diff --git a/packages/app/src/client/index.js b/packages/app/src/client/index.js index eaa3379..5015b61 100644 --- a/packages/app/src/client/index.js +++ b/packages/app/src/client/index.js @@ -3,24 +3,6 @@ import {Flecks} from '@flecks/core'; import Receiver from './receiver'; export const hooks = { - '@flecks/core.mixin': (Flecks) => ( - class FlecksWithHumusAppClient extends Flecks { - - constructor(...args) { - super(...args); - if (!this.humus) { - this.humus = {}; - } - if (!this.humus.app) { - this.humus.app = {}; - } - this.humus.app.room = undefined; - this.humus.app.selfEntity = undefined; - this.humus.app.synchronizer = undefined; - } - - } - ), '@flecks/web/client.up': Flecks.priority( (flecks) => { window.flecks = flecks; @@ -32,3 +14,20 @@ export const hooks = { {after: '@flecks/socket/client'}, ), }; + +export const mixin = (Flecks) => class FlecksWithHumusAppClient extends Flecks { + + constructor(...args) { + super(...args); + if (!this.humus) { + this.humus = {}; + } + if (!this.humus.app) { + this.humus.app = {}; + } + this.humus.app.room = undefined; + this.humus.app.selfEntity = undefined; + this.humus.app.synchronizer = undefined; + } + +}; diff --git a/packages/combat/src/index.js b/packages/combat/src/index.js index 24ebe3f..9536fc7 100644 --- a/packages/combat/src/index.js +++ b/packages/combat/src/index.js @@ -3,23 +3,6 @@ import flatten from 'lodash.flatten'; export const hooks = { '@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)), - '@flecks/core.mixin': (Flecks) => ( - class FlecksWithHumusCombat extends Flecks { - - constructor(...args) { - super(...args); - if (!this.humus) { - this.humus = {}; - } - if (!this.humus.combat) { - this.humus.combat = {}; - } - this.humus.combat.Affinities = {}; - this.humus.combat.interactions = () => {}; - } - - } - ), '@humus/combat.affinities': () => ({ Void: Class, Bio: Class, @@ -60,3 +43,19 @@ export const hooks = { }, '@flecks/socket.packets': Flecks.provide(require.context('./packets', false, /\.js$/)), }; + +export const mixin = (Flecks) => class FlecksWithHumusCombat extends Flecks { + + constructor(...args) { + super(...args); + if (!this.humus) { + this.humus = {}; + } + if (!this.humus.combat) { + this.humus.combat = {}; + } + this.humus.combat.Affinities = {}; + this.humus.combat.interactions = () => {}; + } + +}; diff --git a/packages/universe/src/server/index.js b/packages/universe/src/server/index.js index 783d0a5..3f61959 100644 --- a/packages/universe/src/server/index.js +++ b/packages/universe/src/server/index.js @@ -14,23 +14,6 @@ const { const debug = D('@humus/universe/server'); export const hooks = { - '@flecks/core.mixin': (Flecks) => ( - class FlecksWithHumusAppClient extends Flecks { - - constructor(...args) { - super(...args); - if (!this.humus) { - this.humus = {}; - } - if (!this.humus.universe) { - this.humus.universe = {}; - } - this.humus.universe.universe = undefined; - this.humus.universe.resourceServer = undefined; - } - - } - ), '@flecks/core.starting': async (flecks) => { const {resource} = flecks.get('@humus/universe'); const stats = await stat(resource); @@ -41,18 +24,21 @@ export const hooks = { flecks.humus.universe.resourceServer = express.static(resource); debug('resource root: %s', resource); }, - '@flecks/server.up': async (flecks) => { - const {universe: path} = flecks.get('@humus/universe'); - try { - const universe = await Universe.loadFrom(flecks, resolve(FLECKS_CORE_ROOT, path)); - flecks.humus.universe.universe = universe; - universe.start(); - debug('universe up and running!'); - } - catch (error) { - throw new Error(`couldn't run universe: ${error.stack}`); - } - }, + '@flecks/server.up': Flecks.priority( + async (flecks) => { + const {universe: path} = flecks.get('@humus/universe'); + try { + const universe = await Universe.loadFrom(flecks, resolve(FLECKS_CORE_ROOT, path)); + flecks.humus.universe.universe = universe; + universe.start(); + debug('universe up and running!'); + } + catch (error) { + throw new Error(`couldn't run universe: ${error.stack}`); + } + }, + {before: '@flecks/web/server'}, + ), '@flecks/web/server.request.socket': (flecks) => (req, res, next) => { if (req.url.startsWith('/resource')) { req.url = req.url.slice('/resource'.length); @@ -76,3 +62,19 @@ export const hooks = { {after: '@flecks/governor/server'}, ), }; + +export const mixin = (Flecks) => class FlecksWithHumusAppClient extends Flecks { + + constructor(...args) { + super(...args); + if (!this.humus) { + this.humus = {}; + } + if (!this.humus.universe) { + this.humus.universe = {}; + } + this.humus.universe.universe = undefined; + this.humus.universe.resourceServer = undefined; + } + +};