marko 6.4.5 → 6.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/errors.d.ts +2 -1
- package/dist/common/helpers.d.ts +7 -7
- package/dist/debug/dom/catch.feat.js +3 -3
- package/dist/debug/dom/catch.feat.mjs +3 -3
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +5 -5
- package/dist/debug/dom/controllable.feat.mjs +5 -5
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +1 -1
- package/dist/debug/dom/lazy.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-CUxvM4i9.js → dom-CNgQ6lj9.js} +52 -52
- package/dist/debug/{dom-BeY1nGUb.mjs → dom-o9jQjchF.mjs} +43 -43
- package/dist/debug/dom.js +4 -4
- package/dist/debug/dom.mjs +4 -4
- package/dist/debug/html.js +721 -652
- package/dist/debug/html.mjs +721 -652
- package/dist/dom/catch.feat.js +4 -4
- package/dist/dom/catch.feat.mjs +3 -3
- package/dist/dom/control-flow.d.ts +2 -2
- package/dist/dom/controllable-input.feat.js +2 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +2 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +2 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +2 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.d.ts +4 -4
- package/dist/dom/controllable.feat.js +2 -2
- package/dist/dom/controllable.feat.mjs +2 -2
- package/dist/dom/dom.d.ts +5 -5
- package/dist/dom/dynamic-tag-script.feat.js +2 -2
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +2 -2
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.js +1 -1
- package/dist/dom/lazy.feat.mjs +1 -1
- package/dist/dom/placeholder.feat.js +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/signals.d.ts +4 -1
- package/dist/{dom-Diu8MpmL.js → dom-60R4bRWD.js} +40 -40
- package/dist/{dom-DefWmvQB.mjs → dom-Ci2W4l1P.mjs} +33 -33
- package/dist/dom.js +6 -6
- package/dist/dom.mjs +4 -4
- package/dist/html/assets.d.ts +1 -1
- package/dist/html/compat.d.ts +2 -1
- package/dist/html/control-flow.d.ts +20 -0
- package/dist/html/serializer.d.ts +63 -16
- package/dist/html/writer.d.ts +47 -35
- package/dist/html.d.ts +2 -1
- package/dist/html.js +517 -467
- package/dist/html.mjs +517 -467
- package/dist/translator/core/for.d.ts +0 -4
- package/dist/translator/core/return.d.ts +0 -3
- package/dist/translator/core/style.d.ts +2 -2
- package/dist/translator/index.js +7934 -7978
- package/dist/translator/util/analyze-errors.d.ts +2 -1
- package/dist/translator/util/assert.d.ts +8 -1
- package/dist/translator/util/bindings.d.ts +13 -9
- package/dist/translator/util/body-to-text.d.ts +9 -0
- package/dist/translator/util/branch-tag.d.ts +10 -3
- package/dist/translator/util/build-string-expression.d.ts +4 -0
- package/dist/translator/util/content-derives.d.ts +7 -0
- package/dist/translator/util/entry-builder.d.ts +6 -2
- package/dist/translator/util/finalize-references.d.ts +3 -2
- package/dist/translator/util/generate-uid.d.ts +3 -2
- package/dist/translator/util/get-root.d.ts +3 -3
- package/dist/translator/util/get-tag-name.d.ts +1 -1
- package/dist/translator/util/known-tag.d.ts +10 -8
- package/dist/translator/util/module-read.d.ts +0 -3
- package/dist/translator/util/module-registrations.d.ts +44 -0
- package/dist/translator/util/nested-attribute-tags.d.ts +1 -1
- package/dist/translator/util/optional.d.ts +6 -1
- package/dist/translator/util/params-tree.d.ts +18 -0
- package/dist/translator/util/reasons.d.ts +10 -8
- package/dist/translator/util/references.d.ts +21 -27
- package/dist/translator/util/runtime.d.ts +0 -12
- package/dist/translator/util/scope-accessor.d.ts +0 -1
- package/dist/translator/util/scope-read.d.ts +3 -0
- package/dist/translator/util/section-renderer.d.ts +4 -0
- package/dist/translator/util/sections.d.ts +16 -16
- package/dist/translator/util/setup-work.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +14 -12
- package/dist/translator/util/simplify-fn.d.ts +1 -0
- package/dist/translator/util/slots.d.ts +2 -2
- package/dist/translator/util/solve-reasons.d.ts +1 -3
- package/dist/translator/util/sources.d.ts +2 -1
- package/dist/translator/util/statement-tag.d.ts +2 -0
- package/dist/translator/util/static-text.d.ts +2 -1
- package/dist/translator/util/structure.d.ts +0 -10
- package/dist/translator/util/tag-facts.d.ts +8 -1
- package/dist/translator/util/tag-import.d.ts +20 -0
- package/dist/translator/util/tag-name-type.d.ts +9 -2
- package/dist/translator/util/to-only-or-block.d.ts +3 -0
- package/dist/translator/util/to-property-name.d.ts +2 -0
- package/dist/translator/util/translate-attrs.d.ts +7 -5
- package/dist/translator/util/translate-var.d.ts +2 -0
- package/dist/translator/util/traverse.d.ts +1 -2
- package/dist/translator/util/visitors.d.ts +4 -1
- package/dist/translator/util/with-previous-location.d.ts +1 -1
- package/dist/translator/util/write-guard.d.ts +2 -2
- package/dist/translator/util/writer.d.ts +1 -2
- package/dist/translator/visitors/export-declaration.d.ts +2 -3
- package/dist/translator/visitors/function.d.ts +0 -35
- package/dist/translator/visitors/import-declaration.d.ts +0 -16
- package/dist/translator/visitors/placeholder.d.ts +2 -1
- package/dist/translator/visitors/program/html.d.ts +0 -1
- package/dist/translator/visitors/program/index.d.ts +4 -5
- package/dist/translator/visitors/tag/custom-tag.d.ts +0 -14
- package/dist/translator/visitors/tag/native-tag.d.ts +3 -12
- package/package.json +3 -3
- package/dist/translator/util/binding-has-prop.d.ts +0 -8
- package/dist/translator/util/binding-prop-tree.d.ts +0 -18
- package/dist/translator/util/body-to-text-literal.d.ts +0 -9
- package/dist/translator/util/import-reference.d.ts +0 -3
- package/dist/translator/util/normalize-string-expression.d.ts +0 -4
- package/dist/translator/util/plugin-hooks.d.ts +0 -4
- package/dist/translator/util/resolve-relative-to-entry.d.ts +0 -2
- package/dist/translator/util/set-tag-derived-from.d.ts +0 -7
- package/dist/translator/util/to-first-expression-or-block.d.ts +0 -2
- package/dist/translator/util/to-first-statement-or-block.d.ts +0 -2
package/dist/debug/html.mjs
CHANGED
|
@@ -38,7 +38,7 @@ const Embed = "embed";
|
|
|
38
38
|
const Lazy = "lazy";
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/common/helpers.ts
|
|
41
|
-
const
|
|
41
|
+
const invalidNativeAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
42
42
|
const knownWrongAttrs = {
|
|
43
43
|
className: "class",
|
|
44
44
|
classList: "class",
|
|
@@ -76,11 +76,11 @@ function getWrongAttrSuggestion(name) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function stringifyClassEntry(name, value) {
|
|
80
80
|
return value ? name : "";
|
|
81
81
|
}
|
|
82
82
|
const warnedStyleKeys = /* @__PURE__ */ new Set();
|
|
83
|
-
function
|
|
83
|
+
function stringifyStyleEntry(name, value) {
|
|
84
84
|
if (/[A-Z]/.test(name) && !name.includes("-") && !warnedStyleKeys.has(name)) {
|
|
85
85
|
warnedStyleKeys.add(name);
|
|
86
86
|
console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
|
|
@@ -127,17 +127,17 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
127
127
|
function isEventHandler(name) {
|
|
128
128
|
return /^on[A-Z-]/.test(name);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function getEventType(name) {
|
|
131
131
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
132
132
|
}
|
|
133
133
|
function hasKeys(obj) {
|
|
134
134
|
for (const _ in obj) return true;
|
|
135
135
|
return false;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function isNullishOrFalse(value) {
|
|
138
138
|
return value == null || value === false;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function isNotNullishOrFalse(value) {
|
|
141
141
|
return value != null && value !== false;
|
|
142
142
|
}
|
|
143
143
|
function isPromise(value) {
|
|
@@ -156,9 +156,9 @@ function normalizeDynamicRenderer(value) {
|
|
|
156
156
|
}
|
|
157
157
|
//#endregion
|
|
158
158
|
//#region src/common/errors.ts
|
|
159
|
-
const
|
|
159
|
+
const lowercaseOnAttrReg = /^on[a-z]/;
|
|
160
160
|
function assertValidAttrValue(name, value) {
|
|
161
|
-
if (value && typeof value !== "string" &&
|
|
161
|
+
if (value && typeof value !== "string" && lowercaseOnAttrReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
|
|
162
162
|
if (typeof value === "function") throw new Error(`The \`${name}\` attribute cannot be a function.${/Change$/.test(name) ? " A change handler is only used when its matching controllable attribute combination applies." : ""}`);
|
|
163
163
|
const unrenderable = describeUnrenderable(value);
|
|
164
164
|
if (unrenderable) throw new Error(`The \`${name}\` attribute cannot be ${unrenderable}.`);
|
|
@@ -197,7 +197,7 @@ function describeUnrenderable(value) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
function assertValidLoopKey(key, seenKeys) {
|
|
200
|
-
if (typeof key !== "string" && typeof key !== "number") throw new Error(`A \`<for>\` tag's \`by\` attribute must return a string or number for each item, but received ${key === null ?
|
|
200
|
+
if (typeof key !== "string" && typeof key !== "number" || key !== key) throw new Error(`A \`<for>\` tag's \`by\` attribute must return a string or number for each item, but received ${key === null || key !== key ? key : `type "${typeof key}"`}.`);
|
|
201
201
|
if (seenKeys) {
|
|
202
202
|
if (seenKeys.has(key)) throw new Error(`A \`<for>\` tag's \`by\` attribute must return a unique value for each item, but \`${key}\` was used more than once.`);
|
|
203
203
|
seenKeys.add(key);
|
|
@@ -206,7 +206,7 @@ function assertValidLoopKey(key, seenKeys) {
|
|
|
206
206
|
function assertValidList(value) {
|
|
207
207
|
if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function assertOptionalRangeNumber(name, value) {
|
|
210
210
|
if (value && (typeof value !== "number" || !isFinite(value))) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
211
211
|
}
|
|
212
212
|
function assertValidRangeBound(name, value) {
|
|
@@ -216,7 +216,7 @@ function describeForValue(value) {
|
|
|
216
216
|
return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
|
|
217
217
|
}
|
|
218
218
|
function assertValidAttrName(name) {
|
|
219
|
-
if (
|
|
219
|
+
if (invalidNativeAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
220
220
|
const suggestion = getWrongAttrSuggestion(name);
|
|
221
221
|
if (suggestion) throw new Error(`\`${name}\` is not a valid attribute, did you mean \`${suggestion}\`?`);
|
|
222
222
|
}
|
|
@@ -276,34 +276,6 @@ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
|
276
276
|
const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
|
|
277
277
|
const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
|
|
278
278
|
//#endregion
|
|
279
|
-
//#region src/common/for.ts
|
|
280
|
-
function forIn(obj, cb) {
|
|
281
|
-
for (const key in obj) cb(key, obj[key]);
|
|
282
|
-
}
|
|
283
|
-
function forOf(list, cb) {
|
|
284
|
-
assertValidList(list);
|
|
285
|
-
if (list) {
|
|
286
|
-
let i = 0;
|
|
287
|
-
for (const item of list) cb(item, i++);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function forTo(to, from, step, cb) {
|
|
291
|
-
assertValidRangeBound("to", to);
|
|
292
|
-
assertValidRangeStart("from", from);
|
|
293
|
-
assertValidRangeStart("step", step);
|
|
294
|
-
const start = from || 0;
|
|
295
|
-
const delta = step || 1;
|
|
296
|
-
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
297
|
-
}
|
|
298
|
-
function forUntil(until, from, step, cb) {
|
|
299
|
-
assertValidRangeBound("until", until);
|
|
300
|
-
assertValidRangeStart("from", from);
|
|
301
|
-
assertValidRangeStart("step", step);
|
|
302
|
-
const start = from || 0;
|
|
303
|
-
const delta = step || 1;
|
|
304
|
-
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
279
|
//#region src/common/opt.ts
|
|
308
280
|
function reduce(opt, cb, acc) {
|
|
309
281
|
if (opt) {
|
|
@@ -579,15 +551,57 @@ var State$1 = class {
|
|
|
579
551
|
buf = [];
|
|
580
552
|
strs = /* @__PURE__ */ new Map();
|
|
581
553
|
refs = /* @__PURE__ */ new WeakMap();
|
|
582
|
-
|
|
554
|
+
deferredRefs = /* @__PURE__ */ new Set();
|
|
583
555
|
boundary;
|
|
584
556
|
channel = void 0;
|
|
585
557
|
channelDeps = null;
|
|
586
|
-
|
|
558
|
+
queuedCalls = [];
|
|
559
|
+
queuedReadyCalls = [];
|
|
560
|
+
scopeRef(scope, scopeId) {
|
|
561
|
+
return this.refs.get(scope) || newScopeReference(this, scope, scopeId);
|
|
562
|
+
}
|
|
563
|
+
writeScopeProps(props, ref) {
|
|
564
|
+
return writeObjectProps(this, props, ref);
|
|
565
|
+
}
|
|
566
|
+
scopesCursor(scopeId) {
|
|
567
|
+
return scopeId + ",";
|
|
568
|
+
}
|
|
569
|
+
writeTrailing(scopesIndex) {
|
|
570
|
+
const { buf } = this;
|
|
571
|
+
if (~scopesIndex) {
|
|
572
|
+
buf[scopesIndex] = "_([" + buf[scopesIndex];
|
|
573
|
+
buf.push("])");
|
|
574
|
+
}
|
|
575
|
+
writeDeferred(this);
|
|
576
|
+
return ",0)";
|
|
577
|
+
}
|
|
578
|
+
wrapPayload(result, extras) {
|
|
579
|
+
const arrow = this.wroteUndefined ? "(_,$)=>" : "_=>";
|
|
580
|
+
this.wroteUndefined = false;
|
|
581
|
+
return extras ? arrow + result : arrow + "[" + result + "]";
|
|
582
|
+
}
|
|
583
|
+
writeScopedRegistration(val, parent, accessor, registered) {
|
|
584
|
+
const ref = new Reference(parent, accessor, this.flushId, this.buf.length);
|
|
585
|
+
ref.channel = this.channel;
|
|
586
|
+
this.refs.set(val, ref);
|
|
587
|
+
ref.debug = DEBUG.get(val);
|
|
588
|
+
const scope = registered.scope;
|
|
589
|
+
const scopeId = scope[K_SCOPE_ID];
|
|
590
|
+
trackScope(this, scope, scopeId);
|
|
591
|
+
const locals = registered.locals?.(this.boundary.state.scope);
|
|
592
|
+
if (locals) {
|
|
593
|
+
this.buf.push(registered.access + "(_(" + scopeId + ")");
|
|
594
|
+
for (const local of locals) {
|
|
595
|
+
this.buf.push(",");
|
|
596
|
+
writePlainObject(this, local, newArgReference(this, ref, local));
|
|
597
|
+
}
|
|
598
|
+
} else this.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
|
|
599
|
+
this.buf.push(")");
|
|
600
|
+
}
|
|
587
601
|
};
|
|
588
602
|
var Reference = class {
|
|
589
603
|
assignments = null;
|
|
590
|
-
|
|
604
|
+
deferredMembers = null;
|
|
591
605
|
scopeId = void 0;
|
|
592
606
|
channel = void 0;
|
|
593
607
|
parent;
|
|
@@ -623,109 +637,86 @@ function setDebugSlotName(obj, accessor, name) {
|
|
|
623
637
|
slots: { [accessor]: name }
|
|
624
638
|
});
|
|
625
639
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
this.#state.channel = channel;
|
|
638
|
-
return writeScopesRoot(this.#state, flushes);
|
|
639
|
-
} catch (err) {
|
|
640
|
-
abortRender(boundary, err);
|
|
641
|
-
return "";
|
|
642
|
-
} finally {
|
|
643
|
-
this.#state.flushId++;
|
|
644
|
-
this.#state.buf = [];
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
written(val) {
|
|
648
|
-
return this.#state.refs.has(val);
|
|
649
|
-
}
|
|
650
|
-
takeChannelDeps() {
|
|
651
|
-
const deps = this.#state.channelDeps;
|
|
652
|
-
this.#state.channelDeps = null;
|
|
653
|
-
return deps;
|
|
654
|
-
}
|
|
655
|
-
writeCall(value, object, property, channel) {
|
|
656
|
-
this.#state.mutated.push({
|
|
657
|
-
value,
|
|
658
|
-
object,
|
|
659
|
-
property,
|
|
660
|
-
channel
|
|
661
|
-
});
|
|
640
|
+
function stringifyScopes(state, flushes, boundary, channel) {
|
|
641
|
+
try {
|
|
642
|
+
state.boundary = boundary;
|
|
643
|
+
state.channel = channel;
|
|
644
|
+
return writeScopesRoot(state, flushes);
|
|
645
|
+
} catch (err) {
|
|
646
|
+
abortRender(boundary, err);
|
|
647
|
+
return "";
|
|
648
|
+
} finally {
|
|
649
|
+
state.flushId++;
|
|
650
|
+
state.buf = [];
|
|
662
651
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
652
|
+
}
|
|
653
|
+
function pendingReadyChannel(state) {
|
|
654
|
+
const calls = state.queuedReadyCalls;
|
|
655
|
+
return calls.length ? calls[0].channel : void 0;
|
|
656
|
+
}
|
|
657
|
+
function takeChannelDeps(state) {
|
|
658
|
+
const deps = state.channelDeps;
|
|
659
|
+
state.channelDeps = null;
|
|
660
|
+
return deps;
|
|
661
|
+
}
|
|
662
|
+
function queueCall(state, value, object, method, channel) {
|
|
663
|
+
(channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
|
|
664
|
+
method,
|
|
665
|
+
value,
|
|
666
|
+
object,
|
|
667
|
+
channel,
|
|
668
|
+
valueId: null
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
function dropQueuedCall(state, value, object, method, channel) {
|
|
672
|
+
const queuedCalls = channel?.readyId ? state.queuedReadyCalls : state.queuedCalls;
|
|
673
|
+
for (let i = 0; i < queuedCalls.length; i++) {
|
|
674
|
+
const call = queuedCalls[i];
|
|
675
|
+
if (call.value === value && call.object === object && call.method === method) {
|
|
676
|
+
queuedCalls.splice(i, 1);
|
|
677
|
+
return true;
|
|
671
678
|
}
|
|
672
|
-
return false;
|
|
673
679
|
}
|
|
674
|
-
|
|
675
|
-
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
function register(id, val, scope, locals, access = "_._" + toAccess(toObjectKey(id))) {
|
|
676
683
|
REGISTRY.set(val, {
|
|
677
684
|
id,
|
|
678
685
|
scope,
|
|
679
686
|
locals,
|
|
680
|
-
access
|
|
687
|
+
access
|
|
681
688
|
});
|
|
682
689
|
return val;
|
|
683
690
|
}
|
|
684
|
-
function getRegistered(val) {
|
|
685
|
-
const registered = REGISTRY.get(val);
|
|
686
|
-
if (registered) return {
|
|
687
|
-
id: registered.id,
|
|
688
|
-
scope: registered.scope
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
691
|
function writeScopesRoot(state, flushes) {
|
|
692
692
|
const { buf } = state;
|
|
693
693
|
let nextSlotId = -1;
|
|
694
|
-
let
|
|
694
|
+
let scopesIndex = -1;
|
|
695
695
|
for (const flush of flushes) {
|
|
696
696
|
const scopeId = flush[0];
|
|
697
697
|
const scope = flush[1];
|
|
698
|
-
const ref = state.
|
|
698
|
+
const ref = state.scopeRef(scope, scopeId);
|
|
699
699
|
const openIndex = buf.push("") - 1;
|
|
700
|
-
if (
|
|
701
|
-
buf[openIndex] = nextSlotId === -1 ? scopeId + "
|
|
702
|
-
if (
|
|
700
|
+
if (state.writeScopeProps(flush[2], ref)) {
|
|
701
|
+
buf[openIndex] = nextSlotId === -1 ? state.scopesCursor(scopeId) + "{" : (scopeId !== nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
|
|
702
|
+
if (scopesIndex === -1) scopesIndex = openIndex;
|
|
703
703
|
nextSlotId = scopeId + 1;
|
|
704
704
|
buf.push("}");
|
|
705
705
|
} else buf.pop();
|
|
706
706
|
}
|
|
707
707
|
let extras = "";
|
|
708
|
-
if (state.
|
|
709
|
-
extras = ",0)";
|
|
710
|
-
if (fillIndex !== -1) {
|
|
711
|
-
buf[fillIndex] = "_([" + buf[fillIndex];
|
|
712
|
-
buf.push("])");
|
|
713
|
-
}
|
|
714
|
-
writeAssigned(state);
|
|
715
|
-
}
|
|
708
|
+
if (state.deferredRefs.size || hasChannelCalls(state)) extras = state.writeTrailing(scopesIndex);
|
|
716
709
|
let result = extras && "(";
|
|
717
710
|
for (const chunk of buf) result += chunk;
|
|
718
711
|
result += extras;
|
|
719
712
|
if (!result) return "";
|
|
720
|
-
|
|
721
|
-
state.wroteUndefined = false;
|
|
722
|
-
return extras ? arrow + result : arrow + "[" + result + "]";
|
|
713
|
+
return state.wrapPayload(result, extras);
|
|
723
714
|
}
|
|
724
|
-
function
|
|
715
|
+
function writeDeferred(state) {
|
|
725
716
|
let sep = state.buf.length ? "," : "";
|
|
726
|
-
if (state.
|
|
727
|
-
const pending = state.
|
|
728
|
-
state.
|
|
717
|
+
if (state.deferredRefs.size) {
|
|
718
|
+
const pending = state.deferredRefs;
|
|
719
|
+
state.deferredRefs = /* @__PURE__ */ new Set();
|
|
729
720
|
let buf = "";
|
|
730
721
|
let hasCalls = false;
|
|
731
722
|
for (const ref of pending) {
|
|
@@ -734,77 +725,88 @@ function writeAssigned(state) {
|
|
|
734
725
|
ref.assignments = null;
|
|
735
726
|
sep = ",";
|
|
736
727
|
}
|
|
737
|
-
hasCalls ||= ref.
|
|
728
|
+
hasCalls ||= ref.deferredMembers !== null;
|
|
738
729
|
}
|
|
739
730
|
if (buf) state.buf.push(buf);
|
|
740
731
|
if (hasCalls) for (const ref of pending) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
if (a) state.buf.push(",");
|
|
746
|
-
writeCallArg(state, args[a]);
|
|
747
|
-
}
|
|
748
|
-
state.buf.push(")");
|
|
732
|
+
const members = ref.deferredMembers;
|
|
733
|
+
if (members) {
|
|
734
|
+
writeDeferredMembers(state, ref.id, members);
|
|
735
|
+
ref.deferredMembers = null;
|
|
749
736
|
}
|
|
750
|
-
ref.calls = null;
|
|
751
737
|
}
|
|
752
738
|
}
|
|
753
|
-
|
|
739
|
+
const readyId = state.channel?.readyId;
|
|
740
|
+
let calls = state.queuedCalls;
|
|
741
|
+
if (readyId) {
|
|
742
|
+
calls = [];
|
|
754
743
|
const remaining = [];
|
|
755
|
-
for (const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
744
|
+
for (const call of state.queuedReadyCalls) (call.channel.readyId === readyId ? calls : remaining).push(call);
|
|
745
|
+
state.queuedReadyCalls = remaining;
|
|
746
|
+
} else if (calls.length) state.queuedCalls = [];
|
|
747
|
+
for (const call of calls) {
|
|
748
|
+
const objectStartIndex = state.buf.push(state.buf.length === 0 ? "" : ",");
|
|
749
|
+
if (writeProp(state, call.object, null, "")) {
|
|
750
|
+
const objectRef = state.refs.get(call.object);
|
|
751
|
+
if (!objectRef.id && !isAncestorChannelRef(state, objectRef)) {
|
|
752
|
+
objectRef.id = nextRefAccess(state);
|
|
753
|
+
state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex];
|
|
754
|
+
state.buf.push(")");
|
|
755
|
+
} else if (objectRef.id && state.buf[objectStartIndex] !== objectRef.id) {
|
|
756
|
+
state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex];
|
|
757
|
+
state.buf.push(")");
|
|
759
758
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
} else state.buf.push("void 0");
|
|
783
|
-
state.buf.push(")");
|
|
784
|
-
}
|
|
785
|
-
state.mutated = remaining;
|
|
759
|
+
} else state.buf.push("void 0");
|
|
760
|
+
state.buf.push("." + call.method + "(");
|
|
761
|
+
if (call.value !== void 0) writeCallArg(state, call.value, call.valueId);
|
|
762
|
+
state.buf.push(")");
|
|
763
|
+
}
|
|
764
|
+
if (state.deferredRefs.size) writeDeferred(state);
|
|
765
|
+
}
|
|
766
|
+
function writeDeferredMembers(state, id, { collection, first, rest }) {
|
|
767
|
+
if (collection instanceof Map) {
|
|
768
|
+
writeDeferredEntry(state, id, first);
|
|
769
|
+
for (const entry of rest) writeDeferredEntry(state, id, entry);
|
|
770
|
+
} else {
|
|
771
|
+
writeDeferredMember(state, id, first);
|
|
772
|
+
for (const member of rest) writeDeferredMember(state, id, member);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function writeDeferredEntry(state, id, [key, value]) {
|
|
776
|
+
state.buf.push("," + id + ".set(");
|
|
777
|
+
if (key !== void 0 || value !== void 0) writeCallArg(state, key, null);
|
|
778
|
+
if (value !== void 0) {
|
|
779
|
+
state.buf.push(",");
|
|
780
|
+
writeCallArg(state, value, null);
|
|
786
781
|
}
|
|
787
|
-
|
|
782
|
+
state.buf.push(")");
|
|
783
|
+
}
|
|
784
|
+
function writeDeferredMember(state, id, member) {
|
|
785
|
+
state.buf.push("," + id + ".add(");
|
|
786
|
+
if (member !== void 0) writeCallArg(state, member, null);
|
|
787
|
+
state.buf.push(")");
|
|
788
788
|
}
|
|
789
|
-
function writeCallArg(state, val) {
|
|
789
|
+
function writeCallArg(state, val, valueId) {
|
|
790
|
+
const startIndex = state.buf.length;
|
|
790
791
|
if (val === void 0) {
|
|
791
792
|
state.wroteUndefined = true;
|
|
792
793
|
state.buf.push("$");
|
|
793
794
|
} else if (writeProp(state, val, null, "")) {
|
|
794
|
-
const ref = state.
|
|
795
|
-
if (ref
|
|
795
|
+
const ref = typeof val === "string" ? state.strs.get(val) : state.refs.get(val);
|
|
796
|
+
if (ref && !ref.id && ref.scopeId === void 0 && !isAncestorChannelRef(state, ref)) {
|
|
797
|
+
ref.id = valueId || nextRefAccess(state);
|
|
798
|
+
state.buf[startIndex] = ref.id + "=" + state.buf[startIndex];
|
|
799
|
+
}
|
|
796
800
|
} else state.buf.push("void 0");
|
|
797
801
|
}
|
|
798
|
-
function
|
|
799
|
-
return
|
|
802
|
+
function hasChannelCalls(state) {
|
|
803
|
+
return hasMatchingCalls(state, state.channel?.readyId);
|
|
800
804
|
}
|
|
801
|
-
function
|
|
802
|
-
|
|
805
|
+
function hasMatchingCalls(state, readyId) {
|
|
806
|
+
if (!readyId) return state.queuedCalls.length > 0;
|
|
807
|
+
for (const call of state.queuedReadyCalls) if (call.channel.readyId === readyId) return true;
|
|
803
808
|
return false;
|
|
804
809
|
}
|
|
805
|
-
function mutationMatchesReadyId(mutation, readyId) {
|
|
806
|
-
return mutation.channel?.readyId ? mutation.channel.readyId === readyId : !readyId;
|
|
807
|
-
}
|
|
808
810
|
function writeProp(state, val, parent, accessor) {
|
|
809
811
|
switch (typeof val) {
|
|
810
812
|
case "string": return writeString(state, val, parent, accessor);
|
|
@@ -827,8 +829,8 @@ function writeReferenceOr(state, write, val, parent, accessor) {
|
|
|
827
829
|
return false;
|
|
828
830
|
}
|
|
829
831
|
if (parent && isCircular(parent, ref)) {
|
|
830
|
-
|
|
831
|
-
state.
|
|
832
|
+
ensureRefAccess(state, ref);
|
|
833
|
+
state.deferredRefs.add(ref);
|
|
832
834
|
addAssignment(ref, accessId(state, parent) + toAccess(accessor));
|
|
833
835
|
return false;
|
|
834
836
|
}
|
|
@@ -862,23 +864,8 @@ function quoteRegisterId(id) {
|
|
|
862
864
|
}
|
|
863
865
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
864
866
|
const { scope } = registered;
|
|
865
|
-
if (scope)
|
|
866
|
-
|
|
867
|
-
ref.channel = state.channel;
|
|
868
|
-
state.refs.set(val, ref);
|
|
869
|
-
ref.debug = DEBUG.get(val);
|
|
870
|
-
const scopeId = scope[K_SCOPE_ID];
|
|
871
|
-
trackScope(state, scope, scopeId);
|
|
872
|
-
const locals = registered.locals?.(state.boundary.state.scope);
|
|
873
|
-
if (locals) {
|
|
874
|
-
state.buf.push(registered.access + "(_(" + scopeId + ")");
|
|
875
|
-
for (const local of locals) {
|
|
876
|
-
state.buf.push(",");
|
|
877
|
-
writePlainObject(state, local, newArgReference(state, ref, local));
|
|
878
|
-
}
|
|
879
|
-
} else state.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
|
|
880
|
-
state.buf.push(")");
|
|
881
|
-
} else state.buf.push(registered.access);
|
|
867
|
+
if (scope) state.writeScopedRegistration(val, parent, accessor, registered);
|
|
868
|
+
else state.buf.push(registered.access);
|
|
882
869
|
return true;
|
|
883
870
|
}
|
|
884
871
|
const STRING_DEDUP_LENGTH = 12;
|
|
@@ -1072,7 +1059,7 @@ function writePromise(state, val, ref) {
|
|
|
1072
1059
|
const pId = nextRefAccess(state);
|
|
1073
1060
|
const handle = newAsyncHandle(state, ref, pId);
|
|
1074
1061
|
state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()");
|
|
1075
|
-
val.then((v) =>
|
|
1062
|
+
val.then((v) => queueAsyncCall(state, boundary, handle, "f", v, channel, pId), (v) => queueAsyncCall(state, boundary, handle, "r", v, channel, pId));
|
|
1076
1063
|
boundary.startAsync();
|
|
1077
1064
|
return true;
|
|
1078
1065
|
}
|
|
@@ -1091,14 +1078,18 @@ function writeMap(state, val, ref) {
|
|
|
1091
1078
|
const items = [];
|
|
1092
1079
|
let assignments;
|
|
1093
1080
|
let needsId;
|
|
1094
|
-
let deferring = false;
|
|
1095
1081
|
let i = 0;
|
|
1082
|
+
const entries = val.entries();
|
|
1096
1083
|
if (val.size < 25) {
|
|
1097
|
-
for (
|
|
1098
|
-
|
|
1099
|
-
if (
|
|
1100
|
-
|
|
1101
|
-
|
|
1084
|
+
for (const entry of entries) {
|
|
1085
|
+
let [itemKey, itemValue] = entry;
|
|
1086
|
+
if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
|
|
1087
|
+
deferMembers(state, ref, val, entry, entries);
|
|
1088
|
+
if (!i) {
|
|
1089
|
+
state.buf.push("new Map");
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
break;
|
|
1102
1093
|
}
|
|
1103
1094
|
if (itemKey === val) {
|
|
1104
1095
|
itemKey = void 0;
|
|
@@ -1108,16 +1099,20 @@ function writeMap(state, val, ref) {
|
|
|
1108
1099
|
itemValue = void 0;
|
|
1109
1100
|
(assignments ||= []).push("a[" + i + "][1]");
|
|
1110
1101
|
}
|
|
1111
|
-
needsId ||=
|
|
1102
|
+
needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue);
|
|
1112
1103
|
i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
|
|
1113
1104
|
}
|
|
1114
1105
|
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);
|
|
1115
1106
|
} else {
|
|
1116
|
-
for (
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
|
|
1107
|
+
for (const entry of entries) {
|
|
1108
|
+
let [itemKey, itemValue] = entry;
|
|
1109
|
+
if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
|
|
1110
|
+
deferMembers(state, ref, val, entry, entries);
|
|
1111
|
+
if (!i) {
|
|
1112
|
+
state.buf.push("new Map");
|
|
1113
|
+
return true;
|
|
1114
|
+
}
|
|
1115
|
+
break;
|
|
1121
1116
|
}
|
|
1122
1117
|
if (itemKey === val) {
|
|
1123
1118
|
itemKey = 0;
|
|
@@ -1127,7 +1122,7 @@ function writeMap(state, val, ref) {
|
|
|
1127
1122
|
itemValue = 0;
|
|
1128
1123
|
(assignments ||= []).push("a[" + (i + 1) + "]");
|
|
1129
1124
|
}
|
|
1130
|
-
needsId ||=
|
|
1125
|
+
needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue);
|
|
1131
1126
|
i = items.push(itemKey, itemValue);
|
|
1132
1127
|
}
|
|
1133
1128
|
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);
|
|
@@ -1142,18 +1137,21 @@ function writeSet(state, val, ref) {
|
|
|
1142
1137
|
const items = [];
|
|
1143
1138
|
let assignments;
|
|
1144
1139
|
let needsId;
|
|
1145
|
-
let deferring = false;
|
|
1146
1140
|
let i = 0;
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
if (
|
|
1150
|
-
|
|
1151
|
-
|
|
1141
|
+
const members = val.values();
|
|
1142
|
+
for (let item of members) {
|
|
1143
|
+
if (item !== val && isAncestorMember(state, ref, item)) {
|
|
1144
|
+
deferMembers(state, ref, val, item, members);
|
|
1145
|
+
if (!i) {
|
|
1146
|
+
state.buf.push("new Set");
|
|
1147
|
+
return true;
|
|
1148
|
+
}
|
|
1149
|
+
break;
|
|
1152
1150
|
}
|
|
1153
1151
|
if (item === val) {
|
|
1154
1152
|
item = 0;
|
|
1155
1153
|
(assignments ||= []).push("i[" + i + "]");
|
|
1156
|
-
} else needsId ||=
|
|
1154
|
+
} else needsId ||= isReusableMember(item);
|
|
1157
1155
|
i = items.push(item);
|
|
1158
1156
|
}
|
|
1159
1157
|
writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
|
|
@@ -1164,13 +1162,14 @@ function isAncestorMember(state, container, member) {
|
|
|
1164
1162
|
const ref = state.refs.get(member);
|
|
1165
1163
|
return ref !== void 0 && isCircular(container, ref);
|
|
1166
1164
|
}
|
|
1167
|
-
function
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1165
|
+
function deferMembers(state, ref, collection, first, rest) {
|
|
1166
|
+
ensureRefAccess(state, ref);
|
|
1167
|
+
ref.deferredMembers = {
|
|
1168
|
+
collection,
|
|
1169
|
+
first,
|
|
1170
|
+
rest
|
|
1171
|
+
};
|
|
1172
|
+
state.deferredRefs.add(ref);
|
|
1174
1173
|
}
|
|
1175
1174
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
1176
1175
|
if (assignsPrefix || needsId) {
|
|
@@ -1186,7 +1185,7 @@ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
|
1186
1185
|
function newArgReference(state, parent, val) {
|
|
1187
1186
|
for (const key in val) {
|
|
1188
1187
|
const member = val[key];
|
|
1189
|
-
if (
|
|
1188
|
+
if (isReusableMember(member) && !(typeof member === "string" ? state.strs.has(member) : state.refs.has(member))) {
|
|
1190
1189
|
const ref = new Reference(parent, null, state.flushId, null, nextRefAccess(state));
|
|
1191
1190
|
state.buf.push(ref.id + "=");
|
|
1192
1191
|
return ref;
|
|
@@ -1194,7 +1193,7 @@ function newArgReference(state, parent, val) {
|
|
|
1194
1193
|
}
|
|
1195
1194
|
return new Reference(parent, null, state.flushId, state.buf.length);
|
|
1196
1195
|
}
|
|
1197
|
-
function
|
|
1196
|
+
function isReusableMember(val) {
|
|
1198
1197
|
switch (typeof val) {
|
|
1199
1198
|
case "object": return val !== null && val[K_SCOPE_ID] === void 0;
|
|
1200
1199
|
case "function":
|
|
@@ -1265,7 +1264,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
1265
1264
|
if (inlined) {
|
|
1266
1265
|
const errorsRef = state.refs.get(val.errors);
|
|
1267
1266
|
if (errorsRef?.id) {
|
|
1268
|
-
state.
|
|
1267
|
+
state.deferredRefs.add(errorsRef);
|
|
1269
1268
|
addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
|
|
1270
1269
|
}
|
|
1271
1270
|
}
|
|
@@ -1325,7 +1324,7 @@ function writeRequest(state, val, ref) {
|
|
|
1325
1324
|
}
|
|
1326
1325
|
const seenHeaders = state.refs.get(val.headers);
|
|
1327
1326
|
if (seenHeaders) {
|
|
1328
|
-
options += sep + "headers:" +
|
|
1327
|
+
options += sep + "headers:" + ensureRefAccess(state, seenHeaders);
|
|
1329
1328
|
sep = ",";
|
|
1330
1329
|
} else {
|
|
1331
1330
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
@@ -1375,7 +1374,7 @@ function writeResponse(state, val, ref) {
|
|
|
1375
1374
|
sep = ",";
|
|
1376
1375
|
}
|
|
1377
1376
|
const seenHeaders = state.refs.get(val.headers);
|
|
1378
|
-
if (seenHeaders) options += sep + "headers:" +
|
|
1377
|
+
if (seenHeaders) options += sep + "headers:" + ensureRefAccess(state, seenHeaders);
|
|
1379
1378
|
else {
|
|
1380
1379
|
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1381
1380
|
const headers = stringEntriesToHeadersInit(val.headers);
|
|
@@ -1415,15 +1414,15 @@ function writeReadableStream(state, val, ref) {
|
|
|
1415
1414
|
const iterId = nextRefAccess(state);
|
|
1416
1415
|
const handle = newAsyncHandle(state, ref, iterId);
|
|
1417
1416
|
const onFulfilled = ({ value, done }) => {
|
|
1418
|
-
if (done)
|
|
1417
|
+
if (done) queueAsyncCall(state, boundary, handle, "r", value, channel);
|
|
1419
1418
|
else if (!boundary.aborted) {
|
|
1420
1419
|
reader.read().then(onFulfilled, onRejected);
|
|
1421
1420
|
boundary.startAsync();
|
|
1422
|
-
|
|
1421
|
+
queueAsyncCall(state, boundary, handle, "f", value, channel);
|
|
1423
1422
|
}
|
|
1424
1423
|
};
|
|
1425
1424
|
const onRejected = (reason) => {
|
|
1426
|
-
|
|
1425
|
+
queueAsyncCall(state, boundary, handle, "j", reason, channel);
|
|
1427
1426
|
};
|
|
1428
1427
|
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))}})");
|
|
1429
1428
|
reader.read().then(onFulfilled, onRejected);
|
|
@@ -1444,7 +1443,7 @@ function writeGenerator(state, iter, ref) {
|
|
|
1444
1443
|
returnValue = value;
|
|
1445
1444
|
break;
|
|
1446
1445
|
}
|
|
1447
|
-
needsId ||=
|
|
1446
|
+
needsId ||= isReusableMember(value);
|
|
1448
1447
|
yields.push(value);
|
|
1449
1448
|
}
|
|
1450
1449
|
if (returnValue === void 0 && !yields.length) {
|
|
@@ -1464,9 +1463,9 @@ function writeGenerator(state, iter, ref) {
|
|
|
1464
1463
|
writeProp(state, returnValue, holder, "v");
|
|
1465
1464
|
} else if (returnValue !== void 0) {
|
|
1466
1465
|
state.buf.push(",");
|
|
1467
|
-
if (writeProp(state, returnValue, ref, "") &&
|
|
1466
|
+
if (writeProp(state, returnValue, ref, "") && isReusableMember(returnValue)) {
|
|
1468
1467
|
const retRef = typeof returnValue === "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
|
|
1469
|
-
if (retRef)
|
|
1468
|
+
if (retRef) ensureRefAccess(state, retRef);
|
|
1470
1469
|
}
|
|
1471
1470
|
}
|
|
1472
1471
|
state.buf.push(")");
|
|
@@ -1481,15 +1480,15 @@ function writeAsyncGenerator(state, iter, ref) {
|
|
|
1481
1480
|
const iterId = nextRefAccess(state);
|
|
1482
1481
|
const handle = newAsyncHandle(state, ref, iterId);
|
|
1483
1482
|
const onFulfilled = ({ value, done }) => {
|
|
1484
|
-
if (done)
|
|
1483
|
+
if (done) queueAsyncCall(state, boundary, handle, "r", value, channel);
|
|
1485
1484
|
else if (!boundary.aborted) {
|
|
1486
1485
|
iter.next().then(onFulfilled, onRejected);
|
|
1487
1486
|
boundary.startAsync();
|
|
1488
|
-
|
|
1487
|
+
queueAsyncCall(state, boundary, handle, "f", value, channel);
|
|
1489
1488
|
}
|
|
1490
1489
|
};
|
|
1491
1490
|
const onRejected = (reason) => {
|
|
1492
|
-
|
|
1491
|
+
queueAsyncCall(state, boundary, handle, "j", reason, channel);
|
|
1493
1492
|
};
|
|
1494
1493
|
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 + "={})");
|
|
1495
1494
|
iter.next().then(onFulfilled, onRejected);
|
|
@@ -1528,12 +1527,12 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
1528
1527
|
}
|
|
1529
1528
|
return sep;
|
|
1530
1529
|
}
|
|
1531
|
-
function
|
|
1530
|
+
function queueAsyncCall(state, boundary, handle, method, value, channel, valueId = null) {
|
|
1532
1531
|
if (boundary.aborted) return;
|
|
1533
|
-
state.
|
|
1532
|
+
(channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
|
|
1533
|
+
method,
|
|
1534
1534
|
value,
|
|
1535
1535
|
object: handle,
|
|
1536
|
-
property: method,
|
|
1537
1536
|
channel,
|
|
1538
1537
|
valueId
|
|
1539
1538
|
});
|
|
@@ -1727,9 +1726,9 @@ function writeRef(state, ref) {
|
|
|
1727
1726
|
ref.pos = state.buf.length;
|
|
1728
1727
|
ref.flushId = state.flushId;
|
|
1729
1728
|
state.buf.push(ref.path);
|
|
1730
|
-
} else state.buf.push(
|
|
1729
|
+
} else state.buf.push(ensureRefAccess(state, ref));
|
|
1731
1730
|
}
|
|
1732
|
-
function
|
|
1731
|
+
function ensureRefAccess(state, ref) {
|
|
1733
1732
|
if (ref.scopeId !== void 0) {
|
|
1734
1733
|
trackChannel(state, ref);
|
|
1735
1734
|
return "_(" + ref.scopeId + ")";
|
|
@@ -1738,13 +1737,13 @@ function ensureId(state, ref) {
|
|
|
1738
1737
|
trackChannel(state, ref);
|
|
1739
1738
|
return ref.id;
|
|
1740
1739
|
}
|
|
1741
|
-
return
|
|
1740
|
+
return claimRefAccess(state, ref);
|
|
1742
1741
|
}
|
|
1743
1742
|
function accessId(state, ref) {
|
|
1744
|
-
const id =
|
|
1743
|
+
const id = ensureRefAccess(state, ref);
|
|
1745
1744
|
return id === ref.id || ref.scopeId !== void 0 ? id : "(" + id + ")";
|
|
1746
1745
|
}
|
|
1747
|
-
function
|
|
1746
|
+
function claimRefAccess(state, ref) {
|
|
1748
1747
|
const { pos } = ref;
|
|
1749
1748
|
if (pos !== null && ref.flushId === state.flushId) {
|
|
1750
1749
|
ref.id = nextRefAccess(state);
|
|
@@ -1841,10 +1840,10 @@ function patchIteratorNext(proto) {
|
|
|
1841
1840
|
//#endregion
|
|
1842
1841
|
//#region src/html/attrs.ts
|
|
1843
1842
|
function _attr_class(value) {
|
|
1844
|
-
return stringAttr("class", toDelimitedString(value, " ",
|
|
1843
|
+
return stringAttr("class", toDelimitedString(value, " ", stringifyClassEntry));
|
|
1845
1844
|
}
|
|
1846
1845
|
function _attr_style(value) {
|
|
1847
|
-
return stringAttr("style", toDelimitedString(value, ";",
|
|
1846
|
+
return stringAttr("style", toDelimitedString(value, ";", stringifyStyleEntry));
|
|
1848
1847
|
}
|
|
1849
1848
|
function _attr_option_value(value) {
|
|
1850
1849
|
const valueAttr = _attr("value", value);
|
|
@@ -1892,7 +1891,7 @@ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeT
|
|
|
1892
1891
|
}
|
|
1893
1892
|
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
1894
1893
|
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
|
|
1895
|
-
return
|
|
1894
|
+
return isNotNullishOrFalse(checked) ? " checked" : "";
|
|
1896
1895
|
}
|
|
1897
1896
|
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
1898
1897
|
const valueAttr = _attr("value", value);
|
|
@@ -1911,7 +1910,7 @@ function getCheckedValueRef(checkedValue) {
|
|
|
1911
1910
|
}
|
|
1912
1911
|
}
|
|
1913
1912
|
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
1914
|
-
const normalizedOpen =
|
|
1913
|
+
const normalizedOpen = isNotNullishOrFalse(open);
|
|
1915
1914
|
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
|
|
1916
1915
|
return normalizedOpen ? " open" : "";
|
|
1917
1916
|
}
|
|
@@ -1923,7 +1922,7 @@ function _style_html(decls) {
|
|
|
1923
1922
|
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1924
1923
|
}
|
|
1925
1924
|
function _attr(name, value) {
|
|
1926
|
-
return
|
|
1925
|
+
return isNullishOrFalse(value) ? "" : stringifyAttr(name, value);
|
|
1927
1926
|
}
|
|
1928
1927
|
function _attr_and(name, value, attr) {
|
|
1929
1928
|
return value ? attr : _attr(name, value);
|
|
@@ -1980,14 +1979,14 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
1980
1979
|
break;
|
|
1981
1980
|
default:
|
|
1982
1981
|
if (name) assertValidAttrName(name);
|
|
1983
|
-
if (name && !(
|
|
1982
|
+
if (name && !(isNullishOrFalse(value) || skip.test(name) || name === "content" && tagName !== "meta")) {
|
|
1984
1983
|
if (isEventHandler(name)) {
|
|
1985
1984
|
if (!events) {
|
|
1986
1985
|
events = {};
|
|
1987
1986
|
writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
|
|
1988
1987
|
}
|
|
1989
|
-
events[
|
|
1990
|
-
} else result +=
|
|
1988
|
+
events[getEventType(name)] = value;
|
|
1989
|
+
} else result += stringifyAttr(name, value);
|
|
1991
1990
|
}
|
|
1992
1991
|
}
|
|
1993
1992
|
}
|
|
@@ -2000,7 +1999,7 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, markerGuard) {
|
|
|
2000
1999
|
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
2001
2000
|
const partial = {};
|
|
2002
2001
|
for (const name in data) {
|
|
2003
|
-
const key = isEventHandler(name) ? `on-${
|
|
2002
|
+
const key = isEventHandler(name) ? `on-${getEventType(name)}` : name;
|
|
2004
2003
|
if (!skip[key]) partial[key] = data[name];
|
|
2005
2004
|
}
|
|
2006
2005
|
assertExclusiveAttrs({
|
|
@@ -2034,7 +2033,7 @@ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, s
|
|
|
2034
2033
|
function stringAttr(name, value) {
|
|
2035
2034
|
return value && " " + name + attrAssignment(value);
|
|
2036
2035
|
}
|
|
2037
|
-
function
|
|
2036
|
+
function stringifyAttr(name, value) {
|
|
2038
2037
|
assertValidAttrValue(name, value);
|
|
2039
2038
|
switch (typeof value) {
|
|
2040
2039
|
case "string": return " " + name + attrAssignment(value);
|
|
@@ -2069,18 +2068,7 @@ function normalizedValueMatches(a, b) {
|
|
|
2069
2068
|
return false;
|
|
2070
2069
|
}
|
|
2071
2070
|
function normalizeStrAttrValue(value) {
|
|
2072
|
-
return
|
|
2073
|
-
}
|
|
2074
|
-
//#endregion
|
|
2075
|
-
//#region src/html/for.ts
|
|
2076
|
-
function forOfBy(by, item, index) {
|
|
2077
|
-
return by ? typeof by === "string" ? item[by] : by(item, index) : index;
|
|
2078
|
-
}
|
|
2079
|
-
function forInBy(by, name, value) {
|
|
2080
|
-
return by ? by(name, value) : name;
|
|
2081
|
-
}
|
|
2082
|
-
function forStepBy(by, index) {
|
|
2083
|
-
return by ? by(index) : index;
|
|
2071
|
+
return isNotNullishOrFalse(value) && value !== true ? value + "" : "";
|
|
2084
2072
|
}
|
|
2085
2073
|
//#endregion
|
|
2086
2074
|
//#region src/html/inlined-runtimes.debug.ts
|
|
@@ -2225,13 +2213,13 @@ function _peek_scope_id() {
|
|
|
2225
2213
|
return $chunk.boundary.state.scopeId;
|
|
2226
2214
|
}
|
|
2227
2215
|
const kPendingContexts = Symbol("Pending Contexts");
|
|
2228
|
-
function withContext(key, value, cb, cbValue) {
|
|
2216
|
+
function withContext(key, value, cb, cbValue, cbValue2) {
|
|
2229
2217
|
const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
|
|
2230
2218
|
const prev = ctx[key];
|
|
2231
2219
|
ctx[kPendingContexts]++;
|
|
2232
2220
|
ctx[key] = value;
|
|
2233
2221
|
try {
|
|
2234
|
-
return cb(cbValue);
|
|
2222
|
+
return cb(cbValue, cbValue2);
|
|
2235
2223
|
} finally {
|
|
2236
2224
|
ctx[kPendingContexts]--;
|
|
2237
2225
|
ctx[key] = prev;
|
|
@@ -2244,15 +2232,15 @@ function captureContext(chunk) {
|
|
|
2244
2232
|
};
|
|
2245
2233
|
}
|
|
2246
2234
|
const kBranchId = Symbol("Branch Id");
|
|
2247
|
-
const
|
|
2235
|
+
const kAsyncContent = Symbol("Async Content");
|
|
2248
2236
|
function isInResumedBranch() {
|
|
2249
2237
|
return $chunk?.context?.[kBranchId] !== void 0;
|
|
2250
2238
|
}
|
|
2251
|
-
function withBranchId(branchId, cb, cbValue) {
|
|
2252
|
-
return withContext(kBranchId, branchId, cb, cbValue);
|
|
2239
|
+
function withBranchId(branchId, cb, cbValue, cbValue2) {
|
|
2240
|
+
return withContext(kBranchId, branchId, cb, cbValue, cbValue2);
|
|
2253
2241
|
}
|
|
2254
|
-
function
|
|
2255
|
-
return withContext(
|
|
2242
|
+
function withAsyncContent(async, cb, value) {
|
|
2243
|
+
return withContext(kAsyncContent, async, cb, value);
|
|
2256
2244
|
}
|
|
2257
2245
|
function _html(html) {
|
|
2258
2246
|
$chunk.writeHTML(html);
|
|
@@ -2270,9 +2258,8 @@ function mayDrop(written) {
|
|
|
2270
2258
|
return false;
|
|
2271
2259
|
}
|
|
2272
2260
|
function _script(scopeId, registryId, markerGuard) {
|
|
2273
|
-
if (markerGuard === 0 && ($chunk.
|
|
2274
|
-
$chunk.boundary.state.
|
|
2275
|
-
$chunk.writeEffect(scopeId, registryId);
|
|
2261
|
+
if (markerGuard === 0 && ($chunk.channel.readyId || $chunk.context?.[kAsyncContent])) _resume_branch(scopeId);
|
|
2262
|
+
$chunk.boundary.state.queueEffect(scopeId, registryId);
|
|
2276
2263
|
}
|
|
2277
2264
|
function _trailers(html) {
|
|
2278
2265
|
$chunk.boundary.state.trailerHTML += html;
|
|
@@ -2292,27 +2279,27 @@ function _hoist(scopeId, id) {
|
|
|
2292
2279
|
getter[Symbol.iterator] = _hoist_read_error;
|
|
2293
2280
|
return _resume(getter, id, scopeId);
|
|
2294
2281
|
}
|
|
2295
|
-
function _el_resume(scopeId, accessor,
|
|
2296
|
-
if (
|
|
2282
|
+
function _el_resume(scopeId, accessor, markerGuard) {
|
|
2283
|
+
if (markerGuard === 0) return "";
|
|
2297
2284
|
const { state } = $chunk.boundary;
|
|
2298
|
-
state.
|
|
2285
|
+
state.needsWalkerRuntime = true;
|
|
2299
2286
|
return state.mark("$", scopeId + " " + accessor);
|
|
2300
2287
|
}
|
|
2301
|
-
function _text_resume(scopeId, accessor, val,
|
|
2302
|
-
return markText(scopeId, accessor, _escape(val),
|
|
2288
|
+
function _text_resume(scopeId, accessor, val, markerGuard) {
|
|
2289
|
+
return markText(scopeId, accessor, _escape(val), markerGuard);
|
|
2303
2290
|
}
|
|
2304
|
-
function _html_resume(scopeId, accessor, val,
|
|
2291
|
+
function _html_resume(scopeId, accessor, val, markerGuard) {
|
|
2305
2292
|
const html = _unescaped(val);
|
|
2306
|
-
if (
|
|
2293
|
+
if (markerGuard === 0 || !~html.indexOf("<")) return markText(scopeId, accessor, html, markerGuard);
|
|
2307
2294
|
const { state } = $chunk.boundary;
|
|
2308
|
-
state.
|
|
2295
|
+
state.needsWalkerRuntime = true;
|
|
2309
2296
|
return state.mark("&", "") + html + state.mark("'", scopeId + " " + accessor);
|
|
2310
2297
|
}
|
|
2311
|
-
function markText(scopeId, accessor, text,
|
|
2312
|
-
if (
|
|
2298
|
+
function markText(scopeId, accessor, text, markerGuard) {
|
|
2299
|
+
if (markerGuard === 0) return text;
|
|
2313
2300
|
const { state } = $chunk.boundary;
|
|
2314
|
-
state.
|
|
2315
|
-
return text ? (
|
|
2301
|
+
state.needsWalkerRuntime = true;
|
|
2302
|
+
return text ? (markerGuard === 2 ? "<!>" : "") + text + state.mark("$", scopeId + " " + accessor) : state.mark("%", scopeId + " " + accessor);
|
|
2316
2303
|
}
|
|
2317
2304
|
function _resume_branch(scopeId) {
|
|
2318
2305
|
const branchId = $chunk.context?.[kBranchId];
|
|
@@ -2323,7 +2310,7 @@ function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
|
|
|
2323
2310
|
const render = normalizeServerRender(content);
|
|
2324
2311
|
const branchId = _peek_scope_id();
|
|
2325
2312
|
if (render) try {
|
|
2326
|
-
_set_scope_reason(shouldResume ?
|
|
2313
|
+
_set_scope_reason(shouldResume ? ALL_GROUPS : 0);
|
|
2327
2314
|
if (shouldResume) withBranchId(branchId, render);
|
|
2328
2315
|
else render();
|
|
2329
2316
|
} finally {
|
|
@@ -2349,137 +2336,21 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, node
|
|
|
2349
2336
|
if (nodeAccessor !== void 0) writeScope(parentScopeId, { [BranchScopes + nodeAccessor]: childScope });
|
|
2350
2337
|
}
|
|
2351
2338
|
function writeScopePassive(scopeId, partialScope) {
|
|
2352
|
-
const target = $chunk.
|
|
2339
|
+
const target = $chunk.channel;
|
|
2353
2340
|
const scope = _scope_with_id(scopeId);
|
|
2354
|
-
const passive = target.passiveScopes ||= {};
|
|
2355
2341
|
Object.assign(scope, partialScope);
|
|
2356
|
-
|
|
2342
|
+
$chunk.boundary.state.queuePassiveScope(target, scopeId, partialScope);
|
|
2357
2343
|
return scope;
|
|
2358
2344
|
}
|
|
2359
|
-
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
2360
|
-
if (display) {
|
|
2361
|
-
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
2362
|
-
} else $chunk.writeHTML("<t hidden>");
|
|
2363
|
-
}
|
|
2364
|
-
function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2365
|
-
const branchId = _scope_id();
|
|
2366
|
-
const wrap = !display;
|
|
2367
|
-
if (wrap) $chunk.writeHTML("</t>");
|
|
2368
|
-
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
2369
|
-
}
|
|
2370
|
-
function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2371
|
-
forBranches(by, (each) => each ? forOf(list, (item, index) => {
|
|
2372
|
-
const itemKey = forOfBy(by, item, index);
|
|
2373
|
-
each(itemKey, itemKey === index, () => cb(item, index));
|
|
2374
|
-
}) : forOf(list, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2375
|
-
}
|
|
2376
|
-
function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2377
|
-
forBranches(by, (each) => each ? forIn(obj, (key, value) => {
|
|
2378
|
-
each(forInBy(by, key, value), false, () => cb(key, value));
|
|
2379
|
-
}) : forIn(obj, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2380
|
-
}
|
|
2381
|
-
function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2382
|
-
forBranches(by, (each) => {
|
|
2383
|
-
let index = 0;
|
|
2384
|
-
return each ? forTo(to, from, step, (value) => {
|
|
2385
|
-
const itemKey = forStepBy(by, value);
|
|
2386
|
-
each(itemKey, itemKey === index++, () => cb(value));
|
|
2387
|
-
}) : forTo(to, from, step, cb);
|
|
2388
|
-
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2389
|
-
}
|
|
2390
|
-
function _for_until(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2391
|
-
forBranches(by, (each) => {
|
|
2392
|
-
let index = 0;
|
|
2393
|
-
return each ? forUntil(to, from, step, (value) => {
|
|
2394
|
-
const itemKey = forStepBy(by, value);
|
|
2395
|
-
each(itemKey, itemKey === index++, () => cb(value));
|
|
2396
|
-
}) : forUntil(to, from, step, cb);
|
|
2397
|
-
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2398
|
-
}
|
|
2399
|
-
function forBranches(by, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2400
|
-
if (by) {
|
|
2401
|
-
const run = iterate;
|
|
2402
|
-
const seenKeys = /* @__PURE__ */ new Set();
|
|
2403
|
-
iterate = (each) => run((itemKey, sameAsIndex, render) => {
|
|
2404
|
-
assertValidLoopKey(itemKey, seenKeys);
|
|
2405
|
-
if (each) each(itemKey, sameAsIndex, render);
|
|
2406
|
-
else render();
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2409
|
-
if (branchGuard === 0) {
|
|
2410
|
-
iterate(0);
|
|
2411
|
-
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
|
|
2412
|
-
return;
|
|
2413
|
-
}
|
|
2414
|
-
const { state } = $chunk.boundary;
|
|
2415
|
-
const resumeKeys = markerGuard !== 0;
|
|
2416
|
-
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
2417
|
-
let flushBranchIds = "";
|
|
2418
|
-
let loopScopes;
|
|
2419
|
-
iterate((itemKey, sameAsIndex, render) => {
|
|
2420
|
-
const branchId = _peek_scope_id();
|
|
2421
|
-
if (resumeMarker) {
|
|
2422
|
-
if (singleNode) flushBranchIds = " " + branchId + flushBranchIds;
|
|
2423
|
-
else {
|
|
2424
|
-
$chunk.writeHTML(state.mark("[", flushBranchIds));
|
|
2425
|
-
flushBranchIds = branchId + "";
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
withBranchId(branchId, () => {
|
|
2429
|
-
render();
|
|
2430
|
-
const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { [LoopKey]: itemKey } : {});
|
|
2431
|
-
if (!resumeMarker) loopScopes = push(loopScopes, branchScope);
|
|
2432
|
-
});
|
|
2433
|
-
});
|
|
2434
|
-
if (loopScopes) writeScope(scopeId, { [BranchScopes + accessor]: loopScopes });
|
|
2435
|
-
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
2436
|
-
}
|
|
2437
|
-
function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2438
|
-
const resumeBranch = branchGuard !== 0;
|
|
2439
|
-
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
2440
|
-
const branchId = _peek_scope_id();
|
|
2441
|
-
const chunk = $chunk;
|
|
2442
|
-
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
2443
|
-
const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
|
2444
|
-
const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
2445
|
-
if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
|
|
2446
|
-
if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
|
|
2447
|
-
[ConditionalRenderer + accessor]: branchIndex || void 0,
|
|
2448
|
-
[BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
2449
|
-
});
|
|
2450
|
-
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
2451
|
-
}
|
|
2452
|
-
function deferBranchStart(chunk) {
|
|
2453
|
-
const beforeBranch = chunk.html;
|
|
2454
|
-
chunk.html = "";
|
|
2455
|
-
return beforeBranch;
|
|
2456
|
-
}
|
|
2457
|
-
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
2458
|
-
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
2459
|
-
}
|
|
2460
|
-
function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
2461
|
-
return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
|
|
2462
|
-
}
|
|
2463
|
-
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
2464
|
-
const endTag = parentEndTag || "";
|
|
2465
|
-
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
|
|
2466
|
-
const { state } = $chunk.boundary;
|
|
2467
|
-
const mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
2468
|
-
$chunk.writeHTML(mark + endTag);
|
|
2469
|
-
} else if (markerGuard !== 0) $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
2470
|
-
else $chunk.writeHTML(endTag);
|
|
2471
|
-
}
|
|
2472
2345
|
let writeScope = (scopeId, partialScope) => {
|
|
2473
2346
|
const { state } = $chunk.boundary;
|
|
2474
|
-
const target = $chunk.
|
|
2347
|
+
const target = $chunk.channel;
|
|
2475
2348
|
const scope = scopeWithId(state, scopeId);
|
|
2476
|
-
|
|
2477
|
-
state.needsMainRuntime = true;
|
|
2349
|
+
state.needsWalkerRuntime = true;
|
|
2478
2350
|
countResumeWrite($chunk);
|
|
2351
|
+
writeAsyncVisits($chunk);
|
|
2479
2352
|
Object.assign(scope, partialScope);
|
|
2480
|
-
|
|
2481
|
-
else target.writeScopes[scopeId] = partialScope;
|
|
2482
|
-
target.flushScopes = true;
|
|
2353
|
+
state.queueScope(target, scopeId, partialScope);
|
|
2483
2354
|
return scope;
|
|
2484
2355
|
};
|
|
2485
2356
|
writeScope = ((writeScope) => (scopeId, partialScope, file, loc, vars) => {
|
|
@@ -2501,18 +2372,18 @@ function scopeWithId(state, scopeId) {
|
|
|
2501
2372
|
}
|
|
2502
2373
|
function _subscribe(subscribers, scope, resumeId, markerGuard) {
|
|
2503
2374
|
if (subscribers) {
|
|
2504
|
-
const { boundary,
|
|
2375
|
+
const { boundary, channel } = $chunk;
|
|
2505
2376
|
const { serializer } = boundary.state;
|
|
2506
|
-
if (!
|
|
2377
|
+
if (!channel.readyId && !serializer.refs.has(subscribers)) subscribers.add(scope);
|
|
2507
2378
|
else if (resumeId) _script(scope[K_SCOPE_ID], resumeId, markerGuard);
|
|
2508
|
-
else serializer
|
|
2509
|
-
if (boundary.withinCatch) (boundary.subscribed ||= []).push(subscribers, scope,
|
|
2379
|
+
else queueCall(serializer, scope, subscribers, "add", channel);
|
|
2380
|
+
if (boundary.withinCatch) (boundary.subscribed ||= []).push(subscribers, scope, channel);
|
|
2510
2381
|
}
|
|
2511
2382
|
return scope;
|
|
2512
2383
|
}
|
|
2513
|
-
const
|
|
2514
|
-
function
|
|
2515
|
-
return
|
|
2384
|
+
const ALL_GROUPS = 715827883;
|
|
2385
|
+
function getGroupReason(reason, group) {
|
|
2386
|
+
return reason === 715827883 ? 1 : typeof reason === "number" ? group < 15 ? reason >>> 1 + 2 * group & 3 : 0 : reason[group] ?? 0;
|
|
2516
2387
|
}
|
|
2517
2388
|
function _set_scope_reason(reason) {
|
|
2518
2389
|
$chunk.boundary.state.scopeReason = reason;
|
|
@@ -2522,18 +2393,18 @@ function _scope_reason() {
|
|
|
2522
2393
|
$chunk.boundary.state.scopeReason = void 0;
|
|
2523
2394
|
return reason;
|
|
2524
2395
|
}
|
|
2525
|
-
function _write_if(
|
|
2526
|
-
return
|
|
2396
|
+
function _write_if(reason, group) {
|
|
2397
|
+
return reason && getGroupReason(reason, group) ? 1 : void 0;
|
|
2527
2398
|
}
|
|
2528
|
-
function _write_guard(
|
|
2529
|
-
return _write_if(
|
|
2399
|
+
function _write_guard(reason, group) {
|
|
2400
|
+
return _write_if(reason, group) || 0;
|
|
2530
2401
|
}
|
|
2531
2402
|
function writeWaitReady(readyId, renderer, input) {
|
|
2532
2403
|
const chunk = $chunk;
|
|
2533
2404
|
const { boundary } = chunk;
|
|
2534
2405
|
const body = new Chunk(boundary, null, chunk.context, {
|
|
2535
2406
|
readyId,
|
|
2536
|
-
parent: chunk.
|
|
2407
|
+
parent: chunk.channel,
|
|
2537
2408
|
resumes: "",
|
|
2538
2409
|
writeScopes: {},
|
|
2539
2410
|
flushScopes: false
|
|
@@ -2545,209 +2416,58 @@ function writeWaitReady(readyId, renderer, input) {
|
|
|
2545
2416
|
body.deferOwnReady();
|
|
2546
2417
|
chunk.deferredReady = push(chunk.deferredReady, body);
|
|
2547
2418
|
} else {
|
|
2548
|
-
bodyEnd.next =
|
|
2419
|
+
bodyEnd.next = chunk.forkRest(boundary);
|
|
2549
2420
|
chunk.next = body;
|
|
2550
2421
|
}
|
|
2551
2422
|
}
|
|
2552
|
-
function
|
|
2553
|
-
const
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
const branchId = _peek_scope_id();
|
|
2557
|
-
$chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
2558
|
-
withBranchId(branchId, content, promise);
|
|
2559
|
-
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2560
|
-
} else content(promise);
|
|
2561
|
-
return;
|
|
2562
|
-
}
|
|
2563
|
-
const chunk = $chunk;
|
|
2564
|
-
const { boundary } = chunk;
|
|
2565
|
-
const startId = _peek_scope_id();
|
|
2566
|
-
const after = chunk.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2567
|
-
chunk.async = true;
|
|
2568
|
-
captureContext(chunk);
|
|
2569
|
-
boundary.startAsync();
|
|
2570
|
-
promise.then((value) => {
|
|
2571
|
-
if (chunk.async) {
|
|
2572
|
-
chunk.async = false;
|
|
2573
|
-
if (!boundary.aborted) {
|
|
2574
|
-
const { state } = boundary;
|
|
2575
|
-
chunk.render(() => {
|
|
2576
|
-
if (resumeMarker) {
|
|
2577
|
-
const branchId = _peek_scope_id();
|
|
2578
|
-
$chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
2579
|
-
withBranchId(branchId, () => withIsAsync({ parent: getAsyncContent(chunk) }, content, value));
|
|
2580
|
-
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2581
|
-
} else {
|
|
2582
|
-
const renderedSince = _peek_scope_id() !== startId;
|
|
2583
|
-
const async = { parent: getAsyncContent(chunk) };
|
|
2584
|
-
withIsAsync(async, content, value);
|
|
2585
|
-
async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "";
|
|
2586
|
-
if (async.resumed) $chunk.writeHTML(async.visit);
|
|
2587
|
-
async.end = $chunk;
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
2590
|
-
if (!chunk.async && boundary.pendingReorders?.delete(chunk)) state.reorder(chunk);
|
|
2591
|
-
boundary.endAsync();
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
}, (err) => {
|
|
2595
|
-
chunk.async = false;
|
|
2596
|
-
boundary.abort(err);
|
|
2597
|
-
});
|
|
2423
|
+
function deferBranchStart(chunk) {
|
|
2424
|
+
const beforeBranch = chunk.html;
|
|
2425
|
+
chunk.html = "";
|
|
2426
|
+
return beforeBranch;
|
|
2598
2427
|
}
|
|
2599
|
-
function
|
|
2600
|
-
|
|
2601
|
-
const branchId = _peek_scope_id();
|
|
2602
|
-
const chunk = $chunk;
|
|
2603
|
-
const { boundary } = chunk;
|
|
2604
|
-
const { state } = boundary;
|
|
2605
|
-
const { resumeWrites } = boundary;
|
|
2606
|
-
const beforeBranch = deferBranchStart(chunk);
|
|
2607
|
-
const renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId));
|
|
2608
|
-
const renderersWritten = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers);
|
|
2609
|
-
const rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
|
|
2610
|
-
applyBranchStart(chunk, beforeBranch, rendered);
|
|
2611
|
-
if (!rendered) return;
|
|
2612
|
-
if (!renderersWritten) renderers();
|
|
2613
|
-
$chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2614
|
-
}
|
|
2615
|
-
function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
|
|
2616
|
-
const chunk = $chunk;
|
|
2617
|
-
const { boundary } = chunk;
|
|
2618
|
-
const body = chunk.fork(boundary, null);
|
|
2619
|
-
if (body === body.render(content)) {
|
|
2620
|
-
chunk.append(body);
|
|
2621
|
-
return;
|
|
2622
|
-
}
|
|
2623
|
-
chunk.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2624
|
-
captureContext(chunk);
|
|
2625
|
-
chunk.placeholder = {
|
|
2626
|
-
body,
|
|
2627
|
-
render: placeholder,
|
|
2628
|
-
branchId,
|
|
2629
|
-
scopeId,
|
|
2630
|
-
placeholderBranchId
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
function tryBoundary(content, catchContent, branchId, renderers) {
|
|
2634
|
-
const chunk = $chunk;
|
|
2635
|
-
const { boundary } = chunk;
|
|
2636
|
-
const { state } = boundary;
|
|
2637
|
-
const catchBoundary = new Boundary(state, void 0, boundary);
|
|
2638
|
-
if (catchContent) catchBoundary.withinCatch = true;
|
|
2639
|
-
const body = chunk.fork(catchBoundary, null);
|
|
2640
|
-
const bodyEnd = body.render(() => withBranchId(branchId, content));
|
|
2641
|
-
if (catchBoundary.aborted) {
|
|
2642
|
-
if (!catchContent) throw catchBoundary.reason;
|
|
2643
|
-
catchContent(catchBoundary.reason);
|
|
2644
|
-
return true;
|
|
2645
|
-
}
|
|
2646
|
-
if (body === bodyEnd) {
|
|
2647
|
-
chunk.append(body);
|
|
2648
|
-
return false;
|
|
2649
|
-
}
|
|
2650
|
-
const renderersAtSettle = !catchBoundary.resumeWrites;
|
|
2651
|
-
const bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2652
|
-
chunk.next = body;
|
|
2653
|
-
boundary.startAsync();
|
|
2654
|
-
const reorderId = catchContent ? state.nextReorderId() : "";
|
|
2655
|
-
if (reorderId) {
|
|
2656
|
-
chunk.catchRange = {
|
|
2657
|
-
id: reorderId,
|
|
2658
|
-
end: bodyEnd
|
|
2659
|
-
};
|
|
2660
|
-
captureContext(chunk);
|
|
2661
|
-
}
|
|
2662
|
-
catchBoundary.onNext = () => {
|
|
2663
|
-
if (boundary.aborted) return;
|
|
2664
|
-
if (catchBoundary.aborted) {
|
|
2665
|
-
if (!reorderId) {
|
|
2666
|
-
boundary.abort(catchBoundary.reason);
|
|
2667
|
-
return;
|
|
2668
|
-
}
|
|
2669
|
-
const streamed = !chunk.catchRange;
|
|
2670
|
-
const catchChunk = chunk.fork(boundary, null);
|
|
2671
|
-
chunk.catchRange = null;
|
|
2672
|
-
if (!renderersAtSettle) catchChunk.render(clearTryRenderers, branchId);
|
|
2673
|
-
const inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
|
|
2674
|
-
if (boundary.aborted) return;
|
|
2675
|
-
if (bodyEnd.consumed || !inOrder) catchChunk.reorderBranch = branchId;
|
|
2676
|
-
if (bodyEnd.consumed) {
|
|
2677
|
-
catchChunk.reorderId = reorderId;
|
|
2678
|
-
state.reorder(catchChunk);
|
|
2679
|
-
} else {
|
|
2680
|
-
let reorder = null;
|
|
2681
|
-
if (!inOrder) reorder = catchChunk;
|
|
2682
|
-
else if (streamed) reorder = chunk.fork(boundary, null);
|
|
2683
|
-
if (reorder) reorder.reorderId = reorderId;
|
|
2684
|
-
const endMarker = state.mark("!", reorderId);
|
|
2685
|
-
let cut = body;
|
|
2686
|
-
while (cut.consumed) cut = cut.next;
|
|
2687
|
-
cut.async = false;
|
|
2688
|
-
cut.next = inOrder ? catchChunk : bodyNext;
|
|
2689
|
-
cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker;
|
|
2690
|
-
cut.scripts = cut.effects = cut.lastEffect = "";
|
|
2691
|
-
cut.placeholder = cut.reorderId = cut.catchRange = null;
|
|
2692
|
-
cut.deferredReorder = reorder;
|
|
2693
|
-
if (inOrder) catchChunk.next = bodyNext;
|
|
2694
|
-
}
|
|
2695
|
-
boundary.endAsync();
|
|
2696
|
-
} else if (!catchBoundary.count) {
|
|
2697
|
-
if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(renderers);
|
|
2698
|
-
chunk.catchRange = null;
|
|
2699
|
-
boundary.endAsync();
|
|
2700
|
-
} else boundary.onNext();
|
|
2701
|
-
};
|
|
2702
|
-
return renderersAtSettle;
|
|
2428
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
2429
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
2703
2430
|
}
|
|
2704
2431
|
function unsubscribe(subscribed, serializer) {
|
|
2705
2432
|
for (let i = 0; i < subscribed.length; i += 3) {
|
|
2706
2433
|
const subscribers = subscribed[i];
|
|
2707
2434
|
const scope = subscribed[i + 1];
|
|
2708
|
-
if (!serializer.
|
|
2709
|
-
else
|
|
2435
|
+
if (!serializer.refs.has(subscribers)) subscribers.delete(scope);
|
|
2436
|
+
else {
|
|
2437
|
+
const channel = subscribed[i + 2];
|
|
2438
|
+
if (!dropQueuedCall(serializer, scope, subscribers, "add", channel)) queueCall(serializer, scope, subscribers, "delete", channel);
|
|
2439
|
+
}
|
|
2710
2440
|
}
|
|
2711
2441
|
}
|
|
2712
|
-
function clearTryRenderers(branchId) {
|
|
2713
|
-
writeScope(branchId, {
|
|
2714
|
-
[CatchContent]: 0,
|
|
2715
|
-
[PlaceholderContent]: _scope_with_id(branchId)["#PlaceholderContent"] && 0
|
|
2716
|
-
});
|
|
2717
|
-
}
|
|
2718
|
-
function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
2719
|
-
writeScope(branchId, {
|
|
2720
|
-
[CatchContent]: catchContent,
|
|
2721
|
-
[PlaceholderContent]: placeholderContent
|
|
2722
|
-
});
|
|
2723
|
-
}
|
|
2724
2442
|
const NOOP$2 = () => {};
|
|
2725
2443
|
function countResumeWrite(chunk) {
|
|
2726
2444
|
for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
|
|
2445
|
+
}
|
|
2446
|
+
function writeAsyncVisits(chunk) {
|
|
2727
2447
|
for (let async = getAsyncContent(chunk); async && !async.resumed; async = async.parent) {
|
|
2728
2448
|
async.resumed = true;
|
|
2729
2449
|
async.end?.writeHTML(async.visit);
|
|
2730
2450
|
}
|
|
2731
2451
|
}
|
|
2732
2452
|
function getAsyncContent(chunk) {
|
|
2733
|
-
return chunk.context?.[
|
|
2453
|
+
return chunk.context?.[kAsyncContent];
|
|
2734
2454
|
}
|
|
2735
2455
|
var State = class {
|
|
2736
2456
|
tagId = 1;
|
|
2737
2457
|
scopeId = 1;
|
|
2738
2458
|
reorderId = 1;
|
|
2739
2459
|
readyGate = 1;
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2460
|
+
hasWrittenGlobals = false;
|
|
2461
|
+
needsWalkerRuntime = false;
|
|
2462
|
+
hasWalkerRuntime = false;
|
|
2463
|
+
hasWrittenReady = false;
|
|
2744
2464
|
hasReorderRuntime = false;
|
|
2745
2465
|
hasWrittenResume = false;
|
|
2746
2466
|
walkOnNextFlush = false;
|
|
2747
2467
|
trailerHTML = "";
|
|
2748
2468
|
resumes = "";
|
|
2749
2469
|
nonceAttr = "";
|
|
2750
|
-
serializer = new
|
|
2470
|
+
serializer = new State$1();
|
|
2751
2471
|
writeReorders = null;
|
|
2752
2472
|
scopes = /* @__PURE__ */ new Map();
|
|
2753
2473
|
scope = (scopeId) => scopeWithId(this, scopeId);
|
|
@@ -2760,7 +2480,7 @@ var State = class {
|
|
|
2760
2480
|
this.$global = $global;
|
|
2761
2481
|
if ($global.cspNonce) this.nonceAttr = " nonce" + attrAssignment($global.cspNonce);
|
|
2762
2482
|
}
|
|
2763
|
-
|
|
2483
|
+
joinFlush(html, scripts, pending) {
|
|
2764
2484
|
const { $global, nonceAttr } = this;
|
|
2765
2485
|
const { __flush__ } = $global;
|
|
2766
2486
|
if (scripts) html += "<script" + nonceAttr + ">" + scripts + "<\/script>";
|
|
@@ -2773,6 +2493,32 @@ var State = class {
|
|
|
2773
2493
|
walkScript() {
|
|
2774
2494
|
return this.runtimePrefix + ".w()";
|
|
2775
2495
|
}
|
|
2496
|
+
addResumes(channel, resumes) {
|
|
2497
|
+
channel.resumes = concatSequence(channel.resumes, resumes);
|
|
2498
|
+
}
|
|
2499
|
+
queueScope(target, scopeId, partialScope) {
|
|
2500
|
+
const pending = target.writeScopes[scopeId];
|
|
2501
|
+
if (pending && pending !== partialScope) Object.assign(pending, partialScope);
|
|
2502
|
+
else target.writeScopes[scopeId] = partialScope;
|
|
2503
|
+
target.flushScopes = true;
|
|
2504
|
+
}
|
|
2505
|
+
queuePassiveScope(target, scopeId, partialScope) {
|
|
2506
|
+
const passive = target.passiveScopes ||= {};
|
|
2507
|
+
passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
|
|
2508
|
+
}
|
|
2509
|
+
queueEffect(scopeId, registryId) {
|
|
2510
|
+
this.needsWalkerRuntime = true;
|
|
2511
|
+
$chunk.writeEffect(scopeId, registryId);
|
|
2512
|
+
}
|
|
2513
|
+
serializeFlush(boundary) {
|
|
2514
|
+
flushSerializer(boundary, this);
|
|
2515
|
+
}
|
|
2516
|
+
runtimeScript() {
|
|
2517
|
+
return WALKER_RUNTIME_CODE + "(\"" + this.$global.runtimeId + "\")(\"" + this.$global.renderId + "\")";
|
|
2518
|
+
}
|
|
2519
|
+
keepsTryMarks(chunk, resumeWrites) {
|
|
2520
|
+
return chunk !== $chunk || chunk.boundary.resumeWrites !== resumeWrites;
|
|
2521
|
+
}
|
|
2776
2522
|
resumeScript(resumes) {
|
|
2777
2523
|
if (this.hasWrittenResume) return this.runtimePrefix + ".r.push(" + resumes + ")";
|
|
2778
2524
|
this.hasWrittenResume = true;
|
|
@@ -2789,16 +2535,16 @@ var State = class {
|
|
|
2789
2535
|
reorder(chunk) {
|
|
2790
2536
|
if (this.writeReorders) this.writeReorders.push(chunk);
|
|
2791
2537
|
else {
|
|
2792
|
-
this.
|
|
2538
|
+
this.needsWalkerRuntime = true;
|
|
2793
2539
|
this.writeReorders = [chunk];
|
|
2794
2540
|
}
|
|
2795
2541
|
}
|
|
2796
|
-
|
|
2542
|
+
readyScript(id, resumes) {
|
|
2797
2543
|
const readyKey = toObjectKey(id);
|
|
2798
2544
|
if (this.readyIds?.has(id)) return this.readyAccess(readyKey) + ".push(" + resumes + ")";
|
|
2799
2545
|
(this.readyIds ||= /* @__PURE__ */ new Set()).add(id);
|
|
2800
|
-
if (this.
|
|
2801
|
-
this.
|
|
2546
|
+
if (this.hasWrittenReady) return this.readyAccess(readyKey) + "=[" + resumes + "]";
|
|
2547
|
+
this.hasWrittenReady = true;
|
|
2802
2548
|
return this.runtimePrefix + ".b={" + readyKey + ":[" + resumes + "]}";
|
|
2803
2549
|
}
|
|
2804
2550
|
readyAccess(readyKey) {
|
|
@@ -2858,7 +2604,7 @@ var Boundary = class {
|
|
|
2858
2604
|
this.abort(event.target.reason);
|
|
2859
2605
|
}
|
|
2860
2606
|
flush() {
|
|
2861
|
-
if (!this.aborted)
|
|
2607
|
+
if (!this.aborted) this.state.serializeFlush(this);
|
|
2862
2608
|
return this.count ? 1 : this.aborted ? 2 : 0;
|
|
2863
2609
|
}
|
|
2864
2610
|
startAsync() {
|
|
@@ -2889,21 +2635,25 @@ var Chunk = class Chunk {
|
|
|
2889
2635
|
boundary;
|
|
2890
2636
|
next;
|
|
2891
2637
|
context;
|
|
2892
|
-
|
|
2893
|
-
constructor(boundary, next, context,
|
|
2638
|
+
channel;
|
|
2639
|
+
constructor(boundary, next, context, channel) {
|
|
2894
2640
|
this.boundary = boundary;
|
|
2895
2641
|
this.next = next;
|
|
2896
2642
|
this.context = context;
|
|
2897
|
-
this.
|
|
2643
|
+
this.channel = channel;
|
|
2898
2644
|
}
|
|
2899
2645
|
fork(boundary, next) {
|
|
2900
|
-
return new Chunk(boundary, next, this.context, this.
|
|
2646
|
+
return new Chunk(boundary, next, this.context, this.channel);
|
|
2647
|
+
}
|
|
2648
|
+
forkRest(boundary) {
|
|
2649
|
+
return $chunk = this.fork(boundary, this.next);
|
|
2901
2650
|
}
|
|
2902
2651
|
writeHTML(html) {
|
|
2903
2652
|
this.html += html;
|
|
2904
2653
|
}
|
|
2905
2654
|
writeEffect(scopeId, registryId) {
|
|
2906
2655
|
countResumeWrite(this);
|
|
2656
|
+
writeAsyncVisits(this);
|
|
2907
2657
|
if (this.lastEffect === registryId) this.effects = concatEffects(this.effects, scopeId + "");
|
|
2908
2658
|
else {
|
|
2909
2659
|
this.lastEffect = registryId;
|
|
@@ -2931,7 +2681,7 @@ var Chunk = class Chunk {
|
|
|
2931
2681
|
return deferredReady;
|
|
2932
2682
|
}
|
|
2933
2683
|
deferOwnReady() {
|
|
2934
|
-
if (this.
|
|
2684
|
+
if (this.channel.readyId && (this.effects || this.scripts || this.channel.flushScopes)) {
|
|
2935
2685
|
const deferred = this.fork(this.boundary, null);
|
|
2936
2686
|
deferred.effects = this.effects;
|
|
2937
2687
|
deferred.scripts = this.scripts;
|
|
@@ -2981,12 +2731,12 @@ var Chunk = class Chunk {
|
|
|
2981
2731
|
this.writeHTML(state.mark("!^", reorderId));
|
|
2982
2732
|
const { effects } = this;
|
|
2983
2733
|
const beforeBranch = deferBranchStart(this);
|
|
2984
|
-
if (this.render(
|
|
2734
|
+
if (this.render(withBranchId, placeholderBranchId, placeholder.render) !== this) this.boundary.abort(/* @__PURE__ */ new Error("An @placeholder cannot contain async content."));
|
|
2985
2735
|
if (this.boundary.aborted) return true;
|
|
2986
2736
|
const stateful = this.effects !== effects;
|
|
2987
2737
|
applyBranchStart(this, beforeBranch, stateful);
|
|
2988
2738
|
if (stateful) {
|
|
2989
|
-
this.render(
|
|
2739
|
+
this.render(writeScope, branchId, { [PlaceholderBranch]: scopeWithId(state, placeholderBranchId) });
|
|
2990
2740
|
this.writeHTML(state.mark("]", scopeId + " " + (PlaceholderBranch + branchId) + " " + placeholderBranchId));
|
|
2991
2741
|
dismissChunk(end, body).writeEffect(branchId, PLACEHOLDER_DISMISS_REGISTER_ID);
|
|
2992
2742
|
}
|
|
@@ -3020,12 +2770,12 @@ var Chunk = class Chunk {
|
|
|
3020
2770
|
let heldEffects = this.heldEffects;
|
|
3021
2771
|
let deferredReady;
|
|
3022
2772
|
this.heldEffects = null;
|
|
3023
|
-
if (this.
|
|
2773
|
+
if (this.channel.readyId && this.effects) followHeldEffects(this);
|
|
3024
2774
|
while (cur.next && !cur.async) {
|
|
3025
2775
|
cur.markCatchRange();
|
|
3026
2776
|
cur.queueDeferredReorder();
|
|
3027
2777
|
html += cur.html;
|
|
3028
|
-
if (cur.
|
|
2778
|
+
if (cur.channel.readyId) deferredReady = push(deferredReady, cur);
|
|
3029
2779
|
else {
|
|
3030
2780
|
if (cur.effects) {
|
|
3031
2781
|
if (effectsEnd && effectsEnd.boundary !== cur.boundary) {
|
|
@@ -3043,7 +2793,7 @@ var Chunk = class Chunk {
|
|
|
3043
2793
|
}
|
|
3044
2794
|
cur.deferOwnReady();
|
|
3045
2795
|
if (effects) {
|
|
3046
|
-
if (cur.
|
|
2796
|
+
if (cur.channel.readyId) heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects);
|
|
3047
2797
|
else if (effectsEnd.boundary !== cur.boundary) {
|
|
3048
2798
|
heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects);
|
|
3049
2799
|
if (isWithin(cur.boundary, effectsEnd.boundary)) cur.lastEffect ||= effectsEnd.lastEffect;
|
|
@@ -3058,11 +2808,11 @@ var Chunk = class Chunk {
|
|
|
3058
2808
|
cur.scripts = concatScripts(scripts, cur.scripts);
|
|
3059
2809
|
return cur;
|
|
3060
2810
|
}
|
|
3061
|
-
render(content, val) {
|
|
2811
|
+
render(content, val, val2) {
|
|
3062
2812
|
const prev = $chunk;
|
|
3063
2813
|
$chunk = this;
|
|
3064
2814
|
try {
|
|
3065
|
-
content(val);
|
|
2815
|
+
content(val, val2);
|
|
3066
2816
|
return $chunk;
|
|
3067
2817
|
} catch (err) {
|
|
3068
2818
|
this.boundary.abort(err);
|
|
@@ -3072,8 +2822,8 @@ var Chunk = class Chunk {
|
|
|
3072
2822
|
}
|
|
3073
2823
|
}
|
|
3074
2824
|
flushReadyScripts(boundary, reservations, holdEffects) {
|
|
3075
|
-
const {
|
|
3076
|
-
const { readyId } =
|
|
2825
|
+
const { channel } = this;
|
|
2826
|
+
const { readyId } = channel;
|
|
3077
2827
|
let scripts = "";
|
|
3078
2828
|
const held = this.takeDeferredReady();
|
|
3079
2829
|
if (held) for (const chunk of Array.isArray(held) ? held : [held]) {
|
|
@@ -3083,46 +2833,46 @@ var Chunk = class Chunk {
|
|
|
3083
2833
|
}
|
|
3084
2834
|
if (readyId && !this.async) {
|
|
3085
2835
|
const { state } = boundary;
|
|
3086
|
-
flushSerializer(boundary,
|
|
3087
|
-
const deps = state.serializer
|
|
2836
|
+
flushSerializer(boundary, channel);
|
|
2837
|
+
const deps = takeChannelDeps(state.serializer);
|
|
3088
2838
|
const effects = holdEffects ? "" : this.effects;
|
|
3089
|
-
const { resumes } =
|
|
2839
|
+
const { resumes } = channel;
|
|
3090
2840
|
const chunkScripts = this.scripts;
|
|
3091
|
-
|
|
2841
|
+
channel.resumes = this.scripts = "";
|
|
3092
2842
|
if (effects) this.effects = this.lastEffect = "";
|
|
3093
2843
|
if (resumes || effects) {
|
|
3094
|
-
state.
|
|
2844
|
+
state.needsWalkerRuntime = true;
|
|
3095
2845
|
const batch = concatSequence(depsMarker(deps), concatSequence(resumes, effects && `"${effects}"`));
|
|
3096
2846
|
if (reservations) {
|
|
3097
2847
|
const gate = state.readyGate++;
|
|
3098
|
-
reservations.push(state.
|
|
2848
|
+
reservations.push(state.readyScript(readyId, gate + ""));
|
|
3099
2849
|
scripts = concatScripts(scripts, "(b=>b.splice(b.indexOf(" + gate + "),1," + batch + "))(" + state.readyAccess(toObjectKey(readyId)) + ")");
|
|
3100
|
-
} else scripts = concatScripts(scripts, state.
|
|
2850
|
+
} else scripts = concatScripts(scripts, state.readyScript(readyId, batch));
|
|
3101
2851
|
}
|
|
3102
2852
|
scripts = concatScripts(scripts, chunkScripts);
|
|
3103
2853
|
}
|
|
3104
2854
|
return scripts;
|
|
3105
2855
|
}
|
|
3106
|
-
|
|
2856
|
+
flush(boundary) {
|
|
3107
2857
|
const { state } = boundary;
|
|
3108
|
-
const {
|
|
2858
|
+
const { runtimePrefix } = state;
|
|
3109
2859
|
let needsWalk = state.walkOnNextFlush;
|
|
3110
2860
|
if (needsWalk) state.walkOnNextFlush = false;
|
|
3111
2861
|
flushSerializer(boundary, state);
|
|
3112
2862
|
let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
|
|
3113
|
-
for (let channel; !boundary.aborted && (channel = state.serializer
|
|
3114
|
-
const resumes = state.serializer
|
|
3115
|
-
const deps = state.serializer
|
|
3116
|
-
state.
|
|
3117
|
-
readyResumeScripts = concatScripts(readyResumeScripts, state.
|
|
2863
|
+
for (let channel; !boundary.aborted && (channel = pendingReadyChannel(state.serializer));) {
|
|
2864
|
+
const resumes = stringifyScopes(state.serializer, [], boundary, channel);
|
|
2865
|
+
const deps = takeChannelDeps(state.serializer);
|
|
2866
|
+
state.needsWalkerRuntime = true;
|
|
2867
|
+
readyResumeScripts = concatScripts(readyResumeScripts, state.readyScript(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
3118
2868
|
}
|
|
3119
2869
|
if (readyResumeScripts) needsWalk = true;
|
|
3120
2870
|
const effects = this.async ? "" : joinHeldEffects(this.takeHeldEffects(), this.effects);
|
|
3121
2871
|
let { html, scripts } = this;
|
|
3122
2872
|
if (html && state.hasReorderRuntime) html = state.mark("*", "") + html;
|
|
3123
|
-
if (state.
|
|
3124
|
-
state.
|
|
3125
|
-
scripts = concatScripts(scripts,
|
|
2873
|
+
if (state.needsWalkerRuntime && !state.hasWalkerRuntime) {
|
|
2874
|
+
state.hasWalkerRuntime = true;
|
|
2875
|
+
scripts = concatScripts(scripts, state.runtimeScript());
|
|
3126
2876
|
}
|
|
3127
2877
|
scripts = concatScripts(scripts, readyResumeScripts);
|
|
3128
2878
|
if (effects) {
|
|
@@ -3199,10 +2949,10 @@ var Chunk = class Chunk {
|
|
|
3199
2949
|
}
|
|
3200
2950
|
flushHTML(boundary) {
|
|
3201
2951
|
const { state } = boundary;
|
|
3202
|
-
this.
|
|
2952
|
+
this.flush(boundary);
|
|
3203
2953
|
const { html, scripts } = this;
|
|
3204
2954
|
this.html = this.scripts = "";
|
|
3205
|
-
return state.
|
|
2955
|
+
return state.joinFlush(html, scripts, boundary.count);
|
|
3206
2956
|
}
|
|
3207
2957
|
};
|
|
3208
2958
|
function renderReorderPlaceholders(reorder, reorders) {
|
|
@@ -3224,7 +2974,7 @@ function followHeldEffects(chunk) {
|
|
|
3224
2974
|
}
|
|
3225
2975
|
}
|
|
3226
2976
|
function lastHeldOf(held, cur) {
|
|
3227
|
-
return cur.
|
|
2977
|
+
return cur.channel === held.channel && cur.boundary === held.boundary ? cur : held;
|
|
3228
2978
|
}
|
|
3229
2979
|
function holdEffectsOn(heldEffects, chunk, effects) {
|
|
3230
2980
|
chunk.effects = effects;
|
|
@@ -3235,7 +2985,7 @@ function isWithin(boundary, outer) {
|
|
|
3235
2985
|
return !!boundary;
|
|
3236
2986
|
}
|
|
3237
2987
|
function holdReorderEffects(head, boundary, effects) {
|
|
3238
|
-
if (!head.
|
|
2988
|
+
if (!head.channel.readyId) {
|
|
3239
2989
|
if (head.effects) head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(head.boundary, null), head.effects);
|
|
3240
2990
|
head.effects = head.lastEffect = "";
|
|
3241
2991
|
}
|
|
@@ -3247,13 +2997,12 @@ function joinHeldEffects(heldEffects, effects) {
|
|
|
3247
2997
|
function joinUncaught(joined, held) {
|
|
3248
2998
|
return held.boundary.aborted ? joined : concatEffects(joined, held.effects);
|
|
3249
2999
|
}
|
|
3250
|
-
function flushSerializer(boundary,
|
|
3000
|
+
function flushSerializer(boundary, channel) {
|
|
3251
3001
|
const { state } = boundary;
|
|
3252
3002
|
const { serializer } = state;
|
|
3253
|
-
const pending = serializer.
|
|
3254
|
-
if (
|
|
3255
|
-
const { writeScopes, passiveScopes } =
|
|
3256
|
-
const isBlockingState = serializeState !== state;
|
|
3003
|
+
const pending = hasMatchingCalls(serializer, channel.readyId);
|
|
3004
|
+
if (channel.flushScopes || pending) {
|
|
3005
|
+
const { writeScopes, passiveScopes } = channel;
|
|
3257
3006
|
const flushes = [];
|
|
3258
3007
|
if (passiveScopes) for (const key in passiveScopes) {
|
|
3259
3008
|
const props = writeScopes[key];
|
|
@@ -3262,8 +3011,8 @@ function flushSerializer(boundary, serializeState) {
|
|
|
3262
3011
|
delete passiveScopes[key];
|
|
3263
3012
|
}
|
|
3264
3013
|
}
|
|
3265
|
-
if (!
|
|
3266
|
-
state.
|
|
3014
|
+
if (!channel.readyId && !state.hasWrittenGlobals) {
|
|
3015
|
+
state.hasWrittenGlobals = true;
|
|
3267
3016
|
const globals = getFilteredGlobals(state.$global);
|
|
3268
3017
|
if (globals) flushes.push([
|
|
3269
3018
|
0,
|
|
@@ -3281,11 +3030,11 @@ function flushSerializer(boundary, serializeState) {
|
|
|
3281
3030
|
]);
|
|
3282
3031
|
}
|
|
3283
3032
|
if (flushes.length || pending) {
|
|
3284
|
-
if (
|
|
3285
|
-
|
|
3033
|
+
if (channel.readyId && !state.hasWrittenGlobals) flushSerializerGlobals(boundary);
|
|
3034
|
+
state.addResumes(channel, stringifyScopes(serializer, flushes, boundary, channel));
|
|
3286
3035
|
}
|
|
3287
|
-
|
|
3288
|
-
|
|
3036
|
+
channel.writeScopes = {};
|
|
3037
|
+
channel.flushScopes = false;
|
|
3289
3038
|
if (pending) state.walkOnNextFlush = true;
|
|
3290
3039
|
}
|
|
3291
3040
|
}
|
|
@@ -3293,9 +3042,9 @@ function flushSerializerGlobals(boundary) {
|
|
|
3293
3042
|
const { state } = boundary;
|
|
3294
3043
|
const globals = getFilteredGlobals(state.$global);
|
|
3295
3044
|
if (globals) {
|
|
3296
|
-
state.
|
|
3297
|
-
state.
|
|
3298
|
-
state.resumes = concatSequence(state.resumes, state.serializer
|
|
3045
|
+
state.hasWrittenGlobals = true;
|
|
3046
|
+
state.needsWalkerRuntime = true;
|
|
3047
|
+
state.resumes = concatSequence(state.resumes, stringifyScopes(state.serializer, [[
|
|
3299
3048
|
0,
|
|
3300
3049
|
globals,
|
|
3301
3050
|
globals
|
|
@@ -3453,7 +3202,7 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, m
|
|
|
3453
3202
|
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
3454
3203
|
const render = () => {
|
|
3455
3204
|
if (renderer) try {
|
|
3456
|
-
_set_scope_reason(shouldResume ?
|
|
3205
|
+
_set_scope_reason(shouldResume ? ALL_GROUPS : 0);
|
|
3457
3206
|
return inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
3458
3207
|
...inputOrArgs,
|
|
3459
3208
|
content
|
|
@@ -3485,10 +3234,10 @@ function _content_resume(id, fn, scopeId, locals) {
|
|
|
3485
3234
|
return _resume(_content(id, fn, scopeId), id, scopeId, locals);
|
|
3486
3235
|
}
|
|
3487
3236
|
const patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
|
|
3488
|
-
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs,
|
|
3237
|
+
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, markerGuard, tagVar) => {
|
|
3489
3238
|
const patched = patch(tag, scopeId, accessor);
|
|
3490
3239
|
if (patched !== tag) patched["id"] = tag;
|
|
3491
|
-
return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs,
|
|
3240
|
+
return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, markerGuard, tagVar);
|
|
3492
3241
|
};
|
|
3493
3242
|
})(_dynamic_tag);
|
|
3494
3243
|
//#endregion
|
|
@@ -3773,7 +3522,7 @@ function writeLoadAsset(assetId, flush, triggers) {
|
|
|
3773
3522
|
const g = $global();
|
|
3774
3523
|
writeAsset(g, addAsset(g, assetId, flush, triggers));
|
|
3775
3524
|
}
|
|
3776
|
-
function withPageAssets(template,
|
|
3525
|
+
function withPageAssets(template, flush, assetId, runtimeId) {
|
|
3777
3526
|
return Object.assign((input) => {
|
|
3778
3527
|
const g = $global();
|
|
3779
3528
|
if (runtimeId) {
|
|
@@ -3782,7 +3531,7 @@ function withPageAssets(template, runtime, assetId, runtimeId) {
|
|
|
3782
3531
|
g.runtimeId = runtimeId;
|
|
3783
3532
|
} else if (g.runtimeId !== runtimeId) console.error(`A page entry compiled with runtimeId "${runtimeId}" is nested in a render using runtimeId "${g.runtimeId}", so its content cannot resume.`);
|
|
3784
3533
|
}
|
|
3785
|
-
const asset = addAsset(g, assetId,
|
|
3534
|
+
const asset = addAsset(g, assetId, flush);
|
|
3786
3535
|
if (g.__flush__) {
|
|
3787
3536
|
writeAsset(g, asset);
|
|
3788
3537
|
return writeWaitReady(assetId, template, input);
|
|
@@ -3882,6 +3631,326 @@ function toObjectExpression(options) {
|
|
|
3882
3631
|
const SET_SCOPE_REGISTER_ID = "$compat_setScope";
|
|
3883
3632
|
const RENDER_BODY_ID = "$compat_renderBody";
|
|
3884
3633
|
//#endregion
|
|
3634
|
+
//#region src/common/for.ts
|
|
3635
|
+
function forIn(obj, cb) {
|
|
3636
|
+
for (const key in obj) cb(key, obj[key]);
|
|
3637
|
+
}
|
|
3638
|
+
function forOf(list, cb) {
|
|
3639
|
+
assertValidList(list);
|
|
3640
|
+
if (list) {
|
|
3641
|
+
let i = 0;
|
|
3642
|
+
for (const item of list) cb(item, i++);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
function forTo(to, from, step, cb) {
|
|
3646
|
+
assertValidRangeBound("to", to);
|
|
3647
|
+
assertOptionalRangeNumber("from", from);
|
|
3648
|
+
assertOptionalRangeNumber("step", step);
|
|
3649
|
+
const start = from || 0;
|
|
3650
|
+
const delta = step || 1;
|
|
3651
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
3652
|
+
}
|
|
3653
|
+
function forUntil(until, from, step, cb) {
|
|
3654
|
+
assertValidRangeBound("until", until);
|
|
3655
|
+
assertOptionalRangeNumber("from", from);
|
|
3656
|
+
assertOptionalRangeNumber("step", step);
|
|
3657
|
+
const start = from || 0;
|
|
3658
|
+
const delta = step || 1;
|
|
3659
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
3660
|
+
}
|
|
3661
|
+
//#endregion
|
|
3662
|
+
//#region src/html/for.ts
|
|
3663
|
+
function forOfBy(by, item, index) {
|
|
3664
|
+
return by ? typeof by === "string" ? item[by] : by(item, index) : index;
|
|
3665
|
+
}
|
|
3666
|
+
function forInBy(by, name, value) {
|
|
3667
|
+
return by ? by(name, value) : name;
|
|
3668
|
+
}
|
|
3669
|
+
function forStepBy(by, index) {
|
|
3670
|
+
return by ? by(index) : index;
|
|
3671
|
+
}
|
|
3672
|
+
//#endregion
|
|
3673
|
+
//#region src/html/control-flow.ts
|
|
3674
|
+
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
3675
|
+
if (display) {
|
|
3676
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
3677
|
+
} else $chunk.writeHTML("<t hidden>");
|
|
3678
|
+
}
|
|
3679
|
+
function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3680
|
+
const branchId = _scope_id();
|
|
3681
|
+
const wrap = !display;
|
|
3682
|
+
if (wrap) $chunk.writeHTML("</t>");
|
|
3683
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
3684
|
+
}
|
|
3685
|
+
function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3686
|
+
forBranches(by, cb, iterateForOf(list, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
3687
|
+
}
|
|
3688
|
+
function iterateForOf(list, cb, by) {
|
|
3689
|
+
return (each) => each ? forOf(list, (item, index) => {
|
|
3690
|
+
const itemKey = forOfBy(by, item, index);
|
|
3691
|
+
each(itemKey, itemKey === index, item, index);
|
|
3692
|
+
}) : forOf(list, cb);
|
|
3693
|
+
}
|
|
3694
|
+
function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3695
|
+
forBranches(by, cb, iterateForIn(obj, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
3696
|
+
}
|
|
3697
|
+
function iterateForIn(obj, cb, by) {
|
|
3698
|
+
return (each) => each ? forIn(obj, (key, value) => {
|
|
3699
|
+
each(forInBy(by, key, value), false, key, value);
|
|
3700
|
+
}) : forIn(obj, cb);
|
|
3701
|
+
}
|
|
3702
|
+
function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3703
|
+
forBranches(by, cb, iterateForTo(to, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
3704
|
+
}
|
|
3705
|
+
function iterateForTo(to, from, step, cb, by) {
|
|
3706
|
+
return (each) => {
|
|
3707
|
+
let index = 0;
|
|
3708
|
+
return each ? forTo(to, from, step, (value) => {
|
|
3709
|
+
const itemKey = forStepBy(by, value);
|
|
3710
|
+
each(itemKey, itemKey === index++, value);
|
|
3711
|
+
}) : forTo(to, from, step, cb);
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
function _for_until(until, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3715
|
+
forBranches(by, cb, iterateForUntil(until, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
3716
|
+
}
|
|
3717
|
+
function iterateForUntil(until, from, step, cb, by) {
|
|
3718
|
+
return (each) => {
|
|
3719
|
+
let index = 0;
|
|
3720
|
+
return each ? forUntil(until, from, step, (value) => {
|
|
3721
|
+
const itemKey = forStepBy(by, value);
|
|
3722
|
+
each(itemKey, itemKey === index++, value);
|
|
3723
|
+
}) : forUntil(until, from, step, cb);
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
function checkLoopKeys(cb, iterate) {
|
|
3727
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
3728
|
+
return (each) => iterate((itemKey, sameAsIndex, a, b) => {
|
|
3729
|
+
assertValidLoopKey(itemKey, seenKeys);
|
|
3730
|
+
if (each) each(itemKey, sameAsIndex, a, b);
|
|
3731
|
+
else cb(a, b);
|
|
3732
|
+
});
|
|
3733
|
+
}
|
|
3734
|
+
function forBranches(by, cb, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3735
|
+
if (by) iterate = checkLoopKeys(cb, iterate);
|
|
3736
|
+
if (branchGuard === 0) {
|
|
3737
|
+
iterate(0);
|
|
3738
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
const { state } = $chunk.boundary;
|
|
3742
|
+
const resumeKeys = markerGuard !== 0;
|
|
3743
|
+
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
3744
|
+
let flushBranchIds = "";
|
|
3745
|
+
let loopScopes;
|
|
3746
|
+
iterate((itemKey, sameAsIndex, a, b) => {
|
|
3747
|
+
const branchId = _peek_scope_id();
|
|
3748
|
+
if (resumeMarker) {
|
|
3749
|
+
if (singleNode) flushBranchIds = " " + branchId + flushBranchIds;
|
|
3750
|
+
else {
|
|
3751
|
+
$chunk.writeHTML(state.mark("[", flushBranchIds));
|
|
3752
|
+
flushBranchIds = branchId + "";
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
withBranchId(branchId, cb, a, b);
|
|
3756
|
+
const branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { [LoopKey]: itemKey } : {});
|
|
3757
|
+
if (!resumeMarker) loopScopes = push(loopScopes, branchScope);
|
|
3758
|
+
});
|
|
3759
|
+
if (loopScopes) writeScope(scopeId, { [BranchScopes + accessor]: loopScopes });
|
|
3760
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
3761
|
+
}
|
|
3762
|
+
function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
3763
|
+
const resumeBranch = branchGuard !== 0;
|
|
3764
|
+
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
3765
|
+
const branchId = _peek_scope_id();
|
|
3766
|
+
const chunk = $chunk;
|
|
3767
|
+
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
3768
|
+
const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
|
3769
|
+
const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
3770
|
+
if (beforeBranch !== void 0) applyBranchStart(chunk, beforeBranch, shouldWriteBranch);
|
|
3771
|
+
if (shouldWriteBranch && (branchIndex || !resumeMarker)) writeScope(scopeId, {
|
|
3772
|
+
[ConditionalRenderer + accessor]: branchIndex || void 0,
|
|
3773
|
+
[BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
3774
|
+
});
|
|
3775
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
3776
|
+
}
|
|
3777
|
+
function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
3778
|
+
return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
|
|
3779
|
+
}
|
|
3780
|
+
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
3781
|
+
const endTag = parentEndTag || "";
|
|
3782
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
|
|
3783
|
+
const { state } = $chunk.boundary;
|
|
3784
|
+
const mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
3785
|
+
$chunk.writeHTML(mark + endTag);
|
|
3786
|
+
} else if (markerGuard !== 0) $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
3787
|
+
else $chunk.writeHTML(endTag);
|
|
3788
|
+
}
|
|
3789
|
+
function _await(scopeId, accessor, promise, content, markerGuard) {
|
|
3790
|
+
const resumeMarker = markerGuard !== 0;
|
|
3791
|
+
if (!isPromise(promise)) {
|
|
3792
|
+
if (resumeMarker) {
|
|
3793
|
+
const branchId = _peek_scope_id();
|
|
3794
|
+
$chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
3795
|
+
withBranchId(branchId, content, promise);
|
|
3796
|
+
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
3797
|
+
} else content(promise);
|
|
3798
|
+
return;
|
|
3799
|
+
}
|
|
3800
|
+
const chunk = $chunk;
|
|
3801
|
+
const { boundary } = chunk;
|
|
3802
|
+
const startId = _peek_scope_id();
|
|
3803
|
+
const after = chunk.next = chunk.forkRest(boundary);
|
|
3804
|
+
chunk.async = true;
|
|
3805
|
+
captureContext(chunk);
|
|
3806
|
+
boundary.startAsync();
|
|
3807
|
+
promise.then((value) => {
|
|
3808
|
+
if (chunk.async) {
|
|
3809
|
+
chunk.async = false;
|
|
3810
|
+
if (!boundary.aborted) {
|
|
3811
|
+
const { state } = boundary;
|
|
3812
|
+
chunk.render(() => {
|
|
3813
|
+
if (resumeMarker) {
|
|
3814
|
+
const branchId = _peek_scope_id();
|
|
3815
|
+
$chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
3816
|
+
withBranchId(branchId, () => withAsyncContent({ parent: getAsyncContent(chunk) }, content, value));
|
|
3817
|
+
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
3818
|
+
} else {
|
|
3819
|
+
const renderedSince = _peek_scope_id() !== startId;
|
|
3820
|
+
const async = { parent: getAsyncContent(chunk) };
|
|
3821
|
+
withAsyncContent(async, content, value);
|
|
3822
|
+
async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "";
|
|
3823
|
+
if (async.resumed) $chunk.writeHTML(async.visit);
|
|
3824
|
+
async.end = $chunk;
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
if (!chunk.async && boundary.pendingReorders?.delete(chunk)) state.reorder(chunk);
|
|
3828
|
+
boundary.endAsync();
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
}, (err) => {
|
|
3832
|
+
chunk.async = false;
|
|
3833
|
+
boundary.abort(err);
|
|
3834
|
+
});
|
|
3835
|
+
}
|
|
3836
|
+
function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
|
|
3837
|
+
const placeholderBranchId = placeholderContent ? _scope_id() : 0;
|
|
3838
|
+
const branchId = _peek_scope_id();
|
|
3839
|
+
const chunk = $chunk;
|
|
3840
|
+
const { boundary } = chunk;
|
|
3841
|
+
const { state } = boundary;
|
|
3842
|
+
const { resumeWrites } = boundary;
|
|
3843
|
+
const beforeBranch = deferBranchStart(chunk);
|
|
3844
|
+
const renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId));
|
|
3845
|
+
const writesRenderers = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers);
|
|
3846
|
+
const keepsMarks = state.keepsTryMarks(chunk, resumeWrites);
|
|
3847
|
+
applyBranchStart(chunk, beforeBranch, keepsMarks);
|
|
3848
|
+
if (!keepsMarks) return;
|
|
3849
|
+
if (!writesRenderers) renderers();
|
|
3850
|
+
$chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
3851
|
+
}
|
|
3852
|
+
function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
|
|
3853
|
+
const chunk = $chunk;
|
|
3854
|
+
const { boundary } = chunk;
|
|
3855
|
+
const body = chunk.fork(boundary, null);
|
|
3856
|
+
if (body === body.render(content)) {
|
|
3857
|
+
chunk.append(body);
|
|
3858
|
+
return;
|
|
3859
|
+
}
|
|
3860
|
+
chunk.next = chunk.forkRest(boundary);
|
|
3861
|
+
captureContext(chunk);
|
|
3862
|
+
chunk.placeholder = {
|
|
3863
|
+
body,
|
|
3864
|
+
render: placeholder,
|
|
3865
|
+
branchId,
|
|
3866
|
+
scopeId,
|
|
3867
|
+
placeholderBranchId
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
function tryBoundary(content, catchContent, branchId, renderers) {
|
|
3871
|
+
const chunk = $chunk;
|
|
3872
|
+
const { boundary } = chunk;
|
|
3873
|
+
const { state } = boundary;
|
|
3874
|
+
const bodyBoundary = new Boundary(state, void 0, boundary);
|
|
3875
|
+
if (catchContent) bodyBoundary.withinCatch = true;
|
|
3876
|
+
const body = chunk.fork(bodyBoundary, null);
|
|
3877
|
+
const bodyEnd = body.render(withBranchId, branchId, content);
|
|
3878
|
+
if (bodyBoundary.aborted) {
|
|
3879
|
+
if (!catchContent) throw bodyBoundary.reason;
|
|
3880
|
+
catchContent(bodyBoundary.reason);
|
|
3881
|
+
return true;
|
|
3882
|
+
}
|
|
3883
|
+
if (body === bodyEnd) {
|
|
3884
|
+
chunk.append(body);
|
|
3885
|
+
return false;
|
|
3886
|
+
}
|
|
3887
|
+
const renderersAtSettle = !bodyBoundary.resumeWrites;
|
|
3888
|
+
const bodyNext = bodyEnd.next = chunk.forkRest(boundary);
|
|
3889
|
+
chunk.next = body;
|
|
3890
|
+
boundary.startAsync();
|
|
3891
|
+
const reorderId = catchContent ? state.nextReorderId() : "";
|
|
3892
|
+
if (reorderId) {
|
|
3893
|
+
chunk.catchRange = {
|
|
3894
|
+
id: reorderId,
|
|
3895
|
+
end: bodyEnd
|
|
3896
|
+
};
|
|
3897
|
+
captureContext(chunk);
|
|
3898
|
+
}
|
|
3899
|
+
bodyBoundary.onNext = () => {
|
|
3900
|
+
if (boundary.aborted) return;
|
|
3901
|
+
if (bodyBoundary.aborted) {
|
|
3902
|
+
if (!reorderId) {
|
|
3903
|
+
boundary.abort(bodyBoundary.reason);
|
|
3904
|
+
return;
|
|
3905
|
+
}
|
|
3906
|
+
const streamed = !chunk.catchRange;
|
|
3907
|
+
const catchChunk = chunk.fork(boundary, null);
|
|
3908
|
+
chunk.catchRange = null;
|
|
3909
|
+
if (!renderersAtSettle) catchChunk.render(clearTryRenderers, branchId);
|
|
3910
|
+
const inOrder = catchChunk === catchChunk.render(catchContent, bodyBoundary.reason);
|
|
3911
|
+
if (boundary.aborted) return;
|
|
3912
|
+
if (bodyEnd.consumed || !inOrder) catchChunk.reorderBranch = branchId;
|
|
3913
|
+
if (bodyEnd.consumed) {
|
|
3914
|
+
catchChunk.reorderId = reorderId;
|
|
3915
|
+
state.reorder(catchChunk);
|
|
3916
|
+
} else {
|
|
3917
|
+
let reorder = null;
|
|
3918
|
+
if (!inOrder) reorder = catchChunk;
|
|
3919
|
+
else if (streamed) reorder = chunk.fork(boundary, null);
|
|
3920
|
+
if (reorder) reorder.reorderId = reorderId;
|
|
3921
|
+
const endMarker = state.mark("!", reorderId);
|
|
3922
|
+
let cut = body;
|
|
3923
|
+
while (cut.consumed) cut = cut.next;
|
|
3924
|
+
cut.async = false;
|
|
3925
|
+
cut.next = inOrder ? catchChunk : bodyNext;
|
|
3926
|
+
cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker;
|
|
3927
|
+
cut.scripts = cut.effects = cut.lastEffect = "";
|
|
3928
|
+
cut.placeholder = cut.reorderId = cut.catchRange = null;
|
|
3929
|
+
cut.deferredReorder = reorder;
|
|
3930
|
+
if (inOrder) catchChunk.next = bodyNext;
|
|
3931
|
+
}
|
|
3932
|
+
boundary.endAsync();
|
|
3933
|
+
} else if (!bodyBoundary.count) {
|
|
3934
|
+
if (renderersAtSettle && bodyBoundary.resumeWrites) bodyEnd.render(renderers);
|
|
3935
|
+
chunk.catchRange = null;
|
|
3936
|
+
boundary.endAsync();
|
|
3937
|
+
} else boundary.onNext();
|
|
3938
|
+
};
|
|
3939
|
+
return renderersAtSettle;
|
|
3940
|
+
}
|
|
3941
|
+
function clearTryRenderers(branchId) {
|
|
3942
|
+
writeScope(branchId, {
|
|
3943
|
+
[CatchContent]: 0,
|
|
3944
|
+
[PlaceholderContent]: _scope_with_id(branchId)["#PlaceholderContent"] && 0
|
|
3945
|
+
});
|
|
3946
|
+
}
|
|
3947
|
+
function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
3948
|
+
writeScope(branchId, {
|
|
3949
|
+
[CatchContent]: catchContent,
|
|
3950
|
+
[PlaceholderContent]: placeholderContent
|
|
3951
|
+
});
|
|
3952
|
+
}
|
|
3953
|
+
//#endregion
|
|
3885
3954
|
//#region src/html/compat.ts
|
|
3886
3955
|
const K_TAGS_API_STATE = Symbol();
|
|
3887
3956
|
const COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
@@ -3930,7 +3999,7 @@ const compat = {
|
|
|
3930
3999
|
return function toJSON() {
|
|
3931
4000
|
let compatRegistered = COMPAT_REGISTRY.get(this);
|
|
3932
4001
|
if (!compatRegistered) {
|
|
3933
|
-
const registered =
|
|
4002
|
+
const registered = REGISTRY.get(this);
|
|
3934
4003
|
if (registered) {
|
|
3935
4004
|
const scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
|
|
3936
4005
|
if (scopeId !== void 0) _script(scopeId, SET_SCOPE_REGISTER_ID);
|
|
@@ -3974,7 +4043,7 @@ const compat = {
|
|
|
3974
4043
|
let html = "";
|
|
3975
4044
|
let scripts = "";
|
|
3976
4045
|
if (reorders) for (const reorder of reorders) state.reorder(reorder);
|
|
3977
|
-
if (boundary.flush() === 0) ({html, scripts} = chunk.
|
|
4046
|
+
if (boundary.flush() === 0) ({html, scripts} = chunk.flush(boundary));
|
|
3978
4047
|
if (boundary.aborted) throw boundary.reason;
|
|
3979
4048
|
if (boundary.count) throw new Error("Cannot serialize promise across tags/class compat layer.");
|
|
3980
4049
|
return {
|
|
@@ -4011,7 +4080,7 @@ const compat = {
|
|
|
4011
4080
|
}
|
|
4012
4081
|
});
|
|
4013
4082
|
head.render(() => {
|
|
4014
|
-
_set_scope_reason(willRerender ?
|
|
4083
|
+
_set_scope_reason(willRerender ? ALL_GROUPS : 0);
|
|
4015
4084
|
try {
|
|
4016
4085
|
renderer(normalizedInput);
|
|
4017
4086
|
} finally {
|
|
@@ -4059,7 +4128,7 @@ const compat = {
|
|
|
4059
4128
|
registerClassFunctions(input) {
|
|
4060
4129
|
for (const key in input) {
|
|
4061
4130
|
const value = input[key];
|
|
4062
|
-
if (typeof value === "function" && !
|
|
4131
|
+
if (typeof value === "function" && !REGISTRY.has(value)) register(RENDER_BODY_ID, value);
|
|
4063
4132
|
}
|
|
4064
4133
|
},
|
|
4065
4134
|
registerClassFunction($global, id, fn, hostId) {
|