summitjs 0.2.0 → 0.3.0
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/README.md +38 -0
- package/dist/net.cjs +259 -0
- package/dist/net.cjs.map +1 -0
- package/dist/net.d.cts +134 -0
- package/dist/net.d.ts +134 -0
- package/dist/net.js +252 -0
- package/dist/net.js.map +1 -0
- package/dist/summit.cjs +23 -9
- package/dist/summit.cjs.map +1 -1
- package/dist/summit.js +23 -9
- package/dist/summit.js.map +1 -1
- package/dist/summit.min.js +7 -7
- package/dist/summit.min.js.map +1 -1
- package/package.json +11 -1
package/dist/summit.js
CHANGED
|
@@ -1361,6 +1361,10 @@ var GLOBAL_ALLOW = /* @__PURE__ */ new Set([
|
|
|
1361
1361
|
"requestAnimationFrame",
|
|
1362
1362
|
"cancelAnimationFrame",
|
|
1363
1363
|
"fetch",
|
|
1364
|
+
"AbortController",
|
|
1365
|
+
"Headers",
|
|
1366
|
+
"Request",
|
|
1367
|
+
"Response",
|
|
1364
1368
|
"alert",
|
|
1365
1369
|
"confirm",
|
|
1366
1370
|
"prompt",
|
|
@@ -1808,6 +1812,10 @@ function evaluateAction(source, root, thisVal) {
|
|
|
1808
1812
|
const program = parse(source, "program");
|
|
1809
1813
|
return new Interpreter(root).run(program, thisVal);
|
|
1810
1814
|
}
|
|
1815
|
+
function compileExpression(source) {
|
|
1816
|
+
const program = parse(source, "expression");
|
|
1817
|
+
return (root, thisVal) => new Interpreter(root).run(program, thisVal);
|
|
1818
|
+
}
|
|
1811
1819
|
|
|
1812
1820
|
// src/errors.ts
|
|
1813
1821
|
var DOCS = "https://velofy.github.io/summit";
|
|
@@ -2885,11 +2893,13 @@ var sFor = (el, meta2, utils) => {
|
|
|
2885
2893
|
el.remove();
|
|
2886
2894
|
const parentScopes = utils.scopes;
|
|
2887
2895
|
let blocks = /* @__PURE__ */ new Map();
|
|
2888
|
-
const
|
|
2889
|
-
|
|
2890
|
-
|
|
2896
|
+
const keyEval = keyExpr ? compileExpression(keyExpr) : null;
|
|
2897
|
+
const keyFor = (it) => {
|
|
2898
|
+
if (!keyEval) return it.objectKey ?? it.index;
|
|
2899
|
+
const data = { [itemName]: it.value };
|
|
2900
|
+
if (indexName) data[indexName] = it.objectKey ?? it.index;
|
|
2891
2901
|
try {
|
|
2892
|
-
return
|
|
2902
|
+
return keyEval(makeEnv(el, data).env);
|
|
2893
2903
|
} catch {
|
|
2894
2904
|
return it.index;
|
|
2895
2905
|
}
|
|
@@ -2911,8 +2921,7 @@ var sFor = (el, meta2, utils) => {
|
|
|
2911
2921
|
const next = /* @__PURE__ */ new Map();
|
|
2912
2922
|
const orderedKeys = [];
|
|
2913
2923
|
for (const it of items) {
|
|
2914
|
-
|
|
2915
|
-
const key = keyFor(it, scope);
|
|
2924
|
+
const key = keyFor(it);
|
|
2916
2925
|
orderedKeys.push(key);
|
|
2917
2926
|
const existing = blocks.get(key);
|
|
2918
2927
|
if (existing) {
|
|
@@ -2921,6 +2930,7 @@ var sFor = (el, meta2, utils) => {
|
|
|
2921
2930
|
next.set(key, existing);
|
|
2922
2931
|
blocks.delete(key);
|
|
2923
2932
|
} else {
|
|
2933
|
+
const scope = makeBlockScope(it);
|
|
2924
2934
|
const node = blueprint.cloneNode(true);
|
|
2925
2935
|
parent.insertBefore(node, anchor2);
|
|
2926
2936
|
utils.initTree(node, [...parentScopes, scope]);
|
|
@@ -2931,9 +2941,13 @@ var sFor = (el, meta2, utils) => {
|
|
|
2931
2941
|
utils.destroyTree(block.node);
|
|
2932
2942
|
block.node.remove();
|
|
2933
2943
|
}
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2944
|
+
let expected = anchor2;
|
|
2945
|
+
for (let i = orderedKeys.length - 1; i >= 0; i--) {
|
|
2946
|
+
const node = next.get(orderedKeys[i]).node;
|
|
2947
|
+
if (node.nextSibling !== expected) {
|
|
2948
|
+
parent.insertBefore(node, expected);
|
|
2949
|
+
}
|
|
2950
|
+
expected = node;
|
|
2937
2951
|
}
|
|
2938
2952
|
blocks = next;
|
|
2939
2953
|
});
|