marko 6.0.0-next.3.64 → 6.0.0-next.3.66
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 +1 -2
- package/dist/debug/dom.js +18 -26
- package/dist/debug/dom.mjs +18 -26
- package/dist/debug/html.js +3 -3
- package/dist/debug/html.mjs +3 -3
- package/dist/dom.js +128 -134
- package/dist/dom.mjs +128 -134
- package/dist/html.js +6 -6
- package/dist/html.mjs +6 -6
- package/dist/translator/index.js +15 -6
- package/package.json +2 -2
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,53 +712,53 @@ function toInsertNode(startNode, endNode) {
|
|
718
712
|
var pendingScopes = [];
|
719
713
|
function createScope($global, closestBranch) {
|
720
714
|
let scope = {
|
721
|
-
|
722
|
-
|
723
|
-
|
715
|
+
m: $global.n++,
|
716
|
+
o: 1,
|
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
|
-
scope.
|
727
|
+
scope.o = 0;
|
734
728
|
pendingScopes = [];
|
735
729
|
}
|
736
730
|
function findBranchWithKey(scope, key) {
|
737
|
-
let branch = scope.
|
731
|
+
let branch = scope.k;
|
738
732
|
for (; branch && !branch[key]; )
|
739
|
-
branch = branch.
|
733
|
+
branch = branch.u;
|
740
734
|
return branch;
|
741
735
|
}
|
742
736
|
function destroyBranch(branch) {
|
743
|
-
branch.
|
737
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
744
738
|
}
|
745
739
|
function destroyNestedBranches(branch) {
|
746
|
-
branch.
|
747
|
-
for (let id in scope.
|
748
|
-
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();
|
749
743
|
});
|
750
744
|
}
|
751
745
|
function removeAndDestroyBranch(branch) {
|
752
|
-
destroyBranch(branch), removeChildNodes(branch.
|
746
|
+
destroyBranch(branch), removeChildNodes(branch.h, branch.j);
|
753
747
|
}
|
754
748
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
755
749
|
insertChildNodes(
|
756
750
|
parentNode,
|
757
751
|
nextSibling,
|
758
|
-
branch.
|
759
|
-
branch.
|
752
|
+
branch.h,
|
753
|
+
branch.j
|
760
754
|
);
|
761
755
|
}
|
762
756
|
function tempDetatchBranch(branch) {
|
763
757
|
insertChildNodes(
|
764
758
|
new DocumentFragment(),
|
765
759
|
null,
|
766
|
-
branch.
|
767
|
-
branch.
|
760
|
+
branch.h,
|
761
|
+
branch.j
|
768
762
|
);
|
769
763
|
}
|
770
764
|
|
@@ -786,7 +780,7 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
786
780
|
}
|
787
781
|
if (oldStart > oldEnd) {
|
788
782
|
if (newStart <= newEnd) {
|
789
|
-
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].
|
783
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].h : afterReference;
|
790
784
|
do
|
791
785
|
insertBranchBefore(newBranches[newStart++], parent, nextSibling);
|
792
786
|
while (newStart <= newEnd);
|
@@ -815,10 +809,10 @@ function reconcile(parent, oldBranches, newBranches, afterReference) {
|
|
815
809
|
if (pos === WRONG_POS) {
|
816
810
|
let seq = longestIncreasingSubsequence(sources);
|
817
811
|
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
818
|
-
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;
|
819
813
|
} else if (synced !== newLength)
|
820
814
|
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
821
|
-
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));
|
822
816
|
}
|
823
817
|
}
|
824
818
|
}
|
@@ -865,7 +859,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
865
859
|
currentWalkIndex = walkInternal(
|
866
860
|
currentWalkIndex,
|
867
861
|
walkCodes,
|
868
|
-
scope[currentScopeIndex++] = createScope(scope.$global, scope.
|
862
|
+
scope[currentScopeIndex++] = createScope(scope.$global, scope.k)
|
869
863
|
), value2 === 48 /* BeginChildWithVar */ && (scope[currentScopeIndex++] = skipScope(scope));
|
870
864
|
else if (value2 < 92)
|
871
865
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
@@ -884,8 +878,8 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
884
878
|
|
885
879
|
// src/dom/renderer.ts
|
886
880
|
function createBranch($global, renderer, parentScope, parentNode) {
|
887
|
-
let branch = createScope($global), parentBranch = parentScope?.
|
888
|
-
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?.(
|
889
883
|
branch,
|
890
884
|
parentNode.namespaceURI
|
891
885
|
), branch;
|
@@ -897,10 +891,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
897
891
|
);
|
898
892
|
}
|
899
893
|
function setupBranch(renderer, branch) {
|
900
|
-
return (renderer.
|
894
|
+
return (renderer.C || renderer.E) && queueRender(
|
901
895
|
branch,
|
902
896
|
(branch2) => {
|
903
|
-
renderer.
|
897
|
+
renderer.C?.(branch2), renderer.E?.(branch2);
|
904
898
|
},
|
905
899
|
-1
|
906
900
|
), branch;
|
@@ -914,19 +908,19 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
914
908
|
))(branch, walks);
|
915
909
|
} : (branch) => {
|
916
910
|
walk(
|
917
|
-
branch.
|
911
|
+
branch.h = branch.j = new Text(),
|
918
912
|
walks,
|
919
913
|
branch
|
920
914
|
);
|
921
915
|
};
|
922
916
|
return (owner) => ({
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
917
|
+
m: id,
|
918
|
+
B: clone,
|
919
|
+
y: owner,
|
920
|
+
C: setup,
|
921
|
+
l: params,
|
922
|
+
E: closures,
|
923
|
+
z: dynamicScopesAccessor
|
930
924
|
});
|
931
925
|
}
|
932
926
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -951,13 +945,13 @@ function createCloneableHTML(html2, ns) {
|
|
951
945
|
let { firstChild, lastChild } = parseHTML(html2, ns), parent = document.createElementNS(ns, "t");
|
952
946
|
return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
953
947
|
walk(
|
954
|
-
branch.
|
948
|
+
branch.h = branch.j = firstChild.cloneNode(!0),
|
955
949
|
walks,
|
956
950
|
branch
|
957
951
|
);
|
958
952
|
} : (branch, walks) => {
|
959
953
|
let clone = parent.cloneNode(!0);
|
960
|
-
walk(clone.firstChild, walks, branch), branch.
|
954
|
+
walk(clone.firstChild, walks, branch), branch.h = clone.firstChild, branch.j = clone.lastChild;
|
961
955
|
};
|
962
956
|
}
|
963
957
|
|
@@ -998,9 +992,9 @@ function value(valueAccessor, fn = () => {
|
|
998
992
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
999
993
|
};
|
1000
994
|
}
|
1001
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
995
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
1002
996
|
return (scope) => {
|
1003
|
-
scope.
|
997
|
+
scope.o ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
1004
998
|
};
|
1005
999
|
}
|
1006
1000
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -1010,11 +1004,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1010
1004
|
ownerScope,
|
1011
1005
|
() => {
|
1012
1006
|
for (let scope of scopes)
|
1013
|
-
!scope.
|
1007
|
+
!scope.o && !scope.p && childSignal(scope);
|
1014
1008
|
},
|
1015
1009
|
-1,
|
1016
1010
|
0,
|
1017
|
-
firstScope.
|
1011
|
+
firstScope.m
|
1018
1012
|
);
|
1019
1013
|
};
|
1020
1014
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -1022,7 +1016,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1022
1016
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1023
1017
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
1024
1018
|
let ifScope = scope[scopeAccessor];
|
1025
|
-
ifScope && !ifScope.
|
1019
|
+
ifScope && !ifScope.o && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
1026
1020
|
};
|
1027
1021
|
return ownerSignal._ = childSignal, ownerSignal;
|
1028
1022
|
}
|
@@ -1034,13 +1028,13 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1034
1028
|
));
|
1035
1029
|
}
|
1036
1030
|
function dynamicClosure(...closureSignals) {
|
1037
|
-
let [{
|
1031
|
+
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
1038
1032
|
for (let i = closureSignals.length; i--; )
|
1039
|
-
closureSignals[i].
|
1033
|
+
closureSignals[i].K = i;
|
1040
1034
|
return (scope) => {
|
1041
1035
|
if (scope[___scopeInstancesAccessor])
|
1042
1036
|
for (let childScope of scope[___scopeInstancesAccessor])
|
1043
|
-
childScope.
|
1037
|
+
childScope.o || queueRender(
|
1044
1038
|
childScope,
|
1045
1039
|
closureSignals[childScope[___signalIndexAccessor]],
|
1046
1040
|
-1
|
@@ -1049,13 +1043,13 @@ function dynamicClosure(...closureSignals) {
|
|
1049
1043
|
}
|
1050
1044
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1051
1045
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1052
|
-
scope[closureSignal.
|
1046
|
+
scope[closureSignal.G] = closureSignal.K, childSignal(scope), subscribeToScopeSet(
|
1053
1047
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1054
|
-
closureSignal.
|
1048
|
+
closureSignal.F,
|
1055
1049
|
scope
|
1056
1050
|
);
|
1057
1051
|
};
|
1058
|
-
return closureSignal.
|
1052
|
+
return closureSignal.F = "a" /* ClosureScopes */ + valueAccessor, closureSignal.G = "b" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
1059
1053
|
}
|
1060
1054
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1061
1055
|
return (scope) => {
|
@@ -1100,8 +1094,8 @@ function awaitTag(nodeAccessor, renderer) {
|
|
1100
1094
|
let tryWithPlaceholder = findBranchWithKey(
|
1101
1095
|
scope,
|
1102
1096
|
"d" /* PlaceholderContent */
|
1103
|
-
), awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.
|
1104
|
-
if (!(scope.
|
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(
|
1105
1099
|
prepareEffects(() => {
|
1106
1100
|
tryWithPlaceholder && placeholderShown.add(pendingEffects), (!awaitBranch || !tryWithPlaceholder) && (insertBranchBefore(
|
1107
1101
|
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
@@ -1112,40 +1106,40 @@ function awaitTag(nodeAccessor, renderer) {
|
|
1112
1106
|
),
|
1113
1107
|
referenceNode.parentNode,
|
1114
1108
|
referenceNode
|
1115
|
-
), referenceNode.remove()), renderer.
|
1109
|
+
), referenceNode.remove()), renderer.l?.(awaitBranch, [data2]);
|
1116
1110
|
})
|
1117
|
-
), tryWithPlaceholder && !--tryWithPlaceholder.
|
1111
|
+
), tryWithPlaceholder && !--tryWithPlaceholder.q)) {
|
1118
1112
|
let placeholderBranch = tryWithPlaceholder.c;
|
1119
1113
|
tryWithPlaceholder.c = void 0, placeholderBranch ? (insertBranchBefore(
|
1120
1114
|
tryWithPlaceholder,
|
1121
|
-
placeholderBranch.
|
1122
|
-
placeholderBranch.
|
1115
|
+
placeholderBranch.h.parentNode,
|
1116
|
+
placeholderBranch.h
|
1123
1117
|
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1124
1118
|
tryWithPlaceholder,
|
1125
1119
|
referenceNode.parentNode,
|
1126
1120
|
referenceNode
|
1127
|
-
), tryWithPlaceholder.
|
1121
|
+
), tryWithPlaceholder.H && runEffects(tryWithPlaceholder.H, !0);
|
1128
1122
|
}
|
1129
1123
|
}).catch((error) => {
|
1130
1124
|
renderCatch(scope, error, !0);
|
1131
1125
|
});
|
1132
|
-
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.
|
1133
|
-
if (tryWithPlaceholder.
|
1126
|
+
tryWithPlaceholder ? (placeholderShown.add(pendingEffects), tryWithPlaceholder.q || (tryWithPlaceholder.q = 0, requestAnimationFrame(() => {
|
1127
|
+
if (tryWithPlaceholder.q && !tryWithPlaceholder.p) {
|
1134
1128
|
let placeholderBranch = tryWithPlaceholder.c = createAndSetupBranch(
|
1135
1129
|
scope.$global,
|
1136
1130
|
tryWithPlaceholder.d,
|
1137
1131
|
tryWithPlaceholder._,
|
1138
|
-
tryWithPlaceholder.
|
1132
|
+
tryWithPlaceholder.h.parentNode
|
1139
1133
|
);
|
1140
1134
|
insertBranchBefore(
|
1141
1135
|
placeholderBranch,
|
1142
|
-
tryWithPlaceholder.
|
1143
|
-
tryWithPlaceholder.
|
1136
|
+
tryWithPlaceholder.h.parentNode,
|
1137
|
+
tryWithPlaceholder.h
|
1144
1138
|
), tempDetatchBranch(tryWithPlaceholder);
|
1145
1139
|
}
|
1146
|
-
})), tryWithPlaceholder.
|
1140
|
+
})), tryWithPlaceholder.q++) : awaitBranch && (awaitBranch.h.parentNode.insertBefore(
|
1147
1141
|
referenceNode,
|
1148
|
-
awaitBranch.
|
1142
|
+
awaitBranch.h
|
1149
1143
|
), tempDetatchBranch(awaitBranch));
|
1150
1144
|
};
|
1151
1145
|
}
|
@@ -1173,7 +1167,7 @@ function renderCatch(scope, error, async) {
|
|
1173
1167
|
tryWithCatch.a,
|
1174
1168
|
tryWithCatch.b,
|
1175
1169
|
createAndSetupBranch
|
1176
|
-
), tryWithCatch.b.
|
1170
|
+
), tryWithCatch.b.l?.(
|
1177
1171
|
tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
|
1178
1172
|
[error]
|
1179
1173
|
);
|
@@ -1202,7 +1196,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1202
1196
|
let childScopeAccessor = "d" /* ConditionalScope */ + nodeAccessor, rendererAccessor = "c" /* ConditionalRenderer */ + nodeAccessor;
|
1203
1197
|
return (scope, newRenderer, getInput) => {
|
1204
1198
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1205
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1199
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.m || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1206
1200
|
if (setConditionalRenderer(
|
1207
1201
|
scope,
|
1208
1202
|
nodeAccessor,
|
@@ -1216,15 +1210,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1216
1210
|
0,
|
1217
1211
|
content,
|
1218
1212
|
createAndSetupBranch
|
1219
|
-
), content.
|
1220
|
-
content.x,
|
1213
|
+
), content.z && subscribeToScopeSet(
|
1221
1214
|
content.y,
|
1215
|
+
content.z,
|
1222
1216
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1223
1217
|
);
|
1224
1218
|
}
|
1225
|
-
} else normalizedRenderer?.
|
1226
|
-
normalizedRenderer.x,
|
1219
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1227
1220
|
normalizedRenderer.y,
|
1221
|
+
normalizedRenderer.z,
|
1228
1222
|
scope[childScopeAccessor]
|
1229
1223
|
);
|
1230
1224
|
if (normalizedRenderer) {
|
@@ -1235,9 +1229,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1235
1229
|
0,
|
1236
1230
|
(inputIsArgs ? args[0] : args) || {}
|
1237
1231
|
);
|
1238
|
-
else if (normalizedRenderer.
|
1232
|
+
else if (normalizedRenderer.l)
|
1239
1233
|
if (inputIsArgs)
|
1240
|
-
normalizedRenderer.
|
1234
|
+
normalizedRenderer.l(
|
1241
1235
|
scope[childScopeAccessor],
|
1242
1236
|
normalizedRenderer._ ? args[0] : args
|
1243
1237
|
);
|
@@ -1246,7 +1240,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1246
1240
|
...args,
|
1247
1241
|
content: getContent(scope)
|
1248
1242
|
} : args || {};
|
1249
|
-
normalizedRenderer.
|
1243
|
+
normalizedRenderer.l(
|
1250
1244
|
scope[childScopeAccessor],
|
1251
1245
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1252
1246
|
);
|
@@ -1255,8 +1249,8 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1255
1249
|
};
|
1256
1250
|
};
|
1257
1251
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1258
|
-
let referenceNode = scope[nodeAccessor], prevBranch = scope["d" /* ConditionalScope */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.
|
1259
|
-
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());
|
1260
1254
|
}
|
1261
1255
|
function loopOf(nodeAccessor, renderer) {
|
1262
1256
|
return loop(
|
@@ -1285,17 +1279,17 @@ function loopTo(nodeAccessor, renderer) {
|
|
1285
1279
|
);
|
1286
1280
|
}
|
1287
1281
|
function loop(nodeAccessor, renderer, forEach) {
|
1288
|
-
let params = renderer.
|
1282
|
+
let params = renderer.l;
|
1289
1283
|
return (scope, value2) => {
|
1290
1284
|
let referenceNode = scope[nodeAccessor], oldMap = scope["m" /* LoopScopeMap */ + nodeAccessor], oldArray = oldMap ? scope["l" /* LoopScopeArray */ + nodeAccessor] || [
|
1291
1285
|
...oldMap.values()
|
1292
|
-
] : [], 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] = [];
|
1293
1287
|
forEach(value2, (key, args) => {
|
1294
1288
|
let branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1295
1289
|
params?.(branch, args), newMap.set(key, branch), newArray.push(branch);
|
1296
1290
|
});
|
1297
1291
|
let afterReference = null;
|
1298
|
-
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);
|
1299
1293
|
};
|
1300
1294
|
}
|
1301
1295
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
@@ -1305,7 +1299,7 @@ function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentSco
|
|
1305
1299
|
parentScope,
|
1306
1300
|
parentNode
|
1307
1301
|
);
|
1308
|
-
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.
|
1302
|
+
return typeof tagNameOrRenderer == "string" ? branch[0] = branch.h = branch.j = document.createElementNS(
|
1309
1303
|
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
1310
1304
|
tagNameOrRenderer
|
1311
1305
|
) : setupBranch(tagNameOrRenderer, branch), branch;
|
@@ -1319,20 +1313,20 @@ function byFirstArg(name) {
|
|
1319
1313
|
|
1320
1314
|
// src/dom/queue.ts
|
1321
1315
|
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1322
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.
|
1316
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
1323
1317
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1324
1318
|
if (existingRender)
|
1325
|
-
existingRender.
|
1319
|
+
existingRender.I = value2;
|
1326
1320
|
else {
|
1327
1321
|
let render = {
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1322
|
+
t: key,
|
1323
|
+
D: scope,
|
1324
|
+
L: signal,
|
1325
|
+
I: value2
|
1332
1326
|
}, i = pendingRenders.push(render) - 1;
|
1333
1327
|
for (; i; ) {
|
1334
1328
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1335
|
-
if (key - parent.
|
1329
|
+
if (key - parent.t >= 0) break;
|
1336
1330
|
pendingRenders[i] = parent, i = parentIndex;
|
1337
1331
|
}
|
1338
1332
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1371,52 +1365,52 @@ function runRenders() {
|
|
1371
1365
|
for (; pendingRenders.length; ) {
|
1372
1366
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1373
1367
|
if (render !== item) {
|
1374
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1368
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1375
1369
|
for (; i < mid; ) {
|
1376
1370
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1377
|
-
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)
|
1378
1372
|
break;
|
1379
1373
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1380
1374
|
}
|
1381
1375
|
pendingRenders[i] = item;
|
1382
1376
|
}
|
1383
|
-
render.
|
1377
|
+
render.D.k?.p || runRender(render);
|
1384
1378
|
}
|
1385
1379
|
finishPendingScopes();
|
1386
1380
|
}
|
1387
|
-
var runRender = (render) => render.
|
1381
|
+
var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
|
1388
1382
|
enableCatch = () => {
|
1389
1383
|
};
|
1390
1384
|
let handlePendingTry = (fn, scope, branch) => {
|
1391
1385
|
for (; branch; ) {
|
1392
|
-
if (branch.
|
1393
|
-
return (branch.
|
1394
|
-
branch = branch.
|
1386
|
+
if (branch.q)
|
1387
|
+
return (branch.H ||= []).push(fn, scope);
|
1388
|
+
branch = branch.u;
|
1395
1389
|
}
|
1396
1390
|
};
|
1397
1391
|
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1398
1392
|
if (checkPending || caughtError.has(effects)) {
|
1399
1393
|
let i = 0, fn, scope, branch;
|
1400
1394
|
for (; i < effects.length; )
|
1401
|
-
fn = effects[i++], scope = effects[i++], branch = scope.
|
1395
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.p && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1402
1396
|
} else
|
1403
1397
|
runEffects2(effects);
|
1404
1398
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1405
1399
|
try {
|
1406
1400
|
runRender2(render);
|
1407
1401
|
} catch (error) {
|
1408
|
-
renderCatch(render.
|
1402
|
+
renderCatch(render.D, error);
|
1409
1403
|
}
|
1410
1404
|
})(runRender);
|
1411
1405
|
};
|
1412
1406
|
|
1413
1407
|
// src/dom/abort-signal.ts
|
1414
1408
|
function resetAbortSignal(scope, id) {
|
1415
|
-
let ctrl = scope.
|
1416
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1409
|
+
let ctrl = scope.x?.[id];
|
1410
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1417
1411
|
}
|
1418
1412
|
function getAbortSignal(scope, id) {
|
1419
|
-
return scope.
|
1413
|
+
return scope.k && (scope.k.J ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1420
1414
|
}
|
1421
1415
|
function abort(ctrl) {
|
1422
1416
|
ctrl.abort();
|
@@ -1438,13 +1432,13 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1438
1432
|
register(RENDERER_REGISTER_ID, fn);
|
1439
1433
|
},
|
1440
1434
|
isRenderer(renderer) {
|
1441
|
-
return renderer.
|
1435
|
+
return renderer.B;
|
1442
1436
|
},
|
1443
1437
|
getStartNode(branch) {
|
1444
|
-
return branch.
|
1438
|
+
return branch.h;
|
1445
1439
|
},
|
1446
1440
|
setScopeNodes(branch, startNode, endNode) {
|
1447
|
-
branch.
|
1441
|
+
branch.h = startNode, branch.j = endNode;
|
1448
1442
|
},
|
1449
1443
|
runComponentEffects() {
|
1450
1444
|
runEffects(this.effects);
|
@@ -1463,9 +1457,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1463
1457
|
},
|
1464
1458
|
createRenderer(params, clone) {
|
1465
1459
|
let renderer = createRenderer(0, 0, 0, params);
|
1466
|
-
return renderer.
|
1460
|
+
return renderer.B = (branch) => {
|
1467
1461
|
let cloned = clone();
|
1468
|
-
branch.
|
1462
|
+
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1469
1463
|
}, renderer;
|
1470
1464
|
},
|
1471
1465
|
render(out, component, renderer, args) {
|
@@ -1478,14 +1472,14 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1478
1472
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1479
1473
|
}
|
1480
1474
|
if (component.effects = prepareEffects(() => {
|
1481
|
-
branch ? existing = !0 : (out.global.
|
1475
|
+
branch ? existing = !0 : (out.global.n ||= 0, branch = component.scope = createAndSetupBranch(
|
1482
1476
|
out.global,
|
1483
1477
|
renderer,
|
1484
|
-
renderer.
|
1478
|
+
renderer.y,
|
1485
1479
|
document.body
|
1486
|
-
)), renderer.
|
1480
|
+
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1487
1481
|
}), !existing)
|
1488
|
-
return toInsertNode(branch.
|
1482
|
+
return toInsertNode(branch.h, branch.j);
|
1489
1483
|
}
|
1490
1484
|
};
|
1491
1485
|
|
@@ -1503,12 +1497,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1503
1497
|
function mount(input = {}, reference, position) {
|
1504
1498
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1505
1499
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1506
|
-
|
1500
|
+
n: 0,
|
1507
1501
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1508
1502
|
renderId: DEFAULT_RENDER_ID,
|
1509
1503
|
...$global
|
1510
1504
|
}) : $global = {
|
1511
|
-
|
1505
|
+
n: 0,
|
1512
1506
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1513
1507
|
renderId: DEFAULT_RENDER_ID
|
1514
1508
|
}, position) {
|
@@ -1522,19 +1516,19 @@ function mount(input = {}, reference, position) {
|
|
1522
1516
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1523
1517
|
break;
|
1524
1518
|
}
|
1525
|
-
let args = this.
|
1519
|
+
let args = this.l, effects = prepareEffects(() => {
|
1526
1520
|
branch = createBranch(
|
1527
1521
|
$global,
|
1528
1522
|
this,
|
1529
1523
|
void 0,
|
1530
1524
|
parentNode
|
1531
|
-
), this.
|
1525
|
+
), this.C?.(branch), args?.(branch, input);
|
1532
1526
|
});
|
1533
1527
|
return insertChildNodes(
|
1534
1528
|
parentNode,
|
1535
1529
|
nextSibling,
|
1536
|
-
branch.
|
1537
|
-
branch.
|
1530
|
+
branch.h,
|
1531
|
+
branch.j
|
1538
1532
|
), runEffects(effects), {
|
1539
1533
|
update(newInput) {
|
1540
1534
|
args && runEffects(
|