bobe 0.0.59 → 0.0.60
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 +15 -5
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +15 -5
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +15 -5
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +15 -5
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.umd.js +15 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1456,6 +1456,14 @@ class InlineFragment {
|
|
|
1456
1456
|
}
|
|
1457
1457
|
const isUI = fn => typeof fn === 'function' && fn.__BOBE_IS_UI;
|
|
1458
1458
|
const isRenderAble = val => isStore(val) || isUI(val) || val instanceof InlineFragment;
|
|
1459
|
+
const SAFE_HANDLER = {
|
|
1460
|
+
has: () => true,
|
|
1461
|
+
get: (t, k) => {
|
|
1462
|
+
if (typeof k === 'symbol') return t[k];
|
|
1463
|
+
return k in t ? t[k] : undefined;
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
const safe = data => new Proxy(data, SAFE_HANDLER);
|
|
1459
1467
|
|
|
1460
1468
|
const KEY_INDEX = '__BOBE_KEY_INDEX';
|
|
1461
1469
|
let _ctxStack;
|
|
@@ -1692,7 +1700,7 @@ class Interpreter {
|
|
|
1692
1700
|
effect: null,
|
|
1693
1701
|
textNode: null,
|
|
1694
1702
|
owner: ctx.stack.peekByType(NodeSort.TokenizerSwitcher)?.node,
|
|
1695
|
-
snapshot: this.tokenizer.snapshot(['dentStack']),
|
|
1703
|
+
snapshot: this.tokenizer.snapshot(['dentStack', 'isFirstToken']),
|
|
1696
1704
|
parentDataProvider: ctx.stack.peekByType(NodeSort.CtxProvider)?.node
|
|
1697
1705
|
};
|
|
1698
1706
|
let isUpdate = false;
|
|
@@ -1705,7 +1713,7 @@ class Interpreter {
|
|
|
1705
1713
|
oldTextNode = node.textNode;
|
|
1706
1714
|
if (oldLogicType) {
|
|
1707
1715
|
this.removeLogicNode(node);
|
|
1708
|
-
pickInPlace(node, ['realParent', 'realBefore', 'realAfter'
|
|
1716
|
+
pickInPlace(node, ['realParent', 'realBefore', 'realAfter', 'owner', 'snapshot', 'parentDataProvider']);
|
|
1709
1717
|
}
|
|
1710
1718
|
if (isRenderAble(val)) {
|
|
1711
1719
|
if (oldTextNode) {
|
|
@@ -1735,7 +1743,7 @@ class Interpreter {
|
|
|
1735
1743
|
}
|
|
1736
1744
|
if (isUpdate) {
|
|
1737
1745
|
this.tokenizer.useDedentAsEof = false;
|
|
1738
|
-
this.program(node.realParent, node
|
|
1746
|
+
this.program(node.realParent, node, node.realBefore);
|
|
1739
1747
|
} else {
|
|
1740
1748
|
this.tokenizer.useDedentAsEof = true;
|
|
1741
1749
|
this.tokenizer.initIndentWhenUseDedentAsEof();
|
|
@@ -1880,7 +1888,8 @@ class Interpreter {
|
|
|
1880
1888
|
i: 0
|
|
1881
1889
|
};
|
|
1882
1890
|
if (keyExp) {
|
|
1883
|
-
|
|
1891
|
+
const rawGetKey = new Function('data', `with(data){return (${keyExp})}`);
|
|
1892
|
+
forNode.getKey = data => rawGetKey(safe(data));
|
|
1884
1893
|
}
|
|
1885
1894
|
window['for1'] = forNode;
|
|
1886
1895
|
const data = this.getData();
|
|
@@ -2252,7 +2261,7 @@ class Interpreter {
|
|
|
2252
2261
|
return node;
|
|
2253
2262
|
}
|
|
2254
2263
|
getFn(data, expression) {
|
|
2255
|
-
return new Function('data', `
|
|
2264
|
+
return new Function('data', `with(data){return (${expression})}`).bind(undefined, safe(data));
|
|
2256
2265
|
}
|
|
2257
2266
|
getAssignFn(data, expression) {
|
|
2258
2267
|
const valueId = `value_bobe_${date32()}`;
|
|
@@ -2602,6 +2611,7 @@ function bobe(fragments, ...values) {
|
|
|
2602
2611
|
return tokenizer;
|
|
2603
2612
|
};
|
|
2604
2613
|
ui.boundStore = Store.Current;
|
|
2614
|
+
ui[Keys.ProxyFreeObject] = true;
|
|
2605
2615
|
ui.__BOBE_IS_UI = true;
|
|
2606
2616
|
return ui;
|
|
2607
2617
|
}
|