marko 6.0.152 → 6.0.154
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 +127 -193
- package/dist/debug/dom.mjs +127 -193
- package/dist/debug/html.js +3 -5
- package/dist/debug/html.mjs +3 -5
- package/dist/dom.js +56 -90
- package/dist/dom.mjs +56 -90
- package/dist/html.js +5 -5
- package/dist/html.mjs +5 -5
- package/dist/translator/index.js +32 -30
- package/dist/translator/util/known-tag.d.ts +0 -1
- package/package.json +3 -2
- package/dist/dom/reconcile.d.ts +0 -2
package/dist/debug/dom.js
CHANGED
|
@@ -417,11 +417,12 @@ function destroyBranch(branch) {
|
|
|
417
417
|
function destroyNestedBranches(branch) {
|
|
418
418
|
branch["#Destroyed" /* Destroyed */] = 1;
|
|
419
419
|
branch["#BranchScopes" /* BranchScopes */]?.forEach(destroyNestedBranches);
|
|
420
|
-
branch["#AbortScopes" /* AbortScopes */]?.forEach(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
420
|
+
branch["#AbortScopes" /* AbortScopes */]?.forEach(resetControllers);
|
|
421
|
+
}
|
|
422
|
+
function resetControllers(scope) {
|
|
423
|
+
for (const id in scope["#AbortControllers" /* AbortControllers */]) {
|
|
424
|
+
$signalReset(scope, id);
|
|
425
|
+
}
|
|
425
426
|
}
|
|
426
427
|
function removeAndDestroyBranch(branch) {
|
|
427
428
|
destroyBranch(branch);
|
|
@@ -719,8 +720,8 @@ function walk(startNode, walkCodes, branch) {
|
|
|
719
720
|
}
|
|
720
721
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
721
722
|
let value;
|
|
723
|
+
let currentMultiplier;
|
|
722
724
|
let storedMultiplier = 0;
|
|
723
|
-
let currentMultiplier = 0;
|
|
724
725
|
let currentScopeIndex = 0;
|
|
725
726
|
for (; currentWalkIndex < walkCodes.length; ) {
|
|
726
727
|
value = walkCodes.charCodeAt(currentWalkIndex++);
|
|
@@ -1707,172 +1708,6 @@ function toInsertNode(startNode, endNode) {
|
|
|
1707
1708
|
return parent;
|
|
1708
1709
|
}
|
|
1709
1710
|
|
|
1710
|
-
// src/dom/reconcile.ts
|
|
1711
|
-
var WRONG_POS = 2147483647;
|
|
1712
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
1713
|
-
let oldStart = 0;
|
|
1714
|
-
let newStart = 0;
|
|
1715
|
-
let oldEnd = oldBranches.length - 1;
|
|
1716
|
-
let newEnd = newBranches.length - 1;
|
|
1717
|
-
let oldStartBranch = oldBranches[oldStart];
|
|
1718
|
-
let newStartBranch = newBranches[newStart];
|
|
1719
|
-
let oldEndBranch = oldBranches[oldEnd];
|
|
1720
|
-
let newEndBranch = newBranches[newEnd];
|
|
1721
|
-
let i;
|
|
1722
|
-
let j;
|
|
1723
|
-
let k;
|
|
1724
|
-
let nextSibling;
|
|
1725
|
-
let oldBranch;
|
|
1726
|
-
let newBranch;
|
|
1727
|
-
outer: {
|
|
1728
|
-
while (oldStartBranch === newStartBranch) {
|
|
1729
|
-
++oldStart;
|
|
1730
|
-
++newStart;
|
|
1731
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
1732
|
-
break outer;
|
|
1733
|
-
}
|
|
1734
|
-
oldStartBranch = oldBranches[oldStart];
|
|
1735
|
-
newStartBranch = newBranches[newStart];
|
|
1736
|
-
}
|
|
1737
|
-
while (oldEndBranch === newEndBranch) {
|
|
1738
|
-
--oldEnd;
|
|
1739
|
-
--newEnd;
|
|
1740
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
1741
|
-
break outer;
|
|
1742
|
-
}
|
|
1743
|
-
oldEndBranch = oldBranches[oldEnd];
|
|
1744
|
-
newEndBranch = newBranches[newEnd];
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
if (oldStart > oldEnd) {
|
|
1748
|
-
if (newStart <= newEnd) {
|
|
1749
|
-
k = newEnd + 1;
|
|
1750
|
-
nextSibling = k < newBranches.length ? newBranches[k]["#StartNode" /* StartNode */] : afterReference;
|
|
1751
|
-
do {
|
|
1752
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
|
1753
|
-
} while (newStart <= newEnd);
|
|
1754
|
-
}
|
|
1755
|
-
} else if (newStart > newEnd) {
|
|
1756
|
-
do {
|
|
1757
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
|
1758
|
-
} while (oldStart <= oldEnd);
|
|
1759
|
-
} else {
|
|
1760
|
-
const oldLength = oldEnd - oldStart + 1;
|
|
1761
|
-
const newLength = newEnd - newStart + 1;
|
|
1762
|
-
const aNullable = oldBranches;
|
|
1763
|
-
const sources = new Array(newLength);
|
|
1764
|
-
for (i = 0; i < newLength; ++i) {
|
|
1765
|
-
sources[i] = -1;
|
|
1766
|
-
}
|
|
1767
|
-
let pos = 0;
|
|
1768
|
-
let synced = 0;
|
|
1769
|
-
const keyIndex = /* @__PURE__ */ new Map();
|
|
1770
|
-
for (j = newStart; j <= newEnd; ++j) {
|
|
1771
|
-
keyIndex.set(newBranches[j], j);
|
|
1772
|
-
}
|
|
1773
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
|
1774
|
-
oldBranch = oldBranches[i];
|
|
1775
|
-
j = keyIndex.get(oldBranch);
|
|
1776
|
-
if (j !== void 0) {
|
|
1777
|
-
pos = pos > j ? WRONG_POS : j;
|
|
1778
|
-
++synced;
|
|
1779
|
-
newBranch = newBranches[j];
|
|
1780
|
-
sources[j - newStart] = i;
|
|
1781
|
-
aNullable[i] = null;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
|
1785
|
-
for (; newStart < newLength; ++newStart) {
|
|
1786
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
|
1787
|
-
}
|
|
1788
|
-
for (; oldStart < oldLength; ++oldStart) {
|
|
1789
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
|
1790
|
-
}
|
|
1791
|
-
} else {
|
|
1792
|
-
i = oldLength - synced;
|
|
1793
|
-
while (i > 0) {
|
|
1794
|
-
oldBranch = aNullable[oldStart++];
|
|
1795
|
-
if (oldBranch !== null) {
|
|
1796
|
-
removeAndDestroyBranch(oldBranch);
|
|
1797
|
-
i--;
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
if (pos === WRONG_POS) {
|
|
1801
|
-
const seq = longestIncreasingSubsequence(sources);
|
|
1802
|
-
j = seq.length - 1;
|
|
1803
|
-
k = newBranches.length;
|
|
1804
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
1805
|
-
if (sources[i] === -1) {
|
|
1806
|
-
pos = i + newStart;
|
|
1807
|
-
newBranch = newBranches[pos++];
|
|
1808
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1809
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1810
|
-
} else {
|
|
1811
|
-
if (j < 0 || i !== seq[j]) {
|
|
1812
|
-
pos = i + newStart;
|
|
1813
|
-
newBranch = newBranches[pos++];
|
|
1814
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1815
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1816
|
-
} else {
|
|
1817
|
-
--j;
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
} else if (synced !== newLength) {
|
|
1822
|
-
k = newBranches.length;
|
|
1823
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
1824
|
-
if (sources[i] === -1) {
|
|
1825
|
-
pos = i + newStart;
|
|
1826
|
-
newBranch = newBranches[pos++];
|
|
1827
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1828
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
function longestIncreasingSubsequence(a) {
|
|
1836
|
-
const p = a.slice();
|
|
1837
|
-
const result = [0];
|
|
1838
|
-
let u;
|
|
1839
|
-
let v;
|
|
1840
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
|
1841
|
-
if (a[i] === -1) {
|
|
1842
|
-
continue;
|
|
1843
|
-
}
|
|
1844
|
-
const j = result[result.length - 1];
|
|
1845
|
-
if (a[j] < a[i]) {
|
|
1846
|
-
p[i] = j;
|
|
1847
|
-
result.push(i);
|
|
1848
|
-
continue;
|
|
1849
|
-
}
|
|
1850
|
-
u = 0;
|
|
1851
|
-
v = result.length - 1;
|
|
1852
|
-
while (u < v) {
|
|
1853
|
-
const c = (u + v) / 2 | 0;
|
|
1854
|
-
if (a[result[c]] < a[i]) {
|
|
1855
|
-
u = c + 1;
|
|
1856
|
-
} else {
|
|
1857
|
-
v = c;
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
if (a[i] < a[result[u]]) {
|
|
1861
|
-
if (u > 0) {
|
|
1862
|
-
p[i] = result[u - 1];
|
|
1863
|
-
}
|
|
1864
|
-
result[u] = i;
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
u = result.length;
|
|
1868
|
-
v = result[u - 1];
|
|
1869
|
-
while (u-- > 0) {
|
|
1870
|
-
result[u] = v;
|
|
1871
|
-
v = p[v];
|
|
1872
|
-
}
|
|
1873
|
-
return result;
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
1711
|
// src/dom/control-flow.ts
|
|
1877
1712
|
function _await_promise(nodeAccessor, params) {
|
|
1878
1713
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
@@ -2253,52 +2088,151 @@ function loop(forEach) {
|
|
|
2253
2088
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
2254
2089
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2255
2090
|
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2256
|
-
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2257
2091
|
const renderer = _content("", template, walks, setup)();
|
|
2258
2092
|
enableBranches();
|
|
2259
2093
|
return (scope, value) => {
|
|
2260
2094
|
const referenceNode = scope[nodeAccessor];
|
|
2261
2095
|
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2262
|
-
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2263
|
-
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2264
|
-
/* @__PURE__ */ new Map()
|
|
2265
|
-
);
|
|
2266
2096
|
const newScopes = scope[scopesAccessor] = [];
|
|
2267
|
-
const
|
|
2097
|
+
const oldLen = oldScopes.length;
|
|
2268
2098
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.["#StartNode" /* StartNode */].parentNode : referenceNode;
|
|
2099
|
+
let oldScopesByKey;
|
|
2100
|
+
let hasPotentialMoves;
|
|
2101
|
+
if (true) {
|
|
2102
|
+
var seenKeys = /* @__PURE__ */ new Set();
|
|
2103
|
+
}
|
|
2269
2104
|
forEach(value, (key, args) => {
|
|
2270
2105
|
if (true) {
|
|
2271
|
-
if (
|
|
2106
|
+
if (seenKeys.has(key)) {
|
|
2272
2107
|
console.error(
|
|
2273
2108
|
`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
|
|
2274
2109
|
key
|
|
2275
2110
|
);
|
|
2111
|
+
} else {
|
|
2112
|
+
seenKeys.add(key);
|
|
2276
2113
|
}
|
|
2277
2114
|
}
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2115
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce(
|
|
2116
|
+
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2117
|
+
/* @__PURE__ */ new Map()
|
|
2118
|
+
)).get(key);
|
|
2119
|
+
if (branch) {
|
|
2120
|
+
hasPotentialMoves = oldScopesByKey.delete(key);
|
|
2121
|
+
} else {
|
|
2122
|
+
branch = createAndSetupBranch(
|
|
2123
|
+
scope["$global" /* Global */],
|
|
2124
|
+
renderer,
|
|
2125
|
+
scope,
|
|
2126
|
+
parentNode
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2284
2129
|
branch["#LoopKey" /* LoopKey */] = key;
|
|
2285
|
-
params?.(branch, args);
|
|
2286
|
-
newScopesByKey.set(key, branch);
|
|
2287
2130
|
newScopes.push(branch);
|
|
2131
|
+
params?.(branch, args);
|
|
2288
2132
|
});
|
|
2133
|
+
const newLen = newScopes.length;
|
|
2134
|
+
const hasSiblings = referenceNode !== parentNode;
|
|
2289
2135
|
let afterReference = null;
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2136
|
+
let oldEnd = oldLen - 1;
|
|
2137
|
+
let newEnd = newLen - 1;
|
|
2138
|
+
let start = 0;
|
|
2139
|
+
if (hasSiblings) {
|
|
2140
|
+
if (oldLen) {
|
|
2141
|
+
afterReference = oldScopes[oldEnd]["#EndNode" /* EndNode */].nextSibling;
|
|
2142
|
+
if (!newLen) {
|
|
2294
2143
|
parentNode.insertBefore(referenceNode, afterReference);
|
|
2295
2144
|
}
|
|
2296
|
-
} else if (
|
|
2145
|
+
} else if (newLen) {
|
|
2297
2146
|
afterReference = referenceNode.nextSibling;
|
|
2298
2147
|
referenceNode.remove();
|
|
2299
2148
|
}
|
|
2300
2149
|
}
|
|
2301
|
-
|
|
2150
|
+
if (!hasPotentialMoves) {
|
|
2151
|
+
if (oldLen) {
|
|
2152
|
+
oldScopes.forEach(
|
|
2153
|
+
hasSiblings ? removeAndDestroyBranch : destroyBranch
|
|
2154
|
+
);
|
|
2155
|
+
if (!hasSiblings) {
|
|
2156
|
+
parentNode.textContent = "";
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
for (const newScope of newScopes) {
|
|
2160
|
+
insertBranchBefore(newScope, parentNode, afterReference);
|
|
2161
|
+
}
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
for (const branch of oldScopesByKey.values()) {
|
|
2165
|
+
removeAndDestroyBranch(branch);
|
|
2166
|
+
}
|
|
2167
|
+
while (start < oldLen && start < newLen && oldScopes[start] === newScopes[start]) {
|
|
2168
|
+
start++;
|
|
2169
|
+
}
|
|
2170
|
+
while (oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]) {
|
|
2171
|
+
oldEnd--;
|
|
2172
|
+
newEnd--;
|
|
2173
|
+
}
|
|
2174
|
+
if (oldEnd + 1 < oldLen) {
|
|
2175
|
+
afterReference = oldScopes[oldEnd + 1]["#StartNode" /* StartNode */];
|
|
2176
|
+
}
|
|
2177
|
+
if (start > oldEnd) {
|
|
2178
|
+
if (start <= newEnd) {
|
|
2179
|
+
for (let i = start; i <= newEnd; i++) {
|
|
2180
|
+
insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
return;
|
|
2184
|
+
} else if (start > newEnd) {
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
const diffLen = newEnd - start + 1;
|
|
2188
|
+
const oldPos = /* @__PURE__ */ new Map();
|
|
2189
|
+
const sources = new Array(diffLen);
|
|
2190
|
+
const pred = new Array(diffLen);
|
|
2191
|
+
const tails = [];
|
|
2192
|
+
let tail = -1;
|
|
2193
|
+
let lo;
|
|
2194
|
+
let hi;
|
|
2195
|
+
let mid;
|
|
2196
|
+
for (let i = start; i <= oldEnd; i++) {
|
|
2197
|
+
oldPos.set(oldScopes[i], i);
|
|
2198
|
+
}
|
|
2199
|
+
for (let i = diffLen; i--; ) {
|
|
2200
|
+
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
2201
|
+
}
|
|
2202
|
+
for (let i = 0; i < diffLen; i++) {
|
|
2203
|
+
if (~sources[i]) {
|
|
2204
|
+
if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
2205
|
+
if (~tail) pred[i] = tails[tail];
|
|
2206
|
+
tails[++tail] = i;
|
|
2207
|
+
} else {
|
|
2208
|
+
lo = 0;
|
|
2209
|
+
hi = tail;
|
|
2210
|
+
while (lo < hi) {
|
|
2211
|
+
mid = (lo + hi) / 2 | 0;
|
|
2212
|
+
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
2213
|
+
else hi = mid;
|
|
2214
|
+
}
|
|
2215
|
+
if (sources[i] < sources[tails[lo]]) {
|
|
2216
|
+
if (lo > 0) pred[i] = tails[lo - 1];
|
|
2217
|
+
tails[lo] = i;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
hi = tails[tail];
|
|
2223
|
+
lo = tail + 1;
|
|
2224
|
+
while (lo-- > 0) {
|
|
2225
|
+
tails[lo] = hi;
|
|
2226
|
+
hi = pred[hi];
|
|
2227
|
+
}
|
|
2228
|
+
for (let i = diffLen; i--; ) {
|
|
2229
|
+
if (~tail && i === tails[tail]) {
|
|
2230
|
+
tail--;
|
|
2231
|
+
} else {
|
|
2232
|
+
insertBranchBefore(newScopes[start + i], parentNode, afterReference);
|
|
2233
|
+
}
|
|
2234
|
+
afterReference = newScopes[start + i]["#StartNode" /* StartNode */];
|
|
2235
|
+
}
|
|
2302
2236
|
};
|
|
2303
2237
|
};
|
|
2304
2238
|
}
|