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