@marko/runtime-tags 6.0.107 → 6.0.109
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/debug/dom.js +88 -94
- package/dist/debug/dom.mjs +88 -94
- package/dist/dom/control-flow.d.ts +8 -8
- package/dist/dom/renderer.d.ts +2 -4
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +54 -68
- package/dist/dom.mjs +54 -68
- package/dist/translator/index.js +65 -47
- package/dist/translator/util/sections.d.ts +1 -0
- package/package.json +2 -2
package/dist/debug/dom.js
CHANGED
|
@@ -57,7 +57,6 @@ __export(dom_exports, {
|
|
|
57
57
|
_closure_get: () => _closure_get,
|
|
58
58
|
_const: () => _const,
|
|
59
59
|
_content: () => _content,
|
|
60
|
-
_content_branch: () => _content_branch,
|
|
61
60
|
_content_closures: () => _content_closures,
|
|
62
61
|
_content_resume: () => _content_resume,
|
|
63
62
|
_dynamic_tag: () => _dynamic_tag,
|
|
@@ -1095,8 +1094,8 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
1095
1094
|
ownerLoopNodeAccessor = decodeAccessor3(ownerLoopNodeAccessor);
|
|
1096
1095
|
const scopeAccessor = "BranchScopes:" /* BranchScopes */ + ownerLoopNodeAccessor;
|
|
1097
1096
|
const ownerSignal = (ownerScope) => {
|
|
1098
|
-
|
|
1099
|
-
if (scopes) {
|
|
1097
|
+
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
1098
|
+
if (scopes.length) {
|
|
1100
1099
|
queueRender(
|
|
1101
1100
|
ownerScope,
|
|
1102
1101
|
() => {
|
|
@@ -1108,7 +1107,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
1108
1107
|
},
|
|
1109
1108
|
-1,
|
|
1110
1109
|
0,
|
|
1111
|
-
|
|
1110
|
+
scopes[0]["#Id" /* Id */]
|
|
1112
1111
|
);
|
|
1113
1112
|
}
|
|
1114
1113
|
};
|
|
@@ -1317,9 +1316,6 @@ function _content_closures(renderer, closureFns) {
|
|
|
1317
1316
|
return instance;
|
|
1318
1317
|
};
|
|
1319
1318
|
}
|
|
1320
|
-
function _content_branch(template, walks, setup, params) {
|
|
1321
|
-
return _content("", template, walks, setup, params)();
|
|
1322
|
-
}
|
|
1323
1319
|
var cloneCache = {};
|
|
1324
1320
|
function createCloneableHTML(html, ns) {
|
|
1325
1321
|
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
@@ -1792,10 +1788,11 @@ function longestIncreasingSubsequence(a) {
|
|
|
1792
1788
|
}
|
|
1793
1789
|
|
|
1794
1790
|
// src/dom/control-flow.ts
|
|
1795
|
-
function _await(nodeAccessor,
|
|
1791
|
+
function _await(nodeAccessor, template, walks, setup, params) {
|
|
1796
1792
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1797
1793
|
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
|
1798
1794
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1795
|
+
const renderer = _content("", template, walks, setup)();
|
|
1799
1796
|
enableBranches();
|
|
1800
1797
|
return (scope, promise) => {
|
|
1801
1798
|
const referenceNode = scope[nodeAccessor];
|
|
@@ -1865,7 +1862,7 @@ function _await(nodeAccessor, renderer) {
|
|
|
1865
1862
|
);
|
|
1866
1863
|
referenceNode.remove();
|
|
1867
1864
|
}
|
|
1868
|
-
|
|
1865
|
+
params?.(awaitBranch, [data]);
|
|
1869
1866
|
if (tryWithPlaceholder) {
|
|
1870
1867
|
placeholderShown.add(pendingEffects);
|
|
1871
1868
|
if (!--tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */]) {
|
|
@@ -1904,15 +1901,16 @@ function _await(nodeAccessor, renderer) {
|
|
|
1904
1901
|
);
|
|
1905
1902
|
};
|
|
1906
1903
|
}
|
|
1907
|
-
function _try(nodeAccessor,
|
|
1904
|
+
function _try(nodeAccessor, template, walks, setup) {
|
|
1908
1905
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1909
1906
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1907
|
+
const renderer = _content("", template, walks, setup)();
|
|
1910
1908
|
return (scope, input) => {
|
|
1911
1909
|
if (!scope[branchAccessor]) {
|
|
1912
1910
|
setConditionalRenderer(
|
|
1913
1911
|
scope,
|
|
1914
1912
|
nodeAccessor,
|
|
1915
|
-
|
|
1913
|
+
renderer,
|
|
1916
1914
|
createAndSetupBranch
|
|
1917
1915
|
);
|
|
1918
1916
|
}
|
|
@@ -1951,9 +1949,21 @@ function renderCatch(scope, error) {
|
|
|
1951
1949
|
);
|
|
1952
1950
|
}
|
|
1953
1951
|
}
|
|
1954
|
-
function _if(nodeAccessor, ...
|
|
1952
|
+
function _if(nodeAccessor, ...branchesArgs) {
|
|
1955
1953
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1956
1954
|
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
|
1955
|
+
const branches = [];
|
|
1956
|
+
let i = 0;
|
|
1957
|
+
while (i < branchesArgs.length) {
|
|
1958
|
+
branches.push(
|
|
1959
|
+
_content(
|
|
1960
|
+
"",
|
|
1961
|
+
branchesArgs[i++],
|
|
1962
|
+
branchesArgs[i++],
|
|
1963
|
+
branchesArgs[i++]
|
|
1964
|
+
)()
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1957
1967
|
enableBranches();
|
|
1958
1968
|
return (scope, newBranch) => {
|
|
1959
1969
|
if (newBranch !== scope[branchAccessor]) {
|
|
@@ -2089,91 +2099,75 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
2089
2099
|
referenceNode.remove();
|
|
2090
2100
|
}
|
|
2091
2101
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
if (typeof by === "string") {
|
|
2098
|
-
forOf(
|
|
2099
|
-
all,
|
|
2100
|
-
(item, i) => cb(item[by], [item, i])
|
|
2101
|
-
);
|
|
2102
|
-
} else {
|
|
2103
|
-
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
);
|
|
2107
|
-
}
|
|
2108
|
-
function _for_in(nodeAccessor, renderer) {
|
|
2109
|
-
return loop(
|
|
2110
|
-
nodeAccessor,
|
|
2111
|
-
renderer,
|
|
2112
|
-
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
2113
|
-
);
|
|
2114
|
-
}
|
|
2115
|
-
function _for_to(nodeAccessor, renderer) {
|
|
2116
|
-
return loop(
|
|
2117
|
-
nodeAccessor,
|
|
2118
|
-
renderer,
|
|
2119
|
-
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
2120
|
-
);
|
|
2121
|
-
}
|
|
2122
|
-
function _for_until(nodeAccessor, renderer) {
|
|
2123
|
-
return loop(
|
|
2124
|
-
nodeAccessor,
|
|
2125
|
-
renderer,
|
|
2126
|
-
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
2127
|
-
);
|
|
2128
|
-
}
|
|
2129
|
-
function loop(nodeAccessor, renderer, forEach) {
|
|
2130
|
-
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2131
|
-
const params = renderer.___params;
|
|
2132
|
-
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2133
|
-
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2134
|
-
enableBranches();
|
|
2135
|
-
return (scope, value) => {
|
|
2136
|
-
const referenceNode = scope[nodeAccessor];
|
|
2137
|
-
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2138
|
-
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2139
|
-
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2140
|
-
/* @__PURE__ */ new Map()
|
|
2102
|
+
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
2103
|
+
if (typeof by === "string") {
|
|
2104
|
+
forOf(
|
|
2105
|
+
all,
|
|
2106
|
+
(item, i) => cb(item[by], [item, i])
|
|
2141
2107
|
);
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2108
|
+
} else {
|
|
2109
|
+
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
var _for_in = loop(
|
|
2113
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
2114
|
+
);
|
|
2115
|
+
var _for_to = loop(
|
|
2116
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
2117
|
+
);
|
|
2118
|
+
var _for_until = loop(
|
|
2119
|
+
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
2120
|
+
);
|
|
2121
|
+
function loop(forEach) {
|
|
2122
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
2123
|
+
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2124
|
+
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2125
|
+
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2126
|
+
const renderer = _content("", template, walks, setup)();
|
|
2127
|
+
enableBranches();
|
|
2128
|
+
return (scope, value) => {
|
|
2129
|
+
const referenceNode = scope[nodeAccessor];
|
|
2130
|
+
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2131
|
+
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2132
|
+
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2133
|
+
/* @__PURE__ */ new Map()
|
|
2159
2134
|
);
|
|
2160
|
-
|
|
2161
|
-
newScopesByKey
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2135
|
+
const newScopes = scope[scopesAccessor] = [];
|
|
2136
|
+
const newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map();
|
|
2137
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.["#StartNode" /* StartNode */].parentNode : referenceNode;
|
|
2138
|
+
forEach(value, (key, args) => {
|
|
2139
|
+
if (true) {
|
|
2140
|
+
if (newScopesByKey.has(key)) {
|
|
2141
|
+
console.error(
|
|
2142
|
+
`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
|
|
2143
|
+
key
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
const branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
2148
|
+
scope["$global" /* Global */],
|
|
2149
|
+
renderer,
|
|
2150
|
+
scope,
|
|
2151
|
+
parentNode
|
|
2152
|
+
);
|
|
2153
|
+
params?.(branch, args);
|
|
2154
|
+
newScopesByKey.set(key, branch);
|
|
2155
|
+
newScopes.push(branch);
|
|
2156
|
+
});
|
|
2157
|
+
let afterReference = null;
|
|
2158
|
+
if (referenceNode !== parentNode) {
|
|
2159
|
+
if (oldScopes.length) {
|
|
2160
|
+
afterReference = oldScopes[oldScopes.length - 1]["#EndNode" /* EndNode */].nextSibling;
|
|
2161
|
+
if (!newScopes.length) {
|
|
2162
|
+
parentNode.insertBefore(referenceNode, afterReference);
|
|
2163
|
+
}
|
|
2164
|
+
} else if (newScopes.length) {
|
|
2165
|
+
afterReference = referenceNode.nextSibling;
|
|
2166
|
+
referenceNode.remove();
|
|
2170
2167
|
}
|
|
2171
|
-
} else if (newScopes.length) {
|
|
2172
|
-
afterReference = referenceNode.nextSibling;
|
|
2173
|
-
referenceNode.remove();
|
|
2174
2168
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2169
|
+
reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
2170
|
+
};
|
|
2177
2171
|
};
|
|
2178
2172
|
}
|
|
2179
2173
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
@@ -2416,7 +2410,7 @@ var compat = {
|
|
|
2416
2410
|
return value;
|
|
2417
2411
|
},
|
|
2418
2412
|
createRenderer(params, clone) {
|
|
2419
|
-
const renderer =
|
|
2413
|
+
const renderer = _content("", 0, 0, 0, params)();
|
|
2420
2414
|
renderer.___clone = (branch) => {
|
|
2421
2415
|
const cloned = clone();
|
|
2422
2416
|
branch["#StartNode" /* StartNode */] = cloned.startNode;
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -991,8 +991,8 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
991
991
|
ownerLoopNodeAccessor = decodeAccessor3(ownerLoopNodeAccessor);
|
|
992
992
|
const scopeAccessor = "BranchScopes:" /* BranchScopes */ + ownerLoopNodeAccessor;
|
|
993
993
|
const ownerSignal = (ownerScope) => {
|
|
994
|
-
|
|
995
|
-
if (scopes) {
|
|
994
|
+
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
995
|
+
if (scopes.length) {
|
|
996
996
|
queueRender(
|
|
997
997
|
ownerScope,
|
|
998
998
|
() => {
|
|
@@ -1004,7 +1004,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
1004
1004
|
},
|
|
1005
1005
|
-1,
|
|
1006
1006
|
0,
|
|
1007
|
-
|
|
1007
|
+
scopes[0]["#Id" /* Id */]
|
|
1008
1008
|
);
|
|
1009
1009
|
}
|
|
1010
1010
|
};
|
|
@@ -1213,9 +1213,6 @@ function _content_closures(renderer, closureFns) {
|
|
|
1213
1213
|
return instance;
|
|
1214
1214
|
};
|
|
1215
1215
|
}
|
|
1216
|
-
function _content_branch(template, walks, setup, params) {
|
|
1217
|
-
return _content("", template, walks, setup, params)();
|
|
1218
|
-
}
|
|
1219
1216
|
var cloneCache = {};
|
|
1220
1217
|
function createCloneableHTML(html, ns) {
|
|
1221
1218
|
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
@@ -1688,10 +1685,11 @@ function longestIncreasingSubsequence(a) {
|
|
|
1688
1685
|
}
|
|
1689
1686
|
|
|
1690
1687
|
// src/dom/control-flow.ts
|
|
1691
|
-
function _await(nodeAccessor,
|
|
1688
|
+
function _await(nodeAccessor, template, walks, setup, params) {
|
|
1692
1689
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1693
1690
|
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
|
1694
1691
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1692
|
+
const renderer = _content("", template, walks, setup)();
|
|
1695
1693
|
enableBranches();
|
|
1696
1694
|
return (scope, promise) => {
|
|
1697
1695
|
const referenceNode = scope[nodeAccessor];
|
|
@@ -1761,7 +1759,7 @@ function _await(nodeAccessor, renderer) {
|
|
|
1761
1759
|
);
|
|
1762
1760
|
referenceNode.remove();
|
|
1763
1761
|
}
|
|
1764
|
-
|
|
1762
|
+
params?.(awaitBranch, [data]);
|
|
1765
1763
|
if (tryWithPlaceholder) {
|
|
1766
1764
|
placeholderShown.add(pendingEffects);
|
|
1767
1765
|
if (!--tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */]) {
|
|
@@ -1800,15 +1798,16 @@ function _await(nodeAccessor, renderer) {
|
|
|
1800
1798
|
);
|
|
1801
1799
|
};
|
|
1802
1800
|
}
|
|
1803
|
-
function _try(nodeAccessor,
|
|
1801
|
+
function _try(nodeAccessor, template, walks, setup) {
|
|
1804
1802
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1805
1803
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1804
|
+
const renderer = _content("", template, walks, setup)();
|
|
1806
1805
|
return (scope, input) => {
|
|
1807
1806
|
if (!scope[branchAccessor]) {
|
|
1808
1807
|
setConditionalRenderer(
|
|
1809
1808
|
scope,
|
|
1810
1809
|
nodeAccessor,
|
|
1811
|
-
|
|
1810
|
+
renderer,
|
|
1812
1811
|
createAndSetupBranch
|
|
1813
1812
|
);
|
|
1814
1813
|
}
|
|
@@ -1847,9 +1846,21 @@ function renderCatch(scope, error) {
|
|
|
1847
1846
|
);
|
|
1848
1847
|
}
|
|
1849
1848
|
}
|
|
1850
|
-
function _if(nodeAccessor, ...
|
|
1849
|
+
function _if(nodeAccessor, ...branchesArgs) {
|
|
1851
1850
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1852
1851
|
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
|
1852
|
+
const branches = [];
|
|
1853
|
+
let i = 0;
|
|
1854
|
+
while (i < branchesArgs.length) {
|
|
1855
|
+
branches.push(
|
|
1856
|
+
_content(
|
|
1857
|
+
"",
|
|
1858
|
+
branchesArgs[i++],
|
|
1859
|
+
branchesArgs[i++],
|
|
1860
|
+
branchesArgs[i++]
|
|
1861
|
+
)()
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1853
1864
|
enableBranches();
|
|
1854
1865
|
return (scope, newBranch) => {
|
|
1855
1866
|
if (newBranch !== scope[branchAccessor]) {
|
|
@@ -1985,91 +1996,75 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
1985
1996
|
referenceNode.remove();
|
|
1986
1997
|
}
|
|
1987
1998
|
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
if (typeof by === "string") {
|
|
1994
|
-
forOf(
|
|
1995
|
-
all,
|
|
1996
|
-
(item, i) => cb(item[by], [item, i])
|
|
1997
|
-
);
|
|
1998
|
-
} else {
|
|
1999
|
-
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
function _for_in(nodeAccessor, renderer) {
|
|
2005
|
-
return loop(
|
|
2006
|
-
nodeAccessor,
|
|
2007
|
-
renderer,
|
|
2008
|
-
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
2009
|
-
);
|
|
2010
|
-
}
|
|
2011
|
-
function _for_to(nodeAccessor, renderer) {
|
|
2012
|
-
return loop(
|
|
2013
|
-
nodeAccessor,
|
|
2014
|
-
renderer,
|
|
2015
|
-
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
2016
|
-
);
|
|
2017
|
-
}
|
|
2018
|
-
function _for_until(nodeAccessor, renderer) {
|
|
2019
|
-
return loop(
|
|
2020
|
-
nodeAccessor,
|
|
2021
|
-
renderer,
|
|
2022
|
-
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
2023
|
-
);
|
|
2024
|
-
}
|
|
2025
|
-
function loop(nodeAccessor, renderer, forEach) {
|
|
2026
|
-
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2027
|
-
const params = renderer.___params;
|
|
2028
|
-
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2029
|
-
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2030
|
-
enableBranches();
|
|
2031
|
-
return (scope, value) => {
|
|
2032
|
-
const referenceNode = scope[nodeAccessor];
|
|
2033
|
-
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2034
|
-
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2035
|
-
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2036
|
-
/* @__PURE__ */ new Map()
|
|
1999
|
+
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
2000
|
+
if (typeof by === "string") {
|
|
2001
|
+
forOf(
|
|
2002
|
+
all,
|
|
2003
|
+
(item, i) => cb(item[by], [item, i])
|
|
2037
2004
|
);
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2005
|
+
} else {
|
|
2006
|
+
forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
var _for_in = loop(
|
|
2010
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
2011
|
+
);
|
|
2012
|
+
var _for_to = loop(
|
|
2013
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
2014
|
+
);
|
|
2015
|
+
var _for_until = loop(
|
|
2016
|
+
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
2017
|
+
);
|
|
2018
|
+
function loop(forEach) {
|
|
2019
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
2020
|
+
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2021
|
+
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2022
|
+
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2023
|
+
const renderer = _content("", template, walks, setup)();
|
|
2024
|
+
enableBranches();
|
|
2025
|
+
return (scope, value) => {
|
|
2026
|
+
const referenceNode = scope[nodeAccessor];
|
|
2027
|
+
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2028
|
+
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2029
|
+
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2030
|
+
/* @__PURE__ */ new Map()
|
|
2055
2031
|
);
|
|
2056
|
-
|
|
2057
|
-
newScopesByKey
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2032
|
+
const newScopes = scope[scopesAccessor] = [];
|
|
2033
|
+
const newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map();
|
|
2034
|
+
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.["#StartNode" /* StartNode */].parentNode : referenceNode;
|
|
2035
|
+
forEach(value, (key, args) => {
|
|
2036
|
+
if (true) {
|
|
2037
|
+
if (newScopesByKey.has(key)) {
|
|
2038
|
+
console.error(
|
|
2039
|
+
`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
|
|
2040
|
+
key
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
const branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
2045
|
+
scope["$global" /* Global */],
|
|
2046
|
+
renderer,
|
|
2047
|
+
scope,
|
|
2048
|
+
parentNode
|
|
2049
|
+
);
|
|
2050
|
+
params?.(branch, args);
|
|
2051
|
+
newScopesByKey.set(key, branch);
|
|
2052
|
+
newScopes.push(branch);
|
|
2053
|
+
});
|
|
2054
|
+
let afterReference = null;
|
|
2055
|
+
if (referenceNode !== parentNode) {
|
|
2056
|
+
if (oldScopes.length) {
|
|
2057
|
+
afterReference = oldScopes[oldScopes.length - 1]["#EndNode" /* EndNode */].nextSibling;
|
|
2058
|
+
if (!newScopes.length) {
|
|
2059
|
+
parentNode.insertBefore(referenceNode, afterReference);
|
|
2060
|
+
}
|
|
2061
|
+
} else if (newScopes.length) {
|
|
2062
|
+
afterReference = referenceNode.nextSibling;
|
|
2063
|
+
referenceNode.remove();
|
|
2066
2064
|
}
|
|
2067
|
-
} else if (newScopes.length) {
|
|
2068
|
-
afterReference = referenceNode.nextSibling;
|
|
2069
|
-
referenceNode.remove();
|
|
2070
2065
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2066
|
+
reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
2067
|
+
};
|
|
2073
2068
|
};
|
|
2074
2069
|
}
|
|
2075
2070
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
@@ -2312,7 +2307,7 @@ var compat = {
|
|
|
2312
2307
|
return value;
|
|
2313
2308
|
},
|
|
2314
2309
|
createRenderer(params, clone) {
|
|
2315
|
-
const renderer =
|
|
2310
|
+
const renderer = _content("", 0, 0, 0, params)();
|
|
2316
2311
|
renderer.___clone = (branch) => {
|
|
2317
2312
|
const cloned = clone();
|
|
2318
2313
|
branch["#StartNode" /* StartNode */] = cloned.startNode;
|
|
@@ -2499,7 +2494,6 @@ export {
|
|
|
2499
2494
|
_closure_get,
|
|
2500
2495
|
_const,
|
|
2501
2496
|
_content,
|
|
2502
|
-
_content_branch,
|
|
2503
2497
|
_content_closures,
|
|
2504
2498
|
_content_resume,
|
|
2505
2499
|
_dynamic_tag,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { type Accessor, AccessorProp, type BranchScope, type EncodedAccessor, type Scope } from "../common/types";
|
|
2
|
-
import { type Renderer } from "./renderer";
|
|
2
|
+
import { type Renderer, type SetupFn } from "./renderer";
|
|
3
3
|
import { type Signal } from "./signals";
|
|
4
|
-
export declare function _await(nodeAccessor: EncodedAccessor,
|
|
5
|
-
export declare function _try(nodeAccessor: EncodedAccessor,
|
|
4
|
+
export declare function _await(nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>): (scope: Scope, promise: Promise<unknown>) => void;
|
|
5
|
+
export declare function _try(nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0): (scope: Scope, input: {
|
|
6
6
|
catch: unknown;
|
|
7
7
|
placeholder: unknown;
|
|
8
8
|
}) => void;
|
|
9
9
|
export declare function renderCatch(scope: Scope, error: unknown): void;
|
|
10
|
-
export declare function _if(nodeAccessor: EncodedAccessor, ...
|
|
10
|
+
export declare function _if(nodeAccessor: EncodedAccessor, ...branchesArgs: (string | SetupFn | 0)[]): (scope: Scope, newBranch: number) => void;
|
|
11
11
|
export declare function patchDynamicTag(fn: <T extends typeof _dynamic_tag>(cond: T) => T): void;
|
|
12
12
|
export declare let _dynamic_tag: (nodeAccessor: EncodedAccessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
|
|
13
13
|
export declare function _resume_dynamic_tag(): void;
|
|
14
14
|
export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: ($global: Scope[AccessorProp.Global], renderer: NonNullable<T>, parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
|
|
15
|
-
export declare
|
|
16
|
-
export declare
|
|
17
|
-
export declare
|
|
18
|
-
export declare
|
|
15
|
+
export declare const _for_of: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
|
|
16
|
+
export declare const _for_in: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
|
|
17
|
+
export declare const _for_to: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [to: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
|
|
18
|
+
export declare const _for_until: (nodeAccessor: EncodedAccessor, template?: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown>) => (scope: Scope, value: [until: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
|
package/dist/dom/renderer.d.ts
CHANGED
|
@@ -10,14 +10,12 @@ export type Renderer = {
|
|
|
10
10
|
___localClosures?: Record<Accessor, Signal<unknown>>;
|
|
11
11
|
___localClosureValues?: Record<Accessor, unknown>;
|
|
12
12
|
};
|
|
13
|
-
type SetupFn = (scope: Scope) => void;
|
|
13
|
+
export type SetupFn = (scope: Scope) => void;
|
|
14
14
|
export declare function createBranch($global: Scope[AccessorProp.Global], renderer: Renderer | string, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
|
|
15
15
|
export declare function createAndSetupBranch($global: Scope[AccessorProp.Global], renderer: Renderer, parentScope: Scope | undefined, parentNode: ParentNode): BranchScope;
|
|
16
16
|
export declare function setupBranch(renderer: Renderer, branch: BranchScope): BranchScope;
|
|
17
|
-
export declare function _content(id: string, template
|
|
17
|
+
export declare function _content(id: string, template?: string | 0, walks?: string | 0, setup?: {
|
|
18
18
|
_: Signal<unknown>;
|
|
19
19
|
} | SetupFn | 0, params?: Signal<unknown> | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
|
|
20
20
|
export declare function _content_resume(id: string, template: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown> | 0, dynamicScopesAccessor?: Accessor): (owner?: Scope) => Renderer;
|
|
21
21
|
export declare function _content_closures(renderer: ReturnType<typeof _content>, closureFns: Record<Accessor, SignalFn>): (owner: Scope, closureValues: Record<Accessor, unknown>) => Renderer;
|
|
22
|
-
export declare function _content_branch(template: string | 0, walks?: string | 0, setup?: SetupFn | 0, params?: Signal<unknown> | 0): Renderer;
|
|
23
|
-
export {};
|
package/dist/dom.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_di
|
|
|
9
9
|
export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _text, _text_content, } from "./dom/dom";
|
|
10
10
|
export { _on } from "./dom/event";
|
|
11
11
|
export { _enable_catch as _enable_catch, run } from "./dom/queue";
|
|
12
|
-
export { _content,
|
|
12
|
+
export { _content, _content_closures, _content_resume } from "./dom/renderer";
|
|
13
13
|
export { _el, _resume, _var_resume, init } from "./dom/resume";
|
|
14
14
|
export { _child_setup, _closure, _closure_get, _const, _el_read, _for_closure, _hoist, _id, _if_closure, _let, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
|
15
15
|
export { _template } from "./dom/template";
|
package/dist/dom.js
CHANGED
|
@@ -54,7 +54,6 @@ __export(dom_exports, {
|
|
|
54
54
|
_closure_get: () => _closure_get,
|
|
55
55
|
_const: () => _const,
|
|
56
56
|
_content: () => _content,
|
|
57
|
-
_content_branch: () => _content_branch,
|
|
58
57
|
_content_closures: () => _content_closures,
|
|
59
58
|
_content_resume: () => _content_resume,
|
|
60
59
|
_dynamic_tag: () => _dynamic_tag,
|
|
@@ -665,8 +664,8 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
|
|
|
665
664
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
666
665
|
ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
|
|
667
666
|
let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
668
|
-
let scopes = ownerScope[scopeAccessor];
|
|
669
|
-
scopes && queueRender(
|
|
667
|
+
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
668
|
+
scopes.length && queueRender(
|
|
670
669
|
ownerScope,
|
|
671
670
|
() => {
|
|
672
671
|
for (let scope of scopes)
|
|
@@ -674,7 +673,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
674
673
|
},
|
|
675
674
|
-1,
|
|
676
675
|
0,
|
|
677
|
-
|
|
676
|
+
scopes[0].L
|
|
678
677
|
);
|
|
679
678
|
};
|
|
680
679
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -815,9 +814,6 @@ function _content_closures(renderer, closureFns) {
|
|
|
815
814
|
return instance.l = closureSignals, instance.o = closureValues, instance;
|
|
816
815
|
};
|
|
817
816
|
}
|
|
818
|
-
function _content_branch(template, walks, setup, params) {
|
|
819
|
-
return _content("", template, walks, setup, params)();
|
|
820
|
-
}
|
|
821
817
|
var cloneCache = {};
|
|
822
818
|
function createCloneableHTML(html, ns) {
|
|
823
819
|
let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
|
|
@@ -1121,9 +1117,9 @@ function longestIncreasingSubsequence(a) {
|
|
|
1121
1117
|
}
|
|
1122
1118
|
|
|
1123
1119
|
// src/dom/control-flow.ts
|
|
1124
|
-
function _await(nodeAccessor,
|
|
1120
|
+
function _await(nodeAccessor, template, walks, setup, params) {
|
|
1125
1121
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1126
|
-
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
|
|
1122
|
+
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1127
1123
|
return enableBranches(), (scope, promise) => {
|
|
1128
1124
|
let referenceNode = scope[nodeAccessor], tryWithPlaceholder = findBranchWithKey(
|
|
1129
1125
|
scope,
|
|
@@ -1170,7 +1166,7 @@ function _await(nodeAccessor, renderer) {
|
|
|
1170
1166
|
),
|
|
1171
1167
|
referenceNode.parentNode,
|
|
1172
1168
|
referenceNode
|
|
1173
|
-
), referenceNode.remove()),
|
|
1169
|
+
), referenceNode.remove()), params?.(awaitBranch, [data]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.O)) {
|
|
1174
1170
|
let placeholderBranch = tryWithPlaceholder.P;
|
|
1175
1171
|
tryWithPlaceholder.P = 0, placeholderBranch && (placeholderBranch.S.parentNode.insertBefore(
|
|
1176
1172
|
tryWithPlaceholder.S.parentNode,
|
|
@@ -1190,14 +1186,14 @@ function _await(nodeAccessor, renderer) {
|
|
|
1190
1186
|
);
|
|
1191
1187
|
};
|
|
1192
1188
|
}
|
|
1193
|
-
function _try(nodeAccessor,
|
|
1189
|
+
function _try(nodeAccessor, template, walks, setup) {
|
|
1194
1190
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1195
|
-
let branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
|
|
1191
|
+
let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1196
1192
|
return (scope, input) => {
|
|
1197
1193
|
scope[branchAccessor] || setConditionalRenderer(
|
|
1198
1194
|
scope,
|
|
1199
1195
|
nodeAccessor,
|
|
1200
|
-
|
|
1196
|
+
renderer,
|
|
1201
1197
|
createAndSetupBranch
|
|
1202
1198
|
);
|
|
1203
1199
|
let branch = scope[branchAccessor];
|
|
@@ -1222,9 +1218,18 @@ function renderCatch(scope, error) {
|
|
|
1222
1218
|
} else
|
|
1223
1219
|
throw error;
|
|
1224
1220
|
}
|
|
1225
|
-
function _if(nodeAccessor, ...
|
|
1221
|
+
function _if(nodeAccessor, ...branchesArgs) {
|
|
1226
1222
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1227
|
-
let branchAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1223
|
+
let branchAccessor = "D" /* ConditionalRenderer */ + nodeAccessor, branches = [], i = 0;
|
|
1224
|
+
for (; i < branchesArgs.length; )
|
|
1225
|
+
branches.push(
|
|
1226
|
+
_content(
|
|
1227
|
+
"",
|
|
1228
|
+
branchesArgs[i++],
|
|
1229
|
+
branchesArgs[i++],
|
|
1230
|
+
branchesArgs[i++]
|
|
1231
|
+
)()
|
|
1232
|
+
);
|
|
1228
1233
|
return enableBranches(), (scope, newBranch) => {
|
|
1229
1234
|
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
|
1230
1235
|
scope,
|
|
@@ -1318,58 +1323,39 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
1318
1323
|
prevBranch.S
|
|
1319
1324
|
), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
|
1320
1325
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
)
|
|
1332
|
-
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1335
|
-
nodeAccessor
|
|
1336
|
-
renderer,
|
|
1337
|
-
(
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
}
|
|
1354
|
-
function loop(nodeAccessor, renderer, forEach) {
|
|
1355
|
-
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1356
|
-
let params = renderer.a, scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, scopesByKeyAccessor = "A" /* BranchScopes */ + scopesAccessor;
|
|
1357
|
-
return enableBranches(), (scope, value) => {
|
|
1358
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
1359
|
-
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1360
|
-
/* @__PURE__ */ new Map()
|
|
1361
|
-
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1362
|
-
forEach(value, (key, args) => {
|
|
1363
|
-
let branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
1364
|
-
scope.$,
|
|
1365
|
-
renderer,
|
|
1366
|
-
scope,
|
|
1367
|
-
parentNode
|
|
1368
|
-
);
|
|
1369
|
-
params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1370
|
-
});
|
|
1371
|
-
let afterReference = null;
|
|
1372
|
-
referenceNode !== parentNode && (oldScopes.length ? (afterReference = oldScopes[oldScopes.length - 1].K.nextSibling, newScopes.length || parentNode.insertBefore(referenceNode, afterReference)) : newScopes.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
1326
|
+
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
1327
|
+
typeof by == "string" ? forOf(
|
|
1328
|
+
all,
|
|
1329
|
+
(item, i) => cb(item[by], [item, i])
|
|
1330
|
+
) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
1331
|
+
}), _for_in = loop(
|
|
1332
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
1333
|
+
), _for_to = loop(
|
|
1334
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
1335
|
+
), _for_until = loop(
|
|
1336
|
+
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
1337
|
+
);
|
|
1338
|
+
function loop(forEach) {
|
|
1339
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
1340
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1341
|
+
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, scopesByKeyAccessor = "A" /* BranchScopes */ + scopesAccessor, renderer = _content("", template, walks, setup)();
|
|
1342
|
+
return enableBranches(), (scope, value) => {
|
|
1343
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
1344
|
+
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1345
|
+
/* @__PURE__ */ new Map()
|
|
1346
|
+
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1347
|
+
forEach(value, (key, args) => {
|
|
1348
|
+
let branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
1349
|
+
scope.$,
|
|
1350
|
+
renderer,
|
|
1351
|
+
scope,
|
|
1352
|
+
parentNode
|
|
1353
|
+
);
|
|
1354
|
+
params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1355
|
+
});
|
|
1356
|
+
let afterReference = null;
|
|
1357
|
+
referenceNode !== parentNode && (oldScopes.length ? (afterReference = oldScopes[oldScopes.length - 1].K.nextSibling, newScopes.length || parentNode.insertBefore(referenceNode, afterReference)) : newScopes.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
1358
|
+
};
|
|
1373
1359
|
};
|
|
1374
1360
|
}
|
|
1375
1361
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
@@ -1532,7 +1518,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1532
1518
|
) : value;
|
|
1533
1519
|
},
|
|
1534
1520
|
createRenderer(params, clone) {
|
|
1535
|
-
let renderer =
|
|
1521
|
+
let renderer = _content("", 0, 0, 0, params)();
|
|
1536
1522
|
return renderer.f = (branch) => {
|
|
1537
1523
|
let cloned = clone();
|
|
1538
1524
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
package/dist/dom.mjs
CHANGED
|
@@ -564,8 +564,8 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
|
|
|
564
564
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
565
565
|
ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
|
|
566
566
|
let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
567
|
-
let scopes = ownerScope[scopeAccessor];
|
|
568
|
-
scopes && queueRender(
|
|
567
|
+
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
568
|
+
scopes.length && queueRender(
|
|
569
569
|
ownerScope,
|
|
570
570
|
() => {
|
|
571
571
|
for (let scope of scopes)
|
|
@@ -573,7 +573,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
573
573
|
},
|
|
574
574
|
-1,
|
|
575
575
|
0,
|
|
576
|
-
|
|
576
|
+
scopes[0].L
|
|
577
577
|
);
|
|
578
578
|
};
|
|
579
579
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -714,9 +714,6 @@ function _content_closures(renderer, closureFns) {
|
|
|
714
714
|
return instance.l = closureSignals, instance.o = closureValues, instance;
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
|
-
function _content_branch(template, walks, setup, params) {
|
|
718
|
-
return _content("", template, walks, setup, params)();
|
|
719
|
-
}
|
|
720
717
|
var cloneCache = {};
|
|
721
718
|
function createCloneableHTML(html, ns) {
|
|
722
719
|
let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
|
|
@@ -1020,9 +1017,9 @@ function longestIncreasingSubsequence(a) {
|
|
|
1020
1017
|
}
|
|
1021
1018
|
|
|
1022
1019
|
// src/dom/control-flow.ts
|
|
1023
|
-
function _await(nodeAccessor,
|
|
1020
|
+
function _await(nodeAccessor, template, walks, setup, params) {
|
|
1024
1021
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1025
|
-
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
|
|
1022
|
+
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1026
1023
|
return enableBranches(), (scope, promise) => {
|
|
1027
1024
|
let referenceNode = scope[nodeAccessor], tryWithPlaceholder = findBranchWithKey(
|
|
1028
1025
|
scope,
|
|
@@ -1069,7 +1066,7 @@ function _await(nodeAccessor, renderer) {
|
|
|
1069
1066
|
),
|
|
1070
1067
|
referenceNode.parentNode,
|
|
1071
1068
|
referenceNode
|
|
1072
|
-
), referenceNode.remove()),
|
|
1069
|
+
), referenceNode.remove()), params?.(awaitBranch, [data]), tryWithPlaceholder && (placeholderShown.add(pendingEffects), !--tryWithPlaceholder.O)) {
|
|
1073
1070
|
let placeholderBranch = tryWithPlaceholder.P;
|
|
1074
1071
|
tryWithPlaceholder.P = 0, placeholderBranch && (placeholderBranch.S.parentNode.insertBefore(
|
|
1075
1072
|
tryWithPlaceholder.S.parentNode,
|
|
@@ -1089,14 +1086,14 @@ function _await(nodeAccessor, renderer) {
|
|
|
1089
1086
|
);
|
|
1090
1087
|
};
|
|
1091
1088
|
}
|
|
1092
|
-
function _try(nodeAccessor,
|
|
1089
|
+
function _try(nodeAccessor, template, walks, setup) {
|
|
1093
1090
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1094
|
-
let branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
|
|
1091
|
+
let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1095
1092
|
return (scope, input) => {
|
|
1096
1093
|
scope[branchAccessor] || setConditionalRenderer(
|
|
1097
1094
|
scope,
|
|
1098
1095
|
nodeAccessor,
|
|
1099
|
-
|
|
1096
|
+
renderer,
|
|
1100
1097
|
createAndSetupBranch
|
|
1101
1098
|
);
|
|
1102
1099
|
let branch = scope[branchAccessor];
|
|
@@ -1121,9 +1118,18 @@ function renderCatch(scope, error) {
|
|
|
1121
1118
|
} else
|
|
1122
1119
|
throw error;
|
|
1123
1120
|
}
|
|
1124
|
-
function _if(nodeAccessor, ...
|
|
1121
|
+
function _if(nodeAccessor, ...branchesArgs) {
|
|
1125
1122
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1126
|
-
let branchAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1123
|
+
let branchAccessor = "D" /* ConditionalRenderer */ + nodeAccessor, branches = [], i = 0;
|
|
1124
|
+
for (; i < branchesArgs.length; )
|
|
1125
|
+
branches.push(
|
|
1126
|
+
_content(
|
|
1127
|
+
"",
|
|
1128
|
+
branchesArgs[i++],
|
|
1129
|
+
branchesArgs[i++],
|
|
1130
|
+
branchesArgs[i++]
|
|
1131
|
+
)()
|
|
1132
|
+
);
|
|
1127
1133
|
return enableBranches(), (scope, newBranch) => {
|
|
1128
1134
|
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
|
1129
1135
|
scope,
|
|
@@ -1217,58 +1223,39 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
1217
1223
|
prevBranch.S
|
|
1218
1224
|
), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
|
1219
1225
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
)
|
|
1231
|
-
|
|
1232
|
-
function
|
|
1233
|
-
return
|
|
1234
|
-
nodeAccessor
|
|
1235
|
-
renderer,
|
|
1236
|
-
(
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
function loop(nodeAccessor, renderer, forEach) {
|
|
1254
|
-
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1255
|
-
let params = renderer.a, scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, scopesByKeyAccessor = "A" /* BranchScopes */ + scopesAccessor;
|
|
1256
|
-
return enableBranches(), (scope, value) => {
|
|
1257
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
1258
|
-
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1259
|
-
/* @__PURE__ */ new Map()
|
|
1260
|
-
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1261
|
-
forEach(value, (key, args) => {
|
|
1262
|
-
let branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
1263
|
-
scope.$,
|
|
1264
|
-
renderer,
|
|
1265
|
-
scope,
|
|
1266
|
-
parentNode
|
|
1267
|
-
);
|
|
1268
|
-
params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1269
|
-
});
|
|
1270
|
-
let afterReference = null;
|
|
1271
|
-
referenceNode !== parentNode && (oldScopes.length ? (afterReference = oldScopes[oldScopes.length - 1].K.nextSibling, newScopes.length || parentNode.insertBefore(referenceNode, afterReference)) : newScopes.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
1226
|
+
var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
1227
|
+
typeof by == "string" ? forOf(
|
|
1228
|
+
all,
|
|
1229
|
+
(item, i) => cb(item[by], [item, i])
|
|
1230
|
+
) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
1231
|
+
}), _for_in = loop(
|
|
1232
|
+
([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
|
|
1233
|
+
), _for_to = loop(
|
|
1234
|
+
([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
|
|
1235
|
+
), _for_until = loop(
|
|
1236
|
+
([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
|
|
1237
|
+
);
|
|
1238
|
+
function loop(forEach) {
|
|
1239
|
+
return (nodeAccessor, template, walks, setup, params) => {
|
|
1240
|
+
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1241
|
+
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, scopesByKeyAccessor = "A" /* BranchScopes */ + scopesAccessor, renderer = _content("", template, walks, setup)();
|
|
1242
|
+
return enableBranches(), (scope, value) => {
|
|
1243
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
1244
|
+
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1245
|
+
/* @__PURE__ */ new Map()
|
|
1246
|
+
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1247
|
+
forEach(value, (key, args) => {
|
|
1248
|
+
let branch = oldScopesByKey.get(key) || createAndSetupBranch(
|
|
1249
|
+
scope.$,
|
|
1250
|
+
renderer,
|
|
1251
|
+
scope,
|
|
1252
|
+
parentNode
|
|
1253
|
+
);
|
|
1254
|
+
params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1255
|
+
});
|
|
1256
|
+
let afterReference = null;
|
|
1257
|
+
referenceNode !== parentNode && (oldScopes.length ? (afterReference = oldScopes[oldScopes.length - 1].K.nextSibling, newScopes.length || parentNode.insertBefore(referenceNode, afterReference)) : newScopes.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldScopes, newScopes, afterReference);
|
|
1258
|
+
};
|
|
1272
1259
|
};
|
|
1273
1260
|
}
|
|
1274
1261
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
@@ -1431,7 +1418,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1431
1418
|
) : value;
|
|
1432
1419
|
},
|
|
1433
1420
|
createRenderer(params, clone) {
|
|
1434
|
-
let renderer =
|
|
1421
|
+
let renderer = _content("", 0, 0, 0, params)();
|
|
1435
1422
|
return renderer.f = (branch) => {
|
|
1436
1423
|
let cloned = clone();
|
|
1437
1424
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
@@ -1562,7 +1549,6 @@ export {
|
|
|
1562
1549
|
_closure_get,
|
|
1563
1550
|
_const,
|
|
1564
1551
|
_content,
|
|
1565
|
-
_content_branch,
|
|
1566
1552
|
_content_closures,
|
|
1567
1553
|
_content_resume,
|
|
1568
1554
|
_dynamic_tag,
|
package/dist/translator/index.js
CHANGED
|
@@ -1779,6 +1779,7 @@ var [_getScopeIdentifier] = createSectionState(
|
|
|
1779
1779
|
"scopeIdentifier",
|
|
1780
1780
|
() => import_compiler7.types.identifier("undefined")
|
|
1781
1781
|
);
|
|
1782
|
+
var [getBranchRendererArgs, setSectionRendererArgs] = createSectionState("rendererExpression");
|
|
1782
1783
|
function forEachSection(fn) {
|
|
1783
1784
|
const { sections } = (0, import_babel_utils10.getProgram)().node.extra;
|
|
1784
1785
|
sections?.forEach(fn);
|
|
@@ -2505,7 +2506,6 @@ var pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
|
2505
2506
|
"_if_closure",
|
|
2506
2507
|
"_try",
|
|
2507
2508
|
"_dynamic_tag",
|
|
2508
|
-
"_content_branch",
|
|
2509
2509
|
"_content_closures",
|
|
2510
2510
|
"_content",
|
|
2511
2511
|
"_template",
|
|
@@ -4401,54 +4401,58 @@ var dom_default = {
|
|
|
4401
4401
|
const { walks: walks2, writes: writes2, setup: setup2, decls: decls2 } = getSectionMeta(childSection);
|
|
4402
4402
|
writeSignals(childSection);
|
|
4403
4403
|
if (!childSection.downstreamBinding || bindingHasDownstreamExpressions(childSection.downstreamBinding)) {
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
...replaceNullishAndEmptyFunctionsWith0([
|
|
4404
|
+
if (getSectionParentIsOwner(childSection)) {
|
|
4405
|
+
setSectionRendererArgs(childSection, [
|
|
4407
4406
|
writes2,
|
|
4408
4407
|
walks2,
|
|
4409
4408
|
setup2,
|
|
4410
4409
|
tagParamsIdentifier
|
|
4411
|
-
])
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4410
|
+
]);
|
|
4411
|
+
} else {
|
|
4412
|
+
let renderer = callRuntime(
|
|
4413
|
+
getSectionRegisterReasons(childSection) ? "_content_resume" : "_content",
|
|
4414
|
+
import_compiler23.types.stringLiteral(getResumeRegisterId(childSection, "content")),
|
|
4415
|
+
...replaceNullishAndEmptyFunctionsWith0([
|
|
4416
|
+
writes2,
|
|
4417
|
+
walks2,
|
|
4418
|
+
setup2,
|
|
4419
|
+
tagParamsIdentifier,
|
|
4420
|
+
childSection.hoisted || childSection.isHoistThrough ? getSectionInstancesAccessorLiteral(childSection) : void 0
|
|
4421
|
+
])
|
|
4422
|
+
);
|
|
4423
|
+
if (childSection.referencedLocalClosures) {
|
|
4424
|
+
const objProps = [];
|
|
4425
|
+
forEach(childSection.referencedLocalClosures, (closure) => {
|
|
4426
|
+
const closureSignal = getSignal(childSection, closure);
|
|
4427
|
+
const key = toPropertyName(getScopeAccessor(closure, true));
|
|
4428
|
+
if (signalHasStatements(closureSignal)) {
|
|
4429
|
+
const expr = getSignalFn(closureSignal);
|
|
4430
|
+
if (import_compiler23.types.isFunction(expr) && import_compiler23.types.isBlockStatement(expr.body)) {
|
|
4431
|
+
objProps.push(
|
|
4432
|
+
import_compiler23.types.objectMethod("method", key, expr.params, expr.body)
|
|
4433
|
+
);
|
|
4434
|
+
} else {
|
|
4435
|
+
objProps.push(import_compiler23.types.objectProperty(key, expr));
|
|
4436
|
+
}
|
|
4436
4437
|
}
|
|
4438
|
+
});
|
|
4439
|
+
if (objProps.length) {
|
|
4440
|
+
renderer = callRuntime(
|
|
4441
|
+
"_content_closures",
|
|
4442
|
+
renderer,
|
|
4443
|
+
import_compiler23.types.objectExpression(objProps)
|
|
4444
|
+
);
|
|
4437
4445
|
}
|
|
4438
|
-
});
|
|
4439
|
-
if (objProps.length) {
|
|
4440
|
-
renderer = callRuntime(
|
|
4441
|
-
"_content_closures",
|
|
4442
|
-
renderer,
|
|
4443
|
-
import_compiler23.types.objectExpression(objProps)
|
|
4444
|
-
);
|
|
4445
4446
|
}
|
|
4447
|
+
program.node.body.push(
|
|
4448
|
+
import_compiler23.types.variableDeclaration("const", [
|
|
4449
|
+
import_compiler23.types.variableDeclarator(
|
|
4450
|
+
import_compiler23.types.identifier(childSection.name),
|
|
4451
|
+
renderer
|
|
4452
|
+
)
|
|
4453
|
+
])
|
|
4454
|
+
);
|
|
4446
4455
|
}
|
|
4447
|
-
program.node.body.push(
|
|
4448
|
-
import_compiler23.types.variableDeclaration("const", [
|
|
4449
|
-
import_compiler23.types.variableDeclarator(import_compiler23.types.identifier(childSection.name), renderer)
|
|
4450
|
-
])
|
|
4451
|
-
);
|
|
4452
4456
|
}
|
|
4453
4457
|
if (decls2) {
|
|
4454
4458
|
extraDecls = extraDecls ? [...extraDecls, ...decls2] : decls2;
|
|
@@ -6403,7 +6407,9 @@ var for_default = {
|
|
|
6403
6407
|
return callRuntime(
|
|
6404
6408
|
forTypeToDOMRuntime(forType),
|
|
6405
6409
|
getScopeAccessorLiteral(nodeRef, true),
|
|
6406
|
-
|
|
6410
|
+
...replaceNullishAndEmptyFunctionsWith0(
|
|
6411
|
+
getBranchRendererArgs(bodySection)
|
|
6412
|
+
)
|
|
6407
6413
|
);
|
|
6408
6414
|
};
|
|
6409
6415
|
const forAttrs = getKnownAttrValues(node);
|
|
@@ -9210,7 +9216,9 @@ var await_default = {
|
|
|
9210
9216
|
return callRuntime(
|
|
9211
9217
|
"_await",
|
|
9212
9218
|
getScopeAccessorLiteral(nodeRef, true),
|
|
9213
|
-
|
|
9219
|
+
...replaceNullishAndEmptyFunctionsWith0(
|
|
9220
|
+
getBranchRendererArgs(bodySection)
|
|
9221
|
+
)
|
|
9214
9222
|
);
|
|
9215
9223
|
};
|
|
9216
9224
|
addValue(
|
|
@@ -10665,14 +10673,12 @@ var IfTag = {
|
|
|
10665
10673
|
const ifTagSection = getSection(ifTag);
|
|
10666
10674
|
const ifTagExtra = branches[0][0].node.extra;
|
|
10667
10675
|
const nodeRef = getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection);
|
|
10668
|
-
const rendererIdentifiers = [];
|
|
10669
10676
|
let expr = import_compiler48.types.numericLiteral(branches.length);
|
|
10670
10677
|
for (let i = branches.length; i--; ) {
|
|
10671
10678
|
const [branchTag, branchBodySection] = branches[i];
|
|
10672
10679
|
const [testAttr] = branchTag.node.attributes;
|
|
10673
10680
|
const consequent = import_compiler48.types.numericLiteral(branchBodySection ? i : -1);
|
|
10674
10681
|
if (branchBodySection) {
|
|
10675
|
-
rendererIdentifiers.push(import_compiler48.types.identifier(branchBodySection.name));
|
|
10676
10682
|
setClosureSignalBuilder(branchTag, (_closure, render) => {
|
|
10677
10683
|
return callRuntime(
|
|
10678
10684
|
"_if_closure",
|
|
@@ -10687,10 +10693,20 @@ var IfTag = {
|
|
|
10687
10693
|
}
|
|
10688
10694
|
const signal = getSignal(ifTagSection, nodeRef, "if");
|
|
10689
10695
|
signal.build = () => {
|
|
10696
|
+
const rendererArgs = [];
|
|
10697
|
+
for (const [_, branchBodySection] of branches) {
|
|
10698
|
+
if (branchBodySection) {
|
|
10699
|
+
rendererArgs.push(
|
|
10700
|
+
...getBranchRendererArgs(branchBodySection).slice(0, 3)
|
|
10701
|
+
);
|
|
10702
|
+
} else {
|
|
10703
|
+
rendererArgs.push(void 0, void 0, void 0);
|
|
10704
|
+
}
|
|
10705
|
+
}
|
|
10690
10706
|
return callRuntime(
|
|
10691
10707
|
"_if",
|
|
10692
10708
|
getScopeAccessorLiteral(nodeRef, true),
|
|
10693
|
-
...
|
|
10709
|
+
...replaceNullishAndEmptyFunctionsWith0(rendererArgs)
|
|
10694
10710
|
);
|
|
10695
10711
|
};
|
|
10696
10712
|
addValue(ifTagSection, ifTagExtra.referencedBindings, signal, expr);
|
|
@@ -11562,7 +11578,9 @@ var try_default = {
|
|
|
11562
11578
|
return callRuntime(
|
|
11563
11579
|
"_try",
|
|
11564
11580
|
getScopeAccessorLiteral(nodeRef, true),
|
|
11565
|
-
|
|
11581
|
+
...replaceNullishAndEmptyFunctionsWith0(
|
|
11582
|
+
getBranchRendererArgs(bodySection)
|
|
11583
|
+
)
|
|
11566
11584
|
);
|
|
11567
11585
|
};
|
|
11568
11586
|
if (translatedAttrs.statements.length) {
|
|
@@ -67,6 +67,7 @@ export declare function getSectionForBody(body: t.NodePath<t.MarkoTagBody | t.Pr
|
|
|
67
67
|
export declare function getSection(path: t.NodePath): Section;
|
|
68
68
|
export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
|
|
69
69
|
export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
|
|
70
|
+
export declare const getBranchRendererArgs: (section: Section) => [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined], setSectionRendererArgs: (section: Section, value: [template?: t.Expression | undefined, walks?: t.Expression | undefined, setup?: t.Expression | undefined, params?: t.Expression | undefined]) => void;
|
|
70
71
|
export declare const getScopeIdentifier: (section: Section, ignoreDefault?: boolean) => t.Identifier;
|
|
71
72
|
export declare function forEachSection(fn: (section: Section) => void): void;
|
|
72
73
|
export declare function forEachSectionReverse(fn: (section: Section) => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/runtime-tags",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.109",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build": "node -r ~ts ./scripts/bundle.ts"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@marko/compiler": "^5.39.
|
|
51
|
+
"@marko/compiler": "^5.39.42",
|
|
52
52
|
"csstype": "^3.1.3",
|
|
53
53
|
"magic-string": "^0.30.17"
|
|
54
54
|
},
|