refactor: mixin
This commit is contained in:
parent
2c48d5b808
commit
9dc84ba910
|
@ -12,7 +12,22 @@ export const hooks = {
|
||||||
cache.reset();
|
cache.reset();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoBehavior extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
this.avocado.behavior = {
|
||||||
|
globals: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': async (flecks) => {
|
'@flecks/core.starting': async (flecks) => {
|
||||||
flecks.set('$avocado/behavior.globals', flecks.invokeMerge('@avocado/behavior.globals'));
|
flecks.avocado.behavior.globals = flecks.invokeMerge('@avocado/behavior.globals');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
[Populated]: true,
|
[Populated]: true,
|
||||||
...flecks.get('$avocado/behavior.globals'),
|
...flecks.avocado.behavior,
|
||||||
...locals,
|
...locals,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default (flecks) => class Behaved extends decorate(Trait) {
|
||||||
({
|
({
|
||||||
currentRoutine: this.$$currentRoutine,
|
currentRoutine: this.$$currentRoutine,
|
||||||
} = this.constructor.defaultState());
|
} = this.constructor.defaultState());
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
this.$$context = Script.createContext();
|
this.$$context = Script.createContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ export default (flecks) => class Behaved extends decorate(Trait) {
|
||||||
|
|
||||||
static async loadScripts(scripts, context) {
|
static async loadScripts(scripts, context) {
|
||||||
return mapValuesAsync(scripts, async (codeOrUri) => {
|
return mapValuesAsync(scripts, async (codeOrUri) => {
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
const script = await Script.load(codeOrUri);
|
const script = await Script.load(codeOrUri);
|
||||||
script.context = context;
|
script.context = context;
|
||||||
return script;
|
return script;
|
||||||
|
@ -88,7 +88,7 @@ export default (flecks) => class Behaved extends decorate(Trait) {
|
||||||
|
|
||||||
async load(json) {
|
async load(json) {
|
||||||
await super.load(json);
|
await super.load(json);
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
this.$$context = Script.createContext({
|
this.$$context = Script.createContext({
|
||||||
entity: this.entity,
|
entity: this.entity,
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,11 +10,26 @@ export const hooks = {
|
||||||
Flecks.decorate(require.context('./traits/decorators', false, /\.js$/))
|
Flecks.decorate(require.context('./traits/decorators', false, /\.js$/))
|
||||||
),
|
),
|
||||||
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoDialog extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
this.avocado.dialog = {
|
||||||
|
parser: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': (flecks) => {
|
'@flecks/core.starting': (flecks) => {
|
||||||
const dialogFunctions = flecks.invokeMerge('@avocado/dialog.functions');
|
const dialogFunctions = flecks.invokeMerge('@avocado/dialog.functions');
|
||||||
const resolver = (type) => (dialogFunctions[type] ? dialogFunctions[type] : (i) => i);
|
const resolver = (type) => (dialogFunctions[type] ? dialogFunctions[type] : (i) => i);
|
||||||
flecks.set('$avocado/dialog.parser', async (text) => {
|
flecks.avocado.dialog.parser = async (text) => {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const letters = await Promise.all(
|
const letters = await Promise.all(
|
||||||
parse(text, resolver)
|
parse(text, resolver)
|
||||||
.map((letter) => Entity.load({traits: letter})),
|
.map((letter) => Entity.load({traits: letter})),
|
||||||
|
@ -23,7 +38,7 @@ export const hooks = {
|
||||||
letters,
|
letters,
|
||||||
words: await wordize(letters, flecks),
|
words: await wordize(letters, flecks),
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
},
|
},
|
||||||
'@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)),
|
'@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)),
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default (Trait, flecks) => class DialogInitiator extends Trait {
|
||||||
|
|
||||||
openDialog: async (text) => {
|
openDialog: async (text) => {
|
||||||
if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
if (!this.entity.list) {
|
if (!this.entity.list) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default (flecks) => {
|
||||||
({
|
({
|
||||||
letters: this.$$letters,
|
letters: this.$$letters,
|
||||||
words: this.$$words,
|
words: this.$$words,
|
||||||
} = await flecks.get('$avocado/dialog.parser')(
|
} = await flecks.avocado.dialog.parser(
|
||||||
`<rate frequency={${this.params.rate}}>${text}</rate>`,
|
`<rate frequency={${this.params.rate}}>${text}</rate>`,
|
||||||
));
|
));
|
||||||
if (this.$$letters.length > 0) {
|
if (this.$$letters.length > 0) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const createWord = async (letters, flecks) => {
|
const createWord = async (letters, flecks) => {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const word = await Entity.load({
|
const word = await Entity.load({
|
||||||
traits: {
|
traits: {
|
||||||
DomNode: {
|
DomNode: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export default async (flecks) => {
|
export default async (flecks) => {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
const AllTraits = Object.fromEntries(
|
const AllTraits = Object.fromEntries(
|
||||||
Object.entries(Traits)
|
Object.entries(Traits)
|
||||||
.filter(([key]) => !Number.isInteger(parseInt(key, 10))),
|
.filter(([key]) => !Number.isInteger(parseInt(key, 10))),
|
||||||
|
|
|
@ -25,7 +25,7 @@ const EntityComponent = ({
|
||||||
uri,
|
uri,
|
||||||
}) => {
|
}) => {
|
||||||
const flecks = useFlecks();
|
const flecks = useFlecks();
|
||||||
const {Entity, EntityList} = flecks.avocado.Resources;
|
const {Entity, EntityList} = flecks.avocado.resource.Resources;
|
||||||
const [entity, setEntity] = useState();
|
const [entity, setEntity] = useState();
|
||||||
const dep = uri ? join(uri, path) : path;
|
const dep = uri ? join(uri, path) : path;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {JsonController} from '@avocado/resource/persea';
|
import {JsonController} from '@avocado/resource/persea';
|
||||||
|
|
||||||
export default (buffer, flecks) => {
|
export default (buffer, flecks) => {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const json = Entity.withDefaults(JsonController.fromBuffer(buffer));
|
const json = Entity.withDefaults(JsonController.fromBuffer(buffer));
|
||||||
return {
|
return {
|
||||||
...json,
|
...json,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {JsonController} from '@avocado/resource/persea';
|
import {JsonController} from '@avocado/resource/persea';
|
||||||
|
|
||||||
export default (resource, flecks) => {
|
export default (resource, flecks) => {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const json = Entity.withoutDefaults(resource);
|
const json = Entity.withoutDefaults(resource);
|
||||||
return JsonController.toBuffer({
|
return JsonController.toBuffer({
|
||||||
...json,
|
...json,
|
||||||
|
|
|
@ -60,14 +60,14 @@ const Traits = ({
|
||||||
</button>
|
</button>
|
||||||
</Tab>
|
</Tab>
|
||||||
));
|
));
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
const suggestible = difference(
|
const suggestible = difference(
|
||||||
Object.entries(Traits)
|
Object.entries(Traits)
|
||||||
.filter(([key]) => !Number.isInteger(parseInt(key, 10)))
|
.filter(([key]) => !Number.isInteger(parseInt(key, 10)))
|
||||||
.map(([, {type}]) => type),
|
.map(([, {type}]) => type),
|
||||||
types,
|
types,
|
||||||
);
|
);
|
||||||
const Components = flecks.get('$avocado/traits/persea.components');
|
const {Components} = flecks.avocado.traits.persea;
|
||||||
const tabPanels = types.map((type) => {
|
const tabPanels = types.map((type) => {
|
||||||
const Component = Components[type] || JsonTraitComponent;
|
const Component = Components[type] || JsonTraitComponent;
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default (flecks) => {
|
||||||
await super.acceptPacket(packet);
|
await super.acceptPacket(packet);
|
||||||
const {s13nType} = packet;
|
const {s13nType} = packet;
|
||||||
if ('create' === s13nType) {
|
if ('create' === s13nType) {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const {id} = packet.data.synchronized;
|
const {id} = packet.data.synchronized;
|
||||||
const entity = this.synchronized(Entity.resourceId, id);
|
const entity = this.synchronized(Entity.resourceId, id);
|
||||||
if (entity) {
|
if (entity) {
|
||||||
|
@ -85,7 +85,7 @@ export default (flecks) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.destroyEntities();
|
await this.destroyEntities();
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const entityInstances = await Promise.all(json.map((entity) => Entity.load(entity)));
|
const entityInstances = await Promise.all(json.map((entity) => Entity.load(entity)));
|
||||||
for (let i = 0; i < entityInstances.length; i++) {
|
for (let i = 0; i < entityInstances.length; i++) {
|
||||||
this.addEntity(entityInstances[i]);
|
this.addEntity(entityInstances[i]);
|
||||||
|
@ -105,7 +105,7 @@ export default (flecks) => {
|
||||||
|
|
||||||
packetsFor(informed) {
|
packetsFor(informed) {
|
||||||
const packets = [];
|
const packets = [];
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
// Visible entities.
|
// Visible entities.
|
||||||
const {areaToInform} = informed;
|
const {areaToInform} = informed;
|
||||||
const previousVisibleEntities = this.$$informedEntities.get(informed);
|
const previousVisibleEntities = this.$$informedEntities.get(informed);
|
||||||
|
@ -202,7 +202,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const json = [];
|
const json = [];
|
||||||
for (let i = 0; i < this.$$flatEntities.length; i++) {
|
for (let i = 0; i < this.$$flatEntities.length; i++) {
|
||||||
const entity = this.$$flatEntities[i];
|
const entity = this.$$flatEntities[i];
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async $$addTrait(type, json = {}) {
|
async $$addTrait(type, json = {}) {
|
||||||
const {[type]: Trait} = flecks.get('$avocado/traits.traits');
|
const {[type]: Trait} = flecks.avocado.traits.Traits;
|
||||||
if (!Trait) {
|
if (!Trait) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(`Tried to add trait "${type}" which isn't registered!`);
|
console.error(`Tried to add trait "${type}" which isn't registered!`);
|
||||||
|
@ -150,7 +150,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async addTraits(traits) {
|
async addTraits(traits) {
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
const reorganized = {};
|
const reorganized = {};
|
||||||
const add = (type) => {
|
const add = (type) => {
|
||||||
const deps = Traits[type]?.dependencies() || [];
|
const deps = Traits[type]?.dependencies() || [];
|
||||||
|
@ -192,7 +192,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
createContext(locals = {}) {
|
createContext(locals = {}) {
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
return Script.createContext({
|
return Script.createContext({
|
||||||
...this.contextOrDefault,
|
...this.contextOrDefault,
|
||||||
...locals,
|
...locals,
|
||||||
|
@ -200,7 +200,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
static dependencyTree(types) {
|
static dependencyTree(types) {
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
const tree = new Set(types);
|
const tree = new Set(types);
|
||||||
const checking = types;
|
const checking = types;
|
||||||
while (checking.length > 0) {
|
while (checking.length > 0) {
|
||||||
|
@ -330,7 +330,7 @@ export default (flecks) => {
|
||||||
const implementation = this.$$hooks[hook].find(({type: hookType}) => hookType === type);
|
const implementation = this.$$hooks[hook].find(({type: hookType}) => hookType === type);
|
||||||
this.$$hooks[hook].splice(this.$$hooks[hook].indexOf(implementation), 1);
|
this.$$hooks[hook].splice(this.$$hooks[hook].indexOf(implementation), 1);
|
||||||
}
|
}
|
||||||
const {[type]: Trait} = flecks.get('$avocado/traits.traits');
|
const {[type]: Trait} = flecks.avocado.traits.Traits;
|
||||||
const properties = enumerateTraitAccessorKeys(Trait.prototype);
|
const properties = enumerateTraitAccessorKeys(Trait.prototype);
|
||||||
for (let i = 0; i < properties.length; ++i) {
|
for (let i = 0; i < properties.length; ++i) {
|
||||||
const property = properties[i];
|
const property = properties[i];
|
||||||
|
@ -453,7 +453,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
static withDefaults(json = {}) {
|
static withDefaults(json = {}) {
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
return {
|
return {
|
||||||
...json,
|
...json,
|
||||||
traits: Object.entries(json.traits)
|
traits: Object.entries(json.traits)
|
||||||
|
@ -467,7 +467,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
static withoutDefaults(json) {
|
static withoutDefaults(json) {
|
||||||
const Traits = flecks.get('$avocado/traits.traits');
|
const {Traits} = flecks.avocado.traits;
|
||||||
const without = {
|
const without = {
|
||||||
...json,
|
...json,
|
||||||
traits: Object.entries(json.traits)
|
traits: Object.entries(json.traits)
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default (flecks) => class Alive extends decorate(Trait) {
|
||||||
|
|
||||||
async die() {
|
async die() {
|
||||||
this.entity.emit('startedDying');
|
this.entity.emit('startedDying');
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
const deathScript = await Script.load(this.params.deathScript, this.entity.contextOrDefault);
|
const deathScript = await Script.load(this.params.deathScript, this.entity.contextOrDefault);
|
||||||
await this.entity.addTickingPromise(deathScript.tickingPromise());
|
await this.entity.addTickingPromise(deathScript.tickingPromise());
|
||||||
const died = this.entity.invokeHookFlat('died');
|
const died = this.entity.invokeHookFlat('died');
|
||||||
|
@ -117,7 +117,7 @@ export default (flecks) => class Alive extends decorate(Trait) {
|
||||||
|
|
||||||
async load(json) {
|
async load(json) {
|
||||||
await super.load(json);
|
await super.load(json);
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
this.$$deathCheck = await Script.load(this.params.deathCheck, this.entity.contextOrDefault);
|
this.$$deathCheck = await Script.load(this.params.deathCheck, this.entity.contextOrDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ export default (flecks) => class Spawner extends decorate(Trait) {
|
||||||
const childIndex = this.$$children.length;
|
const childIndex = this.$$children.length;
|
||||||
this.$$children.push(null);
|
this.$$children.push(null);
|
||||||
const list = this.destinationEntityList();
|
const list = this.destinationEntityList();
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
const child = await Entity.load(json);
|
const child = await Entity.load(json);
|
||||||
this.$$children[childIndex] = child;
|
this.$$children[childIndex] = child;
|
||||||
// Listen for destroy event.
|
// Listen for destroy event.
|
||||||
|
|
|
@ -19,7 +19,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -18,7 +18,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -17,7 +17,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
@ -36,7 +36,7 @@ it('can add and remove traits', async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
flecks.set('$avocado/traits.traits.TestTrait', TestTrait);
|
flecks.avocado.traits.Traits['TestTrait'] = TestTrait;
|
||||||
await entity.addTrait('TestTrait');
|
await entity.addTrait('TestTrait');
|
||||||
expect(entity.is('TestTrait')).to.be.true;
|
expect(entity.is('TestTrait')).to.be.true;
|
||||||
entity.removeTrait('TestTrait');
|
entity.removeTrait('TestTrait');
|
||||||
|
@ -55,7 +55,7 @@ it('can add traits asynchronously', async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
flecks.set('$avocado/traits.traits.Async', AsyncTrait);
|
flecks.avocado.traits.Traits['Async'] = AsyncTrait;
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
await Entity.load({
|
await Entity.load({
|
||||||
traits: {
|
traits: {
|
||||||
|
@ -95,8 +95,8 @@ it('can invoke hooks', async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
flecks.set('$avocado/traits.traits.AnotherTrait', AnotherTrait);
|
flecks.avocado.traits.Traits['AnotherTrait'] = AnotherTrait;
|
||||||
flecks.set('$avocado/traits.traits.YetAnotherTrait', YetAnotherTrait);
|
flecks.avocado.traits.Traits['YetAnotherTrait'] = YetAnotherTrait;
|
||||||
const entity = new Entity();
|
const entity = new Entity();
|
||||||
await entity.addTrait('AnotherTrait');
|
await entity.addTrait('AnotherTrait');
|
||||||
await entity.addTrait('YetAnotherTrait');
|
await entity.addTrait('YetAnotherTrait');
|
||||||
|
|
|
@ -17,7 +17,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -17,7 +17,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -17,7 +17,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -17,7 +17,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity} = flecks.avocado.Resources);
|
({Entity} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -19,7 +19,7 @@ beforeEach(async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||||
({Entity, EntityList} = flecks.avocado.Resources);
|
({Entity, EntityList} = flecks.avocado.resource.Resources);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
flecks.destroy();
|
flecks.destroy();
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default (flecks) => class Interactive extends decorate(Trait) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
interact: async (initiator) => {
|
interact: async (initiator) => {
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
const script = await Script.load(this.params.interactScript, {
|
const script = await Script.load(this.params.interactScript, {
|
||||||
entity: this.entity,
|
entity: this.entity,
|
||||||
initiator,
|
initiator,
|
||||||
|
|
|
@ -17,7 +17,7 @@ const Emitter = memo(({
|
||||||
path,
|
path,
|
||||||
}) => {
|
}) => {
|
||||||
const flecks = useFlecks();
|
const flecks = useFlecks();
|
||||||
const {Emitted} = flecks.get('$avocado/traits.traits');
|
const {Emitted} = flecks.avocado.traits.Traits;
|
||||||
return (
|
return (
|
||||||
<div className="emitter">
|
<div className="emitter">
|
||||||
<JsonTabs
|
<JsonTabs
|
||||||
|
|
|
@ -20,7 +20,7 @@ const Particle = ({
|
||||||
}) => {
|
}) => {
|
||||||
const flecks = useFlecks();
|
const flecks = useFlecks();
|
||||||
const patch = useJsonPatcher();
|
const patch = useJsonPatcher();
|
||||||
const {EntityList} = flecks.avocado.Resources;
|
const {EntityList} = flecks.avocado.resource.Resources;
|
||||||
const entityList = new EntityList();
|
const entityList = new EntityList();
|
||||||
const entityListView = new EntityListView(entityList);
|
const entityListView = new EntityListView(entityList);
|
||||||
entityList.addEntity(entity);
|
entityList.addEntity(entity);
|
||||||
|
|
|
@ -145,7 +145,7 @@ export default (flecks) => class Collider extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushCollisionTickingPromise(codeOrUri, other, incident) {
|
async pushCollisionTickingPromise(codeOrUri, other, incident) {
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
this.entity.addTickingPromise(Script.loadTickingPromise(codeOrUri, {
|
this.entity.addTickingPromise(Script.loadTickingPromise(codeOrUri, {
|
||||||
...this.entity.contextOrDefault,
|
...this.entity.contextOrDefault,
|
||||||
incident,
|
incident,
|
||||||
|
|
|
@ -108,7 +108,7 @@ export default (flecks) => class Emitted extends decorate(Trait) {
|
||||||
if (!this.params.onDead) {
|
if (!this.params.onDead) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {Script} = flecks.avocado.Resources;
|
const {Script} = flecks.avocado.resource.Resources;
|
||||||
this.entity.addTickingPromise(Script.loadTickingPromise(this.params.onDead, {
|
this.entity.addTickingPromise(Script.loadTickingPromise(this.params.onDead, {
|
||||||
...this.entity.contextOrDefault,
|
...this.entity.contextOrDefault,
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default (flecks) => class Emitter extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async emitParticleJson(json) {
|
async emitParticleJson(json) {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
let entity;
|
let entity;
|
||||||
if (this.$$pool.length > 0) {
|
if (this.$$pool.length > 0) {
|
||||||
entity = this.$$pool.pop();
|
entity = this.$$pool.pop();
|
||||||
|
@ -282,7 +282,7 @@ export default (flecks) => class Emitter extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static withDefaults(json = {}) {
|
static withDefaults(json = {}) {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
...this.defaultParamsWith(json.params || {}),
|
...this.defaultParamsWith(json.params || {}),
|
||||||
|
@ -297,7 +297,7 @@ export default (flecks) => class Emitter extends decorate(Trait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static withoutDefaults(json) {
|
static withoutDefaults(json) {
|
||||||
const {Entity} = flecks.avocado.Resources;
|
const {Entity} = flecks.avocado.resource.Resources;
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
...this.defaultParamsWith(json.params || {}),
|
...this.defaultParamsWith(json.params || {}),
|
||||||
|
|
|
@ -18,13 +18,16 @@ export const hooks = {
|
||||||
if (!this.avocado) {
|
if (!this.avocado) {
|
||||||
this.avocado = {};
|
this.avocado = {};
|
||||||
}
|
}
|
||||||
this.avocado.Resources = {};
|
if (!this.avocado.resource) {
|
||||||
|
this.avocado.resource = {};
|
||||||
|
}
|
||||||
|
this.avocado.resource.Resources = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
'@flecks/core.starting': (flecks) => {
|
'@flecks/core.starting': (flecks) => {
|
||||||
flecks.avocado.Resources = flecks.gather(
|
flecks.avocado.resource.Resources = flecks.gather(
|
||||||
'@avocado/resource.resources',
|
'@avocado/resource.resources',
|
||||||
{
|
{
|
||||||
idProperty: 'resourceId',
|
idProperty: 'resourceId',
|
||||||
|
|
|
@ -2,6 +2,6 @@ import {useFlecks} from '@flecks/react';
|
||||||
|
|
||||||
export default (uri) => (
|
export default (uri) => (
|
||||||
useFlecks()
|
useFlecks()
|
||||||
.get('$avocado/resource/persea.controllers')
|
.avocado.resource.persea.Controllers
|
||||||
.find(({matcher}) => uri.match(matcher))
|
.find(({matcher}) => uri.match(matcher))
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,6 +22,24 @@ export {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const hooks = {
|
export const hooks = {
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoResourcePersea extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
if (!this.avocado.resource) {
|
||||||
|
this.avocado.resource = {};
|
||||||
|
}
|
||||||
|
this.avocado.resource.persea = {
|
||||||
|
Controllers: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': async (flecks) => {
|
'@flecks/core.starting': async (flecks) => {
|
||||||
const Controllers = (
|
const Controllers = (
|
||||||
await flecks.invokeSequentialAsync('@avocado/resource/persea.controllers')
|
await flecks.invokeSequentialAsync('@avocado/resource/persea.controllers')
|
||||||
|
@ -31,7 +49,7 @@ export const hooks = {
|
||||||
TextController,
|
TextController,
|
||||||
BinaryController,
|
BinaryController,
|
||||||
);
|
);
|
||||||
flecks.set('$avocado/resource/persea.controllers', Controllers);
|
this.avocado.resource.persea.Controllers = Controllers;
|
||||||
},
|
},
|
||||||
'@flecks/redux.reducers': () => reducer,
|
'@flecks/redux.reducers': () => reducer,
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default (flecks) => (Resource) => (
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSynchronized(type, id, json) {
|
async createSynchronized(type, id, json) {
|
||||||
const {[type]: Resource} = flecks.avocado.Resources;
|
const {[type]: Resource} = flecks.avocado.resource.Resources;
|
||||||
if (!(type in this.$$synchronized)) {
|
if (!(type in this.$$synchronized)) {
|
||||||
this.$$synchronized[type] = {};
|
this.$$synchronized[type] = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {
|
||||||
const AnimationVisualization = ({json}) => {
|
const AnimationVisualization = ({json}) => {
|
||||||
const flecks = useFlecks();
|
const flecks = useFlecks();
|
||||||
// const {uuid} = useParams();
|
// const {uuid} = useParams();
|
||||||
const {Animation} = flecks.avocado.Resources;
|
const {Animation} = flecks.avocado.resource.Resources;
|
||||||
const [animations, setAnimations] = useState([]);
|
const [animations, setAnimations] = useState([]);
|
||||||
const [container] = useState(new Container());
|
const [container] = useState(new Container());
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const Animation = ({
|
||||||
if (!fullJson) {
|
if (!fullJson) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {Animation} = flecks.avocado.Resources;
|
const {Animation} = flecks.avocado.resource.Resources;
|
||||||
const loadJson = async () => {
|
const loadJson = async () => {
|
||||||
const animationView = new AnimationView(await Animation.load(fullJson));
|
const animationView = new AnimationView(await Animation.load(fullJson));
|
||||||
const drawCross = (primitives, origin, color) => {
|
const drawCross = (primitives, origin, color) => {
|
||||||
|
|
|
@ -192,7 +192,7 @@ export default (flecks) => class Animated extends decorate(Trait) {
|
||||||
async load(json) {
|
async load(json) {
|
||||||
await super.load(json);
|
await super.load(json);
|
||||||
if (Object.keys(this.params.animations).length > 0) {
|
if (Object.keys(this.params.animations).length > 0) {
|
||||||
const {Animation} = flecks.avocado.Resources;
|
const {Animation} = flecks.avocado.resource.Resources;
|
||||||
const animations = await mapValuesAsync(
|
const animations = await mapValuesAsync(
|
||||||
this.params.animations,
|
this.params.animations,
|
||||||
(json) => Animation.load(json),
|
(json) => Animation.load(json),
|
||||||
|
|
|
@ -41,14 +41,14 @@ const RoomComponent = ({
|
||||||
const {uri, uuid} = useContext(Context);
|
const {uri, uuid} = useContext(Context);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const flecks = useFlecks();
|
const flecks = useFlecks();
|
||||||
const {Room, Tiles} = flecks.avocado.Resources;
|
const {Room, Tiles} = flecks.avocado.resource.Resources;
|
||||||
const previousResource = usePrevious(resource);
|
const previousResource = usePrevious(resource);
|
||||||
const [events, setEvents] = useState();
|
const [events, setEvents] = useState();
|
||||||
const [scale, setScale] = useState(3);
|
const [scale, setScale] = useState(3);
|
||||||
const [side, setSide] = useState(0);
|
const [side, setSide] = useState(0);
|
||||||
const [room, setRoom] = useState();
|
const [room, setRoom] = useState();
|
||||||
const [roomRenderable, setRoomRenderable] = useState();
|
const [roomRenderable, setRoomRenderable] = useState();
|
||||||
const roomSides = flecks.get('$avocado/topdown/persea.room-sides');
|
const {RoomSides} = flecks.avocado.topdown.persea;
|
||||||
// Stage event stream.
|
// Stage event stream.
|
||||||
const onRef = useCallback((stage) => {
|
const onRef = useCallback((stage) => {
|
||||||
setEvents(stage?.events());
|
setEvents(stage?.events());
|
||||||
|
@ -236,7 +236,7 @@ const RoomComponent = ({
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
React.createElement(
|
React.createElement(
|
||||||
roomSides[side],
|
RoomSides[side],
|
||||||
{
|
{
|
||||||
active: true,
|
active: true,
|
||||||
events,
|
events,
|
||||||
|
|
|
@ -10,11 +10,28 @@ export const hooks = {
|
||||||
'@avocado/resource/persea.controllers': () => [
|
'@avocado/resource/persea.controllers': () => [
|
||||||
RoomController,
|
RoomController,
|
||||||
],
|
],
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoTopdownPersea extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
if (!this.avocado.topdown) {
|
||||||
|
this.avocado.topdown = {};
|
||||||
|
}
|
||||||
|
this.avocado.topdown.persea = {
|
||||||
|
RoomSides: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': (flecks) => {
|
'@flecks/core.starting': (flecks) => {
|
||||||
flecks.set(
|
flecks.avocado.topdown.persea.RoomSides = flecks.invokeFlat(
|
||||||
'$avocado/topdown/persea.room-sides',
|
'@avocado/topdown/persea.room-sides',
|
||||||
flecks.invokeFlat('@avocado/topdown/persea.room-sides').flat(),
|
).flat();
|
||||||
);
|
|
||||||
},
|
},
|
||||||
'@avocado/topdown/persea.room-sides': () => [
|
'@avocado/topdown/persea.room-sides': () => [
|
||||||
TilesSide,
|
TilesSide,
|
||||||
|
|
|
@ -448,7 +448,7 @@ function TilesPage({
|
||||||
<VectorComponent
|
<VectorComponent
|
||||||
disabled={!resource.tiles[currentLayer]}
|
disabled={!resource.tiles[currentLayer]}
|
||||||
onChange={(event, newArea) => {
|
onChange={(event, newArea) => {
|
||||||
const {Tiles} = flecks.avocado.Resources;
|
const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// Create new tiles.
|
// Create new tiles.
|
||||||
const newTiles = new Tiles();
|
const newTiles = new Tiles();
|
||||||
newTiles.area = newArea;
|
newTiles.area = newArea;
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default (flecks) => {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.$$s13nId = s13nId++;
|
this.$$s13nId = s13nId++;
|
||||||
const {EntityList} = flecks.avocado.Resources;
|
const {EntityList} = flecks.avocado.resource.Resources;
|
||||||
this.entityList = new EntityList();
|
this.entityList = new EntityList();
|
||||||
this.entityList.on('entityAdded', this.onEntityAdded, this);
|
this.entityList.on('entityAdded', this.onEntityAdded, this);
|
||||||
this.entityList.on('entityRemoved', this.onEntityRemoved, this);
|
this.entityList.on('entityRemoved', this.onEntityRemoved, this);
|
||||||
|
@ -66,7 +66,7 @@ export default (flecks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadTiles(tiles) {
|
async loadTiles(tiles) {
|
||||||
const {Tiles} = flecks.avocado.Resources;
|
const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
this.removeAllTiles();
|
this.removeAllTiles();
|
||||||
(await Promise.all(tiles.map((json, i) => Tiles.load({s13nId: i, ...json}))))
|
(await Promise.all(tiles.map((json, i) => Tiles.load({s13nId: i, ...json}))))
|
||||||
.forEach((tiles) => {
|
.forEach((tiles) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||||
// });
|
// });
|
||||||
// it('has sane defaults', async () => {
|
// it('has sane defaults', async () => {
|
||||||
// const {Layer} = flecks.avocado.Resources;
|
// const {Layer} = flecks.avocado.resource.Resources;
|
||||||
// const layer = new Layer();
|
// const layer = new Layer();
|
||||||
// expect(Object.keys(layer.entities).length).to.equal(0);
|
// expect(Object.keys(layer.entities).length).to.equal(0);
|
||||||
// expect(layer.tiles.size).to.deep.equal([0, 0]);
|
// expect(layer.tiles.size).to.deep.equal([0, 0]);
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
||||||
// });
|
// });
|
||||||
// it("has sane defaults", async () => {
|
// it("has sane defaults", async () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const tiles = new Tiles();
|
// const tiles = new Tiles();
|
||||||
// expect(tiles.size).to.deep.equal([0, 0]);
|
// expect(tiles.size).to.deep.equal([0, 0]);
|
||||||
// expect(tiles.data.length).to.equal(0);
|
// expect(tiles.data.length).to.equal(0);
|
||||||
// });
|
// });
|
||||||
// it("gets and sets tile data", async () => {
|
// it("gets and sets tile data", async () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const tiles = new Tiles({data: [0, 1, 2, 3], size: [2, 2]});
|
// const tiles = new Tiles({data: [0, 1, 2, 3], size: [2, 2]});
|
||||||
// expect(tiles.tileAt([0, 0])).to.equal(0);
|
// expect(tiles.tileAt([0, 0])).to.equal(0);
|
||||||
// expect(tiles.tileAt([1, 0])).to.equal(1);
|
// expect(tiles.tileAt([1, 0])).to.equal(1);
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
// expect(tiles.data).to.deep.equal([69, 420, 311, 42]);
|
// expect(tiles.data).to.deep.equal([69, 420, 311, 42]);
|
||||||
// });
|
// });
|
||||||
// it("can get a data slice", async () => {
|
// it("can get a data slice", async () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const tiles = new Tiles(
|
// const tiles = new Tiles(
|
||||||
// {
|
// {
|
||||||
// data: [
|
// data: [
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
// expect(tiles.slice([1, 1, 0, 0])).to.deep.equal([]);
|
// expect(tiles.slice([1, 1, 0, 0])).to.deep.equal([]);
|
||||||
// });
|
// });
|
||||||
// it("can get convex hulls around indices", () => {
|
// it("can get convex hulls around indices", () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const hulls = [
|
// const hulls = [
|
||||||
// [
|
// [
|
||||||
// [2, 0],
|
// [2, 0],
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
// expect(tiles.indexHulls(new Set([1]))).to.deep.equal(hulls);
|
// expect(tiles.indexHulls(new Set([1]))).to.deep.equal(hulls);
|
||||||
// });
|
// });
|
||||||
// it("can stamp at", async () => {
|
// it("can stamp at", async () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const tiles = new Tiles(
|
// const tiles = new Tiles(
|
||||||
// {
|
// {
|
||||||
// data: [
|
// data: [
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
// ]);
|
// ]);
|
||||||
// });
|
// });
|
||||||
// it("can handle pathological hulls", () => {
|
// it("can handle pathological hulls", () => {
|
||||||
// const {Tiles} = flecks.avocado.Resources;
|
// const {Tiles} = flecks.avocado.resource.Resources;
|
||||||
// const hulls = [
|
// const hulls = [
|
||||||
// [
|
// [
|
||||||
// [ 0, 0 ],
|
// [ 0, 0 ],
|
||||||
|
|
|
@ -2,7 +2,22 @@ export {default as Trait} from './trait';
|
||||||
export {default as StateProperty} from './state-property';
|
export {default as StateProperty} from './state-property';
|
||||||
|
|
||||||
export const hooks = {
|
export const hooks = {
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoTraitrs extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
this.avocado.traits = {
|
||||||
|
Traits: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': (flecks) => {
|
'@flecks/core.starting': (flecks) => {
|
||||||
flecks.set('$avocado/traits.traits', flecks.gather('@avocado/traits.traits'));
|
flecks.avocado.traits.Traits = flecks.gather('@avocado/traits.traits');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
export const hooks = {
|
export const hooks = {
|
||||||
|
'@flecks/core.mixin': (Flecks) => (
|
||||||
|
class FlecksWithAvocadoTraitrs extends Flecks {
|
||||||
|
|
||||||
|
constructor(...args) {
|
||||||
|
super(...args);
|
||||||
|
if (!this.avocado) {
|
||||||
|
this.avocado = {};
|
||||||
|
}
|
||||||
|
if (!this.avocado.traits) {
|
||||||
|
this.avocado.traits = {};
|
||||||
|
}
|
||||||
|
this.avocado.traits.persea = {
|
||||||
|
Components: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
),
|
||||||
'@flecks/core.starting': async (flecks) => {
|
'@flecks/core.starting': async (flecks) => {
|
||||||
flecks.set(
|
flecks.avocado.traits.persea.Components = flecks.invokeMerge(
|
||||||
'$avocado/traits/persea.components',
|
'@avocado/traits/persea.components',
|
||||||
flecks.invokeMerge('@avocado/traits/persea.components'),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user