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.mjs
CHANGED
|
@@ -303,11 +303,12 @@ function destroyBranch(branch) {
|
|
|
303
303
|
function destroyNestedBranches(branch) {
|
|
304
304
|
branch["#Destroyed" /* Destroyed */] = 1;
|
|
305
305
|
branch["#BranchScopes" /* BranchScopes */]?.forEach(destroyNestedBranches);
|
|
306
|
-
branch["#AbortScopes" /* AbortScopes */]?.forEach(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
306
|
+
branch["#AbortScopes" /* AbortScopes */]?.forEach(resetControllers);
|
|
307
|
+
}
|
|
308
|
+
function resetControllers(scope) {
|
|
309
|
+
for (const id in scope["#AbortControllers" /* AbortControllers */]) {
|
|
310
|
+
$signalReset(scope, id);
|
|
311
|
+
}
|
|
311
312
|
}
|
|
312
313
|
function removeAndDestroyBranch(branch) {
|
|
313
314
|
destroyBranch(branch);
|
|
@@ -605,8 +606,8 @@ function walk(startNode, walkCodes, branch) {
|
|
|
605
606
|
}
|
|
606
607
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
607
608
|
let value;
|
|
609
|
+
let currentMultiplier;
|
|
608
610
|
let storedMultiplier = 0;
|
|
609
|
-
let currentMultiplier = 0;
|
|
610
611
|
let currentScopeIndex = 0;
|
|
611
612
|
for (; currentWalkIndex < walkCodes.length; ) {
|
|
612
613
|
value = walkCodes.charCodeAt(currentWalkIndex++);
|
|
@@ -1593,172 +1594,6 @@ function toInsertNode(startNode, endNode) {
|
|
|
1593
1594
|
return parent;
|
|
1594
1595
|
}
|
|
1595
1596
|
|
|
1596
|
-
// src/dom/reconcile.ts
|
|
1597
|
-
var WRONG_POS = 2147483647;
|
|
1598
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
1599
|
-
let oldStart = 0;
|
|
1600
|
-
let newStart = 0;
|
|
1601
|
-
let oldEnd = oldBranches.length - 1;
|
|
1602
|
-
let newEnd = newBranches.length - 1;
|
|
1603
|
-
let oldStartBranch = oldBranches[oldStart];
|
|
1604
|
-
let newStartBranch = newBranches[newStart];
|
|
1605
|
-
let oldEndBranch = oldBranches[oldEnd];
|
|
1606
|
-
let newEndBranch = newBranches[newEnd];
|
|
1607
|
-
let i;
|
|
1608
|
-
let j;
|
|
1609
|
-
let k;
|
|
1610
|
-
let nextSibling;
|
|
1611
|
-
let oldBranch;
|
|
1612
|
-
let newBranch;
|
|
1613
|
-
outer: {
|
|
1614
|
-
while (oldStartBranch === newStartBranch) {
|
|
1615
|
-
++oldStart;
|
|
1616
|
-
++newStart;
|
|
1617
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
1618
|
-
break outer;
|
|
1619
|
-
}
|
|
1620
|
-
oldStartBranch = oldBranches[oldStart];
|
|
1621
|
-
newStartBranch = newBranches[newStart];
|
|
1622
|
-
}
|
|
1623
|
-
while (oldEndBranch === newEndBranch) {
|
|
1624
|
-
--oldEnd;
|
|
1625
|
-
--newEnd;
|
|
1626
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
1627
|
-
break outer;
|
|
1628
|
-
}
|
|
1629
|
-
oldEndBranch = oldBranches[oldEnd];
|
|
1630
|
-
newEndBranch = newBranches[newEnd];
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
if (oldStart > oldEnd) {
|
|
1634
|
-
if (newStart <= newEnd) {
|
|
1635
|
-
k = newEnd + 1;
|
|
1636
|
-
nextSibling = k < newBranches.length ? newBranches[k]["#StartNode" /* StartNode */] : afterReference;
|
|
1637
|
-
do {
|
|
1638
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
|
1639
|
-
} while (newStart <= newEnd);
|
|
1640
|
-
}
|
|
1641
|
-
} else if (newStart > newEnd) {
|
|
1642
|
-
do {
|
|
1643
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
|
1644
|
-
} while (oldStart <= oldEnd);
|
|
1645
|
-
} else {
|
|
1646
|
-
const oldLength = oldEnd - oldStart + 1;
|
|
1647
|
-
const newLength = newEnd - newStart + 1;
|
|
1648
|
-
const aNullable = oldBranches;
|
|
1649
|
-
const sources = new Array(newLength);
|
|
1650
|
-
for (i = 0; i < newLength; ++i) {
|
|
1651
|
-
sources[i] = -1;
|
|
1652
|
-
}
|
|
1653
|
-
let pos = 0;
|
|
1654
|
-
let synced = 0;
|
|
1655
|
-
const keyIndex = /* @__PURE__ */ new Map();
|
|
1656
|
-
for (j = newStart; j <= newEnd; ++j) {
|
|
1657
|
-
keyIndex.set(newBranches[j], j);
|
|
1658
|
-
}
|
|
1659
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
|
1660
|
-
oldBranch = oldBranches[i];
|
|
1661
|
-
j = keyIndex.get(oldBranch);
|
|
1662
|
-
if (j !== void 0) {
|
|
1663
|
-
pos = pos > j ? WRONG_POS : j;
|
|
1664
|
-
++synced;
|
|
1665
|
-
newBranch = newBranches[j];
|
|
1666
|
-
sources[j - newStart] = i;
|
|
1667
|
-
aNullable[i] = null;
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
|
1671
|
-
for (; newStart < newLength; ++newStart) {
|
|
1672
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
|
1673
|
-
}
|
|
1674
|
-
for (; oldStart < oldLength; ++oldStart) {
|
|
1675
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
|
1676
|
-
}
|
|
1677
|
-
} else {
|
|
1678
|
-
i = oldLength - synced;
|
|
1679
|
-
while (i > 0) {
|
|
1680
|
-
oldBranch = aNullable[oldStart++];
|
|
1681
|
-
if (oldBranch !== null) {
|
|
1682
|
-
removeAndDestroyBranch(oldBranch);
|
|
1683
|
-
i--;
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
if (pos === WRONG_POS) {
|
|
1687
|
-
const seq = longestIncreasingSubsequence(sources);
|
|
1688
|
-
j = seq.length - 1;
|
|
1689
|
-
k = newBranches.length;
|
|
1690
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
1691
|
-
if (sources[i] === -1) {
|
|
1692
|
-
pos = i + newStart;
|
|
1693
|
-
newBranch = newBranches[pos++];
|
|
1694
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1695
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1696
|
-
} else {
|
|
1697
|
-
if (j < 0 || i !== seq[j]) {
|
|
1698
|
-
pos = i + newStart;
|
|
1699
|
-
newBranch = newBranches[pos++];
|
|
1700
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1701
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1702
|
-
} else {
|
|
1703
|
-
--j;
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
} else if (synced !== newLength) {
|
|
1708
|
-
k = newBranches.length;
|
|
1709
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
1710
|
-
if (sources[i] === -1) {
|
|
1711
|
-
pos = i + newStart;
|
|
1712
|
-
newBranch = newBranches[pos++];
|
|
1713
|
-
nextSibling = pos < k ? newBranches[pos]["#StartNode" /* StartNode */] : afterReference;
|
|
1714
|
-
insertBranchBefore(newBranch, parent, nextSibling);
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
function longestIncreasingSubsequence(a) {
|
|
1722
|
-
const p = a.slice();
|
|
1723
|
-
const result = [0];
|
|
1724
|
-
let u;
|
|
1725
|
-
let v;
|
|
1726
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
|
1727
|
-
if (a[i] === -1) {
|
|
1728
|
-
continue;
|
|
1729
|
-
}
|
|
1730
|
-
const j = result[result.length - 1];
|
|
1731
|
-
if (a[j] < a[i]) {
|
|
1732
|
-
p[i] = j;
|
|
1733
|
-
result.push(i);
|
|
1734
|
-
continue;
|
|
1735
|
-
}
|
|
1736
|
-
u = 0;
|
|
1737
|
-
v = result.length - 1;
|
|
1738
|
-
while (u < v) {
|
|
1739
|
-
const c = (u + v) / 2 | 0;
|
|
1740
|
-
if (a[result[c]] < a[i]) {
|
|
1741
|
-
u = c + 1;
|
|
1742
|
-
} else {
|
|
1743
|
-
v = c;
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
if (a[i] < a[result[u]]) {
|
|
1747
|
-
if (u > 0) {
|
|
1748
|
-
p[i] = result[u - 1];
|
|
1749
|
-
}
|
|
1750
|
-
result[u] = i;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
u = result.length;
|
|
1754
|
-
v = result[u - 1];
|
|
1755
|
-
while (u-- > 0) {
|
|
1756
|
-
result[u] = v;
|
|
1757
|
-
v = p[v];
|
|
1758
|
-
}
|
|
1759
|
-
return result;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
1597
|
// src/dom/control-flow.ts
|
|
1763
1598
|
function _await_promise(nodeAccessor, params) {
|
|
1764
1599
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
@@ -2139,52 +1974,151 @@ function loop(forEach) {
|
|
|
2139
1974
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
2140
1975
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
2141
1976
|
const scopesAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
2142
|
-
const scopesByKeyAccessor = "BranchScopes:" /* BranchScopes */ + scopesAccessor;
|
|
2143
1977
|
const renderer = _content("", template, walks, setup)();
|
|
2144
1978
|
enableBranches();
|
|
2145
1979
|
return (scope, value) => {
|
|
2146
1980
|
const referenceNode = scope[nodeAccessor];
|
|
2147
1981
|
const oldScopes = toArray(scope[scopesAccessor]);
|
|
2148
|
-
const oldScopesByKey = scope[scopesByKeyAccessor] || oldScopes.reduce(
|
|
2149
|
-
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2150
|
-
/* @__PURE__ */ new Map()
|
|
2151
|
-
);
|
|
2152
1982
|
const newScopes = scope[scopesAccessor] = [];
|
|
2153
|
-
const
|
|
1983
|
+
const oldLen = oldScopes.length;
|
|
2154
1984
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.["#StartNode" /* StartNode */].parentNode : referenceNode;
|
|
1985
|
+
let oldScopesByKey;
|
|
1986
|
+
let hasPotentialMoves;
|
|
1987
|
+
if (true) {
|
|
1988
|
+
var seenKeys = /* @__PURE__ */ new Set();
|
|
1989
|
+
}
|
|
2155
1990
|
forEach(value, (key, args) => {
|
|
2156
1991
|
if (true) {
|
|
2157
|
-
if (
|
|
1992
|
+
if (seenKeys.has(key)) {
|
|
2158
1993
|
console.error(
|
|
2159
1994
|
`A <for> tag's \`by\` attribute must return a unique value for each item, but a duplicate was found matching:`,
|
|
2160
1995
|
key
|
|
2161
1996
|
);
|
|
1997
|
+
} else {
|
|
1998
|
+
seenKeys.add(key);
|
|
2162
1999
|
}
|
|
2163
2000
|
}
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2001
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce(
|
|
2002
|
+
(map, scope2, i) => map.set(scope2["#LoopKey" /* LoopKey */] ?? i, scope2),
|
|
2003
|
+
/* @__PURE__ */ new Map()
|
|
2004
|
+
)).get(key);
|
|
2005
|
+
if (branch) {
|
|
2006
|
+
hasPotentialMoves = oldScopesByKey.delete(key);
|
|
2007
|
+
} else {
|
|
2008
|
+
branch = createAndSetupBranch(
|
|
2009
|
+
scope["$global" /* Global */],
|
|
2010
|
+
renderer,
|
|
2011
|
+
scope,
|
|
2012
|
+
parentNode
|
|
2013
|
+
);
|
|
2014
|
+
}
|
|
2170
2015
|
branch["#LoopKey" /* LoopKey */] = key;
|
|
2171
|
-
params?.(branch, args);
|
|
2172
|
-
newScopesByKey.set(key, branch);
|
|
2173
2016
|
newScopes.push(branch);
|
|
2017
|
+
params?.(branch, args);
|
|
2174
2018
|
});
|
|
2019
|
+
const newLen = newScopes.length;
|
|
2020
|
+
const hasSiblings = referenceNode !== parentNode;
|
|
2175
2021
|
let afterReference = null;
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2022
|
+
let oldEnd = oldLen - 1;
|
|
2023
|
+
let newEnd = newLen - 1;
|
|
2024
|
+
let start = 0;
|
|
2025
|
+
if (hasSiblings) {
|
|
2026
|
+
if (oldLen) {
|
|
2027
|
+
afterReference = oldScopes[oldEnd]["#EndNode" /* EndNode */].nextSibling;
|
|
2028
|
+
if (!newLen) {
|
|
2180
2029
|
parentNode.insertBefore(referenceNode, afterReference);
|
|
2181
2030
|
}
|
|
2182
|
-
} else if (
|
|
2031
|
+
} else if (newLen) {
|
|
2183
2032
|
afterReference = referenceNode.nextSibling;
|
|
2184
2033
|
referenceNode.remove();
|
|
2185
2034
|
}
|
|
2186
2035
|
}
|
|
2187
|
-
|
|
2036
|
+
if (!hasPotentialMoves) {
|
|
2037
|
+
if (oldLen) {
|
|
2038
|
+
oldScopes.forEach(
|
|
2039
|
+
hasSiblings ? removeAndDestroyBranch : destroyBranch
|
|
2040
|
+
);
|
|
2041
|
+
if (!hasSiblings) {
|
|
2042
|
+
parentNode.textContent = "";
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
for (const newScope of newScopes) {
|
|
2046
|
+
insertBranchBefore(newScope, parentNode, afterReference);
|
|
2047
|
+
}
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
for (const branch of oldScopesByKey.values()) {
|
|
2051
|
+
removeAndDestroyBranch(branch);
|
|
2052
|
+
}
|
|
2053
|
+
while (start < oldLen && start < newLen && oldScopes[start] === newScopes[start]) {
|
|
2054
|
+
start++;
|
|
2055
|
+
}
|
|
2056
|
+
while (oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]) {
|
|
2057
|
+
oldEnd--;
|
|
2058
|
+
newEnd--;
|
|
2059
|
+
}
|
|
2060
|
+
if (oldEnd + 1 < oldLen) {
|
|
2061
|
+
afterReference = oldScopes[oldEnd + 1]["#StartNode" /* StartNode */];
|
|
2062
|
+
}
|
|
2063
|
+
if (start > oldEnd) {
|
|
2064
|
+
if (start <= newEnd) {
|
|
2065
|
+
for (let i = start; i <= newEnd; i++) {
|
|
2066
|
+
insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
return;
|
|
2070
|
+
} else if (start > newEnd) {
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
const diffLen = newEnd - start + 1;
|
|
2074
|
+
const oldPos = /* @__PURE__ */ new Map();
|
|
2075
|
+
const sources = new Array(diffLen);
|
|
2076
|
+
const pred = new Array(diffLen);
|
|
2077
|
+
const tails = [];
|
|
2078
|
+
let tail = -1;
|
|
2079
|
+
let lo;
|
|
2080
|
+
let hi;
|
|
2081
|
+
let mid;
|
|
2082
|
+
for (let i = start; i <= oldEnd; i++) {
|
|
2083
|
+
oldPos.set(oldScopes[i], i);
|
|
2084
|
+
}
|
|
2085
|
+
for (let i = diffLen; i--; ) {
|
|
2086
|
+
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
2087
|
+
}
|
|
2088
|
+
for (let i = 0; i < diffLen; i++) {
|
|
2089
|
+
if (~sources[i]) {
|
|
2090
|
+
if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
2091
|
+
if (~tail) pred[i] = tails[tail];
|
|
2092
|
+
tails[++tail] = i;
|
|
2093
|
+
} else {
|
|
2094
|
+
lo = 0;
|
|
2095
|
+
hi = tail;
|
|
2096
|
+
while (lo < hi) {
|
|
2097
|
+
mid = (lo + hi) / 2 | 0;
|
|
2098
|
+
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
2099
|
+
else hi = mid;
|
|
2100
|
+
}
|
|
2101
|
+
if (sources[i] < sources[tails[lo]]) {
|
|
2102
|
+
if (lo > 0) pred[i] = tails[lo - 1];
|
|
2103
|
+
tails[lo] = i;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
hi = tails[tail];
|
|
2109
|
+
lo = tail + 1;
|
|
2110
|
+
while (lo-- > 0) {
|
|
2111
|
+
tails[lo] = hi;
|
|
2112
|
+
hi = pred[hi];
|
|
2113
|
+
}
|
|
2114
|
+
for (let i = diffLen; i--; ) {
|
|
2115
|
+
if (~tail && i === tails[tail]) {
|
|
2116
|
+
tail--;
|
|
2117
|
+
} else {
|
|
2118
|
+
insertBranchBefore(newScopes[start + i], parentNode, afterReference);
|
|
2119
|
+
}
|
|
2120
|
+
afterReference = newScopes[start + i]["#StartNode" /* StartNode */];
|
|
2121
|
+
}
|
|
2188
2122
|
};
|
|
2189
2123
|
};
|
|
2190
2124
|
}
|
package/dist/debug/html.js
CHANGED
|
@@ -782,7 +782,7 @@ function getRegistered(val) {
|
|
|
782
782
|
function writeRoot(state, root) {
|
|
783
783
|
const { buf } = state;
|
|
784
784
|
const hadBuf = buf.length !== 0;
|
|
785
|
-
let result
|
|
785
|
+
let result;
|
|
786
786
|
if (hadBuf) {
|
|
787
787
|
buf.push(",");
|
|
788
788
|
}
|
|
@@ -1238,7 +1238,7 @@ function writeSet(state, val, ref) {
|
|
|
1238
1238
|
return true;
|
|
1239
1239
|
}
|
|
1240
1240
|
function writeArrayBuffer(state, val) {
|
|
1241
|
-
let result
|
|
1241
|
+
let result;
|
|
1242
1242
|
if (val.byteLength) {
|
|
1243
1243
|
const view = new Int8Array(val);
|
|
1244
1244
|
result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
|
|
@@ -1380,7 +1380,6 @@ function writeRequest(state, val, ref) {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
if (val.referrerPolicy) {
|
|
1382
1382
|
options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0);
|
|
1383
|
-
sep = ",";
|
|
1384
1383
|
}
|
|
1385
1384
|
state.buf.push(
|
|
1386
1385
|
hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
|
|
@@ -1402,7 +1401,6 @@ function writeResponse(state, val, ref) {
|
|
|
1402
1401
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
|
|
1403
1402
|
if (headers) {
|
|
1404
1403
|
options += sep + "headers:{" + headers + "}";
|
|
1405
|
-
sep = ",";
|
|
1406
1404
|
}
|
|
1407
1405
|
if (!val.body || val.bodyUsed) {
|
|
1408
1406
|
state.buf.push(
|
|
@@ -3192,7 +3190,7 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
3192
3190
|
}
|
|
3193
3191
|
const state = getState();
|
|
3194
3192
|
const branchId = _peek_scope_id();
|
|
3195
|
-
let rendered
|
|
3193
|
+
let rendered;
|
|
3196
3194
|
let result;
|
|
3197
3195
|
if (typeof renderer === "string") {
|
|
3198
3196
|
if (true) {
|
package/dist/debug/html.mjs
CHANGED
|
@@ -689,7 +689,7 @@ function getRegistered(val) {
|
|
|
689
689
|
function writeRoot(state, root) {
|
|
690
690
|
const { buf } = state;
|
|
691
691
|
const hadBuf = buf.length !== 0;
|
|
692
|
-
let result
|
|
692
|
+
let result;
|
|
693
693
|
if (hadBuf) {
|
|
694
694
|
buf.push(",");
|
|
695
695
|
}
|
|
@@ -1145,7 +1145,7 @@ function writeSet(state, val, ref) {
|
|
|
1145
1145
|
return true;
|
|
1146
1146
|
}
|
|
1147
1147
|
function writeArrayBuffer(state, val) {
|
|
1148
|
-
let result
|
|
1148
|
+
let result;
|
|
1149
1149
|
if (val.byteLength) {
|
|
1150
1150
|
const view = new Int8Array(val);
|
|
1151
1151
|
result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
|
|
@@ -1287,7 +1287,6 @@ function writeRequest(state, val, ref) {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
if (val.referrerPolicy) {
|
|
1289
1289
|
options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0);
|
|
1290
|
-
sep = ",";
|
|
1291
1290
|
}
|
|
1292
1291
|
state.buf.push(
|
|
1293
1292
|
hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
|
|
@@ -1309,7 +1308,6 @@ function writeResponse(state, val, ref) {
|
|
|
1309
1308
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
|
|
1310
1309
|
if (headers) {
|
|
1311
1310
|
options += sep + "headers:{" + headers + "}";
|
|
1312
|
-
sep = ",";
|
|
1313
1311
|
}
|
|
1314
1312
|
if (!val.body || val.bodyUsed) {
|
|
1315
1313
|
state.buf.push(
|
|
@@ -3099,7 +3097,7 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
3099
3097
|
}
|
|
3100
3098
|
const state = getState();
|
|
3101
3099
|
const branchId = _peek_scope_id();
|
|
3102
|
-
let rendered
|
|
3100
|
+
let rendered;
|
|
3103
3101
|
let result;
|
|
3104
3102
|
if (typeof renderer === "string") {
|
|
3105
3103
|
if (true) {
|
package/dist/dom.js
CHANGED
|
@@ -278,10 +278,11 @@ function destroyBranch(branch) {
|
|
|
278
278
|
), destroyNestedBranches(branch);
|
|
279
279
|
}
|
|
280
280
|
function destroyNestedBranches(branch) {
|
|
281
|
-
branch.I = 1, branch.D?.forEach(destroyNestedBranches), branch.B?.forEach(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
branch.I = 1, branch.D?.forEach(destroyNestedBranches), branch.B?.forEach(resetControllers);
|
|
282
|
+
}
|
|
283
|
+
function resetControllers(scope) {
|
|
284
|
+
for (let id in scope.A)
|
|
285
|
+
$signalReset(scope, id);
|
|
285
286
|
}
|
|
286
287
|
function removeAndDestroyBranch(branch) {
|
|
287
288
|
destroyBranch(branch), removeChildNodes(
|
|
@@ -446,7 +447,7 @@ function walk(startNode, walkCodes, branch) {
|
|
|
446
447
|
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
|
447
448
|
}
|
|
448
449
|
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
449
|
-
let value,
|
|
450
|
+
let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
|
|
450
451
|
for (; currentWalkIndex < walkCodes.length; )
|
|
451
452
|
if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
|
|
452
453
|
let node = walker.currentNode;
|
|
@@ -1071,81 +1072,6 @@ function toInsertNode(startNode, endNode) {
|
|
|
1071
1072
|
return parent;
|
|
1072
1073
|
}
|
|
1073
1074
|
|
|
1074
|
-
// src/dom/reconcile.ts
|
|
1075
|
-
var WRONG_POS = 2147483647;
|
|
1076
|
-
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
1077
|
-
let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
|
|
1078
|
-
outer: {
|
|
1079
|
-
for (; oldStartBranch === newStartBranch; ) {
|
|
1080
|
-
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
|
1081
|
-
break outer;
|
|
1082
|
-
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
|
1083
|
-
}
|
|
1084
|
-
for (; oldEndBranch === newEndBranch; ) {
|
|
1085
|
-
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
|
1086
|
-
break outer;
|
|
1087
|
-
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
if (oldStart > oldEnd) {
|
|
1091
|
-
if (newStart <= newEnd) {
|
|
1092
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].S : afterReference;
|
|
1093
|
-
do
|
|
1094
|
-
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
|
1095
|
-
while (newStart <= newEnd);
|
|
1096
|
-
}
|
|
1097
|
-
} else if (newStart > newEnd)
|
|
1098
|
-
do
|
|
1099
|
-
removeAndDestroyBranch(oldBranches[oldStart++]);
|
|
1100
|
-
while (oldStart <= oldEnd);
|
|
1101
|
-
else {
|
|
1102
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
|
1103
|
-
for (i = 0; i < newLength; ++i)
|
|
1104
|
-
sources[i] = -1;
|
|
1105
|
-
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
|
1106
|
-
for (j = newStart; j <= newEnd; ++j)
|
|
1107
|
-
keyIndex.set(newBranches[j], j);
|
|
1108
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
|
1109
|
-
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
|
1110
|
-
if (oldLength === oldBranches.length && synced === 0) {
|
|
1111
|
-
for (; newStart < newLength; ++newStart)
|
|
1112
|
-
insertBranchBefore(newBranches[newStart], parent, afterReference);
|
|
1113
|
-
for (; oldStart < oldLength; ++oldStart)
|
|
1114
|
-
removeAndDestroyBranch(oldBranches[oldStart]);
|
|
1115
|
-
} else {
|
|
1116
|
-
for (i = oldLength - synced; i > 0; )
|
|
1117
|
-
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
|
1118
|
-
if (pos === WRONG_POS) {
|
|
1119
|
-
let seq = longestIncreasingSubsequence(sources);
|
|
1120
|
-
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
|
1121
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
|
1122
|
-
} else if (synced !== newLength)
|
|
1123
|
-
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
|
1124
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].S : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
function longestIncreasingSubsequence(a) {
|
|
1129
|
-
let p = a.slice(), result = [0], u, v;
|
|
1130
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
|
1131
|
-
if (a[i] === -1)
|
|
1132
|
-
continue;
|
|
1133
|
-
let j = result[result.length - 1];
|
|
1134
|
-
if (a[j] < a[i]) {
|
|
1135
|
-
p[i] = j, result.push(i);
|
|
1136
|
-
continue;
|
|
1137
|
-
}
|
|
1138
|
-
for (u = 0, v = result.length - 1; u < v; ) {
|
|
1139
|
-
let c = (u + v) / 2 | 0;
|
|
1140
|
-
a[result[c]] < a[i] ? u = c + 1 : v = c;
|
|
1141
|
-
}
|
|
1142
|
-
a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
|
|
1143
|
-
}
|
|
1144
|
-
for (u = result.length, v = result[u - 1]; u-- > 0; )
|
|
1145
|
-
result[u] = v, v = p[v];
|
|
1146
|
-
return result;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
1075
|
// src/dom/control-flow.ts
|
|
1150
1076
|
function _await_promise(nodeAccessor, params) {
|
|
1151
1077
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
@@ -1399,23 +1325,63 @@ var _for_of = loop(([all, by = bySecondArg], cb) => {
|
|
|
1399
1325
|
function loop(forEach) {
|
|
1400
1326
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
1401
1327
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1402
|
-
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor,
|
|
1328
|
+
let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
1403
1329
|
return enableBranches(), (scope, value) => {
|
|
1404
|
-
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]),
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
), newScopes = scope[scopesAccessor] = [], newScopesByKey = scope[scopesByKeyAccessor] = /* @__PURE__ */ new Map(), parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode;
|
|
1330
|
+
let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [], oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
|
|
1331
|
+
if (0)
|
|
1332
|
+
var seenKeys;
|
|
1408
1333
|
forEach(value, (key, args) => {
|
|
1409
|
-
let branch = oldScopesByKey
|
|
1334
|
+
let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce(
|
|
1335
|
+
(map, scope2, i) => map.set(scope2.M ?? i, scope2),
|
|
1336
|
+
/* @__PURE__ */ new Map()
|
|
1337
|
+
)).get(key);
|
|
1338
|
+
branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(
|
|
1410
1339
|
scope.$,
|
|
1411
1340
|
renderer,
|
|
1412
1341
|
scope,
|
|
1413
1342
|
parentNode
|
|
1414
|
-
);
|
|
1415
|
-
branch.M = key, params?.(branch, args), newScopesByKey.set(key, branch), newScopes.push(branch);
|
|
1343
|
+
), branch.M = key, newScopes.push(branch), params?.(branch, args);
|
|
1416
1344
|
});
|
|
1417
|
-
let afterReference = null;
|
|
1418
|
-
|
|
1345
|
+
let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1, start = 0;
|
|
1346
|
+
if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
|
|
1347
|
+
oldLen && (oldScopes.forEach(
|
|
1348
|
+
hasSiblings ? removeAndDestroyBranch : destroyBranch
|
|
1349
|
+
), hasSiblings || (parentNode.textContent = ""));
|
|
1350
|
+
for (let newScope of newScopes)
|
|
1351
|
+
insertBranchBefore(newScope, parentNode, afterReference);
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
for (let branch of oldScopesByKey.values())
|
|
1355
|
+
removeAndDestroyBranch(branch);
|
|
1356
|
+
for (; start < oldLen && start < newLen && oldScopes[start] === newScopes[start]; )
|
|
1357
|
+
start++;
|
|
1358
|
+
for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]; )
|
|
1359
|
+
oldEnd--, newEnd--;
|
|
1360
|
+
if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
|
|
1361
|
+
if (start <= newEnd)
|
|
1362
|
+
for (let i = start; i <= newEnd; i++)
|
|
1363
|
+
insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
1364
|
+
return;
|
|
1365
|
+
} else if (start > newEnd)
|
|
1366
|
+
return;
|
|
1367
|
+
let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = new Array(diffLen), pred = new Array(diffLen), tails = [], tail = -1, lo, hi, mid;
|
|
1368
|
+
for (let i = start; i <= oldEnd; i++)
|
|
1369
|
+
oldPos.set(oldScopes[i], i);
|
|
1370
|
+
for (let i = diffLen; i--; )
|
|
1371
|
+
sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
|
|
1372
|
+
for (let i = 0; i < diffLen; i++)
|
|
1373
|
+
if (~sources[i])
|
|
1374
|
+
if (tail < 0 || sources[tails[tail]] < sources[i])
|
|
1375
|
+
~tail && (pred[i] = tails[tail]), tails[++tail] = i;
|
|
1376
|
+
else {
|
|
1377
|
+
for (lo = 0, hi = tail; lo < hi; )
|
|
1378
|
+
mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
|
|
1379
|
+
sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
|
|
1380
|
+
}
|
|
1381
|
+
for (hi = tails[tail], lo = tail + 1; lo-- > 0; )
|
|
1382
|
+
tails[lo] = hi, hi = pred[hi];
|
|
1383
|
+
for (let i = diffLen; i--; )
|
|
1384
|
+
~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
|
|
1419
1385
|
};
|
|
1420
1386
|
};
|
|
1421
1387
|
}
|