refactor: mixin
This commit is contained in:
parent
061f5e53a1
commit
37d9a22479
|
@ -19,6 +19,7 @@ import enhancedResolve from 'enhanced-resolve';
|
|||
import {dump as dumpYml, load as loadYml} from 'js-yaml';
|
||||
import {addHook} from 'pirates';
|
||||
|
||||
import compose from '../compose';
|
||||
import D from '../debug';
|
||||
import Flecks from '../flecks';
|
||||
import R from '../require';
|
||||
|
@ -124,13 +125,13 @@ export default class ServerFlecks extends Flecks {
|
|||
const rcs = this.loadRcs(resolver);
|
||||
this.installCompilers(rcs, resolver);
|
||||
// Load the flecks.
|
||||
const flecks = Object.fromEntries(
|
||||
Object.keys(resolver)
|
||||
.map((path) => [path, R(this.resolve(resolver, path))]),
|
||||
);
|
||||
return new ServerFlecks({
|
||||
const entries = Object.keys(resolver).map((path) => [path, R(this.resolve(resolver, path))]);
|
||||
// Flecks mixins.
|
||||
const mixins = entries.map(([, M]) => M.hooks?.['@flecks/core.mixin']).filter((e) => e);
|
||||
const Class = compose(...mixins)(ServerFlecks);
|
||||
return new Class({
|
||||
config,
|
||||
flecks,
|
||||
flecks: Object.fromEntries(entries),
|
||||
platforms,
|
||||
rcs,
|
||||
resolver,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {D, Flecks} from '@flecks/core';
|
||||
import {compose, D, Flecks} from '@flecks/core';
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
|
||||
const {version} = require('@flecks/web/package.json');
|
||||
|
@ -52,7 +52,12 @@ const {version} = require('@flecks/web/package.json');
|
|||
const runtime = await loader(progress.update.bind(progress));
|
||||
progress.finish();
|
||||
debug('starting client...');
|
||||
const flecks = new Flecks(runtime);
|
||||
// Flecks mixins.
|
||||
const mixins = Object.entries(runtime.flecks)
|
||||
.map(([, M]) => M.hooks?.['@flecks/core.mixin'])
|
||||
.filter((e) => e);
|
||||
const Class = compose(...mixins)(Flecks);
|
||||
const flecks = new Class(runtime);
|
||||
window.flecks = flecks;
|
||||
try {
|
||||
await Promise.all(flecks.invokeFlat('@flecks/core.starting'));
|
||||
|
|
Loading…
Reference in New Issue
Block a user