26 lines
655 B
JavaScript
26 lines
655 B
JavaScript
import { has, isObjectLike } from 'lodash-es'
|
|
import { defineNuxtModule, addComponent } from '@nuxt/kit'
|
|
import * as SpeckleUiComponents from '@speckle/ui-components'
|
|
|
|
const isVueComponent = (val) => {
|
|
if (!isObjectLike(val)) return false
|
|
return has(val, '__name')
|
|
}
|
|
|
|
export default defineNuxtModule({
|
|
meta: {
|
|
name: 'speckle-ui-components'
|
|
},
|
|
async setup() {
|
|
// Add all @speckle/ui-components components
|
|
for (const [key, val] of Object.entries(SpeckleUiComponents)) {
|
|
if (!isVueComponent(val)) return
|
|
addComponent({
|
|
name: key,
|
|
filePath: '@speckle/ui-components',
|
|
export: key
|
|
})
|
|
}
|
|
}
|
|
})
|