marko 6.0.0-next.3.58 → 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 +472 -314
- package/dist/debug/dom.mjs +472 -314
- package/dist/debug/html.js +118 -42
- package/dist/debug/html.mjs +118 -42
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +352 -226
- package/dist/dom.mjs +352 -226
- 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 +104 -36
- package/dist/html.mjs +104 -36
- 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.mjs
CHANGED
@@ -121,95 +121,114 @@ function stripSpacesAndPunctuation(str) {
|
|
121
121
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
122
122
|
|
123
123
|
// src/dom/resume.ts
|
124
|
-
var registeredValues = {}
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
this.r = [];
|
182
|
-
let len = resumes.length, i = 0;
|
183
|
-
try {
|
184
|
-
for (isResuming = !0; i < len; ) {
|
185
|
-
let resumeData = resumes[i++];
|
186
|
-
if (typeof resumeData == "function") {
|
187
|
-
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
188
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.G, $global.renderId = this.t, $global.g = 1e6);
|
189
|
-
for (let scopeId in scopes)
|
190
|
-
if (scopeId !== "$") {
|
191
|
-
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
192
|
-
scope.$global = $global, scope.d = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
193
|
-
scope,
|
194
|
-
prevScope
|
195
|
-
));
|
196
|
-
let parentBranchId = parentBranchIds.get(scopeId);
|
197
|
-
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
198
|
-
let branch = scope, parentBranch = branch.c;
|
199
|
-
scope.c = branch, parentBranch && (branch.x = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch));
|
124
|
+
var registeredValues = {};
|
125
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
126
|
+
let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
127
|
+
defineRuntime({
|
128
|
+
value: resumeRender = (renderId) => {
|
129
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, scopeStack = [], scopeLookup = render.s = {}, serializeContext = {
|
130
|
+
_: registeredValues
|
131
|
+
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), closestBranchMarkers = /* @__PURE__ */ new Map(), currentScopeId;
|
132
|
+
return render.w = () => {
|
133
|
+
walk2.call(render);
|
134
|
+
let visits = render.v, resumes = render.r;
|
135
|
+
if (visits.length) {
|
136
|
+
let visitNodes = new Set(visits), lastEndNode;
|
137
|
+
render.v = [];
|
138
|
+
let branchEnd = (branchId, visit, reference) => {
|
139
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = reference;
|
140
|
+
for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
|
141
|
+
endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
142
|
+
new Text(),
|
143
|
+
reference
|
144
|
+
)), branch.b = lastEndNode = endNode, branch.a ||= endNode;
|
145
|
+
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
146
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
147
|
+
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
148
|
+
};
|
149
|
+
for (let visit of visits) {
|
150
|
+
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
151
|
+
commentPrefixLen + 1,
|
152
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
153
|
+
), scope = scopeLookup[scopeId] ||= {
|
154
|
+
e: +scopeId
|
155
|
+
}, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
156
|
+
if (token === "*" /* Node */) {
|
157
|
+
let node = scope[data2] = visit.previousSibling;
|
158
|
+
scope[data2 + ">" /* Getter */] = () => node;
|
159
|
+
} else if (token === "$" /* ClosestBranch */)
|
160
|
+
closestBranchMarkers.set(scopeId, visit);
|
161
|
+
else if (token === "[" /* BranchStart */)
|
162
|
+
currentScopeId && (dataIndex && branchEnd(currentScopeId, visit, visit), scopeStack.push(currentScopeId)), currentScopeId = scopeId, scope.a = visit;
|
163
|
+
else if (token === "]" /* BranchEnd */) {
|
164
|
+
scope[data2] = visit;
|
165
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
166
|
+
currentScopeId,
|
167
|
+
visit,
|
168
|
+
visit
|
169
|
+
).a;
|
170
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentScopeId = scopeStack.pop();
|
171
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
172
|
+
let next = data2.indexOf(" "), curNode = visit;
|
173
|
+
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
174
|
+
let start = next + 1;
|
175
|
+
next = data2.indexOf(" ", start);
|
176
|
+
let childScopeId = data2.slice(
|
177
|
+
start,
|
178
|
+
~next ? next : data2.length
|
179
|
+
);
|
180
|
+
curNode = branchEnd(childScopeId, visit, curNode).b;
|
200
181
|
}
|
201
182
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
183
|
+
}
|
184
|
+
}
|
185
|
+
if (resumes)
|
186
|
+
try {
|
187
|
+
render.r = [], isResuming = !0;
|
188
|
+
for (let i = 0; i < resumes.length; i++) {
|
189
|
+
let serialized = resumes[i];
|
190
|
+
if (typeof serialized == "function") {
|
191
|
+
let scopes = serialized(serializeContext), { $global } = scopeLookup;
|
192
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.f = 1e6);
|
193
|
+
for (let scopeId in scopes)
|
194
|
+
if (scopeId !== "$") {
|
195
|
+
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
196
|
+
scope.$global = $global, scope.e = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
197
|
+
scope,
|
198
|
+
prevScope
|
199
|
+
));
|
200
|
+
let parentBranchId = parentBranchIds.get(scopeId);
|
201
|
+
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
202
|
+
let branch = scope, parentBranch = branch.c;
|
203
|
+
scope.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(
|
204
|
+
branch
|
205
|
+
));
|
206
|
+
}
|
207
|
+
}
|
208
|
+
} else
|
209
|
+
registeredValues[resumes[++i]](
|
210
|
+
scopeLookup[serialized],
|
211
|
+
scopeLookup[serialized]
|
212
|
+
);
|
213
|
+
}
|
214
|
+
} finally {
|
215
|
+
isResuming = !1;
|
216
|
+
}
|
217
|
+
}, render;
|
209
218
|
}
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
219
|
+
});
|
220
|
+
};
|
221
|
+
if (renders) {
|
222
|
+
initRuntime(renders);
|
223
|
+
for (let renderId in renders)
|
224
|
+
resumeRender(renderId).w();
|
225
|
+
} else
|
226
|
+
defineRuntime({
|
227
|
+
configurable: !0,
|
228
|
+
set: initRuntime
|
229
|
+
});
|
230
|
+
}
|
231
|
+
var isResuming = !1;
|
213
232
|
function register(id, obj) {
|
214
233
|
return registeredValues[id] = obj, obj;
|
215
234
|
}
|
@@ -220,22 +239,6 @@ function getRegisteredWithScope(id, scope) {
|
|
220
239
|
let val = registeredValues[id];
|
221
240
|
return scope ? val(scope) : val;
|
222
241
|
}
|
223
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
224
|
-
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
225
|
-
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
226
|
-
configurable: !0,
|
227
|
-
set: setRenders
|
228
|
-
});
|
229
|
-
function setRenders(v) {
|
230
|
-
renders = v;
|
231
|
-
for (let renderId in v)
|
232
|
-
resumeRender(renderId);
|
233
|
-
Object.defineProperty(window, runtimeId, {
|
234
|
-
configurable: !0,
|
235
|
-
value: resumeRender
|
236
|
-
});
|
237
|
-
}
|
238
|
-
}
|
239
242
|
function nodeRef(id, key) {
|
240
243
|
return register(id, (scope) => () => scope[key]());
|
241
244
|
}
|
@@ -630,7 +633,7 @@ function toInsertNode(startNode, endNode) {
|
|
630
633
|
var pendingScopes = [];
|
631
634
|
function createScope($global, closestBranch) {
|
632
635
|
let scope = {
|
633
|
-
|
636
|
+
e: $global.f++,
|
634
637
|
h: 1,
|
635
638
|
c: closestBranch,
|
636
639
|
$global
|
@@ -638,7 +641,7 @@ function createScope($global, closestBranch) {
|
|
638
641
|
return pendingScopes.push(scope), scope;
|
639
642
|
}
|
640
643
|
function skipScope(scope) {
|
641
|
-
return scope.$global.
|
644
|
+
return scope.$global.f++;
|
642
645
|
}
|
643
646
|
function finishPendingScopes() {
|
644
647
|
for (let scope of pendingScopes)
|
@@ -646,12 +649,12 @@ function finishPendingScopes() {
|
|
646
649
|
pendingScopes = [];
|
647
650
|
}
|
648
651
|
function destroyBranch(branch) {
|
649
|
-
branch.
|
652
|
+
branch.g?.o?.delete(branch), destroyNestedBranches(branch);
|
650
653
|
}
|
651
654
|
function destroyNestedBranches(branch) {
|
652
|
-
branch.
|
653
|
-
for (let id in scope.
|
654
|
-
scope.
|
655
|
+
branch.k = 1, branch.o?.forEach(destroyNestedBranches), branch.A?.forEach((scope) => {
|
656
|
+
for (let id in scope.l)
|
657
|
+
scope.l[id]?.abort();
|
655
658
|
});
|
656
659
|
}
|
657
660
|
function removeAndDestroyBranch(branch) {
|
@@ -665,90 +668,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
665
668
|
branch.b
|
666
669
|
);
|
667
670
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
else {
|
676
|
-
let render = {
|
677
|
-
j: key,
|
678
|
-
A: scope,
|
679
|
-
J: signal,
|
680
|
-
z: value2
|
681
|
-
}, i = pendingRenders.push(render) - 1;
|
682
|
-
for (; i; ) {
|
683
|
-
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
684
|
-
if (key - parent.j >= 0) break;
|
685
|
-
pendingRenders[i] = parent, i = parentIndex;
|
686
|
-
}
|
687
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
688
|
-
}
|
689
|
-
}
|
690
|
-
function queueEffect(scope, fn) {
|
691
|
-
pendingEffects.push(fn, scope);
|
692
|
-
}
|
693
|
-
function run() {
|
694
|
-
let effects = pendingEffects;
|
695
|
-
try {
|
696
|
-
rendering = !0, runRenders();
|
697
|
-
} finally {
|
698
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
|
699
|
-
}
|
700
|
-
runEffects(effects);
|
701
|
-
}
|
702
|
-
function prepareEffects(fn) {
|
703
|
-
let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
704
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
|
705
|
-
try {
|
706
|
-
rendering = !0, fn(), runRenders();
|
707
|
-
} finally {
|
708
|
-
rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
|
709
|
-
}
|
710
|
-
return preparedEffects;
|
711
|
-
}
|
712
|
-
function runEffects(effects) {
|
713
|
-
for (let i = 0, scope; i < effects.length; )
|
714
|
-
effects[i++](
|
715
|
-
scope = effects[i++],
|
716
|
-
scope
|
717
|
-
);
|
718
|
-
}
|
719
|
-
function runRenders() {
|
720
|
-
for (; pendingRenders.length; ) {
|
721
|
-
let render = pendingRenders[0], item = pendingRenders.pop();
|
722
|
-
if (render !== item) {
|
723
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).j;
|
724
|
-
for (; i < mid; ) {
|
725
|
-
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
726
|
-
if (right < pendingRenders.length && pendingRenders[right].j - pendingRenders[bestChild].j < 0 && (bestChild = right), pendingRenders[bestChild].j - key >= 0)
|
727
|
-
break;
|
728
|
-
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
729
|
-
}
|
730
|
-
pendingRenders[i] = item;
|
731
|
-
}
|
732
|
-
render.A.c?.y || render.J(render.A, render.z);
|
733
|
-
}
|
734
|
-
finishPendingScopes();
|
735
|
-
}
|
736
|
-
|
737
|
-
// src/dom/abort-signal.ts
|
738
|
-
function resetAbortSignal(scope, id) {
|
739
|
-
let ctrl = scope.k?.[id];
|
740
|
-
ctrl && (queueEffect(ctrl, abort), scope.k[id] = void 0);
|
741
|
-
}
|
742
|
-
function getAbortSignal(scope, id) {
|
743
|
-
return scope.c && (scope.c.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.k ||= {})[id] ||= new AbortController()).signal;
|
744
|
-
}
|
745
|
-
function abort(ctrl) {
|
746
|
-
ctrl.abort();
|
671
|
+
function tempDetatchBranch(branch) {
|
672
|
+
insertChildNodes(
|
673
|
+
branch.a.ownerDocument.createDocumentFragment(),
|
674
|
+
null,
|
675
|
+
branch.a,
|
676
|
+
branch.b
|
677
|
+
);
|
747
678
|
}
|
748
679
|
|
749
|
-
// src/common/compat-meta.ts
|
750
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
751
|
-
|
752
680
|
// src/dom/reconcile.ts
|
753
681
|
var WRONG_POS = 2147483647;
|
754
682
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -866,7 +794,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
866
794
|
// src/dom/renderer.ts
|
867
795
|
function createBranch($global, renderer, parentScope, parentNode) {
|
868
796
|
let branch = createScope($global), parentBranch = parentScope?.c;
|
869
|
-
return branch._ = renderer.
|
797
|
+
return branch._ = renderer.m || parentScope, branch.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(branch)), renderer.p?.(
|
870
798
|
branch,
|
871
799
|
parentNode.namespaceURI
|
872
800
|
), branch;
|
@@ -878,10 +806,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
878
806
|
);
|
879
807
|
}
|
880
808
|
function setupBranch(renderer, branch) {
|
881
|
-
return (renderer.
|
809
|
+
return (renderer.q || renderer.u) && queueRender(
|
882
810
|
branch,
|
883
811
|
(branch2) => {
|
884
|
-
renderer.
|
812
|
+
renderer.q?.(branch2), renderer.u?.(branch2);
|
885
813
|
},
|
886
814
|
-1
|
887
815
|
), branch;
|
@@ -901,13 +829,13 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
901
829
|
);
|
902
830
|
};
|
903
831
|
return (owner) => ({
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
832
|
+
e: id,
|
833
|
+
p: clone,
|
834
|
+
m: owner,
|
835
|
+
q: setup,
|
836
|
+
d: params,
|
837
|
+
u: closures,
|
838
|
+
n: dynamicScopesAccessor
|
911
839
|
});
|
912
840
|
}
|
913
841
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -979,7 +907,7 @@ function value(valueAccessor, fn = () => {
|
|
979
907
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
980
908
|
};
|
981
909
|
}
|
982
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
910
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "e") {
|
983
911
|
return (scope) => {
|
984
912
|
scope.h ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
985
913
|
};
|
@@ -991,11 +919,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
991
919
|
ownerScope,
|
992
920
|
() => {
|
993
921
|
for (let scope of scopes)
|
994
|
-
!scope.h && !scope.
|
922
|
+
!scope.h && !scope.k && childSignal(scope);
|
995
923
|
},
|
996
924
|
-1,
|
997
925
|
0,
|
998
|
-
firstScope.
|
926
|
+
firstScope.e
|
999
927
|
);
|
1000
928
|
};
|
1001
929
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -1015,9 +943,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1015
943
|
));
|
1016
944
|
}
|
1017
945
|
function dynamicClosure(...closureSignals) {
|
1018
|
-
let [{
|
946
|
+
let [{ x: ___scopeInstancesAccessor, y: ___signalIndexAccessor }] = closureSignals;
|
1019
947
|
for (let i = closureSignals.length; i--; )
|
1020
|
-
closureSignals[i].
|
948
|
+
closureSignals[i].B = i;
|
1021
949
|
return (scope) => {
|
1022
950
|
if (scope[___scopeInstancesAccessor])
|
1023
951
|
for (let childScope of scope[___scopeInstancesAccessor])
|
@@ -1030,13 +958,13 @@ function dynamicClosure(...closureSignals) {
|
|
1030
958
|
}
|
1031
959
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1032
960
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1033
|
-
scope[closureSignal.
|
961
|
+
scope[closureSignal.y] = closureSignal.B, childSignal(scope), subscribeToScopeSet(
|
1034
962
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1035
|
-
closureSignal.
|
963
|
+
closureSignal.x,
|
1036
964
|
scope
|
1037
965
|
);
|
1038
966
|
};
|
1039
|
-
return closureSignal.
|
967
|
+
return closureSignal.x = valueAccessor + "!" /* ClosureScopes */, closureSignal.y = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
|
1040
968
|
}
|
1041
969
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1042
970
|
return (scope) => {
|
@@ -1075,6 +1003,94 @@ function hoist(...path) {
|
|
1075
1003
|
}
|
1076
1004
|
|
1077
1005
|
// src/dom/control-flow.ts
|
1006
|
+
function awaitTag(nodeAccessor, renderer) {
|
1007
|
+
let promiseAccessor = nodeAccessor + "?" /* Promise */, branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1008
|
+
return (scope, promise) => {
|
1009
|
+
let tryBranch = scope.c, awaitBranch = scope[branchAccessor], referenceNode = scope[nodeAccessor], namespaceNode = (awaitBranch?.a ?? referenceNode).parentNode;
|
1010
|
+
for (; tryBranch && !tryBranch["%" /* PlaceholderContent */]; )
|
1011
|
+
tryBranch = tryBranch.g;
|
1012
|
+
let thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1013
|
+
if (scope.c?.k || scope[promiseAccessor] !== thisPromise)
|
1014
|
+
return;
|
1015
|
+
scope[promiseAccessor] = void 0;
|
1016
|
+
let effects = prepareEffects(() => {
|
1017
|
+
(!awaitBranch || !tryBranch) && (insertBranchBefore(
|
1018
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1019
|
+
scope.$global,
|
1020
|
+
renderer,
|
1021
|
+
scope,
|
1022
|
+
namespaceNode
|
1023
|
+
),
|
1024
|
+
referenceNode.parentNode,
|
1025
|
+
referenceNode
|
1026
|
+
), referenceNode.remove()), renderer.d?.(awaitBranch, [data2]);
|
1027
|
+
});
|
1028
|
+
if (tryBranch) {
|
1029
|
+
if (!--tryBranch["." /* PendingCount */]) {
|
1030
|
+
let placeholderBranch = tryBranch["#" /* PlaceholderBranch */];
|
1031
|
+
placeholderBranch ? (insertBranchBefore(
|
1032
|
+
tryBranch,
|
1033
|
+
placeholderBranch.a.parentNode,
|
1034
|
+
placeholderBranch.a
|
1035
|
+
), removeAndDestroyBranch(placeholderBranch)) : insertBranchBefore(
|
1036
|
+
tryBranch,
|
1037
|
+
referenceNode.parentNode,
|
1038
|
+
referenceNode
|
1039
|
+
);
|
1040
|
+
}
|
1041
|
+
} else
|
1042
|
+
runEffects(effects);
|
1043
|
+
}).catch((error) => {
|
1044
|
+
let tryBranch2 = scope.c;
|
1045
|
+
for (; tryBranch2 && !tryBranch2["^" /* CatchContent */]; )
|
1046
|
+
tryBranch2 = tryBranch2.g;
|
1047
|
+
tryBranch2 ? (setConditionalRenderer(
|
1048
|
+
tryBranch2._,
|
1049
|
+
tryBranch2["*" /* BranchAccessor */],
|
1050
|
+
tryBranch2["^" /* CatchContent */],
|
1051
|
+
createAndSetupBranch
|
1052
|
+
), tryBranch2["^" /* CatchContent */].d?.(
|
1053
|
+
tryBranch2._[tryBranch2["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1054
|
+
[error]
|
1055
|
+
)) : setTimeout(() => {
|
1056
|
+
throw error;
|
1057
|
+
});
|
1058
|
+
});
|
1059
|
+
tryBranch ? (tryBranch["." /* PendingCount */] || (tryBranch["." /* PendingCount */] = 0, requestAnimationFrame(() => {
|
1060
|
+
if (tryBranch["." /* PendingCount */] && !tryBranch.k) {
|
1061
|
+
let placeholderBranch = tryBranch["#" /* PlaceholderBranch */] = createAndSetupBranch(
|
1062
|
+
scope.$global,
|
1063
|
+
tryBranch["%" /* PlaceholderContent */],
|
1064
|
+
tryBranch._,
|
1065
|
+
tryBranch.a.parentNode
|
1066
|
+
);
|
1067
|
+
insertBranchBefore(
|
1068
|
+
placeholderBranch,
|
1069
|
+
tryBranch.a.parentNode,
|
1070
|
+
tryBranch.a
|
1071
|
+
), tempDetatchBranch(tryBranch);
|
1072
|
+
}
|
1073
|
+
})), tryBranch["." /* PendingCount */]++) : awaitBranch && (awaitBranch.a.parentNode.insertBefore(
|
1074
|
+
referenceNode,
|
1075
|
+
awaitBranch.a
|
1076
|
+
), tempDetatchBranch(awaitBranch));
|
1077
|
+
};
|
1078
|
+
}
|
1079
|
+
function createTry(nodeAccessor, tryContent) {
|
1080
|
+
let branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1081
|
+
return (scope, input) => {
|
1082
|
+
scope[branchAccessor] || setConditionalRenderer(
|
1083
|
+
scope,
|
1084
|
+
nodeAccessor,
|
1085
|
+
tryContent,
|
1086
|
+
createAndSetupBranch
|
1087
|
+
);
|
1088
|
+
let branch = scope[branchAccessor];
|
1089
|
+
branch && (branch["*" /* BranchAccessor */] = nodeAccessor, branch["^" /* CatchContent */] = normalizeDynamicRenderer(input.catch), branch["%" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
1090
|
+
input.placeholder
|
1091
|
+
));
|
1092
|
+
};
|
1093
|
+
}
|
1078
1094
|
function conditional(nodeAccessor, ...branches) {
|
1079
1095
|
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1080
1096
|
return (scope, newBranch) => {
|
@@ -1093,7 +1109,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1093
1109
|
let childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1094
1110
|
return (scope, newRenderer, getInput) => {
|
1095
1111
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1096
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1112
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.e || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1097
1113
|
if (setConditionalRenderer(
|
1098
1114
|
scope,
|
1099
1115
|
nodeAccessor,
|
@@ -1107,15 +1123,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1107
1123
|
0,
|
1108
1124
|
content,
|
1109
1125
|
createAndSetupBranch
|
1110
|
-
), content.
|
1111
|
-
content.l,
|
1126
|
+
), content.n && subscribeToScopeSet(
|
1112
1127
|
content.m,
|
1128
|
+
content.n,
|
1113
1129
|
scope[childScopeAccessor][0 + "!" /* ConditionalScope */]
|
1114
1130
|
);
|
1115
1131
|
}
|
1116
|
-
} else normalizedRenderer?.
|
1117
|
-
normalizedRenderer.l,
|
1132
|
+
} else normalizedRenderer?.n && subscribeToScopeSet(
|
1118
1133
|
normalizedRenderer.m,
|
1134
|
+
normalizedRenderer.n,
|
1119
1135
|
scope[childScopeAccessor]
|
1120
1136
|
);
|
1121
1137
|
if (normalizedRenderer) {
|
@@ -1126,9 +1142,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1126
1142
|
0,
|
1127
1143
|
(inputIsArgs ? args[0] : args) || {}
|
1128
1144
|
);
|
1129
|
-
else if (normalizedRenderer.
|
1145
|
+
else if (normalizedRenderer.d)
|
1130
1146
|
if (inputIsArgs)
|
1131
|
-
normalizedRenderer.
|
1147
|
+
normalizedRenderer.d(
|
1132
1148
|
scope[childScopeAccessor],
|
1133
1149
|
normalizedRenderer._ ? args[0] : args
|
1134
1150
|
);
|
@@ -1137,7 +1153,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1137
1153
|
...args,
|
1138
1154
|
content: getContent(scope)
|
1139
1155
|
} : args || {};
|
1140
|
-
normalizedRenderer.
|
1156
|
+
normalizedRenderer.d(
|
1141
1157
|
scope[childScopeAccessor],
|
1142
1158
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1143
1159
|
);
|
@@ -1176,7 +1192,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1176
1192
|
);
|
1177
1193
|
}
|
1178
1194
|
function loop(nodeAccessor, renderer, forEach) {
|
1179
|
-
let params = renderer.
|
1195
|
+
let params = renderer.d;
|
1180
1196
|
return (scope, value2) => {
|
1181
1197
|
let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1182
1198
|
...oldMap.values()
|
@@ -1208,6 +1224,113 @@ function byFirstArg(name) {
|
|
1208
1224
|
return name;
|
1209
1225
|
}
|
1210
1226
|
|
1227
|
+
// src/dom/queue.ts
|
1228
|
+
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1, scopeKeyOffset = 1e3;
|
1229
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.e) {
|
1230
|
+
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1231
|
+
if (existingRender)
|
1232
|
+
existingRender.z = value2;
|
1233
|
+
else {
|
1234
|
+
let render = {
|
1235
|
+
j: key,
|
1236
|
+
t: scope,
|
1237
|
+
C: signal,
|
1238
|
+
z: value2
|
1239
|
+
}, i = pendingRenders.push(render) - 1;
|
1240
|
+
for (; i; ) {
|
1241
|
+
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1242
|
+
if (key - parent.j >= 0) break;
|
1243
|
+
pendingRenders[i] = parent, i = parentIndex;
|
1244
|
+
}
|
1245
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
function queueEffect(scope, fn) {
|
1249
|
+
pendingEffects.push(fn, scope);
|
1250
|
+
}
|
1251
|
+
function run() {
|
1252
|
+
let effects = pendingEffects;
|
1253
|
+
try {
|
1254
|
+
rendering = !0, runRenders();
|
1255
|
+
} finally {
|
1256
|
+
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
|
1257
|
+
}
|
1258
|
+
runEffects(effects);
|
1259
|
+
}
|
1260
|
+
function prepareEffects(fn) {
|
1261
|
+
let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1262
|
+
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
|
1263
|
+
try {
|
1264
|
+
rendering = !0, fn(), runRenders();
|
1265
|
+
} finally {
|
1266
|
+
rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
|
1267
|
+
}
|
1268
|
+
return preparedEffects;
|
1269
|
+
}
|
1270
|
+
function runEffects(effects) {
|
1271
|
+
for (let i = 0, scope; i < effects.length; )
|
1272
|
+
effects[i++](
|
1273
|
+
scope = effects[i++],
|
1274
|
+
scope
|
1275
|
+
);
|
1276
|
+
}
|
1277
|
+
function runRenders() {
|
1278
|
+
for (; pendingRenders.length; ) {
|
1279
|
+
let render = pendingRenders[0], item = pendingRenders.pop();
|
1280
|
+
if (render !== item) {
|
1281
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).j;
|
1282
|
+
for (; i < mid; ) {
|
1283
|
+
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1284
|
+
if (right < pendingRenders.length && pendingRenders[right].j - pendingRenders[bestChild].j < 0 && (bestChild = right), pendingRenders[bestChild].j - key >= 0)
|
1285
|
+
break;
|
1286
|
+
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1287
|
+
}
|
1288
|
+
pendingRenders[i] = item;
|
1289
|
+
}
|
1290
|
+
render.t.c?.k || runRender(render);
|
1291
|
+
}
|
1292
|
+
finishPendingScopes();
|
1293
|
+
}
|
1294
|
+
var runRender = (render) => render.C(render.t, render.z), enableCatch = () => {
|
1295
|
+
enableCatch = () => {
|
1296
|
+
}, runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1297
|
+
try {
|
1298
|
+
runRender2(render);
|
1299
|
+
} catch (error) {
|
1300
|
+
let branch = render.t.c;
|
1301
|
+
for (; branch && !branch["^" /* CatchContent */]; )
|
1302
|
+
branch = branch.g;
|
1303
|
+
if (branch)
|
1304
|
+
setConditionalRenderer(
|
1305
|
+
branch._,
|
1306
|
+
branch["*" /* BranchAccessor */],
|
1307
|
+
branch["^" /* CatchContent */],
|
1308
|
+
createAndSetupBranch
|
1309
|
+
), branch["^" /* CatchContent */].d?.(
|
1310
|
+
branch._[branch["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1311
|
+
[error]
|
1312
|
+
);
|
1313
|
+
else
|
1314
|
+
throw error;
|
1315
|
+
}
|
1316
|
+
})(runRender);
|
1317
|
+
};
|
1318
|
+
|
1319
|
+
// src/dom/abort-signal.ts
|
1320
|
+
function resetAbortSignal(scope, id) {
|
1321
|
+
let ctrl = scope.l?.[id];
|
1322
|
+
ctrl && (queueEffect(ctrl, abort), scope.l[id] = void 0);
|
1323
|
+
}
|
1324
|
+
function getAbortSignal(scope, id) {
|
1325
|
+
return scope.c && (scope.c.A ||= /* @__PURE__ */ new Set()).add(scope), ((scope.l ||= {})[id] ||= new AbortController()).signal;
|
1326
|
+
}
|
1327
|
+
function abort(ctrl) {
|
1328
|
+
ctrl.abort();
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
// src/common/compat-meta.ts
|
1332
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
1333
|
+
|
1211
1334
|
// src/dom/compat.ts
|
1212
1335
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1213
1336
|
patchDynamicTag,
|
@@ -1221,7 +1344,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1221
1344
|
register(RENDERER_REGISTER_ID, fn);
|
1222
1345
|
},
|
1223
1346
|
isRenderer(renderer) {
|
1224
|
-
return renderer.
|
1347
|
+
return renderer.p;
|
1225
1348
|
},
|
1226
1349
|
getStartNode(branch) {
|
1227
1350
|
return branch.a;
|
@@ -1246,7 +1369,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1246
1369
|
},
|
1247
1370
|
createRenderer(params, clone) {
|
1248
1371
|
let renderer = createRenderer(0, 0, 0, params);
|
1249
|
-
return renderer.
|
1372
|
+
return renderer.p = (branch) => {
|
1250
1373
|
let cloned = clone();
|
1251
1374
|
branch.a = cloned.startNode, branch.b = cloned.endNode;
|
1252
1375
|
}, renderer;
|
@@ -1261,12 +1384,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1261
1384
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1262
1385
|
}
|
1263
1386
|
if (component.effects = prepareEffects(() => {
|
1264
|
-
branch ? existing = !0 : (out.global.
|
1387
|
+
branch ? existing = !0 : (out.global.f ||= 0, branch = component.scope = createAndSetupBranch(
|
1265
1388
|
out.global,
|
1266
1389
|
renderer,
|
1267
|
-
renderer.
|
1390
|
+
renderer.m,
|
1268
1391
|
document.body
|
1269
|
-
)), renderer.
|
1392
|
+
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
1270
1393
|
}), !existing)
|
1271
1394
|
return toInsertNode(branch.a, branch.b);
|
1272
1395
|
}
|
@@ -1286,12 +1409,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1286
1409
|
function mount(input = {}, reference, position) {
|
1287
1410
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1288
1411
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1289
|
-
|
1412
|
+
f: 0,
|
1290
1413
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1291
1414
|
renderId: DEFAULT_RENDER_ID,
|
1292
1415
|
...$global
|
1293
1416
|
}) : $global = {
|
1294
|
-
|
1417
|
+
f: 0,
|
1295
1418
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1296
1419
|
renderId: DEFAULT_RENDER_ID
|
1297
1420
|
}, position) {
|
@@ -1305,13 +1428,13 @@ function mount(input = {}, reference, position) {
|
|
1305
1428
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1306
1429
|
break;
|
1307
1430
|
}
|
1308
|
-
let args = this.
|
1431
|
+
let args = this.d, effects = prepareEffects(() => {
|
1309
1432
|
branch = createBranch(
|
1310
1433
|
$global,
|
1311
1434
|
this,
|
1312
1435
|
void 0,
|
1313
1436
|
parentNode
|
1314
|
-
), this.
|
1437
|
+
), this.q?.(branch), args?.(branch, input);
|
1315
1438
|
});
|
1316
1439
|
return insertChildNodes(
|
1317
1440
|
parentNode,
|
@@ -1337,6 +1460,7 @@ export {
|
|
1337
1460
|
attrTags,
|
1338
1461
|
attrs,
|
1339
1462
|
attrsEvents,
|
1463
|
+
awaitTag,
|
1340
1464
|
classAttr,
|
1341
1465
|
compat,
|
1342
1466
|
conditional,
|
@@ -1356,11 +1480,13 @@ export {
|
|
1356
1480
|
createContent,
|
1357
1481
|
createRenderer,
|
1358
1482
|
createTemplate,
|
1483
|
+
createTry,
|
1359
1484
|
data,
|
1360
1485
|
dynamicClosure,
|
1361
1486
|
dynamicClosureRead,
|
1362
1487
|
dynamicTag,
|
1363
1488
|
effect,
|
1489
|
+
enableCatch,
|
1364
1490
|
forIn,
|
1365
1491
|
forOf,
|
1366
1492
|
forTo,
|