bobe 0.0.70 → 0.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bobe.cjs +64 -10
- package/dist/bobe.cjs.map +1 -1
- package/dist/bobe.compiler.cjs +64 -10
- package/dist/bobe.compiler.cjs.map +1 -1
- package/dist/bobe.compiler.esm.js +62 -11
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +62 -11
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +28 -8
- package/dist/index.umd.js +64 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/bobe.esm.js
CHANGED
|
@@ -1472,6 +1472,7 @@ class Interpreter {
|
|
|
1472
1472
|
rootComponent = null;
|
|
1473
1473
|
program(root, componentNode, before, ctxProvider) {
|
|
1474
1474
|
this.rootComponent = componentNode;
|
|
1475
|
+
this.root = root;
|
|
1475
1476
|
this.tokenizer.nextToken();
|
|
1476
1477
|
const stack = new MultiTypeStack();
|
|
1477
1478
|
setCtxStack(stack);
|
|
@@ -2675,9 +2676,6 @@ class Interpreter {
|
|
|
2675
2676
|
};
|
|
2676
2677
|
}
|
|
2677
2678
|
insertAfter(parent, node, prev) {
|
|
2678
|
-
return this.defaultInsert(parent, node, prev);
|
|
2679
|
-
}
|
|
2680
|
-
defaultInsert(parent, node, prev) {
|
|
2681
2679
|
if (prev) {
|
|
2682
2680
|
const next = prev.nextSibling;
|
|
2683
2681
|
prev.nextSibling = node;
|
|
@@ -2688,10 +2686,7 @@ class Interpreter {
|
|
|
2688
2686
|
node.nextSibling = next;
|
|
2689
2687
|
}
|
|
2690
2688
|
}
|
|
2691
|
-
remove(node, parent,
|
|
2692
|
-
return this.defaultRemove(node, parent, prev);
|
|
2693
|
-
}
|
|
2694
|
-
defaultRemove(node, parent, prevSibling) {
|
|
2689
|
+
remove(node, parent, prevSibling) {
|
|
2695
2690
|
const next = node.nextSibling;
|
|
2696
2691
|
if (prevSibling) {
|
|
2697
2692
|
prevSibling.nextSibling = next;
|
|
@@ -2746,11 +2741,13 @@ function bobe(fragments, ...values) {
|
|
|
2746
2741
|
return ui;
|
|
2747
2742
|
}
|
|
2748
2743
|
function customRender(option) {
|
|
2749
|
-
|
|
2744
|
+
const mw = new Mw();
|
|
2745
|
+
function render(Ctor, root) {
|
|
2750
2746
|
const store = Ctor.new();
|
|
2751
2747
|
const tokenizer = store.ui(false);
|
|
2752
2748
|
const terp = new Interpreter(tokenizer);
|
|
2753
2749
|
terp.config(option);
|
|
2750
|
+
mw.wrapHooks(terp);
|
|
2754
2751
|
const componentNode = {
|
|
2755
2752
|
__logicType: FakeType.Component,
|
|
2756
2753
|
realParent: root,
|
|
@@ -2758,10 +2755,64 @@ function customRender(option) {
|
|
|
2758
2755
|
tokenizer
|
|
2759
2756
|
};
|
|
2760
2757
|
terp.program(root, componentNode);
|
|
2761
|
-
option.onBeforeFlush
|
|
2758
|
+
const onBeforeFlush = mw.wrapHook(terp, 'onBeforeFlush', option.onBeforeFlush);
|
|
2759
|
+
onBeforeFlush?.();
|
|
2762
2760
|
flushMicroEffectManual();
|
|
2763
2761
|
return [componentNode, store];
|
|
2764
|
-
}
|
|
2762
|
+
}
|
|
2763
|
+
render.use = mw.use.bind(mw);
|
|
2764
|
+
return render;
|
|
2765
|
+
}
|
|
2766
|
+
class MwCtx {
|
|
2767
|
+
ctx = {};
|
|
2768
|
+
constructor(terp, handlers = [], base) {
|
|
2769
|
+
this.terp = terp;
|
|
2770
|
+
this.handlers = [...handlers, base];
|
|
2771
|
+
}
|
|
2772
|
+
i = 0;
|
|
2773
|
+
get next() {
|
|
2774
|
+
if (this.i < this.handlers.length) {
|
|
2775
|
+
const handler = this.handlers[this.i];
|
|
2776
|
+
this.i++;
|
|
2777
|
+
return handler;
|
|
2778
|
+
}
|
|
2779
|
+
return null;
|
|
2780
|
+
}
|
|
2781
|
+
get hasNext() {
|
|
2782
|
+
return this.i < this.handlers.length && this.handlers[this.i];
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
class Mw extends Map {
|
|
2786
|
+
use(mw) {
|
|
2787
|
+
for (const key in mw) {
|
|
2788
|
+
const list = this.get(key);
|
|
2789
|
+
if (list) {
|
|
2790
|
+
list.push(mw[key]);
|
|
2791
|
+
} else {
|
|
2792
|
+
this.set(key, [mw[key]]);
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
wrapHooks(terp) {
|
|
2797
|
+
this.forEach((list, key) => {
|
|
2798
|
+
let base = terp[key];
|
|
2799
|
+
base = base?.bind(terp);
|
|
2800
|
+
function wrapped(...args) {
|
|
2801
|
+
const ctx = new MwCtx(terp, list, base);
|
|
2802
|
+
return ctx.next.apply(ctx, args);
|
|
2803
|
+
}
|
|
2804
|
+
terp[key] = wrapped;
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
wrapHook(terp, key, base) {
|
|
2808
|
+
const list = this.get(key);
|
|
2809
|
+
if (!list) return base?.bind(terp);
|
|
2810
|
+
function wrapped(...args) {
|
|
2811
|
+
const ctx = new MwCtx(terp, list, base?.bind(terp));
|
|
2812
|
+
return ctx.next.apply(ctx, args);
|
|
2813
|
+
}
|
|
2814
|
+
return wrapped;
|
|
2815
|
+
}
|
|
2765
2816
|
}
|
|
2766
2817
|
|
|
2767
2818
|
const context = name => {
|
|
@@ -2806,5 +2857,5 @@ const effect = (callback, depOrOpt, opt) => {
|
|
|
2806
2857
|
return effect$1(callback, option);
|
|
2807
2858
|
};
|
|
2808
2859
|
|
|
2809
|
-
export { Compiler, FakeType, NodeType, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
2860
|
+
export { Compiler, FakeType, Interpreter, Mw, MwCtx, NodeType, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
2810
2861
|
//# sourceMappingURL=bobe.esm.js.map
|