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.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,
|
@@ -203,95 +206,114 @@ function stripSpacesAndPunctuation(str) {
|
|
203
206
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
204
207
|
|
205
208
|
// src/dom/resume.ts
|
206
|
-
var registeredValues = {}
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
this.r = [];
|
264
|
-
let len = resumes.length, i = 0;
|
265
|
-
try {
|
266
|
-
for (isResuming = !0; i < len; ) {
|
267
|
-
let resumeData = resumes[i++];
|
268
|
-
if (typeof resumeData == "function") {
|
269
|
-
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
270
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.G, $global.renderId = this.t, $global.g = 1e6);
|
271
|
-
for (let scopeId in scopes)
|
272
|
-
if (scopeId !== "$") {
|
273
|
-
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
274
|
-
scope.$global = $global, scope.d = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
275
|
-
scope,
|
276
|
-
prevScope
|
277
|
-
));
|
278
|
-
let parentBranchId = parentBranchIds.get(scopeId);
|
279
|
-
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
280
|
-
let branch = scope, parentBranch = branch.c;
|
281
|
-
scope.c = branch, parentBranch && (branch.x = parentBranch, (parentBranch.n ||= /* @__PURE__ */ new Set()).add(branch));
|
209
|
+
var registeredValues = {};
|
210
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
211
|
+
let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
212
|
+
defineRuntime({
|
213
|
+
value: resumeRender = (renderId) => {
|
214
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, scopeStack = [], scopeLookup = render.s = {}, serializeContext = {
|
215
|
+
_: registeredValues
|
216
|
+
}, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), closestBranchMarkers = /* @__PURE__ */ new Map(), currentScopeId;
|
217
|
+
return render.w = () => {
|
218
|
+
walk2.call(render);
|
219
|
+
let visits = render.v, resumes = render.r;
|
220
|
+
if (visits.length) {
|
221
|
+
let visitNodes = new Set(visits), lastEndNode;
|
222
|
+
render.v = [];
|
223
|
+
let branchEnd = (branchId, visit, reference) => {
|
224
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = reference;
|
225
|
+
for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
|
226
|
+
endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
|
227
|
+
new Text(),
|
228
|
+
reference
|
229
|
+
)), branch.b = lastEndNode = endNode, branch.a ||= endNode;
|
230
|
+
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
231
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
232
|
+
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
233
|
+
};
|
234
|
+
for (let visit of visits) {
|
235
|
+
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
236
|
+
commentPrefixLen + 1,
|
237
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
238
|
+
), scope = scopeLookup[scopeId] ||= {
|
239
|
+
e: +scopeId
|
240
|
+
}, data2 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
241
|
+
if (token === "*" /* Node */) {
|
242
|
+
let node = scope[data2] = visit.previousSibling;
|
243
|
+
scope[data2 + ">" /* Getter */] = () => node;
|
244
|
+
} else if (token === "$" /* ClosestBranch */)
|
245
|
+
closestBranchMarkers.set(scopeId, visit);
|
246
|
+
else if (token === "[" /* BranchStart */)
|
247
|
+
currentScopeId && (dataIndex && branchEnd(currentScopeId, visit, visit), scopeStack.push(currentScopeId)), currentScopeId = scopeId, scope.a = visit;
|
248
|
+
else if (token === "]" /* BranchEnd */) {
|
249
|
+
scope[data2] = visit;
|
250
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
251
|
+
currentScopeId,
|
252
|
+
visit,
|
253
|
+
visit
|
254
|
+
).a;
|
255
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), currentScopeId = scopeStack.pop();
|
256
|
+
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
257
|
+
let next = data2.indexOf(" "), curNode = visit;
|
258
|
+
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
259
|
+
let start = next + 1;
|
260
|
+
next = data2.indexOf(" ", start);
|
261
|
+
let childScopeId = data2.slice(
|
262
|
+
start,
|
263
|
+
~next ? next : data2.length
|
264
|
+
);
|
265
|
+
curNode = branchEnd(childScopeId, visit, curNode).b;
|
282
266
|
}
|
283
267
|
}
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
268
|
+
}
|
269
|
+
}
|
270
|
+
if (resumes)
|
271
|
+
try {
|
272
|
+
render.r = [], isResuming = !0;
|
273
|
+
for (let i = 0; i < resumes.length; i++) {
|
274
|
+
let serialized = resumes[i];
|
275
|
+
if (typeof serialized == "function") {
|
276
|
+
let scopes = serialized(serializeContext), { $global } = scopeLookup;
|
277
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.f = 1e6);
|
278
|
+
for (let scopeId in scopes)
|
279
|
+
if (scopeId !== "$") {
|
280
|
+
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
281
|
+
scope.$global = $global, scope.e = +scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
282
|
+
scope,
|
283
|
+
prevScope
|
284
|
+
));
|
285
|
+
let parentBranchId = parentBranchIds.get(scopeId);
|
286
|
+
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
287
|
+
let branch = scope, parentBranch = branch.c;
|
288
|
+
scope.c = branch, parentBranch && (branch.g = parentBranch, (parentBranch.o ||= /* @__PURE__ */ new Set()).add(
|
289
|
+
branch
|
290
|
+
));
|
291
|
+
}
|
292
|
+
}
|
293
|
+
} else
|
294
|
+
registeredValues[resumes[++i]](
|
295
|
+
scopeLookup[serialized],
|
296
|
+
scopeLookup[serialized]
|
297
|
+
);
|
298
|
+
}
|
299
|
+
} finally {
|
300
|
+
isResuming = !1;
|
301
|
+
}
|
302
|
+
}, render;
|
291
303
|
}
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
304
|
+
});
|
305
|
+
};
|
306
|
+
if (renders) {
|
307
|
+
initRuntime(renders);
|
308
|
+
for (let renderId in renders)
|
309
|
+
resumeRender(renderId).w();
|
310
|
+
} else
|
311
|
+
defineRuntime({
|
312
|
+
configurable: !0,
|
313
|
+
set: initRuntime
|
314
|
+
});
|
315
|
+
}
|
316
|
+
var isResuming = !1;
|
295
317
|
function register(id, obj) {
|
296
318
|
return registeredValues[id] = obj, obj;
|
297
319
|
}
|
@@ -302,22 +324,6 @@ function getRegisteredWithScope(id, scope) {
|
|
302
324
|
let val = registeredValues[id];
|
303
325
|
return scope ? val(scope) : val;
|
304
326
|
}
|
305
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
306
|
-
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
307
|
-
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
308
|
-
configurable: !0,
|
309
|
-
set: setRenders
|
310
|
-
});
|
311
|
-
function setRenders(v) {
|
312
|
-
renders = v;
|
313
|
-
for (let renderId in v)
|
314
|
-
resumeRender(renderId);
|
315
|
-
Object.defineProperty(window, runtimeId, {
|
316
|
-
configurable: !0,
|
317
|
-
value: resumeRender
|
318
|
-
});
|
319
|
-
}
|
320
|
-
}
|
321
327
|
function nodeRef(id, key) {
|
322
328
|
return register(id, (scope) => () => scope[key]());
|
323
329
|
}
|
@@ -712,7 +718,7 @@ function toInsertNode(startNode, endNode) {
|
|
712
718
|
var pendingScopes = [];
|
713
719
|
function createScope($global, closestBranch) {
|
714
720
|
let scope = {
|
715
|
-
|
721
|
+
e: $global.f++,
|
716
722
|
h: 1,
|
717
723
|
c: closestBranch,
|
718
724
|
$global
|
@@ -720,7 +726,7 @@ function createScope($global, closestBranch) {
|
|
720
726
|
return pendingScopes.push(scope), scope;
|
721
727
|
}
|
722
728
|
function skipScope(scope) {
|
723
|
-
return scope.$global.
|
729
|
+
return scope.$global.f++;
|
724
730
|
}
|
725
731
|
function finishPendingScopes() {
|
726
732
|
for (let scope of pendingScopes)
|
@@ -728,12 +734,12 @@ function finishPendingScopes() {
|
|
728
734
|
pendingScopes = [];
|
729
735
|
}
|
730
736
|
function destroyBranch(branch) {
|
731
|
-
branch.
|
737
|
+
branch.g?.o?.delete(branch), destroyNestedBranches(branch);
|
732
738
|
}
|
733
739
|
function destroyNestedBranches(branch) {
|
734
|
-
branch.
|
735
|
-
for (let id in scope.
|
736
|
-
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();
|
737
743
|
});
|
738
744
|
}
|
739
745
|
function removeAndDestroyBranch(branch) {
|
@@ -747,90 +753,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
747
753
|
branch.b
|
748
754
|
);
|
749
755
|
}
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
else {
|
758
|
-
let render = {
|
759
|
-
j: key,
|
760
|
-
A: scope,
|
761
|
-
J: signal,
|
762
|
-
z: value2
|
763
|
-
}, i = pendingRenders.push(render) - 1;
|
764
|
-
for (; i; ) {
|
765
|
-
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
766
|
-
if (key - parent.j >= 0) break;
|
767
|
-
pendingRenders[i] = parent, i = parentIndex;
|
768
|
-
}
|
769
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
770
|
-
}
|
771
|
-
}
|
772
|
-
function queueEffect(scope, fn) {
|
773
|
-
pendingEffects.push(fn, scope);
|
774
|
-
}
|
775
|
-
function run() {
|
776
|
-
let effects = pendingEffects;
|
777
|
-
try {
|
778
|
-
rendering = !0, runRenders();
|
779
|
-
} finally {
|
780
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), pendingEffects = [], rendering = !1;
|
781
|
-
}
|
782
|
-
runEffects(effects);
|
783
|
-
}
|
784
|
-
function prepareEffects(fn) {
|
785
|
-
let prevRenders = pendingRenders, prevRendersLookup = pendingRendersLookup, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
786
|
-
pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map();
|
787
|
-
try {
|
788
|
-
rendering = !0, fn(), runRenders();
|
789
|
-
} finally {
|
790
|
-
rendering = !1, pendingRenders = prevRenders, pendingRendersLookup = prevRendersLookup, pendingEffects = prevEffects;
|
791
|
-
}
|
792
|
-
return preparedEffects;
|
793
|
-
}
|
794
|
-
function runEffects(effects) {
|
795
|
-
for (let i = 0, scope; i < effects.length; )
|
796
|
-
effects[i++](
|
797
|
-
scope = effects[i++],
|
798
|
-
scope
|
799
|
-
);
|
800
|
-
}
|
801
|
-
function runRenders() {
|
802
|
-
for (; pendingRenders.length; ) {
|
803
|
-
let render = pendingRenders[0], item = pendingRenders.pop();
|
804
|
-
if (render !== item) {
|
805
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).j;
|
806
|
-
for (; i < mid; ) {
|
807
|
-
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
808
|
-
if (right < pendingRenders.length && pendingRenders[right].j - pendingRenders[bestChild].j < 0 && (bestChild = right), pendingRenders[bestChild].j - key >= 0)
|
809
|
-
break;
|
810
|
-
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
811
|
-
}
|
812
|
-
pendingRenders[i] = item;
|
813
|
-
}
|
814
|
-
render.A.c?.y || render.J(render.A, render.z);
|
815
|
-
}
|
816
|
-
finishPendingScopes();
|
817
|
-
}
|
818
|
-
|
819
|
-
// src/dom/abort-signal.ts
|
820
|
-
function resetAbortSignal(scope, id) {
|
821
|
-
let ctrl = scope.k?.[id];
|
822
|
-
ctrl && (queueEffect(ctrl, abort), scope.k[id] = void 0);
|
823
|
-
}
|
824
|
-
function getAbortSignal(scope, id) {
|
825
|
-
return scope.c && (scope.c.I ||= /* @__PURE__ */ new Set()).add(scope), ((scope.k ||= {})[id] ||= new AbortController()).signal;
|
826
|
-
}
|
827
|
-
function abort(ctrl) {
|
828
|
-
ctrl.abort();
|
756
|
+
function tempDetatchBranch(branch) {
|
757
|
+
insertChildNodes(
|
758
|
+
branch.a.ownerDocument.createDocumentFragment(),
|
759
|
+
null,
|
760
|
+
branch.a,
|
761
|
+
branch.b
|
762
|
+
);
|
829
763
|
}
|
830
764
|
|
831
|
-
// src/common/compat-meta.ts
|
832
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s", RENDER_BODY_ID = prefix + "b";
|
833
|
-
|
834
765
|
// src/dom/reconcile.ts
|
835
766
|
var WRONG_POS = 2147483647;
|
836
767
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -948,7 +879,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
948
879
|
// src/dom/renderer.ts
|
949
880
|
function createBranch($global, renderer, parentScope, parentNode) {
|
950
881
|
let branch = createScope($global), parentBranch = parentScope?.c;
|
951
|
-
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?.(
|
952
883
|
branch,
|
953
884
|
parentNode.namespaceURI
|
954
885
|
), branch;
|
@@ -960,10 +891,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
960
891
|
);
|
961
892
|
}
|
962
893
|
function setupBranch(renderer, branch) {
|
963
|
-
return (renderer.
|
894
|
+
return (renderer.q || renderer.u) && queueRender(
|
964
895
|
branch,
|
965
896
|
(branch2) => {
|
966
|
-
renderer.
|
897
|
+
renderer.q?.(branch2), renderer.u?.(branch2);
|
967
898
|
},
|
968
899
|
-1
|
969
900
|
), branch;
|
@@ -983,13 +914,13 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
983
914
|
);
|
984
915
|
};
|
985
916
|
return (owner) => ({
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
917
|
+
e: id,
|
918
|
+
p: clone,
|
919
|
+
m: owner,
|
920
|
+
q: setup,
|
921
|
+
d: params,
|
922
|
+
u: closures,
|
923
|
+
n: dynamicScopesAccessor
|
993
924
|
});
|
994
925
|
}
|
995
926
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -1061,7 +992,7 @@ function value(valueAccessor, fn = () => {
|
|
1061
992
|
(!(valueAccessor in scope) || scope[valueAccessor] !== value2) && (scope[valueAccessor] = value2, fn(scope, value2));
|
1062
993
|
};
|
1063
994
|
}
|
1064
|
-
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "
|
995
|
+
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "e") {
|
1065
996
|
return (scope) => {
|
1066
997
|
scope.h ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
1067
998
|
};
|
@@ -1073,11 +1004,11 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1073
1004
|
ownerScope,
|
1074
1005
|
() => {
|
1075
1006
|
for (let scope of scopes)
|
1076
|
-
!scope.h && !scope.
|
1007
|
+
!scope.h && !scope.k && childSignal(scope);
|
1077
1008
|
},
|
1078
1009
|
-1,
|
1079
1010
|
0,
|
1080
|
-
firstScope.
|
1011
|
+
firstScope.e
|
1081
1012
|
);
|
1082
1013
|
};
|
1083
1014
|
return ownerSignal._ = childSignal, ownerSignal;
|
@@ -1097,9 +1028,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1097
1028
|
));
|
1098
1029
|
}
|
1099
1030
|
function dynamicClosure(...closureSignals) {
|
1100
|
-
let [{
|
1031
|
+
let [{ x: ___scopeInstancesAccessor, y: ___signalIndexAccessor }] = closureSignals;
|
1101
1032
|
for (let i = closureSignals.length; i--; )
|
1102
|
-
closureSignals[i].
|
1033
|
+
closureSignals[i].B = i;
|
1103
1034
|
return (scope) => {
|
1104
1035
|
if (scope[___scopeInstancesAccessor])
|
1105
1036
|
for (let childScope of scope[___scopeInstancesAccessor])
|
@@ -1112,13 +1043,13 @@ function dynamicClosure(...closureSignals) {
|
|
1112
1043
|
}
|
1113
1044
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1114
1045
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1115
|
-
scope[closureSignal.
|
1046
|
+
scope[closureSignal.y] = closureSignal.B, childSignal(scope), subscribeToScopeSet(
|
1116
1047
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1117
|
-
closureSignal.
|
1048
|
+
closureSignal.x,
|
1118
1049
|
scope
|
1119
1050
|
);
|
1120
1051
|
};
|
1121
|
-
return closureSignal.
|
1052
|
+
return closureSignal.x = valueAccessor + "!" /* ClosureScopes */, closureSignal.y = valueAccessor + "(" /* ClosureSignalIndex */, closureSignal;
|
1122
1053
|
}
|
1123
1054
|
function closure(valueAccessor, fn, getOwnerScope) {
|
1124
1055
|
return (scope) => {
|
@@ -1157,6 +1088,94 @@ function hoist(...path) {
|
|
1157
1088
|
}
|
1158
1089
|
|
1159
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
|
+
}
|
1160
1179
|
function conditional(nodeAccessor, ...branches) {
|
1161
1180
|
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1162
1181
|
return (scope, newBranch) => {
|
@@ -1175,7 +1194,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1175
1194
|
let childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1176
1195
|
return (scope, newRenderer, getInput) => {
|
1177
1196
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1178
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
1197
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.e || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
1179
1198
|
if (setConditionalRenderer(
|
1180
1199
|
scope,
|
1181
1200
|
nodeAccessor,
|
@@ -1189,15 +1208,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1189
1208
|
0,
|
1190
1209
|
content,
|
1191
1210
|
createAndSetupBranch
|
1192
|
-
), content.
|
1193
|
-
content.l,
|
1211
|
+
), content.n && subscribeToScopeSet(
|
1194
1212
|
content.m,
|
1213
|
+
content.n,
|
1195
1214
|
scope[childScopeAccessor][0 + "!" /* ConditionalScope */]
|
1196
1215
|
);
|
1197
1216
|
}
|
1198
|
-
} else normalizedRenderer?.
|
1199
|
-
normalizedRenderer.l,
|
1217
|
+
} else normalizedRenderer?.n && subscribeToScopeSet(
|
1200
1218
|
normalizedRenderer.m,
|
1219
|
+
normalizedRenderer.n,
|
1201
1220
|
scope[childScopeAccessor]
|
1202
1221
|
);
|
1203
1222
|
if (normalizedRenderer) {
|
@@ -1208,9 +1227,9 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1208
1227
|
0,
|
1209
1228
|
(inputIsArgs ? args[0] : args) || {}
|
1210
1229
|
);
|
1211
|
-
else if (normalizedRenderer.
|
1230
|
+
else if (normalizedRenderer.d)
|
1212
1231
|
if (inputIsArgs)
|
1213
|
-
normalizedRenderer.
|
1232
|
+
normalizedRenderer.d(
|
1214
1233
|
scope[childScopeAccessor],
|
1215
1234
|
normalizedRenderer._ ? args[0] : args
|
1216
1235
|
);
|
@@ -1219,7 +1238,7 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1219
1238
|
...args,
|
1220
1239
|
content: getContent(scope)
|
1221
1240
|
} : args || {};
|
1222
|
-
normalizedRenderer.
|
1241
|
+
normalizedRenderer.d(
|
1223
1242
|
scope[childScopeAccessor],
|
1224
1243
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
1225
1244
|
);
|
@@ -1258,7 +1277,7 @@ function loopTo(nodeAccessor, renderer) {
|
|
1258
1277
|
);
|
1259
1278
|
}
|
1260
1279
|
function loop(nodeAccessor, renderer, forEach) {
|
1261
|
-
let params = renderer.
|
1280
|
+
let params = renderer.d;
|
1262
1281
|
return (scope, value2) => {
|
1263
1282
|
let referenceNode = scope[nodeAccessor], oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */], oldArray = oldMap ? scope[nodeAccessor + "!" /* LoopScopeArray */] || [
|
1264
1283
|
...oldMap.values()
|
@@ -1290,6 +1309,113 @@ function byFirstArg(name) {
|
|
1290
1309
|
return name;
|
1291
1310
|
}
|
1292
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
|
+
|
1293
1419
|
// src/dom/compat.ts
|
1294
1420
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1295
1421
|
patchDynamicTag,
|
@@ -1303,7 +1429,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1303
1429
|
register(RENDERER_REGISTER_ID, fn);
|
1304
1430
|
},
|
1305
1431
|
isRenderer(renderer) {
|
1306
|
-
return renderer.
|
1432
|
+
return renderer.p;
|
1307
1433
|
},
|
1308
1434
|
getStartNode(branch) {
|
1309
1435
|
return branch.a;
|
@@ -1328,7 +1454,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1328
1454
|
},
|
1329
1455
|
createRenderer(params, clone) {
|
1330
1456
|
let renderer = createRenderer(0, 0, 0, params);
|
1331
|
-
return renderer.
|
1457
|
+
return renderer.p = (branch) => {
|
1332
1458
|
let cloned = clone();
|
1333
1459
|
branch.a = cloned.startNode, branch.b = cloned.endNode;
|
1334
1460
|
}, renderer;
|
@@ -1343,12 +1469,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1343
1469
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1344
1470
|
}
|
1345
1471
|
if (component.effects = prepareEffects(() => {
|
1346
|
-
branch ? existing = !0 : (out.global.
|
1472
|
+
branch ? existing = !0 : (out.global.f ||= 0, branch = component.scope = createAndSetupBranch(
|
1347
1473
|
out.global,
|
1348
1474
|
renderer,
|
1349
|
-
renderer.
|
1475
|
+
renderer.m,
|
1350
1476
|
document.body
|
1351
|
-
)), renderer.
|
1477
|
+
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
1352
1478
|
}), !existing)
|
1353
1479
|
return toInsertNode(branch.a, branch.b);
|
1354
1480
|
}
|
@@ -1368,12 +1494,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1368
1494
|
function mount(input = {}, reference, position) {
|
1369
1495
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1370
1496
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1371
|
-
|
1497
|
+
f: 0,
|
1372
1498
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1373
1499
|
renderId: DEFAULT_RENDER_ID,
|
1374
1500
|
...$global
|
1375
1501
|
}) : $global = {
|
1376
|
-
|
1502
|
+
f: 0,
|
1377
1503
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1378
1504
|
renderId: DEFAULT_RENDER_ID
|
1379
1505
|
}, position) {
|
@@ -1387,13 +1513,13 @@ function mount(input = {}, reference, position) {
|
|
1387
1513
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
1388
1514
|
break;
|
1389
1515
|
}
|
1390
|
-
let args = this.
|
1516
|
+
let args = this.d, effects = prepareEffects(() => {
|
1391
1517
|
branch = createBranch(
|
1392
1518
|
$global,
|
1393
1519
|
this,
|
1394
1520
|
void 0,
|
1395
1521
|
parentNode
|
1396
|
-
), this.
|
1522
|
+
), this.q?.(branch), args?.(branch, input);
|
1397
1523
|
});
|
1398
1524
|
return insertChildNodes(
|
1399
1525
|
parentNode,
|