bobe 0.0.69 → 0.0.71
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 +63 -10
- package/dist/bobe.cjs.map +1 -1
- package/dist/bobe.compiler.cjs +63 -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 +63 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/bobe.cjs
CHANGED
|
@@ -1473,6 +1473,7 @@ class Interpreter {
|
|
|
1473
1473
|
rootComponent = null;
|
|
1474
1474
|
program(root, componentNode, before, ctxProvider) {
|
|
1475
1475
|
this.rootComponent = componentNode;
|
|
1476
|
+
this.root = root;
|
|
1476
1477
|
this.tokenizer.nextToken();
|
|
1477
1478
|
const stack = new MultiTypeStack();
|
|
1478
1479
|
setCtxStack(stack);
|
|
@@ -2676,9 +2677,6 @@ class Interpreter {
|
|
|
2676
2677
|
};
|
|
2677
2678
|
}
|
|
2678
2679
|
insertAfter(parent, node, prev) {
|
|
2679
|
-
return this.defaultInsert(parent, node, prev);
|
|
2680
|
-
}
|
|
2681
|
-
defaultInsert(parent, node, prev) {
|
|
2682
2680
|
if (prev) {
|
|
2683
2681
|
const next = prev.nextSibling;
|
|
2684
2682
|
prev.nextSibling = node;
|
|
@@ -2689,10 +2687,7 @@ class Interpreter {
|
|
|
2689
2687
|
node.nextSibling = next;
|
|
2690
2688
|
}
|
|
2691
2689
|
}
|
|
2692
|
-
remove(node, parent,
|
|
2693
|
-
return this.defaultRemove(node, parent, prev);
|
|
2694
|
-
}
|
|
2695
|
-
defaultRemove(node, parent, prevSibling) {
|
|
2690
|
+
remove(node, parent, prevSibling) {
|
|
2696
2691
|
const next = node.nextSibling;
|
|
2697
2692
|
if (prevSibling) {
|
|
2698
2693
|
prevSibling.nextSibling = next;
|
|
@@ -2747,11 +2742,13 @@ function bobe(fragments, ...values) {
|
|
|
2747
2742
|
return ui;
|
|
2748
2743
|
}
|
|
2749
2744
|
function customRender(option) {
|
|
2750
|
-
|
|
2745
|
+
const mw = new Mw();
|
|
2746
|
+
function render(Ctor, root) {
|
|
2751
2747
|
const store = Ctor.new();
|
|
2752
2748
|
const tokenizer = store.ui(false);
|
|
2753
2749
|
const terp = new Interpreter(tokenizer);
|
|
2754
2750
|
terp.config(option);
|
|
2751
|
+
mw.wrapHooks(terp);
|
|
2755
2752
|
const componentNode = {
|
|
2756
2753
|
__logicType: FakeType.Component,
|
|
2757
2754
|
realParent: root,
|
|
@@ -2759,10 +2756,64 @@ function customRender(option) {
|
|
|
2759
2756
|
tokenizer
|
|
2760
2757
|
};
|
|
2761
2758
|
terp.program(root, componentNode);
|
|
2762
|
-
option.onBeforeFlush
|
|
2759
|
+
const onBeforeFlush = mw.wrapHook(terp, 'onBeforeFlush', option.onBeforeFlush);
|
|
2760
|
+
onBeforeFlush?.();
|
|
2763
2761
|
aoye.flushMicroEffectManual();
|
|
2764
2762
|
return [componentNode, store];
|
|
2765
|
-
}
|
|
2763
|
+
}
|
|
2764
|
+
render.use = mw.use.bind(mw);
|
|
2765
|
+
return render;
|
|
2766
|
+
}
|
|
2767
|
+
class MwCtx {
|
|
2768
|
+
ctx = {};
|
|
2769
|
+
constructor(terp, handlers = [], base) {
|
|
2770
|
+
this.terp = terp;
|
|
2771
|
+
this.handlers = [...handlers, base];
|
|
2772
|
+
}
|
|
2773
|
+
i = 0;
|
|
2774
|
+
get next() {
|
|
2775
|
+
if (this.i < this.handlers.length) {
|
|
2776
|
+
const handler = this.handlers[this.i];
|
|
2777
|
+
this.i++;
|
|
2778
|
+
return handler;
|
|
2779
|
+
}
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
get hasNext() {
|
|
2783
|
+
return this.i < this.handlers.length && this.handlers[this.i];
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
class Mw extends Map {
|
|
2787
|
+
use(mw) {
|
|
2788
|
+
for (const key in mw) {
|
|
2789
|
+
const list = this.get(key);
|
|
2790
|
+
if (list) {
|
|
2791
|
+
list.push(mw[key]);
|
|
2792
|
+
} else {
|
|
2793
|
+
this.set(key, [mw[key]]);
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
wrapHooks(terp) {
|
|
2798
|
+
this.forEach((list, key) => {
|
|
2799
|
+
let base = terp[key];
|
|
2800
|
+
base = base?.bind(terp);
|
|
2801
|
+
function wrapped(...args) {
|
|
2802
|
+
const ctx = new MwCtx(terp, list, base);
|
|
2803
|
+
return ctx.next.apply(ctx, args);
|
|
2804
|
+
}
|
|
2805
|
+
terp[key] = wrapped;
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
wrapHook(terp, key, base) {
|
|
2809
|
+
const list = this.get(key);
|
|
2810
|
+
if (!list) return base?.bind(terp);
|
|
2811
|
+
function wrapped(...args) {
|
|
2812
|
+
const ctx = new MwCtx(terp, list, base?.bind(terp));
|
|
2813
|
+
return ctx.next.apply(ctx, args);
|
|
2814
|
+
}
|
|
2815
|
+
return wrapped;
|
|
2816
|
+
}
|
|
2766
2817
|
}
|
|
2767
2818
|
|
|
2768
2819
|
const context = name => {
|
|
@@ -2813,6 +2864,8 @@ Object.defineProperty(exports, "Store", {
|
|
|
2813
2864
|
});
|
|
2814
2865
|
exports.Compiler = Compiler;
|
|
2815
2866
|
exports.FakeType = FakeType;
|
|
2867
|
+
exports.Mw = Mw;
|
|
2868
|
+
exports.MwCtx = MwCtx;
|
|
2816
2869
|
exports.NodeType = NodeType;
|
|
2817
2870
|
exports.ParseSyntaxError = ParseSyntaxError;
|
|
2818
2871
|
exports.Tokenizer = Tokenizer;
|