marko 6.0.7 → 6.0.9
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 +60 -52
- package/dist/debug/dom.mjs +60 -52
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/dom.d.ts +0 -1
- package/dist/dom/resume.d.ts +2 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +39 -37
- package/dist/dom.mjs +39 -37
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/index.js +725 -637
- 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/package.json +1 -1
- package/dist/translator/util/css-px-props.d.ts +0 -2
package/dist/debug/dom.js
CHANGED
@@ -82,7 +82,6 @@ __export(dom_exports, {
|
|
82
82
|
state: () => state,
|
83
83
|
styleAttr: () => styleAttr,
|
84
84
|
styleItem: () => styleItem,
|
85
|
-
styleItemValue: () => styleItemValue,
|
86
85
|
styleItems: () => styleItems,
|
87
86
|
tagVarSignal: () => tagVarSignal,
|
88
87
|
tagVarSignalChange: () => tagVarSignalChange,
|
@@ -148,7 +147,7 @@ function styleValue(styleValue2) {
|
|
148
147
|
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
149
148
|
}
|
150
149
|
function stringifyStyleObject(name, value2) {
|
151
|
-
return value2 || value2 === 0 ?
|
150
|
+
return value2 || value2 === 0 ? name + ":" + value2 : "";
|
152
151
|
}
|
153
152
|
function toDelimitedString(val, delimiter, stringify) {
|
154
153
|
let str = "";
|
@@ -247,6 +246,10 @@ var DEFAULT_RENDER_ID = "_";
|
|
247
246
|
|
248
247
|
// src/dom/resume.ts
|
249
248
|
var registeredValues = {};
|
249
|
+
var branchesEnabled;
|
250
|
+
function enableBranches() {
|
251
|
+
branchesEnabled = 1;
|
252
|
+
}
|
250
253
|
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
251
254
|
if (true) {
|
252
255
|
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
@@ -313,41 +316,43 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
313
316
|
if (token === "*" /* Node */) {
|
314
317
|
const node = scope[data2] = visit.previousSibling;
|
315
318
|
scope["Getter:" /* Getter */ + data2] = () => node;
|
316
|
-
} else if (
|
317
|
-
if (
|
318
|
-
|
319
|
+
} else if (branchesEnabled) {
|
320
|
+
if (token === "[" /* BranchStart */) {
|
321
|
+
if (currentBranchId && dataIndex) {
|
322
|
+
branchEnd(currentBranchId, visit);
|
323
|
+
currentBranchId = branchStack.pop();
|
324
|
+
}
|
325
|
+
if (currentBranchId) {
|
326
|
+
branchStack.push(currentBranchId);
|
327
|
+
parentBranchIds.set(scopeId, currentBranchId);
|
328
|
+
}
|
329
|
+
currentBranchId = scopeId;
|
330
|
+
scope.___startNode = visit;
|
331
|
+
} else if (token === "]" /* BranchEnd */) {
|
332
|
+
scope[data2] = visit;
|
333
|
+
const curParent = visit.parentNode;
|
334
|
+
const startNode = branchEnd(
|
335
|
+
currentBranchId,
|
336
|
+
visit
|
337
|
+
).___startNode;
|
338
|
+
if (curParent !== startNode.parentNode) {
|
339
|
+
curParent.prepend(startNode);
|
340
|
+
}
|
319
341
|
currentBranchId = branchStack.pop();
|
320
|
-
}
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
if (curParent !== startNode.parentNode) {
|
335
|
-
curParent.prepend(startNode);
|
336
|
-
}
|
337
|
-
currentBranchId = branchStack.pop();
|
338
|
-
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
339
|
-
let next = data2.indexOf(" ");
|
340
|
-
let curNode = visit;
|
341
|
-
scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
342
|
-
while (~next) {
|
343
|
-
const start = next + 1;
|
344
|
-
next = data2.indexOf(" ", start);
|
345
|
-
const childScopeId = +data2.slice(
|
346
|
-
start,
|
347
|
-
~next ? next : data2.length
|
348
|
-
);
|
349
|
-
curNode = branchEnd(childScopeId, curNode).___endNode;
|
350
|
-
parentBranchIds.set(childScopeId, scopeId);
|
342
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
343
|
+
let next = data2.indexOf(" ");
|
344
|
+
let curNode = visit;
|
345
|
+
scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
346
|
+
while (~next) {
|
347
|
+
const start = next + 1;
|
348
|
+
next = data2.indexOf(" ", start);
|
349
|
+
const childScopeId = +data2.slice(
|
350
|
+
start,
|
351
|
+
~next ? next : data2.length
|
352
|
+
);
|
353
|
+
curNode = branchEnd(childScopeId, curNode).___endNode;
|
354
|
+
parentBranchIds.set(childScopeId, scopeId);
|
355
|
+
}
|
351
356
|
}
|
352
357
|
}
|
353
358
|
}
|
@@ -379,19 +384,21 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
379
384
|
prevScope
|
380
385
|
);
|
381
386
|
}
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
387
|
+
if (branchesEnabled) {
|
388
|
+
const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
|
389
|
+
if (parentBranchId) {
|
390
|
+
scope.___closestBranch = scopeLookup[parentBranchId];
|
391
|
+
}
|
392
|
+
if (branchIds.has(scopeId)) {
|
393
|
+
const branch = scope;
|
394
|
+
const parentBranch = branch.___closestBranch;
|
395
|
+
scope.___closestBranch = branch;
|
396
|
+
if (parentBranch) {
|
397
|
+
branch.___parentBranch = parentBranch;
|
398
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(
|
399
|
+
branch
|
400
|
+
);
|
401
|
+
}
|
395
402
|
}
|
396
403
|
}
|
397
404
|
if (true) {
|
@@ -753,9 +760,6 @@ function styleItems(element, items) {
|
|
753
760
|
function styleItem(element, name, value2) {
|
754
761
|
element.style.setProperty(name, value2 || value2 === 0 ? value2 + "" : "");
|
755
762
|
}
|
756
|
-
function styleItemValue(value2) {
|
757
|
-
return value2 && typeof value2 === "number" ? value2 + "px" : value2;
|
758
|
-
}
|
759
763
|
function data(node, value2) {
|
760
764
|
const normalizedValue = normalizeString(value2);
|
761
765
|
if (node.data !== normalizedValue) {
|
@@ -1771,6 +1775,7 @@ function renderCatch(scope, error) {
|
|
1771
1775
|
}
|
1772
1776
|
function conditional(nodeAccessor, ...branches) {
|
1773
1777
|
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1778
|
+
enableBranches();
|
1774
1779
|
return (scope, newBranch) => {
|
1775
1780
|
if (newBranch !== scope[branchAccessor]) {
|
1776
1781
|
setConditionalRenderer(
|
@@ -1788,6 +1793,7 @@ function patchDynamicTag(fn) {
|
|
1788
1793
|
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1789
1794
|
const childScopeAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1790
1795
|
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1796
|
+
enableBranches();
|
1791
1797
|
return (scope, newRenderer, getInput) => {
|
1792
1798
|
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1793
1799
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.___id || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
@@ -1907,6 +1913,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1907
1913
|
}
|
1908
1914
|
function loop(nodeAccessor, renderer, forEach) {
|
1909
1915
|
const params = renderer.___params;
|
1916
|
+
enableBranches();
|
1910
1917
|
return (scope, value2) => {
|
1911
1918
|
const referenceNode = scope[nodeAccessor];
|
1912
1919
|
const oldMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor];
|
@@ -2073,6 +2080,7 @@ var runRender = (render) => render.___signal(render.___scope, render.___value);
|
|
2073
2080
|
var enableCatch = () => {
|
2074
2081
|
enableCatch = () => {
|
2075
2082
|
};
|
2083
|
+
enableBranches();
|
2076
2084
|
const handlePendingTry = (fn, scope, branch) => {
|
2077
2085
|
while (branch) {
|
2078
2086
|
if (branch.___pendingAsyncCount) {
|
package/dist/debug/dom.mjs
CHANGED
@@ -55,7 +55,7 @@ function styleValue(styleValue2) {
|
|
55
55
|
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
56
56
|
}
|
57
57
|
function stringifyStyleObject(name, value2) {
|
58
|
-
return value2 || value2 === 0 ?
|
58
|
+
return value2 || value2 === 0 ? name + ":" + value2 : "";
|
59
59
|
}
|
60
60
|
function toDelimitedString(val, delimiter, stringify) {
|
61
61
|
let str = "";
|
@@ -154,6 +154,10 @@ var DEFAULT_RENDER_ID = "_";
|
|
154
154
|
|
155
155
|
// src/dom/resume.ts
|
156
156
|
var registeredValues = {};
|
157
|
+
var branchesEnabled;
|
158
|
+
function enableBranches() {
|
159
|
+
branchesEnabled = 1;
|
160
|
+
}
|
157
161
|
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
158
162
|
if (true) {
|
159
163
|
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
@@ -220,41 +224,43 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
220
224
|
if (token === "*" /* Node */) {
|
221
225
|
const node = scope[data2] = visit.previousSibling;
|
222
226
|
scope["Getter:" /* Getter */ + data2] = () => node;
|
223
|
-
} else if (
|
224
|
-
if (
|
225
|
-
|
227
|
+
} else if (branchesEnabled) {
|
228
|
+
if (token === "[" /* BranchStart */) {
|
229
|
+
if (currentBranchId && dataIndex) {
|
230
|
+
branchEnd(currentBranchId, visit);
|
231
|
+
currentBranchId = branchStack.pop();
|
232
|
+
}
|
233
|
+
if (currentBranchId) {
|
234
|
+
branchStack.push(currentBranchId);
|
235
|
+
parentBranchIds.set(scopeId, currentBranchId);
|
236
|
+
}
|
237
|
+
currentBranchId = scopeId;
|
238
|
+
scope.___startNode = visit;
|
239
|
+
} else if (token === "]" /* BranchEnd */) {
|
240
|
+
scope[data2] = visit;
|
241
|
+
const curParent = visit.parentNode;
|
242
|
+
const startNode = branchEnd(
|
243
|
+
currentBranchId,
|
244
|
+
visit
|
245
|
+
).___startNode;
|
246
|
+
if (curParent !== startNode.parentNode) {
|
247
|
+
curParent.prepend(startNode);
|
248
|
+
}
|
226
249
|
currentBranchId = branchStack.pop();
|
227
|
-
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
if (curParent !== startNode.parentNode) {
|
242
|
-
curParent.prepend(startNode);
|
243
|
-
}
|
244
|
-
currentBranchId = branchStack.pop();
|
245
|
-
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
246
|
-
let next = data2.indexOf(" ");
|
247
|
-
let curNode = visit;
|
248
|
-
scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
249
|
-
while (~next) {
|
250
|
-
const start = next + 1;
|
251
|
-
next = data2.indexOf(" ", start);
|
252
|
-
const childScopeId = +data2.slice(
|
253
|
-
start,
|
254
|
-
~next ? next : data2.length
|
255
|
-
);
|
256
|
-
curNode = branchEnd(childScopeId, curNode).___endNode;
|
257
|
-
parentBranchIds.set(childScopeId, scopeId);
|
250
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
251
|
+
let next = data2.indexOf(" ");
|
252
|
+
let curNode = visit;
|
253
|
+
scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
|
254
|
+
while (~next) {
|
255
|
+
const start = next + 1;
|
256
|
+
next = data2.indexOf(" ", start);
|
257
|
+
const childScopeId = +data2.slice(
|
258
|
+
start,
|
259
|
+
~next ? next : data2.length
|
260
|
+
);
|
261
|
+
curNode = branchEnd(childScopeId, curNode).___endNode;
|
262
|
+
parentBranchIds.set(childScopeId, scopeId);
|
263
|
+
}
|
258
264
|
}
|
259
265
|
}
|
260
266
|
}
|
@@ -286,19 +292,21 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
286
292
|
prevScope
|
287
293
|
);
|
288
294
|
}
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
295
|
+
if (branchesEnabled) {
|
296
|
+
const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
|
297
|
+
if (parentBranchId) {
|
298
|
+
scope.___closestBranch = scopeLookup[parentBranchId];
|
299
|
+
}
|
300
|
+
if (branchIds.has(scopeId)) {
|
301
|
+
const branch = scope;
|
302
|
+
const parentBranch = branch.___closestBranch;
|
303
|
+
scope.___closestBranch = branch;
|
304
|
+
if (parentBranch) {
|
305
|
+
branch.___parentBranch = parentBranch;
|
306
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(
|
307
|
+
branch
|
308
|
+
);
|
309
|
+
}
|
302
310
|
}
|
303
311
|
}
|
304
312
|
if (true) {
|
@@ -660,9 +668,6 @@ function styleItems(element, items) {
|
|
660
668
|
function styleItem(element, name, value2) {
|
661
669
|
element.style.setProperty(name, value2 || value2 === 0 ? value2 + "" : "");
|
662
670
|
}
|
663
|
-
function styleItemValue(value2) {
|
664
|
-
return value2 && typeof value2 === "number" ? value2 + "px" : value2;
|
665
|
-
}
|
666
671
|
function data(node, value2) {
|
667
672
|
const normalizedValue = normalizeString(value2);
|
668
673
|
if (node.data !== normalizedValue) {
|
@@ -1678,6 +1683,7 @@ function renderCatch(scope, error) {
|
|
1678
1683
|
}
|
1679
1684
|
function conditional(nodeAccessor, ...branches) {
|
1680
1685
|
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1686
|
+
enableBranches();
|
1681
1687
|
return (scope, newBranch) => {
|
1682
1688
|
if (newBranch !== scope[branchAccessor]) {
|
1683
1689
|
setConditionalRenderer(
|
@@ -1695,6 +1701,7 @@ function patchDynamicTag(fn) {
|
|
1695
1701
|
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1696
1702
|
const childScopeAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1697
1703
|
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1704
|
+
enableBranches();
|
1698
1705
|
return (scope, newRenderer, getInput) => {
|
1699
1706
|
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1700
1707
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.___id || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
@@ -1814,6 +1821,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1814
1821
|
}
|
1815
1822
|
function loop(nodeAccessor, renderer, forEach) {
|
1816
1823
|
const params = renderer.___params;
|
1824
|
+
enableBranches();
|
1817
1825
|
return (scope, value2) => {
|
1818
1826
|
const referenceNode = scope[nodeAccessor];
|
1819
1827
|
const oldMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor];
|
@@ -1980,6 +1988,7 @@ var runRender = (render) => render.___signal(render.___scope, render.___value);
|
|
1980
1988
|
var enableCatch = () => {
|
1981
1989
|
enableCatch = () => {
|
1982
1990
|
};
|
1991
|
+
enableBranches();
|
1983
1992
|
const handlePendingTry = (fn, scope, branch) => {
|
1984
1993
|
while (branch) {
|
1985
1994
|
if (branch.___pendingAsyncCount) {
|
@@ -2278,7 +2287,6 @@ export {
|
|
2278
2287
|
state,
|
2279
2288
|
styleAttr,
|
2280
2289
|
styleItem,
|
2281
|
-
styleItemValue,
|
2282
2290
|
styleItems,
|
2283
2291
|
tagVarSignal,
|
2284
2292
|
tagVarSignalChange,
|
package/dist/debug/html.js
CHANGED
@@ -118,7 +118,7 @@ function styleValue(styleValue2) {
|
|
118
118
|
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
119
119
|
}
|
120
120
|
function stringifyStyleObject(name, value) {
|
121
|
-
return value || value === 0 ?
|
121
|
+
return value || value === 0 ? name + ":" + value : "";
|
122
122
|
}
|
123
123
|
function toDelimitedString(val, delimiter, stringify) {
|
124
124
|
let str = "";
|
package/dist/debug/html.mjs
CHANGED
@@ -33,7 +33,7 @@ function styleValue(styleValue2) {
|
|
33
33
|
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
34
34
|
}
|
35
35
|
function stringifyStyleObject(name, value) {
|
36
|
-
return value || value === 0 ?
|
36
|
+
return value || value === 0 ? name + ":" + value : "";
|
37
37
|
}
|
38
38
|
function toDelimitedString(val, delimiter, stringify) {
|
39
39
|
let str = "";
|
package/dist/dom/dom.d.ts
CHANGED
@@ -7,7 +7,6 @@ export declare function classItem(element: Element, name: string, value: unknown
|
|
7
7
|
export declare function styleAttr(element: Element, value: unknown): void;
|
8
8
|
export declare function styleItems(element: HTMLElement, items: Record<string, unknown>): void;
|
9
9
|
export declare function styleItem(element: HTMLElement, name: string, value: unknown): void;
|
10
|
-
export declare function styleItemValue(value: unknown): unknown;
|
11
10
|
export declare function data(node: Text | Comment, value: unknown): void;
|
12
11
|
export declare function textContent(node: ParentNode, value: unknown): void;
|
13
12
|
export declare function attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
|
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.d.ts
CHANGED
@@ -4,7 +4,7 @@ export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
|
|
4
4
|
export { compat } from "./dom/compat";
|
5
5
|
export { awaitTag, conditional, createTry, dynamicTag, loopIn, loopOf, loopTo, } from "./dom/control-flow";
|
6
6
|
export { controllable_detailsOrDialog_open, controllable_detailsOrDialog_open_effect, controllable_input_checked, controllable_input_checked_effect, controllable_input_checkedValue, controllable_input_checkedValue_effect, controllable_input_value, controllable_input_value_effect, controllable_select_value, controllable_select_value_effect, controllable_textarea_value, controllable_textarea_value_effect, } from "./dom/controllable";
|
7
|
-
export { attr, attrs, attrsEvents, classAttr, classItem, classItems, data, html, lifecycle, partialAttrs, props, styleAttr, styleItem, styleItems,
|
7
|
+
export { attr, attrs, attrsEvents, classAttr, classItem, classItems, data, html, lifecycle, partialAttrs, props, styleAttr, styleItem, styleItems, textContent, } from "./dom/dom";
|
8
8
|
export { on } from "./dom/event";
|
9
9
|
export { enableCatch, run } from "./dom/queue";
|
10
10
|
export { createContent, createRenderer, registerContent } from "./dom/renderer";
|
package/dist/dom.js
CHANGED
@@ -79,7 +79,6 @@ __export(dom_exports, {
|
|
79
79
|
state: () => state,
|
80
80
|
styleAttr: () => styleAttr,
|
81
81
|
styleItem: () => styleItem,
|
82
|
-
styleItemValue: () => styleItemValue,
|
83
82
|
styleItems: () => styleItems,
|
84
83
|
tagVarSignal: () => tagVarSignal,
|
85
84
|
tagVarSignalChange: () => tagVarSignalChange,
|
@@ -129,7 +128,7 @@ function styleValue(styleValue2) {
|
|
129
128
|
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
130
129
|
}
|
131
130
|
function stringifyStyleObject(name, value2) {
|
132
|
-
return value2 || value2 === 0 ?
|
131
|
+
return value2 || value2 === 0 ? name + ":" + value2 : "";
|
133
132
|
}
|
134
133
|
function toDelimitedString(val, delimiter, stringify) {
|
135
134
|
let str = "", sep = "", part;
|
@@ -202,7 +201,10 @@ function stripSpacesAndPunctuation(str) {
|
|
202
201
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
203
202
|
|
204
203
|
// src/dom/resume.ts
|
205
|
-
var registeredValues = {};
|
204
|
+
var registeredValues = {}, branchesEnabled;
|
205
|
+
function enableBranches() {
|
206
|
+
branchesEnabled = 1;
|
207
|
+
}
|
206
208
|
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
207
209
|
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
208
210
|
defineRuntime({
|
@@ -227,25 +229,27 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
227
229
|
if (token === "*" /* Node */) {
|
228
230
|
let node = scope[data2] = visit.previousSibling;
|
229
231
|
scope["j" /* Getter */ + data2] = () => node;
|
230
|
-
} else if (
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
+
}
|
249
253
|
}
|
250
254
|
}
|
251
255
|
}
|
@@ -265,16 +269,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
265
269
|
lastScopeId += scope;
|
266
270
|
else {
|
267
271
|
let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
|
268
|
-
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(
|
269
273
|
scope,
|
270
274
|
prevScope
|
271
|
-
))
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
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
|
+
}
|
278
283
|
}
|
279
284
|
}
|
280
285
|
} finally {
|
@@ -528,9 +533,6 @@ function styleItems(element, items) {
|
|
528
533
|
function styleItem(element, name, value2) {
|
529
534
|
element.style.setProperty(name, value2 || value2 === 0 ? value2 + "" : "");
|
530
535
|
}
|
531
|
-
function styleItemValue(value2) {
|
532
|
-
return value2 && typeof value2 == "number" ? value2 + "px" : value2;
|
533
|
-
}
|
534
536
|
function data(node, value2) {
|
535
537
|
let normalizedValue = normalizeString(value2);
|
536
538
|
node.data !== normalizedValue && (node.data = normalizedValue);
|
@@ -1177,7 +1179,7 @@ function renderCatch(scope, error) {
|
|
1177
1179
|
}
|
1178
1180
|
function conditional(nodeAccessor, ...branches) {
|
1179
1181
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1180
|
-
return (scope, newBranch) => {
|
1182
|
+
return enableBranches(), (scope, newBranch) => {
|
1181
1183
|
newBranch !== scope[branchAccessor] && setConditionalRenderer(
|
1182
1184
|
scope,
|
1183
1185
|
nodeAccessor,
|
@@ -1191,7 +1193,7 @@ function patchDynamicTag(fn) {
|
|
1191
1193
|
}
|
1192
1194
|
var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1193
1195
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1194
|
-
return (scope, newRenderer, getInput) => {
|
1196
|
+
return enableBranches(), (scope, newRenderer, getInput) => {
|
1195
1197
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1196
1198
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1197
1199
|
if (setConditionalRenderer(
|
@@ -1274,7 +1276,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1274
1276
|
}
|
1275
1277
|
function loop(nodeAccessor, renderer, forEach) {
|
1276
1278
|
let params = renderer.l;
|
1277
|
-
return (scope, value2) => {
|
1279
|
+
return enableBranches(), (scope, value2) => {
|
1278
1280
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1279
1281
|
...oldMap.values()
|
1280
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] = [];
|
@@ -1376,7 +1378,7 @@ function runRenders() {
|
|
1376
1378
|
}
|
1377
1379
|
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1378
1380
|
enableCatch = () => {
|
1379
|
-
};
|
1381
|
+
}, enableBranches();
|
1380
1382
|
let handlePendingTry = (fn, scope, branch) => {
|
1381
1383
|
for (; branch; ) {
|
1382
1384
|
if (branch.n)
|