marko 6.1.3 → 6.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/accessor.d.ts +5 -0
- package/dist/common/accessor.debug.d.ts +5 -0
- package/dist/common/compat-meta.d.ts +0 -1
- package/dist/common/opt.d.ts +3 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/debug/dom.js +283 -111
- package/dist/debug/dom.mjs +275 -112
- package/dist/debug/html.js +846 -576
- package/dist/debug/html.mjs +844 -577
- package/dist/dom/compat.d.ts +3 -2
- package/dist/dom/control-flow.d.ts +2 -1
- package/dist/dom/load.d.ts +23 -0
- package/dist/dom/queue.d.ts +3 -2
- package/dist/dom/resume.d.ts +10 -8
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +178 -58
- package/dist/dom.mjs +178 -58
- package/dist/html/assets.d.ts +47 -0
- package/dist/html/compat.d.ts +3 -2
- package/dist/html/serializer.d.ts +14 -9
- package/dist/html/writer.d.ts +34 -15
- package/dist/html.d.ts +1 -0
- package/dist/html.js +439 -268
- package/dist/html.mjs +439 -268
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +286 -38
- package/dist/translator/interop/index.d.ts +1 -0
- package/dist/translator/util/marko-config.d.ts +2 -0
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/tag-name-type.d.ts +2 -0
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/visitors/import-declaration.d.ts +10 -1
- package/dist/translator/visitors/tag/custom-tag.d.ts +7 -0
- package/package.json +2 -2
package/dist/dom.mjs
CHANGED
|
@@ -20,10 +20,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
20
20
|
for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
|
|
21
21
|
walker.nextSibling();
|
|
22
22
|
} else storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
23
|
-
}, cloneCache = {}, registeredValues = {},
|
|
24
|
-
let cb = readyLookup[id];
|
|
25
|
-
readyLookup[id] = 1, cb?.();
|
|
26
|
-
})(readyLookup = {}), isResuming, inputType = "", controllableDelegate = /* @__PURE__ */ createDelegator(), _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
23
|
+
}, cloneCache = {}, registeredValues = {}, curRenders, branchesEnabled, embedRenders, readyIds, isResuming, inputType = "", controllableDelegate = /* @__PURE__ */ createDelegator(), _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
27
24
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
28
25
|
let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
|
|
29
26
|
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
@@ -54,16 +51,22 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
54
51
|
typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
55
52
|
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), pendingRenders = [], pendingRendersLookup = {}, asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, runEffects = ((effects) => {
|
|
56
53
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
57
|
-
}), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(),
|
|
54
|
+
}), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
|
|
55
|
+
let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
|
|
56
|
+
return render && !scopes && scopesByRender.set(render, scopes = {}), scopes;
|
|
57
|
+
}, compat = {
|
|
58
58
|
patchDynamicTag,
|
|
59
59
|
queueEffect,
|
|
60
60
|
init(warp10Noop) {
|
|
61
|
-
_resume("$C_s", (
|
|
62
|
-
classIdToBranch.set(
|
|
61
|
+
_resume("$C_s", (scope) => {
|
|
62
|
+
getRenderScopes(scope.$)[scope.L] = scope, scope.m5c && classIdToBranch.set(scope.m5c, scope);
|
|
63
63
|
}), _resume("$C_b", warp10Noop);
|
|
64
64
|
},
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
getScope($global, scopeId) {
|
|
66
|
+
return getRenderScopes($global)?.[scopeId];
|
|
67
|
+
},
|
|
68
|
+
setRendererId(renderer, id) {
|
|
69
|
+
renderer.a = id;
|
|
67
70
|
},
|
|
68
71
|
isRenderer(renderer) {
|
|
69
72
|
return renderer.b;
|
|
@@ -81,7 +84,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
81
84
|
this.scope && destroyBranch(this.scope);
|
|
82
85
|
},
|
|
83
86
|
resolveRegistered(value, $global) {
|
|
84
|
-
return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(value[0],
|
|
87
|
+
return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(value[0], getRenderScopes($global)?.[value[1]]) : value;
|
|
85
88
|
},
|
|
86
89
|
createRenderer(params, clone) {
|
|
87
90
|
let renderer = _content("", 0, 0, 0, params)();
|
|
@@ -411,27 +414,35 @@ function createCloneableHTML(html, ns) {
|
|
|
411
414
|
function enableBranches() {
|
|
412
415
|
branchesEnabled || (branchesEnabled = 1, skipDestroyedRenders());
|
|
413
416
|
}
|
|
417
|
+
function ready(readyId, runtimeId) {
|
|
418
|
+
(readyIds ||= /* @__PURE__ */ new Set()).add(readyId), init(runtimeId);
|
|
419
|
+
for (let renderId in curRenders) runResumeEffects(curRenders[renderId]);
|
|
420
|
+
}
|
|
414
421
|
function initEmbedded(readyId, runtimeId) {
|
|
415
|
-
|
|
416
|
-
let
|
|
417
|
-
|
|
418
|
-
let
|
|
419
|
-
if (n && !n.isConnected) {
|
|
420
|
-
delete renders[renderId];
|
|
421
|
-
for (let id in s) destroyScope(s[id]);
|
|
422
|
-
}
|
|
422
|
+
embedRenders || (embedRenders = /* @__PURE__ */ new Map(), new MutationObserver(() => {
|
|
423
|
+
for (let [anchor, [renderId, scopes]] of embedRenders) if (!anchor.isConnected) {
|
|
424
|
+
embedRenders.delete(anchor), delete curRenders[renderId];
|
|
425
|
+
for (let id in scopes) destroyScope(scopes[id]);
|
|
423
426
|
}
|
|
424
|
-
}).observe(document
|
|
427
|
+
}).observe(document, {
|
|
425
428
|
childList: !0,
|
|
426
429
|
subtree: !0
|
|
427
|
-
});
|
|
430
|
+
})), ready(readyId, runtimeId);
|
|
428
431
|
}
|
|
429
432
|
function init(runtimeId = "M") {
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
if (curRenders) return;
|
|
434
|
+
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders) => {
|
|
435
|
+
defineRuntime({ value: curRenders = ((renderId) => {
|
|
436
|
+
let render = curRenders[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = {}, getScope = (id) => scopeLookup[id] || initScope(scopeLookup[id] = { L: +id }), initGlobal = () => $global ||= {
|
|
437
|
+
runtimeId,
|
|
438
|
+
renderId
|
|
439
|
+
}, initScope = (scope) => (scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
|
|
440
|
+
let scopeId = partials[0];
|
|
441
|
+
for (let i = 1; i < partials.length; i++) {
|
|
442
|
+
let partial = partials[i];
|
|
443
|
+
typeof partial == "number" ? scopeId += partial : (scopeId ? initScope(Object.assign(scopeLookup[scopeId] ||= (partial.L = scopeId, partial), partial)) : Object.assign(initGlobal(), partial), scopeId++);
|
|
444
|
+
}
|
|
445
|
+
}, serializeContext = ((data, registryId) => typeof data == "number" ? registryId ? registeredValues[registryId](getScope(data)) : getScope(data) : applyScopes(data)), createVisitBranches = (branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
|
|
435
446
|
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
436
447
|
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
437
448
|
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
@@ -440,22 +451,40 @@ function init(runtimeId = "M") {
|
|
|
440
451
|
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
441
452
|
nextToken();
|
|
442
453
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
454
|
+
if (endedBranches) {
|
|
455
|
+
for (let ended of endedBranches) orphanBranches.push(ended);
|
|
456
|
+
singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0]);
|
|
457
|
+
}
|
|
458
|
+
visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
|
|
459
|
+
}, nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), processResumes = (resumes = [], effects) => {
|
|
460
|
+
let i = 0;
|
|
461
|
+
for (; i < resumes.length; i++) {
|
|
462
|
+
let serialized = resumes[i];
|
|
463
|
+
if (typeof serialized == "string") for (lastTokenIndex = 0, visitText = serialized; nextToken();) /\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
|
|
464
|
+
else if (Array.isArray(serialized)) {
|
|
465
|
+
if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
|
|
466
|
+
} else if (readyIds && typeof serialized == "number") break;
|
|
467
|
+
else {
|
|
468
|
+
let scopes = serialized(serializeContext);
|
|
469
|
+
Array.isArray(scopes) && applyScopes(scopes);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return resumes.splice(0, i), i;
|
|
473
|
+
}, $global, lastEffect, visits, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, visitBranches, embedAnchor;
|
|
474
|
+
return serializeContext._ = registeredValues, render.m = (effects) => {
|
|
475
|
+
if (processResumes(render.r, effects), readyIds && render.b) for (let progress = 1; progress;) {
|
|
476
|
+
progress = 0;
|
|
477
|
+
for (let readyId of readyIds) {
|
|
478
|
+
let resumes = render.b[readyId];
|
|
479
|
+
resumes && processResumes(resumes, effects) && (progress = 1);
|
|
480
|
+
}
|
|
451
481
|
}
|
|
452
|
-
|
|
453
|
-
else for (let scope of serialized(serializeContext)) $global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = getScope(scope.G))) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
|
|
482
|
+
let retained = 0;
|
|
454
483
|
for (visit of visits = render.v) if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken()), visitType === "*") {
|
|
455
484
|
let prev = visit.previousSibling;
|
|
456
485
|
visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
|
|
457
|
-
} else branchesEnabled
|
|
458
|
-
return
|
|
486
|
+
} else branchesEnabled ? (visitBranches ||= createVisitBranches())() : render.b && (visits[retained++] = visit);
|
|
487
|
+
return embedRenders && !embedAnchor && visit && embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit.nextSibling), [renderId, scopeLookup]), visits.length = retained, effects;
|
|
459
488
|
}, render.w = () => {
|
|
460
489
|
walk(), runResumeEffects(render);
|
|
461
490
|
}, render;
|
|
@@ -463,7 +492,7 @@ function init(runtimeId = "M") {
|
|
|
463
492
|
};
|
|
464
493
|
if (renders) {
|
|
465
494
|
initRuntime(renders);
|
|
466
|
-
for (let renderId in renders) runResumeEffects(
|
|
495
|
+
for (let renderId in renders) runResumeEffects(curRenders(renderId));
|
|
467
496
|
} else defineRuntime({
|
|
468
497
|
configurable: !0,
|
|
469
498
|
set: initRuntime
|
|
@@ -471,7 +500,7 @@ function init(runtimeId = "M") {
|
|
|
471
500
|
}
|
|
472
501
|
function runResumeEffects(render) {
|
|
473
502
|
try {
|
|
474
|
-
isResuming = 1, runEffects(render.m(), 1);
|
|
503
|
+
isResuming = 1, runEffects(render.m([]), 1);
|
|
475
504
|
} finally {
|
|
476
505
|
isResuming = 0;
|
|
477
506
|
}
|
|
@@ -829,32 +858,24 @@ function _await_promise(nodeAccessor, params) {
|
|
|
829
858
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
830
859
|
let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
|
|
831
860
|
return _enable_catch(), (scope, promise) => {
|
|
832
|
-
let awaitBranch = scope[branchAccessor],
|
|
833
|
-
awaitCounter?.i || (awaitCounter = tryBranch.O = {
|
|
861
|
+
let awaitBranch = scope[branchAccessor], tryPlaceholder = findBranchWithKey(scope, "Q"), tryBranch = tryPlaceholder || awaitBranch, awaitCounter = tryBranch.O;
|
|
862
|
+
placeholderShown.add(pendingEffects), tryPlaceholder ? scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter = addAwaitCounter(scope, tryPlaceholder)) : (awaitCounter?.i || (awaitCounter = tryBranch.O = {
|
|
834
863
|
i: 0,
|
|
835
864
|
c() {
|
|
836
865
|
if (--awaitCounter.i) return 1;
|
|
837
|
-
|
|
838
|
-
else {
|
|
839
|
-
let placeholderBranch = tryBranch.P;
|
|
840
|
-
placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
|
|
841
|
-
}
|
|
842
|
-
queueEffect(tryBranch, (scope) => {
|
|
843
|
-
let pendingEffects = scope.J;
|
|
844
|
-
pendingEffects && (scope.J = [], runEffects(pendingEffects, 1));
|
|
845
|
-
});
|
|
866
|
+
tryBranch === scope[branchAccessor] ? scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode) : dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
|
|
846
867
|
}
|
|
847
|
-
}),
|
|
848
|
-
|
|
849
|
-
}, -1)))));
|
|
868
|
+
}), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
|
|
869
|
+
awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
|
|
870
|
+
}, -1))))));
|
|
850
871
|
let thisPromise = scope[promiseAccessor] = promise.then((data) => {
|
|
851
872
|
if (thisPromise === scope[promiseAccessor]) {
|
|
852
873
|
let referenceNode = scope[nodeAccessor];
|
|
853
|
-
scope[promiseAccessor] = 0,
|
|
874
|
+
scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
|
|
854
875
|
(awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [data]);
|
|
855
876
|
let pendingRenders = awaitBranch.W;
|
|
856
877
|
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
857
|
-
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
|
|
878
|
+
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
|
|
858
879
|
for (let i = 0; i < pendingEffects.length;) {
|
|
859
880
|
let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
|
|
860
881
|
scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
|
|
@@ -864,10 +885,10 @@ function _await_promise(nodeAccessor, params) {
|
|
|
864
885
|
fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
|
|
865
886
|
}
|
|
866
887
|
}
|
|
867
|
-
}
|
|
888
|
+
});
|
|
868
889
|
}
|
|
869
890
|
}, (error) => {
|
|
870
|
-
thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0,
|
|
891
|
+
thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, queueAsyncRender(scope, renderCatch, error));
|
|
871
892
|
});
|
|
872
893
|
};
|
|
873
894
|
}
|
|
@@ -878,6 +899,27 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
878
899
|
(scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer, pendingScopes.pop();
|
|
879
900
|
};
|
|
880
901
|
}
|
|
902
|
+
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
|
|
903
|
+
if (!tryBranch) return;
|
|
904
|
+
let awaitCounter = tryBranch.O;
|
|
905
|
+
return awaitCounter?.i || (awaitCounter = tryBranch.O = {
|
|
906
|
+
i: 0,
|
|
907
|
+
c() {
|
|
908
|
+
if (--awaitCounter.i) return 1;
|
|
909
|
+
dismissPlaceholder(tryBranch), queueEffect(tryBranch, runPendingEffects);
|
|
910
|
+
}
|
|
911
|
+
}), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
|
|
912
|
+
insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
|
|
913
|
+
}, -1)))), awaitCounter;
|
|
914
|
+
}
|
|
915
|
+
function runPendingEffects(scope) {
|
|
916
|
+
let effects = scope.J;
|
|
917
|
+
effects && (scope.J = [], runEffects(effects, 1));
|
|
918
|
+
}
|
|
919
|
+
function dismissPlaceholder(tryBranch) {
|
|
920
|
+
let placeholderBranch = tryBranch.P;
|
|
921
|
+
placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
|
|
922
|
+
}
|
|
881
923
|
function _try(nodeAccessor, template, walks, setup) {
|
|
882
924
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
883
925
|
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
@@ -995,6 +1037,9 @@ function run() {
|
|
|
995
1037
|
}
|
|
996
1038
|
runEffects(effects);
|
|
997
1039
|
}
|
|
1040
|
+
function queueAsyncRender(scope, signal, value) {
|
|
1041
|
+
queueRender(scope, signal, -1, value), queueMicrotask(run);
|
|
1042
|
+
}
|
|
998
1043
|
function prepareEffects(fn) {
|
|
999
1044
|
let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
|
|
1000
1045
|
pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = {};
|
|
@@ -1116,4 +1161,79 @@ function mount(input = {}, reference, position) {
|
|
|
1116
1161
|
};
|
|
1117
1162
|
}
|
|
1118
1163
|
//#endregion
|
|
1119
|
-
|
|
1164
|
+
//#region src/dom/load.ts
|
|
1165
|
+
function _load_template(id, load) {
|
|
1166
|
+
_enable_catch();
|
|
1167
|
+
let pending, lazyTemplate = _template(id, 0, 0, (branch) => {
|
|
1168
|
+
let awaitCounter = addAwaitCounter(branch);
|
|
1169
|
+
branch.X ||= /* @__PURE__ */ new Map(), (pending ||= load()).then((renderer) => {
|
|
1170
|
+
Object.assign(lazyTemplate, renderer), queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch.S, awaitCounter));
|
|
1171
|
+
}, loadFailed(branch, awaitCounter));
|
|
1172
|
+
}, _load_signal(() => (pending ||= load()).then((r) => ({ _: r.d }))));
|
|
1173
|
+
return lazyTemplate;
|
|
1174
|
+
}
|
|
1175
|
+
function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
1176
|
+
nodeAccessor = decodeAccessor(nodeAccessor), childScopeAccessor = decodeAccessor(childScopeAccessor);
|
|
1177
|
+
let pending, renderer;
|
|
1178
|
+
return _enable_catch(), (owner) => {
|
|
1179
|
+
let child = owner[childScopeAccessor];
|
|
1180
|
+
if (renderer) insertLoaded(renderer, child, owner[nodeAccessor]);
|
|
1181
|
+
else {
|
|
1182
|
+
let awaitCounter = addAwaitCounter(owner);
|
|
1183
|
+
child.X ||= /* @__PURE__ */ new Map(), (pending ||= load()).then((mod) => {
|
|
1184
|
+
renderer = _content("", ...mod._)(), queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
|
|
1185
|
+
}, loadFailed(child, awaitCounter));
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1190
|
+
let parent = marker.parentNode;
|
|
1191
|
+
branch.H = 1, renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
|
|
1192
|
+
insertBranchBefore(branch, parent, marker), marker.remove(), pendingScopes.push(branch), awaitCounter?.c();
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
function loadFailed(scope, awaitCounter) {
|
|
1196
|
+
return (error) => {
|
|
1197
|
+
awaitCounter && (awaitCounter.i = 0), queueAsyncRender(scope, renderCatch, error);
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
function applyLoad(scope, insert) {
|
|
1201
|
+
let values = scope.X, remaining;
|
|
1202
|
+
if (scope.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
|
|
1203
|
+
entry.b = signal, --remaining || (scope.H = 1, pendingScopes.push(scope), queueAsyncRender(scope, (scope) => {
|
|
1204
|
+
values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1205
|
+
}));
|
|
1206
|
+
}, () => 0);
|
|
1207
|
+
else insert();
|
|
1208
|
+
}
|
|
1209
|
+
function _load_signal(load) {
|
|
1210
|
+
let pending, signal;
|
|
1211
|
+
return (scope, value) => {
|
|
1212
|
+
pending ||= load(), scope.X || !("X" in scope) && scope.H ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
function _load_visible_trigger(selector, options) {
|
|
1216
|
+
let pending, el;
|
|
1217
|
+
return (load) => () => (pending ||= new Promise((resolve) => (el = getSelectorOrResolve(selector, resolve)) && new IntersectionObserver((entries, io) => entries.some((entry) => entry.isIntersecting) && resolve(io.disconnect()), options).observe(el))).then(load);
|
|
1218
|
+
}
|
|
1219
|
+
function _load_idle_trigger(options) {
|
|
1220
|
+
let pending;
|
|
1221
|
+
return (load) => () => (pending ||= new Promise((resolve) => (self.requestIdleCallback || resolve)(resolve, options))).then(load);
|
|
1222
|
+
}
|
|
1223
|
+
function _load_event_trigger(event, selector) {
|
|
1224
|
+
let pending;
|
|
1225
|
+
return (load) => () => (pending ||= new Promise((resolve) => getSelectorOrResolve(selector, resolve)?.addEventListener(event, resolve, { once: !0 }))).then(load);
|
|
1226
|
+
}
|
|
1227
|
+
function _load_media_trigger(query) {
|
|
1228
|
+
let pending, mql;
|
|
1229
|
+
return (load) => () => (pending ||= new Promise((resolve) => (mql = matchMedia(query)).matches ? resolve() : mql.addEventListener("change", resolve, { once: !0 }))).then(load);
|
|
1230
|
+
}
|
|
1231
|
+
function _load_race_trigger(...triggers) {
|
|
1232
|
+
let noop = () => Promise.resolve(), pending;
|
|
1233
|
+
return (load) => () => (pending ||= Promise.race(triggers.map((t) => t(noop)()))).then(load);
|
|
1234
|
+
}
|
|
1235
|
+
function getSelectorOrResolve(selector, resolve) {
|
|
1236
|
+
return document.querySelector(selector) || resolve();
|
|
1237
|
+
}
|
|
1238
|
+
//#endregion
|
|
1239
|
+
export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { $Global, Template } from "../common/types";
|
|
2
|
+
import { type ServerRenderer } from "./template";
|
|
3
|
+
declare const kAssets: unique symbol;
|
|
4
|
+
declare const kBlockIndex: unique symbol;
|
|
5
|
+
declare const kDeferIndex: unique symbol;
|
|
6
|
+
export interface VisibleTrigger {
|
|
7
|
+
type: "visible";
|
|
8
|
+
selector: string;
|
|
9
|
+
options?: {
|
|
10
|
+
rootMargin?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface IdleTrigger {
|
|
14
|
+
type: "idle";
|
|
15
|
+
selector?: never;
|
|
16
|
+
options?: {
|
|
17
|
+
timeout?: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface MediaTrigger {
|
|
21
|
+
type: "media";
|
|
22
|
+
selector: string;
|
|
23
|
+
options?: never;
|
|
24
|
+
}
|
|
25
|
+
export interface EventTrigger {
|
|
26
|
+
type: `on-${string}`;
|
|
27
|
+
selector: string;
|
|
28
|
+
options?: never;
|
|
29
|
+
}
|
|
30
|
+
export type LoadTrigger = VisibleTrigger | IdleTrigger | MediaTrigger | EventTrigger;
|
|
31
|
+
type Trigger = LoadTrigger;
|
|
32
|
+
interface Asset {
|
|
33
|
+
id: string;
|
|
34
|
+
triggers?: Trigger[];
|
|
35
|
+
}
|
|
36
|
+
declare module "../common/types" {
|
|
37
|
+
interface $Global {
|
|
38
|
+
[kAssets]?: Asset[];
|
|
39
|
+
[kBlockIndex]?: number;
|
|
40
|
+
[kDeferIndex]?: number;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
type AssetFlush = (g: $Global, type: "block" | "defer", asset: string) => string;
|
|
44
|
+
export declare function withLoadAssets(renderer: ServerRenderer, assetId: string, triggers?: Trigger[]): ServerRenderer;
|
|
45
|
+
export declare function withPageAssets(template: ServerRenderer & Template, runtime: AssetFlush, assetId: string, runtimeId?: string): Template;
|
|
46
|
+
export declare function _flush_head(): string;
|
|
47
|
+
export {};
|
package/dist/html/compat.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { register } from "./serializer";
|
|
1
2
|
import type { ServerRenderer } from "./template";
|
|
2
3
|
import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, isInResumedBranch, State, writeScript } from "./writer";
|
|
3
4
|
export declare const compat: {
|
|
@@ -13,9 +14,9 @@ export declare const compat: {
|
|
|
13
14
|
onFlush(fn: (chunk: Chunk) => void): void;
|
|
14
15
|
patchDynamicTag: (patch: (tag: unknown, scopeId: number, accessor: import("../common/types").Accessor) => unknown) => void;
|
|
15
16
|
writeSetScopeForComponent(branchId: number, m5c: string, m5i: unknown): void;
|
|
16
|
-
toJSON(
|
|
17
|
+
toJSON(): (this: WeakKey) => [registryId: string, scopeId: unknown] | undefined;
|
|
17
18
|
flushScript($global: any): string;
|
|
18
19
|
render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any, completeChunks: Chunk[]): void;
|
|
19
|
-
|
|
20
|
+
register: typeof register;
|
|
20
21
|
registerRenderBody(fn: any): void;
|
|
21
22
|
};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import type { Boundary } from "./writer";
|
|
2
|
+
export declare const K_SCOPE_ID: unique symbol;
|
|
3
|
+
export type ScopeFlush = [scopeId: number, scope: object, props: object];
|
|
4
|
+
export interface SerializeChannel {
|
|
5
|
+
readyId?: string;
|
|
6
|
+
parent?: SerializeChannel;
|
|
7
|
+
}
|
|
2
8
|
export declare function setDebugInfo(obj: WeakKey, file: string, loc: string | 0, vars?: Record<string, string>): void;
|
|
3
9
|
export declare class Serializer {
|
|
4
10
|
#private;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
|
|
11
|
+
pending(channel?: SerializeChannel): boolean;
|
|
12
|
+
pendingReadyChannel(): SerializeChannel | undefined;
|
|
13
|
+
stringifyScopes(flushes: ScopeFlush[], globals: object | 0, boundary: Boundary, channel?: SerializeChannel): string;
|
|
14
|
+
written(val: WeakKey): boolean;
|
|
15
|
+
takeChannelDeps(): Set<string> | null;
|
|
16
|
+
writeCall(value: unknown, object: unknown, property: string, channel?: SerializeChannel): void;
|
|
12
17
|
}
|
|
13
|
-
export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown
|
|
18
|
+
export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
|
|
14
19
|
export declare function getRegistered(val: WeakKey): {
|
|
15
20
|
id: string;
|
|
16
21
|
scope: unknown;
|
|
17
22
|
} | undefined;
|
|
18
|
-
export declare function stringify(val: unknown): string;
|
|
19
23
|
export declare function toObjectKey(name: string): string;
|
|
20
24
|
export declare function toAccess(accessor: string): string;
|
|
25
|
+
export declare function quote(str: string, startPos: number): string;
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { _hoist_read_error } from "../common/errors";
|
|
2
|
+
import { type Opt } from "../common/opt";
|
|
2
3
|
import { type $Global, type Accessor, type Falsy, ResumeSymbol } from "../common/types";
|
|
3
|
-
import { Serializer } from "./serializer";
|
|
4
|
+
import { K_SCOPE_ID, Serializer } from "./serializer";
|
|
5
|
+
import type { ServerRenderer } from "./template";
|
|
4
6
|
export type PartialScope = Record<Accessor, unknown>;
|
|
7
|
+
interface SerializeState {
|
|
8
|
+
readyId?: string;
|
|
9
|
+
parent?: SerializeState;
|
|
10
|
+
resumes: string;
|
|
11
|
+
writeScopes: Record<number, PartialScope>;
|
|
12
|
+
passiveScopes?: Record<number, PartialScope>;
|
|
13
|
+
flushScopes: boolean;
|
|
14
|
+
}
|
|
5
15
|
type ScopeInternals = PartialScope & {
|
|
6
16
|
[K_SCOPE_ID]?: number;
|
|
7
|
-
[K_SCOPE_REFERENCED]?: 1;
|
|
8
17
|
};
|
|
9
|
-
declare const K_SCOPE_ID: unique symbol;
|
|
10
|
-
declare const K_SCOPE_REFERENCED: unique symbol;
|
|
11
18
|
declare enum Mark {
|
|
12
19
|
Placeholder = "!^",
|
|
13
20
|
PlaceholderEnd = "!",
|
|
@@ -19,6 +26,7 @@ export declare function getState(): State;
|
|
|
19
26
|
export declare function getScopeId(scope: unknown): number | undefined;
|
|
20
27
|
export declare function _html(html: string): void;
|
|
21
28
|
export declare function writeScript(script: string): void;
|
|
29
|
+
export declare function writeWaitReady(readyId: string, renderer: ServerRenderer, input: unknown): void;
|
|
22
30
|
export declare function _script(scopeId: number, registryId: string): void;
|
|
23
31
|
export declare function _attr_content(nodeAccessor: Accessor, scopeId: number, content: unknown, serializeReason?: 1 | 0): void;
|
|
24
32
|
export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
|
|
@@ -28,7 +36,7 @@ export declare function _resume<T extends WeakKey>(val: T, id: string, scopeId?:
|
|
|
28
36
|
export declare function _id(): string;
|
|
29
37
|
export declare function _scope_id(): number;
|
|
30
38
|
export declare function _peek_scope_id(): number;
|
|
31
|
-
export declare function getScopeById(scopeId: number | undefined):
|
|
39
|
+
export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
|
|
32
40
|
export declare function _set_serialize_reason(reason: undefined | 0 | 1): void;
|
|
33
41
|
export declare function _scope_reason(): 0 | 1 | undefined;
|
|
34
42
|
export declare function _serialize_if(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
|
|
@@ -49,7 +57,6 @@ export declare function _for_to(to: number, from: number | Falsy, step: number |
|
|
|
49
57
|
export declare function _for_until(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
50
58
|
export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
|
|
51
59
|
declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
|
|
52
|
-
export declare function writeScopeToState(state: State, scopeId: number, partialScope: PartialScope): ScopeInternals;
|
|
53
60
|
export { writeScope as _scope };
|
|
54
61
|
export declare function _existing_scope(scopeId: number): ScopeInternals;
|
|
55
62
|
export declare function _scope_with_id(scopeId: number): ScopeInternals;
|
|
@@ -66,7 +73,7 @@ export declare function _try(scopeId: number, accessor: Accessor, content: () =>
|
|
|
66
73
|
content?(err: unknown): void;
|
|
67
74
|
};
|
|
68
75
|
}): void;
|
|
69
|
-
export declare class State {
|
|
76
|
+
export declare class State implements SerializeState {
|
|
70
77
|
$global: $Global & {
|
|
71
78
|
renderId: string;
|
|
72
79
|
runtimeId: string;
|
|
@@ -74,10 +81,11 @@ export declare class State {
|
|
|
74
81
|
tagId: number;
|
|
75
82
|
scopeId: number;
|
|
76
83
|
reorderId: number;
|
|
77
|
-
|
|
84
|
+
readyGate: number;
|
|
78
85
|
hasGlobals: boolean;
|
|
79
86
|
needsMainRuntime: boolean;
|
|
80
87
|
hasMainRuntime: boolean;
|
|
88
|
+
hasReadyRuntime: boolean;
|
|
81
89
|
hasReorderRuntime: boolean;
|
|
82
90
|
hasWrittenResume: boolean;
|
|
83
91
|
walkOnNextFlush: boolean;
|
|
@@ -86,9 +94,10 @@ export declare class State {
|
|
|
86
94
|
nonceAttr: string;
|
|
87
95
|
serializer: Serializer;
|
|
88
96
|
writeReorders: Chunk[] | null;
|
|
89
|
-
scopes: Map<number,
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
scopes: Map<number, ScopeInternals>;
|
|
98
|
+
flushScopes: boolean;
|
|
99
|
+
writeScopes: Record<number, PartialScope>;
|
|
100
|
+
readyIds: Set<string> | null;
|
|
92
101
|
serializeReason: undefined | 0 | 1;
|
|
93
102
|
constructor($global: $Global & {
|
|
94
103
|
renderId: string;
|
|
@@ -97,6 +106,8 @@ export declare class State {
|
|
|
97
106
|
get runtimePrefix(): string;
|
|
98
107
|
get commentPrefix(): string;
|
|
99
108
|
reorder(chunk: Chunk): void;
|
|
109
|
+
writeReady(id: string, resumes: string): string;
|
|
110
|
+
readyAccess(readyKey: string): string;
|
|
100
111
|
nextReorderId(): string;
|
|
101
112
|
mark(code: ResumeSymbol | Mark, str: string): string;
|
|
102
113
|
}
|
|
@@ -118,6 +129,7 @@ export declare class Chunk {
|
|
|
118
129
|
boundary: Boundary;
|
|
119
130
|
next: Chunk | null;
|
|
120
131
|
context: Record<string | symbol, unknown> | null;
|
|
132
|
+
serializeState: SerializeState;
|
|
121
133
|
html: string;
|
|
122
134
|
scripts: string;
|
|
123
135
|
effects: string;
|
|
@@ -126,18 +138,25 @@ export declare class Chunk {
|
|
|
126
138
|
consumed: boolean;
|
|
127
139
|
needsWalk: boolean;
|
|
128
140
|
reorderId: string | null;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
deferredReady: Opt<Chunk>;
|
|
142
|
+
placeholder: {
|
|
143
|
+
body: Chunk;
|
|
144
|
+
render: () => void;
|
|
145
|
+
branchId: number;
|
|
146
|
+
} | null;
|
|
147
|
+
constructor(boundary: Boundary, next: Chunk | null, context: Record<string | symbol, unknown> | null, serializeState: SerializeState);
|
|
148
|
+
fork(boundary: Boundary, next: Chunk | null): Chunk;
|
|
133
149
|
writeHTML(html: string): void;
|
|
134
150
|
writeEffect(scopeId: number, registryId: string): void;
|
|
135
151
|
writeScript(script: string): void;
|
|
136
152
|
append(chunk: Chunk): void;
|
|
153
|
+
takeDeferredReady(): Opt<Chunk>;
|
|
154
|
+
deferOwnReady(): void;
|
|
137
155
|
flushPlaceholder(): void;
|
|
138
156
|
consume(): Chunk;
|
|
139
157
|
render(content: () => void): Chunk;
|
|
140
158
|
render<T>(content: (val: T) => void, val: T): Chunk;
|
|
159
|
+
flushReadyScripts(reservations?: string[]): string;
|
|
141
160
|
flushScript(): this;
|
|
142
161
|
flushHTML(): string;
|
|
143
162
|
}
|
package/dist/html.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
2
|
export { _assert_hoist, _el_read_error, _hoist_read_error, } from "./common/errors";
|
|
3
|
+
export { _flush_head, withLoadAssets, withPageAssets } from "./html/assets";
|
|
3
4
|
export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_option_value, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, } from "./html/attrs";
|
|
4
5
|
export { compat } from "./html/compat";
|
|
5
6
|
export { _escape, _escape_comment, _escape_script, _escape_style, _unescaped, } from "./html/content";
|