bobe 0.0.58 → 0.0.59
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 +34 -17
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +34 -17
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +34 -17
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +34 -17
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.umd.js +34 -17
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/bobe.esm.js
CHANGED
|
@@ -243,7 +243,6 @@ class Tokenizer {
|
|
|
243
243
|
}
|
|
244
244
|
isEof() {
|
|
245
245
|
if (!this.token) return false;
|
|
246
|
-
if (this.i >= this.code.length && !this.waitingTokens.len) return true;
|
|
247
246
|
return this.token.type & TokenType.Identifier && this.token.value === Tokenizer.EofId;
|
|
248
247
|
}
|
|
249
248
|
setToken(type, value, dt = 1) {
|
|
@@ -260,6 +259,7 @@ class Tokenizer {
|
|
|
260
259
|
if (this.isEof()) {
|
|
261
260
|
return this.token;
|
|
262
261
|
}
|
|
262
|
+
if (this.i >= this.code.length && !this.waitingTokens.len) return this.token;
|
|
263
263
|
this.token = undefined;
|
|
264
264
|
if (this.waitingTokens.len) {
|
|
265
265
|
const item = this.waitingTokens.shift();
|
|
@@ -1476,6 +1476,9 @@ class Interpreter {
|
|
|
1476
1476
|
if (this.tokenizer.isEof()) {
|
|
1477
1477
|
if (!ctx.prevSibling) ctx.prevSibling = before;
|
|
1478
1478
|
this.handleInsert(root, ctx.current, ctx.prevSibling, componentNode);
|
|
1479
|
+
if (ctx.current) {
|
|
1480
|
+
ctx.current.__logicType ? this.leaveLogicNode?.(ctx.current, false) : this.leaveNode?.(ctx.current, false);
|
|
1481
|
+
}
|
|
1479
1482
|
break;
|
|
1480
1483
|
}
|
|
1481
1484
|
const token = this.tokenizer.token;
|
|
@@ -1487,6 +1490,7 @@ class Interpreter {
|
|
|
1487
1490
|
prev: ctx.prevSibling
|
|
1488
1491
|
}, !ctx.current.__logicType ? NodeSort.Real : (ctx.current.__logicType & LogicalBit ? NodeSort.Logic : 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));
|
|
1489
1492
|
if (ctx.current.__logicType) {
|
|
1493
|
+
this.beforeLogicIndent?.(ctx.current);
|
|
1490
1494
|
if (isLogicNode) {
|
|
1491
1495
|
setPulling(ctx.current.effect);
|
|
1492
1496
|
if (ctx.current.__logicType & FakeType.ForItem) {
|
|
@@ -1495,6 +1499,12 @@ class Interpreter {
|
|
|
1495
1499
|
}
|
|
1496
1500
|
} else {
|
|
1497
1501
|
if (ctx.current) {
|
|
1502
|
+
if (this.beforeIndent?.(ctx.current) === false) {
|
|
1503
|
+
const dentLen = this.tokenizer.dentStack[this.tokenizer.dentStack.length - 1];
|
|
1504
|
+
this.tokenizer.skip(dentLen);
|
|
1505
|
+
ctx.current = null;
|
|
1506
|
+
continue;
|
|
1507
|
+
}
|
|
1498
1508
|
ctx.realParent = ctx.current;
|
|
1499
1509
|
}
|
|
1500
1510
|
ctx.prevSibling = null;
|
|
@@ -1507,6 +1517,7 @@ class Interpreter {
|
|
|
1507
1517
|
ctx.prevSibling = before;
|
|
1508
1518
|
}
|
|
1509
1519
|
this.handleInsert(ctx.realParent, ctx.current, ctx.prevSibling);
|
|
1520
|
+
ctx.current.__logicType ? this.leaveLogicNode?.(ctx.current, false) : this.leaveNode?.(ctx.current, false);
|
|
1510
1521
|
}
|
|
1511
1522
|
if (this.tokenizer.token.type & TokenType.Dedent) {
|
|
1512
1523
|
this.tokenizer.nextToken();
|
|
@@ -1541,6 +1552,7 @@ class Interpreter {
|
|
|
1541
1552
|
const i = forNode.i,
|
|
1542
1553
|
arr = forNode.arr,
|
|
1543
1554
|
snapshot = forNode.snapshot;
|
|
1555
|
+
this.leaveLogicNode?.(parent, false);
|
|
1544
1556
|
if (i + 1 < arr.length) {
|
|
1545
1557
|
this.tokenizer.resume(snapshot);
|
|
1546
1558
|
this.tokenizer.nextToken();
|
|
@@ -1563,13 +1575,13 @@ class Interpreter {
|
|
|
1563
1575
|
}
|
|
1564
1576
|
return componentNode;
|
|
1565
1577
|
}
|
|
1566
|
-
|
|
1578
|
+
insertAnchor(name = 'anchor', isBefore = false) {
|
|
1567
1579
|
const _this$ctx = this.ctx,
|
|
1568
1580
|
realParent = _this$ctx.realParent,
|
|
1569
1581
|
prevSibling = _this$ctx.prevSibling,
|
|
1570
1582
|
stack = _this$ctx.stack,
|
|
1571
1583
|
before = _this$ctx.before;
|
|
1572
|
-
const afterAnchor = this.createAnchor(name);
|
|
1584
|
+
const afterAnchor = this.createAnchor(name, isBefore);
|
|
1573
1585
|
this.ctx.prevSibling = stack.length === 2 && !prevSibling ? before : prevSibling;
|
|
1574
1586
|
this.handleInsert(realParent, afterAnchor, prevSibling);
|
|
1575
1587
|
return afterAnchor;
|
|
@@ -1623,7 +1635,7 @@ class Interpreter {
|
|
|
1623
1635
|
_node = this.componentOrFragmentDeclaration(value, ctx);
|
|
1624
1636
|
} else {
|
|
1625
1637
|
_node = this.createNode('text');
|
|
1626
|
-
_node
|
|
1638
|
+
this.setProp(_node, 'text', String(value));
|
|
1627
1639
|
}
|
|
1628
1640
|
} else {
|
|
1629
1641
|
return this.dynamicDeclaration(data, value, ctx);
|
|
@@ -1657,7 +1669,7 @@ class Interpreter {
|
|
|
1657
1669
|
parentDataProvider: ctx.stack.peekByType(NodeSort.CtxProvider)?.node
|
|
1658
1670
|
};
|
|
1659
1671
|
let isUpdate = false;
|
|
1660
|
-
node.realAfter = this.
|
|
1672
|
+
node.realAfter = this.insertAnchor(`dynamic-after`);
|
|
1661
1673
|
node.effect = this.effect(({
|
|
1662
1674
|
old,
|
|
1663
1675
|
val
|
|
@@ -1693,11 +1705,13 @@ class Interpreter {
|
|
|
1693
1705
|
this.tokenizer = node.tokenizer;
|
|
1694
1706
|
if (node.fragmentSnapshot) {
|
|
1695
1707
|
this.tokenizer.resume(node.fragmentSnapshot);
|
|
1696
|
-
this.tokenizer.useDedentAsEof = true;
|
|
1697
|
-
this.tokenizer.initIndentWhenUseDedentAsEof();
|
|
1698
1708
|
}
|
|
1699
1709
|
if (isUpdate) {
|
|
1710
|
+
this.tokenizer.useDedentAsEof = false;
|
|
1700
1711
|
this.program(node.realParent, node.owner, node.realBefore, node);
|
|
1712
|
+
} else {
|
|
1713
|
+
this.tokenizer.useDedentAsEof = true;
|
|
1714
|
+
this.tokenizer.initIndentWhenUseDedentAsEof();
|
|
1701
1715
|
}
|
|
1702
1716
|
} else {
|
|
1703
1717
|
node.__logicType = FakeType.DynamicText;
|
|
@@ -1706,7 +1720,7 @@ class Interpreter {
|
|
|
1706
1720
|
if (isNewTextNode) {
|
|
1707
1721
|
textNode = node.textNode = this.createNode('text');
|
|
1708
1722
|
}
|
|
1709
|
-
textNode
|
|
1723
|
+
this.setProp(textNode, 'text', String(val));
|
|
1710
1724
|
if (isNewTextNode) {
|
|
1711
1725
|
if (isUpdate) {
|
|
1712
1726
|
this.handleInsert(node.realParent, textNode, node.realBefore);
|
|
@@ -1718,6 +1732,7 @@ class Interpreter {
|
|
|
1718
1732
|
prevSibling = _this$ctx2.prevSibling;
|
|
1719
1733
|
this.handleInsert(realParent, textNode, prevSibling);
|
|
1720
1734
|
}
|
|
1735
|
+
this.leaveNode?.(textNode, false);
|
|
1721
1736
|
}
|
|
1722
1737
|
}
|
|
1723
1738
|
isUpdate = true;
|
|
@@ -1748,7 +1763,7 @@ class Interpreter {
|
|
|
1748
1763
|
realBefore: null,
|
|
1749
1764
|
realAfter: null
|
|
1750
1765
|
};
|
|
1751
|
-
node.realAfter = this.
|
|
1766
|
+
node.realAfter = this.insertAnchor('context-after');
|
|
1752
1767
|
return node;
|
|
1753
1768
|
}
|
|
1754
1769
|
formatForCollection(collection) {
|
|
@@ -1846,7 +1861,7 @@ class Interpreter {
|
|
|
1846
1861
|
const hasArrExpKey = Reflect.has(data[Keys.Raw], arrExp);
|
|
1847
1862
|
const arrSignal = hasArrExpKey ? (data[arrExp], cells.get(arrExp)) : new Computed(this.getFn(data, arrExp));
|
|
1848
1863
|
forNode.arrSignal = arrSignal;
|
|
1849
|
-
forNode.realAfter = this.
|
|
1864
|
+
forNode.realAfter = this.insertAnchor('for-after');
|
|
1850
1865
|
const _forNode$snapshot = forNode.snapshot;
|
|
1851
1866
|
_forNode$snapshot.dentStack;
|
|
1852
1867
|
_forNode$snapshot.isFirstToken;
|
|
@@ -1869,8 +1884,8 @@ class Interpreter {
|
|
|
1869
1884
|
const len = arr.length;
|
|
1870
1885
|
for (let i = len; i--;) {
|
|
1871
1886
|
const item = this.createForItem(forNode, i, data);
|
|
1872
|
-
item.realAfter = this.
|
|
1873
|
-
item.realBefore = this.
|
|
1887
|
+
item.realAfter = this.insertAnchor('for-item-after');
|
|
1888
|
+
item.realBefore = this.insertAnchor('for-item-before', true);
|
|
1874
1889
|
item.realParent = forNode.realParent;
|
|
1875
1890
|
children[i] = item;
|
|
1876
1891
|
}
|
|
@@ -2037,7 +2052,7 @@ class Interpreter {
|
|
|
2037
2052
|
newChildren[i] = item;
|
|
2038
2053
|
let realAfter = this.createAnchor('for-item-after');
|
|
2039
2054
|
this.handleInsert(forNode.realParent, realAfter, before);
|
|
2040
|
-
let realBefore = this.createAnchor('for-item-before');
|
|
2055
|
+
let realBefore = this.createAnchor('for-item-before', true);
|
|
2041
2056
|
this.handleInsert(forNode.realParent, realBefore, before);
|
|
2042
2057
|
item.realBefore = realBefore;
|
|
2043
2058
|
item.realAfter = realAfter;
|
|
@@ -2206,7 +2221,7 @@ class Interpreter {
|
|
|
2206
2221
|
resumeSnapshot
|
|
2207
2222
|
};
|
|
2208
2223
|
this.onePropParsed = onePropParsed;
|
|
2209
|
-
node.realAfter = this.
|
|
2224
|
+
node.realAfter = this.insertAnchor('component-after');
|
|
2210
2225
|
return node;
|
|
2211
2226
|
}
|
|
2212
2227
|
getFn(data, expression) {
|
|
@@ -2301,7 +2316,7 @@ class Interpreter {
|
|
|
2301
2316
|
break;
|
|
2302
2317
|
}
|
|
2303
2318
|
ifNode.condition = signal;
|
|
2304
|
-
ifNode.realAfter = this.
|
|
2319
|
+
ifNode.realAfter = this.insertAnchor(`${keyWord.value}-after`);
|
|
2305
2320
|
const ef = this.effect(({
|
|
2306
2321
|
val
|
|
2307
2322
|
}) => {
|
|
@@ -2486,10 +2501,11 @@ class Interpreter {
|
|
|
2486
2501
|
firstChild(node) {
|
|
2487
2502
|
return node.firstChild;
|
|
2488
2503
|
}
|
|
2489
|
-
createAnchor(name) {
|
|
2504
|
+
createAnchor(name, isBefore) {
|
|
2490
2505
|
return {
|
|
2491
2506
|
name,
|
|
2492
|
-
nextSibling: null
|
|
2507
|
+
nextSibling: null,
|
|
2508
|
+
isBefore
|
|
2493
2509
|
};
|
|
2494
2510
|
}
|
|
2495
2511
|
insertAfter(parent, node, prev) {
|
|
@@ -2575,6 +2591,7 @@ function customRender(option) {
|
|
|
2575
2591
|
tokenizer
|
|
2576
2592
|
};
|
|
2577
2593
|
terp.program(root, componentNode);
|
|
2594
|
+
option.onBeforeFlush?.();
|
|
2578
2595
|
flushMicroEffectManual();
|
|
2579
2596
|
return [componentNode, store];
|
|
2580
2597
|
};
|