marko 6.4.5 → 6.4.6
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 -1
- package/dist/common/helpers.d.ts +7 -7
- package/dist/debug/dom/catch.feat.js +3 -3
- package/dist/debug/dom/catch.feat.mjs +3 -3
- 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 +5 -5
- package/dist/debug/dom/controllable.feat.mjs +5 -5
- 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-CUxvM4i9.js → dom-CNgQ6lj9.js} +52 -52
- package/dist/debug/{dom-BeY1nGUb.mjs → dom-o9jQjchF.mjs} +43 -43
- package/dist/debug/dom.js +4 -4
- package/dist/debug/dom.mjs +4 -4
- package/dist/debug/html.js +721 -652
- package/dist/debug/html.mjs +721 -652
- package/dist/dom/catch.feat.js +4 -4
- package/dist/dom/catch.feat.mjs +3 -3
- package/dist/dom/control-flow.d.ts +2 -2
- package/dist/dom/controllable-input.feat.js +2 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +2 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +2 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +2 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.d.ts +4 -4
- package/dist/dom/controllable.feat.js +2 -2
- package/dist/dom/controllable.feat.mjs +2 -2
- package/dist/dom/dom.d.ts +5 -5
- 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 +2 -2
- 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 +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/signals.d.ts +4 -1
- package/dist/{dom-Diu8MpmL.js → dom-60R4bRWD.js} +40 -40
- package/dist/{dom-DefWmvQB.mjs → dom-Ci2W4l1P.mjs} +33 -33
- package/dist/dom.js +6 -6
- package/dist/dom.mjs +4 -4
- package/dist/html/assets.d.ts +1 -1
- package/dist/html/compat.d.ts +2 -1
- package/dist/html/control-flow.d.ts +20 -0
- package/dist/html/serializer.d.ts +63 -16
- package/dist/html/writer.d.ts +47 -35
- package/dist/html.d.ts +2 -1
- package/dist/html.js +517 -467
- package/dist/html.mjs +517 -467
- package/dist/translator/core/for.d.ts +0 -4
- package/dist/translator/core/return.d.ts +0 -3
- package/dist/translator/core/style.d.ts +2 -2
- package/dist/translator/index.js +7934 -7978
- package/dist/translator/util/analyze-errors.d.ts +2 -1
- package/dist/translator/util/assert.d.ts +8 -1
- package/dist/translator/util/bindings.d.ts +13 -9
- package/dist/translator/util/body-to-text.d.ts +9 -0
- package/dist/translator/util/branch-tag.d.ts +10 -3
- package/dist/translator/util/build-string-expression.d.ts +4 -0
- package/dist/translator/util/content-derives.d.ts +7 -0
- package/dist/translator/util/entry-builder.d.ts +6 -2
- package/dist/translator/util/finalize-references.d.ts +3 -2
- package/dist/translator/util/generate-uid.d.ts +3 -2
- package/dist/translator/util/get-root.d.ts +3 -3
- package/dist/translator/util/get-tag-name.d.ts +1 -1
- package/dist/translator/util/known-tag.d.ts +10 -8
- package/dist/translator/util/module-read.d.ts +0 -3
- package/dist/translator/util/module-registrations.d.ts +44 -0
- package/dist/translator/util/nested-attribute-tags.d.ts +1 -1
- package/dist/translator/util/optional.d.ts +6 -1
- package/dist/translator/util/params-tree.d.ts +18 -0
- package/dist/translator/util/reasons.d.ts +10 -8
- package/dist/translator/util/references.d.ts +21 -27
- package/dist/translator/util/runtime.d.ts +0 -12
- package/dist/translator/util/scope-accessor.d.ts +0 -1
- package/dist/translator/util/scope-read.d.ts +3 -0
- package/dist/translator/util/section-renderer.d.ts +4 -0
- package/dist/translator/util/sections.d.ts +16 -16
- package/dist/translator/util/setup-work.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +14 -12
- package/dist/translator/util/simplify-fn.d.ts +1 -0
- package/dist/translator/util/slots.d.ts +2 -2
- package/dist/translator/util/solve-reasons.d.ts +1 -3
- package/dist/translator/util/sources.d.ts +2 -1
- package/dist/translator/util/statement-tag.d.ts +2 -0
- package/dist/translator/util/static-text.d.ts +2 -1
- package/dist/translator/util/structure.d.ts +0 -10
- package/dist/translator/util/tag-facts.d.ts +8 -1
- package/dist/translator/util/tag-import.d.ts +20 -0
- package/dist/translator/util/tag-name-type.d.ts +9 -2
- package/dist/translator/util/to-only-or-block.d.ts +3 -0
- package/dist/translator/util/to-property-name.d.ts +2 -0
- package/dist/translator/util/translate-attrs.d.ts +7 -5
- package/dist/translator/util/translate-var.d.ts +2 -0
- package/dist/translator/util/traverse.d.ts +1 -2
- package/dist/translator/util/visitors.d.ts +4 -1
- package/dist/translator/util/with-previous-location.d.ts +1 -1
- package/dist/translator/util/write-guard.d.ts +2 -2
- package/dist/translator/util/writer.d.ts +1 -2
- package/dist/translator/visitors/export-declaration.d.ts +2 -3
- package/dist/translator/visitors/function.d.ts +0 -35
- package/dist/translator/visitors/import-declaration.d.ts +0 -16
- package/dist/translator/visitors/placeholder.d.ts +2 -1
- package/dist/translator/visitors/program/html.d.ts +0 -1
- package/dist/translator/visitors/program/index.d.ts +4 -5
- package/dist/translator/visitors/tag/custom-tag.d.ts +0 -14
- package/dist/translator/visitors/tag/native-tag.d.ts +3 -12
- package/package.json +3 -3
- package/dist/translator/util/binding-has-prop.d.ts +0 -8
- package/dist/translator/util/binding-prop-tree.d.ts +0 -18
- package/dist/translator/util/body-to-text-literal.d.ts +0 -9
- package/dist/translator/util/import-reference.d.ts +0 -3
- package/dist/translator/util/normalize-string-expression.d.ts +0 -4
- package/dist/translator/util/plugin-hooks.d.ts +0 -4
- package/dist/translator/util/resolve-relative-to-entry.d.ts +0 -2
- package/dist/translator/util/set-tag-derived-from.d.ts +0 -7
- package/dist/translator/util/to-first-expression-or-block.d.ts +0 -2
- package/dist/translator/util/to-first-statement-or-block.d.ts +0 -2
package/dist/html.js
CHANGED
|
@@ -245,10 +245,10 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
245
245
|
if (ch === "\0") return "\\x00";
|
|
246
246
|
let code = ch.charCodeAt(0);
|
|
247
247
|
return code >= 55296 && code <= 57343 ? "\\u" + code.toString(16).padStart(4, "0") : match;
|
|
248
|
-
}, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"),
|
|
249
|
-
let { state } = $chunk.boundary, target = $chunk.
|
|
250
|
-
return state.
|
|
251
|
-
},
|
|
248
|
+
}, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kAsyncContent = Symbol("Async Content"), writeScope = (scopeId, partialScope) => {
|
|
249
|
+
let { state } = $chunk.boundary, target = $chunk.channel, scope = scopeWithId(state, scopeId);
|
|
250
|
+
return state.needsWalkerRuntime = !0, countResumeWrite($chunk), writeAsyncVisits($chunk), Object.assign(scope, partialScope), state.queueScope(target, scopeId, partialScope), scope;
|
|
251
|
+
}, ALL_GROUPS = 715827883, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\u003C$1") : str, unsafeScriptTemplateLiteralReg = /[`\\\r]|\$\{|<(?=\/?script|!--)/gi, replaceUnsafeScriptTemplateLiteral = (c) => c === "<" ? "\\x3C" : c === "\r" ? "\\r" : "\\" + c, quoteScriptTemplateLiteral = (str) => "`" + (unsafeScriptTemplateLiteralReg.test(str) ? str.replace(unsafeScriptTemplateLiteralReg, replaceUnsafeScriptTemplateLiteral) : str) + "`", unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard, tagVar) => {
|
|
252
252
|
let shouldResume = markerGuard !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
253
253
|
if (typeof renderer == "string") {
|
|
254
254
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
@@ -268,7 +268,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
268
268
|
} else {
|
|
269
269
|
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
270
270
|
if (renderer) try {
|
|
271
|
-
return _set_scope_reason(shouldResume ?
|
|
271
|
+
return _set_scope_reason(shouldResume ? ALL_GROUPS : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
272
272
|
...inputOrArgs,
|
|
273
273
|
content
|
|
274
274
|
} : inputOrArgs);
|
|
@@ -281,9 +281,9 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
281
281
|
}
|
|
282
282
|
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: rendererKey(renderer) }) : _scope_id(), result;
|
|
283
283
|
}, patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
|
|
284
|
-
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs,
|
|
284
|
+
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, markerGuard, tagVar) => {
|
|
285
285
|
let patched = patch(tag, scopeId, accessor);
|
|
286
|
-
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs,
|
|
286
|
+
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, markerGuard, tagVar);
|
|
287
287
|
};
|
|
288
288
|
})(_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 = {
|
|
289
289
|
$global,
|
|
@@ -321,7 +321,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
321
321
|
return function() {
|
|
322
322
|
let compatRegistered = COMPAT_REGISTRY.get(this);
|
|
323
323
|
if (!compatRegistered) {
|
|
324
|
-
let registered =
|
|
324
|
+
let registered = REGISTRY.get(this);
|
|
325
325
|
if (registered) {
|
|
326
326
|
let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
|
|
327
327
|
scopeId !== void 0 && _script(scopeId, SET_SCOPE_REGISTER_ID), COMPAT_REGISTRY.set(this, compatRegistered = [registered.id, scopeId]);
|
|
@@ -353,7 +353,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
353
353
|
flushScript(chunk, reorders) {
|
|
354
354
|
let { boundary } = chunk, { state } = boundary, html = "", scripts = "";
|
|
355
355
|
if (reorders) for (let reorder of reorders) state.reorder(reorder);
|
|
356
|
-
if (boundary.flush() === 0 && ({html, scripts} = chunk.
|
|
356
|
+
if (boundary.flush() === 0 && ({html, scripts} = chunk.flush(boundary)), boundary.aborted) throw boundary.reason;
|
|
357
357
|
if (boundary.count) throw Error("Cannot serialize promise across tags/class compat layer.");
|
|
358
358
|
return {
|
|
359
359
|
html,
|
|
@@ -380,7 +380,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
380
380
|
writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
|
|
381
381
|
}
|
|
382
382
|
}), head.render(() => {
|
|
383
|
-
_set_scope_reason(willRerender ?
|
|
383
|
+
_set_scope_reason(willRerender ? ALL_GROUPS : 0);
|
|
384
384
|
try {
|
|
385
385
|
renderer(normalizedInput);
|
|
386
386
|
} finally {
|
|
@@ -413,7 +413,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
413
413
|
registerClassFunctions(input) {
|
|
414
414
|
for (let key in input) {
|
|
415
415
|
let value = input[key];
|
|
416
|
-
typeof value == "function" && !
|
|
416
|
+
typeof value == "function" && !REGISTRY.has(value) && register(RENDER_BODY_ID, value);
|
|
417
417
|
}
|
|
418
418
|
},
|
|
419
419
|
registerClassFunction($global, id, fn, hostId) {
|
|
@@ -441,10 +441,10 @@ function* attrTagIterator() {
|
|
|
441
441
|
}
|
|
442
442
|
//#endregion
|
|
443
443
|
//#region src/common/helpers.ts
|
|
444
|
-
function
|
|
444
|
+
function stringifyClassEntry(name, value) {
|
|
445
445
|
return value ? name : "";
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function stringifyStyleEntry(name, value) {
|
|
448
448
|
return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
|
|
449
449
|
}
|
|
450
450
|
function escapeStyleAttr(str) {
|
|
@@ -458,17 +458,17 @@ function escapeStyleValue(str) {
|
|
|
458
458
|
function isEventHandler(name) {
|
|
459
459
|
return /^on[A-Z-]/.test(name);
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function getEventType(name) {
|
|
462
462
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
463
463
|
}
|
|
464
464
|
function hasKeys(obj) {
|
|
465
465
|
for (let _ in obj) return !0;
|
|
466
466
|
return !1;
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function isNullishOrFalse(value) {
|
|
469
469
|
return value == null || value === !1;
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function isNotNullishOrFalse(value) {
|
|
472
472
|
return value != null && value !== !1;
|
|
473
473
|
}
|
|
474
474
|
function isPromise(value) {
|
|
@@ -488,25 +488,6 @@ function _el_read_error() {}
|
|
|
488
488
|
function _hoist_read_error() {}
|
|
489
489
|
function _assert_hoist(value) {}
|
|
490
490
|
//#endregion
|
|
491
|
-
//#region src/common/for.ts
|
|
492
|
-
function forIn(obj, cb) {
|
|
493
|
-
for (let key in obj) cb(key, obj[key]);
|
|
494
|
-
}
|
|
495
|
-
function forOf(list, cb) {
|
|
496
|
-
if (list) {
|
|
497
|
-
let i = 0;
|
|
498
|
-
for (let item of list) cb(item, i++);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
function forTo(to, from, step, cb) {
|
|
502
|
-
let start = from || 0, delta = step || 1;
|
|
503
|
-
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
504
|
-
}
|
|
505
|
-
function forUntil(until, from, step, cb) {
|
|
506
|
-
let start = from || 0, delta = step || 1;
|
|
507
|
-
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
508
|
-
}
|
|
509
|
-
//#endregion
|
|
510
491
|
//#region src/common/opt.ts
|
|
511
492
|
function reduce(opt, cb, acc) {
|
|
512
493
|
if (opt) {
|
|
@@ -536,14 +517,44 @@ var State$1 = class {
|
|
|
536
517
|
buf = [];
|
|
537
518
|
strs = /* @__PURE__ */ new Map();
|
|
538
519
|
refs = /* @__PURE__ */ new WeakMap();
|
|
539
|
-
|
|
520
|
+
deferredRefs = /* @__PURE__ */ new Set();
|
|
540
521
|
boundary;
|
|
541
522
|
channel = void 0;
|
|
542
523
|
channelDeps = null;
|
|
543
|
-
|
|
524
|
+
queuedCalls = [];
|
|
525
|
+
queuedReadyCalls = [];
|
|
526
|
+
scopeRef(scope, scopeId) {
|
|
527
|
+
return this.refs.get(scope) || newScopeReference(this, scope, scopeId);
|
|
528
|
+
}
|
|
529
|
+
writeScopeProps(props, ref) {
|
|
530
|
+
return writeObjectProps(this, props, ref);
|
|
531
|
+
}
|
|
532
|
+
scopesCursor(scopeId) {
|
|
533
|
+
return scopeId + ",";
|
|
534
|
+
}
|
|
535
|
+
writeTrailing(scopesIndex) {
|
|
536
|
+
let { buf } = this;
|
|
537
|
+
return ~scopesIndex && (buf[scopesIndex] = "_([" + buf[scopesIndex], buf.push("])")), writeDeferred(this), ",0)";
|
|
538
|
+
}
|
|
539
|
+
wrapPayload(result, extras) {
|
|
540
|
+
let arrow = this.wroteUndefined ? "(_,$)=>" : "_=>";
|
|
541
|
+
return this.wroteUndefined = !1, extras ? arrow + result : arrow + "[" + result + "]";
|
|
542
|
+
}
|
|
543
|
+
writeScopedRegistration(val, parent, accessor, registered) {
|
|
544
|
+
let ref = new Reference(parent, accessor, this.flushId, this.buf.length);
|
|
545
|
+
ref.channel = this.channel, this.refs.set(val, ref);
|
|
546
|
+
let scope = registered.scope, scopeId = scope[K_SCOPE_ID];
|
|
547
|
+
trackScope(this, scope, scopeId);
|
|
548
|
+
let locals = registered.locals?.(this.boundary.state.scope);
|
|
549
|
+
if (locals) {
|
|
550
|
+
this.buf.push(registered.access + "(_(" + scopeId + ")");
|
|
551
|
+
for (let local of locals) this.buf.push(","), writePlainObject(this, local, newArgReference(this, ref, local));
|
|
552
|
+
} else this.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
|
|
553
|
+
this.buf.push(")");
|
|
554
|
+
}
|
|
544
555
|
}, Reference = class {
|
|
545
556
|
assignments = null;
|
|
546
|
-
|
|
557
|
+
deferredMembers = null;
|
|
547
558
|
scopeId = void 0;
|
|
548
559
|
channel = void 0;
|
|
549
560
|
parent;
|
|
@@ -555,136 +566,121 @@ var State$1 = class {
|
|
|
555
566
|
constructor(parent, accessor, flushId, pos = null, id = null) {
|
|
556
567
|
this.parent = parent, this.accessor = accessor, this.flushId = flushId, this.pos = pos, this.id = id;
|
|
557
568
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
stringifyScopes(flushes, boundary, channel) {
|
|
567
|
-
try {
|
|
568
|
-
return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
|
|
569
|
-
} catch (err) {
|
|
570
|
-
return abortRender(boundary, err), "";
|
|
571
|
-
} finally {
|
|
572
|
-
this.#state.flushId++, this.#state.buf = [];
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
written(val) {
|
|
576
|
-
return this.#state.refs.has(val);
|
|
577
|
-
}
|
|
578
|
-
takeChannelDeps() {
|
|
579
|
-
let deps = this.#state.channelDeps;
|
|
580
|
-
return this.#state.channelDeps = null, deps;
|
|
581
|
-
}
|
|
582
|
-
writeCall(value, object, property, channel) {
|
|
583
|
-
this.#state.mutated.push({
|
|
584
|
-
value,
|
|
585
|
-
object,
|
|
586
|
-
property,
|
|
587
|
-
channel
|
|
588
|
-
});
|
|
569
|
+
};
|
|
570
|
+
function stringifyScopes(state, flushes, boundary, channel) {
|
|
571
|
+
try {
|
|
572
|
+
return state.boundary = boundary, state.channel = channel, writeScopesRoot(state, flushes);
|
|
573
|
+
} catch (err) {
|
|
574
|
+
return abortRender(boundary, err), "";
|
|
575
|
+
} finally {
|
|
576
|
+
state.flushId++, state.buf = [];
|
|
589
577
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
578
|
+
}
|
|
579
|
+
function pendingReadyChannel(state) {
|
|
580
|
+
let calls = state.queuedReadyCalls;
|
|
581
|
+
return calls.length ? calls[0].channel : void 0;
|
|
582
|
+
}
|
|
583
|
+
function takeChannelDeps(state) {
|
|
584
|
+
let deps = state.channelDeps;
|
|
585
|
+
return state.channelDeps = null, deps;
|
|
586
|
+
}
|
|
587
|
+
function queueCall(state, value, object, method, channel) {
|
|
588
|
+
(channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
|
|
589
|
+
method,
|
|
590
|
+
value,
|
|
591
|
+
object,
|
|
592
|
+
channel,
|
|
593
|
+
valueId: null
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
function dropQueuedCall(state, value, object, method, channel) {
|
|
597
|
+
let queuedCalls = channel?.readyId ? state.queuedReadyCalls : state.queuedCalls;
|
|
598
|
+
for (let i = 0; i < queuedCalls.length; i++) {
|
|
599
|
+
let call = queuedCalls[i];
|
|
600
|
+
if (call.value === value && call.object === object && call.method === method) return queuedCalls.splice(i, 1), !0;
|
|
597
601
|
}
|
|
598
|
-
|
|
599
|
-
|
|
602
|
+
return !1;
|
|
603
|
+
}
|
|
604
|
+
function register(id, val, scope, locals, access = "_._" + toAccess(toObjectKey(id))) {
|
|
600
605
|
return REGISTRY.set(val, {
|
|
601
606
|
id,
|
|
602
607
|
scope,
|
|
603
608
|
locals,
|
|
604
|
-
access
|
|
609
|
+
access
|
|
605
610
|
}), val;
|
|
606
611
|
}
|
|
607
|
-
function getRegistered(val) {
|
|
608
|
-
let registered = REGISTRY.get(val);
|
|
609
|
-
if (registered) return {
|
|
610
|
-
id: registered.id,
|
|
611
|
-
scope: registered.scope
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
612
|
function writeScopesRoot(state, flushes) {
|
|
615
|
-
let { buf } = state, nextSlotId = -1,
|
|
613
|
+
let { buf } = state, nextSlotId = -1, scopesIndex = -1;
|
|
616
614
|
for (let flush of flushes) {
|
|
617
|
-
let scopeId = flush[0], scope = flush[1], ref = state.
|
|
618
|
-
|
|
615
|
+
let scopeId = flush[0], scope = flush[1], ref = state.scopeRef(scope, scopeId), openIndex = buf.push("") - 1;
|
|
616
|
+
state.writeScopeProps(flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? state.scopesCursor(scopeId) + "{" : (scopeId === nextSlotId ? "" : "," + (scopeId - nextSlotId)) + ",{", scopesIndex === -1 && (scopesIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
|
|
619
617
|
}
|
|
620
618
|
let extras = "";
|
|
621
|
-
(state.
|
|
619
|
+
(state.deferredRefs.size || hasChannelCalls(state)) && (extras = state.writeTrailing(scopesIndex));
|
|
622
620
|
let result = extras && "(";
|
|
623
621
|
for (let chunk of buf) result += chunk;
|
|
624
|
-
|
|
625
|
-
let arrow = state.wroteUndefined ? "(_,$)=>" : "_=>";
|
|
626
|
-
return state.wroteUndefined = !1, extras ? arrow + result : arrow + "[" + result + "]";
|
|
622
|
+
return result += extras, result ? state.wrapPayload(result, extras) : "";
|
|
627
623
|
}
|
|
628
|
-
function
|
|
624
|
+
function writeDeferred(state) {
|
|
629
625
|
let sep = state.buf.length ? "," : "";
|
|
630
|
-
if (state.
|
|
631
|
-
let pending = state.
|
|
632
|
-
state.
|
|
626
|
+
if (state.deferredRefs.size) {
|
|
627
|
+
let pending = state.deferredRefs;
|
|
628
|
+
state.deferredRefs = /* @__PURE__ */ new Set();
|
|
633
629
|
let buf = "", hasCalls = !1;
|
|
634
|
-
for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.
|
|
635
|
-
if (buf && state.buf.push(buf), hasCalls) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
|
|
639
|
-
for (let a = 0; a < args.length; a++) a && state.buf.push(","), writeCallArg(state, args[a]);
|
|
640
|
-
state.buf.push(")");
|
|
641
|
-
}
|
|
642
|
-
ref.calls = null;
|
|
643
|
-
}
|
|
630
|
+
for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.deferredMembers !== null;
|
|
631
|
+
if (buf && state.buf.push(buf), hasCalls) for (let ref of pending) {
|
|
632
|
+
let members = ref.deferredMembers;
|
|
633
|
+
members && (writeDeferredMembers(state, ref.id, members), ref.deferredMembers = null);
|
|
644
634
|
}
|
|
645
635
|
}
|
|
646
|
-
|
|
636
|
+
let readyId = state.channel?.readyId, calls = state.queuedCalls;
|
|
637
|
+
if (readyId) {
|
|
638
|
+
calls = [];
|
|
647
639
|
let remaining = [];
|
|
648
|
-
for (let
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
state
|
|
640
|
+
for (let call of state.queuedReadyCalls) (call.channel.readyId === readyId ? calls : remaining).push(call);
|
|
641
|
+
state.queuedReadyCalls = remaining;
|
|
642
|
+
} else calls.length && (state.queuedCalls = []);
|
|
643
|
+
for (let call of calls) {
|
|
644
|
+
let objectStartIndex = state.buf.push(state.buf.length === 0 ? "" : ",");
|
|
645
|
+
if (writeProp(state, call.object, null, "")) {
|
|
646
|
+
let objectRef = state.refs.get(call.object);
|
|
647
|
+
!objectRef.id && !isAncestorChannelRef(state, objectRef) ? (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")) : objectRef.id && state.buf[objectStartIndex] !== objectRef.id && (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")"));
|
|
648
|
+
} else state.buf.push("void 0");
|
|
649
|
+
state.buf.push("." + call.method + "("), call.value !== void 0 && writeCallArg(state, call.value, call.valueId), state.buf.push(")");
|
|
650
|
+
}
|
|
651
|
+
state.deferredRefs.size && writeDeferred(state);
|
|
652
|
+
}
|
|
653
|
+
function writeDeferredMembers(state, id, { collection, first, rest }) {
|
|
654
|
+
if (collection instanceof Map) {
|
|
655
|
+
writeDeferredEntry(state, id, first);
|
|
656
|
+
for (let entry of rest) writeDeferredEntry(state, id, entry);
|
|
657
|
+
} else {
|
|
658
|
+
writeDeferredMember(state, id, first);
|
|
659
|
+
for (let member of rest) writeDeferredMember(state, id, member);
|
|
668
660
|
}
|
|
669
|
-
state.pendingAssignments.size && writeAssigned(state);
|
|
670
661
|
}
|
|
671
|
-
function
|
|
662
|
+
function writeDeferredEntry(state, id, [key, value]) {
|
|
663
|
+
state.buf.push("," + id + ".set("), (key !== void 0 || value !== void 0) && writeCallArg(state, key, null), value !== void 0 && (state.buf.push(","), writeCallArg(state, value, null)), state.buf.push(")");
|
|
664
|
+
}
|
|
665
|
+
function writeDeferredMember(state, id, member) {
|
|
666
|
+
state.buf.push("," + id + ".add("), member !== void 0 && writeCallArg(state, member, null), state.buf.push(")");
|
|
667
|
+
}
|
|
668
|
+
function writeCallArg(state, val, valueId) {
|
|
669
|
+
let startIndex = state.buf.length;
|
|
672
670
|
if (val === void 0) state.wroteUndefined = !0, state.buf.push("$");
|
|
673
671
|
else if (writeProp(state, val, null, "")) {
|
|
674
|
-
let ref = state.
|
|
675
|
-
ref &&
|
|
672
|
+
let ref = typeof val == "string" ? state.strs.get(val) : state.refs.get(val);
|
|
673
|
+
ref && !ref.id && ref.scopeId === void 0 && !isAncestorChannelRef(state, ref) && (ref.id = valueId || nextRefAccess(state), state.buf[startIndex] = ref.id + "=" + state.buf[startIndex]);
|
|
676
674
|
} else state.buf.push("void 0");
|
|
677
675
|
}
|
|
678
|
-
function
|
|
679
|
-
return
|
|
676
|
+
function hasChannelCalls(state) {
|
|
677
|
+
return hasMatchingCalls(state, state.channel?.readyId);
|
|
680
678
|
}
|
|
681
|
-
function
|
|
682
|
-
|
|
679
|
+
function hasMatchingCalls(state, readyId) {
|
|
680
|
+
if (!readyId) return state.queuedCalls.length > 0;
|
|
681
|
+
for (let call of state.queuedReadyCalls) if (call.channel.readyId === readyId) return !0;
|
|
683
682
|
return !1;
|
|
684
683
|
}
|
|
685
|
-
function mutationMatchesReadyId(mutation, readyId) {
|
|
686
|
-
return mutation.channel?.readyId ? mutation.channel.readyId === readyId : !readyId;
|
|
687
|
-
}
|
|
688
684
|
function writeProp(state, val, parent, accessor) {
|
|
689
685
|
switch (typeof val) {
|
|
690
686
|
case "string": return writeString(state, val, parent, accessor);
|
|
@@ -699,7 +695,7 @@ function writeProp(state, val, parent, accessor) {
|
|
|
699
695
|
}
|
|
700
696
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
701
697
|
let ref = state.refs.get(val);
|
|
702
|
-
if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (
|
|
698
|
+
if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureRefAccess(state, ref), state.deferredRefs.add(ref), addAssignment(ref, accessId(state, parent) + toAccess(accessor)), !1) : (writeRef(state, ref), !0) : !1;
|
|
703
699
|
let registered = REGISTRY.get(val);
|
|
704
700
|
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length)), ref.channel = state.channel, write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
|
|
705
701
|
}
|
|
@@ -716,19 +712,7 @@ function quoteRegisterId(id) {
|
|
|
716
712
|
}
|
|
717
713
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
718
714
|
let { scope } = registered;
|
|
719
|
-
|
|
720
|
-
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
721
|
-
ref.channel = state.channel, state.refs.set(val, ref);
|
|
722
|
-
let scopeId = scope[K_SCOPE_ID];
|
|
723
|
-
trackScope(state, scope, scopeId);
|
|
724
|
-
let locals = registered.locals?.(state.boundary.state.scope);
|
|
725
|
-
if (locals) {
|
|
726
|
-
state.buf.push(registered.access + "(_(" + scopeId + ")");
|
|
727
|
-
for (let local of locals) state.buf.push(","), writePlainObject(state, local, newArgReference(state, ref, local));
|
|
728
|
-
} else state.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
|
|
729
|
-
state.buf.push(")");
|
|
730
|
-
} else state.buf.push(registered.access);
|
|
731
|
-
return !0;
|
|
715
|
+
return scope ? state.writeScopedRegistration(val, parent, accessor, registered) : state.buf.push(registered.access), !0;
|
|
732
716
|
}
|
|
733
717
|
function writeString(state, val, parent, accessor) {
|
|
734
718
|
if (val.length > 12) {
|
|
@@ -864,7 +848,7 @@ function writeRegExp(state, val) {
|
|
|
864
848
|
}
|
|
865
849
|
function writePromise(state, val, ref) {
|
|
866
850
|
let { boundary, channel } = state, pId = nextRefAccess(state), handle = newAsyncHandle(state, ref, pId);
|
|
867
|
-
return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) =>
|
|
851
|
+
return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) => queueAsyncCall(state, boundary, handle, "f", v, channel, pId), (v) => queueAsyncCall(state, boundary, handle, "r", v, channel, pId)), boundary.startAsync(), !0;
|
|
868
852
|
}
|
|
869
853
|
function newAsyncHandle(state, parent, id) {
|
|
870
854
|
let handle = {}, handleRef = new Reference(parent, null, state.flushId, null, id);
|
|
@@ -872,23 +856,25 @@ function newAsyncHandle(state, parent, id) {
|
|
|
872
856
|
}
|
|
873
857
|
function writeMap(state, val, ref) {
|
|
874
858
|
if (!val.size) return state.buf.push("new Map"), !0;
|
|
875
|
-
let items = [], assignments, needsId,
|
|
859
|
+
let items = [], assignments, needsId, i = 0, entries = val.entries();
|
|
876
860
|
if (val.size < 25) {
|
|
877
|
-
for (let
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
861
|
+
for (let entry of entries) {
|
|
862
|
+
let [itemKey, itemValue] = entry;
|
|
863
|
+
if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
|
|
864
|
+
if (deferMembers(state, ref, val, entry, entries), !i) return state.buf.push("new Map"), !0;
|
|
865
|
+
break;
|
|
881
866
|
}
|
|
882
|
-
itemKey === val && (itemKey = void 0, (assignments ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assignments ||= []).push("a[" + i + "][1]")), needsId ||=
|
|
867
|
+
itemKey === val && (itemKey = void 0, (assignments ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assignments ||= []).push("a[" + i + "][1]")), needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
|
|
883
868
|
}
|
|
884
869
|
writeArrayArg(state, ref, items, assignments && "((m,a)=>(" + assignmentsToString(assignments, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
|
|
885
870
|
} else {
|
|
886
|
-
for (let
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
871
|
+
for (let entry of entries) {
|
|
872
|
+
let [itemKey, itemValue] = entry;
|
|
873
|
+
if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
|
|
874
|
+
if (deferMembers(state, ref, val, entry, entries), !i) return state.buf.push("new Map"), !0;
|
|
875
|
+
break;
|
|
890
876
|
}
|
|
891
|
-
itemKey === val && (itemKey = 0, (assignments ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assignments ||= []).push("a[" + (i + 1) + "]")), needsId ||=
|
|
877
|
+
itemKey === val && (itemKey = 0, (assignments ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assignments ||= []).push("a[" + (i + 1) + "]")), needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue), i = items.push(itemKey, itemValue);
|
|
892
878
|
}
|
|
893
879
|
writeArrayArg(state, ref, items, assignments && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignmentsToString(assignments, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
|
|
894
880
|
}
|
|
@@ -896,13 +882,13 @@ function writeMap(state, val, ref) {
|
|
|
896
882
|
}
|
|
897
883
|
function writeSet(state, val, ref) {
|
|
898
884
|
if (!val.size) return state.buf.push("new Set"), !0;
|
|
899
|
-
let items = [], assignments, needsId,
|
|
900
|
-
for (let item of
|
|
901
|
-
if (
|
|
902
|
-
|
|
903
|
-
|
|
885
|
+
let items = [], assignments, needsId, i = 0, members = val.values();
|
|
886
|
+
for (let item of members) {
|
|
887
|
+
if (item !== val && isAncestorMember(state, ref, item)) {
|
|
888
|
+
if (deferMembers(state, ref, val, item, members), !i) return state.buf.push("new Set"), !0;
|
|
889
|
+
break;
|
|
904
890
|
}
|
|
905
|
-
item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||=
|
|
891
|
+
item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isReusableMember(item), i = items.push(item);
|
|
906
892
|
}
|
|
907
893
|
return writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
|
|
908
894
|
}
|
|
@@ -911,11 +897,12 @@ function isAncestorMember(state, container, member) {
|
|
|
911
897
|
let ref = state.refs.get(member);
|
|
912
898
|
return ref !== void 0 && isCircular(container, ref);
|
|
913
899
|
}
|
|
914
|
-
function
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
900
|
+
function deferMembers(state, ref, collection, first, rest) {
|
|
901
|
+
ensureRefAccess(state, ref), ref.deferredMembers = {
|
|
902
|
+
collection,
|
|
903
|
+
first,
|
|
904
|
+
rest
|
|
905
|
+
}, state.deferredRefs.add(ref);
|
|
919
906
|
}
|
|
920
907
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
921
908
|
if (assignsPrefix || needsId) {
|
|
@@ -927,14 +914,14 @@ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
|
927
914
|
function newArgReference(state, parent, val) {
|
|
928
915
|
for (let key in val) {
|
|
929
916
|
let member = val[key];
|
|
930
|
-
if (
|
|
917
|
+
if (isReusableMember(member) && !(typeof member == "string" ? state.strs.has(member) : state.refs.has(member))) {
|
|
931
918
|
let ref = new Reference(parent, null, state.flushId, null, nextRefAccess(state));
|
|
932
919
|
return state.buf.push(ref.id + "="), ref;
|
|
933
920
|
}
|
|
934
921
|
}
|
|
935
922
|
return new Reference(parent, null, state.flushId, state.buf.length);
|
|
936
923
|
}
|
|
937
|
-
function
|
|
924
|
+
function isReusableMember(val) {
|
|
938
925
|
switch (typeof val) {
|
|
939
926
|
case "object": return val !== null && val[K_SCOPE_ID] === void 0;
|
|
940
927
|
case "function":
|
|
@@ -987,7 +974,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
987
974
|
let inlined = writeProp(state, val.errors, ref, "errors");
|
|
988
975
|
if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
|
|
989
976
|
let errorsRef = state.refs.get(val.errors);
|
|
990
|
-
errorsRef?.id && (state.
|
|
977
|
+
errorsRef?.id && (state.deferredRefs.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
|
|
991
978
|
}
|
|
992
979
|
return !0;
|
|
993
980
|
}
|
|
@@ -1016,7 +1003,7 @@ function writeRequest(state, val, ref) {
|
|
|
1016
1003
|
let options = "";
|
|
1017
1004
|
val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
|
|
1018
1005
|
let seenHeaders = state.refs.get(val.headers);
|
|
1019
|
-
if (seenHeaders) options += sep + "headers:" +
|
|
1006
|
+
if (seenHeaders) options += sep + "headers:" + ensureRefAccess(state, seenHeaders), sep = ",";
|
|
1020
1007
|
else {
|
|
1021
1008
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1022
1009
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
@@ -1028,7 +1015,7 @@ function writeResponse(state, val, ref) {
|
|
|
1028
1015
|
let sep = "", options = "";
|
|
1029
1016
|
val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
|
|
1030
1017
|
let seenHeaders = state.refs.get(val.headers);
|
|
1031
|
-
if (seenHeaders) options += sep + "headers:" +
|
|
1018
|
+
if (seenHeaders) options += sep + "headers:" + ensureRefAccess(state, seenHeaders);
|
|
1032
1019
|
else {
|
|
1033
1020
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1034
1021
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
@@ -1051,9 +1038,9 @@ function writeTemporal(state, val, name) {
|
|
|
1051
1038
|
function writeReadableStream(state, val, ref) {
|
|
1052
1039
|
if (val.locked) return !1;
|
|
1053
1040
|
let { boundary, channel } = state, reader = val.getReader(), iterId = nextRefAccess(state), handle = newAsyncHandle(state, ref, iterId), onFulfilled = ({ value, done }) => {
|
|
1054
|
-
done ?
|
|
1041
|
+
done ? queueAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), queueAsyncCall(state, boundary, handle, "f", value, channel));
|
|
1055
1042
|
}, onRejected = (reason) => {
|
|
1056
|
-
|
|
1043
|
+
queueAsyncCall(state, boundary, handle, "j", reason, channel);
|
|
1057
1044
|
};
|
|
1058
1045
|
return state.buf.push("new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
|
|
1059
1046
|
}
|
|
@@ -1066,7 +1053,7 @@ function writeGenerator(state, iter, ref) {
|
|
|
1066
1053
|
returnValue = value;
|
|
1067
1054
|
break;
|
|
1068
1055
|
}
|
|
1069
|
-
needsId ||=
|
|
1056
|
+
needsId ||= isReusableMember(value), yields.push(value);
|
|
1070
1057
|
}
|
|
1071
1058
|
if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
|
|
1072
1059
|
let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
@@ -1077,18 +1064,18 @@ function writeGenerator(state, iter, ref) {
|
|
|
1077
1064
|
if (heldReturn) {
|
|
1078
1065
|
let holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1079
1066
|
state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
|
|
1080
|
-
} else if (returnValue !== void 0 && (state.buf.push(","), writeProp(state, returnValue, ref, "") &&
|
|
1067
|
+
} else if (returnValue !== void 0 && (state.buf.push(","), writeProp(state, returnValue, ref, "") && isReusableMember(returnValue))) {
|
|
1081
1068
|
let retRef = typeof returnValue == "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
|
|
1082
|
-
retRef &&
|
|
1069
|
+
retRef && ensureRefAccess(state, retRef);
|
|
1083
1070
|
}
|
|
1084
1071
|
return state.buf.push(")"), !0;
|
|
1085
1072
|
}
|
|
1086
1073
|
function writeAsyncGenerator(state, iter, ref) {
|
|
1087
1074
|
if (iter[kTouchedIterator]) return state.buf.push("(async function*(){}())"), !0;
|
|
1088
1075
|
let { boundary, channel } = state, iterId = nextRefAccess(state), handle = newAsyncHandle(state, ref, iterId), onFulfilled = ({ value, done }) => {
|
|
1089
|
-
done ?
|
|
1076
|
+
done ? queueAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), queueAsyncCall(state, boundary, handle, "f", value, channel));
|
|
1090
1077
|
}, onRejected = (reason) => {
|
|
1091
|
-
|
|
1078
|
+
queueAsyncCall(state, boundary, handle, "j", reason, channel);
|
|
1092
1079
|
};
|
|
1093
1080
|
return state.buf.push("(async function*(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()])){for(i of a)v=await i,i!=l&&(yield v);return v})(" + iterId + "={})"), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
|
|
1094
1081
|
}
|
|
@@ -1116,11 +1103,11 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
1116
1103
|
}
|
|
1117
1104
|
return sep;
|
|
1118
1105
|
}
|
|
1119
|
-
function
|
|
1120
|
-
boundary.aborted || (state.
|
|
1106
|
+
function queueAsyncCall(state, boundary, handle, method, value, channel, valueId = null) {
|
|
1107
|
+
boundary.aborted || ((channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
|
|
1108
|
+
method,
|
|
1121
1109
|
value,
|
|
1122
1110
|
object: handle,
|
|
1123
|
-
property: method,
|
|
1124
1111
|
channel,
|
|
1125
1112
|
valueId
|
|
1126
1113
|
}), boundary.endAsync());
|
|
@@ -1221,16 +1208,16 @@ function quote(str, startPos) {
|
|
|
1221
1208
|
return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
|
|
1222
1209
|
}
|
|
1223
1210
|
function writeRef(state, ref) {
|
|
1224
|
-
ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) && !isAncestorChannelRef(state, ref) ? (ref.path = accessPath(state, ref), ref.pos = state.buf.length, ref.flushId = state.flushId, state.buf.push(ref.path)) : state.buf.push(
|
|
1211
|
+
ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) && !isAncestorChannelRef(state, ref) ? (ref.path = accessPath(state, ref), ref.pos = state.buf.length, ref.flushId = state.flushId, state.buf.push(ref.path)) : state.buf.push(ensureRefAccess(state, ref));
|
|
1225
1212
|
}
|
|
1226
|
-
function
|
|
1227
|
-
return ref.scopeId === void 0 ? ref.id ? (trackChannel(state, ref), ref.id) :
|
|
1213
|
+
function ensureRefAccess(state, ref) {
|
|
1214
|
+
return ref.scopeId === void 0 ? ref.id ? (trackChannel(state, ref), ref.id) : claimRefAccess(state, ref) : (trackChannel(state, ref), "_(" + ref.scopeId + ")");
|
|
1228
1215
|
}
|
|
1229
1216
|
function accessId(state, ref) {
|
|
1230
|
-
let id =
|
|
1217
|
+
let id = ensureRefAccess(state, ref);
|
|
1231
1218
|
return id === ref.id || ref.scopeId !== void 0 ? id : "(" + id + ")";
|
|
1232
1219
|
}
|
|
1233
|
-
function
|
|
1220
|
+
function claimRefAccess(state, ref) {
|
|
1234
1221
|
let { pos } = ref;
|
|
1235
1222
|
return pos !== null && ref.flushId === state.flushId ? (ref.id = nextRefAccess(state), pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id) : isAncestorChannelRef(state, ref) ? ref.path || accessPath(state, ref) : (ref.id = nextRefAccess(state), ref.id + "=" + (ref.path || accessPath(state, ref)));
|
|
1236
1223
|
}
|
|
@@ -1297,10 +1284,10 @@ function patchIteratorNext(proto) {
|
|
|
1297
1284
|
//#endregion
|
|
1298
1285
|
//#region src/html/attrs.ts
|
|
1299
1286
|
function _attr_class(value) {
|
|
1300
|
-
return stringAttr("class", toDelimitedString(value, " ",
|
|
1287
|
+
return stringAttr("class", toDelimitedString(value, " ", stringifyClassEntry));
|
|
1301
1288
|
}
|
|
1302
1289
|
function _attr_style(value) {
|
|
1303
|
-
return stringAttr("style", toDelimitedString(value, ";",
|
|
1290
|
+
return stringAttr("style", toDelimitedString(value, ";", stringifyStyleEntry));
|
|
1304
1291
|
}
|
|
1305
1292
|
function _attr_option_value(value) {
|
|
1306
1293
|
let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
|
|
@@ -1326,7 +1313,7 @@ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeT
|
|
|
1326
1313
|
return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
|
|
1327
1314
|
}
|
|
1328
1315
|
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
1329
|
-
return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType),
|
|
1316
|
+
return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType), isNotNullishOrFalse(checked) ? " checked" : "";
|
|
1330
1317
|
}
|
|
1331
1318
|
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
1332
1319
|
let valueAttr = _attr("value", value);
|
|
@@ -1339,7 +1326,7 @@ function getCheckedValueRef(checkedValue) {
|
|
|
1339
1326
|
}
|
|
1340
1327
|
}
|
|
1341
1328
|
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
1342
|
-
let normalizedOpen =
|
|
1329
|
+
let normalizedOpen = isNotNullishOrFalse(open);
|
|
1343
1330
|
return openChange && writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType), normalizedOpen ? " open" : "";
|
|
1344
1331
|
}
|
|
1345
1332
|
function _attr_nonce() {
|
|
@@ -1350,7 +1337,7 @@ function _style_html(decls) {
|
|
|
1350
1337
|
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1351
1338
|
}
|
|
1352
1339
|
function _attr(name, value) {
|
|
1353
|
-
return
|
|
1340
|
+
return isNullishOrFalse(value) ? "" : stringifyAttr(name, value);
|
|
1354
1341
|
}
|
|
1355
1342
|
function _attr_and(name, value, attr) {
|
|
1356
1343
|
return value ? attr : _attr(name, value);
|
|
@@ -1386,7 +1373,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
1386
1373
|
case "style":
|
|
1387
1374
|
result += _attr_style(value);
|
|
1388
1375
|
break;
|
|
1389
|
-
default: name && !(
|
|
1376
|
+
default: name && !(isNullishOrFalse(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventType(name)] = value) : result += stringifyAttr(name, value));
|
|
1390
1377
|
}
|
|
1391
1378
|
}
|
|
1392
1379
|
return result;
|
|
@@ -1397,7 +1384,7 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, markerGuard) {
|
|
|
1397
1384
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
1398
1385
|
let partial = {};
|
|
1399
1386
|
for (let name in data) {
|
|
1400
|
-
let key = isEventHandler(name) ? `on-${
|
|
1387
|
+
let key = isEventHandler(name) ? `on-${getEventType(name)}` : name;
|
|
1401
1388
|
skip[key] || (partial[key] = data[name]);
|
|
1402
1389
|
}
|
|
1403
1390
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
@@ -1418,7 +1405,7 @@ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, s
|
|
|
1418
1405
|
function stringAttr(name, value) {
|
|
1419
1406
|
return value && " " + name + attrAssignment(value);
|
|
1420
1407
|
}
|
|
1421
|
-
function
|
|
1408
|
+
function stringifyAttr(name, value) {
|
|
1422
1409
|
switch (typeof value) {
|
|
1423
1410
|
case "string": return " " + name + attrAssignment(value);
|
|
1424
1411
|
case "boolean": return " " + name;
|
|
@@ -1449,18 +1436,7 @@ function normalizedValueMatches(a, b) {
|
|
|
1449
1436
|
return !1;
|
|
1450
1437
|
}
|
|
1451
1438
|
function normalizeStrAttrValue(value) {
|
|
1452
|
-
return
|
|
1453
|
-
}
|
|
1454
|
-
//#endregion
|
|
1455
|
-
//#region src/html/for.ts
|
|
1456
|
-
function forOfBy(by, item, index) {
|
|
1457
|
-
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
|
1458
|
-
}
|
|
1459
|
-
function forInBy(by, name, value) {
|
|
1460
|
-
return by ? by(name, value) : name;
|
|
1461
|
-
}
|
|
1462
|
-
function forStepBy(by, index) {
|
|
1463
|
-
return by ? by(index) : index;
|
|
1439
|
+
return isNotNullishOrFalse(value) && value !== !0 ? value + "" : "";
|
|
1464
1440
|
}
|
|
1465
1441
|
//#endregion
|
|
1466
1442
|
//#region src/html/inlined-runtimes.ts
|
|
@@ -1506,11 +1482,11 @@ function _scope_id() {
|
|
|
1506
1482
|
function _peek_scope_id() {
|
|
1507
1483
|
return $chunk.boundary.state.scopeId;
|
|
1508
1484
|
}
|
|
1509
|
-
function withContext(key, value, cb, cbValue) {
|
|
1485
|
+
function withContext(key, value, cb, cbValue, cbValue2) {
|
|
1510
1486
|
let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
|
|
1511
1487
|
ctx[kPendingContexts]++, ctx[key] = value;
|
|
1512
1488
|
try {
|
|
1513
|
-
return cb(cbValue);
|
|
1489
|
+
return cb(cbValue, cbValue2);
|
|
1514
1490
|
} finally {
|
|
1515
1491
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
|
1516
1492
|
}
|
|
@@ -1524,11 +1500,11 @@ function captureContext(chunk) {
|
|
|
1524
1500
|
function isInResumedBranch() {
|
|
1525
1501
|
return $chunk?.context?.[kBranchId] !== void 0;
|
|
1526
1502
|
}
|
|
1527
|
-
function withBranchId(branchId, cb, cbValue) {
|
|
1528
|
-
return withContext(kBranchId, branchId, cb, cbValue);
|
|
1503
|
+
function withBranchId(branchId, cb, cbValue, cbValue2) {
|
|
1504
|
+
return withContext(kBranchId, branchId, cb, cbValue, cbValue2);
|
|
1529
1505
|
}
|
|
1530
|
-
function
|
|
1531
|
-
return withContext(
|
|
1506
|
+
function withAsyncContent(async, cb, value) {
|
|
1507
|
+
return withContext(kAsyncContent, async, cb, value);
|
|
1532
1508
|
}
|
|
1533
1509
|
function _html(html) {
|
|
1534
1510
|
$chunk.writeHTML(html);
|
|
@@ -1546,7 +1522,7 @@ function mayDrop(written) {
|
|
|
1546
1522
|
return !1;
|
|
1547
1523
|
}
|
|
1548
1524
|
function _script(scopeId, registryId, markerGuard) {
|
|
1549
|
-
markerGuard === 0 && ($chunk.
|
|
1525
|
+
markerGuard === 0 && ($chunk.channel.readyId || $chunk.context?.[kAsyncContent]) && _resume_branch(scopeId), $chunk.boundary.state.queueEffect(scopeId, registryId);
|
|
1550
1526
|
}
|
|
1551
1527
|
function _trailers(html) {
|
|
1552
1528
|
$chunk.boundary.state.trailerHTML += html;
|
|
@@ -1564,24 +1540,24 @@ function _hoist(scopeId, id) {
|
|
|
1564
1540
|
let getter = () => void 0;
|
|
1565
1541
|
return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
|
|
1566
1542
|
}
|
|
1567
|
-
function _el_resume(scopeId, accessor,
|
|
1568
|
-
if (
|
|
1543
|
+
function _el_resume(scopeId, accessor, markerGuard) {
|
|
1544
|
+
if (markerGuard === 0) return "";
|
|
1569
1545
|
let { state } = $chunk.boundary;
|
|
1570
|
-
return state.
|
|
1546
|
+
return state.needsWalkerRuntime = !0, state.mark("$", scopeId + " " + accessor);
|
|
1571
1547
|
}
|
|
1572
|
-
function _text_resume(scopeId, accessor, val,
|
|
1573
|
-
return markText(scopeId, accessor, _escape(val),
|
|
1548
|
+
function _text_resume(scopeId, accessor, val, markerGuard) {
|
|
1549
|
+
return markText(scopeId, accessor, _escape(val), markerGuard);
|
|
1574
1550
|
}
|
|
1575
|
-
function _html_resume(scopeId, accessor, val,
|
|
1551
|
+
function _html_resume(scopeId, accessor, val, markerGuard) {
|
|
1576
1552
|
let html = _unescaped(val);
|
|
1577
|
-
if (
|
|
1553
|
+
if (markerGuard === 0 || !~html.indexOf("<")) return markText(scopeId, accessor, html, markerGuard);
|
|
1578
1554
|
let { state } = $chunk.boundary;
|
|
1579
|
-
return state.
|
|
1555
|
+
return state.needsWalkerRuntime = !0, state.mark("&", "") + html + state.mark("'", scopeId + " " + accessor);
|
|
1580
1556
|
}
|
|
1581
|
-
function markText(scopeId, accessor, text,
|
|
1582
|
-
if (
|
|
1557
|
+
function markText(scopeId, accessor, text, markerGuard) {
|
|
1558
|
+
if (markerGuard === 0) return text;
|
|
1583
1559
|
let { state } = $chunk.boundary;
|
|
1584
|
-
return state.
|
|
1560
|
+
return state.needsWalkerRuntime = !0, text ? (markerGuard === 2 ? "<!>" : "") + text + state.mark("$", scopeId + " " + accessor) : state.mark("%", scopeId + " " + accessor);
|
|
1585
1561
|
}
|
|
1586
1562
|
function _resume_branch(scopeId) {
|
|
1587
1563
|
let branchId = $chunk.context?.[kBranchId];
|
|
@@ -1590,7 +1566,7 @@ function _resume_branch(scopeId) {
|
|
|
1590
1566
|
function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
|
|
1591
1567
|
let shouldResume = markerGuard !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
1592
1568
|
if (render) try {
|
|
1593
|
-
_set_scope_reason(shouldResume ?
|
|
1569
|
+
_set_scope_reason(shouldResume ? ALL_GROUPS : 0), shouldResume ? withBranchId(branchId, render) : render();
|
|
1594
1570
|
} finally {
|
|
1595
1571
|
_set_scope_reason(void 0);
|
|
1596
1572
|
}
|
|
@@ -1609,83 +1585,8 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, node
|
|
|
1609
1585
|
nodeAccessor !== void 0 && writeScope(parentScopeId, { ["A" + nodeAccessor]: childScope });
|
|
1610
1586
|
}
|
|
1611
1587
|
function writeScopePassive(scopeId, partialScope) {
|
|
1612
|
-
let target = $chunk.
|
|
1613
|
-
return Object.assign(scope, partialScope),
|
|
1614
|
-
}
|
|
1615
|
-
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
1616
|
-
display ? resumesMarker(markerGuard, branchExprGuard, parentEndTag) && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
1617
|
-
}
|
|
1618
|
-
function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1619
|
-
let branchId = _scope_id(), wrap = !display;
|
|
1620
|
-
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1621
|
-
}
|
|
1622
|
-
function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1623
|
-
forBranches(by, (each) => each ? forOf(list, (item, index) => {
|
|
1624
|
-
let itemKey = forOfBy(by, item, index);
|
|
1625
|
-
each(itemKey, itemKey === index, () => cb(item, index));
|
|
1626
|
-
}) : forOf(list, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
1627
|
-
}
|
|
1628
|
-
function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1629
|
-
forBranches(by, (each) => each ? forIn(obj, (key, value) => {
|
|
1630
|
-
each(forInBy(by, key, value), !1, () => cb(key, value));
|
|
1631
|
-
}) : forIn(obj, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
1632
|
-
}
|
|
1633
|
-
function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1634
|
-
forBranches(by, (each) => {
|
|
1635
|
-
let index = 0;
|
|
1636
|
-
return each ? forTo(to, from, step, (value) => {
|
|
1637
|
-
let itemKey = forStepBy(by, value);
|
|
1638
|
-
each(itemKey, itemKey === index++, () => cb(value));
|
|
1639
|
-
}) : forTo(to, from, step, cb);
|
|
1640
|
-
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
1641
|
-
}
|
|
1642
|
-
function _for_until(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1643
|
-
forBranches(by, (each) => {
|
|
1644
|
-
let index = 0;
|
|
1645
|
-
return each ? forUntil(to, from, step, (value) => {
|
|
1646
|
-
let itemKey = forStepBy(by, value);
|
|
1647
|
-
each(itemKey, itemKey === index++, () => cb(value));
|
|
1648
|
-
}) : forUntil(to, from, step, cb);
|
|
1649
|
-
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
1650
|
-
}
|
|
1651
|
-
function forBranches(by, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1652
|
-
if (branchGuard === 0) {
|
|
1653
|
-
iterate(0), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
let { state } = $chunk.boundary, resumeKeys = markerGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), flushBranchIds = "", loopScopes;
|
|
1657
|
-
iterate((itemKey, sameAsIndex, render) => {
|
|
1658
|
-
let branchId = _peek_scope_id();
|
|
1659
|
-
resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
|
|
1660
|
-
render();
|
|
1661
|
-
let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
|
|
1662
|
-
resumeMarker || (loopScopes = push(loopScopes, branchScope));
|
|
1663
|
-
});
|
|
1664
|
-
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
1665
|
-
}
|
|
1666
|
-
function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
1667
|
-
let resumeBranch = branchGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1668
|
-
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1669
|
-
["D" + accessor]: branchIndex || void 0,
|
|
1670
|
-
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
1671
|
-
}), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
1672
|
-
}
|
|
1673
|
-
function deferBranchStart(chunk) {
|
|
1674
|
-
let beforeBranch = chunk.html;
|
|
1675
|
-
return chunk.html = "", beforeBranch;
|
|
1676
|
-
}
|
|
1677
|
-
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1678
|
-
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1679
|
-
}
|
|
1680
|
-
function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
1681
|
-
return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
|
|
1682
|
-
}
|
|
1683
|
-
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
1684
|
-
let endTag = parentEndTag || "";
|
|
1685
|
-
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
|
|
1686
|
-
let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
1687
|
-
$chunk.writeHTML(mark + endTag);
|
|
1688
|
-
} else markerGuard === 0 ? $chunk.writeHTML(endTag) : $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1588
|
+
let target = $chunk.channel, scope = _scope_with_id(scopeId);
|
|
1589
|
+
return Object.assign(scope, partialScope), $chunk.boundary.state.queuePassiveScope(target, scopeId, partialScope), scope;
|
|
1689
1590
|
}
|
|
1690
1591
|
function _existing_scope(scopeId) {
|
|
1691
1592
|
return writeScope(scopeId, {});
|
|
@@ -1699,13 +1600,13 @@ function scopeWithId(state, scopeId) {
|
|
|
1699
1600
|
}
|
|
1700
1601
|
function _subscribe(subscribers, scope, resumeId, markerGuard) {
|
|
1701
1602
|
if (subscribers) {
|
|
1702
|
-
let { boundary,
|
|
1703
|
-
!
|
|
1603
|
+
let { boundary, channel } = $chunk, { serializer } = boundary.state;
|
|
1604
|
+
!channel.readyId && !serializer.refs.has(subscribers) ? subscribers.add(scope) : resumeId ? _script(scope[K_SCOPE_ID], resumeId, markerGuard) : queueCall(serializer, scope, subscribers, "add", channel), boundary.withinCatch && (boundary.subscribed ||= []).push(subscribers, scope, channel);
|
|
1704
1605
|
}
|
|
1705
1606
|
return scope;
|
|
1706
1607
|
}
|
|
1707
|
-
function
|
|
1708
|
-
return
|
|
1608
|
+
function getGroupReason(reason, group) {
|
|
1609
|
+
return reason === 715827883 ? 1 : typeof reason == "number" ? group < 15 ? reason >>> 1 + 2 * group & 3 : 0 : reason[group] ?? 0;
|
|
1709
1610
|
}
|
|
1710
1611
|
function _set_scope_reason(reason) {
|
|
1711
1612
|
$chunk.boundary.state.scopeReason = reason;
|
|
@@ -1714,148 +1615,65 @@ function _scope_reason() {
|
|
|
1714
1615
|
let reason = $chunk.boundary.state.scopeReason;
|
|
1715
1616
|
return $chunk.boundary.state.scopeReason = void 0, reason;
|
|
1716
1617
|
}
|
|
1717
|
-
function _write_if(
|
|
1718
|
-
return
|
|
1618
|
+
function _write_if(reason, group) {
|
|
1619
|
+
return reason && getGroupReason(reason, group) ? 1 : void 0;
|
|
1719
1620
|
}
|
|
1720
|
-
function _write_guard(
|
|
1721
|
-
return _write_if(
|
|
1621
|
+
function _write_guard(reason, group) {
|
|
1622
|
+
return _write_if(reason, group) || 0;
|
|
1722
1623
|
}
|
|
1723
1624
|
function writeWaitReady(readyId, renderer, input) {
|
|
1724
1625
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context, {
|
|
1725
1626
|
readyId,
|
|
1726
|
-
parent: chunk.
|
|
1627
|
+
parent: chunk.channel,
|
|
1727
1628
|
resumes: "",
|
|
1728
1629
|
writeScopes: {},
|
|
1729
1630
|
flushScopes: !1
|
|
1730
1631
|
}), bodyEnd = body.render(renderer, input);
|
|
1731
1632
|
if (boundary.aborted) throw boundary.reason;
|
|
1732
|
-
body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next =
|
|
1733
|
-
}
|
|
1734
|
-
function _await(scopeId, accessor, promise, content, markerGuard) {
|
|
1735
|
-
let resumeMarker = markerGuard !== 0;
|
|
1736
|
-
if (!isPromise(promise)) {
|
|
1737
|
-
if (resumeMarker) {
|
|
1738
|
-
let branchId = _peek_scope_id();
|
|
1739
|
-
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, content, promise), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1740
|
-
} else content(promise);
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
let chunk = $chunk, { boundary } = chunk, startId = _peek_scope_id(), after = chunk.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
1744
|
-
chunk.async = !0, captureContext(chunk), boundary.startAsync(), promise.then((value) => {
|
|
1745
|
-
if (chunk.async && (chunk.async = !1, !boundary.aborted)) {
|
|
1746
|
-
let { state } = boundary;
|
|
1747
|
-
chunk.render(() => {
|
|
1748
|
-
if (resumeMarker) {
|
|
1749
|
-
let branchId = _peek_scope_id();
|
|
1750
|
-
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withIsAsync({ parent: getAsyncContent(chunk) }, content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
1751
|
-
} else {
|
|
1752
|
-
let renderedSince = _peek_scope_id() !== startId, async = { parent: getAsyncContent(chunk) };
|
|
1753
|
-
withIsAsync(async, content, value), async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "", async.resumed && $chunk.writeHTML(async.visit), async.end = $chunk;
|
|
1754
|
-
}
|
|
1755
|
-
}), !chunk.async && boundary.pendingReorders?.delete(chunk) && state.reorder(chunk), boundary.endAsync();
|
|
1756
|
-
}
|
|
1757
|
-
}, (err) => {
|
|
1758
|
-
chunk.async = !1, boundary.abort(err);
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
|
|
1762
|
-
let placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId)), renderersWritten = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers), rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
|
|
1763
|
-
applyBranchStart(chunk, beforeBranch, rendered), rendered && (renderersWritten || renderers(), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
|
|
1633
|
+
body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next = chunk.forkRest(boundary), chunk.next = body);
|
|
1764
1634
|
}
|
|
1765
|
-
function
|
|
1766
|
-
let
|
|
1767
|
-
|
|
1768
|
-
chunk.append(body);
|
|
1769
|
-
return;
|
|
1770
|
-
}
|
|
1771
|
-
chunk.next = $chunk = chunk.fork(boundary, chunk.next), captureContext(chunk), chunk.placeholder = {
|
|
1772
|
-
body,
|
|
1773
|
-
render: placeholder,
|
|
1774
|
-
branchId,
|
|
1775
|
-
scopeId,
|
|
1776
|
-
placeholderBranchId
|
|
1777
|
-
};
|
|
1635
|
+
function deferBranchStart(chunk) {
|
|
1636
|
+
let beforeBranch = chunk.html;
|
|
1637
|
+
return chunk.html = "", beforeBranch;
|
|
1778
1638
|
}
|
|
1779
|
-
function
|
|
1780
|
-
|
|
1781
|
-
catchContent && (catchBoundary.withinCatch = !0);
|
|
1782
|
-
let body = chunk.fork(catchBoundary, null), bodyEnd = body.render(() => withBranchId(branchId, content));
|
|
1783
|
-
if (catchBoundary.aborted) {
|
|
1784
|
-
if (!catchContent) throw catchBoundary.reason;
|
|
1785
|
-
return catchContent(catchBoundary.reason), !0;
|
|
1786
|
-
}
|
|
1787
|
-
if (body === bodyEnd) return chunk.append(body), !1;
|
|
1788
|
-
let renderersAtSettle = !catchBoundary.resumeWrites, bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
1789
|
-
chunk.next = body, boundary.startAsync();
|
|
1790
|
-
let reorderId = catchContent ? state.nextReorderId() : "";
|
|
1791
|
-
return reorderId && (chunk.catchRange = {
|
|
1792
|
-
id: reorderId,
|
|
1793
|
-
end: bodyEnd
|
|
1794
|
-
}, captureContext(chunk)), catchBoundary.onNext = () => {
|
|
1795
|
-
if (!boundary.aborted) {
|
|
1796
|
-
if (catchBoundary.aborted) {
|
|
1797
|
-
if (!reorderId) {
|
|
1798
|
-
boundary.abort(catchBoundary.reason);
|
|
1799
|
-
return;
|
|
1800
|
-
}
|
|
1801
|
-
let streamed = !chunk.catchRange, catchChunk = chunk.fork(boundary, null);
|
|
1802
|
-
chunk.catchRange = null, renderersAtSettle || catchChunk.render(clearTryRenderers, branchId);
|
|
1803
|
-
let inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
|
|
1804
|
-
if (boundary.aborted) return;
|
|
1805
|
-
if ((bodyEnd.consumed || !inOrder) && (catchChunk.reorderBranch = branchId), bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
|
|
1806
|
-
else {
|
|
1807
|
-
let reorder = null;
|
|
1808
|
-
inOrder ? streamed && (reorder = chunk.fork(boundary, null)) : reorder = catchChunk, reorder && (reorder.reorderId = reorderId);
|
|
1809
|
-
let endMarker = state.mark("!", reorderId), cut = body;
|
|
1810
|
-
for (; cut.consumed;) cut = cut.next;
|
|
1811
|
-
cut.async = !1, cut.next = inOrder ? catchChunk : bodyNext, cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker, cut.scripts = cut.effects = cut.lastEffect = "", cut.placeholder = cut.reorderId = cut.catchRange = null, cut.deferredReorder = reorder, inOrder && (catchChunk.next = bodyNext);
|
|
1812
|
-
}
|
|
1813
|
-
boundary.endAsync();
|
|
1814
|
-
} else catchBoundary.count ? boundary.onNext() : (renderersAtSettle && catchBoundary.resumeWrites && bodyEnd.render(renderers), chunk.catchRange = null, boundary.endAsync());
|
|
1815
|
-
}
|
|
1816
|
-
}, renderersAtSettle;
|
|
1639
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1640
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1817
1641
|
}
|
|
1818
1642
|
function unsubscribe(subscribed, serializer) {
|
|
1819
1643
|
for (let i = 0; i < subscribed.length; i += 3) {
|
|
1820
1644
|
let subscribers = subscribed[i], scope = subscribed[i + 1];
|
|
1821
|
-
|
|
1645
|
+
if (!serializer.refs.has(subscribers)) subscribers.delete(scope);
|
|
1646
|
+
else {
|
|
1647
|
+
let channel = subscribed[i + 2];
|
|
1648
|
+
dropQueuedCall(serializer, scope, subscribers, "add", channel) || queueCall(serializer, scope, subscribers, "delete", channel);
|
|
1649
|
+
}
|
|
1822
1650
|
}
|
|
1823
1651
|
}
|
|
1824
|
-
function clearTryRenderers(branchId) {
|
|
1825
|
-
writeScope(branchId, {
|
|
1826
|
-
E: 0,
|
|
1827
|
-
Q: _scope_with_id(branchId).Q && 0
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
1831
|
-
writeScope(branchId, {
|
|
1832
|
-
E: catchContent,
|
|
1833
|
-
Q: placeholderContent
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
1652
|
function countResumeWrite(chunk) {
|
|
1837
1653
|
for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
|
|
1654
|
+
}
|
|
1655
|
+
function writeAsyncVisits(chunk) {
|
|
1838
1656
|
for (let async = getAsyncContent(chunk); async && !async.resumed; async = async.parent) async.resumed = !0, async.end?.writeHTML(async.visit);
|
|
1839
1657
|
}
|
|
1840
1658
|
function getAsyncContent(chunk) {
|
|
1841
|
-
return chunk.context?.[
|
|
1659
|
+
return chunk.context?.[kAsyncContent];
|
|
1842
1660
|
}
|
|
1843
1661
|
var State = class {
|
|
1844
1662
|
tagId = 1;
|
|
1845
1663
|
scopeId = 1;
|
|
1846
1664
|
reorderId = 1;
|
|
1847
1665
|
readyGate = 1;
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1666
|
+
hasWrittenGlobals = !1;
|
|
1667
|
+
needsWalkerRuntime = !1;
|
|
1668
|
+
hasWalkerRuntime = !1;
|
|
1669
|
+
hasWrittenReady = !1;
|
|
1852
1670
|
hasReorderRuntime = !1;
|
|
1853
1671
|
hasWrittenResume = !1;
|
|
1854
1672
|
walkOnNextFlush = !1;
|
|
1855
1673
|
trailerHTML = "";
|
|
1856
1674
|
resumes = "";
|
|
1857
1675
|
nonceAttr = "";
|
|
1858
|
-
serializer = new
|
|
1676
|
+
serializer = new State$1();
|
|
1859
1677
|
writeReorders = null;
|
|
1860
1678
|
scopes = /* @__PURE__ */ new Map();
|
|
1861
1679
|
scope = (scopeId) => scopeWithId(this, scopeId);
|
|
@@ -1867,13 +1685,36 @@ var State = class {
|
|
|
1867
1685
|
constructor($global) {
|
|
1868
1686
|
this.$global = $global, $global.cspNonce && (this.nonceAttr = " nonce" + attrAssignment($global.cspNonce));
|
|
1869
1687
|
}
|
|
1870
|
-
|
|
1688
|
+
joinFlush(html, scripts, pending) {
|
|
1871
1689
|
let { $global, nonceAttr } = this, { __flush__ } = $global;
|
|
1872
1690
|
return scripts && (html += "<script" + nonceAttr + ">" + scripts + "<\/script>"), __flush__ && ($global.__flush__ = void 0, html = __flush__($global, html)), pending ? html : html + this.trailerHTML;
|
|
1873
1691
|
}
|
|
1874
1692
|
walkScript() {
|
|
1875
1693
|
return this.runtimePrefix + ".w()";
|
|
1876
1694
|
}
|
|
1695
|
+
addResumes(channel, resumes) {
|
|
1696
|
+
channel.resumes = concatSequence(channel.resumes, resumes);
|
|
1697
|
+
}
|
|
1698
|
+
queueScope(target, scopeId, partialScope) {
|
|
1699
|
+
let pending = target.writeScopes[scopeId];
|
|
1700
|
+
pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0;
|
|
1701
|
+
}
|
|
1702
|
+
queuePassiveScope(target, scopeId, partialScope) {
|
|
1703
|
+
let passive = target.passiveScopes ||= {};
|
|
1704
|
+
passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
|
|
1705
|
+
}
|
|
1706
|
+
queueEffect(scopeId, registryId) {
|
|
1707
|
+
this.needsWalkerRuntime = !0, $chunk.writeEffect(scopeId, registryId);
|
|
1708
|
+
}
|
|
1709
|
+
serializeFlush(boundary) {
|
|
1710
|
+
flushSerializer(boundary, this);
|
|
1711
|
+
}
|
|
1712
|
+
runtimeScript() {
|
|
1713
|
+
return "(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]))(\"" + this.$global.runtimeId + "\")(\"" + this.$global.renderId + "\")";
|
|
1714
|
+
}
|
|
1715
|
+
keepsTryMarks(chunk, resumeWrites) {
|
|
1716
|
+
return chunk !== $chunk || chunk.boundary.resumeWrites !== resumeWrites;
|
|
1717
|
+
}
|
|
1877
1718
|
resumeScript(resumes) {
|
|
1878
1719
|
return this.hasWrittenResume ? this.runtimePrefix + ".r.push(" + resumes + ")" : (this.hasWrittenResume = !0, this.runtimePrefix + ".r=[" + resumes + "]");
|
|
1879
1720
|
}
|
|
@@ -1886,11 +1727,11 @@ var State = class {
|
|
|
1886
1727
|
return $global.runtimeId + $global.renderId;
|
|
1887
1728
|
}
|
|
1888
1729
|
reorder(chunk) {
|
|
1889
|
-
this.writeReorders ? this.writeReorders.push(chunk) : (this.
|
|
1730
|
+
this.writeReorders ? this.writeReorders.push(chunk) : (this.needsWalkerRuntime = !0, this.writeReorders = [chunk]);
|
|
1890
1731
|
}
|
|
1891
|
-
|
|
1732
|
+
readyScript(id, resumes) {
|
|
1892
1733
|
let readyKey = toObjectKey(id);
|
|
1893
|
-
return this.readyIds?.has(id) ? this.readyAccess(readyKey) + ".push(" + resumes + ")" : ((this.readyIds ||= /* @__PURE__ */ new Set()).add(id), this.
|
|
1734
|
+
return this.readyIds?.has(id) ? this.readyAccess(readyKey) + ".push(" + resumes + ")" : ((this.readyIds ||= /* @__PURE__ */ new Set()).add(id), this.hasWrittenReady ? this.readyAccess(readyKey) + "=[" + resumes + "]" : (this.hasWrittenReady = !0, this.runtimePrefix + ".b={" + readyKey + ":[" + resumes + "]}"));
|
|
1894
1735
|
}
|
|
1895
1736
|
readyAccess(readyKey) {
|
|
1896
1737
|
return this.runtimePrefix + ".b" + toAccess(readyKey);
|
|
@@ -1932,7 +1773,7 @@ var State = class {
|
|
|
1932
1773
|
this.abort(event.target.reason);
|
|
1933
1774
|
}
|
|
1934
1775
|
flush() {
|
|
1935
|
-
return this.aborted ||
|
|
1776
|
+
return this.aborted || this.state.serializeFlush(this), this.count ? 1 : this.aborted ? 2 : 0;
|
|
1936
1777
|
}
|
|
1937
1778
|
startAsync() {
|
|
1938
1779
|
this.aborted || this.count++;
|
|
@@ -1957,18 +1798,21 @@ var State = class {
|
|
|
1957
1798
|
boundary;
|
|
1958
1799
|
next;
|
|
1959
1800
|
context;
|
|
1960
|
-
|
|
1961
|
-
constructor(boundary, next, context,
|
|
1962
|
-
this.boundary = boundary, this.next = next, this.context = context, this.
|
|
1801
|
+
channel;
|
|
1802
|
+
constructor(boundary, next, context, channel) {
|
|
1803
|
+
this.boundary = boundary, this.next = next, this.context = context, this.channel = channel;
|
|
1963
1804
|
}
|
|
1964
1805
|
fork(boundary, next) {
|
|
1965
|
-
return new Chunk(boundary, next, this.context, this.
|
|
1806
|
+
return new Chunk(boundary, next, this.context, this.channel);
|
|
1807
|
+
}
|
|
1808
|
+
forkRest(boundary) {
|
|
1809
|
+
return $chunk = this.fork(boundary, this.next);
|
|
1966
1810
|
}
|
|
1967
1811
|
writeHTML(html) {
|
|
1968
1812
|
this.html += html;
|
|
1969
1813
|
}
|
|
1970
1814
|
writeEffect(scopeId, registryId) {
|
|
1971
|
-
countResumeWrite(this), this.lastEffect === registryId ? this.effects = concatEffects(this.effects, scopeId + "") : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
|
|
1815
|
+
countResumeWrite(this), writeAsyncVisits(this), this.lastEffect === registryId ? this.effects = concatEffects(this.effects, scopeId + "") : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
|
|
1972
1816
|
}
|
|
1973
1817
|
writeScript(script) {
|
|
1974
1818
|
this.scripts = concatScripts(this.scripts, script);
|
|
@@ -1985,7 +1829,7 @@ var State = class {
|
|
|
1985
1829
|
return this.deferredReady = null, deferredReady;
|
|
1986
1830
|
}
|
|
1987
1831
|
deferOwnReady() {
|
|
1988
|
-
if (this.
|
|
1832
|
+
if (this.channel.readyId && (this.effects || this.scripts || this.channel.flushScopes)) {
|
|
1989
1833
|
let deferred = this.fork(this.boundary, null);
|
|
1990
1834
|
deferred.effects = this.effects, deferred.scripts = this.scripts, this.effects = this.scripts = this.lastEffect = "", this.deferredReady = concat(deferred, this.deferredReady);
|
|
1991
1835
|
}
|
|
@@ -2023,9 +1867,9 @@ var State = class {
|
|
|
2023
1867
|
let { branchId, scopeId, placeholderBranchId } = placeholder, reorderId = body.reorderId = branchId + "";
|
|
2024
1868
|
this.writeHTML(state.mark("!^", reorderId));
|
|
2025
1869
|
let { effects } = this, beforeBranch = deferBranchStart(this);
|
|
2026
|
-
if (this.render(
|
|
1870
|
+
if (this.render(withBranchId, placeholderBranchId, placeholder.render) !== this && this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), this.boundary.aborted) return !0;
|
|
2027
1871
|
let stateful = this.effects !== effects;
|
|
2028
|
-
return applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(
|
|
1872
|
+
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;
|
|
2029
1873
|
}
|
|
2030
1874
|
markCatchRange() {
|
|
2031
1875
|
let { catchRange } = this;
|
|
@@ -2041,14 +1885,14 @@ var State = class {
|
|
|
2041
1885
|
consume(boundary) {
|
|
2042
1886
|
this.renderPlaceholders(boundary);
|
|
2043
1887
|
let cur = this, html = "", effects = "", scripts = "", effectsEnd, heldEffects = this.heldEffects, deferredReady;
|
|
2044
|
-
for (this.heldEffects = null, this.
|
|
2045
|
-
return cur.deferOwnReady(), effects && (cur.
|
|
1888
|
+
for (this.heldEffects = null, this.channel.readyId && this.effects && followHeldEffects(this); cur.next && !cur.async;) cur.markCatchRange(), cur.queueDeferredReorder(), html += cur.html, cur.channel.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;
|
|
1889
|
+
return cur.deferOwnReady(), effects && (cur.channel.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;
|
|
2046
1890
|
}
|
|
2047
|
-
render(content, val) {
|
|
1891
|
+
render(content, val, val2) {
|
|
2048
1892
|
let prev = $chunk;
|
|
2049
1893
|
$chunk = this;
|
|
2050
1894
|
try {
|
|
2051
|
-
return content(val), $chunk;
|
|
1895
|
+
return content(val, val2), $chunk;
|
|
2052
1896
|
} catch (err) {
|
|
2053
1897
|
return this.boundary.abort(err), this;
|
|
2054
1898
|
} finally {
|
|
@@ -2056,35 +1900,35 @@ var State = class {
|
|
|
2056
1900
|
}
|
|
2057
1901
|
}
|
|
2058
1902
|
flushReadyScripts(boundary, reservations, holdEffects) {
|
|
2059
|
-
let {
|
|
1903
|
+
let { channel } = this, { readyId } = channel, scripts = "", held = this.takeDeferredReady();
|
|
2060
1904
|
if (held) for (let chunk of Array.isArray(held) ? held : [held]) chunk.boundary.aborted || (scripts = concatScripts(scripts, chunk.flushReadyScripts(boundary, reservations, holdEffects)), (chunk.effects || chunk.deferredReady) && (this.deferredReady = push(this.deferredReady, chunk)));
|
|
2061
1905
|
if (readyId && !this.async) {
|
|
2062
1906
|
let { state } = boundary;
|
|
2063
|
-
flushSerializer(boundary,
|
|
2064
|
-
let deps = state.serializer
|
|
2065
|
-
if (
|
|
2066
|
-
state.
|
|
1907
|
+
flushSerializer(boundary, channel);
|
|
1908
|
+
let deps = takeChannelDeps(state.serializer), effects = holdEffects ? "" : this.effects, { resumes } = channel, chunkScripts = this.scripts;
|
|
1909
|
+
if (channel.resumes = this.scripts = "", effects && (this.effects = this.lastEffect = ""), resumes || effects) {
|
|
1910
|
+
state.needsWalkerRuntime = !0;
|
|
2067
1911
|
let batch = concatSequence(depsMarker(deps), concatSequence(resumes, effects && `"${effects}"`));
|
|
2068
1912
|
if (reservations) {
|
|
2069
1913
|
let gate = state.readyGate++;
|
|
2070
|
-
reservations.push(state.
|
|
2071
|
-
} else scripts = concatScripts(scripts, state.
|
|
1914
|
+
reservations.push(state.readyScript(readyId, gate + "")), scripts = concatScripts(scripts, "(b=>b.splice(b.indexOf(" + gate + "),1," + batch + "))(" + state.readyAccess(toObjectKey(readyId)) + ")");
|
|
1915
|
+
} else scripts = concatScripts(scripts, state.readyScript(readyId, batch));
|
|
2072
1916
|
}
|
|
2073
1917
|
scripts = concatScripts(scripts, chunkScripts);
|
|
2074
1918
|
}
|
|
2075
1919
|
return scripts;
|
|
2076
1920
|
}
|
|
2077
|
-
|
|
2078
|
-
let { state } = boundary, {
|
|
1921
|
+
flush(boundary) {
|
|
1922
|
+
let { state } = boundary, { runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
|
|
2079
1923
|
needsWalk && (state.walkOnNextFlush = !1), flushSerializer(boundary, state);
|
|
2080
1924
|
let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
|
|
2081
|
-
for (let channel; !boundary.aborted && (channel = state.serializer
|
|
2082
|
-
let resumes = state.serializer
|
|
2083
|
-
state.
|
|
1925
|
+
for (let channel; !boundary.aborted && (channel = pendingReadyChannel(state.serializer));) {
|
|
1926
|
+
let resumes = stringifyScopes(state.serializer, [], boundary, channel), deps = takeChannelDeps(state.serializer);
|
|
1927
|
+
state.needsWalkerRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.readyScript(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
2084
1928
|
}
|
|
2085
1929
|
readyResumeScripts && (needsWalk = !0);
|
|
2086
1930
|
let effects = this.async ? "" : joinHeldEffects(this.takeHeldEffects(), this.effects), { html, scripts } = this;
|
|
2087
|
-
html && state.hasReorderRuntime && (html = state.mark("*", "") + html), state.
|
|
1931
|
+
html && state.hasReorderRuntime && (html = state.mark("*", "") + html), state.needsWalkerRuntime && !state.hasWalkerRuntime && (state.hasWalkerRuntime = !0, scripts = concatScripts(scripts, state.runtimeScript())), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"");
|
|
2088
1932
|
let reordered = "", needsResumeArray = !1;
|
|
2089
1933
|
if (state.writeReorders) {
|
|
2090
1934
|
for (let reorderedChunk of state.writeReorders) {
|
|
@@ -2110,9 +1954,9 @@ var State = class {
|
|
|
2110
1954
|
}
|
|
2111
1955
|
flushHTML(boundary) {
|
|
2112
1956
|
let { state } = boundary;
|
|
2113
|
-
this.
|
|
1957
|
+
this.flush(boundary);
|
|
2114
1958
|
let { html, scripts } = this;
|
|
2115
|
-
return this.html = this.scripts = "", state.
|
|
1959
|
+
return this.html = this.scripts = "", state.joinFlush(html, scripts, boundary.count);
|
|
2116
1960
|
}
|
|
2117
1961
|
};
|
|
2118
1962
|
function renderReorderPlaceholders(reorder, reorders) {
|
|
@@ -2131,7 +1975,7 @@ function followHeldEffects(chunk) {
|
|
|
2131
1975
|
held !== chunk && (held.effects = concatEffects(held.effects, chunk.effects), chunk.effects = "");
|
|
2132
1976
|
}
|
|
2133
1977
|
function lastHeldOf(held, cur) {
|
|
2134
|
-
return cur.
|
|
1978
|
+
return cur.channel === held.channel && cur.boundary === held.boundary ? cur : held;
|
|
2135
1979
|
}
|
|
2136
1980
|
function holdEffectsOn(heldEffects, chunk, effects) {
|
|
2137
1981
|
return chunk.effects = effects, push(heldEffects, chunk);
|
|
@@ -2141,7 +1985,7 @@ function isWithin(boundary, outer) {
|
|
|
2141
1985
|
return !!boundary;
|
|
2142
1986
|
}
|
|
2143
1987
|
function holdReorderEffects(head, boundary, effects) {
|
|
2144
|
-
head.
|
|
1988
|
+
head.channel.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);
|
|
2145
1989
|
}
|
|
2146
1990
|
function joinHeldEffects(heldEffects, effects) {
|
|
2147
1991
|
return concatEffects(reduce(heldEffects, joinUncaught, ""), effects);
|
|
@@ -2149,16 +1993,16 @@ function joinHeldEffects(heldEffects, effects) {
|
|
|
2149
1993
|
function joinUncaught(joined, held) {
|
|
2150
1994
|
return held.boundary.aborted ? joined : concatEffects(joined, held.effects);
|
|
2151
1995
|
}
|
|
2152
|
-
function flushSerializer(boundary,
|
|
2153
|
-
let { state } = boundary, { serializer } = state, pending = serializer.
|
|
2154
|
-
if (
|
|
2155
|
-
let { writeScopes, passiveScopes } =
|
|
1996
|
+
function flushSerializer(boundary, channel) {
|
|
1997
|
+
let { state } = boundary, { serializer } = state, pending = hasMatchingCalls(serializer, channel.readyId);
|
|
1998
|
+
if (channel.flushScopes || pending) {
|
|
1999
|
+
let { writeScopes, passiveScopes } = channel, flushes = [];
|
|
2156
2000
|
if (passiveScopes) for (let key in passiveScopes) {
|
|
2157
2001
|
let props = writeScopes[key];
|
|
2158
2002
|
props && (writeScopes[key] = Object.assign(passiveScopes[key], props), delete passiveScopes[key]);
|
|
2159
2003
|
}
|
|
2160
|
-
if (!
|
|
2161
|
-
state.
|
|
2004
|
+
if (!channel.readyId && !state.hasWrittenGlobals) {
|
|
2005
|
+
state.hasWrittenGlobals = !0;
|
|
2162
2006
|
let globals = getFilteredGlobals(state.$global);
|
|
2163
2007
|
globals && flushes.push([
|
|
2164
2008
|
0,
|
|
@@ -2174,12 +2018,12 @@ function flushSerializer(boundary, serializeState) {
|
|
|
2174
2018
|
props
|
|
2175
2019
|
]);
|
|
2176
2020
|
}
|
|
2177
|
-
(flushes.length || pending) && (
|
|
2021
|
+
(flushes.length || pending) && (channel.readyId && !state.hasWrittenGlobals && flushSerializerGlobals(boundary), state.addResumes(channel, stringifyScopes(serializer, flushes, boundary, channel))), channel.writeScopes = {}, channel.flushScopes = !1, pending && (state.walkOnNextFlush = !0);
|
|
2178
2022
|
}
|
|
2179
2023
|
}
|
|
2180
2024
|
function flushSerializerGlobals(boundary) {
|
|
2181
2025
|
let { state } = boundary, globals = getFilteredGlobals(state.$global);
|
|
2182
|
-
globals && (state.
|
|
2026
|
+
globals && (state.hasWrittenGlobals = !0, state.needsWalkerRuntime = !0, state.resumes = concatSequence(state.resumes, stringifyScopes(state.serializer, [[
|
|
2183
2027
|
0,
|
|
2184
2028
|
globals,
|
|
2185
2029
|
globals
|
|
@@ -2463,11 +2307,11 @@ function writeLoadAsset(assetId, flush, triggers) {
|
|
|
2463
2307
|
let g = $global();
|
|
2464
2308
|
writeAsset(g, addAsset(g, assetId, flush, triggers));
|
|
2465
2309
|
}
|
|
2466
|
-
function withPageAssets(template,
|
|
2310
|
+
function withPageAssets(template, flush, assetId, runtimeId) {
|
|
2467
2311
|
return Object.assign((input) => {
|
|
2468
2312
|
let g = $global();
|
|
2469
2313
|
runtimeId && (g[kAssets] || (g.runtimeId = runtimeId));
|
|
2470
|
-
let asset = addAsset(g, assetId,
|
|
2314
|
+
let asset = addAsset(g, assetId, flush);
|
|
2471
2315
|
return g.__flush__ ? (writeAsset(g, asset), writeWaitReady(assetId, template, input)) : (g.__flush__ = flushPage, template(input));
|
|
2472
2316
|
}, template);
|
|
2473
2317
|
}
|
|
@@ -2538,6 +2382,212 @@ function toObjectExpression(options) {
|
|
|
2538
2382
|
//#endregion
|
|
2539
2383
|
//#region src/common/compat-meta.ts
|
|
2540
2384
|
//#endregion
|
|
2385
|
+
//#region src/common/for.ts
|
|
2386
|
+
function forIn(obj, cb) {
|
|
2387
|
+
for (let key in obj) cb(key, obj[key]);
|
|
2388
|
+
}
|
|
2389
|
+
function forOf(list, cb) {
|
|
2390
|
+
if (list) {
|
|
2391
|
+
let i = 0;
|
|
2392
|
+
for (let item of list) cb(item, i++);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
function forTo(to, from, step, cb) {
|
|
2396
|
+
let start = from || 0, delta = step || 1;
|
|
2397
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
2398
|
+
}
|
|
2399
|
+
function forUntil(until, from, step, cb) {
|
|
2400
|
+
let start = from || 0, delta = step || 1;
|
|
2401
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
2402
|
+
}
|
|
2403
|
+
//#endregion
|
|
2404
|
+
//#region src/html/for.ts
|
|
2405
|
+
function forOfBy(by, item, index) {
|
|
2406
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
|
2407
|
+
}
|
|
2408
|
+
function forInBy(by, name, value) {
|
|
2409
|
+
return by ? by(name, value) : name;
|
|
2410
|
+
}
|
|
2411
|
+
function forStepBy(by, index) {
|
|
2412
|
+
return by ? by(index) : index;
|
|
2413
|
+
}
|
|
2414
|
+
//#endregion
|
|
2415
|
+
//#region src/html/control-flow.ts
|
|
2416
|
+
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
2417
|
+
display ? resumesMarker(markerGuard, branchExprGuard, parentEndTag) && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
|
|
2418
|
+
}
|
|
2419
|
+
function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2420
|
+
let branchId = _scope_id(), wrap = !display;
|
|
2421
|
+
wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
2422
|
+
}
|
|
2423
|
+
function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2424
|
+
forBranches(by, cb, iterateForOf(list, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2425
|
+
}
|
|
2426
|
+
function iterateForOf(list, cb, by) {
|
|
2427
|
+
return (each) => each ? forOf(list, (item, index) => {
|
|
2428
|
+
let itemKey = forOfBy(by, item, index);
|
|
2429
|
+
each(itemKey, itemKey === index, item, index);
|
|
2430
|
+
}) : forOf(list, cb);
|
|
2431
|
+
}
|
|
2432
|
+
function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2433
|
+
forBranches(by, cb, iterateForIn(obj, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2434
|
+
}
|
|
2435
|
+
function iterateForIn(obj, cb, by) {
|
|
2436
|
+
return (each) => each ? forIn(obj, (key, value) => {
|
|
2437
|
+
each(forInBy(by, key, value), !1, key, value);
|
|
2438
|
+
}) : forIn(obj, cb);
|
|
2439
|
+
}
|
|
2440
|
+
function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2441
|
+
forBranches(by, cb, iterateForTo(to, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2442
|
+
}
|
|
2443
|
+
function iterateForTo(to, from, step, cb, by) {
|
|
2444
|
+
return (each) => {
|
|
2445
|
+
let index = 0;
|
|
2446
|
+
return each ? forTo(to, from, step, (value) => {
|
|
2447
|
+
let itemKey = forStepBy(by, value);
|
|
2448
|
+
each(itemKey, itemKey === index++, value);
|
|
2449
|
+
}) : forTo(to, from, step, cb);
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
function _for_until(until, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2453
|
+
forBranches(by, cb, iterateForUntil(until, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2454
|
+
}
|
|
2455
|
+
function iterateForUntil(until, from, step, cb, by) {
|
|
2456
|
+
return (each) => {
|
|
2457
|
+
let index = 0;
|
|
2458
|
+
return each ? forUntil(until, from, step, (value) => {
|
|
2459
|
+
let itemKey = forStepBy(by, value);
|
|
2460
|
+
each(itemKey, itemKey === index++, value);
|
|
2461
|
+
}) : forUntil(until, from, step, cb);
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
2464
|
+
function forBranches(by, cb, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2465
|
+
if (branchGuard === 0) {
|
|
2466
|
+
iterate(0), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
let { state } = $chunk.boundary, resumeKeys = markerGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), flushBranchIds = "", loopScopes;
|
|
2470
|
+
iterate((itemKey, sameAsIndex, a, b) => {
|
|
2471
|
+
let branchId = _peek_scope_id();
|
|
2472
|
+
resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, cb, a, b);
|
|
2473
|
+
let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
|
|
2474
|
+
resumeMarker || (loopScopes = push(loopScopes, branchScope));
|
|
2475
|
+
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
2476
|
+
}
|
|
2477
|
+
function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2478
|
+
let resumeBranch = branchGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
2479
|
+
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
2480
|
+
["D" + accessor]: branchIndex || void 0,
|
|
2481
|
+
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
2482
|
+
}), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
2483
|
+
}
|
|
2484
|
+
function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
2485
|
+
return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
|
|
2486
|
+
}
|
|
2487
|
+
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
2488
|
+
let endTag = parentEndTag || "";
|
|
2489
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
|
|
2490
|
+
let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
2491
|
+
$chunk.writeHTML(mark + endTag);
|
|
2492
|
+
} else markerGuard === 0 ? $chunk.writeHTML(endTag) : $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
2493
|
+
}
|
|
2494
|
+
function _await(scopeId, accessor, promise, content, markerGuard) {
|
|
2495
|
+
let resumeMarker = markerGuard !== 0;
|
|
2496
|
+
if (!isPromise(promise)) {
|
|
2497
|
+
if (resumeMarker) {
|
|
2498
|
+
let branchId = _peek_scope_id();
|
|
2499
|
+
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, content, promise), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2500
|
+
} else content(promise);
|
|
2501
|
+
return;
|
|
2502
|
+
}
|
|
2503
|
+
let chunk = $chunk, { boundary } = chunk, startId = _peek_scope_id(), after = chunk.next = chunk.forkRest(boundary);
|
|
2504
|
+
chunk.async = !0, captureContext(chunk), boundary.startAsync(), promise.then((value) => {
|
|
2505
|
+
if (chunk.async && (chunk.async = !1, !boundary.aborted)) {
|
|
2506
|
+
let { state } = boundary;
|
|
2507
|
+
chunk.render(() => {
|
|
2508
|
+
if (resumeMarker) {
|
|
2509
|
+
let branchId = _peek_scope_id();
|
|
2510
|
+
$chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withAsyncContent({ parent: getAsyncContent(chunk) }, content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2511
|
+
} else {
|
|
2512
|
+
let renderedSince = _peek_scope_id() !== startId, async = { parent: getAsyncContent(chunk) };
|
|
2513
|
+
withAsyncContent(async, content, value), async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "", async.resumed && $chunk.writeHTML(async.visit), async.end = $chunk;
|
|
2514
|
+
}
|
|
2515
|
+
}), !chunk.async && boundary.pendingReorders?.delete(chunk) && state.reorder(chunk), boundary.endAsync();
|
|
2516
|
+
}
|
|
2517
|
+
}, (err) => {
|
|
2518
|
+
chunk.async = !1, boundary.abort(err);
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
|
|
2522
|
+
let placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId)), writesRenderers = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers), keepsMarks = state.keepsTryMarks(chunk, resumeWrites);
|
|
2523
|
+
applyBranchStart(chunk, beforeBranch, keepsMarks), keepsMarks && (writesRenderers || renderers(), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
|
|
2524
|
+
}
|
|
2525
|
+
function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
|
|
2526
|
+
let chunk = $chunk, { boundary } = chunk, body = chunk.fork(boundary, null);
|
|
2527
|
+
if (body === body.render(content)) {
|
|
2528
|
+
chunk.append(body);
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
chunk.next = chunk.forkRest(boundary), captureContext(chunk), chunk.placeholder = {
|
|
2532
|
+
body,
|
|
2533
|
+
render: placeholder,
|
|
2534
|
+
branchId,
|
|
2535
|
+
scopeId,
|
|
2536
|
+
placeholderBranchId
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function tryBoundary(content, catchContent, branchId, renderers) {
|
|
2540
|
+
let chunk = $chunk, { boundary } = chunk, { state } = boundary, bodyBoundary = new Boundary(state, void 0, boundary);
|
|
2541
|
+
catchContent && (bodyBoundary.withinCatch = !0);
|
|
2542
|
+
let body = chunk.fork(bodyBoundary, null), bodyEnd = body.render(withBranchId, branchId, content);
|
|
2543
|
+
if (bodyBoundary.aborted) {
|
|
2544
|
+
if (!catchContent) throw bodyBoundary.reason;
|
|
2545
|
+
return catchContent(bodyBoundary.reason), !0;
|
|
2546
|
+
}
|
|
2547
|
+
if (body === bodyEnd) return chunk.append(body), !1;
|
|
2548
|
+
let renderersAtSettle = !bodyBoundary.resumeWrites, bodyNext = bodyEnd.next = chunk.forkRest(boundary);
|
|
2549
|
+
chunk.next = body, boundary.startAsync();
|
|
2550
|
+
let reorderId = catchContent ? state.nextReorderId() : "";
|
|
2551
|
+
return reorderId && (chunk.catchRange = {
|
|
2552
|
+
id: reorderId,
|
|
2553
|
+
end: bodyEnd
|
|
2554
|
+
}, captureContext(chunk)), bodyBoundary.onNext = () => {
|
|
2555
|
+
if (!boundary.aborted) {
|
|
2556
|
+
if (bodyBoundary.aborted) {
|
|
2557
|
+
if (!reorderId) {
|
|
2558
|
+
boundary.abort(bodyBoundary.reason);
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
let streamed = !chunk.catchRange, catchChunk = chunk.fork(boundary, null);
|
|
2562
|
+
chunk.catchRange = null, renderersAtSettle || catchChunk.render(clearTryRenderers, branchId);
|
|
2563
|
+
let inOrder = catchChunk === catchChunk.render(catchContent, bodyBoundary.reason);
|
|
2564
|
+
if (boundary.aborted) return;
|
|
2565
|
+
if ((bodyEnd.consumed || !inOrder) && (catchChunk.reorderBranch = branchId), bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
|
|
2566
|
+
else {
|
|
2567
|
+
let reorder = null;
|
|
2568
|
+
inOrder ? streamed && (reorder = chunk.fork(boundary, null)) : reorder = catchChunk, reorder && (reorder.reorderId = reorderId);
|
|
2569
|
+
let endMarker = state.mark("!", reorderId), cut = body;
|
|
2570
|
+
for (; cut.consumed;) cut = cut.next;
|
|
2571
|
+
cut.async = !1, cut.next = inOrder ? catchChunk : bodyNext, cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker, cut.scripts = cut.effects = cut.lastEffect = "", cut.placeholder = cut.reorderId = cut.catchRange = null, cut.deferredReorder = reorder, inOrder && (catchChunk.next = bodyNext);
|
|
2572
|
+
}
|
|
2573
|
+
boundary.endAsync();
|
|
2574
|
+
} else bodyBoundary.count ? boundary.onNext() : (renderersAtSettle && bodyBoundary.resumeWrites && bodyEnd.render(renderers), chunk.catchRange = null, boundary.endAsync());
|
|
2575
|
+
}
|
|
2576
|
+
}, renderersAtSettle;
|
|
2577
|
+
}
|
|
2578
|
+
function clearTryRenderers(branchId) {
|
|
2579
|
+
writeScope(branchId, {
|
|
2580
|
+
E: 0,
|
|
2581
|
+
Q: _scope_with_id(branchId).Q && 0
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
2585
|
+
writeScope(branchId, {
|
|
2586
|
+
E: catchContent,
|
|
2587
|
+
Q: placeholderContent
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
//#endregion
|
|
2541
2591
|
//#region src/html/compat.ts
|
|
2542
2592
|
function drainClassFunctions($global, writeScope) {
|
|
2543
2593
|
let pending = pendingClassFunctions.get($global), scopeByHost = {};
|