2020-06-25 07:44:13 -05:00
|
|
|
import {mapObject} from '@avocado/core'
|
|
|
|
|
2020-06-23 11:19:59 -05:00
|
|
|
export function behaviorTypes() {
|
2020-06-19 17:59:14 -05:00
|
|
|
return {
|
2020-06-19 22:01:45 -05:00
|
|
|
entity: (entity) => {
|
2020-06-20 01:40:53 -05:00
|
|
|
const {allTraits} = require('./trait/registrar');
|
|
|
|
const Traits = entity
|
|
|
|
? Object.values(entity.allTraitInstances()).map((instance) => instance.constructor)
|
|
|
|
: allTraits();
|
2020-06-22 16:53:49 -05:00
|
|
|
const core = {
|
|
|
|
children: {
|
|
|
|
invokeHook: {
|
|
|
|
type: 'object',
|
|
|
|
label: 'Invoke hook.',
|
|
|
|
args: [
|
|
|
|
['hook', {
|
|
|
|
type: 'string',
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|
2020-06-19 22:01:45 -05:00
|
|
|
};
|
2020-06-22 16:53:49 -05:00
|
|
|
return Traits
|
|
|
|
.reduce((r, T) => ({
|
2020-06-25 07:44:13 -05:00
|
|
|
...r, children: {
|
|
|
|
...r.children,
|
|
|
|
...T.behaviorTypes(),
|
|
|
|
...mapObject(T.describeState(), (spec) => ({...spec, type: `property|${spec.type}`})),
|
|
|
|
},
|
2020-06-22 16:53:49 -05:00
|
|
|
}), core);
|
2020-06-19 22:01:45 -05:00
|
|
|
},
|
2020-06-19 17:59:14 -05:00
|
|
|
};
|
|
|
|
}
|