marko 6.0.0-next.3.59 → 6.0.0-next.3.60
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 +7 -1
- package/dist/debug/dom.js +291 -126
- package/dist/debug/dom.mjs +291 -126
- package/dist/debug/html.js +118 -39
- package/dist/debug/html.mjs +118 -39
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +253 -130
- package/dist/dom.mjs +253 -130
- package/dist/html/dynamic-tag.d.ts +3 -4
- package/dist/html/serializer.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -3
- package/dist/html.js +103 -35
- package/dist/html.mjs +103 -35
- package/dist/translator/core/await.d.ts +7 -0
- package/dist/translator/core/try.d.ts +7 -0
- package/dist/translator/index.js +140 -27
- package/package.json +1 -1
package/dist/dom.js
CHANGED
@@ -22,6 +22,7 @@ __export(dom_exports, {
|
|
22
22
|
attrTags: () => attrTags,
|
23
23
|
attrs: () => attrs,
|
24
24
|
attrsEvents: () => attrsEvents,
|
25
|
+
awaitTag: () => awaitTag,
|
25
26
|
classAttr: () => classAttr,
|
26
27
|
compat: () => compat,
|
27
28
|
conditional: () => conditional,
|
@@ -41,11 +42,13 @@ __export(dom_exports, {
|
|
41
42
|
createContent: () => createContent,
|
42
43
|
createRenderer: () => createRenderer,
|
43
44
|
createTemplate: () => createTemplate,
|
45
|
+
createTry: () => createTry,
|
44
46
|
data: () => data,
|
45
47
|
dynamicClosure: () => dynamicClosure,
|
46
48
|
dynamicClosureRead: () => dynamicClosureRead,
|
47
49
|
dynamicTag: () => dynamicTag,
|
48
50
|
effect: () => effect,
|
51
|
+
enableCatch: () => enableCatch,
|
49
52
|
forIn: () => forIn,
|
50
53
|
forOf: () => forOf,
|
51
54
|
forTo: () => forTo,
|
@@ -233,7 +236,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
233
236
|
commentPrefixLen + 1,
|
234
237
|
dataIndex ? dataIndex - 1 : commentText.length
|
235
238
|
), scope = scopeLookup[scopeId] ||= {
|
236
|
-
|
239
|
+
e: +scopeId
|
237
240
|
}, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
238
241
|
if (token === "*" /* Node */) {
|
239
242
|
let node = scope[data2] = visit.previousSibling;
|
@@ -275,14 +278,14 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
275
278
|
for (let scopeId in scopes)
|
276
279
|
if (scopeId !== "$") {
|
277
280
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
278
|
-
scope.$global = $global, scope.
|
281
|
+
scope.$global = $global, scope.e = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
279
282
|
scope,
|
280
283
|
prevScope
|
281
284
|
));
|
282
285
|
let parentBranchId = parentBranchIds.get(scopeId);
|
283
286
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
284
287
|
let branch = scope, parentBranch = branch.c;
|
285
|
-
scope.c = branch, parentBranch && (branch.
|
288
|
+
scope.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(
|
286
289
|
branch
|
287
290
|
));
|
288
291
|
}
|
@@ -715,8 +718,8 @@ function toInsertNode(startNode, endNode) {
|
|
715
718
|
var pendingScopes = [];
|
716
719
|
function createScope($global, closestBranch) {
|
717
720
|
let scope = {
|
718
|
-
|
719
|
-
|
721
|
+
e: $global.f++,
|
722
|
+
h: 1,
|
720
723
|
c: closestBranch,
|
721
724
|
$global
|
722
725
|
};
|
@@ -727,16 +730,16 @@ function skipScope(scope) {
|
|
727
730
|
}
|
728
731
|
function finishPendingScopes() {
|
729
732
|
for (let scope of pendingScopes)
|
730
|
-
scope.
|
733
|
+
scope.h = 0;
|
731
734
|
pendingScopes = [];
|
732
735
|
}
|
733
736
|
function destroyBranch(branch) {
|
734
|
-
branch.
|
737
|
+
branch.g?.o?.delete(branch), destroyNestedBranches(branch);
|
735
738
|
}
|
736
739
|
function destroyNestedBranches(branch) {
|
737
|
-
branch.
|
738
|
-
for (let id in scope.
|
739
|
-
scope.
|
740
|
+
branch.k = 1, branch.o?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
|
741
|
+
for (let id in scope.l)
|
742
|
+
scope.l[id]?.abort();
|
740
743
|
});
|
741
744
|
}
|
742
745
|
function removeAndDestroyBranch(branch) {
|
@@ -750,90 +753,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
750
753
|
branch.b
|
751
754
|
);
|
752
755
|
}
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
else {
|
761
|
-
let render = {
|
762
|
-
h: key,
|
763
|
-
u: scope,
|
764
|
-
B: signal,
|
765
|
-
t: value2
|
766
|
-
}, i = pendingRenders.push(render) - 1;
|
767
|
-
for (; i; ) {
|
768
|
-
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
769
|
-
if (key - parent.h >= 0) break;
|
770
|
-
pendingRenders[i] = parent, i = parentIndex;
|
771
|
-
}
|
772
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
773
|
-
}
|
774
|
-
}
|
775
|
-
function queueEffect(scope, fn) {
|
776
|
-
pendingEffects.push(fn, scope);
|
777
|
-
}
|
778
|
-
function run() {
|
779
|
-
let effects = pendingEffects;
|
780
|
-
try {
|
781
|
-
rendering = !0, runRenders();
|
782
|
-
} finally {
|
783
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
|
784
|
-
}
|
785
|
-
runEffects(effects);
|
786
|
-
}
|
787
|
-
function prepareEffects(fn) {
|
788
|
-
let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
789
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
|
790
|
-
try {
|
791
|
-
rendering = !0, fn(), runRenders();
|
792
|
-
} finally {
|
793
|
-
rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
|
794
|
-
}
|
795
|
-
return preparedEffects;
|
796
|
-
}
|
797
|
-
function runEffects(effects) {
|
798
|
-
for (let i = 0, scope; i < effects.length; )
|
799
|
-
effects[i++](
|
800
|
-
scope = effects[i++],
|
801
|
-
scope
|
802
|
-
);
|
803
|
-
}
|
804
|
-
function runRenders() {
|
805
|
-
for (; pendingRenders.length; ) {
|
806
|
-
let render = pendingRenders[0], item = pendingRenders.pop();
|
807
|
-
if (render !== item) {
|
808
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).h;
|
809
|
-
for (; i < mid; ) {
|
810
|
-
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
811
|
-
if (right < pendingRenders.length && pendingRenders[right].h - pendingRenders[bestChild].h < 0 && (bestChild = right), pendingRenders[bestChild].h - key >= 0)
|
812
|
-
break;
|
813
|
-
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
814
|
-
}
|
815
|
-
pendingRenders[i] = item;
|
816
|
-
}
|
817
|
-
render.u.c?.q || render.B(render.u, render.t);
|
818
|
-
}
|
819
|
-
finishPendingScopes();
|
820
|
-
}
|
821
|
-
|
822
|
-
// src/dom/abort-signal.ts
|
823
|
-
function resetAbortSignal(scope, id) {
|
824
|
-
let ctrl = scope.j?.[id];
|
825
|
-
ctrl && (queueEffect(ctrl, abort), scope.j[id] = void 0);
|
826
|
-
}
|
827
|
-
function getAbortSignal(scope, id) {
|
828
|
-
return scope.c && (scope.c.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.j ||= {})[id] ||= new AbortController()).signal;
|
829
|
-
}
|
830
|
-
function abort(ctrl) {
|
831
|
-
ctrl.abort();
|
756
|
+
function tempDetatchBranch(branch) {
|
757
|
+
insertChildNodes(
|
758
|
+
branch.a.ownerDocument.createDocumentFragment(),
|
759
|
+
null,
|
760
|
+
branch.a,
|
761
|
+
branch.b
|
762
|
+
);
|
832
763
|
}
|
833
764
|
|
834
|
-
// src/common/compat-meta.ts
|
835
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
836
|
-
|
837
765
|
// src/dom/reconcile.ts
|
838
766
|
var WRONG_POS = 2147483647;
|
839
767
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -951,7 +879,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
951
879
|
// src/dom/renderer.ts
|
952
880
|
function createBranch($global, renderer, parentScope, parentNode) {
|
953
881
|
let branch = createScope($global), parentBranch = parentScope?.c;
|
954
|
-
return branch._ = renderer.
|
882
|
+
return branch._ = renderer.m || parentScope, branch.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(branch)), renderer.p?.(
|
955
883
|
branch,
|
956
884
|
parentNode.namespaceURI
|
957
885
|
), branch;
|
@@ -963,10 +891,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
963
891
|
);
|
964
892
|
}
|
965
893
|
function setupBranch(renderer, branch) {
|
966
|
-
return (renderer.
|
894
|
+
return (renderer.q || renderer.u) && queueRender(
|
967
895
|
branch,
|
968
896
|
(branch2) => {
|
969
|
-
renderer.
|
897
|
+
renderer.q?.(branch2), renderer.u?.(branch2);
|
970
898
|
},
|
971
899
|
-1
|
972
900
|
), branch;
|
@@ -986,13 +914,13 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
986
914
|
);
|
987
915
|
};
|
988
916
|
return (owner) => ({
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
917
|
+
e: id,
|
918
|
+
p: clone,
|
919
|
+
m: owner,
|
920
|
+
q: setup,
|
921
|
+
d: params,
|
922
|
+
u: closures,
|
923
|
+
n: dynamicScopesAccessor
|
996
924
|
});
|
997
925
|
}
|
998
926
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -1064,9 +992,9 @@ function value(valueAccessor, fn = () => {
|
|
1064
992
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
1065
993
|
};
|
1066
994
|
}
|
1067
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
995
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "e") {
|
1068
996
|
return (scope) => {
|
1069
|
-
scope.
|
997
|
+
scope.h ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
1070
998
|
};
|
1071
999
|
}
|
1072
1000
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -1076,11 +1004,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1076
1004
|
ownerScope,
|
1077
1005
|
() => {
|
1078
1006
|
for (let scope of scopes)
|
1079
|
-
!scope.
|
1007
|
+
!scope.h && !scope.k && childSignal(scope);
|
1080
1008
|
},
|
1081
1009
|
-1,
|
1082
1010
|
0,
|
1083
|
-
firstScope.
|
1011
|
+
firstScope.e
|
1084
1012
|
);
|
1085
1013
|
};
|
1086
1014
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -1088,7 +1016,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1088
1016
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1089
1017
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, ownerSignal = (scope) => {
|
1090
1018
|
let ifScope = scope[scopeAccessor];
|
1091
|
-
ifScope && !ifScope.
|
1019
|
+
ifScope && !ifScope.h && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
1092
1020
|
};
|
1093
1021
|
return ownerSignal._ = childSignal, ownerSignal;
|
1094
1022
|
}
|
@@ -1100,13 +1028,13 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1100
1028
|
));
|
1101
1029
|
}
|
1102
1030
|
function dynamicClosure(...closureSignals) {
|
1103
|
-
let [{
|
1031
|
+
let [{ x: ___scopeInstancesAccessor, y: ___signalIndexAccessor }] = closureSignals;
|
1104
1032
|
for (let i = closureSignals.length; i--; )
|
1105
|
-
closureSignals[i].
|
1033
|
+
closureSignals[i].B = i;
|
1106
1034
|
return (scope) => {
|
1107
1035
|
if (scope[___scopeInstancesAccessor])
|
1108
1036
|
for (let childScope of scope[___scopeInstancesAccessor])
|
1109
|
-
childScope.
|
1037
|
+
childScope.h || queueRender(
|
1110
1038
|
childScope,
|
1111
1039
|
closureSignals[childScope[___signalIndexAccessor]],
|
1112
1040
|
-1
|
@@ -1115,13 +1043,13 @@ function dynamicClosure(...closureSignals) {
|
|
1115
1043
|
}
|
1116
1044
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1117
1045
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1118
|
-
scope[closureSignal.
|
1046
|
+
scope[closureSignal.y] = closureSignal.B, childSignal(scope), subscribeToScopeSet(
|
1119
1047
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1120
|
-
closureSignal.
|
1048
|
+
closureSignal.x,
|
1121
1049
|
scope
|
1122
1050
|
);
|
1123
1051
|
};
|
1124
|
-
return closureSignal.
|
1052
|
+
return closureSignal.x = valueAccessor + "!" /* ClosureScopes */, closureSignal.y = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
|
1125
1053
|
}
|
1126
1054
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1127
1055
|
return (scope) => {
|
@@ -1160,6 +1088,94 @@ function hoist(...path) {
|
|
1160
1088
|
}
|
1161
1089
|
|
1162
1090
|
// src/dom/control-flow.ts
|
1091
|
+
function awaitTag(nodeAccessor, renderer) {
|
1092
|
+
let promiseAccessor = nodeAccessor + "?" /* Promise */, branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1093
|
+
return (scope, promise) => {
|
1094
|
+
let tryBranch = scope.c, awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.a ?? referenceNode).parentNode;
|
1095
|
+
for (; tryBranch && !tryBranch["%" /* PlaceholderContent */]; )
|
1096
|
+
tryBranch = tryBranch.g;
|
1097
|
+
let thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1098
|
+
if (scope.c?.k || scope[promiseAccessor] !== thisPromise)
|
1099
|
+
return;
|
1100
|
+
scope[promiseAccessor] = void 0;
|
1101
|
+
let effects = prepareEffects(() => {
|
1102
|
+
(!awaitBranch || !tryBranch) && (insertBranchBefore(
|
1103
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1104
|
+
scope.$global,
|
1105
|
+
renderer,
|
1106
|
+
scope,
|
1107
|
+
namespaceNode
|
1108
|
+
),
|
1109
|
+
referenceNode.parentNode,
|
1110
|
+
referenceNode
|
1111
|
+
), referenceNode.remove()), renderer.d?.(awaitBranch, [data2]);
|
1112
|
+
});
|
1113
|
+
if (tryBranch) {
|
1114
|
+
if (!--tryBranch["." /* PendingCount */]) {
|
1115
|
+
let placeholderBranch = tryBranch["#" /* PlaceholderBranch */];
|
1116
|
+
placeholderBranch ? (insertBranchBefore(
|
1117
|
+
tryBranch,
|
1118
|
+
placeholderBranch.a.parentNode,
|
1119
|
+
placeholderBranch.a
|
1120
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1121
|
+
tryBranch,
|
1122
|
+
referenceNode.parentNode,
|
1123
|
+
referenceNode
|
1124
|
+
);
|
1125
|
+
}
|
1126
|
+
} else
|
1127
|
+
runEffects(effects);
|
1128
|
+
}).catch((error) => {
|
1129
|
+
let tryBranch2 = scope.c;
|
1130
|
+
for (; tryBranch2 && !tryBranch2["^" /* CatchContent */]; )
|
1131
|
+
tryBranch2 = tryBranch2.g;
|
1132
|
+
tryBranch2 ? (setConditionalRenderer(
|
1133
|
+
tryBranch2._,
|
1134
|
+
tryBranch2["*" /* BranchAccessor */],
|
1135
|
+
tryBranch2["^" /* CatchContent */],
|
1136
|
+
createAndSetupBranch
|
1137
|
+
), tryBranch2["^" /* CatchContent */].d?.(
|
1138
|
+
tryBranch2._[tryBranch2["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1139
|
+
[error]
|
1140
|
+
)) : setTimeout(() => {
|
1141
|
+
throw error;
|
1142
|
+
});
|
1143
|
+
});
|
1144
|
+
tryBranch ? (tryBranch["." /* PendingCount */] || (tryBranch["." /* PendingCount */] = 0, requestAnimationFrame(() => {
|
1145
|
+
if (tryBranch["." /* PendingCount */] && !tryBranch.k) {
|
1146
|
+
let placeholderBranch = tryBranch["#" /* PlaceholderBranch */] = createAndSetupBranch(
|
1147
|
+
scope.$global,
|
1148
|
+
tryBranch["%" /* PlaceholderContent */],
|
1149
|
+
tryBranch._,
|
1150
|
+
tryBranch.a.parentNode
|
1151
|
+
);
|
1152
|
+
insertBranchBefore(
|
1153
|
+
placeholderBranch,
|
1154
|
+
tryBranch.a.parentNode,
|
1155
|
+
tryBranch.a
|
1156
|
+
), tempDetatchBranch(tryBranch);
|
1157
|
+
}
|
1158
|
+
})), tryBranch["." /* PendingCount */]++) : awaitBranch && (awaitBranch.a.parentNode.insertBefore(
|
1159
|
+
referenceNode,
|
1160
|
+
awaitBranch.a
|
1161
|
+
), tempDetatchBranch(awaitBranch));
|
1162
|
+
};
|
1163
|
+
}
|
1164
|
+
function createTry(nodeAccessor, tryContent) {
|
1165
|
+
let branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1166
|
+
return (scope, input) => {
|
1167
|
+
scope[branchAccessor] || setConditionalRenderer(
|
1168
|
+
scope,
|
1169
|
+
nodeAccessor,
|
1170
|
+
tryContent,
|
1171
|
+
createAndSetupBranch
|
1172
|
+
);
|
1173
|
+
let branch = scope[branchAccessor];
|
1174
|
+
branch && (branch["*" /* BranchAccessor */] = nodeAccessor, branch["^" /* CatchContent */] = normalizeDynamicRenderer(input.catch), branch["%" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
1175
|
+
input.placeholder
|
1176
|
+
));
|
1177
|
+
};
|
1178
|
+
}
|
1163
1179
|
function conditional(nodeAccessor, ...branches) {
|
1164
1180
|
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1165
1181
|
return (scope, newBranch) => {
|
@@ -1178,7 +1194,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1178
1194
|
let childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1179
1195
|
return (scope, newRenderer, getInput) => {
|
1180
1196
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1181
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1197
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.e || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1182
1198
|
if (setConditionalRenderer(
|
1183
1199
|
scope,
|
1184
1200
|
nodeAccessor,
|
@@ -1192,15 +1208,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1192
1208
|
0,
|
1193
1209
|
content,
|
1194
1210
|
createAndSetupBranch
|
1195
|
-
), content.
|
1196
|
-
content.
|
1197
|
-
content.
|
1211
|
+
), content.n && subscribeToScopeSet(
|
1212
|
+
content.m,
|
1213
|
+
content.n,
|
1198
1214
|
scope[childScopeAccessor][0 + "!" /* ConditionalScope */]
|
1199
1215
|
);
|
1200
1216
|
}
|
1201
|
-
} else normalizedRenderer?.
|
1202
|
-
normalizedRenderer.
|
1203
|
-
normalizedRenderer.
|
1217
|
+
} else normalizedRenderer?.n && subscribeToScopeSet(
|
1218
|
+
normalizedRenderer.m,
|
1219
|
+
normalizedRenderer.n,
|
1204
1220
|
scope[childScopeAccessor]
|
1205
1221
|
);
|
1206
1222
|
if (normalizedRenderer) {
|
@@ -1211,9 +1227,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1211
1227
|
0,
|
1212
1228
|
(inputIsArgs ? args[0] : args) || {}
|
1213
1229
|
);
|
1214
|
-
else if (normalizedRenderer.
|
1230
|
+
else if (normalizedRenderer.d)
|
1215
1231
|
if (inputIsArgs)
|
1216
|
-
normalizedRenderer.
|
1232
|
+
normalizedRenderer.d(
|
1217
1233
|
scope[childScopeAccessor],
|
1218
1234
|
normalizedRenderer._ ? args[0] : args
|
1219
1235
|
);
|
@@ -1222,7 +1238,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1222
1238
|
...args,
|
1223
1239
|
content: getContent(scope)
|
1224
1240
|
} : args || {};
|
1225
|
-
normalizedRenderer.
|
1241
|
+
normalizedRenderer.d(
|
1226
1242
|
scope[childScopeAccessor],
|
1227
1243
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1228
1244
|
);
|
@@ -1261,7 +1277,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1261
1277
|
);
|
1262
1278
|
}
|
1263
1279
|
function loop(nodeAccessor, renderer, forEach) {
|
1264
|
-
let params = renderer.
|
1280
|
+
let params = renderer.d;
|
1265
1281
|
return (scope, value2) => {
|
1266
1282
|
let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1267
1283
|
...oldMap.values()
|
@@ -1293,6 +1309,113 @@ function byFirstArg(name) {
|
|
1293
1309
|
return name;
|
1294
1310
|
}
|
1295
1311
|
|
1312
|
+
// 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.e) {
|
1315
|
+
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1316
|
+
if (existingRender)
|
1317
|
+
existingRender.z = value2;
|
1318
|
+
else {
|
1319
|
+
let render = {
|
1320
|
+
j: key,
|
1321
|
+
t: scope,
|
1322
|
+
C: signal,
|
1323
|
+
z: value2
|
1324
|
+
}, i = pendingRenders.push(render) - 1;
|
1325
|
+
for (; i; ) {
|
1326
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1327
|
+
if (key - parent.j >= 0) break;
|
1328
|
+
pendingRenders[i] = parent, i = parentIndex;
|
1329
|
+
}
|
1330
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
1331
|
+
}
|
1332
|
+
}
|
1333
|
+
function queueEffect(scope, fn) {
|
1334
|
+
pendingEffects.push(fn, scope);
|
1335
|
+
}
|
1336
|
+
function run() {
|
1337
|
+
let effects = pendingEffects;
|
1338
|
+
try {
|
1339
|
+
rendering = !0, runRenders();
|
1340
|
+
} finally {
|
1341
|
+
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
|
1342
|
+
}
|
1343
|
+
runEffects(effects);
|
1344
|
+
}
|
1345
|
+
function prepareEffects(fn) {
|
1346
|
+
let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1347
|
+
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
|
1348
|
+
try {
|
1349
|
+
rendering = !0, fn(), runRenders();
|
1350
|
+
} finally {
|
1351
|
+
rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
|
1352
|
+
}
|
1353
|
+
return preparedEffects;
|
1354
|
+
}
|
1355
|
+
function runEffects(effects) {
|
1356
|
+
for (let i = 0, scope; i < effects.length; )
|
1357
|
+
effects[i++](
|
1358
|
+
scope = effects[i++],
|
1359
|
+
scope
|
1360
|
+
);
|
1361
|
+
}
|
1362
|
+
function runRenders() {
|
1363
|
+
for (; pendingRenders.length; ) {
|
1364
|
+
let render = pendingRenders[0], item = pendingRenders.pop();
|
1365
|
+
if (render !== item) {
|
1366
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).j;
|
1367
|
+
for (; i < mid; ) {
|
1368
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1369
|
+
if (right < pendingRenders.length && pendingRenders[right].j - pendingRenders[bestChild].j < 0 && (bestChild = right), pendingRenders[bestChild].j - key >= 0)
|
1370
|
+
break;
|
1371
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1372
|
+
}
|
1373
|
+
pendingRenders[i] = item;
|
1374
|
+
}
|
1375
|
+
render.t.c?.k || runRender(render);
|
1376
|
+
}
|
1377
|
+
finishPendingScopes();
|
1378
|
+
}
|
1379
|
+
var runRender = (render) => render.C(render.t, render.z), enableCatch = () => {
|
1380
|
+
enableCatch = () => {
|
1381
|
+
}, runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1382
|
+
try {
|
1383
|
+
runRender2(render);
|
1384
|
+
} catch (error) {
|
1385
|
+
let branch = render.t.c;
|
1386
|
+
for (; branch && !branch["^" /* CatchContent */]; )
|
1387
|
+
branch = branch.g;
|
1388
|
+
if (branch)
|
1389
|
+
setConditionalRenderer(
|
1390
|
+
branch._,
|
1391
|
+
branch["*" /* BranchAccessor */],
|
1392
|
+
branch["^" /* CatchContent */],
|
1393
|
+
createAndSetupBranch
|
1394
|
+
), branch["^" /* CatchContent */].d?.(
|
1395
|
+
branch._[branch["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1396
|
+
[error]
|
1397
|
+
);
|
1398
|
+
else
|
1399
|
+
throw error;
|
1400
|
+
}
|
1401
|
+
})(runRender);
|
1402
|
+
};
|
1403
|
+
|
1404
|
+
// src/dom/abort-signal.ts
|
1405
|
+
function resetAbortSignal(scope, id) {
|
1406
|
+
let ctrl = scope.l?.[id];
|
1407
|
+
ctrl && (queueEffect(ctrl, abort), scope.l[id] = void 0);
|
1408
|
+
}
|
1409
|
+
function getAbortSignal(scope, id) {
|
1410
|
+
return scope.c && (scope.c.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.l ||= {})[id] ||= new AbortController()).signal;
|
1411
|
+
}
|
1412
|
+
function abort(ctrl) {
|
1413
|
+
ctrl.abort();
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
// src/common/compat-meta.ts
|
1417
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1418
|
+
|
1296
1419
|
// src/dom/compat.ts
|
1297
1420
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1298
1421
|
patchDynamicTag,
|
@@ -1306,7 +1429,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1306
1429
|
register(RENDERER_REGISTER_ID, fn);
|
1307
1430
|
},
|
1308
1431
|
isRenderer(renderer) {
|
1309
|
-
return renderer.
|
1432
|
+
return renderer.p;
|
1310
1433
|
},
|
1311
1434
|
getStartNode(branch) {
|
1312
1435
|
return branch.a;
|
@@ -1331,7 +1454,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1331
1454
|
},
|
1332
1455
|
createRenderer(params, clone) {
|
1333
1456
|
let renderer = createRenderer(0, 0, 0, params);
|
1334
|
-
return renderer.
|
1457
|
+
return renderer.p = (branch) => {
|
1335
1458
|
let cloned = clone();
|
1336
1459
|
branch.a = cloned.startNode, branch.b = cloned.endNode;
|
1337
1460
|
}, renderer;
|
@@ -1349,9 +1472,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1349
1472
|
branch ? existing = !0 : (out.global.f ||= 0, branch = component.scope = createAndSetupBranch(
|
1350
1473
|
out.global,
|
1351
1474
|
renderer,
|
1352
|
-
renderer.
|
1475
|
+
renderer.m,
|
1353
1476
|
document.body
|
1354
|
-
)), renderer.
|
1477
|
+
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
1355
1478
|
}), !existing)
|
1356
1479
|
return toInsertNode(branch.a, branch.b);
|
1357
1480
|
}
|
@@ -1390,13 +1513,13 @@ function mount(input = {}, reference, position) {
|
|
1390
1513
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1391
1514
|
break;
|
1392
1515
|
}
|
1393
|
-
let args = this.
|
1516
|
+
let args = this.d, effects = prepareEffects(() => {
|
1394
1517
|
branch = createBranch(
|
1395
1518
|
$global,
|
1396
1519
|
this,
|
1397
1520
|
void 0,
|
1398
1521
|
parentNode
|
1399
|
-
), this.
|
1522
|
+
), this.q?.(branch), args?.(branch, input);
|
1400
1523
|
});
|
1401
1524
|
return insertChildNodes(
|
1402
1525
|
parentNode,
|