34 lines
864 B
JavaScript
34 lines
864 B
JavaScript
import {mapObject} from '@avocado/core'
|
|
|
|
export function behaviorTypes() {
|
|
return {
|
|
entity: (entity) => {
|
|
const {allTraits} = require('./trait/registrar');
|
|
const Traits = entity
|
|
? Object.values(entity.allTraitInstances()).map((instance) => instance.constructor)
|
|
: allTraits();
|
|
const core = {
|
|
children: {
|
|
invokeHook: {
|
|
type: 'object',
|
|
label: 'Invoke hook.',
|
|
args: [
|
|
['hook', {
|
|
type: 'string',
|
|
}],
|
|
],
|
|
},
|
|
}
|
|
};
|
|
return Traits
|
|
.reduce((r, T) => ({
|
|
...r, children: {
|
|
...r.children,
|
|
...T.behaviorTypes(),
|
|
...mapObject(T.describeState(), (spec) => ({...spec, type: `property|${spec.type}`})),
|
|
},
|
|
}), core);
|
|
},
|
|
};
|
|
}
|