marko 6.3.56 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cheatsheet.md +3 -3
- package/dist/common/constants/accessor-prefix.d.ts +2 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +2 -0
- package/dist/common/constants/accessor-prop.d.ts +3 -0
- package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
- package/dist/common/constants/reserved-id.d.ts +5 -0
- package/dist/common/errors.d.ts +1 -1
- package/dist/common/types.d.ts +11 -2
- package/dist/debug/dom/catch.feat.js +12 -14
- package/dist/debug/dom/catch.feat.mjs +12 -14
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +4 -0
- package/dist/debug/dom/lazy.feat.mjs +4 -0
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-DcwejnYg.js → dom-ClV4kVOO.js} +263 -193
- package/dist/debug/{dom-BeCNT5R5.mjs → dom-LFrKxOk5.mjs} +246 -182
- package/dist/debug/dom.js +14 -12
- package/dist/debug/dom.mjs +14 -12
- package/dist/debug/html.js +826 -685
- package/dist/debug/html.mjs +822 -683
- package/dist/dom/abort-signal.d.ts +2 -0
- package/dist/dom/catch.feat.js +6 -7
- package/dist/dom/catch.feat.mjs +5 -7
- package/dist/dom/control-flow.d.ts +3 -5
- package/dist/dom/controllable-input.feat.js +3 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +3 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +3 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +3 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +3 -2
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-script.feat.js +3 -2
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +2 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.d.ts +1 -0
- package/dist/dom/lazy.feat.js +4 -0
- package/dist/dom/lazy.feat.mjs +4 -0
- package/dist/dom/load.d.ts +3 -3
- package/dist/dom/placeholder.feat.js +4 -3
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/queue.d.ts +2 -4
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/scope.d.ts +0 -1
- package/dist/dom/signals.d.ts +3 -2
- package/dist/{dom-QEF0csuC.js → dom-CNglVi8P.js} +222 -185
- package/dist/{dom-BwNsIevR.mjs → dom-DfP3MCo0.mjs} +126 -90
- package/dist/dom.js +59 -56
- package/dist/dom.mjs +34 -32
- package/dist/html/attrs.d.ts +4 -2
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/inlined-runtimes.d.ts +1 -1
- package/dist/html/inlined-runtimes.debug.d.ts +1 -1
- package/dist/html/serializer.d.ts +1 -1
- package/dist/html/writer.d.ts +39 -33
- package/dist/html.d.ts +2 -2
- package/dist/html.js +526 -424
- package/dist/html.mjs +524 -423
- package/dist/translator/core/html-comment.d.ts +0 -7
- package/dist/translator/core/let.d.ts +0 -5
- package/dist/translator/core/show.d.ts +2 -5
- package/dist/translator/core/style.d.ts +6 -8
- package/dist/translator/index.d.ts +9 -0
- package/dist/translator/index.js +8195 -7939
- package/dist/translator/util/binding-has-prop.d.ts +3 -1
- package/dist/translator/util/binding-prop-tree.d.ts +4 -4
- package/dist/translator/util/bindings.d.ts +127 -0
- package/dist/translator/util/body-to-text-literal.d.ts +1 -2
- package/dist/translator/util/branch-tag.d.ts +7 -7
- package/dist/translator/util/constants/binding-type.d.ts +5 -6
- package/dist/translator/util/constants/slot-kind.d.ts +14 -0
- package/dist/translator/util/constants/structure-kind.d.ts +1 -1
- package/dist/translator/util/entry-builder.d.ts +2 -0
- package/dist/translator/util/evaluate.d.ts +11 -10
- package/dist/translator/util/finalize-references.d.ts +4 -0
- package/dist/translator/util/for-selector.d.ts +1 -1
- package/dist/translator/util/generate-uid.d.ts +7 -0
- package/dist/translator/util/get-declared-binding-expression.d.ts +2 -2
- package/dist/translator/util/is-core-tag.d.ts +0 -3
- package/dist/translator/util/is-only-child-in-parent.d.ts +2 -7
- package/dist/translator/util/known-tag.d.ts +8 -7
- package/dist/translator/util/read-replacement.d.ts +3 -0
- package/dist/translator/util/reasons.d.ts +32 -0
- package/dist/translator/util/references.d.ts +69 -167
- package/dist/translator/util/runtime.d.ts +3 -3
- package/dist/translator/util/scope-accessor.d.ts +14 -0
- package/dist/translator/util/scope-read.d.ts +1 -1
- package/dist/translator/util/sections.d.ts +56 -50
- package/dist/translator/util/set-tag-derived-from.d.ts +7 -0
- package/dist/translator/util/setup-work.d.ts +4 -0
- package/dist/translator/util/signals.d.ts +8 -12
- package/dist/translator/util/slots.d.ts +50 -0
- package/dist/translator/util/solve-reasons.d.ts +10 -0
- package/dist/translator/util/sources.d.ts +21 -0
- package/dist/translator/util/structure.d.ts +5 -2
- package/dist/translator/util/tag-facts.d.ts +21 -0
- package/dist/translator/util/tag-name-type.d.ts +4 -1
- package/dist/translator/util/translate-attrs.d.ts +2 -0
- package/dist/translator/util/translate-var.d.ts +3 -0
- package/dist/translator/util/write-guard.d.ts +12 -0
- package/dist/translator/util/writer.d.ts +3 -3
- package/dist/translator/visitors/export-declaration.d.ts +9 -0
- package/dist/translator/visitors/function.d.ts +5 -4
- package/dist/translator/visitors/import-declaration.d.ts +2 -2
- package/dist/translator/visitors/placeholder.d.ts +0 -3
- package/dist/translator/visitors/program/index.d.ts +13 -3
- package/dist/translator/visitors/referenced-identifier.d.ts +2 -1
- package/dist/translator/visitors/tag/custom-tag.d.ts +1 -1
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +0 -3
- package/dist/translator/visitors/tag/index.d.ts +2 -1
- package/dist/translator/visitors/tag/native-tag.d.ts +26 -11
- package/package.json +3 -3
- package/dist/translator/util/insertion-context.d.ts +0 -1
- package/dist/translator/util/is-non-html-text.d.ts +0 -3
- package/dist/translator/util/serialize-guard.d.ts +0 -11
- package/dist/translator/util/serialize-reasons.d.ts +0 -37
- package/dist/translator/util/set-tag-sections-downstream.d.ts +0 -6
- package/dist/translator/util/setup-statements.d.ts +0 -5
package/dist/debug/html.js
CHANGED
|
@@ -106,19 +106,21 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
106
106
|
let str = "";
|
|
107
107
|
let sep = "";
|
|
108
108
|
let part;
|
|
109
|
-
if (val)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
if (val) {
|
|
110
|
+
if (typeof val !== "object") str += val;
|
|
111
|
+
else if (Array.isArray(val)) for (const v of val) {
|
|
112
|
+
part = toDelimitedString(v, delimiter, stringify);
|
|
113
|
+
if (part) {
|
|
114
|
+
str += sep + part;
|
|
115
|
+
sep = delimiter;
|
|
116
|
+
}
|
|
115
117
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
else for (const name in val) {
|
|
119
|
+
part = stringify(name, val[name]);
|
|
120
|
+
if (part) {
|
|
121
|
+
str += sep + part;
|
|
122
|
+
sep = delimiter;
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
return str;
|
|
@@ -218,18 +220,18 @@ function _hoist_read_error() {
|
|
|
218
220
|
function _assert_hoist(value) {
|
|
219
221
|
if (value !== void 0 && typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
|
|
220
222
|
}
|
|
221
|
-
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
223
|
+
function assertExclusiveAttrs(attrs, onError = throwErr, isSet = isTruthy) {
|
|
222
224
|
if (attrs) {
|
|
223
225
|
let exclusiveAttrs;
|
|
224
|
-
if (attrs.checkedChange) (exclusiveAttrs ||= []).push("checkedChange");
|
|
226
|
+
if (isSet(attrs.checkedChange)) (exclusiveAttrs ||= []).push("checkedChange");
|
|
225
227
|
if ("checkedValue" in attrs) {
|
|
226
228
|
(exclusiveAttrs ||= []).push("checkedValue");
|
|
227
229
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
228
|
-
} else if (attrs.checkedValueChange) {
|
|
230
|
+
} else if (isSet(attrs.checkedValueChange)) {
|
|
229
231
|
(exclusiveAttrs ||= []).push("checkedValueChange");
|
|
230
232
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
231
233
|
}
|
|
232
|
-
if (attrs.valueChange) {
|
|
234
|
+
if (isSet(attrs.valueChange)) {
|
|
233
235
|
(exclusiveAttrs ||= []).push("valueChange");
|
|
234
236
|
if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
|
|
235
237
|
}
|
|
@@ -245,6 +247,9 @@ function assertHandlerIsFunction(name, value) {
|
|
|
245
247
|
function assertValidTagName(tagName) {
|
|
246
248
|
if (!/^[a-z][a-z0-9._-]*$/i.test(tagName)) throw new Error(`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`);
|
|
247
249
|
}
|
|
250
|
+
function isTruthy(value) {
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
248
253
|
function throwErr(msg) {
|
|
249
254
|
throw new Error(msg);
|
|
250
255
|
}
|
|
@@ -262,43 +267,47 @@ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
|
262
267
|
const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
|
|
263
268
|
const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
|
|
264
269
|
//#endregion
|
|
265
|
-
//#region src/
|
|
266
|
-
function
|
|
267
|
-
|
|
268
|
-
return val || val === 0 ? val + "" : "";
|
|
269
|
-
}
|
|
270
|
-
function _unescaped(val) {
|
|
271
|
-
assertValidTextValue(val);
|
|
272
|
-
return val ? val + "" : val === 0 ? "0" : "";
|
|
270
|
+
//#region src/common/for.ts
|
|
271
|
+
function forIn(obj, cb) {
|
|
272
|
+
for (const key in obj) cb(key, obj[key]);
|
|
273
273
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
274
|
+
function forOf(list, cb) {
|
|
275
|
+
assertValidList(list);
|
|
276
|
+
if (list) {
|
|
277
|
+
let i = 0;
|
|
278
|
+
for (const item of list) cb(item, i++);
|
|
279
|
+
}
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
function forTo(to, from, step, cb) {
|
|
282
|
+
assertValidRangeBound("to", to);
|
|
283
|
+
assertValidRangeStart("from", from);
|
|
284
|
+
assertValidRangeStart("step", step);
|
|
285
|
+
const start = from || 0;
|
|
286
|
+
const delta = step || 1;
|
|
287
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
286
288
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
function forUntil(until, from, step, cb) {
|
|
290
|
+
assertValidRangeBound("until", until);
|
|
291
|
+
assertValidRangeStart("from", from);
|
|
292
|
+
assertValidRangeStart("step", step);
|
|
293
|
+
const start = from || 0;
|
|
294
|
+
const delta = step || 1;
|
|
295
|
+
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
292
296
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/common/opt.ts
|
|
299
|
+
function push(opt, item) {
|
|
300
|
+
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
296
301
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
+
function concat(opt, other) {
|
|
303
|
+
if (!opt) return other;
|
|
304
|
+
if (!other) return opt;
|
|
305
|
+
if (Array.isArray(opt)) {
|
|
306
|
+
if (Array.isArray(other)) for (const item of other) opt.push(item);
|
|
307
|
+
else opt.push(other);
|
|
308
|
+
return opt;
|
|
309
|
+
}
|
|
310
|
+
return Array.isArray(other) ? [opt, ...other] : [opt, other];
|
|
302
311
|
}
|
|
303
312
|
//#endregion
|
|
304
313
|
//#region src/html/serializer.ts
|
|
@@ -389,7 +398,6 @@ const KNOWN_FUNCTIONS = /* @__PURE__ */ (() => /* @__PURE__ */ new Map([
|
|
|
389
398
|
[Function, "Function"],
|
|
390
399
|
[globalThis.atob, "atob"],
|
|
391
400
|
[globalThis.btoa, "btoa"],
|
|
392
|
-
[globalThis.clearImmediate, "clearImmediate"],
|
|
393
401
|
[globalThis.clearInterval, "clearInterval"],
|
|
394
402
|
[globalThis.clearTimeout, "clearTimeout"],
|
|
395
403
|
[globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
|
|
@@ -397,7 +405,6 @@ const KNOWN_FUNCTIONS = /* @__PURE__ */ (() => /* @__PURE__ */ new Map([
|
|
|
397
405
|
[globalThis.fetch, "fetch"],
|
|
398
406
|
[globalThis.performance?.now, "performance.now"],
|
|
399
407
|
[globalThis.queueMicrotask, "queueMicrotask"],
|
|
400
|
-
[globalThis.setImmediate, "setImmediate"],
|
|
401
408
|
[globalThis.setInterval, "setInterval"],
|
|
402
409
|
[globalThis.setTimeout, "setTimeout"],
|
|
403
410
|
[globalThis.structuredClone, "structuredClone"],
|
|
@@ -613,6 +620,9 @@ var Serializer = class {
|
|
|
613
620
|
this.#state.boundary = boundary;
|
|
614
621
|
this.#state.channel = channel;
|
|
615
622
|
return writeScopesRoot(this.#state, flushes);
|
|
623
|
+
} catch (err) {
|
|
624
|
+
abortRender(boundary, err);
|
|
625
|
+
return "";
|
|
616
626
|
} finally {
|
|
617
627
|
this.#state.flushId++;
|
|
618
628
|
this.#state.buf = [];
|
|
@@ -727,7 +737,7 @@ function writeAssigned(state) {
|
|
|
727
737
|
if (writeProp(state, mutation.object, null, "")) {
|
|
728
738
|
const objectRef = state.refs.get(mutation.object);
|
|
729
739
|
if (objectRef && objectRef.scopeId === void 0) {
|
|
730
|
-
if (!objectRef.id) {
|
|
740
|
+
if (!objectRef.id && !isAncestorChannelRef(state, objectRef)) {
|
|
731
741
|
objectRef.id = nextRefAccess(state);
|
|
732
742
|
state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex];
|
|
733
743
|
state.buf.push(")");
|
|
@@ -740,7 +750,7 @@ function writeAssigned(state) {
|
|
|
740
750
|
const valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
|
|
741
751
|
if (mutation.value === void 0) {} else if (writeProp(state, mutation.value, null, "")) {
|
|
742
752
|
const valueRef = typeof mutation.value === "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
|
|
743
|
-
if (valueRef && !valueRef.id && valueRef.scopeId === void 0) {
|
|
753
|
+
if (valueRef && !valueRef.id && valueRef.scopeId === void 0 && !isAncestorChannelRef(state, valueRef)) {
|
|
744
754
|
valueRef.id = mutation.valueId || nextRefAccess(state);
|
|
745
755
|
state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
|
|
746
756
|
}
|
|
@@ -757,7 +767,7 @@ function writeCallArg(state, val) {
|
|
|
757
767
|
state.buf.push("$");
|
|
758
768
|
} else if (writeProp(state, val, null, "")) {
|
|
759
769
|
const ref = state.refs.get(val) || state.strs.get(val);
|
|
760
|
-
if (ref
|
|
770
|
+
if (ref) ensureId(state, ref);
|
|
761
771
|
} else state.buf.push("void 0");
|
|
762
772
|
}
|
|
763
773
|
function hasChannelMutations(state) {
|
|
@@ -839,8 +849,7 @@ function writeRegistered(state, val, parent, accessor, registered) {
|
|
|
839
849
|
state.buf.push(registered.access + "(_(" + scopeId + ")");
|
|
840
850
|
for (const local of locals) {
|
|
841
851
|
state.buf.push(",");
|
|
842
|
-
|
|
843
|
-
else state.buf.push("0");
|
|
852
|
+
writePlainObject(state, local, newArgReference(state, ref, local));
|
|
844
853
|
}
|
|
845
854
|
} else state.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
|
|
846
855
|
state.buf.push(")");
|
|
@@ -929,7 +938,8 @@ function writeUnknownObject(state, val, ref) {
|
|
|
929
938
|
const proto = Object.getPrototypeOf(val);
|
|
930
939
|
if (proto === objectProto) return writePlainObject(state, val, ref);
|
|
931
940
|
if (proto === arrayProto) return writeArray(state, val, ref);
|
|
932
|
-
|
|
941
|
+
const constructor = proto?.constructor;
|
|
942
|
+
switch (constructor) {
|
|
933
943
|
case void 0: return writeNullObject(state, val, ref);
|
|
934
944
|
case Object: return writePlainObject(state, val, ref);
|
|
935
945
|
case Array: return writeArray(state, val, ref);
|
|
@@ -946,7 +956,7 @@ function writeUnknownObject(state, val, ref) {
|
|
|
946
956
|
case ReferenceError:
|
|
947
957
|
case SyntaxError:
|
|
948
958
|
case TypeError:
|
|
949
|
-
case URIError: return writeError(state, val, ref);
|
|
959
|
+
case URIError: return writeError(state, val, constructor.name, ref);
|
|
950
960
|
case AggregateError: return writeAggregateError(state, val, ref);
|
|
951
961
|
case ArrayBuffer: return writeArrayBuffer(state, val);
|
|
952
962
|
case Int8Array:
|
|
@@ -959,7 +969,7 @@ function writeUnknownObject(state, val, ref) {
|
|
|
959
969
|
case Float32Array:
|
|
960
970
|
case Float64Array:
|
|
961
971
|
case BigInt64Array:
|
|
962
|
-
case BigUint64Array: return writeTypedArray(state, val, ref);
|
|
972
|
+
case BigUint64Array: return writeTypedArray(state, val, constructor.name, ref);
|
|
963
973
|
case DataView: return writeDataView(state, val, ref);
|
|
964
974
|
case WeakSet: return writeWeakSet(state);
|
|
965
975
|
case WeakMap: return writeWeakMap(state);
|
|
@@ -1148,6 +1158,17 @@ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
|
1148
1158
|
}
|
|
1149
1159
|
state.buf.push(")");
|
|
1150
1160
|
}
|
|
1161
|
+
function newArgReference(state, parent, val) {
|
|
1162
|
+
for (const key in val) {
|
|
1163
|
+
const member = val[key];
|
|
1164
|
+
if (isDedupedMember(member) && !(typeof member === "string" ? state.strs.has(member) : state.refs.has(member))) {
|
|
1165
|
+
const ref = new Reference(parent, null, state.flushId, null, nextRefAccess(state));
|
|
1166
|
+
state.buf.push(ref.id + "=");
|
|
1167
|
+
return ref;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return new Reference(parent, null, state.flushId, state.buf.length);
|
|
1171
|
+
}
|
|
1151
1172
|
function isDedupedMember(val) {
|
|
1152
1173
|
switch (typeof val) {
|
|
1153
1174
|
case "object": return val !== null && val[K_SCOPE_ID] === void 0;
|
|
@@ -1180,16 +1201,16 @@ function writeArrayBuffer(state, val) {
|
|
|
1180
1201
|
state.buf.push(result);
|
|
1181
1202
|
return true;
|
|
1182
1203
|
}
|
|
1183
|
-
function writeTypedArray(state, val, ref) {
|
|
1204
|
+
function writeTypedArray(state, val, name, ref) {
|
|
1184
1205
|
if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
|
|
1185
1206
|
if (!canWriteBuffer(state, val.buffer, ref)) return false;
|
|
1186
1207
|
const needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
1187
|
-
state.buf.push("new " +
|
|
1208
|
+
state.buf.push("new " + name + "(");
|
|
1188
1209
|
writeProp(state, val.buffer, ref, "buffer");
|
|
1189
1210
|
state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
1190
1211
|
} else {
|
|
1191
1212
|
state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null));
|
|
1192
|
-
state.buf.push("new " +
|
|
1213
|
+
state.buf.push("new " + name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
|
|
1193
1214
|
}
|
|
1194
1215
|
return true;
|
|
1195
1216
|
}
|
|
@@ -1201,8 +1222,8 @@ function writeWeakMap(state) {
|
|
|
1201
1222
|
state.buf.push("new WeakMap");
|
|
1202
1223
|
return true;
|
|
1203
1224
|
}
|
|
1204
|
-
function writeError(state, val, ref) {
|
|
1205
|
-
const result = "new " +
|
|
1225
|
+
function writeError(state, val, name, ref) {
|
|
1226
|
+
const result = "new " + name + "(" + quote(val.message + "", 0);
|
|
1206
1227
|
if (val.cause !== void 0) {
|
|
1207
1228
|
const pos = state.buf.push(result + ",{cause:") - 1;
|
|
1208
1229
|
if (writeProp(state, val.cause, ref, "cause")) state.buf.push("})");
|
|
@@ -1344,20 +1365,9 @@ function writeResponse(state, val, ref) {
|
|
|
1344
1365
|
}
|
|
1345
1366
|
function writeIntl(state, val, name, ref) {
|
|
1346
1367
|
const { locale, ...options } = val.resolvedOptions();
|
|
1347
|
-
let needsId = false;
|
|
1348
|
-
for (const key in options) if (isDedupedMember(options[key])) {
|
|
1349
|
-
needsId = true;
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
1368
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
optionsRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1356
|
-
state.buf.push(optionsRef.id + "={");
|
|
1357
|
-
} else {
|
|
1358
|
-
optionsRef = new Reference(ref, null, state.flushId, state.buf.length);
|
|
1359
|
-
state.buf.push("{");
|
|
1360
|
-
}
|
|
1369
|
+
const optionsRef = newArgReference(state, ref, options);
|
|
1370
|
+
state.buf.push("{");
|
|
1361
1371
|
writeObjectProps(state, options, optionsRef);
|
|
1362
1372
|
state.buf.push("})");
|
|
1363
1373
|
return true;
|
|
@@ -1371,14 +1381,17 @@ function writeTemporal(state, val, name) {
|
|
|
1371
1381
|
return true;
|
|
1372
1382
|
}
|
|
1373
1383
|
function writeReadableStream(state, val, ref) {
|
|
1374
|
-
if (val.locked)
|
|
1384
|
+
if (val.locked) {
|
|
1385
|
+
throwUnserializable(state, val, ref, "", "The ReadableStream is locked by a reader on the server; to also send it to the browser, `tee()` it (or `clone()` its `Request`/`Response`) before reading.");
|
|
1386
|
+
return false;
|
|
1387
|
+
}
|
|
1375
1388
|
const { boundary, channel } = state;
|
|
1376
1389
|
const reader = val.getReader();
|
|
1377
1390
|
const iterId = nextRefAccess(state);
|
|
1378
1391
|
const handle = newAsyncHandle(state, ref, iterId);
|
|
1379
1392
|
const onFulfilled = ({ value, done }) => {
|
|
1380
1393
|
if (done) writeAsyncCall(state, boundary, handle, "r", value, channel);
|
|
1381
|
-
else if (!boundary.
|
|
1394
|
+
else if (!boundary.aborted) {
|
|
1382
1395
|
reader.read().then(onFulfilled, onRejected);
|
|
1383
1396
|
boundary.startAsync();
|
|
1384
1397
|
writeAsyncCall(state, boundary, handle, "f", value, channel);
|
|
@@ -1425,13 +1438,10 @@ function writeGenerator(state, iter, ref) {
|
|
|
1425
1438
|
state.buf.push("," + holder.id + "={}");
|
|
1426
1439
|
writeProp(state, returnValue, holder, "v");
|
|
1427
1440
|
} else if (returnValue !== void 0) {
|
|
1428
|
-
|
|
1441
|
+
state.buf.push(",");
|
|
1429
1442
|
if (writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue)) {
|
|
1430
1443
|
const retRef = typeof returnValue === "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
|
|
1431
|
-
if (retRef
|
|
1432
|
-
retRef.id = nextRefAccess(state);
|
|
1433
|
-
state.buf[sepIndex] = "," + retRef.id + "=";
|
|
1434
|
-
}
|
|
1444
|
+
if (retRef) ensureId(state, retRef);
|
|
1435
1445
|
}
|
|
1436
1446
|
}
|
|
1437
1447
|
state.buf.push(")");
|
|
@@ -1447,7 +1457,7 @@ function writeAsyncGenerator(state, iter, ref) {
|
|
|
1447
1457
|
const handle = newAsyncHandle(state, ref, iterId);
|
|
1448
1458
|
const onFulfilled = ({ value, done }) => {
|
|
1449
1459
|
if (done) writeAsyncCall(state, boundary, handle, "r", value, channel);
|
|
1450
|
-
else if (!boundary.
|
|
1460
|
+
else if (!boundary.aborted) {
|
|
1451
1461
|
iter.next().then(onFulfilled, onRejected);
|
|
1452
1462
|
boundary.startAsync();
|
|
1453
1463
|
writeAsyncCall(state, boundary, handle, "f", value, channel);
|
|
@@ -1494,7 +1504,7 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
1494
1504
|
return sep;
|
|
1495
1505
|
}
|
|
1496
1506
|
function writeAsyncCall(state, boundary, handle, method, value, channel, valueId = null) {
|
|
1497
|
-
if (boundary.
|
|
1507
|
+
if (boundary.aborted) return;
|
|
1498
1508
|
state.mutated.push({
|
|
1499
1509
|
value,
|
|
1500
1510
|
object: handle,
|
|
@@ -1504,7 +1514,7 @@ function writeAsyncCall(state, boundary, handle, method, value, channel, valueId
|
|
|
1504
1514
|
});
|
|
1505
1515
|
boundary.endAsync();
|
|
1506
1516
|
}
|
|
1507
|
-
function throwUnserializable(state, cause, ref = null, accessor = "") {
|
|
1517
|
+
function throwUnserializable(state, cause, ref = null, accessor = "", hint = "Values referenced in the browser must be serializable.") {
|
|
1508
1518
|
if (cause !== void 0) {
|
|
1509
1519
|
let message = "Unable to serialize";
|
|
1510
1520
|
let access = "";
|
|
@@ -1517,10 +1527,12 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
|
|
|
1517
1527
|
const slotName = debug.slots?.[rawAccessor];
|
|
1518
1528
|
let debugAccess = varLoc ? rawAccessor : void 0;
|
|
1519
1529
|
let debugLoc = debug.loc;
|
|
1520
|
-
if (varLoc)
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1530
|
+
if (varLoc) {
|
|
1531
|
+
if (Array.isArray(varLoc)) {
|
|
1532
|
+
debugAccess = varLoc[0];
|
|
1533
|
+
if (varLoc[1]) debugLoc = varLoc[1];
|
|
1534
|
+
} else debugLoc = varLoc;
|
|
1535
|
+
}
|
|
1524
1536
|
let display;
|
|
1525
1537
|
if (debugAccess !== void 0) display = slotName && debugAccess.startsWith("...") ? `\`${slotName}\` from \`${debugAccess}\`` : JSON.stringify(debugAccess);
|
|
1526
1538
|
else display = describeAccessor(rawAccessor, slotName) ?? JSON.stringify(rawAccessor);
|
|
@@ -1534,10 +1546,10 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
|
|
|
1534
1546
|
if (accessor) access = toAccess(accessor) + access;
|
|
1535
1547
|
if (access[0] === ".") access = access.slice(1);
|
|
1536
1548
|
if (access) message += ` (reading ${access})`;
|
|
1537
|
-
message += ".
|
|
1549
|
+
message += ". " + hint;
|
|
1538
1550
|
const err = new TypeError(message, { cause });
|
|
1539
1551
|
err.stack = void 0;
|
|
1540
|
-
state.boundary
|
|
1552
|
+
abortRender(state.boundary, err);
|
|
1541
1553
|
}
|
|
1542
1554
|
}
|
|
1543
1555
|
const accessorPrefixDescriptions = {
|
|
@@ -1550,12 +1562,14 @@ const accessorPrefixDescriptions = {
|
|
|
1550
1562
|
ControlledType: "the controlled type",
|
|
1551
1563
|
ControlledValue: "the controlled value",
|
|
1552
1564
|
DynamicHTMLLastChild: "the dynamic html",
|
|
1565
|
+
DynamicHTMLValue: "the dynamic html value",
|
|
1553
1566
|
EventAttributes: "the event handlers",
|
|
1554
1567
|
IdFallback: "the generated id",
|
|
1555
1568
|
KeyedScopes: "the keyed scopes",
|
|
1556
1569
|
Lifecycle: "the lifecycle handlers",
|
|
1557
1570
|
Promise: "the pending promise",
|
|
1558
|
-
TagVariableChange: "the tag variable change handler"
|
|
1571
|
+
TagVariableChange: "the tag variable change handler",
|
|
1572
|
+
TryBranch: "the try branch"
|
|
1559
1573
|
};
|
|
1560
1574
|
function describeAccessor(accessor, slotName) {
|
|
1561
1575
|
const sep = accessor.indexOf(":");
|
|
@@ -1587,10 +1601,17 @@ function trackChannel(state, ref) {
|
|
|
1587
1601
|
}
|
|
1588
1602
|
return false;
|
|
1589
1603
|
}
|
|
1604
|
+
function isAncestorChannelRef(state, ref) {
|
|
1605
|
+
return ref.channel?.readyId !== state.channel?.readyId;
|
|
1606
|
+
}
|
|
1590
1607
|
function abortUnreachableChannel(state, val) {
|
|
1591
1608
|
const err = new TypeError("Unable to serialize a value shared between independently lazy loaded content. Values shared this way must also be serialized by content that is not lazily loaded, or by a common parent.", { cause: val });
|
|
1592
1609
|
err.stack = void 0;
|
|
1593
|
-
state.boundary
|
|
1610
|
+
abortRender(state.boundary, err);
|
|
1611
|
+
}
|
|
1612
|
+
function abortRender(boundary, err) {
|
|
1613
|
+
while (boundary.parent) boundary = boundary.parent;
|
|
1614
|
+
boundary.abort(err);
|
|
1594
1615
|
}
|
|
1595
1616
|
function isCircular(parent, ref) {
|
|
1596
1617
|
let cur = parent;
|
|
@@ -1605,16 +1626,17 @@ function toObjectKey(name) {
|
|
|
1605
1626
|
if (name === "__proto__") return "[\"__proto__\"]";
|
|
1606
1627
|
const len = name.length;
|
|
1607
1628
|
const c0 = name.charCodeAt(0);
|
|
1608
|
-
if (c0 >= 48 && c0 <= 57)
|
|
1609
|
-
if (
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1629
|
+
if (c0 >= 48 && c0 <= 57) {
|
|
1630
|
+
if (c0 === 48) {
|
|
1631
|
+
if (len !== 1) return quote(name, 1);
|
|
1632
|
+
} else {
|
|
1633
|
+
for (let i = 1; i < len; i++) {
|
|
1634
|
+
const c = name.charCodeAt(i);
|
|
1635
|
+
if (c < 48 || c > 57) return quote(name, i);
|
|
1636
|
+
}
|
|
1637
|
+
if (len > 15 && "" + +name !== name) return quote(name, 0);
|
|
1614
1638
|
}
|
|
1615
|
-
|
|
1616
|
-
}
|
|
1617
|
-
else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
|
|
1639
|
+
} else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
|
|
1618
1640
|
const c = name.charCodeAt(i);
|
|
1619
1641
|
if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95 || c === 36)) return quote(name, i);
|
|
1620
1642
|
}
|
|
@@ -1675,11 +1697,10 @@ function quote(str, startPos) {
|
|
|
1675
1697
|
return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
|
|
1676
1698
|
}
|
|
1677
1699
|
function writeRef(state, ref) {
|
|
1678
|
-
if (ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId)) {
|
|
1700
|
+
if (ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) && !isAncestorChannelRef(state, ref)) {
|
|
1679
1701
|
ref.path = accessPath(state, ref);
|
|
1680
1702
|
ref.pos = state.buf.length;
|
|
1681
1703
|
ref.flushId = state.flushId;
|
|
1682
|
-
ref.channel = state.channel;
|
|
1683
1704
|
state.buf.push(ref.path);
|
|
1684
1705
|
} else state.buf.push(ensureId(state, ref));
|
|
1685
1706
|
}
|
|
@@ -1700,23 +1721,26 @@ function accessId(state, ref) {
|
|
|
1700
1721
|
}
|
|
1701
1722
|
function assignId(state, ref) {
|
|
1702
1723
|
const { pos } = ref;
|
|
1703
|
-
ref.id = nextRefAccess(state);
|
|
1704
1724
|
if (pos !== null && ref.flushId === state.flushId) {
|
|
1725
|
+
ref.id = nextRefAccess(state);
|
|
1705
1726
|
if (pos === 0) state.buf[0] = ref.id + "=" + state.buf[0];
|
|
1706
1727
|
else state.buf[pos - 1] += ref.id + "=";
|
|
1707
1728
|
return ref.id;
|
|
1708
1729
|
}
|
|
1709
|
-
ref.
|
|
1730
|
+
if (isAncestorChannelRef(state, ref)) return ref.path || accessPath(state, ref);
|
|
1731
|
+
ref.id = nextRefAccess(state);
|
|
1710
1732
|
return ref.id + "=" + (ref.path || accessPath(state, ref));
|
|
1711
1733
|
}
|
|
1712
1734
|
function accessPath(state, ref) {
|
|
1713
1735
|
let cur = ref;
|
|
1714
1736
|
let accessPrevValue = "";
|
|
1715
1737
|
do {
|
|
1738
|
+
if (cur.accessor === null) throw new Error("Unable to serialize a reused value: no access path reaches where it was first written, and it has no id.");
|
|
1716
1739
|
accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
|
|
1717
1740
|
const parent = cur.parent;
|
|
1718
1741
|
if (parent.id) {
|
|
1719
|
-
|
|
1742
|
+
trackChannel(state, parent);
|
|
1743
|
+
return parent.id + accessPrevValue;
|
|
1720
1744
|
}
|
|
1721
1745
|
if (parent.flushId === state.flushId || parent.scopeId !== void 0) return accessId(state, parent) + accessPrevValue;
|
|
1722
1746
|
cur = parent;
|
|
@@ -1739,7 +1763,7 @@ function nextId(state) {
|
|
|
1739
1763
|
let n = state.ids++;
|
|
1740
1764
|
let r = c[n % 53];
|
|
1741
1765
|
for (n = n / 53 | 0; n; n >>>= 6) r += c[n & 63];
|
|
1742
|
-
return r;
|
|
1766
|
+
return r === "name" ? nextId(state) : r;
|
|
1743
1767
|
}
|
|
1744
1768
|
function hasSymbolIterator(value) {
|
|
1745
1769
|
return Symbol.iterator in value;
|
|
@@ -1790,126 +1814,307 @@ function patchIteratorNext(proto) {
|
|
|
1790
1814
|
proto.next[kTouchedIterator] = true;
|
|
1791
1815
|
}
|
|
1792
1816
|
//#endregion
|
|
1793
|
-
//#region src/
|
|
1794
|
-
function
|
|
1795
|
-
|
|
1817
|
+
//#region src/html/attrs.ts
|
|
1818
|
+
function _attr_class(value) {
|
|
1819
|
+
return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
|
|
1796
1820
|
}
|
|
1797
|
-
function
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1821
|
+
function _attr_style(value) {
|
|
1822
|
+
return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
|
|
1823
|
+
}
|
|
1824
|
+
function _attr_option_value(value) {
|
|
1825
|
+
const valueAttr = _attr("value", value);
|
|
1826
|
+
const selectedValue = getContext(kSelectedValue);
|
|
1827
|
+
if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
|
|
1828
|
+
{
|
|
1829
|
+
const matched = getContext(kSelectedValueMatched);
|
|
1830
|
+
if (matched) matched.value = true;
|
|
1831
|
+
}
|
|
1832
|
+
return valueAttr + " selected";
|
|
1802
1833
|
}
|
|
1834
|
+
return valueAttr;
|
|
1803
1835
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1836
|
+
const kSelectedValue = Symbol("selectedValue");
|
|
1837
|
+
const kSelectedValueMatched = Symbol("selectedValueMatched");
|
|
1838
|
+
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
1839
|
+
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1840
|
+
if (content) {
|
|
1841
|
+
const selectedValue = value ?? "";
|
|
1842
|
+
if (valueChange) {
|
|
1843
|
+
const matched = { value: false };
|
|
1844
|
+
withContext(kSelectedValue, selectedValue, () => withContext(kSelectedValueMatched, matched, content));
|
|
1845
|
+
if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
|
|
1846
|
+
} else withContext(kSelectedValue, selectedValue, content);
|
|
1847
|
+
}
|
|
1811
1848
|
}
|
|
1812
|
-
function
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
assertValidRangeStart("step", step);
|
|
1816
|
-
const start = from || 0;
|
|
1817
|
-
const delta = step || 1;
|
|
1818
|
-
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
1849
|
+
function _attrs_select_value(scopeId, nodeAccessor, data, content) {
|
|
1850
|
+
if (data && ("value" in data || data.valueChange)) _attr_select_value(scopeId, nodeAccessor, data.value, data.valueChange, content, 1);
|
|
1851
|
+
else content();
|
|
1819
1852
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
if (opt) if (Array.isArray(opt)) for (const item of opt) cb(item);
|
|
1824
|
-
else cb(opt);
|
|
1853
|
+
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1854
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1855
|
+
return _textarea_value(value);
|
|
1825
1856
|
}
|
|
1826
|
-
function
|
|
1827
|
-
return
|
|
1857
|
+
function _attrs_textarea_value(scopeId, nodeAccessor, data) {
|
|
1858
|
+
return _attr_textarea_value(scopeId, nodeAccessor, data?.value, data?.valueChange, 1);
|
|
1828
1859
|
}
|
|
1829
|
-
function
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1860
|
+
function _textarea_value(value) {
|
|
1861
|
+
const escaped = _escape(normalizeStrAttrValue(value));
|
|
1862
|
+
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
1863
|
+
}
|
|
1864
|
+
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1865
|
+
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1866
|
+
return _attr("value", value);
|
|
1867
|
+
}
|
|
1868
|
+
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
1869
|
+
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
|
|
1870
|
+
return isNotVoid(checked) ? " checked" : "";
|
|
1871
|
+
}
|
|
1872
|
+
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
1873
|
+
const valueAttr = _attr("value", value);
|
|
1874
|
+
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
|
|
1875
|
+
return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
|
|
1876
|
+
}
|
|
1877
|
+
const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
|
|
1878
|
+
function getCheckedValueRef(checkedValue) {
|
|
1879
|
+
if (Array.isArray(checkedValue)) {
|
|
1880
|
+
let ref = checkedValuesRefs.get(checkedValue);
|
|
1881
|
+
if (!ref) {
|
|
1882
|
+
ref = [];
|
|
1883
|
+
checkedValuesRefs.set(checkedValue, ref);
|
|
1884
|
+
}
|
|
1885
|
+
return ref;
|
|
1836
1886
|
}
|
|
1837
|
-
return Array.isArray(other) ? [opt, ...other] : [opt, other];
|
|
1838
1887
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
return
|
|
1888
|
+
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
1889
|
+
const normalizedOpen = isNotVoid(open);
|
|
1890
|
+
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
|
|
1891
|
+
return normalizedOpen ? " open" : "";
|
|
1843
1892
|
}
|
|
1844
|
-
function
|
|
1845
|
-
return
|
|
1893
|
+
function _attr_nonce() {
|
|
1894
|
+
return getChunk().boundary.state.nonceAttr;
|
|
1846
1895
|
}
|
|
1847
|
-
function
|
|
1848
|
-
|
|
1896
|
+
function _style_html(decls) {
|
|
1897
|
+
const id = _id();
|
|
1898
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1849
1899
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1900
|
+
function _attr(name, value) {
|
|
1901
|
+
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
1902
|
+
}
|
|
1903
|
+
function _attr_and(name, value, attr) {
|
|
1904
|
+
return value ? attr : _attr(name, value);
|
|
1905
|
+
}
|
|
1906
|
+
function _attr_or(name, value, attr) {
|
|
1907
|
+
return value ? _attr(name, value) : attr;
|
|
1908
|
+
}
|
|
1909
|
+
function _attr_nullish(name, value, attr) {
|
|
1910
|
+
return value == null ? attr : _attr(name, value);
|
|
1911
|
+
}
|
|
1912
|
+
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
1913
|
+
let result = "";
|
|
1914
|
+
let skip = /[\s/>"'=]/;
|
|
1915
|
+
let events;
|
|
1916
|
+
switch (data && tagName) {
|
|
1917
|
+
case "input":
|
|
1918
|
+
assertExclusiveAttrs(data);
|
|
1919
|
+
if (data.checkedChange) {
|
|
1920
|
+
result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
|
|
1921
|
+
skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
|
|
1922
|
+
} else if ("checkedValue" in data || data.checkedValueChange) {
|
|
1923
|
+
result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
|
|
1924
|
+
skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
|
|
1925
|
+
} else if (data.valueChange) {
|
|
1926
|
+
assertNoValueBindingOnCheckable(data.type, data.valueChange);
|
|
1927
|
+
result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
|
|
1928
|
+
skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
1929
|
+
}
|
|
1930
|
+
break;
|
|
1931
|
+
case "select":
|
|
1932
|
+
case "textarea":
|
|
1933
|
+
if ("value" in data || data.valueChange) skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
1934
|
+
break;
|
|
1935
|
+
case "option":
|
|
1936
|
+
if ("value" in data) {
|
|
1937
|
+
result += _attr_option_value(data.value);
|
|
1938
|
+
skip = /^value$|[\s/>"'=]/;
|
|
1939
|
+
}
|
|
1940
|
+
break;
|
|
1941
|
+
case "details":
|
|
1942
|
+
case "dialog": if (data.openChange) {
|
|
1943
|
+
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
|
|
1944
|
+
skip = /^open(?:Change)?$|[\s/>"'=]/;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
for (const name in data) {
|
|
1948
|
+
const value = data[name];
|
|
1949
|
+
switch (name) {
|
|
1950
|
+
case "class":
|
|
1951
|
+
result += _attr_class(value);
|
|
1952
|
+
break;
|
|
1953
|
+
case "style":
|
|
1954
|
+
result += _attr_style(value);
|
|
1955
|
+
break;
|
|
1956
|
+
default:
|
|
1957
|
+
if (name) assertValidAttrName(name);
|
|
1958
|
+
if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) {
|
|
1959
|
+
if (isEventHandler(name)) {
|
|
1960
|
+
if (!events) {
|
|
1961
|
+
events = {};
|
|
1962
|
+
writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
|
|
1963
|
+
}
|
|
1964
|
+
events[getEventHandlerName(name)] = value;
|
|
1965
|
+
} else result += nonVoidAttr(name, value);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
return result;
|
|
1970
|
+
}
|
|
1971
|
+
function _attrs_content(data, nodeAccessor, scopeId, tagName, markerGuard) {
|
|
1972
|
+
_html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`);
|
|
1973
|
+
_attr_content(nodeAccessor, scopeId, data?.content, markerGuard);
|
|
1974
|
+
}
|
|
1975
|
+
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
1976
|
+
const partial = {};
|
|
1977
|
+
for (const name in data) {
|
|
1978
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1979
|
+
if (!skip[key]) partial[key] = data[name];
|
|
1980
|
+
}
|
|
1981
|
+
assertExclusiveAttrs({
|
|
1982
|
+
...data,
|
|
1983
|
+
...skip
|
|
1984
|
+
});
|
|
1985
|
+
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
1986
|
+
}
|
|
1987
|
+
function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, markerGuard) {
|
|
1988
|
+
_html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`);
|
|
1989
|
+
_attr_content(nodeAccessor, scopeId, data?.content, markerGuard);
|
|
1990
|
+
}
|
|
1991
|
+
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1992
|
+
var handlerName = [
|
|
1993
|
+
"checkedChange",
|
|
1994
|
+
"checkedValueChange",
|
|
1995
|
+
"valueChange",
|
|
1996
|
+
"valueChange",
|
|
1997
|
+
"openChange"
|
|
1998
|
+
][type];
|
|
1999
|
+
assertHandlerIsFunction(handlerName, valueChange);
|
|
2000
|
+
setDebugSlotName(writeScope(scopeId, serializeType ? {
|
|
2001
|
+
[ControlledType + nodeAccessor]: type,
|
|
2002
|
+
[ControlledValue + nodeAccessor]: value,
|
|
2003
|
+
[ControlledHandler + nodeAccessor]: valueChange
|
|
2004
|
+
} : {
|
|
2005
|
+
[ControlledValue + nodeAccessor]: value,
|
|
2006
|
+
[ControlledHandler + nodeAccessor]: valueChange
|
|
2007
|
+
}), ControlledHandler + nodeAccessor, handlerName);
|
|
2008
|
+
}
|
|
2009
|
+
function stringAttr(name, value) {
|
|
2010
|
+
return value && " " + name + attrAssignment(value);
|
|
2011
|
+
}
|
|
2012
|
+
function nonVoidAttr(name, value) {
|
|
2013
|
+
assertValidAttrValue(name, value);
|
|
2014
|
+
switch (typeof value) {
|
|
2015
|
+
case "string": return " " + name + attrAssignment(value);
|
|
2016
|
+
case "boolean": return " " + name;
|
|
2017
|
+
case "number": return " " + name + "=" + value;
|
|
2018
|
+
}
|
|
2019
|
+
return " " + name + attrAssignment(value + "");
|
|
2020
|
+
}
|
|
2021
|
+
const singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g;
|
|
2022
|
+
const doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g;
|
|
2023
|
+
const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
|
|
2024
|
+
function attrAssignment(value) {
|
|
2025
|
+
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
2026
|
+
}
|
|
2027
|
+
function escapeSingleQuotedAttrValue(value) {
|
|
2028
|
+
return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
|
|
2029
|
+
}
|
|
2030
|
+
function replaceUnsafeSingleQuoteAttrChar(match) {
|
|
2031
|
+
return match === "'" ? "'" : match === "\r" ? " " : "&";
|
|
2032
|
+
}
|
|
2033
|
+
function escapeDoubleQuotedAttrValue(value) {
|
|
2034
|
+
return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
|
|
2035
|
+
}
|
|
2036
|
+
function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
2037
|
+
return match === "\"" ? """ : match === "\r" ? " " : "&";
|
|
2038
|
+
}
|
|
2039
|
+
function normalizedValueMatches(a, b) {
|
|
2040
|
+
const value = normalizeStrAttrValue(b);
|
|
2041
|
+
if (Array.isArray(a)) {
|
|
2042
|
+
for (const item of a) if (normalizeStrAttrValue(item) === value) return true;
|
|
2043
|
+
} else if (normalizeStrAttrValue(a) === value) return true;
|
|
2044
|
+
return false;
|
|
2045
|
+
}
|
|
2046
|
+
function normalizeStrAttrValue(value) {
|
|
2047
|
+
return isNotVoid(value) && value !== true ? value + "" : "";
|
|
2048
|
+
}
|
|
2049
|
+
//#endregion
|
|
2050
|
+
//#region src/html/for.ts
|
|
2051
|
+
function forOfBy(by, item, index) {
|
|
2052
|
+
return by ? typeof by === "string" ? item[by] : by(item, index) : index;
|
|
2053
|
+
}
|
|
2054
|
+
function forInBy(by, name, value) {
|
|
2055
|
+
return by ? by(name, value) : name;
|
|
2056
|
+
}
|
|
2057
|
+
function forStepBy(by, index) {
|
|
2058
|
+
return by ? by(index) : index;
|
|
2059
|
+
}
|
|
2060
|
+
//#endregion
|
|
2061
|
+
//#region src/html/inlined-runtimes.debug.ts
|
|
2062
|
+
const WALKER_RUNTIME_CODE = `((runtimeId) => (self[runtimeId] ||= (
|
|
2063
|
+
renderId,
|
|
2064
|
+
prefix = runtimeId + renderId,
|
|
2065
|
+
prefixLen = prefix.length,
|
|
2066
|
+
lookup = {},
|
|
2067
|
+
visits = [],
|
|
2068
|
+
doc = document,
|
|
2069
|
+
walker = doc.createTreeWalker(
|
|
2070
|
+
doc,
|
|
2071
|
+
129 /* NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT */,
|
|
2072
|
+
),
|
|
2073
|
+
) =>
|
|
2074
|
+
doc = (self[runtimeId][renderId] = {
|
|
2075
|
+
i: prefix,
|
|
2076
|
+
d: doc,
|
|
2077
|
+
l: lookup,
|
|
2078
|
+
v: visits,
|
|
2079
|
+
x() {},
|
|
2080
|
+
w(node, op, id) {
|
|
2081
|
+
while ((node = walker.nextNode())) {
|
|
2082
|
+
// Only reorder markers ("#", "!") are ever looked up, so only they are
|
|
2083
|
+
// kept: the lookup lives as long as the page, and every node marker
|
|
2084
|
+
// would otherwise stay referenced in it after resume consumed it.
|
|
2085
|
+
doc.x(
|
|
2086
|
+
(op =
|
|
2087
|
+
(op = node.data) &&
|
|
2088
|
+
!op.indexOf(prefix) &&
|
|
2089
|
+
((id = op.slice(prefixLen + 1)),
|
|
2090
|
+
(op = op[prefixLen]) > "#" || (lookup[id] = node),
|
|
2091
|
+
op)),
|
|
2092
|
+
id,
|
|
2093
|
+
node,
|
|
2094
|
+
);
|
|
2095
|
+
|
|
2096
|
+
if (op > "#") {
|
|
2097
|
+
visits.push(node);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
},
|
|
2101
|
+
})
|
|
2102
|
+
, self[runtimeId]))`;
|
|
2103
|
+
const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
2104
|
+
if (runtime.j) return;
|
|
2105
|
+
let onNextSibling,
|
|
2106
|
+
placeholder,
|
|
2107
|
+
nextSibling,
|
|
2108
|
+
placeholders = runtime.p = {},
|
|
2109
|
+
replace = (id, container) => runtime.l[id].replaceWith(...container.childNodes);
|
|
2110
|
+
runtime.j = {};
|
|
2111
|
+
runtime.x = (op, id, node, placeholderRoot, placeholderCb) => {
|
|
2112
|
+
if (node == nextSibling) {
|
|
2113
|
+
onNextSibling();
|
|
1904
2114
|
}
|
|
1905
2115
|
|
|
1906
2116
|
if (op == "#") {
|
|
1907
2117
|
(placeholders[id] = placeholder).i++;
|
|
1908
|
-
} else if (op == "!") {
|
|
1909
|
-
if (runtime.l[id] && placeholders[id]) {
|
|
1910
|
-
nextSibling = node.nextSibling;
|
|
1911
|
-
onNextSibling = () => placeholders[id].c();
|
|
1912
|
-
}
|
|
1913
2118
|
} else if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
|
|
1914
2119
|
nextSibling = node.nextSibling;
|
|
1915
2120
|
onNextSibling = () => {
|
|
@@ -1921,7 +2126,8 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
|
1921
2126
|
placeholders[id] ||
|
|
1922
2127
|
(placeholderRoot = placeholders[id] =
|
|
1923
2128
|
{
|
|
1924
|
-
|
|
2129
|
+
// The writer streams a reorder only after its markers.
|
|
2130
|
+
i: 1,
|
|
1925
2131
|
r: id,
|
|
1926
2132
|
// Resume may still walk markers inside the dropped placeholder, so
|
|
1927
2133
|
// park it in any detached parent (a bare <t> clone is the cheapest).
|
|
@@ -2006,6 +2212,12 @@ function withContext(key, value, cb, cbValue) {
|
|
|
2006
2212
|
ctx[key] = prev;
|
|
2007
2213
|
}
|
|
2008
2214
|
}
|
|
2215
|
+
function captureContext(chunk) {
|
|
2216
|
+
if (chunk.context?.[kPendingContexts]) chunk.context = {
|
|
2217
|
+
...chunk.context,
|
|
2218
|
+
[kPendingContexts]: 0
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2009
2221
|
const kBranchId = Symbol("Branch Id");
|
|
2010
2222
|
const kIsAsync = Symbol("Is Async");
|
|
2011
2223
|
function isInResumedBranch() {
|
|
@@ -2014,8 +2226,8 @@ function isInResumedBranch() {
|
|
|
2014
2226
|
function withBranchId(branchId, cb, cbValue) {
|
|
2015
2227
|
return withContext(kBranchId, branchId, cb, cbValue);
|
|
2016
2228
|
}
|
|
2017
|
-
function withIsAsync(cb, value) {
|
|
2018
|
-
return withContext(kIsAsync,
|
|
2229
|
+
function withIsAsync(async, cb, value) {
|
|
2230
|
+
return withContext(kIsAsync, async, cb, value);
|
|
2019
2231
|
}
|
|
2020
2232
|
function _html(html) {
|
|
2021
2233
|
$chunk.writeHTML(html);
|
|
@@ -2023,8 +2235,8 @@ function _html(html) {
|
|
|
2023
2235
|
function writeScript(script) {
|
|
2024
2236
|
$chunk.writeScript(script);
|
|
2025
2237
|
}
|
|
2026
|
-
function _script(scopeId, registryId,
|
|
2027
|
-
if (
|
|
2238
|
+
function _script(scopeId, registryId, markerGuard) {
|
|
2239
|
+
if (markerGuard === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync])) _resume_branch(scopeId);
|
|
2028
2240
|
$chunk.boundary.state.needsMainRuntime = true;
|
|
2029
2241
|
$chunk.writeEffect(scopeId, registryId);
|
|
2030
2242
|
}
|
|
@@ -2072,12 +2284,14 @@ function _resume_branch(scopeId) {
|
|
|
2072
2284
|
const branchId = $chunk.context?.[kBranchId];
|
|
2073
2285
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId]: branchId });
|
|
2074
2286
|
}
|
|
2075
|
-
function _attr_content(nodeAccessor, scopeId, content,
|
|
2076
|
-
const shouldResume =
|
|
2287
|
+
function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
|
|
2288
|
+
const shouldResume = markerGuard !== 0;
|
|
2077
2289
|
const render = normalizeServerRender(content);
|
|
2078
2290
|
const branchId = _peek_scope_id();
|
|
2079
|
-
if (render)
|
|
2080
|
-
|
|
2291
|
+
if (render) {
|
|
2292
|
+
if (shouldResume) withBranchId(branchId, render);
|
|
2293
|
+
else render();
|
|
2294
|
+
}
|
|
2081
2295
|
if (_peek_scope_id() !== branchId) {
|
|
2082
2296
|
if (shouldResume) writeScope(scopeId, {
|
|
2083
2297
|
[BranchScopes + nodeAccessor]: writeScope(branchId, {}),
|
|
@@ -2087,8 +2301,10 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
|
2087
2301
|
}
|
|
2088
2302
|
function normalizeServerRender(value) {
|
|
2089
2303
|
const renderer = normalizeDynamicRenderer(value);
|
|
2090
|
-
if (renderer)
|
|
2091
|
-
|
|
2304
|
+
if (renderer) {
|
|
2305
|
+
if (typeof renderer === "function") return renderer;
|
|
2306
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
2307
|
+
}
|
|
2092
2308
|
}
|
|
2093
2309
|
function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
|
|
2094
2310
|
writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
|
|
@@ -2103,47 +2319,47 @@ function writeScopePassive(scopeId, partialScope) {
|
|
|
2103
2319
|
passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
|
|
2104
2320
|
return scope;
|
|
2105
2321
|
}
|
|
2106
|
-
function _show_start(display,
|
|
2322
|
+
function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
|
|
2107
2323
|
if (display) {
|
|
2108
|
-
if (
|
|
2324
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
2109
2325
|
} else $chunk.writeHTML("<t hidden>");
|
|
2110
2326
|
}
|
|
2111
|
-
function _show_end(scopeId, accessor, display,
|
|
2327
|
+
function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2112
2328
|
const branchId = _scope_id();
|
|
2113
2329
|
const wrap = !display;
|
|
2114
2330
|
if (wrap) $chunk.writeHTML("</t>");
|
|
2115
|
-
writeBranchEnd(scopeId, accessor,
|
|
2331
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
2116
2332
|
}
|
|
2117
|
-
function _for_of(list, cb, by, scopeId, accessor,
|
|
2333
|
+
function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2118
2334
|
forBranches(by, (each) => each ? forOf(list, (item, index) => {
|
|
2119
2335
|
const itemKey = forOfBy(by, item, index);
|
|
2120
2336
|
each(itemKey, itemKey === index, () => cb(item, index));
|
|
2121
|
-
}) : forOf(list, cb), scopeId, accessor,
|
|
2337
|
+
}) : forOf(list, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2122
2338
|
}
|
|
2123
|
-
function _for_in(obj, cb, by, scopeId, accessor,
|
|
2339
|
+
function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2124
2340
|
forBranches(by, (each) => each ? forIn(obj, (key, value) => {
|
|
2125
2341
|
each(forInBy(by, key, value), false, () => cb(key, value));
|
|
2126
|
-
}) : forIn(obj, cb), scopeId, accessor,
|
|
2342
|
+
}) : forIn(obj, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2127
2343
|
}
|
|
2128
|
-
function _for_to(to, from, step, cb, by, scopeId, accessor,
|
|
2344
|
+
function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2129
2345
|
forBranches(by, (each) => {
|
|
2130
2346
|
let index = 0;
|
|
2131
2347
|
return each ? forTo(to, from, step, (value) => {
|
|
2132
2348
|
const itemKey = forStepBy(by, value);
|
|
2133
2349
|
each(itemKey, itemKey === index++, () => cb(value));
|
|
2134
2350
|
}) : forTo(to, from, step, cb);
|
|
2135
|
-
}, scopeId, accessor,
|
|
2351
|
+
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2136
2352
|
}
|
|
2137
|
-
function _for_until(to, from, step, cb, by, scopeId, accessor,
|
|
2353
|
+
function _for_until(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2138
2354
|
forBranches(by, (each) => {
|
|
2139
2355
|
let index = 0;
|
|
2140
2356
|
return each ? forUntil(to, from, step, (value) => {
|
|
2141
2357
|
const itemKey = forStepBy(by, value);
|
|
2142
2358
|
each(itemKey, itemKey === index++, () => cb(value));
|
|
2143
2359
|
}) : forUntil(to, from, step, cb);
|
|
2144
|
-
}, scopeId, accessor,
|
|
2360
|
+
}, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
|
|
2145
2361
|
}
|
|
2146
|
-
function forBranches(by, iterate, scopeId, accessor,
|
|
2362
|
+
function forBranches(by, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2147
2363
|
if (by) {
|
|
2148
2364
|
const run = iterate;
|
|
2149
2365
|
const seenKeys = /* @__PURE__ */ new Set();
|
|
@@ -2153,22 +2369,24 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
2153
2369
|
else render();
|
|
2154
2370
|
});
|
|
2155
2371
|
}
|
|
2156
|
-
if (
|
|
2372
|
+
if (branchGuard === 0) {
|
|
2157
2373
|
iterate(0);
|
|
2158
|
-
writeBranchEnd(scopeId, accessor,
|
|
2374
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
|
|
2159
2375
|
return;
|
|
2160
2376
|
}
|
|
2161
2377
|
const { state } = $chunk.boundary;
|
|
2162
|
-
const resumeKeys =
|
|
2163
|
-
const resumeMarker =
|
|
2378
|
+
const resumeKeys = markerGuard !== 0;
|
|
2379
|
+
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
2164
2380
|
let flushBranchIds = "";
|
|
2165
2381
|
let loopScopes;
|
|
2166
2382
|
iterate((itemKey, sameAsIndex, render) => {
|
|
2167
2383
|
const branchId = _peek_scope_id();
|
|
2168
|
-
if (resumeMarker)
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2384
|
+
if (resumeMarker) {
|
|
2385
|
+
if (singleNode) flushBranchIds = " " + branchId + flushBranchIds;
|
|
2386
|
+
else {
|
|
2387
|
+
$chunk.writeHTML(state.mark("[", flushBranchIds));
|
|
2388
|
+
flushBranchIds = branchId + "";
|
|
2389
|
+
}
|
|
2172
2390
|
}
|
|
2173
2391
|
withBranchId(branchId, () => {
|
|
2174
2392
|
render();
|
|
@@ -2177,11 +2395,11 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
2177
2395
|
});
|
|
2178
2396
|
});
|
|
2179
2397
|
if (loopScopes) writeScope(scopeId, { [BranchScopes + accessor]: loopScopes });
|
|
2180
|
-
writeBranchEnd(scopeId, accessor,
|
|
2398
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
2181
2399
|
}
|
|
2182
|
-
function _if(cb, scopeId, accessor,
|
|
2183
|
-
const resumeBranch =
|
|
2184
|
-
const resumeMarker =
|
|
2400
|
+
function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
|
|
2401
|
+
const resumeBranch = branchGuard !== 0;
|
|
2402
|
+
const resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag);
|
|
2185
2403
|
const branchId = _peek_scope_id();
|
|
2186
2404
|
const chunk = $chunk;
|
|
2187
2405
|
const beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0;
|
|
@@ -2192,7 +2410,7 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeS
|
|
|
2192
2410
|
[ConditionalRenderer + accessor]: branchIndex || void 0,
|
|
2193
2411
|
[BranchScopes + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
2194
2412
|
});
|
|
2195
|
-
writeBranchEnd(scopeId, accessor,
|
|
2413
|
+
writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
2196
2414
|
}
|
|
2197
2415
|
function deferBranchStart(chunk) {
|
|
2198
2416
|
const beforeBranch = chunk.html;
|
|
@@ -2202,13 +2420,16 @@ function deferBranchStart(chunk) {
|
|
|
2202
2420
|
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
2203
2421
|
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
2204
2422
|
}
|
|
2205
|
-
function
|
|
2423
|
+
function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
|
|
2424
|
+
return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
|
|
2425
|
+
}
|
|
2426
|
+
function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
|
|
2206
2427
|
const endTag = parentEndTag || "";
|
|
2207
|
-
if (
|
|
2428
|
+
if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
|
|
2208
2429
|
const { state } = $chunk.boundary;
|
|
2209
2430
|
const mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
|
|
2210
2431
|
$chunk.writeHTML(mark + endTag);
|
|
2211
|
-
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
2432
|
+
} else if (markerGuard !== 0) $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
2212
2433
|
else $chunk.writeHTML(endTag);
|
|
2213
2434
|
}
|
|
2214
2435
|
let writeScope = (scopeId, partialScope) => {
|
|
@@ -2217,7 +2438,7 @@ let writeScope = (scopeId, partialScope) => {
|
|
|
2217
2438
|
const scope = scopeWithId(state, scopeId);
|
|
2218
2439
|
const pending = target.writeScopes[scopeId];
|
|
2219
2440
|
state.needsMainRuntime = true;
|
|
2220
|
-
countResumeWrite($chunk
|
|
2441
|
+
countResumeWrite($chunk);
|
|
2221
2442
|
Object.assign(scope, partialScope);
|
|
2222
2443
|
if (pending && pending !== partialScope) Object.assign(pending, partialScope);
|
|
2223
2444
|
else target.writeScopes[scopeId] = partialScope;
|
|
@@ -2241,11 +2462,11 @@ function scopeWithId(state, scopeId) {
|
|
|
2241
2462
|
if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
|
|
2242
2463
|
return scope;
|
|
2243
2464
|
}
|
|
2244
|
-
function _subscribe(subscribers, scope, resumeId,
|
|
2465
|
+
function _subscribe(subscribers, scope, resumeId, markerGuard) {
|
|
2245
2466
|
if (subscribers) {
|
|
2246
2467
|
const { serializer } = $chunk.boundary.state;
|
|
2247
2468
|
if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
|
|
2248
|
-
else if (resumeId) _script(scope[K_SCOPE_ID], resumeId,
|
|
2469
|
+
else if (resumeId) _script(scope[K_SCOPE_ID], resumeId, markerGuard);
|
|
2249
2470
|
else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
|
|
2250
2471
|
}
|
|
2251
2472
|
return scope;
|
|
@@ -2254,19 +2475,19 @@ const CLIENT_ALL = 715827883;
|
|
|
2254
2475
|
function maskGroup(mask, group) {
|
|
2255
2476
|
return mask === 715827883 ? 1 : typeof mask === "number" ? group < 15 ? mask >>> 1 + 2 * group & 3 : 0 : mask[group] ?? 0;
|
|
2256
2477
|
}
|
|
2257
|
-
function
|
|
2258
|
-
$chunk.boundary.state.
|
|
2478
|
+
function _set_scope_reason(reason) {
|
|
2479
|
+
$chunk.boundary.state.scopeReason = reason;
|
|
2259
2480
|
}
|
|
2260
2481
|
function _scope_reason() {
|
|
2261
|
-
const reason = $chunk.boundary.state.
|
|
2262
|
-
$chunk.boundary.state.
|
|
2482
|
+
const reason = $chunk.boundary.state.scopeReason;
|
|
2483
|
+
$chunk.boundary.state.scopeReason = void 0;
|
|
2263
2484
|
return reason;
|
|
2264
2485
|
}
|
|
2265
|
-
function
|
|
2486
|
+
function _write_if(condition, key) {
|
|
2266
2487
|
return condition && maskGroup(condition, key) ? 1 : void 0;
|
|
2267
2488
|
}
|
|
2268
|
-
function
|
|
2269
|
-
return
|
|
2489
|
+
function _write_guard(condition, key) {
|
|
2490
|
+
return _write_if(condition, key) || 0;
|
|
2270
2491
|
}
|
|
2271
2492
|
function writeWaitReady(readyId, renderer, input) {
|
|
2272
2493
|
const chunk = $chunk;
|
|
@@ -2279,6 +2500,7 @@ function writeWaitReady(readyId, renderer, input) {
|
|
|
2279
2500
|
flushScopes: false
|
|
2280
2501
|
});
|
|
2281
2502
|
const bodyEnd = body.render(renderer, input);
|
|
2503
|
+
if (boundary.aborted) throw boundary.reason;
|
|
2282
2504
|
if (body === bodyEnd) {
|
|
2283
2505
|
chunk.writeHTML(body.html);
|
|
2284
2506
|
body.deferOwnReady();
|
|
@@ -2288,8 +2510,8 @@ function writeWaitReady(readyId, renderer, input) {
|
|
|
2288
2510
|
chunk.next = body;
|
|
2289
2511
|
}
|
|
2290
2512
|
}
|
|
2291
|
-
function _await(scopeId, accessor, promise, content,
|
|
2292
|
-
const resumeMarker =
|
|
2513
|
+
function _await(scopeId, accessor, promise, content, markerGuard) {
|
|
2514
|
+
const resumeMarker = markerGuard !== 0;
|
|
2293
2515
|
if (!isPromise(promise)) {
|
|
2294
2516
|
if (resumeMarker) {
|
|
2295
2517
|
const branchId = _peek_scope_id();
|
|
@@ -2301,25 +2523,32 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
2301
2523
|
}
|
|
2302
2524
|
const chunk = $chunk;
|
|
2303
2525
|
const { boundary } = chunk;
|
|
2304
|
-
|
|
2526
|
+
const startId = _peek_scope_id();
|
|
2527
|
+
const after = chunk.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2305
2528
|
chunk.async = true;
|
|
2306
|
-
|
|
2307
|
-
...chunk.context,
|
|
2308
|
-
[kPendingContexts]: 0
|
|
2309
|
-
};
|
|
2529
|
+
captureContext(chunk);
|
|
2310
2530
|
boundary.startAsync();
|
|
2311
2531
|
promise.then((value) => {
|
|
2312
2532
|
if (chunk.async) {
|
|
2313
2533
|
chunk.async = false;
|
|
2314
|
-
if (!boundary.
|
|
2534
|
+
if (!boundary.aborted) {
|
|
2535
|
+
const { state } = boundary;
|
|
2315
2536
|
chunk.render(() => {
|
|
2316
2537
|
if (resumeMarker) {
|
|
2317
2538
|
const branchId = _peek_scope_id();
|
|
2318
2539
|
$chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
2319
|
-
withBranchId(branchId, () => withIsAsync(content, value));
|
|
2540
|
+
withBranchId(branchId, () => withIsAsync({ parent: getAsyncContent(chunk) }, content, value));
|
|
2320
2541
|
$chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2321
|
-
} else
|
|
2542
|
+
} else {
|
|
2543
|
+
const renderedSince = _peek_scope_id() !== startId;
|
|
2544
|
+
const async = { parent: getAsyncContent(chunk) };
|
|
2545
|
+
withIsAsync(async, content, value);
|
|
2546
|
+
async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "";
|
|
2547
|
+
if (async.resumed) $chunk.writeHTML(async.visit);
|
|
2548
|
+
async.end = $chunk;
|
|
2549
|
+
}
|
|
2322
2550
|
});
|
|
2551
|
+
if (!chunk.async && boundary.pendingReorders?.delete(chunk)) state.reorder(chunk);
|
|
2323
2552
|
boundary.endAsync();
|
|
2324
2553
|
}
|
|
2325
2554
|
}
|
|
@@ -2328,9 +2557,7 @@ function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
|
2328
2557
|
boundary.abort(err);
|
|
2329
2558
|
});
|
|
2330
2559
|
}
|
|
2331
|
-
function _try(scopeId, accessor, content,
|
|
2332
|
-
const catchContent = input.catch ? normalizeDynamicRenderer(input.catch) || 0 : void 0;
|
|
2333
|
-
const placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
|
2560
|
+
function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
|
|
2334
2561
|
const placeholderBranchId = placeholderContent ? _scope_id() : 0;
|
|
2335
2562
|
const branchId = _peek_scope_id();
|
|
2336
2563
|
const chunk = $chunk;
|
|
@@ -2338,13 +2565,12 @@ function _try(scopeId, accessor, content, input) {
|
|
|
2338
2565
|
const { state } = boundary;
|
|
2339
2566
|
const { resumeWrites } = boundary;
|
|
2340
2567
|
const beforeBranch = deferBranchStart(chunk);
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
else withBranchId(branchId, content);
|
|
2568
|
+
const renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId));
|
|
2569
|
+
const renderersWritten = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers);
|
|
2344
2570
|
const rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
|
|
2345
2571
|
applyBranchStart(chunk, beforeBranch, rendered);
|
|
2346
2572
|
if (!rendered) return;
|
|
2347
|
-
if (!
|
|
2573
|
+
if (!renderersWritten) renderers();
|
|
2348
2574
|
$chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId));
|
|
2349
2575
|
}
|
|
2350
2576
|
function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
|
|
@@ -2356,6 +2582,7 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
|
|
|
2356
2582
|
return;
|
|
2357
2583
|
}
|
|
2358
2584
|
chunk.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2585
|
+
captureContext(chunk);
|
|
2359
2586
|
chunk.placeholder = {
|
|
2360
2587
|
body,
|
|
2361
2588
|
render: placeholder,
|
|
@@ -2364,17 +2591,17 @@ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBran
|
|
|
2364
2591
|
placeholderBranchId
|
|
2365
2592
|
};
|
|
2366
2593
|
}
|
|
2367
|
-
function tryBoundary(content, catchContent,
|
|
2594
|
+
function tryBoundary(content, catchContent, branchId, renderers) {
|
|
2368
2595
|
const chunk = $chunk;
|
|
2369
2596
|
const { boundary } = chunk;
|
|
2370
2597
|
const { state } = boundary;
|
|
2371
|
-
const catchBoundary = new Boundary(state,
|
|
2598
|
+
const catchBoundary = new Boundary(state, void 0, boundary);
|
|
2372
2599
|
const body = chunk.fork(catchBoundary, null);
|
|
2373
|
-
const bodyEnd =
|
|
2374
|
-
if (catchBoundary.
|
|
2375
|
-
if (catchContent
|
|
2376
|
-
|
|
2377
|
-
return
|
|
2600
|
+
const bodyEnd = body.render(() => withBranchId(branchId, content));
|
|
2601
|
+
if (catchBoundary.aborted) {
|
|
2602
|
+
if (!catchContent) throw catchBoundary.reason;
|
|
2603
|
+
catchContent(catchBoundary.reason);
|
|
2604
|
+
return true;
|
|
2378
2605
|
}
|
|
2379
2606
|
if (body === bodyEnd) {
|
|
2380
2607
|
chunk.append(body);
|
|
@@ -2384,45 +2611,49 @@ function tryBoundary(content, catchContent, placeholderContent, branchId) {
|
|
|
2384
2611
|
const bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
2385
2612
|
chunk.next = body;
|
|
2386
2613
|
boundary.startAsync();
|
|
2387
|
-
const reorderId = catchContent
|
|
2388
|
-
const endMarker = reorderId && state.mark("!", reorderId);
|
|
2614
|
+
const reorderId = catchContent ? state.nextReorderId() : "";
|
|
2389
2615
|
if (reorderId) {
|
|
2390
|
-
chunk.
|
|
2391
|
-
|
|
2616
|
+
chunk.catchRange = {
|
|
2617
|
+
id: reorderId,
|
|
2618
|
+
end: bodyEnd
|
|
2619
|
+
};
|
|
2620
|
+
captureContext(chunk);
|
|
2392
2621
|
}
|
|
2393
2622
|
catchBoundary.onNext = () => {
|
|
2394
|
-
if (boundary.
|
|
2395
|
-
if (catchBoundary.
|
|
2623
|
+
if (boundary.aborted) return;
|
|
2624
|
+
if (catchBoundary.aborted) {
|
|
2396
2625
|
if (!reorderId) {
|
|
2397
|
-
boundary.abort(catchBoundary.
|
|
2626
|
+
boundary.abort(catchBoundary.reason);
|
|
2398
2627
|
return;
|
|
2399
2628
|
}
|
|
2400
|
-
|
|
2401
|
-
let cur = body;
|
|
2402
|
-
let writeMarker = true;
|
|
2403
|
-
do {
|
|
2404
|
-
const next = cur.next;
|
|
2405
|
-
if (cur.boundary !== catchBoundary) cur.boundary.abort(catchBoundary.signal.reason);
|
|
2406
|
-
if (writeMarker && !cur.consumed) {
|
|
2407
|
-
writeMarker = false;
|
|
2408
|
-
cur.async = false;
|
|
2409
|
-
cur.next = bodyNext;
|
|
2410
|
-
cur.needsWalk = true;
|
|
2411
|
-
cur.html = endMarker;
|
|
2412
|
-
cur.scripts = cur.effects = cur.lastEffect = "";
|
|
2413
|
-
cur.placeholder = cur.reorderId = cur.deferredReady = null;
|
|
2414
|
-
}
|
|
2415
|
-
cur = next;
|
|
2416
|
-
} while (cur !== bodyNext);
|
|
2417
|
-
}
|
|
2629
|
+
const streamed = !chunk.catchRange;
|
|
2418
2630
|
const catchChunk = chunk.fork(boundary, null);
|
|
2419
|
-
|
|
2420
|
-
catchChunk.
|
|
2421
|
-
if (
|
|
2422
|
-
|
|
2631
|
+
chunk.catchRange = null;
|
|
2632
|
+
const inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
|
|
2633
|
+
if (boundary.aborted) return;
|
|
2634
|
+
if (bodyEnd.consumed) {
|
|
2635
|
+
catchChunk.reorderId = reorderId;
|
|
2636
|
+
state.reorder(catchChunk);
|
|
2637
|
+
} else {
|
|
2638
|
+
let reorder = null;
|
|
2639
|
+
if (!inOrder) reorder = catchChunk;
|
|
2640
|
+
else if (streamed) reorder = chunk.fork(boundary, null);
|
|
2641
|
+
if (reorder) reorder.reorderId = reorderId;
|
|
2642
|
+
const endMarker = state.mark("!", reorderId);
|
|
2643
|
+
let cut = body;
|
|
2644
|
+
while (cut.consumed) cut = cut.next;
|
|
2645
|
+
cut.async = false;
|
|
2646
|
+
cut.next = inOrder ? catchChunk : bodyNext;
|
|
2647
|
+
cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker;
|
|
2648
|
+
cut.scripts = cut.effects = cut.lastEffect = "";
|
|
2649
|
+
cut.placeholder = cut.reorderId = cut.catchRange = null;
|
|
2650
|
+
cut.deferredReorder = reorder;
|
|
2651
|
+
if (inOrder) catchChunk.next = bodyNext;
|
|
2652
|
+
}
|
|
2423
2653
|
boundary.endAsync();
|
|
2424
2654
|
} else if (!catchBoundary.count) {
|
|
2425
|
-
if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(
|
|
2655
|
+
if (renderersAtSettle && catchBoundary.resumeWrites) bodyEnd.render(renderers);
|
|
2656
|
+
chunk.catchRange = null;
|
|
2426
2657
|
boundary.endAsync();
|
|
2427
2658
|
} else boundary.onNext();
|
|
2428
2659
|
};
|
|
@@ -2435,8 +2666,15 @@ function writeTryRenderers(branchId, catchContent, placeholderContent) {
|
|
|
2435
2666
|
});
|
|
2436
2667
|
}
|
|
2437
2668
|
const NOOP$2 = () => {};
|
|
2438
|
-
function countResumeWrite(
|
|
2439
|
-
for (; boundary; boundary = boundary.parent) boundary.resumeWrites++;
|
|
2669
|
+
function countResumeWrite(chunk) {
|
|
2670
|
+
for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
|
|
2671
|
+
for (let async = getAsyncContent(chunk); async && !async.resumed; async = async.parent) {
|
|
2672
|
+
async.resumed = true;
|
|
2673
|
+
async.end?.writeHTML(async.visit);
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
function getAsyncContent(chunk) {
|
|
2677
|
+
return chunk.context?.[kIsAsync];
|
|
2440
2678
|
}
|
|
2441
2679
|
var State = class {
|
|
2442
2680
|
tagId = 1;
|
|
@@ -2460,7 +2698,7 @@ var State = class {
|
|
|
2460
2698
|
flushScopes = false;
|
|
2461
2699
|
writeScopes = {};
|
|
2462
2700
|
readyIds = null;
|
|
2463
|
-
|
|
2701
|
+
scopeReason;
|
|
2464
2702
|
$global;
|
|
2465
2703
|
constructor($global) {
|
|
2466
2704
|
this.$global = $global;
|
|
@@ -2521,35 +2759,54 @@ var State = class {
|
|
|
2521
2759
|
return "<!--" + this.commentPrefix + code + str + "-->";
|
|
2522
2760
|
}
|
|
2523
2761
|
};
|
|
2524
|
-
var Boundary = class
|
|
2762
|
+
var Boundary = class {
|
|
2525
2763
|
onNext = NOOP$2;
|
|
2526
2764
|
count = 0;
|
|
2527
2765
|
resumeWrites = 0;
|
|
2528
2766
|
state;
|
|
2529
2767
|
parent;
|
|
2768
|
+
aborted = false;
|
|
2769
|
+
reason;
|
|
2770
|
+
pendingReorders;
|
|
2771
|
+
children;
|
|
2530
2772
|
constructor(state, signal, parent) {
|
|
2531
|
-
super();
|
|
2532
2773
|
this.state = state;
|
|
2533
2774
|
this.parent = parent;
|
|
2534
|
-
|
|
2535
|
-
this.
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2775
|
+
if (parent) {
|
|
2776
|
+
if (parent.aborted) this.abort(parent.reason);
|
|
2777
|
+
else (parent.children ||= []).push(this);
|
|
2778
|
+
} else if (signal) {
|
|
2779
|
+
if (signal.aborted) this.abort(signal.reason);
|
|
2780
|
+
else signal.addEventListener("abort", this);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
abort(reason) {
|
|
2784
|
+
if (this.aborted) return;
|
|
2785
|
+
const { state } = this;
|
|
2786
|
+
this.aborted = true;
|
|
2787
|
+
this.reason = reason;
|
|
2788
|
+
if (this.pendingReorders) {
|
|
2789
|
+
for (const reorder of this.pendingReorders) state.reorder(reorder);
|
|
2790
|
+
this.pendingReorders = void 0;
|
|
2791
|
+
}
|
|
2792
|
+
this.count = 0;
|
|
2793
|
+
this.state = new State(state.$global);
|
|
2794
|
+
if (this.children) for (const child of this.children) child.abort(reason);
|
|
2795
|
+
this.onNext();
|
|
2796
|
+
}
|
|
2797
|
+
handleEvent(event) {
|
|
2798
|
+
this.abort(event.target.reason);
|
|
2543
2799
|
}
|
|
2544
2800
|
flush() {
|
|
2545
|
-
if (!this.
|
|
2546
|
-
return this.count ? 1 : this.
|
|
2801
|
+
if (!this.aborted) flushSerializer(this, this.state);
|
|
2802
|
+
return this.count ? 1 : this.aborted ? 2 : 0;
|
|
2547
2803
|
}
|
|
2548
2804
|
startAsync() {
|
|
2549
|
-
if (!this.
|
|
2805
|
+
if (!this.aborted) this.count++;
|
|
2550
2806
|
}
|
|
2551
2807
|
endAsync() {
|
|
2552
|
-
if (!this.
|
|
2808
|
+
if (!this.aborted) {
|
|
2809
|
+
if (!this.count) throw new Error("A boundary ended more async work than it started.");
|
|
2553
2810
|
this.count--;
|
|
2554
2811
|
this.onNext();
|
|
2555
2812
|
}
|
|
@@ -2562,9 +2819,10 @@ var Chunk = class Chunk {
|
|
|
2562
2819
|
lastEffect = "";
|
|
2563
2820
|
async = false;
|
|
2564
2821
|
consumed = false;
|
|
2565
|
-
needsWalk = false;
|
|
2566
2822
|
reorderId = null;
|
|
2567
2823
|
deferredReady = null;
|
|
2824
|
+
deferredReorder = null;
|
|
2825
|
+
catchRange = null;
|
|
2568
2826
|
placeholder = null;
|
|
2569
2827
|
boundary;
|
|
2570
2828
|
next;
|
|
@@ -2583,7 +2841,7 @@ var Chunk = class Chunk {
|
|
|
2583
2841
|
this.html += html;
|
|
2584
2842
|
}
|
|
2585
2843
|
writeEffect(scopeId, registryId) {
|
|
2586
|
-
countResumeWrite(this
|
|
2844
|
+
countResumeWrite(this);
|
|
2587
2845
|
if (this.lastEffect === registryId) this.effects += " " + scopeId;
|
|
2588
2846
|
else {
|
|
2589
2847
|
this.lastEffect = registryId;
|
|
@@ -2595,7 +2853,6 @@ var Chunk = class Chunk {
|
|
|
2595
2853
|
}
|
|
2596
2854
|
append(chunk) {
|
|
2597
2855
|
this.html += chunk.html;
|
|
2598
|
-
this.needsWalk ||= chunk.needsWalk;
|
|
2599
2856
|
this.effects = concatEffects(this.effects, chunk.effects);
|
|
2600
2857
|
this.scripts = concatScripts(this.scripts, chunk.scripts);
|
|
2601
2858
|
this.lastEffect = chunk.lastEffect || this.lastEffect;
|
|
@@ -2615,46 +2872,88 @@ var Chunk = class Chunk {
|
|
|
2615
2872
|
this.deferredReady = concat(deferred, this.deferredReady);
|
|
2616
2873
|
}
|
|
2617
2874
|
}
|
|
2618
|
-
|
|
2619
|
-
const {
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
this.writeHTML(state.mark("!^", reorderId));
|
|
2627
|
-
const { effects } = this;
|
|
2628
|
-
const beforeBranch = deferBranchStart(this);
|
|
2629
|
-
const after = this.render(() => withBranchId(placeholderBranchId, placeholder.render));
|
|
2630
|
-
const stateful = after === this && this.effects !== effects;
|
|
2631
|
-
applyBranchStart(this, beforeBranch, stateful);
|
|
2632
|
-
if (after !== this) this.boundary.abort(/* @__PURE__ */ new Error("An @placeholder cannot contain async content."));
|
|
2633
|
-
else if (stateful) {
|
|
2634
|
-
this.render(() => writeScope(branchId, { [PlaceholderBranch]: scopeWithId(state, placeholderBranchId) }));
|
|
2635
|
-
this.writeHTML(state.mark("]", scopeId + " " + (PlaceholderBranch + branchId) + " " + placeholderBranchId));
|
|
2636
|
-
body.writeEffect(branchId, PLACEHOLDER_DISMISS_REGISTER_ID);
|
|
2875
|
+
renderPlaceholders(boundary) {
|
|
2876
|
+
const { state } = boundary;
|
|
2877
|
+
restart: for (;;) {
|
|
2878
|
+
let reorders = null;
|
|
2879
|
+
for (let cur = this; cur.next && !cur.async; cur = cur.next) {
|
|
2880
|
+
if (cur.renderPlaceholder(state)) {
|
|
2881
|
+
if (boundary.aborted) return;
|
|
2882
|
+
continue restart;
|
|
2637
2883
|
}
|
|
2638
|
-
|
|
2639
|
-
state.reorder(body);
|
|
2640
|
-
} else {
|
|
2641
|
-
body.next = this.next;
|
|
2642
|
-
this.next = body;
|
|
2884
|
+
if (cur.deferredReorder) (reorders ||= []).push(cur.deferredReorder);
|
|
2643
2885
|
}
|
|
2644
|
-
|
|
2886
|
+
if (state.writeReorders) {
|
|
2887
|
+
for (const reorder of state.writeReorders) if ((reorders = renderReorderPlaceholders(reorder, reorders)) === false) {
|
|
2888
|
+
if (boundary.aborted) return;
|
|
2889
|
+
continue restart;
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
for (let i = 0; reorders && i < reorders.length; i++) if ((reorders = renderReorderPlaceholders(reorders[i], reorders)) === false) {
|
|
2893
|
+
if (boundary.aborted) return;
|
|
2894
|
+
continue restart;
|
|
2895
|
+
}
|
|
2896
|
+
return;
|
|
2645
2897
|
}
|
|
2646
2898
|
}
|
|
2647
|
-
|
|
2899
|
+
renderPlaceholder(state) {
|
|
2900
|
+
const { placeholder } = this;
|
|
2901
|
+
if (!placeholder) return false;
|
|
2902
|
+
this.placeholder = null;
|
|
2903
|
+
if (this.boundary.aborted) return false;
|
|
2904
|
+
const { body } = placeholder;
|
|
2905
|
+
let end = body;
|
|
2906
|
+
while (end.next && !end.async) end = end.next;
|
|
2907
|
+
if (!end.async) {
|
|
2908
|
+
end.next = this.next;
|
|
2909
|
+
this.next = body;
|
|
2910
|
+
return false;
|
|
2911
|
+
}
|
|
2912
|
+
const { branchId, scopeId, placeholderBranchId } = placeholder;
|
|
2913
|
+
const reorderId = body.reorderId = branchId ? branchId + "" : state.nextReorderId();
|
|
2914
|
+
this.writeHTML(state.mark("!^", reorderId));
|
|
2915
|
+
const { effects } = this;
|
|
2916
|
+
const beforeBranch = deferBranchStart(this);
|
|
2917
|
+
if (this.render(() => withBranchId(placeholderBranchId, placeholder.render)) !== this) this.boundary.abort(/* @__PURE__ */ new Error("An @placeholder cannot contain async content."));
|
|
2918
|
+
if (this.boundary.aborted) return true;
|
|
2919
|
+
const stateful = this.effects !== effects;
|
|
2920
|
+
applyBranchStart(this, beforeBranch, stateful);
|
|
2921
|
+
if (stateful) {
|
|
2922
|
+
this.render(() => writeScope(branchId, { [PlaceholderBranch]: scopeWithId(state, placeholderBranchId) }));
|
|
2923
|
+
this.writeHTML(state.mark("]", scopeId + " " + (PlaceholderBranch + branchId) + " " + placeholderBranchId));
|
|
2924
|
+
end.writeEffect(branchId, PLACEHOLDER_DISMISS_REGISTER_ID);
|
|
2925
|
+
}
|
|
2926
|
+
this.writeHTML(state.mark("!", reorderId));
|
|
2927
|
+
this.deferredReorder = body;
|
|
2928
|
+
return false;
|
|
2929
|
+
}
|
|
2930
|
+
markCatchRange() {
|
|
2931
|
+
const { catchRange } = this;
|
|
2932
|
+
if (catchRange) {
|
|
2933
|
+
const { state } = this.boundary;
|
|
2934
|
+
this.catchRange = null;
|
|
2935
|
+
this.writeHTML(state.mark("!^", catchRange.id));
|
|
2936
|
+
catchRange.end.writeHTML(state.mark("!", catchRange.id));
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
queueDeferredReorder() {
|
|
2940
|
+
const { deferredReorder } = this;
|
|
2941
|
+
if (deferredReorder) {
|
|
2942
|
+
this.deferredReorder = null;
|
|
2943
|
+
deferredReorder.boundary.state.reorder(deferredReorder);
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
consume(boundary) {
|
|
2947
|
+
this.renderPlaceholders(boundary);
|
|
2648
2948
|
let cur = this;
|
|
2649
2949
|
let html = "";
|
|
2650
2950
|
let effects = "";
|
|
2651
2951
|
let scripts = "";
|
|
2652
2952
|
let lastEffect = "";
|
|
2653
|
-
let needsWalk = false;
|
|
2654
2953
|
let deferredReady;
|
|
2655
2954
|
while (cur.next && !cur.async) {
|
|
2656
|
-
cur.
|
|
2657
|
-
|
|
2955
|
+
cur.markCatchRange();
|
|
2956
|
+
cur.queueDeferredReorder();
|
|
2658
2957
|
html += cur.html;
|
|
2659
2958
|
if (cur.serializeState.readyId) deferredReady = push(deferredReady, cur);
|
|
2660
2959
|
else {
|
|
@@ -2668,7 +2967,6 @@ var Chunk = class Chunk {
|
|
|
2668
2967
|
}
|
|
2669
2968
|
cur.deferOwnReady();
|
|
2670
2969
|
cur.deferredReady = concat(deferredReady, cur.deferredReady);
|
|
2671
|
-
cur.needsWalk ||= needsWalk;
|
|
2672
2970
|
cur.html = html + cur.html;
|
|
2673
2971
|
cur.effects = concatEffects(effects, cur.effects);
|
|
2674
2972
|
cur.scripts = concatScripts(scripts, cur.scripts);
|
|
@@ -2688,14 +2986,16 @@ var Chunk = class Chunk {
|
|
|
2688
2986
|
$chunk = prev;
|
|
2689
2987
|
}
|
|
2690
2988
|
}
|
|
2691
|
-
flushReadyScripts(reservations, holdEffects) {
|
|
2692
|
-
const {
|
|
2989
|
+
flushReadyScripts(boundary, reservations, holdEffects) {
|
|
2990
|
+
const { serializeState } = this;
|
|
2693
2991
|
const { readyId } = serializeState;
|
|
2694
2992
|
let scripts = "";
|
|
2695
|
-
|
|
2696
|
-
|
|
2993
|
+
const held = this.takeDeferredReady();
|
|
2994
|
+
if (held) for (const chunk of Array.isArray(held) ? held : [held]) {
|
|
2995
|
+
if (chunk.boundary.aborted) continue;
|
|
2996
|
+
scripts = concatScripts(scripts, chunk.flushReadyScripts(boundary, reservations, holdEffects));
|
|
2697
2997
|
if (chunk.effects || chunk.deferredReady) this.deferredReady = push(this.deferredReady, chunk);
|
|
2698
|
-
}
|
|
2998
|
+
}
|
|
2699
2999
|
if (readyId && !this.async) {
|
|
2700
3000
|
const { state } = boundary;
|
|
2701
3001
|
flushSerializer(boundary, serializeState);
|
|
@@ -2718,14 +3018,13 @@ var Chunk = class Chunk {
|
|
|
2718
3018
|
}
|
|
2719
3019
|
return scripts;
|
|
2720
3020
|
}
|
|
2721
|
-
flushScript() {
|
|
2722
|
-
const { boundary } = this;
|
|
3021
|
+
flushScript(boundary) {
|
|
2723
3022
|
const { state } = boundary;
|
|
2724
3023
|
const { $global, runtimePrefix } = state;
|
|
2725
3024
|
let needsWalk = state.walkOnNextFlush;
|
|
2726
3025
|
if (needsWalk) state.walkOnNextFlush = false;
|
|
2727
|
-
let readyResumeScripts = this.flushReadyScripts(void 0, this.async);
|
|
2728
|
-
for (let channel; channel = state.serializer.pendingReadyChannel();) {
|
|
3026
|
+
let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
|
|
3027
|
+
for (let channel; !boundary.aborted && (channel = state.serializer.pendingReadyChannel());) {
|
|
2729
3028
|
const resumes = state.serializer.stringifyScopes([], boundary, channel);
|
|
2730
3029
|
const deps = state.serializer.takeChannelDeps();
|
|
2731
3030
|
state.needsMainRuntime = true;
|
|
@@ -2746,17 +3045,7 @@ var Chunk = class Chunk {
|
|
|
2746
3045
|
let reordered = "";
|
|
2747
3046
|
let needsResumeArray = false;
|
|
2748
3047
|
if (state.writeReorders) {
|
|
2749
|
-
let carried = null;
|
|
2750
3048
|
for (const reorderedChunk of state.writeReorders) {
|
|
2751
|
-
if (reorderedChunk.async && reorderedChunk.consumed) {
|
|
2752
|
-
let aborted = reorderedChunk.boundary;
|
|
2753
|
-
while (aborted && !aborted.signal.aborted) aborted = aborted.parent;
|
|
2754
|
-
if (!aborted) {
|
|
2755
|
-
(carried ||= []).push(reorderedChunk);
|
|
2756
|
-
continue;
|
|
2757
|
-
}
|
|
2758
|
-
reorderedChunk.async = false;
|
|
2759
|
-
}
|
|
2760
3049
|
needsWalk = true;
|
|
2761
3050
|
if (!state.hasReorderRuntime) {
|
|
2762
3051
|
state.hasReorderRuntime = true;
|
|
@@ -2767,13 +3056,14 @@ var Chunk = class Chunk {
|
|
|
2767
3056
|
let reorderHTML = "";
|
|
2768
3057
|
let reorderEffects = "";
|
|
2769
3058
|
let reorderScripts = "";
|
|
2770
|
-
let cur = reorderedChunk;
|
|
3059
|
+
let cur = reorderedChunk.boundary.aborted ? null : reorderedChunk;
|
|
2771
3060
|
reorderedChunk.reorderId = null;
|
|
2772
|
-
|
|
2773
|
-
cur.
|
|
3061
|
+
while (cur) {
|
|
3062
|
+
cur.markCatchRange();
|
|
3063
|
+
cur.queueDeferredReorder();
|
|
2774
3064
|
cur.deferOwnReady();
|
|
2775
3065
|
const { next } = cur;
|
|
2776
|
-
const readyResumeScripts = cur.flushReadyScripts(readyReservations, this.async);
|
|
3066
|
+
const readyResumeScripts = cur.flushReadyScripts(boundary, readyReservations, this.async);
|
|
2777
3067
|
this.deferredReady = concat(this.deferredReady, cur.takeDeferredReady());
|
|
2778
3068
|
cur.consumed = true;
|
|
2779
3069
|
reorderHTML += cur.html;
|
|
@@ -2781,25 +3071,26 @@ var Chunk = class Chunk {
|
|
|
2781
3071
|
reorderScripts = concatScripts(reorderScripts, concatScripts(readyResumeScripts, cur.scripts));
|
|
2782
3072
|
if (cur.async) {
|
|
2783
3073
|
reorderHTML += state.mark("#", cur.reorderId = state.nextReorderId());
|
|
2784
|
-
|
|
3074
|
+
(cur.boundary.pendingReorders ||= /* @__PURE__ */ new Set()).add(cur);
|
|
2785
3075
|
cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
|
|
2786
3076
|
cur.next = null;
|
|
2787
3077
|
}
|
|
2788
|
-
|
|
2789
|
-
else break;
|
|
3078
|
+
cur = next;
|
|
2790
3079
|
}
|
|
2791
|
-
if (reorderEffects)
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
3080
|
+
if (reorderEffects) {
|
|
3081
|
+
if (this.async) {
|
|
3082
|
+
this.effects = concatEffects(this.effects, reorderEffects);
|
|
3083
|
+
this.lastEffect = "";
|
|
3084
|
+
} else {
|
|
3085
|
+
needsResumeArray = true;
|
|
3086
|
+
reorderScripts = concatScripts(reorderScripts, "_.push(\"" + reorderEffects + "\")");
|
|
3087
|
+
}
|
|
2797
3088
|
}
|
|
2798
3089
|
for (const reservation of readyReservations) reordered = concatScripts(reordered, reservation);
|
|
2799
3090
|
reordered = concatScripts(reordered, reorderScripts && runtimePrefix + ".j" + toAccess(reorderId) + "=_=>{" + reorderScripts + "}");
|
|
2800
3091
|
html += "<t hidden " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
2801
3092
|
}
|
|
2802
|
-
state.writeReorders =
|
|
3093
|
+
state.writeReorders = null;
|
|
2803
3094
|
}
|
|
2804
3095
|
flushSerializer(boundary, state);
|
|
2805
3096
|
if (state.resumes || needsResumeArray && !state.hasWrittenResume) scripts = concatScripts(scripts, state.resumeScript(state.resumes));
|
|
@@ -2811,19 +3102,21 @@ var Chunk = class Chunk {
|
|
|
2811
3102
|
state.resumes = "";
|
|
2812
3103
|
return this;
|
|
2813
3104
|
}
|
|
2814
|
-
flushHTML() {
|
|
2815
|
-
const { boundary } = this;
|
|
3105
|
+
flushHTML(boundary) {
|
|
2816
3106
|
const { state } = boundary;
|
|
2817
|
-
|
|
2818
|
-
this.needsWalk = false;
|
|
2819
|
-
state.walkOnNextFlush = true;
|
|
2820
|
-
}
|
|
2821
|
-
this.flushScript();
|
|
3107
|
+
this.flushScript(boundary);
|
|
2822
3108
|
const { html, scripts } = this;
|
|
2823
3109
|
this.html = this.scripts = "";
|
|
2824
3110
|
return state.flushChunk(html, scripts, boundary.count);
|
|
2825
3111
|
}
|
|
2826
3112
|
};
|
|
3113
|
+
function renderReorderPlaceholders(reorder, reorders) {
|
|
3114
|
+
if (!reorder.boundary.aborted) for (let cur = reorder; cur; cur = cur.next) {
|
|
3115
|
+
if (cur.renderPlaceholder(reorder.boundary.state)) return false;
|
|
3116
|
+
if (cur.deferredReorder) (reorders ||= []).push(cur.deferredReorder);
|
|
3117
|
+
}
|
|
3118
|
+
return reorders;
|
|
3119
|
+
}
|
|
2827
3120
|
function flushSerializer(boundary, serializeState) {
|
|
2828
3121
|
const { state } = boundary;
|
|
2829
3122
|
const { serializer } = state;
|
|
@@ -2894,13 +3187,17 @@ function getFilteredGlobals($global) {
|
|
|
2894
3187
|
let filtered = 0;
|
|
2895
3188
|
if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
|
|
2896
3189
|
const value = $global[key];
|
|
2897
|
-
if (value !== void 0)
|
|
2898
|
-
|
|
3190
|
+
if (value !== void 0) {
|
|
3191
|
+
if (filtered) filtered[key] = value;
|
|
3192
|
+
else filtered = { [key]: value };
|
|
3193
|
+
}
|
|
2899
3194
|
}
|
|
2900
3195
|
else for (const key in serializedGlobals) if (serializedGlobals[key]) {
|
|
2901
3196
|
const value = $global[key];
|
|
2902
|
-
if (value !== void 0)
|
|
2903
|
-
|
|
3197
|
+
if (value !== void 0) {
|
|
3198
|
+
if (filtered) filtered[key] = value;
|
|
3199
|
+
else filtered = { [key]: value };
|
|
3200
|
+
}
|
|
2904
3201
|
}
|
|
2905
3202
|
return filtered;
|
|
2906
3203
|
}
|
|
@@ -2937,237 +3234,52 @@ function flushTickQueue() {
|
|
|
2937
3234
|
}
|
|
2938
3235
|
}
|
|
2939
3236
|
//#endregion
|
|
2940
|
-
//#region src/html/
|
|
2941
|
-
function
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
function _attr_style(value) {
|
|
2945
|
-
return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
|
|
2946
|
-
}
|
|
2947
|
-
function _attr_option_value(value) {
|
|
2948
|
-
const valueAttr = _attr("value", value);
|
|
2949
|
-
const selectedValue = getContext(kSelectedValue);
|
|
2950
|
-
if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) {
|
|
2951
|
-
{
|
|
2952
|
-
const matched = getContext(kSelectedValueMatched);
|
|
2953
|
-
if (matched) matched.value = true;
|
|
2954
|
-
}
|
|
2955
|
-
return valueAttr + " selected";
|
|
2956
|
-
}
|
|
2957
|
-
return valueAttr;
|
|
2958
|
-
}
|
|
2959
|
-
const kSelectedValue = Symbol("selectedValue");
|
|
2960
|
-
const kSelectedValueMatched = Symbol("selectedValueMatched");
|
|
2961
|
-
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
2962
|
-
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2963
|
-
if (content) {
|
|
2964
|
-
const selectedValue = value ?? "";
|
|
2965
|
-
if (valueChange) {
|
|
2966
|
-
const matched = { value: false };
|
|
2967
|
-
withContext(kSelectedValue, selectedValue, () => withContext(kSelectedValueMatched, matched, content));
|
|
2968
|
-
if (!matched.value && (Array.isArray(value) ? value.some((v) => normalizeStrAttrValue(v) !== "") : normalizeStrAttrValue(value) !== "")) console.error("A controlled `<select>`'s `value` has no matching `<option>`:", value);
|
|
2969
|
-
} else withContext(kSelectedValue, selectedValue, content);
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2973
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2974
|
-
return _textarea_value(value);
|
|
2975
|
-
}
|
|
2976
|
-
function _textarea_value(value) {
|
|
2977
|
-
const escaped = _escape(normalizeStrAttrValue(value));
|
|
2978
|
-
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
2979
|
-
}
|
|
2980
|
-
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2981
|
-
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
2982
|
-
return _attr("value", value);
|
|
2983
|
-
}
|
|
2984
|
-
function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
|
|
2985
|
-
if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
|
|
2986
|
-
return isNotVoid(checked) ? " checked" : "";
|
|
2987
|
-
}
|
|
2988
|
-
function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
|
|
2989
|
-
const valueAttr = _attr("value", value);
|
|
2990
|
-
if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
|
|
2991
|
-
return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
|
|
2992
|
-
}
|
|
2993
|
-
const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
|
|
2994
|
-
function getCheckedValueRef(checkedValue) {
|
|
2995
|
-
if (Array.isArray(checkedValue)) {
|
|
2996
|
-
let ref = checkedValuesRefs.get(checkedValue);
|
|
2997
|
-
if (!ref) {
|
|
2998
|
-
ref = [];
|
|
2999
|
-
checkedValuesRefs.set(checkedValue, ref);
|
|
3000
|
-
}
|
|
3001
|
-
return ref;
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
|
|
3005
|
-
const normalizedOpen = isNotVoid(open);
|
|
3006
|
-
if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
|
|
3007
|
-
return normalizedOpen ? " open" : "";
|
|
3008
|
-
}
|
|
3009
|
-
function _attr_nonce() {
|
|
3010
|
-
return getChunk().boundary.state.nonceAttr;
|
|
3011
|
-
}
|
|
3012
|
-
function _style_html(decls) {
|
|
3013
|
-
const id = _id();
|
|
3014
|
-
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
3015
|
-
}
|
|
3016
|
-
function _attr(name, value) {
|
|
3017
|
-
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
|
3018
|
-
}
|
|
3019
|
-
function _attr_and(name, value, attr) {
|
|
3020
|
-
return value ? attr : _attr(name, value);
|
|
3021
|
-
}
|
|
3022
|
-
function _attr_or(name, value, attr) {
|
|
3023
|
-
return value ? _attr(name, value) : attr;
|
|
3024
|
-
}
|
|
3025
|
-
function _attr_nullish(name, value, attr) {
|
|
3026
|
-
return value == null ? attr : _attr(name, value);
|
|
3027
|
-
}
|
|
3028
|
-
function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
3029
|
-
let result = "";
|
|
3030
|
-
let skip = /[\s/>"'=]/;
|
|
3031
|
-
let events;
|
|
3032
|
-
switch (data && tagName) {
|
|
3033
|
-
case "input":
|
|
3034
|
-
assertExclusiveAttrs(data);
|
|
3035
|
-
if (data.checkedChange) {
|
|
3036
|
-
result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
|
|
3037
|
-
skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
|
|
3038
|
-
} else if ("checkedValue" in data || data.checkedValueChange) {
|
|
3039
|
-
result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
|
|
3040
|
-
skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
|
|
3041
|
-
} else if (data.valueChange) {
|
|
3042
|
-
assertNoValueBindingOnCheckable(data.type, data.valueChange);
|
|
3043
|
-
result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
|
|
3044
|
-
skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
3045
|
-
}
|
|
3046
|
-
break;
|
|
3047
|
-
case "select":
|
|
3048
|
-
case "textarea":
|
|
3049
|
-
if ("value" in data || data.valueChange) skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
3050
|
-
break;
|
|
3051
|
-
case "option":
|
|
3052
|
-
if ("value" in data) {
|
|
3053
|
-
result += _attr_option_value(data.value);
|
|
3054
|
-
skip = /^value$|[\s/>"'=]/;
|
|
3055
|
-
}
|
|
3056
|
-
break;
|
|
3057
|
-
case "details":
|
|
3058
|
-
case "dialog":
|
|
3059
|
-
if (data.openChange) {
|
|
3060
|
-
result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
|
|
3061
|
-
skip = /^open(?:Change)?$|[\s/>"'=]/;
|
|
3062
|
-
}
|
|
3063
|
-
break;
|
|
3064
|
-
}
|
|
3065
|
-
for (const name in data) {
|
|
3066
|
-
const value = data[name];
|
|
3067
|
-
switch (name) {
|
|
3068
|
-
case "class":
|
|
3069
|
-
result += _attr_class(value);
|
|
3070
|
-
break;
|
|
3071
|
-
case "style":
|
|
3072
|
-
result += _attr_style(value);
|
|
3073
|
-
break;
|
|
3074
|
-
default:
|
|
3075
|
-
if (name) assertValidAttrName(name);
|
|
3076
|
-
if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
|
|
3077
|
-
if (!events) {
|
|
3078
|
-
events = {};
|
|
3079
|
-
writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
|
|
3080
|
-
}
|
|
3081
|
-
events[getEventHandlerName(name)] = value;
|
|
3082
|
-
} else result += nonVoidAttr(name, value);
|
|
3083
|
-
break;
|
|
3084
|
-
}
|
|
3085
|
-
}
|
|
3086
|
-
return result;
|
|
3087
|
-
}
|
|
3088
|
-
function _attrs_content(data, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
3089
|
-
_html(`${_attrs(data, nodeAccessor, scopeId, tagName)}>`);
|
|
3090
|
-
_attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
|
|
3091
|
-
}
|
|
3092
|
-
function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
3093
|
-
const partial = {};
|
|
3094
|
-
for (const name in data) {
|
|
3095
|
-
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
3096
|
-
if (!skip[key]) partial[key] = data[name];
|
|
3097
|
-
}
|
|
3098
|
-
assertExclusiveAttrs({
|
|
3099
|
-
...data,
|
|
3100
|
-
...skip
|
|
3101
|
-
});
|
|
3102
|
-
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
3103
|
-
}
|
|
3104
|
-
function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
3105
|
-
_html(`${_attrs_partial(data, skip, nodeAccessor, scopeId, tagName)}>`);
|
|
3106
|
-
_attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
|
|
3107
|
-
}
|
|
3108
|
-
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
3109
|
-
var handlerName = [
|
|
3110
|
-
"checkedChange",
|
|
3111
|
-
"checkedValueChange",
|
|
3112
|
-
"valueChange",
|
|
3113
|
-
"valueChange",
|
|
3114
|
-
"openChange"
|
|
3115
|
-
][type];
|
|
3116
|
-
assertHandlerIsFunction(handlerName, valueChange);
|
|
3117
|
-
setDebugSlotName(writeScope(scopeId, serializeType ? {
|
|
3118
|
-
[ControlledType + nodeAccessor]: type,
|
|
3119
|
-
[ControlledValue + nodeAccessor]: value,
|
|
3120
|
-
[ControlledHandler + nodeAccessor]: valueChange
|
|
3121
|
-
} : {
|
|
3122
|
-
[ControlledValue + nodeAccessor]: value,
|
|
3123
|
-
[ControlledHandler + nodeAccessor]: valueChange
|
|
3124
|
-
}), ControlledHandler + nodeAccessor, handlerName);
|
|
3125
|
-
}
|
|
3126
|
-
function stringAttr(name, value) {
|
|
3127
|
-
return value && " " + name + attrAssignment(value);
|
|
3128
|
-
}
|
|
3129
|
-
function nonVoidAttr(name, value) {
|
|
3130
|
-
assertValidAttrValue(name, value);
|
|
3131
|
-
switch (typeof value) {
|
|
3132
|
-
case "string": return " " + name + attrAssignment(value);
|
|
3133
|
-
case "boolean": return " " + name;
|
|
3134
|
-
case "number": return " " + name + "=" + value;
|
|
3135
|
-
}
|
|
3136
|
-
return " " + name + attrAssignment(value + "");
|
|
3237
|
+
//#region src/html/content.ts
|
|
3238
|
+
function _to_text(val) {
|
|
3239
|
+
assertValidTextValue(val);
|
|
3240
|
+
return val || val === 0 ? val + "" : "";
|
|
3137
3241
|
}
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
function attrAssignment(value) {
|
|
3142
|
-
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
3242
|
+
function _unescaped(val) {
|
|
3243
|
+
assertValidTextValue(val);
|
|
3244
|
+
return val ? val + "" : val === 0 ? "0" : "";
|
|
3143
3245
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3246
|
+
const unsafeXMLReg = /[<&\r]/g;
|
|
3247
|
+
const replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ";
|
|
3248
|
+
const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
|
3249
|
+
function _escape(val) {
|
|
3250
|
+
assertValidTextValue(val);
|
|
3251
|
+
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
|
|
3146
3252
|
}
|
|
3147
|
-
|
|
3148
|
-
|
|
3253
|
+
const unsafeScriptReg = /<(\/?script|!--)/gi;
|
|
3254
|
+
const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str;
|
|
3255
|
+
function _escape_script(val) {
|
|
3256
|
+
assertValidTextValue(val);
|
|
3257
|
+
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
3149
3258
|
}
|
|
3150
|
-
|
|
3151
|
-
|
|
3259
|
+
const unsafeStyleReg = /<(\/style)/gi;
|
|
3260
|
+
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
|
|
3261
|
+
function _escape_style(val) {
|
|
3262
|
+
assertValidTextValue(val);
|
|
3263
|
+
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
3152
3264
|
}
|
|
3153
|
-
function
|
|
3154
|
-
|
|
3265
|
+
function _escape_style_value(val) {
|
|
3266
|
+
assertValidTextValue(val);
|
|
3267
|
+
return val || val === 0 ? escapeStyleValue(val + "") : "";
|
|
3155
3268
|
}
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
if (
|
|
3159
|
-
|
|
3160
|
-
} else if (normalizeStrAttrValue(a) === value) return true;
|
|
3161
|
-
return false;
|
|
3269
|
+
const unsafeCommentReg = />/g;
|
|
3270
|
+
function escapeCommentStr(str) {
|
|
3271
|
+
if (unsafeCommentReg.test(str)) str = str.replace(unsafeCommentReg, ">");
|
|
3272
|
+
return str.startsWith(getState().commentPrefix) ? "&#" + str.charCodeAt(0) + ";" + str.slice(1) : str;
|
|
3162
3273
|
}
|
|
3163
|
-
function
|
|
3164
|
-
|
|
3274
|
+
function _escape_comment(val) {
|
|
3275
|
+
assertValidTextValue(val);
|
|
3276
|
+
return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
|
|
3165
3277
|
}
|
|
3166
3278
|
//#endregion
|
|
3167
3279
|
//#region src/html/dynamic-tag.ts
|
|
3168
3280
|
const voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
|
3169
|
-
let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs,
|
|
3170
|
-
const shouldResume =
|
|
3281
|
+
let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard) => {
|
|
3282
|
+
const shouldResume = markerGuard !== 0;
|
|
3171
3283
|
const renderer = normalizeDynamicRenderer(tag);
|
|
3172
3284
|
const state = getState();
|
|
3173
3285
|
const branchId = _peek_scope_id();
|
|
@@ -3184,11 +3296,11 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
3184
3296
|
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
3185
3297
|
if (renderer === "textarea") {
|
|
3186
3298
|
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
3187
|
-
_html(
|
|
3299
|
+
_html(_attrs_textarea_value(branchId, `#${renderer.toLowerCase()}/0`, input));
|
|
3188
3300
|
} else {
|
|
3189
3301
|
if (renderContent && typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
3190
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0,
|
|
3191
|
-
else if (renderContent) _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0,
|
|
3302
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, markerGuard) : void 0, 1);
|
|
3303
|
+
else if (renderContent) _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, markerGuard);
|
|
3192
3304
|
}
|
|
3193
3305
|
_html(`</${renderer}>`);
|
|
3194
3306
|
} else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
@@ -3207,13 +3319,13 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
3207
3319
|
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
3208
3320
|
const render = () => {
|
|
3209
3321
|
if (renderer) try {
|
|
3210
|
-
|
|
3322
|
+
_set_scope_reason(shouldResume && inputOrArgs !== void 0 ? CLIENT_ALL : 0);
|
|
3211
3323
|
return inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
3212
3324
|
...inputOrArgs,
|
|
3213
3325
|
content
|
|
3214
3326
|
} : inputOrArgs);
|
|
3215
3327
|
} finally {
|
|
3216
|
-
|
|
3328
|
+
_set_scope_reason(void 0);
|
|
3217
3329
|
}
|
|
3218
3330
|
else if (content) return content();
|
|
3219
3331
|
};
|
|
@@ -3420,27 +3532,33 @@ var ServerRendered = class {
|
|
|
3420
3532
|
}
|
|
3421
3533
|
#promise() {
|
|
3422
3534
|
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
|
3423
|
-
|
|
3535
|
+
let head = this.#head;
|
|
3424
3536
|
this.#head = null;
|
|
3425
3537
|
if (!head) return reject(/* @__PURE__ */ new Error(CONSUMED_RESULT_MESSAGE));
|
|
3426
3538
|
const { boundary } = head;
|
|
3539
|
+
let html = "";
|
|
3427
3540
|
(boundary.onNext = () => {
|
|
3428
3541
|
switch (!boundary.count && boundary.flush()) {
|
|
3429
3542
|
case 2:
|
|
3430
|
-
boundary
|
|
3431
|
-
reject(boundary.
|
|
3432
|
-
break;
|
|
3433
|
-
case 0: {
|
|
3434
|
-
const consumed = head.consume();
|
|
3435
|
-
if (!boundary.signal.aborted) resolve(consumed.flushHTML());
|
|
3543
|
+
settle(boundary);
|
|
3544
|
+
reject(boundary.reason);
|
|
3436
3545
|
break;
|
|
3437
|
-
|
|
3546
|
+
case 0:
|
|
3547
|
+
head = head.consume(boundary);
|
|
3548
|
+
if (boundary.aborted) break;
|
|
3549
|
+
html += head.flushHTML(boundary);
|
|
3550
|
+
if (!(boundary.count || boundary.aborted)) {
|
|
3551
|
+
settle(boundary);
|
|
3552
|
+
resolve(html);
|
|
3553
|
+
}
|
|
3438
3554
|
}
|
|
3439
3555
|
})();
|
|
3440
3556
|
});
|
|
3441
3557
|
}
|
|
3442
3558
|
#read(onWrite, onAbort, onClose) {
|
|
3443
3559
|
let tick = true;
|
|
3560
|
+
let flushing = false;
|
|
3561
|
+
let again = false;
|
|
3444
3562
|
let head = this.#head;
|
|
3445
3563
|
this.#head = null;
|
|
3446
3564
|
if (!head) {
|
|
@@ -3449,24 +3567,39 @@ var ServerRendered = class {
|
|
|
3449
3567
|
}
|
|
3450
3568
|
const { boundary } = head;
|
|
3451
3569
|
const onNext = boundary.onNext = (write) => {
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
boundary.onNext = NOOP$1;
|
|
3456
|
-
onAbort(boundary.signal.reason);
|
|
3457
|
-
} else if (write || status === 0) {
|
|
3458
|
-
head = head.consume();
|
|
3459
|
-
if (boundary.signal.aborted) return;
|
|
3460
|
-
const html = head.flushHTML();
|
|
3461
|
-
if (html) onWrite(html);
|
|
3462
|
-
if (status === 0) {
|
|
3463
|
-
if (!tick) offTick(onNext);
|
|
3464
|
-
onClose();
|
|
3465
|
-
} else tick = true;
|
|
3466
|
-
} else if (tick) {
|
|
3467
|
-
tick = false;
|
|
3468
|
-
queueTick(onNext);
|
|
3570
|
+
if (flushing) {
|
|
3571
|
+
again = true;
|
|
3572
|
+
return;
|
|
3469
3573
|
}
|
|
3574
|
+
flushing = true;
|
|
3575
|
+
do {
|
|
3576
|
+
again = false;
|
|
3577
|
+
const status = boundary.flush();
|
|
3578
|
+
if (status === 2) {
|
|
3579
|
+
if (!tick) offTick(onNext);
|
|
3580
|
+
settle(boundary);
|
|
3581
|
+
onAbort(boundary.reason);
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
if (write || status === 0) {
|
|
3585
|
+
head = head.consume(boundary);
|
|
3586
|
+
if (boundary.aborted) continue;
|
|
3587
|
+
const html = head.flushHTML(boundary);
|
|
3588
|
+
if (boundary.aborted) continue;
|
|
3589
|
+
if (html) onWrite(html);
|
|
3590
|
+
if (!boundary.count) {
|
|
3591
|
+
if (!tick) offTick(onNext);
|
|
3592
|
+
settle(boundary);
|
|
3593
|
+
onClose();
|
|
3594
|
+
return;
|
|
3595
|
+
}
|
|
3596
|
+
if (write) tick = true;
|
|
3597
|
+
} else if (tick) {
|
|
3598
|
+
tick = false;
|
|
3599
|
+
queueTick(onNext);
|
|
3600
|
+
}
|
|
3601
|
+
} while (again);
|
|
3602
|
+
flushing = false;
|
|
3470
3603
|
};
|
|
3471
3604
|
onNext();
|
|
3472
3605
|
return boundary;
|
|
@@ -3476,13 +3609,17 @@ var ServerRendered = class {
|
|
|
3476
3609
|
this.#head = null;
|
|
3477
3610
|
if (!head) throw new Error(CONSUMED_RESULT_MESSAGE);
|
|
3478
3611
|
const { boundary } = head;
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
return
|
|
3612
|
+
const html = boundary.flush() === 0 ? head.consume(boundary).flushHTML(boundary) : "";
|
|
3613
|
+
if (boundary.count) boundary.abort(/* @__PURE__ */ new Error("Cannot consume asynchronous render with 'toString'"));
|
|
3614
|
+
settle(boundary);
|
|
3615
|
+
if (boundary.aborted) throw boundary.reason;
|
|
3616
|
+
return html;
|
|
3484
3617
|
}
|
|
3485
3618
|
};
|
|
3619
|
+
function settle(boundary) {
|
|
3620
|
+
boundary.onNext = NOOP$1;
|
|
3621
|
+
boundary.state.$global.signal?.removeEventListener("abort", boundary);
|
|
3622
|
+
}
|
|
3486
3623
|
function NOOP$1() {}
|
|
3487
3624
|
//#endregion
|
|
3488
3625
|
//#region src/html/assets.ts
|
|
@@ -3503,8 +3640,10 @@ function withPageAssets(template, runtime, assetId, runtimeId) {
|
|
|
3503
3640
|
return Object.assign((input) => {
|
|
3504
3641
|
const g = $global();
|
|
3505
3642
|
if (runtimeId) {
|
|
3506
|
-
if (g
|
|
3507
|
-
|
|
3643
|
+
if (!g[kAssets]) {
|
|
3644
|
+
if (g.runtimeId !== "M" && g.runtimeId !== runtimeId) throw new Error(`$global.runtimeId ("${g.runtimeId}") conflicts with the runtimeId this entry was compiled with ("${runtimeId}").`);
|
|
3645
|
+
g.runtimeId = runtimeId;
|
|
3646
|
+
} 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.`);
|
|
3508
3647
|
}
|
|
3509
3648
|
addAsset(g, assetId);
|
|
3510
3649
|
if (g.__flush__) {
|
|
@@ -3612,9 +3751,9 @@ const compat = {
|
|
|
3612
3751
|
},
|
|
3613
3752
|
onFlush(fn) {
|
|
3614
3753
|
const { flushHTML } = Chunk.prototype;
|
|
3615
|
-
Chunk.prototype.flushHTML = function() {
|
|
3754
|
+
Chunk.prototype.flushHTML = function(boundary) {
|
|
3616
3755
|
fn(this);
|
|
3617
|
-
return flushHTML.call(this);
|
|
3756
|
+
return flushHTML.call(this, boundary);
|
|
3618
3757
|
};
|
|
3619
3758
|
},
|
|
3620
3759
|
patchDynamicTag,
|
|
@@ -3646,16 +3785,16 @@ const compat = {
|
|
|
3646
3785
|
flushScript($global, chunk) {
|
|
3647
3786
|
chunk ||= this.createChunk($global);
|
|
3648
3787
|
const { boundary } = chunk;
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
return chunk.flushScript().scripts;
|
|
3788
|
+
const scripts = boundary.flush() === 0 ? chunk.flushScript(boundary).scripts : "";
|
|
3789
|
+
if (boundary.aborted) throw boundary.reason;
|
|
3790
|
+
if (boundary.count) throw new Error("Cannot serialize promise across tags/class compat layer.");
|
|
3791
|
+
return scripts;
|
|
3654
3792
|
},
|
|
3655
3793
|
render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
|
|
3656
3794
|
const state = this.ensureState(classAPIOut.global);
|
|
3657
3795
|
const boundary = new Boundary(state);
|
|
3658
|
-
|
|
3796
|
+
const context = getChunk()?.context ?? null;
|
|
3797
|
+
let head = new Chunk(boundary, new Chunk(boundary, null, context, state), context, state);
|
|
3659
3798
|
let normalizedInput = input;
|
|
3660
3799
|
if ("renderBody" in input) {
|
|
3661
3800
|
normalizedInput = {};
|
|
@@ -3676,11 +3815,11 @@ const compat = {
|
|
|
3676
3815
|
writeScope(scopeId, { m5c: component.id });
|
|
3677
3816
|
_script(scopeId, SET_SCOPE_REGISTER_ID);
|
|
3678
3817
|
}
|
|
3679
|
-
|
|
3818
|
+
_set_scope_reason(willRerender ? CLIENT_ALL : 0);
|
|
3680
3819
|
try {
|
|
3681
3820
|
renderer(normalizedInput);
|
|
3682
3821
|
} finally {
|
|
3683
|
-
|
|
3822
|
+
_set_scope_reason(void 0);
|
|
3684
3823
|
}
|
|
3685
3824
|
const asyncOut = classAPIOut.beginAsync({
|
|
3686
3825
|
last: true,
|
|
@@ -3688,12 +3827,12 @@ const compat = {
|
|
|
3688
3827
|
});
|
|
3689
3828
|
classAPIOut.onLast((next) => {
|
|
3690
3829
|
(boundary.onNext = () => {
|
|
3691
|
-
if (boundary.
|
|
3692
|
-
asyncOut.error(boundary.
|
|
3830
|
+
if (boundary.aborted) {
|
|
3831
|
+
asyncOut.error(boundary.reason);
|
|
3693
3832
|
boundary.onNext = NOOP;
|
|
3694
3833
|
} else if (!boundary.count) {
|
|
3695
3834
|
boundary.onNext = NOOP;
|
|
3696
|
-
head = head.consume();
|
|
3835
|
+
head = head.consume(boundary);
|
|
3697
3836
|
asyncOut.write(head.html);
|
|
3698
3837
|
asyncOut.script(head.scripts);
|
|
3699
3838
|
asyncOut.end();
|
|
@@ -3760,6 +3899,8 @@ exports._attrs = _attrs;
|
|
|
3760
3899
|
exports._attrs_content = _attrs_content;
|
|
3761
3900
|
exports._attrs_partial = _attrs_partial;
|
|
3762
3901
|
exports._attrs_partial_content = _attrs_partial_content;
|
|
3902
|
+
exports._attrs_select_value = _attrs_select_value;
|
|
3903
|
+
exports._attrs_textarea_value = _attrs_textarea_value;
|
|
3763
3904
|
exports._await = _await;
|
|
3764
3905
|
exports._content = _content;
|
|
3765
3906
|
exports._content_resume = _content_resume;
|
|
@@ -3803,9 +3944,7 @@ exports._scope_id = _scope_id;
|
|
|
3803
3944
|
exports._scope_reason = _scope_reason;
|
|
3804
3945
|
exports._scope_with_id = _scope_with_id;
|
|
3805
3946
|
exports._script = _script;
|
|
3806
|
-
exports.
|
|
3807
|
-
exports._serialize_if = _serialize_if;
|
|
3808
|
-
exports._set_serialize_reason = _set_serialize_reason;
|
|
3947
|
+
exports._set_scope_reason = _set_scope_reason;
|
|
3809
3948
|
exports._show_end = _show_end;
|
|
3810
3949
|
exports._show_start = _show_start;
|
|
3811
3950
|
exports._style_html = _style_html;
|
|
@@ -3818,6 +3957,8 @@ exports._trailers = _trailers;
|
|
|
3818
3957
|
exports._try = _try;
|
|
3819
3958
|
exports._unescaped = _unescaped;
|
|
3820
3959
|
exports._var = _var;
|
|
3960
|
+
exports._write_guard = _write_guard;
|
|
3961
|
+
exports._write_if = _write_if;
|
|
3821
3962
|
exports.attrTag = attrTag;
|
|
3822
3963
|
exports.attrTags = attrTags;
|
|
3823
3964
|
exports.compat = compat;
|