bobe 0.0.61 → 0.0.62
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.js +40 -20
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +40 -20
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +42 -22
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +42 -22
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.umd.js +40 -20
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/bobe.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Queue, isNum, matchIdStart2, matchId, escapeMap, pickInPlace, jsVarRegexp, date32 } from 'bobe-shared';
|
|
2
|
-
import { Signal, Computed, Keys, isStore, getPulling, setPulling, deepSignal,
|
|
1
|
+
import { Queue, isNum, matchIdStart2, matchId, escapeMap, pickInPlace, jsVarRegexp, date32, hasOwn } from 'bobe-shared';
|
|
2
|
+
import { Signal, Computed, Keys, isStore, getPulling, setPulling, runWithPulling, getProxyHasKey, deepSignal, Scope, backupSignal, toRaw, ScheduleType, Store, noopEffect, NoopEffect, Effect, effect as effect$1, shareSignal, flushMicroEffectManual } from 'aoye';
|
|
3
3
|
export { Store } from 'aoye';
|
|
4
4
|
|
|
5
5
|
let TokenType = function (TokenType) {
|
|
@@ -1434,7 +1434,7 @@ const SAFE_HANDLER = {
|
|
|
1434
1434
|
has: () => true,
|
|
1435
1435
|
get: (t, k) => {
|
|
1436
1436
|
if (typeof k === 'symbol') return t[k];
|
|
1437
|
-
return
|
|
1437
|
+
return t[k];
|
|
1438
1438
|
}
|
|
1439
1439
|
};
|
|
1440
1440
|
const safe = data => new Proxy(data, SAFE_HANDLER);
|
|
@@ -1494,7 +1494,7 @@ class Interpreter {
|
|
|
1494
1494
|
stack.push({
|
|
1495
1495
|
node: ctx.current,
|
|
1496
1496
|
prev: ctx.prevSibling
|
|
1497
|
-
}, !ctx.current.__logicType ? NodeSort.Real : (isEffectNode ? NodeSort.EffectNode : 0) | (ctx.current.__logicType & TokenizerSwitcherBit ? NodeSort.TokenizerSwitcher : 0) | (ctx.current.__logicType & ContextBit ? NodeSort.Context : 0) | (ctx.current.__logicType === FakeType.Component ? NodeSort.Component : 0) | (ctx.current.__logicType & CtxProviderBit ? NodeSort.CtxProvider : 0));
|
|
1497
|
+
}, !ctx.current.__logicType ? NodeSort.Real : (isEffectNode ? NodeSort.EffectNode : 0) | (ctx.current.__logicType & TokenizerSwitcherBit ? NodeSort.TokenizerSwitcher : 0) | (ctx.current.__logicType & ContextBit ? NodeSort.Context : 0) | (ctx.current.__logicType === FakeType.Component ? NodeSort.Component : 0) | (ctx.current.__logicType === FakeType.Tp ? NodeSort.Real : 0) | (ctx.current.__logicType & CtxProviderBit ? NodeSort.CtxProvider : 0));
|
|
1498
1498
|
if (ctx.current.__logicType) {
|
|
1499
1499
|
this.beforeLogicIndent?.(ctx.current);
|
|
1500
1500
|
if (isEffectNode) {
|
|
@@ -1503,7 +1503,9 @@ class Interpreter {
|
|
|
1503
1503
|
ctx.prevSibling = ctx.current.realBefore;
|
|
1504
1504
|
}
|
|
1505
1505
|
if (ctx.current.__logicType & FakeType.Tp) {
|
|
1506
|
-
|
|
1506
|
+
runWithPulling(() => {
|
|
1507
|
+
ctx.realParent = ctx.current.tpData.node;
|
|
1508
|
+
}, null);
|
|
1507
1509
|
ctx.prevSibling = ctx.current.contentBefore;
|
|
1508
1510
|
}
|
|
1509
1511
|
}
|
|
@@ -1539,7 +1541,12 @@ class Interpreter {
|
|
|
1539
1541
|
sort = _stack$pop2[1];
|
|
1540
1542
|
if (!parent.__logicType) {
|
|
1541
1543
|
const prevSameType = stack.peekByType(NodeSort.Real);
|
|
1542
|
-
|
|
1544
|
+
const sameNode = prevSameType?.node;
|
|
1545
|
+
if (sameNode) {
|
|
1546
|
+
ctx.realParent = sameNode.__logicType === FakeType.Tp ? runWithPulling(() => sameNode.tpData.node, null) : sameNode;
|
|
1547
|
+
} else {
|
|
1548
|
+
ctx.realParent = root;
|
|
1549
|
+
}
|
|
1543
1550
|
} else {
|
|
1544
1551
|
if (sort & NodeSort.EffectNode) {
|
|
1545
1552
|
const parentLogic = stack.peekByType(NodeSort.EffectNode)?.node;
|
|
@@ -1676,7 +1683,7 @@ class Interpreter {
|
|
|
1676
1683
|
return _node;
|
|
1677
1684
|
}
|
|
1678
1685
|
dynamicDeclaration(pData, value, ctx) {
|
|
1679
|
-
const valueIsMapKey =
|
|
1686
|
+
const valueIsMapKey = Boolean(getProxyHasKey(pData, value));
|
|
1680
1687
|
let node = {
|
|
1681
1688
|
__logicType: null,
|
|
1682
1689
|
realParent: null,
|
|
@@ -1760,10 +1767,7 @@ class Interpreter {
|
|
|
1760
1767
|
this.removeLogicNode(node);
|
|
1761
1768
|
}
|
|
1762
1769
|
};
|
|
1763
|
-
}, [() => {
|
|
1764
|
-
const val = valueIsMapKey ? pData[value] : this.getFn(pData, value)();
|
|
1765
|
-
return val;
|
|
1766
|
-
}], {
|
|
1770
|
+
}, [valueIsMapKey ? () => pData[value] : this.getFn(pData, value)], {
|
|
1767
1771
|
type: 'render'
|
|
1768
1772
|
});
|
|
1769
1773
|
return node;
|
|
@@ -1791,7 +1795,13 @@ class Interpreter {
|
|
|
1791
1795
|
const before = node.contentBefore = this.createAnchor('tp-content-before', true);
|
|
1792
1796
|
const after = node.contentAfter = this.createAnchor('tp-content-after', true);
|
|
1793
1797
|
let firstRender = true;
|
|
1794
|
-
|
|
1798
|
+
let scope = new Scope(() => {});
|
|
1799
|
+
scope.scope = null;
|
|
1800
|
+
runWithPulling(() => {
|
|
1801
|
+
scope.get();
|
|
1802
|
+
}, null);
|
|
1803
|
+
node.effect = scope;
|
|
1804
|
+
this.effect(({
|
|
1795
1805
|
old: oldDom,
|
|
1796
1806
|
val: dom
|
|
1797
1807
|
}) => {
|
|
@@ -1835,19 +1845,29 @@ class Interpreter {
|
|
|
1835
1845
|
} else {
|
|
1836
1846
|
this.handleInsert(dom, after, null);
|
|
1837
1847
|
this.handleInsert(dom, before, null);
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1848
|
+
runWithPulling(() => {
|
|
1849
|
+
this.tokenizer = node.owner.tokenizer;
|
|
1850
|
+
this.tokenizer.resume(node.snapshot);
|
|
1851
|
+
this.tokenizer.useDedentAsEof = false;
|
|
1852
|
+
this.program(dom, node.owner, before, node);
|
|
1853
|
+
}, scope);
|
|
1842
1854
|
}
|
|
1843
1855
|
} else {
|
|
1844
1856
|
removeTpChild();
|
|
1857
|
+
scope.dispose();
|
|
1858
|
+
scope = new Scope(() => {});
|
|
1859
|
+
scope.scope = null;
|
|
1860
|
+
runWithPulling(() => {
|
|
1861
|
+
scope.get();
|
|
1862
|
+
}, null);
|
|
1863
|
+
node.effect = scope;
|
|
1845
1864
|
}
|
|
1846
1865
|
}
|
|
1847
1866
|
firstRender = false;
|
|
1848
1867
|
return isDestroy => {
|
|
1849
1868
|
if (isDestroy) {
|
|
1850
1869
|
removeTpChild();
|
|
1870
|
+
scope.dispose();
|
|
1851
1871
|
}
|
|
1852
1872
|
};
|
|
1853
1873
|
}, [() => child.node], {
|
|
@@ -1859,7 +1879,7 @@ class Interpreter {
|
|
|
1859
1879
|
const child = deepSignal({}, getPulling());
|
|
1860
1880
|
const parentContext = this.ctx.stack.peekByType(NodeSort.Context)?.node?.context;
|
|
1861
1881
|
if (parentContext) {
|
|
1862
|
-
|
|
1882
|
+
backupSignal(child, parentContext);
|
|
1863
1883
|
}
|
|
1864
1884
|
this.onePropParsed = createStoreOnePropParsed(child);
|
|
1865
1885
|
const node = {
|
|
@@ -2247,7 +2267,7 @@ class Interpreter {
|
|
|
2247
2267
|
cells.set(name, new Computed(() => computedData.get()[name]));
|
|
2248
2268
|
}
|
|
2249
2269
|
}
|
|
2250
|
-
|
|
2270
|
+
backupSignal(data, parentData);
|
|
2251
2271
|
return data;
|
|
2252
2272
|
}
|
|
2253
2273
|
getData() {
|
|
@@ -2288,7 +2308,7 @@ class Interpreter {
|
|
|
2288
2308
|
} else if (ComponentOrRender instanceof InlineFragment) {
|
|
2289
2309
|
const conf = ComponentOrRender;
|
|
2290
2310
|
child = deepSignal({}, getPulling(), true);
|
|
2291
|
-
|
|
2311
|
+
backupSignal(child, conf.data);
|
|
2292
2312
|
tokenizer = conf.tokenizer;
|
|
2293
2313
|
fragmentSnapshot = conf.snapshot;
|
|
2294
2314
|
__logicType = FakeType.Fragment;
|
|
@@ -2298,7 +2318,7 @@ class Interpreter {
|
|
|
2298
2318
|
const boundStore = render.boundStore;
|
|
2299
2319
|
child = deepSignal({}, getPulling(), true);
|
|
2300
2320
|
if (boundStore) {
|
|
2301
|
-
|
|
2321
|
+
backupSignal(child, boundStore);
|
|
2302
2322
|
}
|
|
2303
2323
|
tokenizer = render(true);
|
|
2304
2324
|
__logicType = FakeType.Fragment;
|
|
@@ -2546,7 +2566,7 @@ class Interpreter {
|
|
|
2546
2566
|
prevKeys.delete(k);
|
|
2547
2567
|
if (isComponent) {
|
|
2548
2568
|
const savedK = savedDefaults.has(k);
|
|
2549
|
-
if (!savedK &&
|
|
2569
|
+
if (!savedK && hasOwn(rawTarget, k)) {
|
|
2550
2570
|
savedDefaults.set(k, rawTarget[k]);
|
|
2551
2571
|
}
|
|
2552
2572
|
const val = props[k];
|
|
@@ -2579,7 +2599,7 @@ class Interpreter {
|
|
|
2579
2599
|
}).get();
|
|
2580
2600
|
}
|
|
2581
2601
|
} else if (hookType === 'dynamic') {
|
|
2582
|
-
const valueIsMapKey =
|
|
2602
|
+
const valueIsMapKey = Boolean(getProxyHasKey(data, value));
|
|
2583
2603
|
const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
|
|
2584
2604
|
this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
|
|
2585
2605
|
} else if (hookType === 'static') {
|