marko 6.0.155 → 6.0.156
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/debug/dom.js +75 -16
- package/dist/debug/dom.mjs +75 -16
- 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 +1 -1
- package/dist/dom.js +89 -55
- package/dist/dom.mjs +89 -55
- package/dist/html/serializer.d.ts +1 -0
- package/dist/html/template.d.ts +2 -1
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.js +30 -10
- package/dist/html.mjs +30 -10
- package/dist/translator/index.js +25 -5
- package/dist/translator/util/entry-builder.d.ts +1 -0
- package/package.json +1 -1
- package/tags-html.d.ts +6 -0
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
|
}
|
|
@@ -164,10 +164,13 @@ function findBranchWithKey(scope, key) {
|
|
|
164
164
|
function destroyBranch(branch) {
|
|
165
165
|
branch.N?.D?.delete(
|
|
166
166
|
branch
|
|
167
|
-
),
|
|
167
|
+
), destroyNestedScopes(branch);
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
|
|
169
|
+
function destroyScope(scope) {
|
|
170
|
+
scope.I || (destroyNestedScopes(scope), resetControllers(scope));
|
|
171
|
+
}
|
|
172
|
+
function destroyNestedScopes(scope) {
|
|
173
|
+
scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
171
174
|
}
|
|
172
175
|
function resetControllers(scope) {
|
|
173
176
|
for (let id in scope.A)
|
|
@@ -261,9 +264,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
|
261
264
|
));
|
|
262
265
|
}
|
|
263
266
|
function _closure(...closureSignals) {
|
|
264
|
-
let [{
|
|
267
|
+
let [{ o: ___scopeInstancesAccessor, q: ___signalIndexAccessor }] = closureSignals;
|
|
265
268
|
for (let i = closureSignals.length; i--; )
|
|
266
|
-
closureSignals[i].
|
|
269
|
+
closureSignals[i].x = i;
|
|
267
270
|
return (scope) => {
|
|
268
271
|
if (scope[___scopeInstancesAccessor])
|
|
269
272
|
for (let childScope of scope[___scopeInstancesAccessor])
|
|
@@ -277,13 +280,13 @@ function _closure(...closureSignals) {
|
|
|
277
280
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
278
281
|
valueAccessor = decodeAccessor(valueAccessor);
|
|
279
282
|
let closureSignal = ((scope) => {
|
|
280
|
-
scope[closureSignal.
|
|
283
|
+
scope[closureSignal.q] = closureSignal.x, fn(scope), subscribeToScopeSet(
|
|
281
284
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
|
282
|
-
closureSignal.
|
|
285
|
+
closureSignal.o,
|
|
283
286
|
scope
|
|
284
287
|
);
|
|
285
288
|
});
|
|
286
|
-
return closureSignal.
|
|
289
|
+
return closureSignal.o = "B" /* ClosureScopes */ + valueAccessor, closureSignal.q = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
|
|
287
290
|
}
|
|
288
291
|
function _child_setup(setup) {
|
|
289
292
|
return setup._ = (scope, owner) => {
|
|
@@ -375,7 +378,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
375
378
|
// src/dom/renderer.ts
|
|
376
379
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
377
380
|
let branch = createScope($global);
|
|
378
|
-
return branch._ = renderer.
|
|
381
|
+
return branch._ = renderer.f || parentScope, setParentBranch(branch, parentScope?.F), renderer.k?.(
|
|
379
382
|
branch,
|
|
380
383
|
parentNode.namespaceURI
|
|
381
384
|
), branch;
|
|
@@ -390,7 +393,7 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
|
390
393
|
);
|
|
391
394
|
}
|
|
392
395
|
function setupBranch(renderer, branch) {
|
|
393
|
-
return renderer.
|
|
396
|
+
return renderer.l && queueRender(branch, renderer.l, -1), branch;
|
|
394
397
|
}
|
|
395
398
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
396
399
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
|
|
@@ -407,12 +410,12 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
407
410
|
);
|
|
408
411
|
};
|
|
409
412
|
return (owner) => ({
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
413
|
+
g: id,
|
|
414
|
+
k: clone,
|
|
415
|
+
f: owner,
|
|
416
|
+
l: setup,
|
|
417
|
+
d: params,
|
|
418
|
+
e: dynamicScopesAccessor
|
|
416
419
|
});
|
|
417
420
|
}
|
|
418
421
|
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
@@ -427,7 +430,7 @@ function _content_closures(renderer, closureFns) {
|
|
|
427
430
|
closureSignals[key] = _const(+key, closureFns[key]);
|
|
428
431
|
return (owner, closureValues) => {
|
|
429
432
|
let instance = renderer(owner);
|
|
430
|
-
return instance.
|
|
433
|
+
return instance.h = closureSignals, instance.t = closureValues, instance;
|
|
431
434
|
};
|
|
432
435
|
}
|
|
433
436
|
var cloneCache = {};
|
|
@@ -446,12 +449,31 @@ function createCloneableHTML(html, ns) {
|
|
|
446
449
|
}
|
|
447
450
|
|
|
448
451
|
// src/dom/resume.ts
|
|
449
|
-
var registeredValues = {}, branchesEnabled;
|
|
452
|
+
var registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled;
|
|
450
453
|
function enableBranches() {
|
|
451
454
|
branchesEnabled = 1;
|
|
452
455
|
}
|
|
456
|
+
var ready = /* @__PURE__ */ ((_) => (id) => {
|
|
457
|
+
readyLookup[id]?.(), readyLookup[id] = 1;
|
|
458
|
+
})(readyLookup = {});
|
|
459
|
+
function initEmbedded(readyId, runtimeId) {
|
|
460
|
+
embedEnabled = 1, ready(readyId), init(runtimeId), new MutationObserver(() => {
|
|
461
|
+
let renders = self[curRuntimeId];
|
|
462
|
+
for (let renderId in renders) {
|
|
463
|
+
let { s, n } = renders[renderId];
|
|
464
|
+
if (n && !n.isConnected) {
|
|
465
|
+
delete renders[renderId];
|
|
466
|
+
for (let id in s)
|
|
467
|
+
destroyScope(s[id]);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}).observe(document.body, { childList: !0, subtree: !0 });
|
|
471
|
+
}
|
|
453
472
|
function init(runtimeId = "M") {
|
|
454
|
-
|
|
473
|
+
if (curRuntimeId)
|
|
474
|
+
return;
|
|
475
|
+
curRuntimeId = runtimeId;
|
|
476
|
+
let resumeRender, renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders2) => {
|
|
455
477
|
defineRuntime({
|
|
456
478
|
value: resumeRender = ((renderId) => {
|
|
457
479
|
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = {
|
|
@@ -478,11 +500,19 @@ function init(runtimeId = "M") {
|
|
|
478
500
|
);
|
|
479
501
|
}
|
|
480
502
|
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
|
-
})(),
|
|
503
|
+
})(), nextToken = () => lastToken = visitText.slice(
|
|
482
504
|
lastTokenIndex,
|
|
483
505
|
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
|
|
484
|
-
);
|
|
506
|
+
), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0;
|
|
485
507
|
return render.m = (effects = []) => {
|
|
508
|
+
if (readyLookup) {
|
|
509
|
+
for (let readyId in render.b)
|
|
510
|
+
if (readyLookup[readyId] !== 1)
|
|
511
|
+
return readyLookup[readyId] = /* @__PURE__ */ ((prev) => () => {
|
|
512
|
+
render.m(), prev?.();
|
|
513
|
+
})(readyLookup[readyId]), effects;
|
|
514
|
+
render.b = 0;
|
|
515
|
+
}
|
|
486
516
|
for (let serialized of resumes = render.r || [])
|
|
487
517
|
if (typeof serialized == "string")
|
|
488
518
|
for (lastTokenIndex = 0, visitText = serialized; nextToken(); )
|
|
@@ -498,7 +528,10 @@ function init(runtimeId = "M") {
|
|
|
498
528
|
)), visitType === "*" /* Node */ ? visitScope[nextToken(
|
|
499
529
|
/* read accessor */
|
|
500
530
|
)] = visit.previousSibling : branchesEnabled && visitBranches();
|
|
501
|
-
return
|
|
531
|
+
return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(
|
|
532
|
+
new Text(),
|
|
533
|
+
visit.nextSibling
|
|
534
|
+
)), visits.length = resumes.length = 0, effects;
|
|
502
535
|
}, render.w = () => {
|
|
503
536
|
walk2(), runResumeEffects(render);
|
|
504
537
|
}, render;
|
|
@@ -880,15 +913,15 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
880
913
|
}
|
|
881
914
|
function _attr_content(scope, nodeAccessor, value) {
|
|
882
915
|
let content = normalizeClientRender(value);
|
|
883
|
-
scope["D" /* ConditionalRenderer */ + nodeAccessor] !== (scope["D" /* ConditionalRenderer */ + nodeAccessor] = content?.
|
|
916
|
+
scope["D" /* ConditionalRenderer */ + nodeAccessor] !== (scope["D" /* ConditionalRenderer */ + nodeAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.e && subscribeToScopeSet(
|
|
917
|
+
content.f,
|
|
884
918
|
content.e,
|
|
885
|
-
content.d,
|
|
886
919
|
scope["A" /* BranchScopes */ + nodeAccessor]
|
|
887
920
|
));
|
|
888
|
-
for (let accessor in content?.
|
|
889
|
-
content.
|
|
921
|
+
for (let accessor in content?.h)
|
|
922
|
+
content.h[accessor](
|
|
890
923
|
scope["A" /* BranchScopes */ + nodeAccessor],
|
|
891
|
-
content.
|
|
924
|
+
content.t[accessor]
|
|
892
925
|
);
|
|
893
926
|
}
|
|
894
927
|
function _attrs_script(scope, nodeAccessor) {
|
|
@@ -927,7 +960,7 @@ function _html(scope, value, accessor) {
|
|
|
927
960
|
}
|
|
928
961
|
function normalizeClientRender(value) {
|
|
929
962
|
let renderer = normalizeDynamicRenderer(value);
|
|
930
|
-
if (renderer && renderer.
|
|
963
|
+
if (renderer && renderer.g)
|
|
931
964
|
return renderer;
|
|
932
965
|
}
|
|
933
966
|
function normalizeAttrValue(value) {
|
|
@@ -1087,7 +1120,7 @@ function renderCatch(scope, error) {
|
|
|
1087
1120
|
tryWithCatch.C,
|
|
1088
1121
|
tryWithCatch.E,
|
|
1089
1122
|
createAndSetupBranch
|
|
1090
|
-
), tryWithCatch.E.
|
|
1123
|
+
), tryWithCatch.E.d?.(
|
|
1091
1124
|
owner["A" /* BranchScopes */ + tryWithCatch.C],
|
|
1092
1125
|
[error]
|
|
1093
1126
|
);
|
|
@@ -1123,7 +1156,7 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1123
1156
|
let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
|
|
1124
1157
|
return enableBranches(), (scope, newRenderer, getInput) => {
|
|
1125
1158
|
let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1126
|
-
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.
|
|
1159
|
+
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
|
|
1127
1160
|
if (setConditionalRenderer(
|
|
1128
1161
|
scope,
|
|
1129
1162
|
nodeAccessor,
|
|
@@ -1137,15 +1170,15 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1137
1170
|
"a",
|
|
1138
1171
|
content,
|
|
1139
1172
|
createAndSetupBranch
|
|
1140
|
-
), content.
|
|
1173
|
+
), content.e && subscribeToScopeSet(
|
|
1174
|
+
content.f,
|
|
1141
1175
|
content.e,
|
|
1142
|
-
content.d,
|
|
1143
1176
|
scope[childScopeAccessor]["Aa"]
|
|
1144
1177
|
);
|
|
1145
1178
|
}
|
|
1146
|
-
} else normalizedRenderer?.
|
|
1179
|
+
} else normalizedRenderer?.e && subscribeToScopeSet(
|
|
1180
|
+
normalizedRenderer.f,
|
|
1147
1181
|
normalizedRenderer.e,
|
|
1148
|
-
normalizedRenderer.d,
|
|
1149
1182
|
scope[childScopeAccessor]
|
|
1150
1183
|
);
|
|
1151
1184
|
if (normalizedRenderer) {
|
|
@@ -1157,20 +1190,20 @@ var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
|
1157
1190
|
(inputIsArgs ? args[0] : args) || {}
|
|
1158
1191
|
), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
|
|
1159
1192
|
else {
|
|
1160
|
-
for (let accessor in normalizedRenderer.
|
|
1161
|
-
normalizedRenderer.
|
|
1193
|
+
for (let accessor in normalizedRenderer.h)
|
|
1194
|
+
normalizedRenderer.h[accessor](
|
|
1162
1195
|
childScope,
|
|
1163
|
-
normalizedRenderer.
|
|
1196
|
+
normalizedRenderer.t[accessor]
|
|
1164
1197
|
);
|
|
1165
|
-
if (normalizedRenderer.
|
|
1198
|
+
if (normalizedRenderer.d)
|
|
1166
1199
|
if (inputIsArgs)
|
|
1167
|
-
normalizedRenderer.
|
|
1200
|
+
normalizedRenderer.d(
|
|
1168
1201
|
childScope,
|
|
1169
1202
|
normalizedRenderer._ ? args[0] : args
|
|
1170
1203
|
);
|
|
1171
1204
|
else {
|
|
1172
1205
|
let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
|
|
1173
|
-
normalizedRenderer.
|
|
1206
|
+
normalizedRenderer.d(
|
|
1174
1207
|
childScope,
|
|
1175
1208
|
normalizedRenderer._ ? inputWithContent : [inputWithContent]
|
|
1176
1209
|
);
|
|
@@ -1297,12 +1330,12 @@ function byFirstArg(name) {
|
|
|
1297
1330
|
var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
|
|
1298
1331
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
|
|
1299
1332
|
let key = scopeKey * scopeKeyOffset + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
|
|
1300
|
-
render ? render.
|
|
1333
|
+
render ? render.u = value : (queuePendingRender(
|
|
1301
1334
|
render = {
|
|
1302
1335
|
a: key,
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1336
|
+
j: scope,
|
|
1337
|
+
y: signal,
|
|
1338
|
+
u: value
|
|
1306
1339
|
}
|
|
1307
1340
|
), signalKey >= 0 && pendingRendersLookup.set(key, render));
|
|
1308
1341
|
}
|
|
@@ -1355,13 +1388,13 @@ function runRenders() {
|
|
|
1355
1388
|
}
|
|
1356
1389
|
pendingRenders[i] = item;
|
|
1357
1390
|
}
|
|
1358
|
-
render.
|
|
1391
|
+
render.j.F?.I || runRender(render);
|
|
1359
1392
|
}
|
|
1360
1393
|
for (let scope of pendingScopes)
|
|
1361
1394
|
scope.H = 0;
|
|
1362
1395
|
pendingScopes = [];
|
|
1363
1396
|
}
|
|
1364
|
-
var runRender = (render) => render.
|
|
1397
|
+
var runRender = (render) => render.y(render.j, render.u), _enable_catch = () => {
|
|
1365
1398
|
_enable_catch = () => {
|
|
1366
1399
|
}, enableBranches();
|
|
1367
1400
|
let handlePendingTry = (fn, scope, branch) => {
|
|
@@ -1380,7 +1413,7 @@ var runRender = (render) => render.u(render.h, render.q), _enable_catch = () =>
|
|
|
1380
1413
|
runEffects2(effects);
|
|
1381
1414
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
|
1382
1415
|
try {
|
|
1383
|
-
let branch = render.
|
|
1416
|
+
let branch = render.j.F;
|
|
1384
1417
|
for (; branch; ) {
|
|
1385
1418
|
if (branch.W)
|
|
1386
1419
|
return asyncRendersLookup.set(
|
|
@@ -1391,7 +1424,7 @@ var runRender = (render) => render.u(render.h, render.q), _enable_catch = () =>
|
|
|
1391
1424
|
}
|
|
1392
1425
|
runRender2(render);
|
|
1393
1426
|
} catch (error) {
|
|
1394
|
-
renderCatch(render.
|
|
1427
|
+
renderCatch(render.j, error);
|
|
1395
1428
|
}
|
|
1396
1429
|
})(runRender);
|
|
1397
1430
|
};
|
|
@@ -1424,7 +1457,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1424
1457
|
_resume(RENDERER_REGISTER_ID, fn);
|
|
1425
1458
|
},
|
|
1426
1459
|
isRenderer(renderer) {
|
|
1427
|
-
return renderer.
|
|
1460
|
+
return renderer.k;
|
|
1428
1461
|
},
|
|
1429
1462
|
getStartNode(branch) {
|
|
1430
1463
|
return branch.S;
|
|
@@ -1446,7 +1479,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1446
1479
|
},
|
|
1447
1480
|
createRenderer(params, clone) {
|
|
1448
1481
|
let renderer = _content("", 0, 0, 0, params)();
|
|
1449
|
-
return renderer.
|
|
1482
|
+
return renderer.k = (branch) => {
|
|
1450
1483
|
let cloned = clone();
|
|
1451
1484
|
branch.S = cloned.startNode, branch.K = cloned.endNode;
|
|
1452
1485
|
}, renderer;
|
|
@@ -1462,9 +1495,9 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
|
1462
1495
|
branch || (created = 1, branch = component.scope = createAndSetupBranch(
|
|
1463
1496
|
out.global,
|
|
1464
1497
|
renderer,
|
|
1465
|
-
renderer.
|
|
1498
|
+
renderer.f,
|
|
1466
1499
|
document.body
|
|
1467
|
-
)), renderer.
|
|
1500
|
+
)), renderer.d?.(branch, renderer._ ? args[0] : args);
|
|
1468
1501
|
}), created)
|
|
1469
1502
|
return toInsertNode(
|
|
1470
1503
|
branch.S,
|
|
@@ -1504,7 +1537,7 @@ function mount(input = {}, reference, position) {
|
|
|
1504
1537
|
parentNode = reference.parentNode, nextSibling = reference.nextSibling;
|
|
1505
1538
|
break;
|
|
1506
1539
|
}
|
|
1507
|
-
let curValue, args = this.
|
|
1540
|
+
let curValue, args = this.d, effects = prepareEffects(() => {
|
|
1508
1541
|
branch = createBranch(
|
|
1509
1542
|
$global,
|
|
1510
1543
|
this,
|
|
@@ -1512,7 +1545,7 @@ function mount(input = {}, reference, position) {
|
|
|
1512
1545
|
parentNode
|
|
1513
1546
|
), branch.T = (newValue) => {
|
|
1514
1547
|
curValue = newValue;
|
|
1515
|
-
}, this.
|
|
1548
|
+
}, this.l?.(branch), args?.(branch, input);
|
|
1516
1549
|
});
|
|
1517
1550
|
return insertChildNodes(
|
|
1518
1551
|
parentNode,
|
|
@@ -1627,5 +1660,6 @@ export {
|
|
|
1627
1660
|
forTo,
|
|
1628
1661
|
forUntil,
|
|
1629
1662
|
init,
|
|
1663
|
+
initEmbedded,
|
|
1630
1664
|
run
|
|
1631
1665
|
};
|
|
@@ -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
|
@@ -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;
|
package/dist/translator/index.js
CHANGED
|
@@ -2336,18 +2336,26 @@ var entry_builder_default = {
|
|
|
2336
2336
|
(it) => import_compiler9.types.importDeclaration([], import_compiler9.types.stringLiteral(it))
|
|
2337
2337
|
);
|
|
2338
2338
|
if (state.init) {
|
|
2339
|
+
const isPage = entryFile.path.node.extra.page;
|
|
2340
|
+
const initHelper = isPage ? "init" : "initEmbedded";
|
|
2339
2341
|
body.unshift(
|
|
2340
2342
|
import_compiler9.types.importDeclaration(
|
|
2341
|
-
[
|
|
2343
|
+
[
|
|
2344
|
+
import_compiler9.types.importSpecifier(
|
|
2345
|
+
import_compiler9.types.identifier(initHelper),
|
|
2346
|
+
import_compiler9.types.identifier(initHelper)
|
|
2347
|
+
)
|
|
2348
|
+
],
|
|
2342
2349
|
import_compiler9.types.stringLiteral(
|
|
2343
2350
|
`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
|
|
2344
2351
|
)
|
|
2345
2352
|
)
|
|
2346
2353
|
);
|
|
2347
2354
|
const { runtimeId } = entryFile.markoOpts;
|
|
2355
|
+
const readyId = !isPage && (0, import_babel_utils12.getTemplateId)(entryFile.markoOpts, entryFile.opts.filename);
|
|
2348
2356
|
const initExpression = import_compiler9.types.callExpression(
|
|
2349
|
-
import_compiler9.types.identifier(
|
|
2350
|
-
runtimeId ? [import_compiler9.types.stringLiteral(runtimeId)] : []
|
|
2357
|
+
import_compiler9.types.identifier(initHelper),
|
|
2358
|
+
readyId ? runtimeId ? [import_compiler9.types.stringLiteral(readyId), import_compiler9.types.stringLiteral(runtimeId)] : [import_compiler9.types.stringLiteral(readyId)] : runtimeId ? [import_compiler9.types.stringLiteral(runtimeId)] : []
|
|
2351
2359
|
);
|
|
2352
2360
|
body.push(
|
|
2353
2361
|
exportInit ? import_compiler9.types.exportDefaultDeclaration(
|
|
@@ -4802,7 +4810,8 @@ var html_default = {
|
|
|
4802
4810
|
callRuntime(
|
|
4803
4811
|
"_template",
|
|
4804
4812
|
import_compiler24.types.stringLiteral(program.hub.file.metadata.marko.id),
|
|
4805
|
-
contentId ? import_compiler24.types.identifier(contentId) : contentFn
|
|
4813
|
+
contentId ? import_compiler24.types.identifier(contentId) : contentFn,
|
|
4814
|
+
program.node.extra.page ? import_compiler24.types.numericLiteral(1) : void 0
|
|
4806
4815
|
)
|
|
4807
4816
|
);
|
|
4808
4817
|
if (contentId) {
|
|
@@ -5578,6 +5587,13 @@ var native_tag_default = {
|
|
|
5578
5587
|
);
|
|
5579
5588
|
}
|
|
5580
5589
|
const tagName = getCanonicalTagName(tag);
|
|
5590
|
+
switch (tagName) {
|
|
5591
|
+
case "html":
|
|
5592
|
+
case "body":
|
|
5593
|
+
case "head":
|
|
5594
|
+
(0, import_babel_utils21.getProgram)().node.extra.page ??= true;
|
|
5595
|
+
break;
|
|
5596
|
+
}
|
|
5581
5597
|
const isTextOnly = isTextOnlyNativeTag(tag);
|
|
5582
5598
|
const seen = {};
|
|
5583
5599
|
const { attributes } = tag.node;
|
|
@@ -12408,10 +12424,14 @@ var custom_tag_default = {
|
|
|
12408
12424
|
if (!childFile) {
|
|
12409
12425
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12410
12426
|
}
|
|
12411
|
-
const
|
|
12427
|
+
const programExtra = (0, import_babel_utils49.getProgram)().node.extra;
|
|
12428
|
+
const programSection = programExtra.section;
|
|
12412
12429
|
const childProgram = childFile.ast.program;
|
|
12413
12430
|
const childExtra = childProgram.extra;
|
|
12414
12431
|
const childSection = childExtra.section;
|
|
12432
|
+
if (childExtra.page) {
|
|
12433
|
+
programExtra.page ??= true;
|
|
12434
|
+
}
|
|
12415
12435
|
knownTagAnalyze(
|
|
12416
12436
|
tag,
|
|
12417
12437
|
childSection,
|
package/package.json
CHANGED
package/tags-html.d.ts
CHANGED
|
@@ -1393,6 +1393,12 @@ declare global {
|
|
|
1393
1393
|
*/
|
|
1394
1394
|
value?: AttrStringOrNumber;
|
|
1395
1395
|
|
|
1396
|
+
/**
|
|
1397
|
+
* Indicates that the file input allows the user to select a directory instead of a file.
|
|
1398
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
|
|
1399
|
+
*/
|
|
1400
|
+
webkitdirectory?: AttrBoolean;
|
|
1401
|
+
|
|
1396
1402
|
/**
|
|
1397
1403
|
* The width of an image input in pixels.
|
|
1398
1404
|
* @see https://html.spec.whatwg.org/multipage/embedded-content-other.html#attr-dim-width
|