marko 6.0.155 → 6.0.157
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/errors.d.ts +2 -0
- package/dist/debug/dom.js +91 -31
- package/dist/debug/dom.mjs +91 -31
- package/dist/debug/html.js +45 -8
- package/dist/debug/html.mjs +45 -8
- package/dist/dom/resume.d.ts +5 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +93 -55
- package/dist/dom.mjs +93 -55
- package/dist/html/serializer.d.ts +1 -0
- package/dist/html/template.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -1
- package/dist/html.js +30 -10
- package/dist/html.mjs +30 -10
- package/dist/translator/index.js +264 -185
- package/dist/translator/util/entry-builder.d.ts +1 -0
- package/dist/translator/util/references.d.ts +5 -1
- package/package.json +2 -2
- package/tags-html.d.ts +6 -0
package/dist/dom.mjs
CHANGED
|
@@ -13,6 +13,9 @@ function* attrTagIterator() {
|
|
|
13
13
|
// src/common/errors.ts
|
|
14
14
|
function _assert_hoist(value) {
|
|
15
15
|
}
|
|
16
|
+
function _assert_init(scope, accessor) {
|
|
17
|
+
return scope[accessor];
|
|
18
|
+
}
|
|
16
19
|
|
|
17
20
|
// src/common/for.ts
|
|
18
21
|
function forIn(obj, cb) {
|
|
@@ -76,7 +79,7 @@ function normalizeDynamicRenderer(value) {
|
|
|
76
79
|
if (value) {
|
|
77
80
|
if (typeof value == "string") return value;
|
|
78
81
|
let normalized = value.content || value.default || value;
|
|
79
|
-
if (/* @__KEY__ */ "
|
|
82
|
+
if (/* @__KEY__ */ "g" in normalized)
|
|
80
83
|
return normalized;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -164,10 +167,13 @@ function findBranchWithKey(scope, key) {
|
|
|
164
167
|
function destroyBranch(branch) {
|
|
165
168
|
branch.N?.D?.delete(
|
|
166
169
|
branch
|
|
167
|
-
),
|
|
170
|
+
), destroyNestedScopes(branch);
|
|
171
|
+
}
|
|
172
|
+
function destroyScope(scope) {
|
|
173
|
+
scope.I || (destroyNestedScopes(scope), resetControllers(scope));
|
|
168
174
|
}
|
|
169
|
-
function
|
|
170
|
-
|
|
175
|
+
function destroyNestedScopes(scope) {
|
|
176
|
+
scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
171
177
|
}
|
|
172
178
|
function resetControllers(scope) {
|
|
173
179
|
for (let id in scope.A)
|
|
@@ -261,9 +267,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
|
261
267
|
));
|
|
262
268
|
}
|
|
263
269
|
function _closure(...closureSignals) {
|
|
264
|
-
let [{
|
|
270
|
+
let [{ o: ___scopeInstancesAccessor, q: ___signalIndexAccessor }] = closureSignals;
|
|
265
271
|
for (let i = closureSignals.length; i--; )
|
|
266
|
-
closureSignals[i].
|
|
272
|
+
closureSignals[i].x = i;
|
|
267
273
|
return (scope) => {
|
|
268
274
|
if (scope[___scopeInstancesAccessor])
|
|
269
275
|
for (let childScope of scope[___scopeInstancesAccessor])
|
|
@@ -277,13 +283,13 @@ function _closure(...closureSignals) {
|
|
|
277
283
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
278
284
|
valueAccessor = decodeAccessor(valueAccessor);
|
|
279
285
|
let closureSignal = ((scope) => {
|
|
280
|
-
scope[closureSignal.
|
|
286
|
+
scope[closureSignal.q] = closureSignal.x, fn(scope), subscribeToScopeSet(
|
|
281
287
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
|
282
|
-
closureSignal.
|
|
288
|
+
closureSignal.o,
|
|
283
289
|
scope
|
|
284
290
|
);
|
|
285
291
|
});
|
|
286
|
-
return closureSignal.
|
|
292
|
+
return closureSignal.o = "B" /* ClosureScopes */ + valueAccessor, closureSignal.q = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
|
|
287
293
|
}
|
|
288
294
|
function _child_setup(setup) {
|
|
289
295
|
return setup._ = (scope, owner) => {
|
|
@@ -375,7 +381,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
375
381
|
// src/dom/renderer.ts
|
|
376
382
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
377
383
|
let branch = createScope($global);
|
|
378
|
-
return branch._ = renderer.
|
|
384
|
+
return branch._ = renderer.f || parentScope, setParentBranch(branch, parentScope?.F), renderer.k?.(
|
|
379
385
|
branch,
|
|
380
386
|
parentNode.namespaceURI
|
|
381
387
|
), branch;
|
|
@@ -390,7 +396,7 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
|
390
396
|
);
|
|
391
397
|
}
|
|
392
398
|
function setupBranch(renderer, branch) {
|
|
393
|
-
return renderer.
|
|
399
|
+
return renderer.l && queueRender(branch, renderer.l, -1), branch;
|
|
394
400
|
}
|
|
395
401
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
396
402
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
|
|
@@ -407,12 +413,12 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
407
413
|
);
|
|
408
414
|
};
|
|
409
415
|
return (owner) => ({
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
+
g: id,
|
|
417
|
+
k: clone,
|
|
418
|
+
f: owner,
|
|
419
|
+
l: setup,
|
|
420
|
+
d: params,
|
|
421
|
+
e: dynamicScopesAccessor
|
|
416
422
|
});
|
|
417
423
|
}
|
|
418
424
|
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
@@ -427,7 +433,7 @@ function _content_closures(renderer, closureFns) {
|
|
|
427
433
|
closureSignals[key] = _const(+key, closureFns[key]);
|
|
428
434
|
return (owner, closureValues) => {
|
|
429
435
|
let instance = renderer(owner);
|
|
430
|
-
return instance.
|
|
436
|
+
return instance.h = closureSignals, instance.t = closureValues, instance;
|
|
431
437
|
};
|
|
432
438
|
}
|
|
433
439
|
var cloneCache = {};
|
|
@@ -446,12 +452,31 @@ function createCloneableHTML(html, ns) {
|
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
// src/dom/resume.ts
|
|
449
|
-
var registeredValues = {}, branchesEnabled;
|
|
455
|
+
var registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled;
|
|
450
456
|
function enableBranches() {
|
|
451
457
|
branchesEnabled = 1;
|
|
452
458
|
}
|
|
459
|
+
var ready = /* @__PURE__ */ ((_) => (id) => {
|
|
460
|
+
readyLookup[id]?.(), readyLookup[id] = 1;
|
|
461
|
+
})(readyLookup = {});
|
|
462
|
+
function initEmbedded(readyId, runtimeId) {
|
|
463
|
+
embedEnabled = 1, ready(readyId), init(runtimeId), new MutationObserver(() => {
|
|
464
|
+
let renders = self[curRuntimeId];
|
|
465
|
+
for (let renderId in renders) {
|
|
466
|
+
let { s, n } = renders[renderId];
|
|
467
|
+
if (n && !n.isConnected) {
|
|
468
|
+
delete renders[renderId];
|
|
469
|
+
for (let id in s)
|
|
470
|
+
destroyScope(s[id]);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}).observe(document.body, { childList: !0, subtree: !0 });
|
|
474
|
+
}
|
|
453
475
|
function init(runtimeId = "M") {
|
|
454
|
-
|
|
476
|
+
if (curRuntimeId)
|
|
477
|
+
return;
|
|
478
|
+
curRuntimeId = runtimeId;
|
|
479
|
+
let resumeRender, renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders2) => {
|
|
455
480
|
defineRuntime({
|
|
456
481
|
value: resumeRender = ((renderId) => {
|
|
457
482
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = {
|
|
@@ -478,11 +503,19 @@ function init(runtimeId = "M") {
|
|
|
478
503
|
);
|
|
479
504
|
}
|
|
480
505
|
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));
|
|
481
|
-
})(),
|
|
506
|
+
})(), nextToken = () => lastToken = visitText.slice(
|
|
482
507
|
lastTokenIndex,
|
|
483
508
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
|
|
484
|
-
);
|
|
509
|
+
), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0;
|
|
485
510
|
return render.m = (effects = []) => {
|
|
511
|
+
if (readyLookup) {
|
|
512
|
+
for (let readyId in render.b)
|
|
513
|
+
if (readyLookup[readyId] !== 1)
|
|
514
|
+
return readyLookup[readyId] = /* @__PURE__ */ ((prev) => () => {
|
|
515
|
+
render.m(), prev?.();
|
|
516
|
+
})(readyLookup[readyId]), effects;
|
|
517
|
+
render.b = 0;
|
|
518
|
+
}
|
|
486
519
|
for (let serialized of resumes = render.r || [])
|
|
487
520
|
if (typeof serialized == "string")
|
|
488
521
|
for (lastTokenIndex = 0, visitText = serialized; nextToken(); )
|
|
@@ -498,7 +531,10 @@ function init(runtimeId = "M") {
|
|
|
498
531
|
)), visitType === "*" /* Node */ ? visitScope[nextToken(
|
|
499
532
|
/* read accessor */
|
|
500
533
|
)] = visit.previousSibling : branchesEnabled && visitBranches();
|
|
501
|
-
return
|
|
534
|
+
return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(
|
|
535
|
+
new Text(),
|
|
536
|
+
visit.nextSibling
|
|
537
|
+
)), visits.length = resumes.length = 0, effects;
|
|
502
538
|
}, render.w = () => {
|
|
503
539
|
walk2(), runResumeEffects(render);
|
|
504
540
|
}, render;
|
|
@@ -880,15 +916,15 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
880
916
|
}
|
|
881
917
|
function _attr_content(scope, nodeAccessor, value) {
|
|
882
918
|
let content = normalizeClientRender(value);
|
|
883
|
-
scope["D" /* ConditionalRenderer */ + nodeAccessor] !== (scope["D" /* ConditionalRenderer */ + nodeAccessor] = content?.
|
|
919
|
+
scope["D" /* ConditionalRenderer */ + nodeAccessor] !== (scope["D" /* ConditionalRenderer */ + nodeAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.e && subscribeToScopeSet(
|
|
920
|
+
content.f,
|
|
884
921
|
content.e,
|
|
885
|
-
content.d,
|
|
886
922
|
scope["A" /* BranchScopes */ + nodeAccessor]
|
|
887
923
|
));
|
|
888
|
-
for (let accessor in content?.
|
|
889
|
-
content.
|
|
924
|
+
for (let accessor in content?.h)
|
|
925
|
+
content.h[accessor](
|
|
890
926
|
scope["A" /* BranchScopes */ + nodeAccessor],
|
|
891
|
-
content.
|
|
927
|
+
content.t[accessor]
|
|
892
928
|
);
|
|
893
929
|
}
|
|
894
930
|
function _attrs_script(scope, nodeAccessor) {
|
|
@@ -927,7 +963,7 @@ function _html(scope, value, accessor) {
|
|
|
927
963
|
}
|
|
928
964
|
function normalizeClientRender(value) {
|
|
929
965
|
let renderer = normalizeDynamicRenderer(value);
|
|
930
|
-
if (renderer && renderer.
|
|
966
|
+
if (renderer && renderer.g)
|
|
931
967
|
return renderer;
|
|
932
968
|
}
|
|
933
969
|
function normalizeAttrValue(value) {
|
|
@@ -1087,7 +1123,7 @@ function renderCatch(scope, error) {
|
|
|
1087
1123
|
tryWithCatch.C,
|
|
1088
1124
|
tryWithCatch.E,
|
|
1089
1125
|
createAndSetupBranch
|
|
1090
|
-
), tryWithCatch.E.
|
|
1126
|
+
), tryWithCatch.E.d?.(
|
|
1091
1127
|
owner["A" /* BranchScopes */ + tryWithCatch.C],
|
|
1092
1128
|
[error]
|
|
1093
1129
|
);
|
|
@@ -1123,7 +1159,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1123
1159
|
let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1124
1160
|
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
1125
1161
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1126
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
|
1162
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
|
1127
1163
|
if (setConditionalRenderer(
|
|
1128
1164
|
scope,
|
|
1129
1165
|
nodeAccessor,
|
|
@@ -1137,15 +1173,15 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1137
1173
|
"a",
|
|
1138
1174
|
content,
|
|
1139
1175
|
createAndSetupBranch
|
|
1140
|
-
), content.
|
|
1176
|
+
), content.e && subscribeToScopeSet(
|
|
1177
|
+
content.f,
|
|
1141
1178
|
content.e,
|
|
1142
|
-
content.d,
|
|
1143
1179
|
scope[childScopeAccessor]["Aa"]
|
|
1144
1180
|
);
|
|
1145
1181
|
}
|
|
1146
|
-
} else normalizedRenderer?.
|
|
1182
|
+
} else normalizedRenderer?.e && subscribeToScopeSet(
|
|
1183
|
+
normalizedRenderer.f,
|
|
1147
1184
|
normalizedRenderer.e,
|
|
1148
|
-
normalizedRenderer.d,
|
|
1149
1185
|
scope[childScopeAccessor]
|
|
1150
1186
|
);
|
|
1151
1187
|
if (normalizedRenderer) {
|
|
@@ -1157,20 +1193,20 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1157
1193
|
(inputIsArgs ? args[0] : args) || {}
|
|
1158
1194
|
), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
|
|
1159
1195
|
else {
|
|
1160
|
-
for (let accessor in normalizedRenderer.
|
|
1161
|
-
normalizedRenderer.
|
|
1196
|
+
for (let accessor in normalizedRenderer.h)
|
|
1197
|
+
normalizedRenderer.h[accessor](
|
|
1162
1198
|
childScope,
|
|
1163
|
-
normalizedRenderer.
|
|
1199
|
+
normalizedRenderer.t[accessor]
|
|
1164
1200
|
);
|
|
1165
|
-
if (normalizedRenderer.
|
|
1201
|
+
if (normalizedRenderer.d)
|
|
1166
1202
|
if (inputIsArgs)
|
|
1167
|
-
normalizedRenderer.
|
|
1203
|
+
normalizedRenderer.d(
|
|
1168
1204
|
childScope,
|
|
1169
1205
|
normalizedRenderer._ ? args[0] : args
|
|
1170
1206
|
);
|
|
1171
1207
|
else {
|
|
1172
1208
|
let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
|
1173
|
-
normalizedRenderer.
|
|
1209
|
+
normalizedRenderer.d(
|
|
1174
1210
|
childScope,
|
|
1175
1211
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
|
1176
1212
|
);
|
|
@@ -1297,12 +1333,12 @@ function byFirstArg(name) {
|
|
|
1297
1333
|
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
|
|
1298
1334
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
|
|
1299
1335
|
let key = scopeKey * scopeKeyOffset + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
1300
|
-
render ? render.
|
|
1336
|
+
render ? render.u = value : (queuePendingRender(
|
|
1301
1337
|
render = {
|
|
1302
1338
|
a: key,
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1339
|
+
j: scope,
|
|
1340
|
+
y: signal,
|
|
1341
|
+
u: value
|
|
1306
1342
|
}
|
|
1307
1343
|
), signalKey >= 0 && pendingRendersLookup.set(key, render));
|
|
1308
1344
|
}
|
|
@@ -1355,13 +1391,13 @@ function runRenders() {
|
|
|
1355
1391
|
}
|
|
1356
1392
|
pendingRenders[i] = item;
|
|
1357
1393
|
}
|
|
1358
|
-
render.
|
|
1394
|
+
render.j.F?.I || runRender(render);
|
|
1359
1395
|
}
|
|
1360
1396
|
for (let scope of pendingScopes)
|
|
1361
1397
|
scope.H = 0;
|
|
1362
1398
|
pendingScopes = [];
|
|
1363
1399
|
}
|
|
1364
|
-
var runRender = (render) => render.
|
|
1400
|
+
var runRender = (render) => render.y(render.j, render.u), _enable_catch = () => {
|
|
1365
1401
|
_enable_catch = () => {
|
|
1366
1402
|
}, enableBranches();
|
|
1367
1403
|
let handlePendingTry = (fn, scope, branch) => {
|
|
@@ -1380,7 +1416,7 @@ var runRender = (render) => render.u(render.h, render.q), _enable_catch = () =>
|
|
|
1380
1416
|
runEffects2(effects);
|
|
1381
1417
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
|
1382
1418
|
try {
|
|
1383
|
-
let branch = render.
|
|
1419
|
+
let branch = render.j.F;
|
|
1384
1420
|
for (; branch; ) {
|
|
1385
1421
|
if (branch.W)
|
|
1386
1422
|
return asyncRendersLookup.set(
|
|
@@ -1391,7 +1427,7 @@ var runRender = (render) => render.u(render.h, render.q), _enable_catch = () =>
|
|
|
1391
1427
|
}
|
|
1392
1428
|
runRender2(render);
|
|
1393
1429
|
} catch (error) {
|
|
1394
|
-
renderCatch(render.
|
|
1430
|
+
renderCatch(render.j, error);
|
|
1395
1431
|
}
|
|
1396
1432
|
})(runRender);
|
|
1397
1433
|
};
|
|
@@ -1424,7 +1460,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1424
1460
|
_resume(RENDERER_REGISTER_ID, fn);
|
|
1425
1461
|
},
|
|
1426
1462
|
isRenderer(renderer) {
|
|
1427
|
-
return renderer.
|
|
1463
|
+
return renderer.k;
|
|
1428
1464
|
},
|
|
1429
1465
|
getStartNode(branch) {
|
|
1430
1466
|
return branch.S;
|
|
@@ -1446,7 +1482,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1446
1482
|
},
|
|
1447
1483
|
createRenderer(params, clone) {
|
|
1448
1484
|
let renderer = _content("", 0, 0, 0, params)();
|
|
1449
|
-
return renderer.
|
|
1485
|
+
return renderer.k = (branch) => {
|
|
1450
1486
|
let cloned = clone();
|
|
1451
1487
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
1452
1488
|
}, renderer;
|
|
@@ -1462,9 +1498,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1462
1498
|
branch || (created = 1, branch = component.scope = createAndSetupBranch(
|
|
1463
1499
|
out.global,
|
|
1464
1500
|
renderer,
|
|
1465
|
-
renderer.
|
|
1501
|
+
renderer.f,
|
|
1466
1502
|
document.body
|
|
1467
|
-
)), renderer.
|
|
1503
|
+
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
|
1468
1504
|
}), created)
|
|
1469
1505
|
return toInsertNode(
|
|
1470
1506
|
branch.S,
|
|
@@ -1504,7 +1540,7 @@ function mount(input = {}, reference, position) {
|
|
|
1504
1540
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
|
1505
1541
|
break;
|
|
1506
1542
|
}
|
|
1507
|
-
let curValue, args = this.
|
|
1543
|
+
let curValue, args = this.d, effects = prepareEffects(() => {
|
|
1508
1544
|
branch = createBranch(
|
|
1509
1545
|
$global,
|
|
1510
1546
|
this,
|
|
@@ -1512,7 +1548,7 @@ function mount(input = {}, reference, position) {
|
|
|
1512
1548
|
parentNode
|
|
1513
1549
|
), branch.T = (newValue) => {
|
|
1514
1550
|
curValue = newValue;
|
|
1515
|
-
}, this.
|
|
1551
|
+
}, this.l?.(branch), args?.(branch, input);
|
|
1516
1552
|
});
|
|
1517
1553
|
return insertChildNodes(
|
|
1518
1554
|
parentNode,
|
|
@@ -1542,6 +1578,7 @@ export {
|
|
|
1542
1578
|
$signal,
|
|
1543
1579
|
$signalReset,
|
|
1544
1580
|
_assert_hoist,
|
|
1581
|
+
_assert_init,
|
|
1545
1582
|
_attr,
|
|
1546
1583
|
_attr_class,
|
|
1547
1584
|
_attr_class_item,
|
|
@@ -1627,5 +1664,6 @@ export {
|
|
|
1627
1664
|
forTo,
|
|
1628
1665
|
forUntil,
|
|
1629
1666
|
init,
|
|
1667
|
+
initEmbedded,
|
|
1630
1668
|
run
|
|
1631
1669
|
};
|
|
@@ -16,4 +16,5 @@ export declare function getRegistered(val: WeakKey): {
|
|
|
16
16
|
scope: unknown;
|
|
17
17
|
} | undefined;
|
|
18
18
|
export declare function stringify(val: unknown): string;
|
|
19
|
+
export declare function toObjectKey(name: string): string;
|
|
19
20
|
export declare function toAccess(accessor: string): string;
|
package/dist/html/template.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Template } from "../common/types";
|
|
2
2
|
export type ServerRenderer = ((...args: unknown[]) => unknown) & {
|
|
3
3
|
___id?: string;
|
|
4
|
+
___embed?: boolean;
|
|
4
5
|
};
|
|
5
|
-
export declare const _template: (templateId: string, renderer: ServerRenderer) => Template;
|
|
6
|
+
export declare const _template: (templateId: string, renderer: ServerRenderer, page?: 1) => Template;
|
|
6
7
|
export declare function isTemplate(renderer: ServerRenderer | Template): renderer is ServerRenderer & Template;
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare function getScopeById(scopeId: number | undefined): PartialScope
|
|
|
34
34
|
export declare function _set_serialize_reason(reason: undefined | 0 | 1): void;
|
|
35
35
|
export declare function _scope_reason(): 0 | 1 | undefined;
|
|
36
36
|
export declare function _serialize_if(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
|
|
37
|
-
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string):
|
|
37
|
+
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string): 0 | 1;
|
|
38
38
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
39
39
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
40
40
|
export declare function _el(scopeId: number, id: string): () => void;
|
|
@@ -90,6 +90,7 @@ export declare class State {
|
|
|
90
90
|
writeReorders: Chunk[] | null;
|
|
91
91
|
scopes: Map<number, PartialScope>;
|
|
92
92
|
writeScopes: null | Record<number, PartialScope>;
|
|
93
|
+
ensureReady: null | Record<string, 0 | 1>;
|
|
93
94
|
serializeReason: undefined | 0 | 1;
|
|
94
95
|
constructor($global: $Global & {
|
|
95
96
|
renderId: string;
|
package/dist/html.js
CHANGED
|
@@ -1549,6 +1549,7 @@ var State2 = class {
|
|
|
1549
1549
|
writeReorders = null;
|
|
1550
1550
|
scopes = /* @__PURE__ */ new Map();
|
|
1551
1551
|
writeScopes = null;
|
|
1552
|
+
ensureReady = null;
|
|
1552
1553
|
serializeReason;
|
|
1553
1554
|
get runtimePrefix() {
|
|
1554
1555
|
let { $global: $global2 } = this;
|
|
@@ -1664,7 +1665,18 @@ var Boundary = class extends AbortController {
|
|
|
1664
1665
|
if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
|
|
1665
1666
|
scripts,
|
|
1666
1667
|
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
|
1667
|
-
)),
|
|
1668
|
+
)), state.ensureReady && state.hasMainRuntime) {
|
|
1669
|
+
let first = !0;
|
|
1670
|
+
for (let id in state.ensureReady)
|
|
1671
|
+
state.ensureReady[id] && (state.ensureReady[id] = 0, first ? scripts = concatScripts(
|
|
1672
|
+
scripts,
|
|
1673
|
+
"(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1"
|
|
1674
|
+
) : scripts = concatScripts(
|
|
1675
|
+
scripts,
|
|
1676
|
+
runtimePrefix + ".b" /* Blocking */ + toAccess(toObjectKey(id)) + "=1"
|
|
1677
|
+
)), first = !1;
|
|
1678
|
+
}
|
|
1679
|
+
if (effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ',"' + effects + '"' : '"' + effects + '"'), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
|
1668
1680
|
scripts,
|
|
1669
1681
|
runtimePrefix + ".r.push(" + state.resumes + ")"
|
|
1670
1682
|
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
|
@@ -2198,20 +2210,28 @@ function NOOP2() {
|
|
|
2198
2210
|
}
|
|
2199
2211
|
|
|
2200
2212
|
// src/html/template.ts
|
|
2201
|
-
var _template = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, _content_resume(templateId, renderer));
|
|
2213
|
+
var _template = (templateId, renderer, page) => (renderer.render = render, renderer.b = !page, renderer._ = renderer, _content_resume(templateId, renderer));
|
|
2202
2214
|
function render(input = {}) {
|
|
2203
2215
|
let { $global: $global2 } = input;
|
|
2204
2216
|
$global2 ? ({ $global: $global2, ...input } = input, $global2 = {
|
|
2205
2217
|
runtimeId: "M",
|
|
2206
|
-
renderId:
|
|
2218
|
+
renderId: getDefaultRenderId(this),
|
|
2207
2219
|
...$global2
|
|
2208
|
-
}) : $global2 = {
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
);
|
|
2214
|
-
|
|
2220
|
+
}) : $global2 = {
|
|
2221
|
+
runtimeId: "M",
|
|
2222
|
+
renderId: getDefaultRenderId(this)
|
|
2223
|
+
};
|
|
2224
|
+
let state = new State2($global2), head = new Chunk(new Boundary(state, $global2.signal), null, null);
|
|
2225
|
+
return this.b && ((state.ensureReady ||= {})[this.a] = 1), head.render(this, input), new ServerRendered(head);
|
|
2226
|
+
}
|
|
2227
|
+
function getDefaultRenderId(template) {
|
|
2228
|
+
if (template.b) {
|
|
2229
|
+
let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 53];
|
|
2230
|
+
for (n = n / 53 | 0; n; n >>>= 6)
|
|
2231
|
+
r += ENCODE_CHARS[n & 63];
|
|
2232
|
+
return r;
|
|
2233
|
+
}
|
|
2234
|
+
return "_";
|
|
2215
2235
|
}
|
|
2216
2236
|
var ServerRendered = class {
|
|
2217
2237
|
#head;
|
package/dist/html.mjs
CHANGED
|
@@ -1459,6 +1459,7 @@ var State2 = class {
|
|
|
1459
1459
|
writeReorders = null;
|
|
1460
1460
|
scopes = /* @__PURE__ */ new Map();
|
|
1461
1461
|
writeScopes = null;
|
|
1462
|
+
ensureReady = null;
|
|
1462
1463
|
serializeReason;
|
|
1463
1464
|
get runtimePrefix() {
|
|
1464
1465
|
let { $global: $global2 } = this;
|
|
@@ -1574,7 +1575,18 @@ var Boundary = class extends AbortController {
|
|
|
1574
1575
|
if (needsWalk && (state.walkOnNextFlush = !1), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
|
|
1575
1576
|
scripts,
|
|
1576
1577
|
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
|
1577
|
-
)),
|
|
1578
|
+
)), state.ensureReady && state.hasMainRuntime) {
|
|
1579
|
+
let first = !0;
|
|
1580
|
+
for (let id in state.ensureReady)
|
|
1581
|
+
state.ensureReady[id] && (state.ensureReady[id] = 0, first ? scripts = concatScripts(
|
|
1582
|
+
scripts,
|
|
1583
|
+
"(" + runtimePrefix + ".b={})" + toAccess(toObjectKey(id)) + "=1"
|
|
1584
|
+
) : scripts = concatScripts(
|
|
1585
|
+
scripts,
|
|
1586
|
+
runtimePrefix + ".b" /* Blocking */ + toAccess(toObjectKey(id)) + "=1"
|
|
1587
|
+
)), first = !1;
|
|
1588
|
+
}
|
|
1589
|
+
if (effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ',"' + effects + '"' : '"' + effects + '"'), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
|
1578
1590
|
scripts,
|
|
1579
1591
|
runtimePrefix + ".r.push(" + state.resumes + ")"
|
|
1580
1592
|
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
|
@@ -2108,20 +2120,28 @@ function NOOP2() {
|
|
|
2108
2120
|
}
|
|
2109
2121
|
|
|
2110
2122
|
// src/html/template.ts
|
|
2111
|
-
var _template = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, _content_resume(templateId, renderer));
|
|
2123
|
+
var _template = (templateId, renderer, page) => (renderer.render = render, renderer.b = !page, renderer._ = renderer, _content_resume(templateId, renderer));
|
|
2112
2124
|
function render(input = {}) {
|
|
2113
2125
|
let { $global: $global2 } = input;
|
|
2114
2126
|
$global2 ? ({ $global: $global2, ...input } = input, $global2 = {
|
|
2115
2127
|
runtimeId: "M",
|
|
2116
|
-
renderId:
|
|
2128
|
+
renderId: getDefaultRenderId(this),
|
|
2117
2129
|
...$global2
|
|
2118
|
-
}) : $global2 = {
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
);
|
|
2124
|
-
|
|
2130
|
+
}) : $global2 = {
|
|
2131
|
+
runtimeId: "M",
|
|
2132
|
+
renderId: getDefaultRenderId(this)
|
|
2133
|
+
};
|
|
2134
|
+
let state = new State2($global2), head = new Chunk(new Boundary(state, $global2.signal), null, null);
|
|
2135
|
+
return this.b && ((state.ensureReady ||= {})[this.a] = 1), head.render(this, input), new ServerRendered(head);
|
|
2136
|
+
}
|
|
2137
|
+
function getDefaultRenderId(template) {
|
|
2138
|
+
if (template.b) {
|
|
2139
|
+
let ENCODE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", n = Math.random() * 4294967296 >>> 0, r = ENCODE_CHARS[n % 53];
|
|
2140
|
+
for (n = n / 53 | 0; n; n >>>= 6)
|
|
2141
|
+
r += ENCODE_CHARS[n & 63];
|
|
2142
|
+
return r;
|
|
2143
|
+
}
|
|
2144
|
+
return "_";
|
|
2125
2145
|
}
|
|
2126
2146
|
var ServerRendered = class {
|
|
2127
2147
|
#head;
|