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