marko 6.0.49 → 6.0.51
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/common/types.d.ts +1 -0
- package/dist/debug/dom.js +131 -127
- package/dist/debug/dom.mjs +131 -127
- package/dist/debug/html.js +53 -47
- package/dist/debug/html.mjs +53 -47
- package/dist/dom/walker.d.ts +1 -0
- package/dist/dom.js +105 -102
- package/dist/dom.mjs +105 -102
- package/dist/html.js +39 -31
- package/dist/html.mjs +39 -31
- package/dist/translator/index.js +9 -5
- package/package.json +1 -1
package/dist/debug/html.js
CHANGED
@@ -711,19 +711,22 @@ function writeRoot(state, root) {
|
|
711
711
|
}
|
712
712
|
function writeAssigned(state) {
|
713
713
|
if (state.assigned.size) {
|
714
|
+
let inits = "";
|
715
|
+
let assigns = "";
|
714
716
|
for (const valueRef of state.assigned) {
|
715
717
|
if (valueRef.init) {
|
716
|
-
|
717
|
-
state.buf.push(
|
718
|
-
"," + assignsToString(valueRef.assigns, valueRef.init)
|
719
|
-
);
|
720
|
-
} else {
|
721
|
-
state.buf.push("," + valueRef.init);
|
722
|
-
}
|
718
|
+
inits += "," + (valueRef.assigns ? assignsToString(valueRef.assigns, valueRef.init) : valueRef.init);
|
723
719
|
valueRef.init = "";
|
724
720
|
} else if (valueRef.assigns) {
|
725
|
-
|
721
|
+
assigns += "," + assignsToString(valueRef.assigns, valueRef.id);
|
726
722
|
}
|
723
|
+
valueRef.assigns = null;
|
724
|
+
}
|
725
|
+
if (assigns) {
|
726
|
+
state.buf.push(assigns);
|
727
|
+
}
|
728
|
+
if (inits) {
|
729
|
+
state.buf.push(inits);
|
727
730
|
}
|
728
731
|
state.assigned = /* @__PURE__ */ new Set();
|
729
732
|
}
|
@@ -3125,48 +3128,51 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
|
|
3125
3128
|
let result;
|
3126
3129
|
if (typeof renderer === "string") {
|
3127
3130
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
3128
|
-
const renderContent = content || normalizeDynamicRenderer(input.content);
|
3129
3131
|
nextScopeId();
|
3130
|
-
write(
|
3132
|
+
write(
|
3133
|
+
`<${renderer}${attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
|
3134
|
+
);
|
3131
3135
|
if (!voidElementsReg.test(renderer)) {
|
3132
|
-
const
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3136
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
3137
|
+
if (renderer === "textarea") {
|
3138
|
+
if (renderContent) {
|
3139
|
+
throw new Error(
|
3140
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
3141
|
+
);
|
3142
|
+
}
|
3143
|
+
write(
|
3144
|
+
controllable_textarea_value(
|
3145
|
+
branchId,
|
3146
|
+
true ? `#${renderer}/0` : 0,
|
3147
|
+
input.value,
|
3148
|
+
input.valueChange
|
3149
|
+
)
|
3150
|
+
);
|
3151
|
+
} else if (renderContent) {
|
3152
|
+
if (typeof renderContent !== "function") {
|
3153
|
+
throw new Error(
|
3154
|
+
`Body content is not supported for the \`<${renderer}>\` tag.`
|
3155
|
+
);
|
3156
|
+
}
|
3157
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3158
|
+
controllable_select_value(
|
3159
|
+
branchId,
|
3160
|
+
true ? `#${renderer}/0` : 0,
|
3161
|
+
input.value,
|
3162
|
+
input.valueChange,
|
3163
|
+
renderContent
|
3164
|
+
);
|
3165
|
+
} else {
|
3166
|
+
dynamicTag(
|
3167
|
+
branchId,
|
3168
|
+
true ? `#${renderer}/0` : 0,
|
3169
|
+
renderContent,
|
3170
|
+
[],
|
3171
|
+
0,
|
3172
|
+
1,
|
3173
|
+
serializeReason
|
3146
3174
|
);
|
3147
|
-
} else if (renderContent) {
|
3148
|
-
if (typeof renderContent !== "function") {
|
3149
|
-
throw new Error(
|
3150
|
-
`Body content is not supported for the \`<${renderer}>\` tag.`
|
3151
|
-
);
|
3152
|
-
}
|
3153
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3154
|
-
controllable_select_value(
|
3155
|
-
scopeId,
|
3156
|
-
accessor,
|
3157
|
-
input.value,
|
3158
|
-
input.valueChange,
|
3159
|
-
renderContent
|
3160
|
-
);
|
3161
|
-
} else {
|
3162
|
-
renderContent();
|
3163
|
-
}
|
3164
3175
|
}
|
3165
|
-
};
|
3166
|
-
if (shouldResume) {
|
3167
|
-
withBranchId(branchId, renderNativeTag);
|
3168
|
-
} else {
|
3169
|
-
renderNativeTag();
|
3170
3176
|
}
|
3171
3177
|
write(`</${renderer}>`);
|
3172
3178
|
} else if (content) {
|
@@ -3177,7 +3183,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
|
|
3177
3183
|
if (shouldResume) {
|
3178
3184
|
write(
|
3179
3185
|
state.mark(
|
3180
|
-
"
|
3186
|
+
"'" /* BranchNativeTag */,
|
3181
3187
|
scopeId + " " + accessor + " " + branchId
|
3182
3188
|
)
|
3183
3189
|
);
|
package/dist/debug/html.mjs
CHANGED
@@ -627,19 +627,22 @@ function writeRoot(state, root) {
|
|
627
627
|
}
|
628
628
|
function writeAssigned(state) {
|
629
629
|
if (state.assigned.size) {
|
630
|
+
let inits = "";
|
631
|
+
let assigns = "";
|
630
632
|
for (const valueRef of state.assigned) {
|
631
633
|
if (valueRef.init) {
|
632
|
-
|
633
|
-
state.buf.push(
|
634
|
-
"," + assignsToString(valueRef.assigns, valueRef.init)
|
635
|
-
);
|
636
|
-
} else {
|
637
|
-
state.buf.push("," + valueRef.init);
|
638
|
-
}
|
634
|
+
inits += "," + (valueRef.assigns ? assignsToString(valueRef.assigns, valueRef.init) : valueRef.init);
|
639
635
|
valueRef.init = "";
|
640
636
|
} else if (valueRef.assigns) {
|
641
|
-
|
637
|
+
assigns += "," + assignsToString(valueRef.assigns, valueRef.id);
|
642
638
|
}
|
639
|
+
valueRef.assigns = null;
|
640
|
+
}
|
641
|
+
if (assigns) {
|
642
|
+
state.buf.push(assigns);
|
643
|
+
}
|
644
|
+
if (inits) {
|
645
|
+
state.buf.push(inits);
|
643
646
|
}
|
644
647
|
state.assigned = /* @__PURE__ */ new Set();
|
645
648
|
}
|
@@ -3041,48 +3044,51 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
|
|
3041
3044
|
let result;
|
3042
3045
|
if (typeof renderer === "string") {
|
3043
3046
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
3044
|
-
const renderContent = content || normalizeDynamicRenderer(input.content);
|
3045
3047
|
nextScopeId();
|
3046
|
-
write(
|
3048
|
+
write(
|
3049
|
+
`<${renderer}${attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
|
3050
|
+
);
|
3047
3051
|
if (!voidElementsReg.test(renderer)) {
|
3048
|
-
const
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3052
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
3053
|
+
if (renderer === "textarea") {
|
3054
|
+
if (renderContent) {
|
3055
|
+
throw new Error(
|
3056
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
3057
|
+
);
|
3058
|
+
}
|
3059
|
+
write(
|
3060
|
+
controllable_textarea_value(
|
3061
|
+
branchId,
|
3062
|
+
true ? `#${renderer}/0` : 0,
|
3063
|
+
input.value,
|
3064
|
+
input.valueChange
|
3065
|
+
)
|
3066
|
+
);
|
3067
|
+
} else if (renderContent) {
|
3068
|
+
if (typeof renderContent !== "function") {
|
3069
|
+
throw new Error(
|
3070
|
+
`Body content is not supported for the \`<${renderer}>\` tag.`
|
3071
|
+
);
|
3072
|
+
}
|
3073
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3074
|
+
controllable_select_value(
|
3075
|
+
branchId,
|
3076
|
+
true ? `#${renderer}/0` : 0,
|
3077
|
+
input.value,
|
3078
|
+
input.valueChange,
|
3079
|
+
renderContent
|
3080
|
+
);
|
3081
|
+
} else {
|
3082
|
+
dynamicTag(
|
3083
|
+
branchId,
|
3084
|
+
true ? `#${renderer}/0` : 0,
|
3085
|
+
renderContent,
|
3086
|
+
[],
|
3087
|
+
0,
|
3088
|
+
1,
|
3089
|
+
serializeReason
|
3062
3090
|
);
|
3063
|
-
} else if (renderContent) {
|
3064
|
-
if (typeof renderContent !== "function") {
|
3065
|
-
throw new Error(
|
3066
|
-
`Body content is not supported for the \`<${renderer}>\` tag.`
|
3067
|
-
);
|
3068
|
-
}
|
3069
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3070
|
-
controllable_select_value(
|
3071
|
-
scopeId,
|
3072
|
-
accessor,
|
3073
|
-
input.value,
|
3074
|
-
input.valueChange,
|
3075
|
-
renderContent
|
3076
|
-
);
|
3077
|
-
} else {
|
3078
|
-
renderContent();
|
3079
|
-
}
|
3080
3091
|
}
|
3081
|
-
};
|
3082
|
-
if (shouldResume) {
|
3083
|
-
withBranchId(branchId, renderNativeTag);
|
3084
|
-
} else {
|
3085
|
-
renderNativeTag();
|
3086
3092
|
}
|
3087
3093
|
write(`</${renderer}>`);
|
3088
3094
|
} else if (content) {
|
@@ -3093,7 +3099,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
|
|
3093
3099
|
if (shouldResume) {
|
3094
3100
|
write(
|
3095
3101
|
state.mark(
|
3096
|
-
"
|
3102
|
+
"'" /* BranchNativeTag */,
|
3097
3103
|
scopeId + " " + accessor + " " + branchId
|
3098
3104
|
)
|
3099
3105
|
);
|
package/dist/dom/walker.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
import { type BranchScope } from "../common/types";
|
2
2
|
export declare const walker: TreeWalker;
|
3
3
|
export declare function walk(startNode: Node, walkCodes: string, branch: BranchScope): void;
|
4
|
+
export declare function getDebugKey(index: number, node: Node | string): string | number;
|
package/dist/dom.js
CHANGED
@@ -201,6 +201,89 @@ function stripSpacesAndPunctuation(str) {
|
|
201
201
|
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
202
202
|
}
|
203
203
|
|
204
|
+
// src/dom/scope.ts
|
205
|
+
function createScope($global, closestBranch) {
|
206
|
+
let scope = {
|
207
|
+
l: $global.p++,
|
208
|
+
q: 1,
|
209
|
+
k: closestBranch,
|
210
|
+
$global
|
211
|
+
};
|
212
|
+
return pendingScopes.push(scope), scope;
|
213
|
+
}
|
214
|
+
function skipScope(scope) {
|
215
|
+
return scope.$global.p++;
|
216
|
+
}
|
217
|
+
function findBranchWithKey(scope, key) {
|
218
|
+
let branch = scope.k;
|
219
|
+
for (; branch && !branch[key]; )
|
220
|
+
branch = branch.y;
|
221
|
+
return branch;
|
222
|
+
}
|
223
|
+
function destroyBranch(branch) {
|
224
|
+
branch.y?.A?.delete(branch), destroyNestedBranches(branch);
|
225
|
+
}
|
226
|
+
function destroyNestedBranches(branch) {
|
227
|
+
branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.J?.forEach((scope) => {
|
228
|
+
for (let id in scope.z)
|
229
|
+
scope.z[id]?.abort();
|
230
|
+
});
|
231
|
+
}
|
232
|
+
function removeAndDestroyBranch(branch) {
|
233
|
+
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
234
|
+
}
|
235
|
+
function insertBranchBefore(branch, parentNode, nextSibling) {
|
236
|
+
insertChildNodes(
|
237
|
+
parentNode,
|
238
|
+
nextSibling,
|
239
|
+
branch.h,
|
240
|
+
branch.j
|
241
|
+
);
|
242
|
+
}
|
243
|
+
function tempDetachBranch(branch) {
|
244
|
+
let fragment = new DocumentFragment();
|
245
|
+
fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
|
246
|
+
}
|
247
|
+
|
248
|
+
// src/dom/walker.ts
|
249
|
+
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
250
|
+
function walk(startNode, walkCodes, branch) {
|
251
|
+
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
252
|
+
}
|
253
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
254
|
+
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
255
|
+
for (; currentWalkIndex < walkCodes.length; )
|
256
|
+
if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
|
257
|
+
let node = walker.currentNode;
|
258
|
+
scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
|
259
|
+
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
|
260
|
+
walker.currentNode.replaceWith(
|
261
|
+
walker.currentNode = scope[currentScopeIndex++] = new Text()
|
262
|
+
), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
263
|
+
else {
|
264
|
+
if (value2 === 38 /* EndChild */)
|
265
|
+
return currentWalkIndex;
|
266
|
+
if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
|
267
|
+
currentWalkIndex = walkInternal(
|
268
|
+
currentWalkIndex,
|
269
|
+
walkCodes,
|
270
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
271
|
+
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
272
|
+
else if (value2 < 92)
|
273
|
+
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
274
|
+
walker.nextNode();
|
275
|
+
else if (value2 < 107)
|
276
|
+
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
277
|
+
walker.nextSibling();
|
278
|
+
else if (value2 < 117) {
|
279
|
+
for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
|
280
|
+
walker.parentNode();
|
281
|
+
walker.nextSibling();
|
282
|
+
} else
|
283
|
+
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
204
287
|
// src/dom/resume.ts
|
205
288
|
var registeredValues = {}, branchesEnabled;
|
206
289
|
function enableBranches() {
|
@@ -219,7 +302,7 @@ function init(runtimeId = "M") {
|
|
219
302
|
return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
|
220
303
|
};
|
221
304
|
return {
|
222
|
-
|
305
|
+
K() {
|
223
306
|
if (visitToken === "[" /* BranchStart */)
|
224
307
|
currentBranchId && visitDataIndex && (endBranch(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, visitScope.h = visit;
|
225
308
|
else if (visitToken === "]" /* BranchEnd */) {
|
@@ -237,11 +320,14 @@ function init(runtimeId = "M") {
|
|
237
320
|
start,
|
238
321
|
~next ? next : visitData.length
|
239
322
|
);
|
240
|
-
curNode = endBranch(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId)
|
323
|
+
if (curNode = endBranch(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId), visitToken === "'" /* BranchNativeTag */) {
|
324
|
+
let childBranch = scopeLookup[childScopeId];
|
325
|
+
childBranch[0] = childBranch.h = childBranch.j = curNode;
|
326
|
+
}
|
241
327
|
}
|
242
328
|
}
|
243
329
|
},
|
244
|
-
|
330
|
+
t(scope) {
|
245
331
|
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
246
332
|
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
247
333
|
let branch = scope, parentBranch = branch.k;
|
@@ -259,7 +345,7 @@ function init(runtimeId = "M") {
|
|
259
345
|
visitDataIndex ? visitDataIndex - 1 : visitText.length
|
260
346
|
), visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "", visitToken = visitText[commentPrefixLen], visitScope = scopeLookup[scopeId] ||= {
|
261
347
|
l: scopeId
|
262
|
-
}, visitToken === "*" /* Node */ ? visitScope["j" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling) : branches && branches.
|
348
|
+
}, visitToken === "*" /* Node */ ? visitScope["j" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling) : branches && branches.K();
|
263
349
|
for (let serialized of resumes = render.r || [])
|
264
350
|
if (typeof serialized == "string")
|
265
351
|
lastEffect = serialized;
|
@@ -275,7 +361,7 @@ function init(runtimeId = "M") {
|
|
275
361
|
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.l = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
|
276
362
|
scope,
|
277
363
|
scopeLookup[scopeId]
|
278
|
-
)), branches && branches.
|
364
|
+
)), branches && branches.t(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
|
279
365
|
} finally {
|
280
366
|
isResuming = visits.length = resumes.length = 0;
|
281
367
|
}
|
@@ -500,50 +586,6 @@ function parseHTML(html2, ns) {
|
|
500
586
|
return parser.innerHTML = html2, parser.content || parser;
|
501
587
|
}
|
502
588
|
|
503
|
-
// src/dom/scope.ts
|
504
|
-
function createScope($global, closestBranch) {
|
505
|
-
let scope = {
|
506
|
-
l: $global.q++,
|
507
|
-
t: 1,
|
508
|
-
k: closestBranch,
|
509
|
-
$global
|
510
|
-
};
|
511
|
-
return pendingScopes.push(scope), scope;
|
512
|
-
}
|
513
|
-
function skipScope(scope) {
|
514
|
-
return scope.$global.q++;
|
515
|
-
}
|
516
|
-
function findBranchWithKey(scope, key) {
|
517
|
-
let branch = scope.k;
|
518
|
-
for (; branch && !branch[key]; )
|
519
|
-
branch = branch.y;
|
520
|
-
return branch;
|
521
|
-
}
|
522
|
-
function destroyBranch(branch) {
|
523
|
-
branch.y?.A?.delete(branch), destroyNestedBranches(branch);
|
524
|
-
}
|
525
|
-
function destroyNestedBranches(branch) {
|
526
|
-
branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
|
527
|
-
for (let id in scope.z)
|
528
|
-
scope.z[id]?.abort();
|
529
|
-
});
|
530
|
-
}
|
531
|
-
function removeAndDestroyBranch(branch) {
|
532
|
-
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
533
|
-
}
|
534
|
-
function insertBranchBefore(branch, parentNode, nextSibling) {
|
535
|
-
insertChildNodes(
|
536
|
-
parentNode,
|
537
|
-
nextSibling,
|
538
|
-
branch.h,
|
539
|
-
branch.j
|
540
|
-
);
|
541
|
-
}
|
542
|
-
function tempDetachBranch(branch) {
|
543
|
-
let fragment = new DocumentFragment();
|
544
|
-
fragment.namespaceURI = branch.h.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.h, branch.j);
|
545
|
-
}
|
546
|
-
|
547
589
|
// src/dom/schedule.ts
|
548
590
|
var isScheduled, channel;
|
549
591
|
function schedule() {
|
@@ -580,7 +622,7 @@ function value(valueAccessor, fn = () => {
|
|
580
622
|
}
|
581
623
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "l") {
|
582
624
|
return (scope) => {
|
583
|
-
scope.
|
625
|
+
scope.q ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
584
626
|
};
|
585
627
|
}
|
586
628
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -590,7 +632,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
590
632
|
ownerScope,
|
591
633
|
() => {
|
592
634
|
for (let scope of scopes)
|
593
|
-
!scope.
|
635
|
+
!scope.q && !scope.B && childSignal(scope);
|
594
636
|
},
|
595
637
|
-1,
|
596
638
|
0,
|
@@ -602,7 +644,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
602
644
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
603
645
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
604
646
|
let ifScope = scope[scopeAccessor];
|
605
|
-
ifScope && !ifScope.
|
647
|
+
ifScope && !ifScope.q && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
606
648
|
};
|
607
649
|
return ownerSignal._ = childSignal, ownerSignal;
|
608
650
|
}
|
@@ -620,7 +662,7 @@ function dynamicClosure(...closureSignals) {
|
|
620
662
|
return (scope) => {
|
621
663
|
if (scope[___scopeInstancesAccessor])
|
622
664
|
for (let childScope of scope[___scopeInstancesAccessor])
|
623
|
-
childScope.
|
665
|
+
childScope.q || queueRender(
|
624
666
|
childScope,
|
625
667
|
closureSignals[childScope[___signalIndexAccessor]],
|
626
668
|
-1
|
@@ -676,45 +718,6 @@ function hoist(...path) {
|
|
676
718
|
};
|
677
719
|
}
|
678
720
|
|
679
|
-
// src/dom/walker.ts
|
680
|
-
var walker = /* @__PURE__ */ document.createTreeWalker(document);
|
681
|
-
function walk(startNode, walkCodes, branch) {
|
682
|
-
walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
|
683
|
-
}
|
684
|
-
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
685
|
-
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
686
|
-
for (; currentWalkIndex < walkCodes.length; )
|
687
|
-
if (value2 = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 === 32 /* Get */) {
|
688
|
-
let node = walker.currentNode;
|
689
|
-
scope[currentScopeIndex] = node, scope["j" /* Getter */ + currentScopeIndex++] = () => node;
|
690
|
-
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */)
|
691
|
-
walker.currentNode.replaceWith(
|
692
|
-
walker.currentNode = scope[currentScopeIndex++] = new Text()
|
693
|
-
), value2 === 49 /* DynamicTagWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
694
|
-
else {
|
695
|
-
if (value2 === 38 /* EndChild */)
|
696
|
-
return currentWalkIndex;
|
697
|
-
if (value2 === 47 /* BeginChild */ || value2 === 48 /* BeginChildWithVar */)
|
698
|
-
currentWalkIndex = walkInternal(
|
699
|
-
currentWalkIndex,
|
700
|
-
walkCodes,
|
701
|
-
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
702
|
-
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
703
|
-
else if (value2 < 92)
|
704
|
-
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
705
|
-
walker.nextNode();
|
706
|
-
else if (value2 < 107)
|
707
|
-
for (value2 = 10 /* Over */ * currentMultiplier + value2 - 97 /* Over */; value2--; )
|
708
|
-
walker.nextSibling();
|
709
|
-
else if (value2 < 117) {
|
710
|
-
for (value2 = 10 /* Out */ * currentMultiplier + value2 - 107 /* Out */; value2--; )
|
711
|
-
walker.parentNode();
|
712
|
-
walker.nextSibling();
|
713
|
-
} else
|
714
|
-
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
715
|
-
}
|
716
|
-
}
|
717
|
-
|
718
721
|
// src/dom/renderer.ts
|
719
722
|
function createBranch($global, renderer, parentScope, parentNode) {
|
720
723
|
let branch = createScope($global), parentBranch = parentScope?.k;
|
@@ -1230,7 +1233,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1230
1233
|
if (normalizedRenderer) {
|
1231
1234
|
let childScope = scope[childScopeAccessor], args = getInput?.();
|
1232
1235
|
if (typeof normalizedRenderer == "string")
|
1233
|
-
attrs(
|
1236
|
+
(getContent ? attrs : attrsAndContent)(
|
1234
1237
|
childScope,
|
1235
1238
|
0,
|
1236
1239
|
(inputIsArgs ? args[0] : args) || {}
|
@@ -1330,7 +1333,7 @@ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.l) {
|
|
1330
1333
|
else {
|
1331
1334
|
let render = {
|
1332
1335
|
x: key,
|
1333
|
-
|
1336
|
+
t: scope,
|
1334
1337
|
N: signal,
|
1335
1338
|
I: value2
|
1336
1339
|
}, i = pendingRenders.push(render) - 1;
|
@@ -1384,13 +1387,13 @@ function runRenders() {
|
|
1384
1387
|
}
|
1385
1388
|
pendingRenders[i] = item;
|
1386
1389
|
}
|
1387
|
-
render.
|
1390
|
+
render.t.k?.B || runRender(render);
|
1388
1391
|
}
|
1389
1392
|
for (let scope of pendingScopes)
|
1390
|
-
scope.
|
1393
|
+
scope.q = 0;
|
1391
1394
|
pendingScopes = [];
|
1392
1395
|
}
|
1393
|
-
var runRender = (render) => render.N(render.
|
1396
|
+
var runRender = (render) => render.N(render.t, render.I), enableCatch = () => {
|
1394
1397
|
enableCatch = () => {
|
1395
1398
|
}, enableBranches();
|
1396
1399
|
let handlePendingTry = (fn, scope, branch) => {
|
@@ -1411,7 +1414,7 @@ var runRender = (render) => render.N(render.p, render.I), enableCatch = () => {
|
|
1411
1414
|
try {
|
1412
1415
|
runRender2(render);
|
1413
1416
|
} catch (error) {
|
1414
|
-
renderCatch(render.
|
1417
|
+
renderCatch(render.t, error);
|
1415
1418
|
}
|
1416
1419
|
})(runRender);
|
1417
1420
|
};
|
@@ -1422,7 +1425,7 @@ function resetAbortSignal(scope, id) {
|
|
1422
1425
|
ctrl && (queueEffect(ctrl, abort), scope.z[id] = void 0);
|
1423
1426
|
}
|
1424
1427
|
function getAbortSignal(scope, id) {
|
1425
|
-
return scope.k && (scope.k.
|
1428
|
+
return scope.k && (scope.k.J ||= /* @__PURE__ */ new Set()).add(scope), ((scope.z ||= {})[id] ||= new AbortController()).signal;
|
1426
1429
|
}
|
1427
1430
|
function abort(ctrl) {
|
1428
1431
|
ctrl.abort();
|
@@ -1481,7 +1484,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1481
1484
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1482
1485
|
}
|
1483
1486
|
if (component.effects = prepareEffects(() => {
|
1484
|
-
branch ? existing = 1 : (out.global.
|
1487
|
+
branch ? existing = 1 : (out.global.p ||= 0, branch = component.scope = createAndSetupBranch(
|
1485
1488
|
out.global,
|
1486
1489
|
renderer,
|
1487
1490
|
renderer.u,
|
@@ -1506,12 +1509,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1506
1509
|
function mount(input = {}, reference, position) {
|
1507
1510
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1508
1511
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1509
|
-
|
1512
|
+
p: 0,
|
1510
1513
|
runtimeId: "M",
|
1511
1514
|
renderId: "_",
|
1512
1515
|
...$global
|
1513
1516
|
}) : $global = {
|
1514
|
-
|
1517
|
+
p: 0,
|
1515
1518
|
runtimeId: "M",
|
1516
1519
|
renderId: "_"
|
1517
1520
|
}, position) {
|