marko 6.0.112 → 6.0.114
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/README.md +1 -1
- package/dist/common/accessor.d.ts +2 -2
- package/dist/common/accessor.debug.d.ts +2 -2
- package/dist/common/types.d.ts +6 -1
- package/dist/debug/dom.js +140 -90
- package/dist/debug/dom.mjs +140 -90
- package/dist/debug/html.js +34 -24
- package/dist/debug/html.mjs +34 -24
- package/dist/dom/control-flow.d.ts +2 -1
- package/dist/dom/queue.d.ts +1 -1
- package/dist/dom/resume.d.ts +21 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +120 -95
- package/dist/dom.mjs +120 -95
- package/dist/html/writer.d.ts +2 -0
- package/dist/html.js +28 -24
- package/dist/html.mjs +28 -24
- package/dist/translator/index.js +35 -13
- package/dist/translator/util/sections.d.ts +1 -1
- package/package.json +1 -1
package/dist/dom.mjs
CHANGED
|
@@ -76,7 +76,7 @@ function normalizeDynamicRenderer(value) {
|
|
|
76
76
|
if (value) {
|
|
77
77
|
if (typeof value == "string") return value;
|
|
78
78
|
let normalized = value.content || value.default || value;
|
|
79
|
-
if (/* @__KEY__ */ "
|
|
79
|
+
if (/* @__KEY__ */ "g" in normalized)
|
|
80
80
|
return normalized;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -272,35 +272,30 @@ function init(runtimeId = "M") {
|
|
|
272
272
|
endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" /* BranchStart */ && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
|
|
273
273
|
})(), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0, nextToken = () => lastToken = visitText.slice(
|
|
274
274
|
lastTokenIndex,
|
|
275
|
-
|
|
276
|
-
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
275
|
+
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
|
|
277
276
|
);
|
|
278
|
-
return render.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
registeredValues[lastEffect],
|
|
287
|
-
scopeLookup[serialized] ||= {
|
|
288
|
-
L: serialized
|
|
277
|
+
return render.m = (effects = []) => {
|
|
278
|
+
for (let serialized of resumes = render.r || [])
|
|
279
|
+
if (typeof serialized == "string")
|
|
280
|
+
for (lastTokenIndex = 0, visitText = serialized; nextToken(); )
|
|
281
|
+
/\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(
|
|
282
|
+
lastEffect,
|
|
283
|
+
scopeLookup[lastToken] ||= {
|
|
284
|
+
L: +lastToken
|
|
289
285
|
}
|
|
290
286
|
);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
287
|
+
else
|
|
288
|
+
for (let scope of serialized(serializeContext))
|
|
289
|
+
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = scopeLookup[scope.G])) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
|
|
290
|
+
for (visit of visits = render.v)
|
|
291
|
+
lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = scopeLookup[+nextToken(
|
|
292
|
+
/* read scope id */
|
|
293
|
+
)] ||= {
|
|
294
|
+
L: +lastToken
|
|
295
|
+
}, visitType === "*" /* Node */ ? visitScope["J" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling) : branchesEnabled && visitBranches();
|
|
296
|
+
return visits.length = resumes.length = 0, effects;
|
|
297
|
+
}, render.w = () => {
|
|
298
|
+
walk2(), runResumeEffects(render);
|
|
304
299
|
}, render;
|
|
305
300
|
})
|
|
306
301
|
});
|
|
@@ -308,7 +303,7 @@ function init(runtimeId = "M") {
|
|
|
308
303
|
if (renders) {
|
|
309
304
|
initRuntime(renders);
|
|
310
305
|
for (let renderId in renders)
|
|
311
|
-
resumeRender(renderId)
|
|
306
|
+
runResumeEffects(resumeRender(renderId));
|
|
312
307
|
} else
|
|
313
308
|
defineRuntime({
|
|
314
309
|
configurable: !0,
|
|
@@ -316,6 +311,13 @@ function init(runtimeId = "M") {
|
|
|
316
311
|
});
|
|
317
312
|
}
|
|
318
313
|
var isResuming;
|
|
314
|
+
function runResumeEffects(render) {
|
|
315
|
+
try {
|
|
316
|
+
isResuming = 1, runEffects(render.m(), 1);
|
|
317
|
+
} finally {
|
|
318
|
+
isResuming = 0;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
319
321
|
function getRegisteredWithScope(id, scope) {
|
|
320
322
|
let val = registeredValues[id];
|
|
321
323
|
return scope ? val(scope) : val;
|
|
@@ -587,9 +589,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
|
587
589
|
));
|
|
588
590
|
}
|
|
589
591
|
function _closure(...closureSignals) {
|
|
590
|
-
let [{
|
|
592
|
+
let [{ l: ___scopeInstancesAccessor, n: ___signalIndexAccessor }] = closureSignals;
|
|
591
593
|
for (let i = closureSignals.length; i--; )
|
|
592
|
-
closureSignals[i].
|
|
594
|
+
closureSignals[i].t = i;
|
|
593
595
|
return (scope) => {
|
|
594
596
|
if (scope[___scopeInstancesAccessor])
|
|
595
597
|
for (let childScope of scope[___scopeInstancesAccessor])
|
|
@@ -603,13 +605,13 @@ function _closure(...closureSignals) {
|
|
|
603
605
|
function _closure_get(valueAccessor, fn, getOwnerScope) {
|
|
604
606
|
valueAccessor = decodeAccessor(valueAccessor);
|
|
605
607
|
let closureSignal = ((scope) => {
|
|
606
|
-
scope[closureSignal.
|
|
608
|
+
scope[closureSignal.n] = closureSignal.t, fn(scope), subscribeToScopeSet(
|
|
607
609
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
|
608
|
-
closureSignal.
|
|
610
|
+
closureSignal.l,
|
|
609
611
|
scope
|
|
610
612
|
);
|
|
611
613
|
});
|
|
612
|
-
return closureSignal.
|
|
614
|
+
return closureSignal.l = "B" /* ClosureScopes */ + valueAccessor, closureSignal.n = "C" /* ClosureSignalIndex */ + valueAccessor, closureSignal;
|
|
613
615
|
}
|
|
614
616
|
function _child_setup(setup) {
|
|
615
617
|
return setup._ = (scope, owner) => {
|
|
@@ -653,7 +655,7 @@ function _hoist(...path) {
|
|
|
653
655
|
// src/dom/renderer.ts
|
|
654
656
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
655
657
|
let branch = createScope($global), parentBranch = parentScope?.F;
|
|
656
|
-
return branch._ = renderer.
|
|
658
|
+
return branch._ = renderer.e || parentScope, branch.F = branch, parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), renderer.h?.(
|
|
657
659
|
branch,
|
|
658
660
|
parentNode.namespaceURI
|
|
659
661
|
), branch;
|
|
@@ -665,7 +667,7 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
|
665
667
|
);
|
|
666
668
|
}
|
|
667
669
|
function setupBranch(renderer, branch) {
|
|
668
|
-
return renderer.
|
|
670
|
+
return renderer.j && queueRender(branch, renderer.j, -1), branch;
|
|
669
671
|
}
|
|
670
672
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
671
673
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
|
|
@@ -682,10 +684,10 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
682
684
|
);
|
|
683
685
|
};
|
|
684
686
|
return (owner) => ({
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
687
|
+
g: id,
|
|
688
|
+
h: clone,
|
|
689
|
+
e: owner,
|
|
690
|
+
j: setup,
|
|
689
691
|
a: params,
|
|
690
692
|
b: dynamicScopesAccessor
|
|
691
693
|
});
|
|
@@ -702,7 +704,7 @@ function _content_closures(renderer, closureFns) {
|
|
|
702
704
|
closureSignals[key] = _const(+key, closureFns[key]);
|
|
703
705
|
return (owner, closureValues) => {
|
|
704
706
|
let instance = renderer(owner);
|
|
705
|
-
return instance.
|
|
707
|
+
return instance.o = closureSignals, instance.u = closureValues, instance;
|
|
706
708
|
};
|
|
707
709
|
}
|
|
708
710
|
var cloneCache = {};
|
|
@@ -856,8 +858,8 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
856
858
|
}
|
|
857
859
|
function _attr_content(scope, nodeAccessor, value) {
|
|
858
860
|
let content = normalizeClientRender(value), rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
859
|
-
scope[rendererAccessor] !== (scope[rendererAccessor] = content?.
|
|
860
|
-
content.
|
|
861
|
+
scope[rendererAccessor] !== (scope[rendererAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.b && subscribeToScopeSet(
|
|
862
|
+
content.e,
|
|
861
863
|
content.b,
|
|
862
864
|
scope["A" /* BranchScopes */ + nodeAccessor]
|
|
863
865
|
));
|
|
@@ -898,7 +900,7 @@ function _html(scope, value, accessor) {
|
|
|
898
900
|
}
|
|
899
901
|
function normalizeClientRender(value) {
|
|
900
902
|
let renderer = normalizeDynamicRenderer(value);
|
|
901
|
-
if (renderer && renderer.
|
|
903
|
+
if (renderer && renderer.g)
|
|
902
904
|
return renderer;
|
|
903
905
|
}
|
|
904
906
|
function normalizeAttrValue(value) {
|
|
@@ -1008,16 +1010,31 @@ function longestIncreasingSubsequence(a) {
|
|
|
1008
1010
|
}
|
|
1009
1011
|
|
|
1010
1012
|
// src/dom/control-flow.ts
|
|
1011
|
-
function
|
|
1013
|
+
function _await_promise(nodeAccessor, params) {
|
|
1012
1014
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1013
|
-
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor,
|
|
1014
|
-
return
|
|
1015
|
-
let
|
|
1015
|
+
let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1016
|
+
return _enable_catch(), (scope, promise) => {
|
|
1017
|
+
let awaitCounter, renderData, tryWithPlaceholder = findBranchWithKey(
|
|
1016
1018
|
scope,
|
|
1017
1019
|
"Q" /* PlaceholderContent */
|
|
1018
|
-
)
|
|
1019
|
-
tryWithPlaceholder ? (
|
|
1020
|
-
|
|
1020
|
+
);
|
|
1021
|
+
tryWithPlaceholder ? (renderData = self[tryWithPlaceholder.$.runtimeId]?.[tryWithPlaceholder.$.renderId], awaitCounter = tryWithPlaceholder.O ||= renderData?.p?.[tryWithPlaceholder.L], awaitCounter?.i || (awaitCounter = tryWithPlaceholder.O = {
|
|
1022
|
+
d: 1,
|
|
1023
|
+
i: 0,
|
|
1024
|
+
c() {
|
|
1025
|
+
if (!--awaitCounter.i) {
|
|
1026
|
+
let placeholderBranch = tryWithPlaceholder.P;
|
|
1027
|
+
tryWithPlaceholder.P = 0, placeholderBranch && (placeholderBranch.S.parentNode.insertBefore(
|
|
1028
|
+
tryWithPlaceholder.S.parentNode,
|
|
1029
|
+
placeholderBranch.S
|
|
1030
|
+
), removeAndDestroyBranch(placeholderBranch)), queueEffect(tryWithPlaceholder, (scope2) => {
|
|
1031
|
+
let pendingEffects2 = scope2.J;
|
|
1032
|
+
pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, !0));
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}), placeholderShown.add(pendingEffects), !scope[promiseAccessor] && !awaitCounter.i++ && requestAnimationFrame(
|
|
1037
|
+
() => awaitCounter.i && runEffects(
|
|
1021
1038
|
prepareEffects(
|
|
1022
1039
|
() => queueRender(
|
|
1023
1040
|
tryWithPlaceholder,
|
|
@@ -1037,46 +1054,53 @@ function _await(nodeAccessor, template, walks, setup, params) {
|
|
|
1037
1054
|
)
|
|
1038
1055
|
)
|
|
1039
1056
|
)
|
|
1040
|
-
)) :
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
), tempDetachBranch(
|
|
1057
|
+
)) : scope[branchAccessor] && !scope[promiseAccessor] && (scope[branchAccessor].S.parentNode.insertBefore(
|
|
1058
|
+
scope[nodeAccessor],
|
|
1059
|
+
scope[branchAccessor].S
|
|
1060
|
+
), tempDetachBranch(scope[branchAccessor]));
|
|
1044
1061
|
let thisPromise = scope[promiseAccessor] = promise.then(
|
|
1045
1062
|
(data) => {
|
|
1046
1063
|
thisPromise === scope[promiseAccessor] && (scope[promiseAccessor] = 0, schedule(), queueRender(
|
|
1047
1064
|
scope,
|
|
1048
1065
|
() => {
|
|
1049
|
-
if (
|
|
1050
|
-
|
|
1066
|
+
if (scope[branchAccessor] ? tryWithPlaceholder || scope[nodeAccessor].replaceWith(
|
|
1067
|
+
scope[branchAccessor].S.parentNode
|
|
1051
1068
|
) : (insertBranchBefore(
|
|
1052
|
-
|
|
1069
|
+
scope[branchAccessor] = createAndSetupBranch(
|
|
1053
1070
|
scope.$,
|
|
1054
|
-
|
|
1071
|
+
scope[rendererAccessor],
|
|
1055
1072
|
scope,
|
|
1056
|
-
|
|
1073
|
+
scope[nodeAccessor].parentNode
|
|
1057
1074
|
),
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
),
|
|
1061
|
-
let
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1075
|
+
scope[nodeAccessor].parentNode,
|
|
1076
|
+
scope[nodeAccessor]
|
|
1077
|
+
), scope[nodeAccessor].remove()), params?.(scope[branchAccessor], [data]), awaitCounter && (placeholderShown.add(pendingEffects), awaitCounter.c(), !awaitCounter.d)) {
|
|
1078
|
+
let fnScopes = /* @__PURE__ */ new Map(), effects = renderData.m();
|
|
1079
|
+
for (let i = 0; i < pendingEffects.length; ) {
|
|
1080
|
+
let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
|
|
1081
|
+
scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
|
|
1082
|
+
}
|
|
1083
|
+
for (let i = 0; i < effects.length; ) {
|
|
1084
|
+
let fn = effects[i++], scope2 = effects[i++];
|
|
1085
|
+
fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
|
|
1086
|
+
}
|
|
1069
1087
|
}
|
|
1070
1088
|
},
|
|
1071
1089
|
-1
|
|
1072
1090
|
));
|
|
1073
1091
|
},
|
|
1074
1092
|
(error) => {
|
|
1075
|
-
thisPromise === scope[promiseAccessor] && (
|
|
1093
|
+
thisPromise === scope[promiseAccessor] && (awaitCounter && (awaitCounter.i = 0), scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
|
|
1076
1094
|
}
|
|
1077
1095
|
);
|
|
1078
1096
|
};
|
|
1079
1097
|
}
|
|
1098
|
+
function _await_content(nodeAccessor, template, walks, setup) {
|
|
1099
|
+
let rendererAccessor = "D" /* ConditionalRenderer */ + decodeAccessor(nodeAccessor), renderer = _content("", template, walks, setup)();
|
|
1100
|
+
return (scope) => {
|
|
1101
|
+
scope[rendererAccessor] = renderer;
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1080
1104
|
function _try(nodeAccessor, template, walks, setup) {
|
|
1081
1105
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
1082
1106
|
let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
@@ -1097,7 +1121,7 @@ function renderCatch(scope, error) {
|
|
|
1097
1121
|
let tryWithCatch = findBranchWithKey(scope, "E" /* CatchContent */);
|
|
1098
1122
|
if (tryWithCatch) {
|
|
1099
1123
|
let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
|
|
1100
|
-
placeholderBranch && (tryWithCatch.O = 0, owner["A" /* BranchScopes */ + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
|
1124
|
+
placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" /* BranchScopes */ + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
|
|
1101
1125
|
owner,
|
|
1102
1126
|
tryWithCatch.C,
|
|
1103
1127
|
tryWithCatch.E,
|
|
@@ -1138,7 +1162,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1138
1162
|
let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1139
1163
|
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
1140
1164
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1141
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
|
1165
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
|
1142
1166
|
if (setConditionalRenderer(
|
|
1143
1167
|
scope,
|
|
1144
1168
|
nodeAccessor,
|
|
@@ -1153,13 +1177,13 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1153
1177
|
content,
|
|
1154
1178
|
createAndSetupBranch
|
|
1155
1179
|
), content.b && subscribeToScopeSet(
|
|
1156
|
-
content.
|
|
1180
|
+
content.e,
|
|
1157
1181
|
content.b,
|
|
1158
1182
|
scope[childScopeAccessor]["Aa"]
|
|
1159
1183
|
);
|
|
1160
1184
|
}
|
|
1161
1185
|
} else normalizedRenderer?.b && subscribeToScopeSet(
|
|
1162
|
-
normalizedRenderer.
|
|
1186
|
+
normalizedRenderer.e,
|
|
1163
1187
|
normalizedRenderer.b,
|
|
1164
1188
|
scope[childScopeAccessor]
|
|
1165
1189
|
);
|
|
@@ -1172,10 +1196,10 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1172
1196
|
(inputIsArgs ? args[0] : args) || {}
|
|
1173
1197
|
), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
|
|
1174
1198
|
else {
|
|
1175
|
-
for (let accessor in normalizedRenderer.
|
|
1176
|
-
normalizedRenderer.
|
|
1199
|
+
for (let accessor in normalizedRenderer.o)
|
|
1200
|
+
normalizedRenderer.o[accessor](
|
|
1177
1201
|
childScope,
|
|
1178
|
-
normalizedRenderer.
|
|
1202
|
+
normalizedRenderer.u[accessor]
|
|
1179
1203
|
);
|
|
1180
1204
|
if (normalizedRenderer.a)
|
|
1181
1205
|
if (inputIsArgs)
|
|
@@ -1273,17 +1297,17 @@ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caugh
|
|
|
1273
1297
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
|
|
1274
1298
|
let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
1275
1299
|
if (existingRender)
|
|
1276
|
-
existingRender.
|
|
1300
|
+
existingRender.q = value;
|
|
1277
1301
|
else {
|
|
1278
1302
|
let render = {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1303
|
+
f: key,
|
|
1304
|
+
k: scope,
|
|
1305
|
+
x: signal,
|
|
1306
|
+
q: value
|
|
1283
1307
|
}, i = pendingRenders.push(render) - 1;
|
|
1284
1308
|
for (; i; ) {
|
|
1285
1309
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
|
1286
|
-
if (key - parent.
|
|
1310
|
+
if (key - parent.f >= 0) break;
|
|
1287
1311
|
pendingRenders[i] = parent, i = parentIndex;
|
|
1288
1312
|
}
|
|
1289
1313
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
|
@@ -1319,27 +1343,27 @@ function runRenders() {
|
|
|
1319
1343
|
for (; pendingRenders.length; ) {
|
|
1320
1344
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
|
1321
1345
|
if (render !== item) {
|
|
1322
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
|
1346
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).f;
|
|
1323
1347
|
for (; i < mid; ) {
|
|
1324
1348
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
|
1325
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
|
1349
|
+
if (right < pendingRenders.length && pendingRenders[right].f - pendingRenders[bestChild].f < 0 && (bestChild = right), pendingRenders[bestChild].f - key >= 0)
|
|
1326
1350
|
break;
|
|
1327
1351
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
|
1328
1352
|
}
|
|
1329
1353
|
pendingRenders[i] = item;
|
|
1330
1354
|
}
|
|
1331
|
-
render.
|
|
1355
|
+
render.k.F?.I || runRender(render);
|
|
1332
1356
|
}
|
|
1333
1357
|
for (let scope of pendingScopes)
|
|
1334
1358
|
scope.H = 0;
|
|
1335
1359
|
pendingScopes = [];
|
|
1336
1360
|
}
|
|
1337
|
-
var runRender = (render) => render.
|
|
1361
|
+
var runRender = (render) => render.x(render.k, render.q), _enable_catch = () => {
|
|
1338
1362
|
_enable_catch = () => {
|
|
1339
1363
|
}, enableBranches();
|
|
1340
1364
|
let handlePendingTry = (fn, scope, branch) => {
|
|
1341
1365
|
for (; branch; ) {
|
|
1342
|
-
if (branch.O)
|
|
1366
|
+
if (branch.O?.i)
|
|
1343
1367
|
return (branch.J ||= []).push(fn, scope);
|
|
1344
1368
|
branch = branch.N;
|
|
1345
1369
|
}
|
|
@@ -1355,7 +1379,7 @@ var runRender = (render) => render.p(render.h, render.m), _enable_catch = () =>
|
|
|
1355
1379
|
try {
|
|
1356
1380
|
runRender2(render);
|
|
1357
1381
|
} catch (error) {
|
|
1358
|
-
renderCatch(render.
|
|
1382
|
+
renderCatch(render.k, error);
|
|
1359
1383
|
}
|
|
1360
1384
|
})(runRender);
|
|
1361
1385
|
};
|
|
@@ -1388,7 +1412,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1388
1412
|
_resume(RENDERER_REGISTER_ID, fn);
|
|
1389
1413
|
},
|
|
1390
1414
|
isRenderer(renderer) {
|
|
1391
|
-
return renderer.
|
|
1415
|
+
return renderer.h;
|
|
1392
1416
|
},
|
|
1393
1417
|
getStartNode(branch) {
|
|
1394
1418
|
return branch.S;
|
|
@@ -1410,7 +1434,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1410
1434
|
},
|
|
1411
1435
|
createRenderer(params, clone) {
|
|
1412
1436
|
let renderer = _content("", 0, 0, 0, params)();
|
|
1413
|
-
return renderer.
|
|
1437
|
+
return renderer.h = (branch) => {
|
|
1414
1438
|
let cloned = clone();
|
|
1415
1439
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
1416
1440
|
}, renderer;
|
|
@@ -1426,7 +1450,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1426
1450
|
branch || (created = 1, branch = component.scope = createAndSetupBranch(
|
|
1427
1451
|
out.global,
|
|
1428
1452
|
renderer,
|
|
1429
|
-
renderer.
|
|
1453
|
+
renderer.e,
|
|
1430
1454
|
document.body
|
|
1431
1455
|
)), renderer.a?.(branch, renderer._ ? args[0] : args);
|
|
1432
1456
|
}), created)
|
|
@@ -1476,7 +1500,7 @@ function mount(input = {}, reference, position) {
|
|
|
1476
1500
|
parentNode
|
|
1477
1501
|
), branch.T = (newValue) => {
|
|
1478
1502
|
curValue = newValue;
|
|
1479
|
-
}, this.
|
|
1503
|
+
}, this.j?.(branch), args?.(branch, input);
|
|
1480
1504
|
});
|
|
1481
1505
|
return insertChildNodes(
|
|
1482
1506
|
parentNode,
|
|
@@ -1533,7 +1557,8 @@ export {
|
|
|
1533
1557
|
_attrs_partial,
|
|
1534
1558
|
_attrs_partial_content,
|
|
1535
1559
|
_attrs_script,
|
|
1536
|
-
|
|
1560
|
+
_await_content,
|
|
1561
|
+
_await_promise,
|
|
1537
1562
|
_call,
|
|
1538
1563
|
_child_setup,
|
|
1539
1564
|
_closure,
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare function _script(scopeId: number, registryId: string): void;
|
|
|
22
22
|
export declare function _attr_content(nodeAccessor: Accessor, scopeId: number, content: unknown, serializeReason?: 1 | 0): void;
|
|
23
23
|
export declare function normalizeServerRender(value: unknown): ServerRenderer | undefined;
|
|
24
24
|
export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
|
|
25
|
+
export declare function withContext<T, U>(key: PropertyKey, value: unknown, cb: (value: U) => T, cbValue: U): T;
|
|
25
26
|
export declare function _var(parentScopeId: number, scopeOffsetAccessor: Accessor, childScopeId: number, registryId: string): void;
|
|
26
27
|
export declare function _resume<T extends WeakKey>(val: T, id: string, scopeId?: number): T;
|
|
27
28
|
export declare function _id(): string;
|
|
@@ -126,6 +127,7 @@ export declare class Chunk {
|
|
|
126
127
|
reorderId: string | null;
|
|
127
128
|
placeholderBody: Chunk | null;
|
|
128
129
|
placeholderRender: (() => void) | null;
|
|
130
|
+
placeholderBranchId: number | null;
|
|
129
131
|
constructor(boundary: Boundary, next: Chunk | null, context: Record<string | symbol, unknown> | null);
|
|
130
132
|
writeHTML(html: string): void;
|
|
131
133
|
writeEffect(scopeId: number, registryId: string): void;
|
package/dist/html.js
CHANGED
|
@@ -212,7 +212,7 @@ function forStepBy(by, index) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// src/html/inlined-runtimes.ts
|
|
215
|
-
var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,l,r,t={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})';
|
|
215
|
+
var WALKER_RUNTIME_CODE = '(e=>(self[e]||(self[e]=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>"#"&&d.push(e)}}),self[e]))', REORDER_RUNTIME_CODE = '(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),"#"==n?(t[a]=l).i++:"!"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):"T"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l["^"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})';
|
|
216
216
|
|
|
217
217
|
// src/html/serializer.ts
|
|
218
218
|
var kTouchedIterator = Symbol(), { hasOwnProperty } = {}, Generator = (function* () {
|
|
@@ -1151,7 +1151,7 @@ function writeScript(script) {
|
|
|
1151
1151
|
$chunk.writeScript(script);
|
|
1152
1152
|
}
|
|
1153
1153
|
function _script(scopeId, registryId) {
|
|
1154
|
-
$chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
|
|
1154
|
+
$chunk.context?.[kIsAsync] && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
|
|
1155
1155
|
}
|
|
1156
1156
|
function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
1157
1157
|
let shouldResume = serializeReason !== 0, render2 = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
@@ -1166,11 +1166,11 @@ function normalizeServerRender(value) {
|
|
|
1166
1166
|
return renderer;
|
|
1167
1167
|
}
|
|
1168
1168
|
var kPendingContexts = Symbol("Pending Contexts");
|
|
1169
|
-
function withContext(key, value, cb) {
|
|
1169
|
+
function withContext(key, value, cb, cbValue) {
|
|
1170
1170
|
let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
|
|
1171
1171
|
ctx[kPendingContexts]++, ctx[key] = value;
|
|
1172
1172
|
try {
|
|
1173
|
-
return cb();
|
|
1173
|
+
return cb(cbValue);
|
|
1174
1174
|
} finally {
|
|
1175
1175
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
|
1176
1176
|
}
|
|
@@ -1232,15 +1232,18 @@ function _hoist(scopeId, id) {
|
|
|
1232
1232
|
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1233
1233
|
}
|
|
1234
1234
|
function _resume_branch(scopeId) {
|
|
1235
|
-
let branchId = $chunk.context?.[
|
|
1235
|
+
let branchId = $chunk.context?.[kBranchId];
|
|
1236
1236
|
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { G: branchId });
|
|
1237
1237
|
}
|
|
1238
|
-
var
|
|
1238
|
+
var kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async");
|
|
1239
1239
|
function isInResumedBranch() {
|
|
1240
|
-
return $chunk?.context?.[
|
|
1240
|
+
return $chunk?.context?.[kBranchId] !== void 0;
|
|
1241
1241
|
}
|
|
1242
1242
|
function withBranchId(branchId, cb) {
|
|
1243
|
-
return withContext(
|
|
1243
|
+
return withContext(kBranchId, branchId, cb);
|
|
1244
|
+
}
|
|
1245
|
+
function withIsAsync(cb, value) {
|
|
1246
|
+
return withContext(kIsAsync, !0, cb, value);
|
|
1244
1247
|
}
|
|
1245
1248
|
function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1246
1249
|
let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
|
|
@@ -1440,14 +1443,14 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
1440
1443
|
let branchId = _peek_scope_id();
|
|
1441
1444
|
$chunk.writeHTML(
|
|
1442
1445
|
$chunk.boundary.state.mark("[" /* BranchStart */, "")
|
|
1443
|
-
), content
|
|
1446
|
+
), withIsAsync(content, value), $chunk.writeHTML(
|
|
1444
1447
|
$chunk.boundary.state.mark(
|
|
1445
1448
|
"]" /* BranchEnd */,
|
|
1446
1449
|
scopeId + " " + accessor + " " + branchId
|
|
1447
1450
|
)
|
|
1448
1451
|
);
|
|
1449
1452
|
} else
|
|
1450
|
-
content
|
|
1453
|
+
withIsAsync(content, value);
|
|
1451
1454
|
}), boundary.endAsync(chunk)));
|
|
1452
1455
|
},
|
|
1453
1456
|
(err) => {
|
|
@@ -1460,9 +1463,9 @@ function _try(scopeId, accessor, content, input) {
|
|
|
1460
1463
|
$chunk.writeHTML($chunk.boundary.state.mark("[" /* BranchStart */, ""));
|
|
1461
1464
|
let catchContent = normalizeDynamicRenderer(input.catch), placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
|
1462
1465
|
catchContent ? tryCatch(
|
|
1463
|
-
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
|
1466
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId) : content,
|
|
1464
1467
|
catchContent
|
|
1465
|
-
) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content(), writeScope(branchId, {
|
|
1468
|
+
) : placeholderContent ? tryPlaceholder(content, placeholderContent, branchId) : content(), writeScope(branchId, {
|
|
1466
1469
|
C: accessor,
|
|
1467
1470
|
E: catchContent,
|
|
1468
1471
|
Q: placeholderContent
|
|
@@ -1473,13 +1476,13 @@ function _try(scopeId, accessor, content, input) {
|
|
|
1473
1476
|
)
|
|
1474
1477
|
);
|
|
1475
1478
|
}
|
|
1476
|
-
function tryPlaceholder(content, placeholder) {
|
|
1479
|
+
function tryPlaceholder(content, placeholder, branchId) {
|
|
1477
1480
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
|
1478
1481
|
if (body === body.render(content)) {
|
|
1479
1482
|
chunk.append(body);
|
|
1480
1483
|
return;
|
|
1481
1484
|
}
|
|
1482
|
-
chunk.next = $chunk = new Chunk(boundary, chunk.next,
|
|
1485
|
+
chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.placeholderBody = body, chunk.placeholderRender = placeholder, chunk.placeholderBranchId = branchId;
|
|
1483
1486
|
}
|
|
1484
1487
|
function tryCatch(content, catchContent) {
|
|
1485
1488
|
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(content);
|
|
@@ -1589,14 +1592,12 @@ var Boundary = class extends AbortController {
|
|
|
1589
1592
|
reorderId = null;
|
|
1590
1593
|
placeholderBody = null;
|
|
1591
1594
|
placeholderRender = null;
|
|
1595
|
+
placeholderBranchId = null;
|
|
1592
1596
|
writeHTML(html) {
|
|
1593
1597
|
this.html += html;
|
|
1594
1598
|
}
|
|
1595
1599
|
writeEffect(scopeId, registryId) {
|
|
1596
|
-
this.lastEffect === registryId ? this.effects += "
|
|
1597
|
-
this.effects,
|
|
1598
|
-
'"' + registryId + '",' + scopeId
|
|
1599
|
-
));
|
|
1600
|
+
this.lastEffect === registryId ? this.effects += " " + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
|
|
1600
1601
|
}
|
|
1601
1602
|
writeScript(script) {
|
|
1602
1603
|
this.scripts = concatScripts(this.scripts, script);
|
|
@@ -1608,8 +1609,8 @@ var Boundary = class extends AbortController {
|
|
|
1608
1609
|
if (this.placeholderBody) {
|
|
1609
1610
|
let body = this.placeholderBody.consume();
|
|
1610
1611
|
if (body.async) {
|
|
1611
|
-
let { state } = this.boundary, reorderId = body.reorderId = state.nextReorderId();
|
|
1612
|
-
this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
|
|
1612
|
+
let { state } = this.boundary, reorderId = body.reorderId = this.placeholderBranchId ? this.placeholderBranchId + "" : state.nextReorderId();
|
|
1613
|
+
this.placeholderBranchId = null, this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
|
|
1613
1614
|
let after = this.render(this.placeholderRender);
|
|
1614
1615
|
after !== this && this.boundary.abort(
|
|
1615
1616
|
new Error("An @placeholder cannot contain async content.")
|
|
@@ -1646,7 +1647,7 @@ var Boundary = class extends AbortController {
|
|
|
1646
1647
|
if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
|
|
1647
1648
|
scripts,
|
|
1648
1649
|
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
|
1649
|
-
)), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes +
|
|
1650
|
+
)), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ',"' + effects + '"' : '"' + effects + '"'), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
|
1650
1651
|
scripts,
|
|
1651
1652
|
runtimePrefix + ".r.push(" + state.resumes + ")"
|
|
1652
1653
|
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
|
@@ -1675,10 +1676,10 @@ var Boundary = class extends AbortController {
|
|
|
1675
1676
|
runtimePrefix + ".r=[]"
|
|
1676
1677
|
)), reorderScripts = concatScripts(
|
|
1677
1678
|
reorderScripts,
|
|
1678
|
-
|
|
1679
|
+
'_.push("' + reorderEffects + '")'
|
|
1679
1680
|
)), scripts = concatScripts(
|
|
1680
1681
|
scripts,
|
|
1681
|
-
reorderScripts && runtimePrefix + ".j
|
|
1682
|
+
reorderScripts && runtimePrefix + ".j" /* Scripts */ + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"
|
|
1682
1683
|
), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1683
1684
|
}
|
|
1684
1685
|
state.writeReorders = null;
|
|
@@ -1701,7 +1702,7 @@ function flushSerializer(boundary) {
|
|
|
1701
1702
|
let scope = writeScopes[key], scopeId = getScopeId(scope), scopeIdDelta = scopeId - lastSerializedScopeId;
|
|
1702
1703
|
lastSerializedScopeId = scopeId + 1, scopeIdDelta && serializeData.push(scopeIdDelta), serializeData.push(scope);
|
|
1703
1704
|
}
|
|
1704
|
-
state.resumes =
|
|
1705
|
+
state.resumes = concatSequence(
|
|
1705
1706
|
state.resumes,
|
|
1706
1707
|
serializer.stringify(serializeData, boundary)
|
|
1707
1708
|
), state.lastSerializedScopeId = lastSerializedScopeId, state.writeScopes = null, flushed && (state.walkOnNextFlush = !0);
|
|
@@ -1711,6 +1712,9 @@ function _trailers(html) {
|
|
|
1711
1712
|
$chunk.boundary.state.trailerHTML += html;
|
|
1712
1713
|
}
|
|
1713
1714
|
function concatEffects(a, b) {
|
|
1715
|
+
return a ? b ? a + " " + b : a : b;
|
|
1716
|
+
}
|
|
1717
|
+
function concatSequence(a, b) {
|
|
1714
1718
|
return a ? b ? a + "," + b : a : b;
|
|
1715
1719
|
}
|
|
1716
1720
|
function concatScripts(a, b) {
|