fix: mixin

This commit is contained in:
cha0s 2024-01-05 22:49:48 -06:00
parent 9dc84ba910
commit 4c7e83a53e
6 changed files with 20 additions and 18 deletions

View File

@ -49,7 +49,7 @@ export default (flecks) => {
} }
return { return {
[Populated]: true, [Populated]: true,
...flecks.avocado.behavior, ...flecks.avocado.behavior.globals,
...locals, ...locals,
}; };
} }

View File

@ -36,7 +36,7 @@ it('can add and remove traits', async () => {
} }
}; };
flecks.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.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.avocado.traits.Traits['AnotherTrait'] = AnotherTrait; flecks.avocado.traits.Traits.AnotherTrait = AnotherTrait;
flecks.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');

View File

@ -1,4 +1,3 @@
import Renderer from '@avocado/graphics/renderer';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import { import {
forwardRef, forwardRef,
@ -130,7 +129,7 @@ const Stage = forwardRef(({
Stage.defaultProps = { Stage.defaultProps = {
centered: true, centered: true,
renderer: new Renderer([0, 0]), renderer: undefined,
scale: 1, scale: 1,
styles: { styles: {
canvas: '', canvas: '',

View File

@ -33,9 +33,10 @@ export const hooks = {
if (!this.avocado.resource) { if (!this.avocado.resource) {
this.avocado.resource = {}; this.avocado.resource = {};
} }
this.avocado.resource.persea = { if (!this.avocado.resource.persea) {
Controllers: {}, this.avocado.resource.persea = {};
}; }
this.avocado.resource.persea.Controllers = {};
} }
} }
@ -49,7 +50,7 @@ export const hooks = {
TextController, TextController,
BinaryController, BinaryController,
); );
this.avocado.resource.persea.Controllers = Controllers; flecks.avocado.resource.persea.Controllers = Controllers;
}, },
'@flecks/redux.reducers': () => reducer, '@flecks/redux.reducers': () => reducer,
}; };

View File

@ -10,9 +10,10 @@ export const hooks = {
if (!this.avocado) { if (!this.avocado) {
this.avocado = {}; this.avocado = {};
} }
this.avocado.traits = { if (!this.avocado.traits) {
Traits: {}, this.avocado.traits = {};
}; }
this.avocado.traits.Traits = {};
} }
} }

View File

@ -1,6 +1,6 @@
export const hooks = { export const hooks = {
'@flecks/core.mixin': (Flecks) => ( '@flecks/core.mixin': (Flecks) => (
class FlecksWithAvocadoTraitrs extends Flecks { class FlecksWithAvocadoTraits extends Flecks {
constructor(...args) { constructor(...args) {
super(...args); super(...args);
@ -10,9 +10,10 @@ export const hooks = {
if (!this.avocado.traits) { if (!this.avocado.traits) {
this.avocado.traits = {}; this.avocado.traits = {};
} }
this.avocado.traits.persea = { if (!this.avocado.traits.persea) {
Components: {}, this.avocado.traits.persea = {};
}; }
this.avocado.traits.persea.Components = {};
} }
} }