marko 6.0.0-next.3.63 → 6.0.0-next.3.65
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/accessor.d.ts +2 -1
- package/dist/common/accessor.debug.d.ts +2 -1
- package/dist/common/types.d.ts +3 -3
- package/dist/debug/dom.js +140 -110
- package/dist/debug/dom.mjs +140 -110
- package/dist/debug/html.js +5 -5
- package/dist/debug/html.mjs +5 -5
- package/dist/dom/control-flow.d.ts +1 -0
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.js +188 -185
- package/dist/dom.mjs +188 -185
- package/dist/html.js +7 -7
- package/dist/html.mjs +7 -7
- package/dist/translator/index.js +2 -0
- package/package.json +1 -1
package/dist/dom.js
CHANGED
@@ -211,48 +211,42 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
211
211
|
let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
212
212
|
defineRuntime({
|
213
213
|
value: resumeRender = (renderId) => {
|
214
|
-
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length,
|
214
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
|
215
215
|
_: registeredValues
|
216
|
-
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(),
|
216
|
+
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), currentBranchId;
|
217
217
|
return render.w = () => {
|
218
218
|
walk2.call(render);
|
219
219
|
let visits = render.v, resumes = render.r;
|
220
220
|
if (visits.length) {
|
221
221
|
let visitNodes = new Set(visits), lastEndNode;
|
222
|
-
|
223
|
-
let branchEnd = (branchId,
|
222
|
+
visits.length = 0;
|
223
|
+
let branchEnd = (branchId, reference) => {
|
224
224
|
let branch = scopeLookup[branchId] ||= {}, endNode = reference;
|
225
225
|
for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
|
226
|
-
endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
226
|
+
return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
227
227
|
new Text(),
|
228
228
|
reference
|
229
|
-
)), branch.
|
230
|
-
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
231
|
-
branch.g.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
232
|
-
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
229
|
+
)), branch.j = lastEndNode = endNode, branch.h ||= endNode, branchIds.add(branchId), branch;
|
233
230
|
};
|
234
|
-
for (let visit of
|
231
|
+
for (let visit of visitNodes) {
|
235
232
|
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
236
233
|
commentPrefixLen + 1,
|
237
234
|
dataIndex ? dataIndex - 1 : commentText.length
|
238
235
|
), scope = scopeLookup[scopeId] ||= {
|
239
|
-
|
236
|
+
m: +scopeId
|
240
237
|
}, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
241
238
|
if (token === "*" /* Node */) {
|
242
239
|
let node = scope[data2] = visit.previousSibling;
|
243
240
|
scope["j" /* Getter */ + data2] = () => node;
|
244
|
-
} else if (token === "
|
245
|
-
|
246
|
-
else if (token === "[" /* BranchStart */)
|
247
|
-
currentScopeId && (dataIndex && branchEnd(currentScopeId, visit, visit), scopeStack.push(currentScopeId)), currentScopeId = scopeId, scope.g = visit;
|
241
|
+
} else if (token === "[" /* BranchStart */)
|
242
|
+
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
248
243
|
else if (token === "]" /* BranchEnd */) {
|
249
244
|
scope[data2] = visit;
|
250
245
|
let curParent = visit.parentNode, startNode = branchEnd(
|
251
|
-
|
252
|
-
visit,
|
246
|
+
currentBranchId,
|
253
247
|
visit
|
254
|
-
).
|
255
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode),
|
248
|
+
).h;
|
249
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
256
250
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
257
251
|
let next = data2.indexOf(" "), curNode = visit;
|
258
252
|
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -262,7 +256,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
262
256
|
start,
|
263
257
|
~next ? next : data2.length
|
264
258
|
);
|
265
|
-
curNode = branchEnd(childScopeId,
|
259
|
+
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
266
260
|
}
|
267
261
|
}
|
268
262
|
}
|
@@ -274,18 +268,18 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
274
268
|
let serialized = resumes[i];
|
275
269
|
if (typeof serialized == "function") {
|
276
270
|
let scopes = serialized(serializeContext), { $global } = scopeLookup;
|
277
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.
|
271
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.n = 1e6);
|
278
272
|
for (let scopeId in scopes)
|
279
273
|
if (scopeId !== "$") {
|
280
274
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
281
|
-
scope.$global = $global, scope.
|
275
|
+
scope.$global = $global, scope.m = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
282
276
|
scope,
|
283
277
|
prevScope
|
284
278
|
));
|
285
|
-
let parentBranchId = parentBranchIds.get(scopeId);
|
286
|
-
if (parentBranchId && (scope.
|
287
|
-
let branch = scope, parentBranch = branch.
|
288
|
-
scope.
|
279
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
280
|
+
if (parentBranchId && (scope.k = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
281
|
+
let branch = scope, parentBranch = branch.k;
|
282
|
+
scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(
|
289
283
|
branch
|
290
284
|
));
|
291
285
|
}
|
@@ -718,47 +712,53 @@ function toInsertNode(startNode, endNode) {
|
|
718
712
|
var pendingScopes = [];
|
719
713
|
function createScope($global, closestBranch) {
|
720
714
|
let scope = {
|
721
|
-
|
715
|
+
m: $global.n++,
|
722
716
|
o: 1,
|
723
|
-
|
717
|
+
k: closestBranch,
|
724
718
|
$global
|
725
719
|
};
|
726
720
|
return pendingScopes.push(scope), scope;
|
727
721
|
}
|
728
722
|
function skipScope(scope) {
|
729
|
-
return scope.$global.
|
723
|
+
return scope.$global.n++;
|
730
724
|
}
|
731
725
|
function finishPendingScopes() {
|
732
726
|
for (let scope of pendingScopes)
|
733
727
|
scope.o = 0;
|
734
728
|
pendingScopes = [];
|
735
729
|
}
|
730
|
+
function findBranchWithKey(scope, key) {
|
731
|
+
let branch = scope.k;
|
732
|
+
for (; branch && !branch[key]; )
|
733
|
+
branch = branch.u;
|
734
|
+
return branch;
|
735
|
+
}
|
736
736
|
function destroyBranch(branch) {
|
737
|
-
branch.
|
737
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
738
738
|
}
|
739
739
|
function destroyNestedBranches(branch) {
|
740
|
-
branch.
|
741
|
-
for (let id in scope.
|
742
|
-
scope.
|
740
|
+
branch.p = 1, branch.A?.forEach(destroyNestedBranches), branch.J?.forEach((scope) => {
|
741
|
+
for (let id in scope.x)
|
742
|
+
scope.x[id]?.abort();
|
743
743
|
});
|
744
744
|
}
|
745
745
|
function removeAndDestroyBranch(branch) {
|
746
|
-
destroyBranch(branch), removeChildNodes(branch.
|
746
|
+
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
747
747
|
}
|
748
748
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
749
749
|
insertChildNodes(
|
750
750
|
parentNode,
|
751
751
|
nextSibling,
|
752
|
-
branch.
|
753
|
-
branch.
|
752
|
+
branch.h,
|
753
|
+
branch.j
|
754
754
|
);
|
755
755
|
}
|
756
756
|
function tempDetatchBranch(branch) {
|
757
757
|
insertChildNodes(
|
758
758
|
new DocumentFragment(),
|
759
759
|
null,
|
760
|
-
branch.
|
761
|
-
branch.
|
760
|
+
branch.h,
|
761
|
+
branch.j
|
762
762
|
);
|
763
763
|
}
|
764
764
|
|
@@ -780,7 +780,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
780
780
|
}
|
781
781
|
if (oldStart > oldEnd) {
|
782
782
|
if (newStart <= newEnd) {
|
783
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].
|
783
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].h : afterReference;
|
784
784
|
do
|
785
785
|
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
786
786
|
while (newStart <= newEnd);
|
@@ -809,10 +809,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
809
809
|
if (pos === WRONG_POS) {
|
810
810
|
let seq = longestIncreasingSubsequence(sources);
|
811
811
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
812
|
-
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].
|
812
|
+
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
|
813
813
|
} else if (synced !== newLength)
|
814
814
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
815
|
-
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].
|
815
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].h : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
|
816
816
|
}
|
817
817
|
}
|
818
818
|
}
|
@@ -859,7 +859,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
859
859
|
currentWalkIndex = walkInternal(
|
860
860
|
currentWalkIndex,
|
861
861
|
walkCodes,
|
862
|
-
scope[currentScopeIndex++] = createScope(scope.$global, scope.
|
862
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
863
863
|
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
864
864
|
else if (value2 < 92)
|
865
865
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
@@ -878,8 +878,8 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
878
878
|
|
879
879
|
// src/dom/renderer.ts
|
880
880
|
function createBranch($global, renderer, parentScope, parentNode) {
|
881
|
-
let branch = createScope($global), parentBranch = parentScope?.
|
882
|
-
return branch._ = renderer.
|
881
|
+
let branch = createScope($global), parentBranch = parentScope?.k;
|
882
|
+
return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.B?.(
|
883
883
|
branch,
|
884
884
|
parentNode.namespaceURI
|
885
885
|
), branch;
|
@@ -891,10 +891,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
891
891
|
);
|
892
892
|
}
|
893
893
|
function setupBranch(renderer, branch) {
|
894
|
-
return (renderer.
|
894
|
+
return (renderer.C || renderer.E) && queueRender(
|
895
895
|
branch,
|
896
896
|
(branch2) => {
|
897
|
-
renderer.
|
897
|
+
renderer.C?.(branch2), renderer.E?.(branch2);
|
898
898
|
},
|
899
899
|
-1
|
900
900
|
), branch;
|
@@ -908,19 +908,19 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
908
908
|
))(branch, walks);
|
909
909
|
} : (branch) => {
|
910
910
|
walk(
|
911
|
-
branch.
|
911
|
+
branch.h = branch.j = new Text(),
|
912
912
|
walks,
|
913
913
|
branch
|
914
914
|
);
|
915
915
|
};
|
916
916
|
return (owner) => ({
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
917
|
+
m: id,
|
918
|
+
B: clone,
|
919
|
+
y: owner,
|
920
|
+
C: setup,
|
921
|
+
l: params,
|
922
|
+
E: closures,
|
923
|
+
z: dynamicScopesAccessor
|
924
924
|
});
|
925
925
|
}
|
926
926
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -945,13 +945,13 @@ function createCloneableHTML(html2, ns) {
|
|
945
945
|
let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
|
946
946
|
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
947
947
|
walk(
|
948
|
-
branch.
|
948
|
+
branch.h = branch.j = firstChild.cloneNode(!0),
|
949
949
|
walks,
|
950
950
|
branch
|
951
951
|
);
|
952
952
|
} : (branch, walks) => {
|
953
953
|
let clone = parent.cloneNode(!0);
|
954
|
-
walk(clone.firstChild, walks, branch), branch.
|
954
|
+
walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
|
955
955
|
};
|
956
956
|
}
|
957
957
|
|
@@ -992,7 +992,7 @@ function value(valueAccessor, fn = () => {
|
|
992
992
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
993
993
|
};
|
994
994
|
}
|
995
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
995
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
996
996
|
return (scope) => {
|
997
997
|
scope.o ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
998
998
|
};
|
@@ -1004,11 +1004,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1004
1004
|
ownerScope,
|
1005
1005
|
() => {
|
1006
1006
|
for (let scope of scopes)
|
1007
|
-
!scope.o && !scope.
|
1007
|
+
!scope.o && !scope.p && childSignal(scope);
|
1008
1008
|
},
|
1009
1009
|
-1,
|
1010
1010
|
0,
|
1011
|
-
firstScope.
|
1011
|
+
firstScope.m
|
1012
1012
|
);
|
1013
1013
|
};
|
1014
1014
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -1028,9 +1028,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1028
1028
|
));
|
1029
1029
|
}
|
1030
1030
|
function dynamicClosure(...closureSignals) {
|
1031
|
-
let [{
|
1031
|
+
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
1032
1032
|
for (let i = closureSignals.length; i--; )
|
1033
|
-
closureSignals[i].
|
1033
|
+
closureSignals[i].K = i;
|
1034
1034
|
return (scope) => {
|
1035
1035
|
if (scope[___scopeInstancesAccessor])
|
1036
1036
|
for (let childScope of scope[___scopeInstancesAccessor])
|
@@ -1043,13 +1043,13 @@ function dynamicClosure(...closureSignals) {
|
|
1043
1043
|
}
|
1044
1044
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1045
1045
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1046
|
-
scope[closureSignal.
|
1046
|
+
scope[closureSignal.G] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
|
1047
1047
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1048
|
-
closureSignal.
|
1048
|
+
closureSignal.F,
|
1049
1049
|
scope
|
1050
1050
|
);
|
1051
1051
|
};
|
1052
|
-
return closureSignal.
|
1052
|
+
return closureSignal.F = "a" /* ClosureScopes */ + valueAccessor, closureSignal.G = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
1053
1053
|
}
|
1054
1054
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1055
1055
|
return (scope) => {
|
@@ -1091,73 +1091,55 @@ function hoist(...path) {
|
|
1091
1091
|
function awaitTag(nodeAccessor, renderer) {
|
1092
1092
|
let promiseAccessor = "n" /* Promise */ + nodeAccessor, branchAccessor = "d" /* ConditionalScope */ + nodeAccessor;
|
1093
1093
|
return (scope, promise) => {
|
1094
|
-
let
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
if (scope.
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
namespaceNode
|
1108
|
-
),
|
1109
|
-
referenceNode.parentNode,
|
1110
|
-
referenceNode
|
1111
|
-
), referenceNode.remove()), renderer.k?.(awaitBranch, [data2]);
|
1112
|
-
});
|
1113
|
-
if (tryBranch) {
|
1114
|
-
if (!--tryBranch.y) {
|
1115
|
-
let placeholderBranch = tryBranch.c;
|
1116
|
-
placeholderBranch ? (insertBranchBefore(
|
1117
|
-
tryBranch,
|
1118
|
-
placeholderBranch.g.parentNode,
|
1119
|
-
placeholderBranch.g
|
1120
|
-
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1121
|
-
tryBranch,
|
1094
|
+
let tryWithPlaceholder = findBranchWithKey(
|
1095
|
+
scope,
|
1096
|
+
"d" /* PlaceholderContent */
|
1097
|
+
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.h ?? referenceNode).parentNode, thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1098
|
+
if (!(scope.k?.p || scope[promiseAccessor] !== thisPromise) && (scope[promiseAccessor] = void 0, runEffects(
|
1099
|
+
prepareEffects(() => {
|
1100
|
+
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1101
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1102
|
+
scope.$global,
|
1103
|
+
renderer,
|
1104
|
+
scope,
|
1105
|
+
namespaceNode
|
1106
|
+
),
|
1122
1107
|
referenceNode.parentNode,
|
1123
1108
|
referenceNode
|
1124
|
-
);
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
|
1109
|
+
), referenceNode.remove()), renderer.l?.(awaitBranch, [data2]);
|
1110
|
+
})
|
1111
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.q)) {
|
1112
|
+
let placeholderBranch = tryWithPlaceholder.c;
|
1113
|
+
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1114
|
+
tryWithPlaceholder,
|
1115
|
+
placeholderBranch.h.parentNode,
|
1116
|
+
placeholderBranch.h
|
1117
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1118
|
+
tryWithPlaceholder,
|
1119
|
+
referenceNode.parentNode,
|
1120
|
+
referenceNode
|
1121
|
+
), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
|
1122
|
+
}
|
1128
1123
|
}).catch((error) => {
|
1129
|
-
|
1130
|
-
for (; tryBranch2 && !tryBranch2.b; )
|
1131
|
-
tryBranch2 = tryBranch2.n;
|
1132
|
-
tryBranch2 ? (setConditionalRenderer(
|
1133
|
-
tryBranch2._,
|
1134
|
-
tryBranch2.a,
|
1135
|
-
tryBranch2.b,
|
1136
|
-
createAndSetupBranch
|
1137
|
-
), tryBranch2.b.k?.(
|
1138
|
-
tryBranch2._["d" /* ConditionalScope */ + tryBranch2.a],
|
1139
|
-
[error]
|
1140
|
-
)) : setTimeout(() => {
|
1141
|
-
throw error;
|
1142
|
-
});
|
1124
|
+
renderCatch(scope, error, !0);
|
1143
1125
|
});
|
1144
|
-
|
1145
|
-
if (
|
1146
|
-
let placeholderBranch =
|
1126
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.q || (tryWithPlaceholder.q = 0, requestAnimationFrame(() => {
|
1127
|
+
if (tryWithPlaceholder.q && !tryWithPlaceholder.p) {
|
1128
|
+
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1147
1129
|
scope.$global,
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1130
|
+
tryWithPlaceholder.d,
|
1131
|
+
tryWithPlaceholder._,
|
1132
|
+
tryWithPlaceholder.h.parentNode
|
1151
1133
|
);
|
1152
1134
|
insertBranchBefore(
|
1153
1135
|
placeholderBranch,
|
1154
|
-
|
1155
|
-
|
1156
|
-
), tempDetatchBranch(
|
1136
|
+
tryWithPlaceholder.h.parentNode,
|
1137
|
+
tryWithPlaceholder.h
|
1138
|
+
), tempDetatchBranch(tryWithPlaceholder);
|
1157
1139
|
}
|
1158
|
-
})),
|
1140
|
+
})), tryWithPlaceholder.q++) : awaitBranch && (awaitBranch.h.parentNode.insertBefore(
|
1159
1141
|
referenceNode,
|
1160
|
-
awaitBranch.
|
1142
|
+
awaitBranch.h
|
1161
1143
|
), tempDetatchBranch(awaitBranch));
|
1162
1144
|
};
|
1163
1145
|
}
|
@@ -1176,6 +1158,26 @@ function createTry(nodeAccessor, tryContent) {
|
|
1176
1158
|
));
|
1177
1159
|
};
|
1178
1160
|
}
|
1161
|
+
function renderCatch(scope, error, async) {
|
1162
|
+
let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
|
1163
|
+
if (tryWithCatch) {
|
1164
|
+
let placeholderBranch = tryWithCatch.c;
|
1165
|
+
placeholderBranch && (tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
1166
|
+
tryWithCatch._,
|
1167
|
+
tryWithCatch.a,
|
1168
|
+
tryWithCatch.b,
|
1169
|
+
createAndSetupBranch
|
1170
|
+
), tryWithCatch.b.l?.(
|
1171
|
+
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1172
|
+
[error]
|
1173
|
+
);
|
1174
|
+
} else if (async)
|
1175
|
+
setTimeout(() => {
|
1176
|
+
throw error;
|
1177
|
+
});
|
1178
|
+
else
|
1179
|
+
throw error;
|
1180
|
+
}
|
1179
1181
|
function conditional(nodeAccessor, ...branches) {
|
1180
1182
|
let branchAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1181
1183
|
return (scope, newBranch) => {
|
@@ -1194,7 +1196,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1194
1196
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1195
1197
|
return (scope, newRenderer, getInput) => {
|
1196
1198
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1197
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1199
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1198
1200
|
if (setConditionalRenderer(
|
1199
1201
|
scope,
|
1200
1202
|
nodeAccessor,
|
@@ -1208,15 +1210,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1208
1210
|
0,
|
1209
1211
|
content,
|
1210
1212
|
createAndSetupBranch
|
1211
|
-
), content.
|
1212
|
-
content.
|
1213
|
-
content.
|
1213
|
+
), content.z && subscribeToScopeSet(
|
1214
|
+
content.y,
|
1215
|
+
content.z,
|
1214
1216
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1215
1217
|
);
|
1216
1218
|
}
|
1217
|
-
} else normalizedRenderer?.
|
1218
|
-
normalizedRenderer.
|
1219
|
-
normalizedRenderer.
|
1219
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1220
|
+
normalizedRenderer.y,
|
1221
|
+
normalizedRenderer.z,
|
1220
1222
|
scope[childScopeAccessor]
|
1221
1223
|
);
|
1222
1224
|
if (normalizedRenderer) {
|
@@ -1227,9 +1229,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1227
1229
|
0,
|
1228
1230
|
(inputIsArgs ? args[0] : args) || {}
|
1229
1231
|
);
|
1230
|
-
else if (normalizedRenderer.
|
1232
|
+
else if (normalizedRenderer.l)
|
1231
1233
|
if (inputIsArgs)
|
1232
|
-
normalizedRenderer.
|
1234
|
+
normalizedRenderer.l(
|
1233
1235
|
scope[childScopeAccessor],
|
1234
1236
|
normalizedRenderer._ ? args[0] : args
|
1235
1237
|
);
|
@@ -1238,7 +1240,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1238
1240
|
...args,
|
1239
1241
|
content: getContent(scope)
|
1240
1242
|
} : args || {};
|
1241
|
-
normalizedRenderer.
|
1243
|
+
normalizedRenderer.l(
|
1242
1244
|
scope[childScopeAccessor],
|
1243
1245
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1244
1246
|
);
|
@@ -1247,8 +1249,8 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1247
1249
|
};
|
1248
1250
|
};
|
1249
1251
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1250
|
-
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.
|
1251
|
-
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.
|
1252
|
+
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.h || referenceNode).parentNode : referenceNode, newBranch = scope["d" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
1253
|
+
referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.h) : parentNode.insertBefore(referenceNode, prevBranch.h), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
|
1252
1254
|
}
|
1253
1255
|
function loopOf(nodeAccessor, renderer) {
|
1254
1256
|
return loop(
|
@@ -1277,17 +1279,17 @@ function loopTo(nodeAccessor, renderer) {
|
|
1277
1279
|
);
|
1278
1280
|
}
|
1279
1281
|
function loop(nodeAccessor, renderer, forEach) {
|
1280
|
-
let params = renderer.
|
1282
|
+
let params = renderer.l;
|
1281
1283
|
return (scope, value2) => {
|
1282
1284
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1283
1285
|
...oldMap.values()
|
1284
|
-
] : [], parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].
|
1286
|
+
] : [], 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] = [];
|
1285
1287
|
forEach(value2, (key, args) => {
|
1286
1288
|
let branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1287
1289
|
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1288
1290
|
});
|
1289
1291
|
let afterReference = null;
|
1290
|
-
referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].
|
1292
|
+
referenceNode !== parentNode && (oldArray.length ? (afterReference = oldArray[oldArray.length - 1].j.nextSibling, newArray.length || parentNode.insertBefore(referenceNode, afterReference)) : newArray.length && (afterReference = referenceNode.nextSibling, referenceNode.remove())), reconcile(parentNode, oldArray, newArray, afterReference);
|
1291
1293
|
};
|
1292
1294
|
}
|
1293
1295
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
@@ -1297,7 +1299,7 @@ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentSco
|
|
1297
1299
|
parentScope,
|
1298
1300
|
parentNode
|
1299
1301
|
);
|
1300
|
-
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.
|
1302
|
+
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.h = branch.j = document.createElementNS(
|
1301
1303
|
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1302
1304
|
tagNameOrRenderer
|
1303
1305
|
) : setupBranch(tagNameOrRenderer, branch), branch;
|
@@ -1310,21 +1312,21 @@ function byFirstArg(name) {
|
|
1310
1312
|
}
|
1311
1313
|
|
1312
1314
|
// src/dom/queue.ts
|
1313
|
-
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1314
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.
|
1315
|
+
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1316
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
1315
1317
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1316
1318
|
if (existingRender)
|
1317
|
-
existingRender.
|
1319
|
+
existingRender.I = value2;
|
1318
1320
|
else {
|
1319
1321
|
let render = {
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1322
|
+
t: key,
|
1323
|
+
D: scope,
|
1324
|
+
L: signal,
|
1325
|
+
I: value2
|
1324
1326
|
}, i = pendingRenders.push(render) - 1;
|
1325
1327
|
for (; i; ) {
|
1326
1328
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1327
|
-
if (key - parent.
|
1329
|
+
if (key - parent.t >= 0) break;
|
1328
1330
|
pendingRenders[i] = parent, i = parentIndex;
|
1329
1331
|
}
|
1330
1332
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1352,62 +1354,63 @@ function prepareEffects(fn) {
|
|
1352
1354
|
}
|
1353
1355
|
return preparedEffects;
|
1354
1356
|
}
|
1355
|
-
|
1357
|
+
var runEffects = (effects) => {
|
1356
1358
|
for (let i = 0, scope; i < effects.length; )
|
1357
1359
|
effects[i++](
|
1358
1360
|
scope = effects[i++],
|
1359
1361
|
scope
|
1360
1362
|
);
|
1361
|
-
}
|
1363
|
+
};
|
1362
1364
|
function runRenders() {
|
1363
1365
|
for (; pendingRenders.length; ) {
|
1364
1366
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1365
1367
|
if (render !== item) {
|
1366
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1368
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1367
1369
|
for (; i < mid; ) {
|
1368
1370
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1369
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1371
|
+
if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
|
1370
1372
|
break;
|
1371
1373
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1372
1374
|
}
|
1373
1375
|
pendingRenders[i] = item;
|
1374
1376
|
}
|
1375
|
-
render.
|
1377
|
+
render.D.k?.p || runRender(render);
|
1376
1378
|
}
|
1377
1379
|
finishPendingScopes();
|
1378
1380
|
}
|
1379
|
-
var runRender = (render) => render.
|
1381
|
+
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1380
1382
|
enableCatch = () => {
|
1381
|
-
}
|
1383
|
+
};
|
1384
|
+
let handlePendingTry = (fn, scope, branch) => {
|
1385
|
+
for (; branch; ) {
|
1386
|
+
if (branch.q)
|
1387
|
+
return (branch.H ||= []).push(fn, scope);
|
1388
|
+
branch = branch.u;
|
1389
|
+
}
|
1390
|
+
};
|
1391
|
+
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1392
|
+
if (checkPending || caughtError.has(effects)) {
|
1393
|
+
let i = 0, fn, scope, branch;
|
1394
|
+
for (; i < effects.length; )
|
1395
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.p && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1396
|
+
} else
|
1397
|
+
runEffects2(effects);
|
1398
|
+
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1382
1399
|
try {
|
1383
1400
|
runRender2(render);
|
1384
1401
|
} catch (error) {
|
1385
|
-
|
1386
|
-
for (; branch && !branch.b; )
|
1387
|
-
branch = branch.n;
|
1388
|
-
if (branch)
|
1389
|
-
setConditionalRenderer(
|
1390
|
-
branch._,
|
1391
|
-
branch.a,
|
1392
|
-
branch.b,
|
1393
|
-
createAndSetupBranch
|
1394
|
-
), branch.b.k?.(
|
1395
|
-
branch._["d" /* ConditionalScope */ + branch.a],
|
1396
|
-
[error]
|
1397
|
-
);
|
1398
|
-
else
|
1399
|
-
throw error;
|
1402
|
+
renderCatch(render.D, error);
|
1400
1403
|
}
|
1401
1404
|
})(runRender);
|
1402
1405
|
};
|
1403
1406
|
|
1404
1407
|
// src/dom/abort-signal.ts
|
1405
1408
|
function resetAbortSignal(scope, id) {
|
1406
|
-
let ctrl = scope.
|
1407
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1409
|
+
let ctrl = scope.x?.[id];
|
1410
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1408
1411
|
}
|
1409
1412
|
function getAbortSignal(scope, id) {
|
1410
|
-
return scope.
|
1413
|
+
return scope.k && (scope.k.J ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1411
1414
|
}
|
1412
1415
|
function abort(ctrl) {
|
1413
1416
|
ctrl.abort();
|
@@ -1429,13 +1432,13 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1429
1432
|
register(RENDERER_REGISTER_ID, fn);
|
1430
1433
|
},
|
1431
1434
|
isRenderer(renderer) {
|
1432
|
-
return renderer.
|
1435
|
+
return renderer.B;
|
1433
1436
|
},
|
1434
1437
|
getStartNode(branch) {
|
1435
|
-
return branch.
|
1438
|
+
return branch.h;
|
1436
1439
|
},
|
1437
1440
|
setScopeNodes(branch, startNode, endNode) {
|
1438
|
-
branch.
|
1441
|
+
branch.h = startNode, branch.j = endNode;
|
1439
1442
|
},
|
1440
1443
|
runComponentEffects() {
|
1441
1444
|
runEffects(this.effects);
|
@@ -1454,9 +1457,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1454
1457
|
},
|
1455
1458
|
createRenderer(params, clone) {
|
1456
1459
|
let renderer = createRenderer(0, 0, 0, params);
|
1457
|
-
return renderer.
|
1460
|
+
return renderer.B = (branch) => {
|
1458
1461
|
let cloned = clone();
|
1459
|
-
branch.
|
1462
|
+
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1460
1463
|
}, renderer;
|
1461
1464
|
},
|
1462
1465
|
render(out, component, renderer, args) {
|
@@ -1469,14 +1472,14 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1469
1472
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1470
1473
|
}
|
1471
1474
|
if (component.effects = prepareEffects(() => {
|
1472
|
-
branch ? existing = !0 : (out.global.
|
1475
|
+
branch ? existing = !0 : (out.global.n ||= 0, branch = component.scope = createAndSetupBranch(
|
1473
1476
|
out.global,
|
1474
1477
|
renderer,
|
1475
|
-
renderer.
|
1478
|
+
renderer.y,
|
1476
1479
|
document.body
|
1477
|
-
)), renderer.
|
1480
|
+
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1478
1481
|
}), !existing)
|
1479
|
-
return toInsertNode(branch.
|
1482
|
+
return toInsertNode(branch.h, branch.j);
|
1480
1483
|
}
|
1481
1484
|
};
|
1482
1485
|
|
@@ -1494,12 +1497,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1494
1497
|
function mount(input = {}, reference, position) {
|
1495
1498
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1496
1499
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1497
|
-
|
1500
|
+
n: 0,
|
1498
1501
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1499
1502
|
renderId: DEFAULT_RENDER_ID,
|
1500
1503
|
...$global
|
1501
1504
|
}) : $global = {
|
1502
|
-
|
1505
|
+
n: 0,
|
1503
1506
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1504
1507
|
renderId: DEFAULT_RENDER_ID
|
1505
1508
|
}, position) {
|
@@ -1513,19 +1516,19 @@ function mount(input = {}, reference, position) {
|
|
1513
1516
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1514
1517
|
break;
|
1515
1518
|
}
|
1516
|
-
let args = this.
|
1519
|
+
let args = this.l, effects = prepareEffects(() => {
|
1517
1520
|
branch = createBranch(
|
1518
1521
|
$global,
|
1519
1522
|
this,
|
1520
1523
|
void 0,
|
1521
1524
|
parentNode
|
1522
|
-
), this.
|
1525
|
+
), this.C?.(branch), args?.(branch, input);
|
1523
1526
|
});
|
1524
1527
|
return insertChildNodes(
|
1525
1528
|
parentNode,
|
1526
1529
|
nextSibling,
|
1527
|
-
branch.
|
1528
|
-
branch.
|
1530
|
+
branch.h,
|
1531
|
+
branch.j
|
1529
1532
|
), runEffects(effects), {
|
1530
1533
|
update(newInput) {
|
1531
1534
|
args && runEffects(
|