marko 6.4.1 → 6.4.2
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/cheatsheet.md +1 -1
- package/dist/common/errors.d.ts +1 -0
- package/dist/common/opt.d.ts +1 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +1 -1
- package/dist/debug/dom/lazy.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-ClV4kVOO.js → dom-BLbR0hEx.js} +30 -0
- package/dist/debug/{dom-LFrKxOk5.mjs → dom-Cii0IA92.mjs} +19 -1
- package/dist/debug/dom.js +7 -4
- package/dist/debug/dom.mjs +6 -5
- package/dist/debug/html.js +280 -76
- package/dist/debug/html.mjs +280 -77
- package/dist/dom/catch.feat.js +3 -3
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dom.d.ts +1 -0
- package/dist/dom/dynamic-tag-script.feat.js +2 -2
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.js +1 -1
- package/dist/dom/lazy.feat.mjs +1 -1
- package/dist/dom/placeholder.feat.js +3 -3
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/{dom-CNglVi8P.js → dom-B8UEYzOz.js} +99 -80
- package/dist/{dom-DfP3MCo0.mjs → dom-BPjLe6YU.mjs} +10 -1
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +34 -33
- package/dist/dom.mjs +6 -5
- package/dist/html/assets.d.ts +12 -6
- package/dist/html/attrs.d.ts +1 -0
- package/dist/html/compat.d.ts +10 -2
- package/dist/html/serializer.d.ts +1 -0
- package/dist/html/writer.d.ts +8 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +194 -59
- package/dist/html.mjs +194 -59
- package/dist/translator/index.js +404 -190
- package/dist/translator/util/bindings.d.ts +9 -1
- package/dist/translator/util/constants/structure-kind.d.ts +1 -0
- package/dist/translator/util/known-tag.d.ts +2 -1
- package/dist/translator/util/module-read.d.ts +21 -0
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +2 -0
- package/dist/translator/util/sections.d.ts +5 -1
- package/dist/translator/util/structure.d.ts +1 -0
- package/package.json +3 -3
package/dist/html.mjs
CHANGED
|
@@ -284,8 +284,9 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
284
284
|
let patched = patch(tag, scopeId, accessor);
|
|
285
285
|
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
|
|
286
286
|
};
|
|
287
|
-
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(),
|
|
287
|
+
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kHead = Symbol(), SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
288
288
|
$global,
|
|
289
|
+
writeLoadAsset,
|
|
289
290
|
fork: _await,
|
|
290
291
|
write: _html,
|
|
291
292
|
writeScript,
|
|
@@ -304,7 +305,8 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
304
305
|
onFlush(fn) {
|
|
305
306
|
let { flushHTML } = Chunk.prototype;
|
|
306
307
|
Chunk.prototype.flushHTML = function(boundary) {
|
|
307
|
-
|
|
308
|
+
let { state } = boundary, reorders = swapReorders(state, null);
|
|
309
|
+
return fn(this), swapReorders(state, reorders), flushHTML.call(this, boundary);
|
|
308
310
|
};
|
|
309
311
|
},
|
|
310
312
|
patchDynamicTag,
|
|
@@ -327,24 +329,45 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
327
329
|
return compatRegistered;
|
|
328
330
|
};
|
|
329
331
|
},
|
|
332
|
+
joinChunks(chunks) {
|
|
333
|
+
let joined;
|
|
334
|
+
for (let chunk of chunks) chunk.boundary.aborted || (joined ? joined.append(chunk) : joined = chunk);
|
|
335
|
+
return joined;
|
|
336
|
+
},
|
|
337
|
+
appendChunks(chunks) {
|
|
338
|
+
let chunk = getChunk();
|
|
339
|
+
for (let part of chunks) chunk.append(part), part.effects && (chunk.lastEffect = part.lastEffect);
|
|
340
|
+
},
|
|
341
|
+
deferReorders(reorders) {
|
|
342
|
+
let chunk = getChunk();
|
|
343
|
+
for (let i = reorders.length; i--;) {
|
|
344
|
+
let carrier = chunk.fork(chunk.boundary, chunk.next);
|
|
345
|
+
carrier.deferredReorder = reorders[i], chunk.next = carrier;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
330
348
|
createChunk($global) {
|
|
331
349
|
let state = this.ensureState($global);
|
|
332
350
|
return new Chunk(new Boundary(state), null, null, state);
|
|
333
351
|
},
|
|
334
|
-
flushScript(
|
|
335
|
-
chunk
|
|
336
|
-
|
|
337
|
-
if (boundary.aborted) throw boundary.reason;
|
|
352
|
+
flushScript(chunk, reorders) {
|
|
353
|
+
let { boundary } = chunk, { state } = boundary, html = "", scripts = "";
|
|
354
|
+
if (reorders) for (let reorder of reorders) state.reorder(reorder);
|
|
355
|
+
if (boundary.flush() === 0 && ({html, scripts} = chunk.flushScript(boundary)), boundary.aborted) throw boundary.reason;
|
|
338
356
|
if (boundary.count) throw Error("Cannot serialize promise across tags/class compat layer.");
|
|
339
|
-
return
|
|
357
|
+
return {
|
|
358
|
+
html,
|
|
359
|
+
scripts
|
|
360
|
+
};
|
|
340
361
|
},
|
|
341
|
-
render(renderer, willRerender, classAPIOut, component, input,
|
|
342
|
-
|
|
362
|
+
render(renderer, willRerender, classAPIOut, component, input, componentScopes, registerChildScope, parentChunk) {
|
|
363
|
+
if (parentChunk?.boundary.aborted) return;
|
|
364
|
+
let state = this.ensureState(classAPIOut.global), boundary = new Boundary(state, void 0, parentChunk?.boundary), context = getChunk()?.context ?? null, head = new Chunk(boundary, new Chunk(boundary, null, context, state), context, state), normalizedInput = input;
|
|
343
365
|
if ("renderBody" in input) {
|
|
344
366
|
normalizedInput = {};
|
|
345
367
|
for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
|
346
368
|
}
|
|
347
|
-
|
|
369
|
+
let componentScope = new Chunk(boundary, null, context, state);
|
|
370
|
+
componentScope.render(() => {
|
|
348
371
|
if (this.hasPendingClassFunctions(classAPIOut.global) && drainClassFunctions(classAPIOut.global, (hostId) => {
|
|
349
372
|
let fnScopeId = _scope_id(), scope = writeScope(fnScopeId, {
|
|
350
373
|
m5c: component.id,
|
|
@@ -355,6 +378,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
355
378
|
let scopeId = _peek_scope_id();
|
|
356
379
|
writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
|
|
357
380
|
}
|
|
381
|
+
}), head.render(() => {
|
|
358
382
|
_set_scope_reason(willRerender ? CLIENT_ALL : 0);
|
|
359
383
|
try {
|
|
360
384
|
renderer(normalizedInput);
|
|
@@ -367,7 +391,16 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
367
391
|
});
|
|
368
392
|
classAPIOut.onLast((next) => {
|
|
369
393
|
(boundary.onNext = () => {
|
|
370
|
-
|
|
394
|
+
if (boundary.aborted) boundary.onNext = NOOP, parentChunk?.boundary.aborted ? (asyncOut.end(), next()) : asyncOut.error(boundary.reason);
|
|
395
|
+
else if (!boundary.count) {
|
|
396
|
+
boundary.onNext = NOOP;
|
|
397
|
+
let queued = swapReorders(state, null);
|
|
398
|
+
head = head.consume(boundary);
|
|
399
|
+
let reorders = swapReorders(state, queued);
|
|
400
|
+
reorders && asyncOut.writer.get("reorders").push(...reorders);
|
|
401
|
+
let heldEffects = head.takeHeldEffects();
|
|
402
|
+
heldEffects && (head.effects = joinHeldEffects(heldEffects, head.effects), head.lastEffect = ""), asyncOut.write(head.html), asyncOut.script(head.scripts), head.html = head.scripts = "", asyncOut.writer.get("chunks").push(head), asyncOut.end(), componentScopes.push(componentScope), next();
|
|
403
|
+
}
|
|
371
404
|
})();
|
|
372
405
|
});
|
|
373
406
|
});
|
|
@@ -448,6 +481,7 @@ function normalizeDynamicRenderer(value) {
|
|
|
448
481
|
}
|
|
449
482
|
//#endregion
|
|
450
483
|
//#region src/common/errors.ts
|
|
484
|
+
function _assert_class_toggles(classes, toggles) {}
|
|
451
485
|
function _el_read_error() {}
|
|
452
486
|
function _hoist_read_error() {}
|
|
453
487
|
function _assert_hoist(value) {}
|
|
@@ -472,6 +506,13 @@ function forUntil(until, from, step, cb) {
|
|
|
472
506
|
}
|
|
473
507
|
//#endregion
|
|
474
508
|
//#region src/common/opt.ts
|
|
509
|
+
function reduce(opt, cb, acc) {
|
|
510
|
+
if (opt) {
|
|
511
|
+
if (Array.isArray(opt)) for (let item of opt) acc = cb(acc, item);
|
|
512
|
+
else acc = cb(acc, opt);
|
|
513
|
+
}
|
|
514
|
+
return acc;
|
|
515
|
+
}
|
|
475
516
|
function push(opt, item) {
|
|
476
517
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
477
518
|
}
|
|
@@ -544,6 +585,14 @@ var State$1 = class {
|
|
|
544
585
|
channel
|
|
545
586
|
});
|
|
546
587
|
}
|
|
588
|
+
dropCall(value, object, property) {
|
|
589
|
+
let { mutated } = this.#state;
|
|
590
|
+
for (let i = 0; i < mutated.length; i++) {
|
|
591
|
+
let mutation = mutated[i];
|
|
592
|
+
if (mutation.value === value && mutation.object === object && mutation.property === property) return mutated.splice(i, 1), !0;
|
|
593
|
+
}
|
|
594
|
+
return !1;
|
|
595
|
+
}
|
|
547
596
|
};
|
|
548
597
|
function register(id, val, scope, locals) {
|
|
549
598
|
return REGISTRY.set(val, {
|
|
@@ -1484,6 +1533,15 @@ function _html(html) {
|
|
|
1484
1533
|
function writeScript(script) {
|
|
1485
1534
|
$chunk.writeScript(script);
|
|
1486
1535
|
}
|
|
1536
|
+
function catchableBoundary() {
|
|
1537
|
+
let { boundary } = $chunk;
|
|
1538
|
+
return boundary.withinCatch ? boundary : null;
|
|
1539
|
+
}
|
|
1540
|
+
function mayDrop(written) {
|
|
1541
|
+
let { boundary } = $chunk;
|
|
1542
|
+
for (let cur = written; cur && !isWithin(boundary, cur); cur = cur.parent) if (cur.aborted || cur.count) return !0;
|
|
1543
|
+
return !1;
|
|
1544
|
+
}
|
|
1487
1545
|
function _script(scopeId, registryId, markerGuard) {
|
|
1488
1546
|
markerGuard === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
|
|
1489
1547
|
}
|
|
@@ -1633,8 +1691,8 @@ function scopeWithId(state, scopeId) {
|
|
|
1633
1691
|
}
|
|
1634
1692
|
function _subscribe(subscribers, scope, resumeId, markerGuard) {
|
|
1635
1693
|
if (subscribers) {
|
|
1636
|
-
let {
|
|
1637
|
-
|
|
1694
|
+
let { boundary, serializeState } = $chunk, { serializer } = boundary.state;
|
|
1695
|
+
!serializeState.readyId && !serializer.written(subscribers) ? subscribers.add(scope) : resumeId ? _script(scope[K_SCOPE_ID], resumeId, markerGuard) : serializer.writeCall(scope, subscribers, "add", serializeState), boundary.withinCatch && (boundary.subscribed ||= []).push(subscribers, scope, serializeState);
|
|
1638
1696
|
}
|
|
1639
1697
|
return scope;
|
|
1640
1698
|
}
|
|
@@ -1711,7 +1769,9 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
|
|
|
1711
1769
|
};
|
|
1712
1770
|
}
|
|
1713
1771
|
function tryBoundary(content, catchContent, branchId, renderers) {
|
|
1714
|
-
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary)
|
|
1772
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary);
|
|
1773
|
+
catchContent && (catchBoundary.withinCatch = !0);
|
|
1774
|
+
let body = chunk.fork(catchBoundary, null), bodyEnd = body.render(() => withBranchId(branchId, content));
|
|
1715
1775
|
if (catchBoundary.aborted) {
|
|
1716
1776
|
if (!catchContent) throw catchBoundary.reason;
|
|
1717
1777
|
return catchContent(catchBoundary.reason), !0;
|
|
@@ -1731,10 +1791,10 @@ function tryBoundary(content, catchContent, branchId, renderers) {
|
|
|
1731
1791
|
return;
|
|
1732
1792
|
}
|
|
1733
1793
|
let streamed = !chunk.catchRange, catchChunk = chunk.fork(boundary, null);
|
|
1734
|
-
chunk.catchRange = null;
|
|
1794
|
+
chunk.catchRange = null, renderersAtSettle || catchChunk.render(clearTryRenderers, branchId);
|
|
1735
1795
|
let inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
|
|
1736
1796
|
if (boundary.aborted) return;
|
|
1737
|
-
if (bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
|
|
1797
|
+
if ((bodyEnd.consumed || !inOrder) && (catchChunk.reorderStart = state.mark("*", branchId + "")), bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
|
|
1738
1798
|
else {
|
|
1739
1799
|
let reorder = null;
|
|
1740
1800
|
inOrder ? streamed && (reorder = chunk.fork(boundary, null)) : reorder = catchChunk, reorder && (reorder.reorderId = reorderId);
|
|
@@ -1747,6 +1807,18 @@ function tryBoundary(content, catchContent, branchId, renderers) {
|
|
|
1747
1807
|
}
|
|
1748
1808
|
}, renderersAtSettle;
|
|
1749
1809
|
}
|
|
1810
|
+
function unsubscribe(subscribed, serializer) {
|
|
1811
|
+
for (let i = 0; i < subscribed.length; i += 3) {
|
|
1812
|
+
let subscribers = subscribed[i], scope = subscribed[i + 1];
|
|
1813
|
+
serializer.written(subscribers) ? serializer.dropCall(scope, subscribers, "add") || serializer.writeCall(scope, subscribers, "delete", subscribed[i + 2]) : subscribers.delete(scope);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function clearTryRenderers(branchId) {
|
|
1817
|
+
writeScope(branchId, {
|
|
1818
|
+
E: 0,
|
|
1819
|
+
Q: _scope_with_id(branchId).Q && 0
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1750
1822
|
function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
1751
1823
|
writeScope(branchId, {
|
|
1752
1824
|
E: catchContent,
|
|
@@ -1831,15 +1903,17 @@ var State = class {
|
|
|
1831
1903
|
parent;
|
|
1832
1904
|
aborted = !1;
|
|
1833
1905
|
reason;
|
|
1906
|
+
subscribed;
|
|
1834
1907
|
pendingReorders;
|
|
1835
1908
|
children;
|
|
1909
|
+
withinCatch = !1;
|
|
1836
1910
|
constructor(state, signal, parent) {
|
|
1837
|
-
this.state = state, this.parent = parent, parent ? parent.aborted ? this.abort(parent.reason) : (parent.children ||= []).push(this) : signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", this));
|
|
1911
|
+
this.state = state, this.parent = parent, parent ? (this.withinCatch = parent.withinCatch, parent.aborted ? this.abort(parent.reason) : (parent.children ||= []).push(this)) : signal && (signal.aborted ? this.abort(signal.reason) : signal.addEventListener("abort", this));
|
|
1838
1912
|
}
|
|
1839
1913
|
abort(reason) {
|
|
1840
1914
|
if (this.aborted) return;
|
|
1841
1915
|
let { state } = this;
|
|
1842
|
-
if (this.aborted = !0, this.reason = reason, this.pendingReorders) {
|
|
1916
|
+
if (this.aborted = !0, this.reason = reason, this.subscribed && unsubscribe(this.subscribed, state.serializer), this.pendingReorders) {
|
|
1843
1917
|
for (let reorder of this.pendingReorders) state.reorder(reorder);
|
|
1844
1918
|
this.pendingReorders = void 0;
|
|
1845
1919
|
}
|
|
@@ -1866,7 +1940,9 @@ var State = class {
|
|
|
1866
1940
|
async = !1;
|
|
1867
1941
|
consumed = !1;
|
|
1868
1942
|
reorderId = null;
|
|
1943
|
+
reorderStart = "";
|
|
1869
1944
|
deferredReady = null;
|
|
1945
|
+
heldEffects = null;
|
|
1870
1946
|
deferredReorder = null;
|
|
1871
1947
|
catchRange = null;
|
|
1872
1948
|
placeholder = null;
|
|
@@ -1884,7 +1960,7 @@ var State = class {
|
|
|
1884
1960
|
this.html += html;
|
|
1885
1961
|
}
|
|
1886
1962
|
writeEffect(scopeId, registryId) {
|
|
1887
|
-
countResumeWrite(this), this.lastEffect === registryId ? this.effects
|
|
1963
|
+
countResumeWrite(this), this.lastEffect === registryId ? this.effects = concatEffects(this.effects, scopeId + "") : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
|
|
1888
1964
|
}
|
|
1889
1965
|
writeScript(script) {
|
|
1890
1966
|
this.scripts = concatScripts(this.scripts, script);
|
|
@@ -1892,6 +1968,10 @@ var State = class {
|
|
|
1892
1968
|
append(chunk) {
|
|
1893
1969
|
this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect, this.deferredReady = concat(this.deferredReady, chunk.takeDeferredReady());
|
|
1894
1970
|
}
|
|
1971
|
+
takeHeldEffects() {
|
|
1972
|
+
let { heldEffects } = this;
|
|
1973
|
+
return this.heldEffects = null, heldEffects;
|
|
1974
|
+
}
|
|
1895
1975
|
takeDeferredReady() {
|
|
1896
1976
|
let { deferredReady } = this;
|
|
1897
1977
|
return this.deferredReady = null, deferredReady;
|
|
@@ -1932,12 +2012,12 @@ var State = class {
|
|
|
1932
2012
|
let { body } = placeholder, end = body;
|
|
1933
2013
|
for (; end.next && !end.async;) end = end.next;
|
|
1934
2014
|
if (!end.async) return end.next = this.next, this.next = body, !1;
|
|
1935
|
-
let { branchId, scopeId, placeholderBranchId } = placeholder, reorderId = body.reorderId = branchId
|
|
2015
|
+
let { branchId, scopeId, placeholderBranchId } = placeholder, reorderId = body.reorderId = branchId + "";
|
|
1936
2016
|
this.writeHTML(state.mark("!^", reorderId));
|
|
1937
2017
|
let { effects } = this, beforeBranch = deferBranchStart(this);
|
|
1938
2018
|
if (this.render(() => withBranchId(placeholderBranchId, placeholder.render)) !== this && this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), this.boundary.aborted) return !0;
|
|
1939
2019
|
let stateful = this.effects !== effects;
|
|
1940
|
-
return applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(() => writeScope(branchId, { P: scopeWithId(state, placeholderBranchId) })), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), end.writeEffect(branchId, "_f")), this.writeHTML(state.mark("!", reorderId)), this.deferredReorder = body, !1;
|
|
2020
|
+
return applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(() => writeScope(branchId, { P: scopeWithId(state, placeholderBranchId) })), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), dismissChunk(end, body).writeEffect(branchId, "_f")), this.writeHTML(state.mark("!", reorderId)), this.deferredReorder = body, !1;
|
|
1941
2021
|
}
|
|
1942
2022
|
markCatchRange() {
|
|
1943
2023
|
let { catchRange } = this;
|
|
@@ -1952,9 +2032,9 @@ var State = class {
|
|
|
1952
2032
|
}
|
|
1953
2033
|
consume(boundary) {
|
|
1954
2034
|
this.renderPlaceholders(boundary);
|
|
1955
|
-
let cur = this, html = "", effects = "", scripts = "",
|
|
1956
|
-
for (; cur.next && !cur.async;) cur.markCatchRange(), cur.queueDeferredReorder(), html += cur.html, cur.serializeState.readyId ? deferredReady = push(deferredReady, cur) : (effects =
|
|
1957
|
-
return cur.deferOwnReady(), cur.
|
|
2035
|
+
let cur = this, html = "", effects = "", scripts = "", effectsEnd, heldEffects = this.heldEffects, deferredReady;
|
|
2036
|
+
for (this.heldEffects = null, this.serializeState.readyId && this.effects && followHeldEffects(this); cur.next && !cur.async;) cur.markCatchRange(), cur.queueDeferredReorder(), html += cur.html, cur.serializeState.readyId ? deferredReady = push(deferredReady, cur) : (cur.effects && (effectsEnd && effectsEnd.boundary !== cur.boundary && (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), effects = ""), effectsEnd = cur, effects = concatEffects(effects, cur.effects)), scripts = concatScripts(scripts, cur.scripts)), deferredReady = concat(deferredReady, cur.takeDeferredReady()), cur.consumed = !0, cur = cur.next;
|
|
2037
|
+
return cur.deferOwnReady(), effects && (cur.serializeState.readyId ? heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects) : effectsEnd.boundary === cur.boundary ? (cur.effects = concatEffects(effects, cur.effects), cur.lastEffect ||= effectsEnd.lastEffect) : (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), isWithin(cur.boundary, effectsEnd.boundary) && (cur.lastEffect ||= effectsEnd.lastEffect))), cur.heldEffects = heldEffects, cur.deferredReady = concat(deferredReady, cur.deferredReady), cur.html = html + cur.html, cur.scripts = concatScripts(scripts, cur.scripts), cur;
|
|
1958
2038
|
}
|
|
1959
2039
|
render(content, val) {
|
|
1960
2040
|
let prev = $chunk;
|
|
@@ -1988,32 +2068,32 @@ var State = class {
|
|
|
1988
2068
|
}
|
|
1989
2069
|
flushScript(boundary) {
|
|
1990
2070
|
let { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
|
|
1991
|
-
needsWalk && (state.walkOnNextFlush = !1);
|
|
2071
|
+
needsWalk && (state.walkOnNextFlush = !1), flushSerializer(boundary, state);
|
|
1992
2072
|
let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
|
|
1993
2073
|
for (let channel; !boundary.aborted && (channel = state.serializer.pendingReadyChannel());) {
|
|
1994
2074
|
let resumes = state.serializer.stringifyScopes([], boundary, channel), deps = state.serializer.takeChannelDeps();
|
|
1995
2075
|
state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
1996
2076
|
}
|
|
1997
2077
|
readyResumeScripts && (needsWalk = !0);
|
|
1998
|
-
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1999
|
-
state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(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)&&(r=l.slice(s+1),(l=l[s])>\"#\"||(a[r]=e),l),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"");
|
|
2078
|
+
let effects = this.async ? "" : joinHeldEffects(this.takeHeldEffects(), this.effects), { html, scripts } = this;
|
|
2079
|
+
html && state.hasReorderRuntime && (html = state.mark("*", "") + html), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(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)&&(r=l.slice(s+1),(l=l[s])>\"#\"||(a[r]=e),l),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"");
|
|
2000
2080
|
let reordered = "", needsResumeArray = !1;
|
|
2001
2081
|
if (state.writeReorders) {
|
|
2002
2082
|
for (let reorderedChunk of state.writeReorders) {
|
|
2003
2083
|
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"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:1,r:a,c(i=e.l[\"^\"+a],f=d.cloneNode()){if(--o.i)return 1;for(;f.prepend(r=e.l[a].previousSibling||i),i!=r;);c(a,d)}}),e.v.push({data:e.i+\"*\"+l.r}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
2004
|
-
let { reorderId } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk.boundary.aborted ? null : reorderedChunk;
|
|
2084
|
+
let { reorderId, reorderStart } = reorderedChunk, readyReservations = [], reorderHTML = "", reorderEffects = "", effectsBoundary = reorderedChunk.boundary, reorderScripts = "", cur = reorderedChunk.boundary.aborted ? null : reorderedChunk;
|
|
2005
2085
|
for (reorderedChunk.reorderId = null; cur;) {
|
|
2006
2086
|
cur.markCatchRange(), cur.queueDeferredReorder(), cur.deferOwnReady();
|
|
2007
2087
|
let { next } = cur, readyResumeScripts = cur.flushReadyScripts(boundary, readyReservations, this.async);
|
|
2008
|
-
this.deferredReady = concat(this.deferredReady, cur.takeDeferredReady()), cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), (cur.boundary.pendingReorders ||= /* @__PURE__ */ new Set()).add(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), cur = next;
|
|
2088
|
+
this.deferredReady = concat(this.deferredReady, cur.takeDeferredReady()), cur.consumed = !0, reorderHTML += cur.html, this.async && cur.effects && cur.boundary !== effectsBoundary && (reorderEffects &&= (holdReorderEffects(this, effectsBoundary, reorderEffects), ""), effectsBoundary = cur.boundary), reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts)), cur.async && (reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId()), cur.reorderStart = reorderStart, (cur.boundary.pendingReorders ||= /* @__PURE__ */ new Set()).add(cur), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), cur = next;
|
|
2009
2089
|
}
|
|
2010
|
-
reorderEffects && (this.async ? (this
|
|
2090
|
+
reorderEffects && (this.async ? holdReorderEffects(this, effectsBoundary, reorderEffects) : (needsResumeArray = !0, reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")")));
|
|
2011
2091
|
for (let reservation of readyReservations) reordered = concatScripts(reordered, reservation);
|
|
2012
|
-
reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2092
|
+
reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}"), html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderStart + reorderHTML + "</t>";
|
|
2013
2093
|
}
|
|
2014
2094
|
state.writeReorders = null;
|
|
2015
2095
|
}
|
|
2016
|
-
return
|
|
2096
|
+
return (state.resumes || needsResumeArray && !state.hasWrittenResume) && (scripts = concatScripts(scripts, state.resumeScript(state.resumes))), scripts = concatScripts(scripts, reordered), needsWalk && (scripts = concatScripts(scripts, state.walkScript())), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
2017
2097
|
}
|
|
2018
2098
|
flushHTML(boundary) {
|
|
2019
2099
|
let { state } = boundary;
|
|
@@ -2029,6 +2109,33 @@ function renderReorderPlaceholders(reorder, reorders) {
|
|
|
2029
2109
|
}
|
|
2030
2110
|
return reorders;
|
|
2031
2111
|
}
|
|
2112
|
+
function dismissChunk(end, body) {
|
|
2113
|
+
if (end.boundary !== body.boundary) for (; end.next;) end = end.next;
|
|
2114
|
+
return end;
|
|
2115
|
+
}
|
|
2116
|
+
function followHeldEffects(chunk) {
|
|
2117
|
+
let held = reduce(chunk.deferredReady, lastHeldOf, chunk);
|
|
2118
|
+
held !== chunk && (held.effects = concatEffects(held.effects, chunk.effects), chunk.effects = "");
|
|
2119
|
+
}
|
|
2120
|
+
function lastHeldOf(held, cur) {
|
|
2121
|
+
return cur.serializeState === held.serializeState && cur.boundary === held.boundary ? cur : held;
|
|
2122
|
+
}
|
|
2123
|
+
function holdEffectsOn(heldEffects, chunk, effects) {
|
|
2124
|
+
return chunk.effects = effects, push(heldEffects, chunk);
|
|
2125
|
+
}
|
|
2126
|
+
function isWithin(boundary, outer) {
|
|
2127
|
+
for (; boundary && boundary !== outer;) boundary = boundary.parent;
|
|
2128
|
+
return !!boundary;
|
|
2129
|
+
}
|
|
2130
|
+
function holdReorderEffects(head, boundary, effects) {
|
|
2131
|
+
head.serializeState.readyId || (head.effects && (head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(head.boundary, null), head.effects)), head.effects = head.lastEffect = ""), head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(boundary, null), effects);
|
|
2132
|
+
}
|
|
2133
|
+
function joinHeldEffects(heldEffects, effects) {
|
|
2134
|
+
return concatEffects(reduce(heldEffects, joinUncaught, ""), effects);
|
|
2135
|
+
}
|
|
2136
|
+
function joinUncaught(joined, held) {
|
|
2137
|
+
return held.boundary.aborted ? joined : concatEffects(joined, held.effects);
|
|
2138
|
+
}
|
|
2032
2139
|
function flushSerializer(boundary, serializeState) {
|
|
2033
2140
|
let { state } = boundary, { serializer } = state, pending = serializer.pending(serializeState);
|
|
2034
2141
|
if (serializeState.flushScopes || pending) {
|
|
@@ -2336,42 +2443,66 @@ function settle(boundary) {
|
|
|
2336
2443
|
function NOOP$1() {}
|
|
2337
2444
|
//#endregion
|
|
2338
2445
|
//#region src/html/assets.ts
|
|
2339
|
-
function withLoadAssets(renderer, assetId, triggers) {
|
|
2340
|
-
return Object.assign((input) =>
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2446
|
+
function withLoadAssets(renderer, flush, assetId, triggers) {
|
|
2447
|
+
return Object.assign((input) => (writeLoadAsset(assetId, flush, triggers), writeWaitReady(assetId, renderer, input)), renderer);
|
|
2448
|
+
}
|
|
2449
|
+
function writeLoadAsset(assetId, flush, triggers) {
|
|
2450
|
+
let g = $global();
|
|
2451
|
+
writeAsset(g, addAsset(g, assetId, flush, triggers));
|
|
2344
2452
|
}
|
|
2345
2453
|
function withPageAssets(template, runtime, assetId, runtimeId) {
|
|
2346
|
-
return
|
|
2454
|
+
return Object.assign((input) => {
|
|
2347
2455
|
let g = $global();
|
|
2348
|
-
|
|
2456
|
+
runtimeId && (g[kAssets] || (g.runtimeId = runtimeId));
|
|
2457
|
+
let asset = addAsset(g, assetId, runtime);
|
|
2458
|
+
return g.__flush__ ? (writeAsset(g, asset), writeWaitReady(assetId, template, input)) : (g.__flush__ = flushPage, template(input));
|
|
2349
2459
|
}, template);
|
|
2350
2460
|
}
|
|
2351
2461
|
function _flush_head() {
|
|
2352
2462
|
let g = $global();
|
|
2353
|
-
return g[kAssets] ?
|
|
2463
|
+
return g[kAssets] ? (g[kHead] = !0, takeAssets(g, catchableBoundary())) : "";
|
|
2464
|
+
}
|
|
2465
|
+
function flushPage(g, html) {
|
|
2466
|
+
return takeAssets(g, null) + html;
|
|
2467
|
+
}
|
|
2468
|
+
function takeAssets(g, at) {
|
|
2469
|
+
let block = "", defer = "";
|
|
2470
|
+
for (let asset of g[kAssets]) asset.htmlAt === void 0 && (asset.htmlAt = at, block += blockHTML(g, asset), asset.triggers || (defer += deferHTML(g, asset)));
|
|
2471
|
+
return block + defer;
|
|
2354
2472
|
}
|
|
2355
|
-
function
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2473
|
+
function writeAsset(g, asset) {
|
|
2474
|
+
if (needsWrite(asset.htmlAt) && (asset.htmlAt = void 0, g[kHead] || g.__flush__ !== flushPage)) {
|
|
2475
|
+
let block = blockHTML(g, asset);
|
|
2476
|
+
_html(block + (asset.triggers ? "" : deferHTML(g, asset))), block && isInResumedBranch() && writeScript(`document.head.insertAdjacentHTML("beforeend",${_escape_script(JSON.stringify(block))})`), asset.htmlAt = catchableBoundary();
|
|
2477
|
+
}
|
|
2478
|
+
if (asset.triggers && needsWrite(asset.scriptAt)) {
|
|
2479
|
+
let defer = deferHTML(g, asset);
|
|
2480
|
+
defer && writeScript(asset.script ||= triggerScript(asset.id, defer, asset.triggers)), asset.scriptAt = catchableBoundary();
|
|
2361
2481
|
}
|
|
2362
|
-
return g[kBlockIndex] = bi, g[kDeferIndex] = di, result + html;
|
|
2363
2482
|
}
|
|
2364
|
-
function
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
}], g[kBlockIndex] = g[kDeferIndex] = 0);
|
|
2483
|
+
function needsWrite(at) {
|
|
2484
|
+
return at === void 0 || at !== null && mayDrop(at);
|
|
2485
|
+
}
|
|
2486
|
+
function blockHTML(g, asset) {
|
|
2487
|
+
return asset.block ??= asset.flush(g, "block", asset.id);
|
|
2488
|
+
}
|
|
2489
|
+
function deferHTML(g, asset) {
|
|
2490
|
+
return asset.defer ??= asset.flush(g, "defer", asset.id);
|
|
2373
2491
|
}
|
|
2374
|
-
function
|
|
2492
|
+
function addAsset(g, id, flush, triggers) {
|
|
2493
|
+
let assets = g[kAssets] ||= [], asset = assets.find((a) => a.id === id);
|
|
2494
|
+
return asset || assets.push(asset = {
|
|
2495
|
+
id,
|
|
2496
|
+
flush,
|
|
2497
|
+
triggers,
|
|
2498
|
+
block: void 0,
|
|
2499
|
+
defer: void 0,
|
|
2500
|
+
script: void 0,
|
|
2501
|
+
htmlAt: void 0,
|
|
2502
|
+
scriptAt: void 0
|
|
2503
|
+
}), asset;
|
|
2504
|
+
}
|
|
2505
|
+
function triggerScript(id, html, triggers) {
|
|
2375
2506
|
let htmlStr = _escape_script(JSON.stringify(html)), exprs = triggers.map((trigger) => {
|
|
2376
2507
|
let options = trigger.options && toObjectExpression(trigger.options);
|
|
2377
2508
|
switch (trigger.type) {
|
|
@@ -2381,7 +2512,7 @@ function writeTriggerScript(id, html, triggers) {
|
|
|
2381
2512
|
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2382
2513
|
}
|
|
2383
2514
|
});
|
|
2384
|
-
|
|
2515
|
+
return `((h,d,l=$=>{d||document.head.append(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(${htmlStr})`;
|
|
2385
2516
|
}
|
|
2386
2517
|
function querySelectorOrLoad(selector) {
|
|
2387
2518
|
return `document.querySelector(${JSON.stringify(selector)})||l()`;
|
|
@@ -2400,6 +2531,10 @@ function drainClassFunctions($global, writeScope) {
|
|
|
2400
2531
|
for (let [id, fn, hostId] of pending) register(id, fn, scopeByHost[hostId] ||= writeScope(hostId));
|
|
2401
2532
|
pending.length = 0;
|
|
2402
2533
|
}
|
|
2534
|
+
function swapReorders(state, reorders) {
|
|
2535
|
+
let { writeReorders } = state;
|
|
2536
|
+
return state.writeReorders = reorders, writeReorders;
|
|
2537
|
+
}
|
|
2403
2538
|
function NOOP() {}
|
|
2404
2539
|
//#endregion
|
|
2405
|
-
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_select_value, _attrs_textarea_value, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _html_resume, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _set_scope_reason, _show_end, _show_start, _style_html, _subscribe, _template, _text_resume, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, _write_guard, _write_if, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
|
|
2540
|
+
export { $global, _assert_class_toggles, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_select_value, _attrs_textarea_value, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _html_resume, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _set_scope_reason, _show_end, _show_start, _style_html, _subscribe, _template, _text_resume, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, _write_guard, _write_if, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
|