marko 6.0.8 → 6.0.10
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 +59 -47
- package/dist/debug/dom.mjs +59 -47
- package/dist/debug/html.js +98 -70
- package/dist/debug/html.mjs +98 -70
- package/dist/dom/resume.d.ts +2 -0
- package/dist/dom.js +38 -32
- package/dist/dom.mjs +38 -32
- package/dist/html/writer.d.ts +8 -8
- package/dist/html.js +64 -28
- package/dist/html.mjs +64 -28
- package/dist/translator/index.js +1294 -1170
- package/dist/translator/util/is-only-child-in-parent.d.ts +2 -2
- package/dist/translator/util/optional.d.ts +1 -0
- package/dist/translator/util/references.d.ts +16 -5
- package/dist/translator/util/serialize-reasons.d.ts +10 -12
- package/dist/translator/util/with-comment.d.ts +2 -0
- package/dist/translator/visitors/program/html.d.ts +4 -3
- package/dist/translator/visitors/program/index.d.ts +9 -5
- package/dist/translator/visitors/tag/native-tag.d.ts +2 -2
- package/package.json +1 -1
package/dist/debug/html.mjs
CHANGED
@@ -1705,7 +1705,7 @@ var branchIdKey = Symbol();
|
|
1705
1705
|
function withBranchId(branchId, cb) {
|
1706
1706
|
return withContext(branchIdKey, branchId, cb);
|
1707
1707
|
}
|
1708
|
-
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1708
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1709
1709
|
const resumeBranch = serializeBranch !== 0;
|
1710
1710
|
const resumeMarker = serializeMarker !== 0;
|
1711
1711
|
if (resumeBranch) {
|
@@ -1733,16 +1733,18 @@ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serialize
|
|
1733
1733
|
} else {
|
1734
1734
|
forOf(list, cb);
|
1735
1735
|
}
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1736
|
+
writeBranchEnd(
|
1737
|
+
scopeId,
|
1738
|
+
accessor,
|
1739
|
+
resumeMarker,
|
1740
|
+
parentEndTag,
|
1741
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1742
|
+
"]" /* BranchEnd */,
|
1743
|
+
scopeId + " " + accessor
|
1744
|
+
)
|
1745
|
+
);
|
1744
1746
|
}
|
1745
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker,
|
1747
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1746
1748
|
const resumeBranch = serializeBranch !== 0;
|
1747
1749
|
const resumeMarker = serializeMarker !== 0;
|
1748
1750
|
let branchIds = "";
|
@@ -1766,16 +1768,18 @@ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch,
|
|
1766
1768
|
} else {
|
1767
1769
|
forOf(list, cb);
|
1768
1770
|
}
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1771
|
+
writeBranchEnd(
|
1772
|
+
scopeId,
|
1773
|
+
accessor,
|
1774
|
+
resumeMarker,
|
1775
|
+
parentEndTag,
|
1776
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1777
|
+
parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1778
|
+
scopeId + " " + accessor + branchIds
|
1779
|
+
)
|
1780
|
+
);
|
1777
1781
|
}
|
1778
|
-
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1782
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1779
1783
|
const resumeBranch = serializeBranch !== 0;
|
1780
1784
|
const resumeMarker = serializeMarker !== 0;
|
1781
1785
|
if (resumeBranch) {
|
@@ -1802,16 +1806,18 @@ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeM
|
|
1802
1806
|
} else {
|
1803
1807
|
forIn(obj, cb);
|
1804
1808
|
}
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1809
|
+
writeBranchEnd(
|
1810
|
+
scopeId,
|
1811
|
+
accessor,
|
1812
|
+
resumeMarker,
|
1813
|
+
parentEndTag,
|
1814
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1815
|
+
"]" /* BranchEnd */,
|
1816
|
+
scopeId + " " + accessor
|
1817
|
+
)
|
1818
|
+
);
|
1813
1819
|
}
|
1814
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker,
|
1820
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1815
1821
|
const resumeBranch = serializeBranch !== 0;
|
1816
1822
|
const resumeMarker = serializeMarker !== 0;
|
1817
1823
|
let branchIds = "";
|
@@ -1835,16 +1841,18 @@ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch,
|
|
1835
1841
|
} else {
|
1836
1842
|
forIn(obj, cb);
|
1837
1843
|
}
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1844
|
+
writeBranchEnd(
|
1845
|
+
scopeId,
|
1846
|
+
accessor,
|
1847
|
+
resumeMarker,
|
1848
|
+
parentEndTag,
|
1849
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1850
|
+
parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1851
|
+
scopeId + " " + accessor + branchIds
|
1852
|
+
)
|
1853
|
+
);
|
1846
1854
|
}
|
1847
|
-
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1855
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1848
1856
|
const resumeBranch = serializeBranch !== 0;
|
1849
1857
|
const resumeMarker = serializeMarker !== 0;
|
1850
1858
|
if (resumeBranch) {
|
@@ -1871,16 +1879,18 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch,
|
|
1871
1879
|
} else {
|
1872
1880
|
forTo(to, from, step, cb);
|
1873
1881
|
}
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
+
writeBranchEnd(
|
1883
|
+
scopeId,
|
1884
|
+
accessor,
|
1885
|
+
resumeMarker,
|
1886
|
+
parentEndTag,
|
1887
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1888
|
+
"]" /* BranchEnd */,
|
1889
|
+
scopeId + " " + accessor
|
1890
|
+
)
|
1891
|
+
);
|
1882
1892
|
}
|
1883
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker,
|
1893
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1884
1894
|
const resumeBranch = serializeBranch !== 0;
|
1885
1895
|
const resumeMarker = serializeMarker !== 0;
|
1886
1896
|
let branchIds = "";
|
@@ -1904,16 +1914,18 @@ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serial
|
|
1904
1914
|
} else {
|
1905
1915
|
forTo(to, from, step, cb);
|
1906
1916
|
}
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1917
|
+
writeBranchEnd(
|
1918
|
+
scopeId,
|
1919
|
+
accessor,
|
1920
|
+
resumeMarker,
|
1921
|
+
parentEndTag,
|
1922
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1923
|
+
parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1924
|
+
scopeId + " " + accessor + branchIds
|
1925
|
+
)
|
1926
|
+
);
|
1915
1927
|
}
|
1916
|
-
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1928
|
+
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1917
1929
|
const resumeBranch = serializeBranch !== 0;
|
1918
1930
|
const resumeMarker = serializeMarker !== 0;
|
1919
1931
|
const branchId = peekNextScopeId();
|
@@ -1930,16 +1942,18 @@ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMark
|
|
1930
1942
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1931
1943
|
});
|
1932
1944
|
}
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1945
|
+
writeBranchEnd(
|
1946
|
+
scopeId,
|
1947
|
+
accessor,
|
1948
|
+
resumeMarker,
|
1949
|
+
parentEndTag,
|
1950
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1951
|
+
"]" /* BranchEnd */,
|
1952
|
+
scopeId + " " + accessor
|
1953
|
+
)
|
1954
|
+
);
|
1941
1955
|
}
|
1942
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker,
|
1956
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag) {
|
1943
1957
|
const resumeBranch = serializeBranch !== 0;
|
1944
1958
|
const resumeMarker = serializeMarker !== 0;
|
1945
1959
|
const branchId = peekNextScopeId();
|
@@ -1951,13 +1965,27 @@ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, ser
|
|
1951
1965
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1952
1966
|
});
|
1953
1967
|
}
|
1968
|
+
writeBranchEnd(
|
1969
|
+
scopeId,
|
1970
|
+
accessor,
|
1971
|
+
resumeMarker,
|
1972
|
+
parentEndTag,
|
1973
|
+
resumeMarker && (!parentEndTag || resumeBranch) && $chunk.boundary.state.mark(
|
1974
|
+
parentEndTag ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1975
|
+
scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
|
1976
|
+
)
|
1977
|
+
);
|
1978
|
+
}
|
1979
|
+
function writeBranchEnd(scopeId, accessor, resumeMarker, parentEndTag, mark) {
|
1980
|
+
const endTag = parentEndTag || "";
|
1954
1981
|
if (resumeMarker) {
|
1955
|
-
|
1956
|
-
$chunk.
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1982
|
+
if (mark) {
|
1983
|
+
$chunk.writeHTML(mark + endTag);
|
1984
|
+
} else {
|
1985
|
+
$chunk.writeHTML(endTag + markResumeNode(scopeId, accessor));
|
1986
|
+
}
|
1987
|
+
} else {
|
1988
|
+
$chunk.writeHTML(endTag);
|
1961
1989
|
}
|
1962
1990
|
}
|
1963
1991
|
var writeScope = (scopeId, partialScope) => {
|
package/dist/dom/resume.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { type Scope } from "../common/types";
|
2
2
|
import type { Signal } from "./signals";
|
3
|
+
export declare let branchesEnabled: undefined | 1;
|
4
|
+
export declare function enableBranches(): void;
|
3
5
|
export declare function init(runtimeId?: string): void;
|
4
6
|
export declare let isResuming: undefined | 0 | 1;
|
5
7
|
export declare function register<T>(id: string, obj: T): T;
|
package/dist/dom.js
CHANGED
@@ -201,7 +201,10 @@ function stripSpacesAndPunctuation(str) {
|
|
201
201
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
202
202
|
|
203
203
|
// src/dom/resume.ts
|
204
|
-
var registeredValues = {};
|
204
|
+
var registeredValues = {}, branchesEnabled;
|
205
|
+
function enableBranches() {
|
206
|
+
branchesEnabled = 1;
|
207
|
+
}
|
205
208
|
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
206
209
|
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
207
210
|
defineRuntime({
|
@@ -226,25 +229,27 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
226
229
|
if (token === "*" /* Node */) {
|
227
230
|
let node = scope[data2] = visit.previousSibling;
|
228
231
|
scope["j" /* Getter */ + data2] = () => node;
|
229
|
-
} else if (
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
232
|
+
} else if (branchesEnabled) {
|
233
|
+
if (token === "[" /* BranchStart */)
|
234
|
+
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
235
|
+
else if (token === "]" /* BranchEnd */) {
|
236
|
+
scope[data2] = visit;
|
237
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
238
|
+
currentBranchId,
|
239
|
+
visit
|
240
|
+
).h;
|
241
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
242
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
243
|
+
let next = data2.indexOf(" "), curNode = visit;
|
244
|
+
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
245
|
+
let start = next + 1;
|
246
|
+
next = data2.indexOf(" ", start);
|
247
|
+
let childScopeId = +data2.slice(
|
248
|
+
start,
|
249
|
+
~next ? next : data2.length
|
250
|
+
);
|
251
|
+
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
252
|
+
}
|
248
253
|
}
|
249
254
|
}
|
250
255
|
}
|
@@ -264,16 +269,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
264
269
|
lastScopeId += scope;
|
265
270
|
else {
|
266
271
|
let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
|
267
|
-
scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
272
|
+
if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
268
273
|
scope,
|
269
274
|
prevScope
|
270
|
-
))
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
275
|
+
)), branchesEnabled) {
|
276
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
277
|
+
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
278
|
+
let branch = scope, parentBranch = branch.k;
|
279
|
+
scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
280
|
+
branch
|
281
|
+
));
|
282
|
+
}
|
277
283
|
}
|
278
284
|
}
|
279
285
|
} finally {
|
@@ -1173,7 +1179,7 @@ function renderCatch(scope, error) {
|
|
1173
1179
|
}
|
1174
1180
|
function conditional(nodeAccessor, ...branches) {
|
1175
1181
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1176
|
-
return (scope, newBranch) => {
|
1182
|
+
return enableBranches(), (scope, newBranch) => {
|
1177
1183
|
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
1178
1184
|
scope,
|
1179
1185
|
nodeAccessor,
|
@@ -1187,7 +1193,7 @@ function patchDynamicTag(fn) {
|
|
1187
1193
|
}
|
1188
1194
|
var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1189
1195
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1190
|
-
return (scope, newRenderer, getInput) => {
|
1196
|
+
return enableBranches(), (scope, newRenderer, getInput) => {
|
1191
1197
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1192
1198
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1193
1199
|
if (setConditionalRenderer(
|
@@ -1270,7 +1276,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1270
1276
|
}
|
1271
1277
|
function loop(nodeAccessor, renderer, forEach) {
|
1272
1278
|
let params = renderer.l;
|
1273
|
-
return (scope, value2) => {
|
1279
|
+
return enableBranches(), (scope, value2) => {
|
1274
1280
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1275
1281
|
...oldMap.values()
|
1276
1282
|
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].h.parentNode : referenceNode, newMap = scope["m" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map(), newArray = scope["l" /* LoopScopeArray */ + nodeAccessor] = [];
|
@@ -1372,7 +1378,7 @@ function runRenders() {
|
|
1372
1378
|
}
|
1373
1379
|
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1374
1380
|
enableCatch = () => {
|
1375
|
-
};
|
1381
|
+
}, enableBranches();
|
1376
1382
|
let handlePendingTry = (fn, scope, branch) => {
|
1377
1383
|
for (; branch; ) {
|
1378
1384
|
if (branch.n)
|
package/dist/dom.mjs
CHANGED
@@ -112,7 +112,10 @@ function stripSpacesAndPunctuation(str) {
|
|
112
112
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
113
113
|
|
114
114
|
// src/dom/resume.ts
|
115
|
-
var registeredValues = {};
|
115
|
+
var registeredValues = {}, branchesEnabled;
|
116
|
+
function enableBranches() {
|
117
|
+
branchesEnabled = 1;
|
118
|
+
}
|
116
119
|
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
117
120
|
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
118
121
|
defineRuntime({
|
@@ -137,25 +140,27 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
137
140
|
if (token === "*" /* Node */) {
|
138
141
|
let node = scope[data2] = visit.previousSibling;
|
139
142
|
scope["j" /* Getter */ + data2] = () => node;
|
140
|
-
} else if (
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
143
|
+
} else if (branchesEnabled) {
|
144
|
+
if (token === "[" /* BranchStart */)
|
145
|
+
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
146
|
+
else if (token === "]" /* BranchEnd */) {
|
147
|
+
scope[data2] = visit;
|
148
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
149
|
+
currentBranchId,
|
150
|
+
visit
|
151
|
+
).h;
|
152
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
153
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
154
|
+
let next = data2.indexOf(" "), curNode = visit;
|
155
|
+
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
156
|
+
let start = next + 1;
|
157
|
+
next = data2.indexOf(" ", start);
|
158
|
+
let childScopeId = +data2.slice(
|
159
|
+
start,
|
160
|
+
~next ? next : data2.length
|
161
|
+
);
|
162
|
+
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
163
|
+
}
|
159
164
|
}
|
160
165
|
}
|
161
166
|
}
|
@@ -175,16 +180,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
175
180
|
lastScopeId += scope;
|
176
181
|
else {
|
177
182
|
let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
|
178
|
-
scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
183
|
+
if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
179
184
|
scope,
|
180
185
|
prevScope
|
181
|
-
))
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
186
|
+
)), branchesEnabled) {
|
187
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
188
|
+
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
189
|
+
let branch = scope, parentBranch = branch.k;
|
190
|
+
scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
191
|
+
branch
|
192
|
+
));
|
193
|
+
}
|
188
194
|
}
|
189
195
|
}
|
190
196
|
} finally {
|
@@ -1084,7 +1090,7 @@ function renderCatch(scope, error) {
|
|
1084
1090
|
}
|
1085
1091
|
function conditional(nodeAccessor, ...branches) {
|
1086
1092
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1087
|
-
return (scope, newBranch) => {
|
1093
|
+
return enableBranches(), (scope, newBranch) => {
|
1088
1094
|
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
1089
1095
|
scope,
|
1090
1096
|
nodeAccessor,
|
@@ -1098,7 +1104,7 @@ function patchDynamicTag(fn) {
|
|
1098
1104
|
}
|
1099
1105
|
var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1100
1106
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1101
|
-
return (scope, newRenderer, getInput) => {
|
1107
|
+
return enableBranches(), (scope, newRenderer, getInput) => {
|
1102
1108
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1103
1109
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1104
1110
|
if (setConditionalRenderer(
|
@@ -1181,7 +1187,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1181
1187
|
}
|
1182
1188
|
function loop(nodeAccessor, renderer, forEach) {
|
1183
1189
|
let params = renderer.l;
|
1184
|
-
return (scope, value2) => {
|
1190
|
+
return enableBranches(), (scope, value2) => {
|
1185
1191
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1186
1192
|
...oldMap.values()
|
1187
1193
|
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].h.parentNode : referenceNode, newMap = scope["m" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map(), newArray = scope["l" /* LoopScopeArray */ + nodeAccessor] = [];
|
@@ -1283,7 +1289,7 @@ function runRenders() {
|
|
1283
1289
|
}
|
1284
1290
|
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1285
1291
|
enableCatch = () => {
|
1286
|
-
};
|
1292
|
+
}, enableBranches();
|
1287
1293
|
let handlePendingTry = (fn, scope, branch) => {
|
1288
1294
|
for (; branch; ) {
|
1289
1295
|
if (branch.n)
|
package/dist/html/writer.d.ts
CHANGED
@@ -35,14 +35,14 @@ export declare function hoist(scopeId: number, id?: string): {
|
|
35
35
|
};
|
36
36
|
export declare function resumeClosestBranch(scopeId: number): void;
|
37
37
|
export declare function withBranchId<T>(branchId: number, cb: () => T): T;
|
38
|
-
export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
|
39
|
-
export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1,
|
40
|
-
export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
|
41
|
-
export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1,
|
42
|
-
export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
|
43
|
-
export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1,
|
44
|
-
export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
|
45
|
-
export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1,
|
38
|
+
export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
39
|
+
export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
40
|
+
export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
41
|
+
export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
42
|
+
export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
43
|
+
export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
44
|
+
export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
45
|
+
export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string): void;
|
46
46
|
declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
|
47
47
|
export { writeScope };
|
48
48
|
export declare function writeExistingScope(scopeId: number): ScopeInternals;
|