bobe 0.0.70 → 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
|
@@ -1499,6 +1499,7 @@ class Interpreter {
|
|
|
1499
1499
|
rootComponent = null;
|
|
1500
1500
|
program(root, componentNode, before, ctxProvider) {
|
|
1501
1501
|
this.rootComponent = componentNode;
|
|
1502
|
+
this.root = root;
|
|
1502
1503
|
this.tokenizer.nextToken();
|
|
1503
1504
|
const stack = new MultiTypeStack();
|
|
1504
1505
|
setCtxStack(stack);
|
|
@@ -2702,9 +2703,6 @@ class Interpreter {
|
|
|
2702
2703
|
};
|
|
2703
2704
|
}
|
|
2704
2705
|
insertAfter(parent, node, prev) {
|
|
2705
|
-
return this.defaultInsert(parent, node, prev);
|
|
2706
|
-
}
|
|
2707
|
-
defaultInsert(parent, node, prev) {
|
|
2708
2706
|
if (prev) {
|
|
2709
2707
|
const next = prev.nextSibling;
|
|
2710
2708
|
prev.nextSibling = node;
|
|
@@ -2715,10 +2713,7 @@ class Interpreter {
|
|
|
2715
2713
|
node.nextSibling = next;
|
|
2716
2714
|
}
|
|
2717
2715
|
}
|
|
2718
|
-
remove(node, parent,
|
|
2719
|
-
return this.defaultRemove(node, parent, prev);
|
|
2720
|
-
}
|
|
2721
|
-
defaultRemove(node, parent, prevSibling) {
|
|
2716
|
+
remove(node, parent, prevSibling) {
|
|
2722
2717
|
const next = node.nextSibling;
|
|
2723
2718
|
if (prevSibling) {
|
|
2724
2719
|
prevSibling.nextSibling = next;
|
|
@@ -2773,11 +2768,13 @@ function bobe(fragments, ...values) {
|
|
|
2773
2768
|
return ui;
|
|
2774
2769
|
}
|
|
2775
2770
|
function customRender(option) {
|
|
2776
|
-
|
|
2771
|
+
const mw = new Mw();
|
|
2772
|
+
function render(Ctor, root) {
|
|
2777
2773
|
const store = Ctor.new();
|
|
2778
2774
|
const tokenizer = store.ui(false);
|
|
2779
2775
|
const terp = new Interpreter(tokenizer);
|
|
2780
2776
|
terp.config(option);
|
|
2777
|
+
mw.wrapHooks(terp);
|
|
2781
2778
|
const componentNode = {
|
|
2782
2779
|
__logicType: FakeType.Component,
|
|
2783
2780
|
realParent: root,
|
|
@@ -2785,10 +2782,64 @@ function customRender(option) {
|
|
|
2785
2782
|
tokenizer
|
|
2786
2783
|
};
|
|
2787
2784
|
terp.program(root, componentNode);
|
|
2788
|
-
option.onBeforeFlush
|
|
2785
|
+
const onBeforeFlush = mw.wrapHook(terp, 'onBeforeFlush', option.onBeforeFlush);
|
|
2786
|
+
onBeforeFlush?.();
|
|
2789
2787
|
flushMicroEffectManual();
|
|
2790
2788
|
return [componentNode, store];
|
|
2791
|
-
}
|
|
2789
|
+
}
|
|
2790
|
+
render.use = mw.use.bind(mw);
|
|
2791
|
+
return render;
|
|
2792
|
+
}
|
|
2793
|
+
class MwCtx {
|
|
2794
|
+
ctx = {};
|
|
2795
|
+
constructor(terp, handlers = [], base) {
|
|
2796
|
+
this.terp = terp;
|
|
2797
|
+
this.handlers = [...handlers, base];
|
|
2798
|
+
}
|
|
2799
|
+
i = 0;
|
|
2800
|
+
get next() {
|
|
2801
|
+
if (this.i < this.handlers.length) {
|
|
2802
|
+
const handler = this.handlers[this.i];
|
|
2803
|
+
this.i++;
|
|
2804
|
+
return handler;
|
|
2805
|
+
}
|
|
2806
|
+
return null;
|
|
2807
|
+
}
|
|
2808
|
+
get hasNext() {
|
|
2809
|
+
return this.i < this.handlers.length && this.handlers[this.i];
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
class Mw extends Map {
|
|
2813
|
+
use(mw) {
|
|
2814
|
+
for (const key in mw) {
|
|
2815
|
+
const list = this.get(key);
|
|
2816
|
+
if (list) {
|
|
2817
|
+
list.push(mw[key]);
|
|
2818
|
+
} else {
|
|
2819
|
+
this.set(key, [mw[key]]);
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
wrapHooks(terp) {
|
|
2824
|
+
this.forEach((list, key) => {
|
|
2825
|
+
let base = terp[key];
|
|
2826
|
+
base = base?.bind(terp);
|
|
2827
|
+
function wrapped(...args) {
|
|
2828
|
+
const ctx = new MwCtx(terp, list, base);
|
|
2829
|
+
return ctx.next.apply(ctx, args);
|
|
2830
|
+
}
|
|
2831
|
+
terp[key] = wrapped;
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
wrapHook(terp, key, base) {
|
|
2835
|
+
const list = this.get(key);
|
|
2836
|
+
if (!list) return base?.bind(terp);
|
|
2837
|
+
function wrapped(...args) {
|
|
2838
|
+
const ctx = new MwCtx(terp, list, base?.bind(terp));
|
|
2839
|
+
return ctx.next.apply(ctx, args);
|
|
2840
|
+
}
|
|
2841
|
+
return wrapped;
|
|
2842
|
+
}
|
|
2792
2843
|
}
|
|
2793
2844
|
|
|
2794
2845
|
const context = name => {
|
|
@@ -2833,5 +2884,5 @@ const effect = (callback, depOrOpt, opt) => {
|
|
|
2833
2884
|
return effect$1(callback, option);
|
|
2834
2885
|
};
|
|
2835
2886
|
|
|
2836
|
-
export { Compiler, FakeType, NodeType, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
2887
|
+
export { Compiler, FakeType, Mw, MwCtx, NodeType, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
2837
2888
|
//# sourceMappingURL=bobe.compiler.esm.js.map
|