more progressive style, flow, and separation refactoring

This commit is contained in:
Stewart Allen 2022-02-17 17:55:26 -05:00
commit addcfdde3e
16 changed files with 1097 additions and 1120 deletions

View file

@ -143,7 +143,7 @@ async function slice(points, options = {}) {
zScale = 1 / (zSpan / bucketCount); zScale = 1 / (zSpan / bucketCount);
if (true || debug) { if (debug) {
console.log({ console.log({
zMin, zMax, zIndexes, zScale, zSum, zSpanAvg, zMin, zMax, zIndexes, zScale, zSum, zSpanAvg,
points, bucketCount, points, bucketCount,

View file

@ -2,7 +2,7 @@
"use strict"; "use strict";
self.kiri.loader.push(function() { kiri.load(function() {
let KIRI = self.kiri, let KIRI = self.kiri,
CAM = KIRI.driver.CAM, CAM = KIRI.driver.CAM,
@ -25,8 +25,9 @@ self.kiri.loader.push(function() {
if (KIRI.client) if (KIRI.client)
CAM.animate_clear = function(api) { CAM.animate_clear = function(api) {
API = api;
KIRI.client.animate_cleanup(); KIRI.client.animate_cleanup();
SPACE = (API = api).const.SPACE; SPACE = KIRI.space;
WORLD = SPACE.world; WORLD = SPACE.world;
$('layer-animate').innerHTML = ''; $('layer-animate').innerHTML = '';
$('layer-toolpos').innerHTML = ''; $('layer-toolpos').innerHTML = '';

View file

@ -22,7 +22,6 @@
let zaxis = { x: 0, y: 0, z: 1 }, let zaxis = { x: 0, y: 0, z: 1 },
popOp = {}, popOp = {},
noop = () => {},
func = { func = {
hover: noop, hover: noop,
hoverUp: noop hoverUp: noop
@ -35,10 +34,10 @@
FDM = KIRI.driver.FDM; FDM = KIRI.driver.FDM;
// console.log({kiri,api}) // console.log({kiri,api})
SPACE = kiri.space;
MODES = kiri.consts.MODES;
VIEWS = kiri.consts.VIEWS;
STACKS = api.const.STACKS; STACKS = api.const.STACKS;
SPACE = api.const.SPACE;
MODES = api.const.MODES;
VIEWS = api.const.VIEWS;
LANG = api.const.LANG; LANG = api.const.LANG;
UI = api.ui; UI = api.ui;
UC = api.uc; UC = api.uc;

View file

@ -22,7 +22,7 @@
}; };
// defer loading until KIRI.client and KIRI.worker exist // defer loading until KIRI.client and KIRI.worker exist
KIRI.loader.push(function(API) { KIRI.load(function(API) {
if (KIRI.client) if (KIRI.client)
CAM.traces = function(ondone, single) { CAM.traces = function(ondone, single) {

View file

@ -14,8 +14,7 @@
newLine = BASE.newLine, newLine = BASE.newLine,
newSlope = BASE.newSlope, newSlope = BASE.newSlope,
newPoint = BASE.newPoint, newPoint = BASE.newPoint,
newPolygon = BASE.newPolygon, newPolygon = BASE.newPolygon;
noop = function() {};
class Topo { class Topo {
constructor(opt = {}) { constructor(opt = {}) {

View file

@ -24,8 +24,8 @@
UI = api.ui; UI = api.ui;
UC = api.uc; UC = api.uc;
API = api; API = api;
SPACE = api.const.SPACE; SPACE = kiri.space;
VIEWS = api.const.VIEWS; VIEWS = kiri.consts.VIEWS;
LANG = KIRI.lang.current; LANG = KIRI.lang.current;
PROC = Object.keys(kiri.conf.defaults.fdm.p); PROC = Object.keys(kiri.conf.defaults.fdm.p);
@ -79,7 +79,7 @@
function filterSynth() { function filterSynth() {
api.widgets.filter((widget) => { api.widgets.filter((widget) => {
if (widget.track.synth) { if (widget.track.synth) {
api.const.SPACE.world.remove(widget.mesh); kiri.space.world.remove(widget.mesh);
kiri.Widget.Groups.remove(widget); kiri.Widget.Groups.remove(widget);
} }
return !widget.track.synth return !widget.track.synth
@ -295,7 +295,7 @@
sw._move(fwp.x, fwp.y, fwp.z); sw._move(fwp.x, fwp.y, fwp.z);
api.widgets.add(sw); api.widgets.add(sw);
sw.track.synth = true; sw.track.synth = true;
api.const.SPACE.world.add(sw.mesh); KIRI.space.world.add(sw.mesh);
} }
}); });
api.event.on("slice.end", () => { api.event.on("slice.end", () => {

View file

@ -37,7 +37,7 @@
} }
// defer loading until KIRI.client and KIRI.worker exist // defer loading until KIRI.client and KIRI.worker exist
KIRI.loader.push(function(API) { KIRI.load(function(API) {
if (KIRI.client) if (KIRI.client)
// FDM.support_generate = KIRI.client.fdm_support_generate = function(ondone) { // FDM.support_generate = KIRI.client.fdm_support_generate = function(ondone) {

View file

@ -4,19 +4,14 @@
(function() { (function() {
const KIRI = self.kiri, const { base, kiri } = self;
BASE = self.base, const { driver, fill, fill_fixed, newSlice, utils } = kiri;
POLY = BASE.polygons, const { config, polygons, util, newPoint } = base;
UTIL = BASE.util, const { fillArea } = polygons;
CONF = BASE.config, const { FDM } = driver;
FDM = KIRI.driver.FDM,
SLICER = KIRI.slicer, const POLY = polygons,
fillArea = POLY.fillArea, tracker = util.pwait,
newPoint = BASE.newPoint,
newSlice = KIRI.newSlice,
tracker = UTIL.pwait,
FILL = KIRI.fill,
FILLFIXED = KIRI.fill_fixed,
lopacity = 0.6, lopacity = 0.6,
opacity = 1, opacity = 1,
COLOR = { COLOR = {
@ -29,7 +24,6 @@
}, },
PROTO = Object.clone(COLOR), PROTO = Object.clone(COLOR),
getRangeParameters = FDM.getRangeParameters, getRangeParameters = FDM.getRangeParameters,
noop = function() {},
profile = false, profile = false,
profileStart = profile ? console.profile : noop, profileStart = profile ? console.profile : noop,
profileEnd = profile ? console.profileEnd : noop, profileEnd = profile ? console.profileEnd : noop,
@ -56,19 +50,22 @@
* that will not quickly encode in threaded mode. add to existing * that will not quickly encode in threaded mode. add to existing
* data object. return is ignored. * data object. return is ignored.
*/ */
BASE.slicePost.FDM = function(data, options) { base.slicePost.FDM = function(data, options) {
let { z, lines, groups } = data; const { z, lines, groups } = data;
let { useAssembly, post_args, index } = options; const { useAssembly, post_args, index } = options;
let { process, isSynth, isDanger, vaseMode } = post_args; const { process, isSynth, isDanger, vaseMode } = post_args;
let { shellOffset, fillOffset, clipOffset } = post_args; const { shellOffset, fillOffset, clipOffset } = post_args;
const tops = POLY.nest(groups);
if (isSynth) { if (isSynth) {
// do not shell synth widgets because // do not shell synth widgets because
// they will be clipped against peers later // they will be clipped against peers later
// which requires shelling post-clip // which requires shelling post-clip
// but we still need to generate tops
data.tops = tops;
delete data.groups;
return; return;
} }
let tops = POLY.nest(groups); const range = FDM.getRangeParameters(process, index);
let range = FDM.getRangeParameters(process, index);
// calculate fractional shells // calculate fractional shells
let shellFrac = (range.sliceShells - (range.sliceShells | 0)); let shellFrac = (range.sliceShells - (range.sliceShells | 0));
let sliceShells = range.sliceShells | 0; let sliceShells = range.sliceShells | 0;
@ -80,13 +77,13 @@
let trg = shellFrac > 0.5 ? 1 : parts - 1; let trg = shellFrac > 0.5 ? 1 : parts - 1;
sliceShells += rem >= trg ? 1 : 0; sliceShells += rem >= trg ? 1 : 0;
} }
let isFirst = index === 0; const isFirst = index === 0;
let height = process.sliceHeight; const height = process.sliceHeight;
let spaceMult = isFirst ? process.firstLayerLineMult || 1 : 1; const spaceMult = isFirst ? process.firstLayerLineMult || 1 : 1;
let count = isSynth ? 1 : sliceShells; const count = isSynth ? 1 : sliceShells;
let offset = shellOffset * spaceMult; const offset = shellOffset * spaceMult;
let fillOff = fillOffset * spaceMult; const fillOff = fillOffset * spaceMult;
let nutops = []; const nutops = [];
// co-locate shell processing with top generation in slicer // co-locate shell processing with top generation in slicer
for (let top of tops) { for (let top of tops) {
nutops.push(FDM.share.doTopShells(z, top, count, offset/2, offset, fillOff, { nutops.push(FDM.share.doTopShells(z, top, count, offset/2, offset, fillOff, {
@ -103,7 +100,7 @@
FDM.sliceAll = function(settings, onupdate) { FDM.sliceAll = function(settings, onupdate) {
// future home of brim and anchor generation // future home of brim and anchor generation
let widgets = Object.values(KIRI.worker.cache) let widgets = Object.values(kiri.worker.cache)
.filter(w => !w.meta.disabled) .filter(w => !w.meta.disabled)
.sort((a,b) => { .sort((a,b) => {
return a.slices[0].z - b.slices[0].z return a.slices[0].z - b.slices[0].z
@ -147,7 +144,7 @@
isSynth = widget.track.synth, isSynth = widget.track.synth,
isDanger = controller.danger, isDanger = controller.danger,
useAssembly = controller.assembly, useAssembly = controller.assembly,
isConcurrent = controller.threaded && KIRI.minions.concurrent, isConcurrent = controller.threaded && kiri.minions.concurrent,
solidMinArea = process.sliceSolidMinArea, solidMinArea = process.sliceSolidMinArea,
solidLayers = process.sliceSolidLayers || 0, solidLayers = process.sliceSolidLayers || 0,
vaseMode = process.sliceFillType === 'vase' && !isSynth, vaseMode = process.sliceFillType === 'vase' && !isSynth,
@ -233,7 +230,7 @@
} }
} }
BASE.slice(points, { base.slice(points, {
debug: process.xray, debug: process.xray,
xray: process.xray, xray: process.xray,
zMin: bounds.min.z, zMin: bounds.min.z,
@ -335,7 +332,7 @@
}, },
// slicer function (worker local or minion distributed) // slicer function (worker local or minion distributed)
slicer(z, points, opts) { slicer(z, points, opts) {
return (isConcurrent ? KIRI.minions.sliceZ : BASE.sliceZ)(z, points, opts); return (isConcurrent ? kiri.minions.sliceZ : base.sliceZ)(z, points, opts);
}, },
onupdate(update) { onupdate(update) {
return onupdate(0.0 + update * 0.5) return onupdate(0.0 + update * 0.5)
@ -344,6 +341,7 @@
// post process slices and re-incorporate missing meta-data // post process slices and re-incorporate missing meta-data
return output.slices.map(data => { return output.slices.map(data => {
let { z, clip, lines, groups } = data; let { z, clip, lines, groups } = data;
if (!data.tops) return null;
let slice = newSlice(z).addTops(data.tops); let slice = newSlice(z).addTops(data.tops);
slice.index = indices.indexOf(z); slice.index = indices.indexOf(z);
slice.height = heights[slice.index]; slice.height = heights[slice.index];
@ -354,7 +352,7 @@
slice.xray = process.xray; slice.xray = process.xray;
} }
return slice; return slice;
}); }).filter(s => s);
}).then(slices => { }).then(slices => {
return onSliceDone(slices); return onSliceDone(slices);
}).then(ondone); }).then(ondone);
@ -374,7 +372,7 @@
.map(w => w.slices).flat() .map(w => w.slices).flat()
.map(s => s.tops).flat().map(t => t.simple); .map(s => s.tops).flat().map(t => t.simple);
let shadow = isConcurrent ? let shadow = isConcurrent ?
await KIRI.minions.union(alltops, 0.1) : await kiri.minions.union(alltops, 0.1) :
POLY.union(alltops, 0.1, true); POLY.union(alltops, 0.1, true);
// expand shadow when requested (support clipping) // expand shadow when requested (support clipping)
if (process.sliceSupportExtra) { if (process.sliceSupportExtra) {
@ -471,7 +469,7 @@
} }
// do not hint polygon fill longer than a max span length // do not hint polygon fill longer than a max span length
CONF.hint_len_max = UTIL.sqr(process.sliceBridgeMax); config.hint_len_max = util.sqr(process.sliceBridgeMax);
// reset for solids, support projections // reset for solids, support projections
// and other annotations // and other annotations
@ -565,7 +563,7 @@
addto.belt.touch = false; addto.belt.touch = false;
let z = addto.z; let z = addto.z;
let y = z - smin - (nozzleSize / 2); let y = z - smin - (nozzleSize / 2);
let splat = BASE.newPolygon().add(minx, y, z).add(maxx, y, z).setOpen(); let splat = base.newPolygon().add(minx, y, z).add(maxx, y, z).setOpen();
let snew = addto.addTop(splat).fill_sparse = [ splat ]; let snew = addto.addTop(splat).fill_sparse = [ splat ];
adds.push(snew); adds.push(snew);
start = addto; start = addto;
@ -598,7 +596,7 @@
let fz = first.z; let fz = first.z;
let n2 = nozzleSize / 2; let n2 = nozzleSize / 2;
for (let x = mp - dx; x <= mp + dx ; x += 3) { for (let x = mp - dx; x <= mp + dx ; x += 3) {
add.push( BASE.newPolygon().add(x, fy - n2, fz).add(x, fy + y + n2, fz).setOpen() ); add.push( base.newPolygon().add(x, fy - n2, fz).add(x, fy + y + n2, fz).setOpen() );
} }
} }
} }
@ -774,7 +772,7 @@
} }
if (isBelt) { if (isBelt) {
let bounds = BASE.newBounds(); let bounds = base.newBounds();
for (let top of slices[0].tops) { for (let top of slices[0].tops) {
bounds.merge(top.poly.bounds); bounds.merge(top.poly.bounds);
} }
@ -1038,7 +1036,7 @@
// for diffing // for diffing
top.last = last; top.last = last;
// top.last_simple = last.map(p => p.clean(true, undefined, CONF.clipper / 10)); // top.last_simple = last.map(p => p.clean(true, undefined, config.clipper / 10));
return top; return top;
} }
@ -1128,8 +1126,8 @@
}; };
// use specified fill type // use specified fill type
if (type && FILL[type]) { if (type && fill[type]) {
FILL[type](target); fill[type](target);
} else { } else {
console.log({missing_infill: type}); console.log({missing_infill: type});
return; return;
@ -1148,7 +1146,7 @@
// update fill fingerprint for this slice // update fill fingerprint for this slice
slice._fill_finger = POLY.fingerprint(polys); slice._fill_finger = POLY.fingerprint(polys);
let skippable = cache && FILLFIXED[type] ? true : false; let skippable = cache && fill_fixed[type] ? true : false;
let miss = false; let miss = false;
// if the layer below has the same fingerprint, // if the layer below has the same fingerprint,
// we may be able to clone the infill instead of regenerating it // we may be able to clone the infill instead of regenerating it
@ -1214,7 +1212,7 @@
} }
if (options.promises) { if (options.promises) {
options.promises.push(KIRI.minions.clip(slice, polys, lines)); options.promises.push(kiri.minions.clip(slice, polys, lines));
return; return;
} }
@ -1389,7 +1387,7 @@
function doFillArea(fillQ, polys, angle, spacing, output, minLen, maxLen) { function doFillArea(fillQ, polys, angle, spacing, output, minLen, maxLen) {
if (fillQ) { if (fillQ) {
fillQ.push(KIRI.minions.fill(polys, angle, spacing, output, minLen, maxLen)); fillQ.push(kiri.minions.fill(polys, angle, spacing, output, minLen, maxLen));
} else { } else {
POLY.fillArea(polys, angle, spacing, output, minLen, maxLen); POLY.fillArea(polys, angle, spacing, output, minLen, maxLen);
} }
@ -1421,7 +1419,7 @@
// use de-rez'd top shadow instead // use de-rez'd top shadow instead
down_tops = down.topSimples(); down_tops = down.topSimples();
// de-rez trace polys because it's not that important for supports // de-rez trace polys because it's not that important for supports
down_traces = down_traces.map(p => p.clean(true, undefined, CONF.clipper / 10)); down_traces = down_traces.map(p => p.clean(true, undefined, config.clipper / 10));
} }
} }
@ -1488,13 +1486,13 @@
// for each point, create a bounding rectangle // for each point, create a bounding rectangle
points.forEach(function(point) { points.forEach(function(point) {
pillars.push(BASE.newPolygon().centerRectangle(point, size/2, size/2)); pillars.push(base.newPolygon().centerRectangle(point, size/2, size/2));
}); });
supports.appendAll(POLY.union(pillars, null, true, { wasm: false })); supports.appendAll(POLY.union(pillars, null, true, { wasm: false }));
// merge pillars and replace with convex hull of outer points (aka smoothing) // merge pillars and replace with convex hull of outer points (aka smoothing)
pillars = POLY.union(pillars, null, true, { wasm: false }).forEach(function(pillar) { pillars = POLY.union(pillars, null, true, { wasm: false }).forEach(function(pillar) {
supports.push(BASE.newPolygon().createConvexHull(pillar.points)); supports.push(base.newPolygon().createConvexHull(pillar.points));
}); });
})(); })();
@ -1518,7 +1516,7 @@
// then union supports // then union supports
if (supports.length > 10) { if (supports.length > 10) {
supports = await KIRI.minions.union(supports); supports = await kiri.minions.union(supports);
} else { } else {
supports = POLY.union(supports, null, true, { wasm: false }); supports = POLY.union(supports, null, true, { wasm: false });
} }
@ -1657,7 +1655,7 @@
if (bl.del) { if (bl.del) {
continue; continue;
} }
if (UTIL.intersect(al.a, al.b, bl.a, bl.b, BASE.key.SEGINT)) { if (util.intersect(al.a, al.b, bl.a, bl.b, base.key.SEGINT)) {
if (al.l < bl.l) { if (al.l < bl.l) {
bl.del = true; bl.del = true;
} else { } else {
@ -1722,12 +1720,12 @@
let sortz = [p1,p2,p3].sort((a,b) => { return a.z - b.z }); let sortz = [p1,p2,p3].sort((a,b) => { return a.z - b.z });
let xv = fld(sortx, 'x'); let xv = fld(sortx, 'x');
let yv = fld(sorty, 'y'); let yv = fld(sorty, 'y');
let xa = BASE.util.lerp(xv.first.x + s4, xv.last.x - s4, s2, true); let xa = base.util.lerp(xv.first.x + s4, xv.last.x - s4, s2, true);
let ya = BASE.util.lerp(yv.first.y + s4, yv.last.y - s4, s2, true); let ya = base.util.lerp(yv.first.y + s4, yv.last.y - s4, s2, true);
for (let x of xa) { for (let x of xa) {
for (let y of ya) { for (let y of ya) {
if (pointIn(x, y, p1, p2, p3)) { if (pointIn(x, y, p1, p2, p3)) {
let z = BASE.util.zInPlane(p1, p2, p3, x, y); let z = base.util.zInPlane(p1, p2, p3, x, y);
tp(new THREE.Vector3(x, y, z)); tp(new THREE.Vector3(x, y, z));
} }
} }
@ -1736,12 +1734,12 @@
// test poly // test poly
function tP(poly, face) { function tP(poly, face) {
let bounds = poly.bounds; let bounds = poly.bounds;
let xa = BASE.util.lerp(bounds.minx + s4, bounds.maxx - s4, s2, true); let xa = base.util.lerp(bounds.minx + s4, bounds.maxx - s4, s2, true);
let ya = BASE.util.lerp(bounds.miny + s4, bounds.maxy - s4, s2, true); let ya = base.util.lerp(bounds.miny + s4, bounds.maxy - s4, s2, true);
for (let x of xa) { for (let x of xa) {
for (let y of ya) { for (let y of ya) {
if (BASE.newPoint(x, y, 0).isInPolygon(poly)) { if (base.newPoint(x, y, 0).isInPolygon(poly)) {
let z = BASE.util.zInPlane(face[0], face[1], face[2], x, y); let z = base.util.zInPlane(face[0], face[1], face[2], x, y);
tp(new THREE.Vector3(x, y, z)); tp(new THREE.Vector3(x, y, z));
} }
} }
@ -1788,7 +1786,7 @@
continue; continue;
} }
// skip tiny faces // skip tiny faces
let poly = BASE.newPolygon().addPoints([a,b,c].map(v => BASE.newPoint(v.x, v.y, v.z))); let poly = base.newPolygon().addPoints([a,b,c].map(v => base.newPoint(v.x, v.y, v.z)));
if (poly.area() < min && poly.perimeter() < size) { if (poly.area() < min && poly.perimeter() < size) {
continue; continue;
} }
@ -1879,7 +1877,7 @@
// convert groups of faces to contiguous polygon groups // convert groups of faces to contiguous polygon groups
groups = groups.map(group => { groups = groups.map(group => {
let parr = group.map(arr => { let parr = group.map(arr => {
return BASE.newPolygon() return base.newPolygon()
.add(arr[0].x, arr[0].y, arr[0].z) .add(arr[0].x, arr[0].y, arr[0].z)
.add(arr[1].x, arr[1].y, arr[1].z) .add(arr[1].x, arr[1].y, arr[1].z)
.add(arr[2].x, arr[2].y, arr[2].z); .add(arr[2].x, arr[2].y, arr[2].z);

View file

@ -122,12 +122,15 @@ const PMODES = {
TOOLS: 2 TOOLS: 2
}; };
const SEED = 'kiri-seed';
kiri.consts = { kiri.consts = {
PMODES, PMODES,
COLOR, COLOR,
LISTS, LISTS,
MODES, MODES,
VIEWS, VIEWS,
SEED,
}; };
})(); })();

View file

@ -37,7 +37,7 @@ kiri.load(function(API) {
}; };
function updateButtons() { function updateButtons() {
let isArrange = API.view.get() === API.const.VIEWS.ARRANGE; let isArrange = API.view.get() === kiri.consts.VIEWS.ARRANGE;
$('doit').style.display = isArrange && stack.length ? 'flex' : 'none'; $('doit').style.display = isArrange && stack.length ? 'flex' : 'none';
$('undo').disabled = stpos === 0; $('undo').disabled = stpos === 0;
$('redo').disabled = stpos == stack.length; $('redo').disabled = stpos == stack.length;

View file

@ -13,7 +13,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
SDB = API.sdb, SDB = API.sdb,
UI = API.ui, UI = API.ui,
STATS = API.stats, STATS = API.stats,
MODES = API.const.MODES; MODES = KIRI.consts.MODES;
KIRI.export = exportFile; KIRI.export = exportFile;

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,6 @@
SPACE = kiri.space = moto.Space, SPACE = kiri.space = moto.Space,
CATALOG = kiri.catalog = kiri.openCatalog(ODB), CATALOG = kiri.catalog = kiri.openCatalog(ODB),
STATS = new Stats(SDB), STATS = new Stats(SDB),
SEED = 'kiri-seed',
// --------------- // ---------------
CONF = kiri.conf, CONF = kiri.conf,
clone = Object.clone; clone = Object.clone;
@ -52,8 +51,7 @@
alerts = [], alerts = [],
grouping = false, grouping = false,
saveTimer = null, saveTimer = null,
version = kiri.version = gapp.version, version = kiri.version = gapp.version;
noop = () => { return false };
// add show() to catalog for API // add show() to catalog for API
CATALOG.show = showCatalog; CATALOG.show = showCatalog;
@ -167,13 +165,9 @@
const: { const: {
LANG, LANG,
LOCAL, LOCAL,
MODES,
SEED,
SETUP, SETUP,
SECURE, SECURE,
STACKS, STACKS,
SPACE,
VIEWS,
}, },
devel, devel,
doit: { doit: {
@ -271,6 +265,7 @@
save: saveWorkspace, save: saveWorkspace,
set_focus: setFocus, set_focus: setFocus,
update: SPACE.update, update: SPACE.update,
is_dark() { return settings.controller.dark }
}, },
tweak, tweak,
util: { util: {

View file

@ -51,7 +51,7 @@ kiri.utils = {
encodeOpt, encodeOpt,
ajax, ajax,
o2js, o2js,
js2o js2o,
}; };
})(); })();

View file

@ -877,6 +877,4 @@ dispatch.onmessage = self.onmessage = function(e) {
}; };
// load kiri modules // load kiri modules
KIRI.loader.forEach(fn => { KIRI.load_exec(dispatch);
fn(dispatch);
});

View file

@ -10,15 +10,14 @@
let kiri = self.kiri = { let kiri = self.kiri = {
beta: 3301, beta: 3301,
driver: {}, // driver modules driver: {}, // driver modules
loader: modfns, // module loading: array of functions
load(fn) { load(fn) {
kiri.loader.push(fn); modfns.push(fn);
}, },
load_exec() { load_exec(api) {
// complete module loading // complete module loading
modfns.forEach(modfn => { modfn(kiri.api)} ); modfns.forEach(modfn => { modfn(api || kiri.api)} );
// rewrite load() to be immediate post-finalize // rewrite load() to be immediate post-finalize
kiri.load = (modfn) => { modfn(kiri.api) }; kiri.load = (modfn) => { modfn(api || kiri.api) };
} }
}; };
} }