@marko/runtime-tags 6.0.108 → 6.0.110
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 +85 -91
- package/dist/debug/dom.mjs +85 -91
- 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 +51 -65
- package/dist/dom.mjs +51 -65
- package/dist/translator/index.js +111 -80
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/walks.d.ts +2 -1
- package/dist/translator/util/writer.d.ts +2 -2
- 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,
|
|
@@ -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
|
@@ -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";
|