marko 6.3.33 → 6.3.35
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 +37 -33
- package/dist/common/constants/accessor-prefix.d.ts +1 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
- package/dist/common/errors.d.ts +2 -0
- package/dist/common/types.d.ts +10 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- 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-BJ93mcSe.mjs → dom-B57LrRnX.mjs} +89 -46
- package/dist/debug/{dom-CiFITSPN.js → dom-Bt4OoZ-j.js} +89 -46
- package/dist/debug/dom.js +3 -1
- package/dist/debug/dom.mjs +3 -1
- package/dist/debug/html.js +205 -98
- package/dist/debug/html.mjs +205 -98
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +4 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/signals.d.ts +3 -3
- package/dist/{dom-Cj4HQ7T_.mjs → dom-BP2XSglG.mjs} +46 -33
- package/dist/{dom-CI-06TZb.js → dom-BeF9xIzO.js} +46 -33
- package/dist/dom.js +3 -1
- package/dist/dom.mjs +3 -1
- package/dist/html/compat.d.ts +4 -2
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/serializer.d.ts +9 -1
- package/dist/html/template.d.ts +1 -0
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.js +88 -63
- package/dist/html.mjs +88 -63
- package/dist/translator/core/client.d.ts +1 -2
- package/dist/translator/core/server.d.ts +1 -2
- package/dist/translator/core/static.d.ts +1 -2
- package/dist/translator/index.js +514 -314
- package/dist/translator/util/constants/binding-type.d.ts +1 -0
- package/dist/translator/util/references.d.ts +8 -1
- package/dist/translator/util/serialize-reasons.d.ts +4 -4
- package/dist/translator/util/signals.d.ts +5 -0
- package/dist/translator/util/statement-tag.d.ts +2 -0
- package/dist/translator/util/translate-var.d.ts +1 -1
- package/dist/translator/visitors/export-declaration.d.ts +8 -0
- package/dist/translator/visitors/program/index.d.ts +0 -1
- package/package.json +5 -4
- package/tags/html-comment.d.marko +2 -0
- package/tags/html-script.d.marko +2 -0
- package/tags/html-style.d.marko +2 -0
- package/tags/let.d.marko +4 -5
- package/tags/show.d.marko +6 -0
- package/tags/try.d.marko +1 -1
- package/tags-html.d.ts +6 -1
- /package/dist/translator/util/{get-accessor-char.d.ts → get-accessor-enums.d.ts} +0 -0
package/dist/debug/html.mjs
CHANGED
|
@@ -33,6 +33,7 @@ const LoopKey = "#LoopKey";
|
|
|
33
33
|
const PlaceholderContent = "#PlaceholderContent";
|
|
34
34
|
const Renderer = "#Renderer";
|
|
35
35
|
const TagVariable = "#TagVariable";
|
|
36
|
+
const Owner = "owner";
|
|
36
37
|
const Embed = "embed";
|
|
37
38
|
//#endregion
|
|
38
39
|
//#region src/common/helpers.ts
|
|
@@ -83,6 +84,7 @@ function stringifyStyleObject(name, value) {
|
|
|
83
84
|
warnedStyleKeys.add(name);
|
|
84
85
|
console.warn(`\`${name}\` is not a CSS property name; \`style\` object keys are written verbatim, so it renders as invalid CSS. Use \`${name.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^ms-/, "-ms-")}\`.`);
|
|
85
86
|
}
|
|
87
|
+
if (value !== value || typeof value === "bigint" && !value) console.warn(`The \`${name}\` style value \`${value !== value ? "NaN" : "0n"}\` drops the declaration; convert it to a string or number to render it.`);
|
|
86
88
|
return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
|
|
87
89
|
}
|
|
88
90
|
const unsafeStyleAttrReg = /[\\;]/g;
|
|
@@ -157,6 +159,13 @@ function assertValidAttrValue(name, value) {
|
|
|
157
159
|
function assertValidTextValue(value) {
|
|
158
160
|
const unrenderable = describeUnrenderable(value);
|
|
159
161
|
if (unrenderable) throw new Error(`Text content cannot be ${unrenderable}.`);
|
|
162
|
+
if (isSilentlyDropped(value)) console.warn(`Text content of \`${describeDropped(value)}\` renders as nothing; convert it to a string or number to render it.`);
|
|
163
|
+
}
|
|
164
|
+
function isSilentlyDropped(value) {
|
|
165
|
+
return value !== value || typeof value === "bigint" && !value;
|
|
166
|
+
}
|
|
167
|
+
function describeDropped(value) {
|
|
168
|
+
return value !== value ? "NaN" : "0n";
|
|
160
169
|
}
|
|
161
170
|
function describeUnrenderable(value) {
|
|
162
171
|
if (typeof value === "symbol") return "a symbol";
|
|
@@ -180,6 +189,9 @@ function assertValidLoopKey(key, seenKeys) {
|
|
|
180
189
|
function assertValidList(value) {
|
|
181
190
|
if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
|
|
182
191
|
}
|
|
192
|
+
function assertValidRangeStart(name, value) {
|
|
193
|
+
if (value && (typeof value !== "number" || !isFinite(value))) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
194
|
+
}
|
|
183
195
|
function assertValidRangeBound(name, value) {
|
|
184
196
|
if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
185
197
|
}
|
|
@@ -211,10 +223,16 @@ function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
|
211
223
|
(exclusiveAttrs ||= []).push("checkedValueChange");
|
|
212
224
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
213
225
|
}
|
|
214
|
-
if (attrs.valueChange)
|
|
226
|
+
if (attrs.valueChange) {
|
|
227
|
+
(exclusiveAttrs ||= []).push("valueChange");
|
|
228
|
+
if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
|
|
229
|
+
}
|
|
215
230
|
if (exclusiveAttrs && exclusiveAttrs.length > 1) onError(`The attributes ${joinWithAnd(exclusiveAttrs)} are mutually exclusive.`);
|
|
216
231
|
}
|
|
217
232
|
}
|
|
233
|
+
function assertNoValueBindingOnCheckable(type, valueChange) {
|
|
234
|
+
if (valueChange && /^(?:button|checkbox|hidden|image|radio|reset|submit)$/i.test(type)) console.error(`\`valueChange\` cannot be used on a \`type="${type}"\` \`<input>\` — user interaction can never change its \`value\`.` + (/^[cr]/i.test(type) ? " Bind `checked` or `checkedValue` instead." : ""));
|
|
235
|
+
}
|
|
218
236
|
function assertHandlerIsFunction(name, value) {
|
|
219
237
|
if (value && typeof value !== "function") throw new Error(`The \`${name}\` handler must be a function or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}".`);
|
|
220
238
|
}
|
|
@@ -245,8 +263,8 @@ function _unescaped(val) {
|
|
|
245
263
|
assertValidTextValue(val);
|
|
246
264
|
return val ? val + "" : val === 0 ? "0" : "";
|
|
247
265
|
}
|
|
248
|
-
const unsafeXMLReg = /[
|
|
249
|
-
const replaceUnsafeXML = (c) => c === "&" ? "&" : "<";
|
|
266
|
+
const unsafeXMLReg = /[<&\r]/g;
|
|
267
|
+
const replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ";
|
|
250
268
|
const escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
|
251
269
|
function _escape(val) {
|
|
252
270
|
assertValidTextValue(val);
|
|
@@ -525,31 +543,31 @@ const KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
|
|
525
543
|
]);
|
|
526
544
|
var State$1 = class {
|
|
527
545
|
ids = 0;
|
|
528
|
-
|
|
546
|
+
flushId = 0;
|
|
529
547
|
wroteUndefined = false;
|
|
530
548
|
buf = [];
|
|
531
549
|
strs = /* @__PURE__ */ new Map();
|
|
532
550
|
refs = /* @__PURE__ */ new WeakMap();
|
|
533
|
-
|
|
551
|
+
pendingAssignments = /* @__PURE__ */ new Set();
|
|
534
552
|
boundary = void 0;
|
|
535
553
|
channel = void 0;
|
|
536
554
|
channelDeps = null;
|
|
537
555
|
mutated = [];
|
|
538
556
|
};
|
|
539
557
|
var Reference = class {
|
|
540
|
-
|
|
558
|
+
assignments = null;
|
|
541
559
|
calls = null;
|
|
542
560
|
scopeId = void 0;
|
|
543
561
|
channel = void 0;
|
|
544
562
|
parent;
|
|
545
563
|
accessor;
|
|
546
|
-
|
|
564
|
+
flushId;
|
|
547
565
|
pos;
|
|
548
566
|
id;
|
|
549
|
-
constructor(parent, accessor,
|
|
567
|
+
constructor(parent, accessor, flushId, pos = null, id = null) {
|
|
550
568
|
this.parent = parent;
|
|
551
569
|
this.accessor = accessor;
|
|
552
|
-
this.
|
|
570
|
+
this.flushId = flushId;
|
|
553
571
|
this.pos = pos;
|
|
554
572
|
this.id = id;
|
|
555
573
|
}
|
|
@@ -559,7 +577,18 @@ function setDebugInfo(obj, file, loc, vars) {
|
|
|
559
577
|
DEBUG.set(obj, {
|
|
560
578
|
file,
|
|
561
579
|
loc,
|
|
562
|
-
vars
|
|
580
|
+
vars,
|
|
581
|
+
slots: DEBUG.get(obj)?.slots
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
function setDebugSlotName(obj, accessor, name) {
|
|
585
|
+
const debug = DEBUG.get(obj);
|
|
586
|
+
if (debug) (debug.slots ??= {})[accessor] = name;
|
|
587
|
+
else DEBUG.set(obj, {
|
|
588
|
+
file: "",
|
|
589
|
+
loc: 0,
|
|
590
|
+
vars: void 0,
|
|
591
|
+
slots: { [accessor]: name }
|
|
563
592
|
});
|
|
564
593
|
}
|
|
565
594
|
var Serializer = class {
|
|
@@ -576,7 +605,7 @@ var Serializer = class {
|
|
|
576
605
|
this.#state.channel = channel;
|
|
577
606
|
return writeScopesRoot(this.#state, flushes);
|
|
578
607
|
} finally {
|
|
579
|
-
this.#state.
|
|
608
|
+
this.#state.flushId++;
|
|
580
609
|
this.#state.buf = [];
|
|
581
610
|
}
|
|
582
611
|
}
|
|
@@ -630,7 +659,7 @@ function writeScopesRoot(state, flushes) {
|
|
|
630
659
|
}
|
|
631
660
|
if (nextSlotId !== -1) buf.push("]");
|
|
632
661
|
let extras = "";
|
|
633
|
-
if (state.
|
|
662
|
+
if (state.pendingAssignments.size || hasChannelMutations(state)) {
|
|
634
663
|
extras = ",0)";
|
|
635
664
|
if (fillIndex !== -1) {
|
|
636
665
|
buf[fillIndex] = "_(" + buf[fillIndex];
|
|
@@ -649,21 +678,21 @@ function writeScopesRoot(state, flushes) {
|
|
|
649
678
|
}
|
|
650
679
|
function writeAssigned(state) {
|
|
651
680
|
let sep = state.buf.length ? "," : "";
|
|
652
|
-
if (state.
|
|
653
|
-
const
|
|
654
|
-
state.
|
|
681
|
+
if (state.pendingAssignments.size) {
|
|
682
|
+
const pending = state.pendingAssignments;
|
|
683
|
+
state.pendingAssignments = /* @__PURE__ */ new Set();
|
|
655
684
|
let buf = "";
|
|
656
685
|
let hasCalls = false;
|
|
657
|
-
for (const ref of
|
|
658
|
-
if (ref.
|
|
659
|
-
buf += sep +
|
|
660
|
-
ref.
|
|
686
|
+
for (const ref of pending) {
|
|
687
|
+
if (ref.assignments) {
|
|
688
|
+
buf += sep + assignmentsToString(ref.assignments, ref.id);
|
|
689
|
+
ref.assignments = null;
|
|
661
690
|
sep = ",";
|
|
662
691
|
}
|
|
663
692
|
hasCalls ||= ref.calls !== null;
|
|
664
693
|
}
|
|
665
694
|
if (buf) state.buf.push(buf);
|
|
666
|
-
if (hasCalls) for (const ref of
|
|
695
|
+
if (hasCalls) for (const ref of pending) {
|
|
667
696
|
if (!ref.calls) continue;
|
|
668
697
|
for (const { method, args } of ref.calls) {
|
|
669
698
|
state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
|
|
@@ -710,13 +739,16 @@ function writeAssigned(state) {
|
|
|
710
739
|
}
|
|
711
740
|
state.mutated = remaining;
|
|
712
741
|
}
|
|
713
|
-
if (state.
|
|
742
|
+
if (state.pendingAssignments.size) writeAssigned(state);
|
|
714
743
|
}
|
|
715
744
|
function writeCallArg(state, val) {
|
|
716
745
|
if (val === void 0) {
|
|
717
746
|
state.wroteUndefined = true;
|
|
718
747
|
state.buf.push("$");
|
|
719
|
-
} else if (
|
|
748
|
+
} else if (writeProp(state, val, null, "")) {
|
|
749
|
+
const ref = state.refs.get(val) || state.strs.get(val);
|
|
750
|
+
if (ref && ref.id === null) assignId(state, ref);
|
|
751
|
+
} else state.buf.push("void 0");
|
|
720
752
|
}
|
|
721
753
|
function hasChannelMutations(state) {
|
|
722
754
|
return hasMatchingMutations(state.mutated, state.channel?.readyId);
|
|
@@ -751,7 +783,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
|
|
|
751
783
|
}
|
|
752
784
|
if (parent && isCircular(parent, ref)) {
|
|
753
785
|
ensureId(state, ref);
|
|
754
|
-
state.
|
|
786
|
+
state.pendingAssignments.add(ref);
|
|
755
787
|
addAssignment(ref, accessId(state, parent) + toAccess(accessor));
|
|
756
788
|
return false;
|
|
757
789
|
}
|
|
@@ -760,7 +792,7 @@ function writeReferenceOr(state, write, val, parent, accessor) {
|
|
|
760
792
|
}
|
|
761
793
|
const registered = REGISTRY.get(val);
|
|
762
794
|
if (registered) return writeRegistered(state, val, parent, accessor, registered);
|
|
763
|
-
state.refs.set(val, ref = new Reference(parent, accessor, state.
|
|
795
|
+
state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length));
|
|
764
796
|
ref.channel = state.channel;
|
|
765
797
|
ref.debug = DEBUG.get(val);
|
|
766
798
|
if (write(state, val, ref)) return true;
|
|
@@ -773,7 +805,7 @@ function trackScope(state, val, scopeId) {
|
|
|
773
805
|
else newScopeReference(state, val, scopeId);
|
|
774
806
|
}
|
|
775
807
|
function newScopeReference(state, val, scopeId) {
|
|
776
|
-
const ref = new Reference(null, null, state.
|
|
808
|
+
const ref = new Reference(null, null, state.flushId);
|
|
777
809
|
ref.scopeId = scopeId;
|
|
778
810
|
ref.channel = state.channel;
|
|
779
811
|
state.refs.set(val, ref);
|
|
@@ -783,7 +815,7 @@ function newScopeReference(state, val, scopeId) {
|
|
|
783
815
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
784
816
|
const { scope } = registered;
|
|
785
817
|
if (scope) {
|
|
786
|
-
const ref = new Reference(parent, accessor, state.
|
|
818
|
+
const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
787
819
|
ref.channel = state.channel;
|
|
788
820
|
state.refs.set(val, ref);
|
|
789
821
|
ref.debug = DEBUG.get(val);
|
|
@@ -803,7 +835,7 @@ function writeString(state, val, parent, accessor) {
|
|
|
803
835
|
return true;
|
|
804
836
|
}
|
|
805
837
|
} else {
|
|
806
|
-
const ref = new Reference(parent, accessor, state.
|
|
838
|
+
const ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
807
839
|
ref.channel = state.channel;
|
|
808
840
|
state.strs.set(val, ref);
|
|
809
841
|
}
|
|
@@ -989,7 +1021,7 @@ function writePromise(state, val, ref) {
|
|
|
989
1021
|
}
|
|
990
1022
|
function newAsyncHandle(state, parent, id) {
|
|
991
1023
|
const handle = {};
|
|
992
|
-
const handleRef = new Reference(parent, null, state.
|
|
1024
|
+
const handleRef = new Reference(parent, null, state.flushId, null, id);
|
|
993
1025
|
handleRef.channel = state.channel;
|
|
994
1026
|
state.refs.set(handle, handleRef);
|
|
995
1027
|
return handle;
|
|
@@ -1000,7 +1032,7 @@ function writeMap(state, val, ref) {
|
|
|
1000
1032
|
return true;
|
|
1001
1033
|
}
|
|
1002
1034
|
const items = [];
|
|
1003
|
-
let
|
|
1035
|
+
let assignments;
|
|
1004
1036
|
let needsId;
|
|
1005
1037
|
let deferring = false;
|
|
1006
1038
|
let i = 0;
|
|
@@ -1013,16 +1045,16 @@ function writeMap(state, val, ref) {
|
|
|
1013
1045
|
}
|
|
1014
1046
|
if (itemKey === val) {
|
|
1015
1047
|
itemKey = void 0;
|
|
1016
|
-
(
|
|
1048
|
+
(assignments ||= []).push("a[" + i + "][0]");
|
|
1017
1049
|
}
|
|
1018
1050
|
if (itemValue === val) {
|
|
1019
1051
|
itemValue = void 0;
|
|
1020
|
-
(
|
|
1052
|
+
(assignments ||= []).push("a[" + i + "][1]");
|
|
1021
1053
|
}
|
|
1022
1054
|
needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
|
|
1023
1055
|
i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
|
|
1024
1056
|
}
|
|
1025
|
-
writeArrayArg(state, ref, items,
|
|
1057
|
+
writeArrayArg(state, ref, items, assignments && "((m,a)=>(" + assignmentsToString(assignments, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
|
|
1026
1058
|
} else {
|
|
1027
1059
|
for (let [itemKey, itemValue] of val) {
|
|
1028
1060
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue))) deferring = true;
|
|
@@ -1032,16 +1064,16 @@ function writeMap(state, val, ref) {
|
|
|
1032
1064
|
}
|
|
1033
1065
|
if (itemKey === val) {
|
|
1034
1066
|
itemKey = 0;
|
|
1035
|
-
(
|
|
1067
|
+
(assignments ||= []).push("a[" + i + "]");
|
|
1036
1068
|
}
|
|
1037
1069
|
if (itemValue === val) {
|
|
1038
1070
|
itemValue = 0;
|
|
1039
|
-
(
|
|
1071
|
+
(assignments ||= []).push("a[" + (i + 1) + "]");
|
|
1040
1072
|
}
|
|
1041
1073
|
needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue);
|
|
1042
1074
|
i = items.push(itemKey, itemValue);
|
|
1043
1075
|
}
|
|
1044
|
-
writeArrayArg(state, ref, items,
|
|
1076
|
+
writeArrayArg(state, ref, items, assignments && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignmentsToString(assignments, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
|
|
1045
1077
|
}
|
|
1046
1078
|
return true;
|
|
1047
1079
|
}
|
|
@@ -1051,7 +1083,7 @@ function writeSet(state, val, ref) {
|
|
|
1051
1083
|
return true;
|
|
1052
1084
|
}
|
|
1053
1085
|
const items = [];
|
|
1054
|
-
let
|
|
1086
|
+
let assignments;
|
|
1055
1087
|
let needsId;
|
|
1056
1088
|
let deferring = false;
|
|
1057
1089
|
let i = 0;
|
|
@@ -1063,11 +1095,11 @@ function writeSet(state, val, ref) {
|
|
|
1063
1095
|
}
|
|
1064
1096
|
if (item === val) {
|
|
1065
1097
|
item = 0;
|
|
1066
|
-
(
|
|
1098
|
+
(assignments ||= []).push("i[" + i + "]");
|
|
1067
1099
|
} else needsId ||= isDedupedMember(item);
|
|
1068
1100
|
i = items.push(item);
|
|
1069
1101
|
}
|
|
1070
|
-
writeArrayArg(state, ref, items,
|
|
1102
|
+
writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId);
|
|
1071
1103
|
return true;
|
|
1072
1104
|
}
|
|
1073
1105
|
function isAncestorMember(state, container, member) {
|
|
@@ -1081,16 +1113,16 @@ function deferCall(state, ref, method, args) {
|
|
|
1081
1113
|
method,
|
|
1082
1114
|
args
|
|
1083
1115
|
});
|
|
1084
|
-
state.
|
|
1116
|
+
state.pendingAssignments.add(ref);
|
|
1085
1117
|
}
|
|
1086
1118
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
1087
1119
|
if (assignsPrefix || needsId) {
|
|
1088
|
-
const arrayRef = new Reference(ref, null, state.
|
|
1120
|
+
const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1089
1121
|
state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "=");
|
|
1090
1122
|
writeArray(state, items, arrayRef);
|
|
1091
1123
|
} else {
|
|
1092
1124
|
state.buf.push(plainPrefix);
|
|
1093
|
-
writeArray(state, items, new Reference(ref, null, state.
|
|
1125
|
+
writeArray(state, items, new Reference(ref, null, state.flushId, state.buf.length));
|
|
1094
1126
|
}
|
|
1095
1127
|
state.buf.push(")");
|
|
1096
1128
|
}
|
|
@@ -1134,7 +1166,7 @@ function writeTypedArray(state, val, ref) {
|
|
|
1134
1166
|
writeProp(state, val.buffer, ref, "buffer");
|
|
1135
1167
|
state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
1136
1168
|
} else {
|
|
1137
|
-
state.refs.set(val.buffer, new Reference(ref, "buffer", state.
|
|
1169
|
+
state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null));
|
|
1138
1170
|
state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
|
|
1139
1171
|
}
|
|
1140
1172
|
return true;
|
|
@@ -1165,7 +1197,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
1165
1197
|
if (inlined) {
|
|
1166
1198
|
const errorsRef = state.refs.get(val.errors);
|
|
1167
1199
|
if (errorsRef?.id) {
|
|
1168
|
-
state.
|
|
1200
|
+
state.pendingAssignments.add(errorsRef);
|
|
1169
1201
|
addAssignment(errorsRef, accessId(state, ref) + toAccess("errors"));
|
|
1170
1202
|
}
|
|
1171
1203
|
}
|
|
@@ -1228,7 +1260,7 @@ function writeRequest(state, val, ref) {
|
|
|
1228
1260
|
options += sep + "headers:" + ensureId(state, seenHeaders);
|
|
1229
1261
|
sep = ",";
|
|
1230
1262
|
} else {
|
|
1231
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
1263
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1232
1264
|
const headers = stringEntriesToHeadersInit(val.headers);
|
|
1233
1265
|
if (headers) {
|
|
1234
1266
|
options += sep + "headers:" + headers;
|
|
@@ -1277,7 +1309,7 @@ function writeResponse(state, val, ref) {
|
|
|
1277
1309
|
const seenHeaders = state.refs.get(val.headers);
|
|
1278
1310
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
|
|
1279
1311
|
else {
|
|
1280
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
1312
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
1281
1313
|
const headers = stringEntriesToHeadersInit(val.headers);
|
|
1282
1314
|
if (headers) options += sep + "headers:" + headers;
|
|
1283
1315
|
}
|
|
@@ -1298,10 +1330,10 @@ function writeIntl(state, val, name, ref) {
|
|
|
1298
1330
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
1299
1331
|
let optionsRef;
|
|
1300
1332
|
if (needsId) {
|
|
1301
|
-
optionsRef = new Reference(ref, null, state.
|
|
1333
|
+
optionsRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1302
1334
|
state.buf.push(optionsRef.id + "={");
|
|
1303
1335
|
} else {
|
|
1304
|
-
optionsRef = new Reference(ref, null, state.
|
|
1336
|
+
optionsRef = new Reference(ref, null, state.flushId, state.buf.length);
|
|
1305
1337
|
state.buf.push("{");
|
|
1306
1338
|
}
|
|
1307
1339
|
writeObjectProps(state, options, optionsRef);
|
|
@@ -1362,12 +1394,12 @@ function writeGenerator(state, iter, ref) {
|
|
|
1362
1394
|
const heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
1363
1395
|
state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})(");
|
|
1364
1396
|
if (needsId) {
|
|
1365
|
-
const arrayRef = new Reference(ref, null, state.
|
|
1397
|
+
const arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1366
1398
|
state.buf.push(arrayRef.id + "=");
|
|
1367
1399
|
writeArray(state, yields, arrayRef);
|
|
1368
|
-
} else writeArray(state, yields, new Reference(ref, null, state.
|
|
1400
|
+
} else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
|
|
1369
1401
|
if (heldReturn) {
|
|
1370
|
-
const holder = new Reference(ref, null, state.
|
|
1402
|
+
const holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1371
1403
|
state.buf.push("," + holder.id + "={}");
|
|
1372
1404
|
writeProp(state, returnValue, holder, "v");
|
|
1373
1405
|
} else if (returnValue !== void 0) {
|
|
@@ -1431,7 +1463,7 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
1431
1463
|
for (const item of val) if (item === val && !(yieldSelf || iterArr.length)) yieldSelf = "yield this;";
|
|
1432
1464
|
else iterArr.push(item);
|
|
1433
1465
|
if (iterArr.length) {
|
|
1434
|
-
const iterRef = new Reference(ref, null, state.
|
|
1466
|
+
const iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1435
1467
|
state.buf.push(sep + "*[(" + iterRef.id + "=");
|
|
1436
1468
|
writeArray(state, iterArr, iterRef);
|
|
1437
1469
|
state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
|
|
@@ -1455,21 +1487,27 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
|
|
|
1455
1487
|
if (cause !== void 0 && state.boundary?.abort) {
|
|
1456
1488
|
let message = "Unable to serialize";
|
|
1457
1489
|
let access = "";
|
|
1458
|
-
while (ref
|
|
1490
|
+
while (ref) {
|
|
1491
|
+
const { accessor } = ref;
|
|
1459
1492
|
const debug = ref.parent?.debug;
|
|
1460
|
-
if (debug) {
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1493
|
+
if (accessor && debug) {
|
|
1494
|
+
const rawAccessor = fromObjectKey(accessor);
|
|
1495
|
+
const varLoc = debug.vars?.[rawAccessor];
|
|
1496
|
+
const slotName = debug.slots?.[rawAccessor];
|
|
1497
|
+
let debugAccess = varLoc ? rawAccessor : void 0;
|
|
1463
1498
|
let debugLoc = debug.loc;
|
|
1464
1499
|
if (varLoc) if (Array.isArray(varLoc)) {
|
|
1465
1500
|
debugAccess = varLoc[0];
|
|
1466
1501
|
if (varLoc[1]) debugLoc = varLoc[1];
|
|
1467
1502
|
} else debugLoc = varLoc;
|
|
1468
|
-
|
|
1503
|
+
let display;
|
|
1504
|
+
if (debugAccess !== void 0) display = slotName && debugAccess.startsWith("...") ? `\`${slotName}\` from \`${debugAccess}\`` : JSON.stringify(debugAccess);
|
|
1505
|
+
else display = describeAccessor(rawAccessor, slotName) ?? JSON.stringify(rawAccessor);
|
|
1506
|
+
message += ` ${display} in ${debug.file}`;
|
|
1469
1507
|
if (debugLoc) message += `:${debugLoc}`;
|
|
1470
1508
|
break;
|
|
1471
1509
|
}
|
|
1472
|
-
access = toAccess(
|
|
1510
|
+
if (accessor) access = toAccess(accessor) + access;
|
|
1473
1511
|
ref = ref.parent;
|
|
1474
1512
|
}
|
|
1475
1513
|
if (accessor) access = toAccess(accessor) + access;
|
|
@@ -1481,6 +1519,40 @@ function throwUnserializable(state, cause, ref = null, accessor = "") {
|
|
|
1481
1519
|
state.boundary.abort(err);
|
|
1482
1520
|
}
|
|
1483
1521
|
}
|
|
1522
|
+
const accessorPrefixDescriptions = {
|
|
1523
|
+
BranchScopes: "the branch scopes",
|
|
1524
|
+
ClosureScopes: "the closure scopes",
|
|
1525
|
+
ClosureSignalIndex: "the closure signal index",
|
|
1526
|
+
ConditionalRenderer: "the conditional renderer",
|
|
1527
|
+
ControlledObserver: "the controlled observer",
|
|
1528
|
+
ControlledHandler: "the change handler",
|
|
1529
|
+
ControlledType: "the controlled type",
|
|
1530
|
+
ControlledValue: "the controlled value",
|
|
1531
|
+
DynamicHTMLLastChild: "the dynamic html",
|
|
1532
|
+
EventAttributes: "the event handlers",
|
|
1533
|
+
IdFallback: "the generated id",
|
|
1534
|
+
KeyedScopes: "the keyed scopes",
|
|
1535
|
+
Lifecycle: "the lifecycle handlers",
|
|
1536
|
+
Promise: "the pending promise",
|
|
1537
|
+
TagVariableChange: "the tag variable change handler"
|
|
1538
|
+
};
|
|
1539
|
+
function describeAccessor(accessor, slotName) {
|
|
1540
|
+
const sep = accessor.indexOf(":");
|
|
1541
|
+
if (~sep) {
|
|
1542
|
+
const description = slotName === void 0 ? accessorPrefixDescriptions[accessor.slice(0, sep)] : `the \`${slotName}\` handler`;
|
|
1543
|
+
if (description) {
|
|
1544
|
+
const node = /^#([a-z-]+)\//i.exec(accessor.slice(sep + 1));
|
|
1545
|
+
return node ? `${description} of \`<${node[1]}>\`` : description;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
function fromObjectKey(key) {
|
|
1550
|
+
try {
|
|
1551
|
+
if (key[0] === "\"") return JSON.parse(key.replace(/\\x/g, "\\u00"));
|
|
1552
|
+
if (key[0] === "[") return JSON.parse(key.slice(1, -1));
|
|
1553
|
+
} catch {}
|
|
1554
|
+
return key;
|
|
1555
|
+
}
|
|
1484
1556
|
function trackChannel(state, ref) {
|
|
1485
1557
|
const refReadyId = ref.channel?.readyId;
|
|
1486
1558
|
if (!refReadyId || refReadyId === state.channel?.readyId) return true;
|
|
@@ -1601,7 +1673,7 @@ function accessId(state, ref) {
|
|
|
1601
1673
|
function assignId(state, ref) {
|
|
1602
1674
|
const { pos } = ref;
|
|
1603
1675
|
ref.id = nextRefAccess(state);
|
|
1604
|
-
if (pos !== null && ref.
|
|
1676
|
+
if (pos !== null && ref.flushId === state.flushId) {
|
|
1605
1677
|
if (pos === 0) state.buf[0] = ref.id + "=" + state.buf[0];
|
|
1606
1678
|
else state.buf[pos - 1] += ref.id + "=";
|
|
1607
1679
|
return ref.id;
|
|
@@ -1618,7 +1690,7 @@ function assignId(state, ref) {
|
|
|
1618
1690
|
break;
|
|
1619
1691
|
}
|
|
1620
1692
|
}
|
|
1621
|
-
if (parent.
|
|
1693
|
+
if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
|
|
1622
1694
|
accessPrevValue = accessId(state, parent) + accessPrevValue;
|
|
1623
1695
|
break;
|
|
1624
1696
|
}
|
|
@@ -1626,13 +1698,13 @@ function assignId(state, ref) {
|
|
|
1626
1698
|
} while (cur);
|
|
1627
1699
|
return ref.id + "=" + accessPrevValue;
|
|
1628
1700
|
}
|
|
1629
|
-
function
|
|
1630
|
-
if (
|
|
1631
|
-
return
|
|
1701
|
+
function assignmentsToString(assignments, value) {
|
|
1702
|
+
if (assignments.length > 100) return "($=>(" + assignments.join("=$,") + "=$))(" + value + ")";
|
|
1703
|
+
return assignments.join("=") + "=" + value;
|
|
1632
1704
|
}
|
|
1633
1705
|
function addAssignment(ref, assign) {
|
|
1634
|
-
if (ref.
|
|
1635
|
-
else ref.
|
|
1706
|
+
if (ref.assignments) ref.assignments.push(assign);
|
|
1707
|
+
else ref.assignments = [assign];
|
|
1636
1708
|
}
|
|
1637
1709
|
function nextRefAccess(state) {
|
|
1638
1710
|
return "_." + nextId(state);
|
|
@@ -1706,12 +1778,16 @@ function forOf(list, cb) {
|
|
|
1706
1778
|
}
|
|
1707
1779
|
function forTo(to, from, step, cb) {
|
|
1708
1780
|
assertValidRangeBound("to", to);
|
|
1781
|
+
assertValidRangeStart("from", from);
|
|
1782
|
+
assertValidRangeStart("step", step);
|
|
1709
1783
|
const start = from || 0;
|
|
1710
1784
|
const delta = step || 1;
|
|
1711
1785
|
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
1712
1786
|
}
|
|
1713
1787
|
function forUntil(until, from, step, cb) {
|
|
1714
1788
|
assertValidRangeBound("until", until);
|
|
1789
|
+
assertValidRangeStart("from", from);
|
|
1790
|
+
assertValidRangeStart("step", step);
|
|
1715
1791
|
const start = from || 0;
|
|
1716
1792
|
const delta = step || 1;
|
|
1717
1793
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
@@ -1857,6 +1933,9 @@ function getContext(key) {
|
|
|
1857
1933
|
function getState() {
|
|
1858
1934
|
return $chunk.boundary.state;
|
|
1859
1935
|
}
|
|
1936
|
+
function rendererKey(renderer) {
|
|
1937
|
+
return renderer?.["owner"] === void 0 ? renderer?.["id"] || renderer : renderer["id"] + " " + renderer[Owner];
|
|
1938
|
+
}
|
|
1860
1939
|
function getScopeId(scope) {
|
|
1861
1940
|
return scope[K_SCOPE_ID];
|
|
1862
1941
|
}
|
|
@@ -1952,7 +2031,7 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
|
1952
2031
|
if (_peek_scope_id() !== branchId) {
|
|
1953
2032
|
if (shouldResume) writeScope(scopeId, {
|
|
1954
2033
|
[BranchScopes + nodeAccessor]: writeScope(branchId, {}),
|
|
1955
|
-
[ConditionalRenderer + nodeAccessor]: render
|
|
2034
|
+
[ConditionalRenderer + nodeAccessor]: rendererKey(render)
|
|
1956
2035
|
});
|
|
1957
2036
|
} else _scope_id();
|
|
1958
2037
|
}
|
|
@@ -2739,7 +2818,13 @@ function offTick(cb) {
|
|
|
2739
2818
|
function flushTickQueue() {
|
|
2740
2819
|
const queue = tickQueue;
|
|
2741
2820
|
tickQueue = void 0;
|
|
2742
|
-
for (const cb of queue)
|
|
2821
|
+
for (const cb of queue) try {
|
|
2822
|
+
cb(true);
|
|
2823
|
+
} catch (err) {
|
|
2824
|
+
tick(() => {
|
|
2825
|
+
throw err;
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2743
2828
|
}
|
|
2744
2829
|
//#endregion
|
|
2745
2830
|
//#region src/html/attrs.ts
|
|
@@ -2780,7 +2865,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
|
|
|
2780
2865
|
}
|
|
2781
2866
|
function _textarea_value(value) {
|
|
2782
2867
|
const escaped = _escape(normalizeStrAttrValue(value));
|
|
2783
|
-
return escaped[0] === "\n"
|
|
2868
|
+
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
2784
2869
|
}
|
|
2785
2870
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2786
2871
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
@@ -2844,6 +2929,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2844
2929
|
result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
|
|
2845
2930
|
skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
|
|
2846
2931
|
} else if (data.valueChange) {
|
|
2932
|
+
assertNoValueBindingOnCheckable(data.type, data.valueChange);
|
|
2847
2933
|
result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
|
|
2848
2934
|
skip = /^value(?:Change)?$|[\s/>"'=]/;
|
|
2849
2935
|
}
|
|
@@ -2876,16 +2962,14 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
|
|
|
2876
2962
|
result += _attr_style(value);
|
|
2877
2963
|
break;
|
|
2878
2964
|
default:
|
|
2879
|
-
if (name
|
|
2880
|
-
|
|
2881
|
-
if (
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
} else result += nonVoidAttr(name, value);
|
|
2888
|
-
}
|
|
2965
|
+
if (name) assertValidAttrName(name);
|
|
2966
|
+
if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
|
|
2967
|
+
if (!events) {
|
|
2968
|
+
events = {};
|
|
2969
|
+
writeScope(scopeId, { [EventAttributes + nodeAccessor]: events });
|
|
2970
|
+
}
|
|
2971
|
+
events[getEventHandlerName(name)] = value;
|
|
2972
|
+
} else result += nonVoidAttr(name, value);
|
|
2889
2973
|
break;
|
|
2890
2974
|
}
|
|
2891
2975
|
}
|
|
@@ -2901,6 +2985,10 @@ function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
|
|
|
2901
2985
|
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
2902
2986
|
if (!skip[key]) partial[key] = data[name];
|
|
2903
2987
|
}
|
|
2988
|
+
assertExclusiveAttrs({
|
|
2989
|
+
...data,
|
|
2990
|
+
...skip
|
|
2991
|
+
});
|
|
2904
2992
|
return _attrs(partial, nodeAccessor, scopeId, tagName);
|
|
2905
2993
|
}
|
|
2906
2994
|
function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, serializeReason) {
|
|
@@ -2908,15 +2996,22 @@ function _attrs_partial_content(data, skip, nodeAccessor, scopeId, tagName, seri
|
|
|
2908
2996
|
_attr_content(nodeAccessor, scopeId, data?.content, serializeReason);
|
|
2909
2997
|
}
|
|
2910
2998
|
function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2911
|
-
|
|
2912
|
-
|
|
2999
|
+
var handlerName = [
|
|
3000
|
+
"checkedChange",
|
|
3001
|
+
"checkedValueChange",
|
|
3002
|
+
"valueChange",
|
|
3003
|
+
"valueChange",
|
|
3004
|
+
"openChange"
|
|
3005
|
+
][type];
|
|
3006
|
+
assertHandlerIsFunction(handlerName, valueChange);
|
|
3007
|
+
setDebugSlotName(writeScope(scopeId, serializeType ? {
|
|
2913
3008
|
[ControlledType + nodeAccessor]: type,
|
|
2914
3009
|
[ControlledValue + nodeAccessor]: value,
|
|
2915
3010
|
[ControlledHandler + nodeAccessor]: valueChange
|
|
2916
3011
|
} : {
|
|
2917
3012
|
[ControlledValue + nodeAccessor]: value,
|
|
2918
3013
|
[ControlledHandler + nodeAccessor]: valueChange
|
|
2919
|
-
});
|
|
3014
|
+
}), ControlledHandler + nodeAccessor, handlerName);
|
|
2920
3015
|
}
|
|
2921
3016
|
function stringAttr(name, value) {
|
|
2922
3017
|
return value && " " + name + attrAssignment(value);
|
|
@@ -2930,8 +3025,8 @@ function nonVoidAttr(name, value) {
|
|
|
2930
3025
|
}
|
|
2931
3026
|
return " " + name + attrAssignment(value + "");
|
|
2932
3027
|
}
|
|
2933
|
-
const singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g;
|
|
2934
|
-
const doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g;
|
|
3028
|
+
const singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g;
|
|
3029
|
+
const doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g;
|
|
2935
3030
|
const needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g;
|
|
2936
3031
|
function attrAssignment(value) {
|
|
2937
3032
|
return value ? needsQuotedAttr.test(value) ? value[needsQuotedAttr.lastIndex - 1] === (needsQuotedAttr.lastIndex = 0, "\"") ? "='" + escapeSingleQuotedAttrValue(value) + "'" : "=\"" + escapeDoubleQuotedAttrValue(value) + "\"" : "=" + value : "";
|
|
@@ -2940,13 +3035,13 @@ function escapeSingleQuotedAttrValue(value) {
|
|
|
2940
3035
|
return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
|
|
2941
3036
|
}
|
|
2942
3037
|
function replaceUnsafeSingleQuoteAttrChar(match) {
|
|
2943
|
-
return match === "'" ? "'" : "&";
|
|
3038
|
+
return match === "'" ? "'" : match === "\r" ? " " : "&";
|
|
2944
3039
|
}
|
|
2945
3040
|
function escapeDoubleQuotedAttrValue(value) {
|
|
2946
3041
|
return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
|
|
2947
3042
|
}
|
|
2948
3043
|
function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
2949
|
-
return match === "\"" ? """ : "&";
|
|
3044
|
+
return match === "\"" ? """ : match === "\r" ? " " : "&";
|
|
2950
3045
|
}
|
|
2951
3046
|
function normalizedValueMatches(a, b) {
|
|
2952
3047
|
const value = normalizeStrAttrValue(b);
|
|
@@ -2974,21 +3069,21 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2974
3069
|
rendered = true;
|
|
2975
3070
|
const renderNative = () => {
|
|
2976
3071
|
_scope_id();
|
|
2977
|
-
_html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
|
|
3072
|
+
_html(`<${renderer}${_attrs(input, `#${renderer.toLowerCase()}/0`, branchId, renderer)}>`);
|
|
2978
3073
|
if (!voidElementsReg.test(renderer)) {
|
|
2979
3074
|
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
2980
3075
|
if (renderer === "textarea") {
|
|
2981
3076
|
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
2982
|
-
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
|
|
3077
|
+
_html(_attr_textarea_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, 1));
|
|
2983
3078
|
} else if (renderContent) {
|
|
2984
3079
|
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2985
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
|
|
2986
|
-
else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
|
|
3080
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer.toLowerCase()}/0`, input.value, input.valueChange, renderContent, 1);
|
|
3081
|
+
else _dynamic_tag(branchId, `#${renderer.toLowerCase()}/0`, renderContent, void 0, 0, void 0, serializeReason);
|
|
2987
3082
|
}
|
|
2988
3083
|
_html(`</${renderer}>`);
|
|
2989
3084
|
} else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2990
3085
|
const childScope = getScopeById(branchId);
|
|
2991
|
-
const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
|
|
3086
|
+
const needsScript = childScope && (childScope[`EventAttributes:#${renderer.toLowerCase()}/0`] || childScope[`ControlledHandler:#${renderer.toLowerCase()}/0`]);
|
|
2992
3087
|
if (needsScript) {
|
|
2993
3088
|
writeScope(branchId, { [Renderer]: renderer });
|
|
2994
3089
|
_script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
|
|
@@ -3019,16 +3114,17 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
3019
3114
|
}
|
|
3020
3115
|
}
|
|
3021
3116
|
if (rendered) {
|
|
3022
|
-
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: renderer
|
|
3117
|
+
if (shouldResume) writeScope(scopeId, { [ConditionalRenderer + accessor]: rendererKey(renderer) });
|
|
3023
3118
|
} else _scope_id();
|
|
3024
3119
|
return result;
|
|
3025
3120
|
};
|
|
3026
|
-
function _content(id, fn) {
|
|
3121
|
+
function _content(id, fn, scopeId) {
|
|
3027
3122
|
fn["id"] = id;
|
|
3123
|
+
fn[Owner] = scopeId;
|
|
3028
3124
|
return fn;
|
|
3029
3125
|
}
|
|
3030
3126
|
function _content_resume(id, fn, scopeId) {
|
|
3031
|
-
return _resume(_content(id, fn), id, scopeId);
|
|
3127
|
+
return _resume(_content(id, fn, scopeId), id, scopeId);
|
|
3032
3128
|
}
|
|
3033
3129
|
const patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
3034
3130
|
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
|
@@ -3349,14 +3445,17 @@ function writeTriggerScript(html, triggers) {
|
|
|
3349
3445
|
const exprs = triggers.map((trigger) => {
|
|
3350
3446
|
const options = trigger.options && toObjectExpression(trigger.options);
|
|
3351
3447
|
switch (trigger.type) {
|
|
3352
|
-
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(
|
|
3448
|
+
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3353
3449
|
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
3354
3450
|
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
3355
|
-
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(
|
|
3451
|
+
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
3356
3452
|
}
|
|
3357
3453
|
});
|
|
3358
3454
|
writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
|
|
3359
3455
|
}
|
|
3456
|
+
function querySelectorOrLoad(selector) {
|
|
3457
|
+
return `document.querySelector(${JSON.stringify(selector)})||${`(console.warn(${JSON.stringify(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`)}),l())`}`;
|
|
3458
|
+
}
|
|
3360
3459
|
function toObjectExpression(options) {
|
|
3361
3460
|
let result = "{";
|
|
3362
3461
|
let sep = "";
|
|
@@ -3383,6 +3482,7 @@ const compat = {
|
|
|
3383
3482
|
peekNextScopeId: _peek_scope_id,
|
|
3384
3483
|
isInResumedBranch,
|
|
3385
3484
|
withChunk,
|
|
3485
|
+
getChunk,
|
|
3386
3486
|
ensureState($global) {
|
|
3387
3487
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
3388
3488
|
if (!state) {
|
|
@@ -3424,11 +3524,18 @@ const compat = {
|
|
|
3424
3524
|
return compatRegistered;
|
|
3425
3525
|
};
|
|
3426
3526
|
},
|
|
3427
|
-
|
|
3527
|
+
createChunk($global) {
|
|
3428
3528
|
const state = this.ensureState($global);
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3529
|
+
return new Chunk(new Boundary(state), null, null, state);
|
|
3530
|
+
},
|
|
3531
|
+
flushScript($global, chunk) {
|
|
3532
|
+
chunk ||= this.createChunk($global);
|
|
3533
|
+
const { boundary } = chunk;
|
|
3534
|
+
switch (boundary.flush()) {
|
|
3535
|
+
case 2: throw boundary.signal.reason;
|
|
3536
|
+
case 1: throw new Error("Cannot serialize promise across tags/class compat layer.");
|
|
3537
|
+
}
|
|
3538
|
+
return chunk.flushScript().scripts;
|
|
3432
3539
|
},
|
|
3433
3540
|
render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
|
|
3434
3541
|
const state = this.ensureState(classAPIOut.global);
|