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