marko 6.0.8 → 6.0.9

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.
@@ -235,6 +235,268 @@ function isNullableExpr(expr) {
235
235
  var import_compiler24 = require("@marko/compiler");
236
236
  var import_babel_utils17 = require("@marko/compiler/babel-utils");
237
237
 
238
+ // src/html/serializer.ts
239
+ var kTouchedIterator = Symbol();
240
+ var { hasOwnProperty } = {};
241
+ var Generator = function* () {
242
+ }().constructor;
243
+ var AsyncGenerator = async function* () {
244
+ }().constructor;
245
+ patchIteratorNext(Generator.prototype);
246
+ patchIteratorNext(AsyncGenerator.prototype);
247
+ var KNOWN_SYMBOLS = (() => {
248
+ const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
249
+ for (const name2 of Object.getOwnPropertyNames(Symbol)) {
250
+ const symbol = Symbol[name2];
251
+ if (typeof symbol === "symbol") {
252
+ KNOWN_SYMBOLS2.set(symbol, "Symbol." + name2);
253
+ }
254
+ }
255
+ return KNOWN_SYMBOLS2;
256
+ })();
257
+ var KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
258
+ // This is by no means an exhaustive list,
259
+ // but it should cover most of the built-in functions.
260
+ [AggregateError, "AggregateError"],
261
+ [Array, "Array"],
262
+ [Array.from, "Array.from"],
263
+ [Array.isArray, "Array.isArray"],
264
+ [Array.of, "Array.of"],
265
+ [ArrayBuffer, "ArrayBuffer"],
266
+ [ArrayBuffer.isView, "ArrayBuffer.isView"],
267
+ [Atomics.add, "Atomics.add"],
268
+ [Atomics.and, "Atomics.and"],
269
+ [Atomics.compareExchange, "Atomics.compareExchange"],
270
+ [Atomics.exchange, "Atomics.exchange"],
271
+ [Atomics.isLockFree, "Atomics.isLockFree"],
272
+ [Atomics.load, "Atomics.load"],
273
+ [Atomics.notify, "Atomics.notify"],
274
+ [Atomics.or, "Atomics.or"],
275
+ [Atomics.store, "Atomics.store"],
276
+ [Atomics.sub, "Atomics.sub"],
277
+ [Atomics.wait, "Atomics.wait"],
278
+ [BigInt, "BigInt"],
279
+ [BigInt.asIntN, "BigInt.asIntN"],
280
+ [BigInt.asUintN, "BigInt.asUintN"],
281
+ [BigInt64Array, "BigInt64Array"],
282
+ [BigInt64Array.from, "BigInt64Array.from"],
283
+ [BigInt64Array.of, "BigInt64Array.of"],
284
+ [BigUint64Array, "BigUint64Array"],
285
+ [BigUint64Array.from, "BigUint64Array.from"],
286
+ [BigUint64Array.of, "BigUint64Array.of"],
287
+ [Boolean, "Boolean"],
288
+ [console.assert, "console.assert"],
289
+ [console.clear, "console.clear"],
290
+ [console.count, "console.count"],
291
+ [console.countReset, "console.countReset"],
292
+ [console.debug, "console.debug"],
293
+ [console.dir, "console.dir"],
294
+ [console.dirxml, "console.dirxml"],
295
+ [console.error, "console.error"],
296
+ [console.group, "console.group"],
297
+ [console.groupCollapsed, "console.groupCollapsed"],
298
+ [console.groupEnd, "console.groupEnd"],
299
+ [console.info, "console.info"],
300
+ [console.log, "console.log"],
301
+ [console.table, "console.table"],
302
+ [console.time, "console.time"],
303
+ [console.timeEnd, "console.timeEnd"],
304
+ [console.timeLog, "console.timeLog"],
305
+ [console.timeStamp, "console.timeStamp"],
306
+ [console.trace, "console.trace"],
307
+ [console.warn, "console.warn"],
308
+ [DataView, "DataView"],
309
+ [Date, "Date"],
310
+ [Date.now, "Date.now"],
311
+ [Date.parse, "Date.parse"],
312
+ [Date.UTC, "Date.UTC"],
313
+ [decodeURI, "decodeURI"],
314
+ [decodeURIComponent, "decodeURIComponent"],
315
+ [encodeURI, "encodeURI"],
316
+ [encodeURIComponent, "encodeURIComponent"],
317
+ [Error, "Error"],
318
+ [EvalError, "EvalError"],
319
+ [Float32Array, "Float32Array"],
320
+ [Float32Array.from, "Float32Array.from"],
321
+ [Float32Array.of, "Float32Array.of"],
322
+ [Float64Array, "Float64Array"],
323
+ [Float64Array.from, "Float64Array.from"],
324
+ [Float64Array.of, "Float64Array.of"],
325
+ [Function, "Function"],
326
+ [globalThis.atob, "atob"],
327
+ [globalThis.btoa, "btoa"],
328
+ [globalThis.clearImmediate, "clearImmediate"],
329
+ [globalThis.clearInterval, "clearInterval"],
330
+ [globalThis.clearTimeout, "clearTimeout"],
331
+ [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
332
+ [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
333
+ [globalThis.fetch, "fetch"],
334
+ [globalThis.performance?.now, "performance.now"],
335
+ [globalThis.queueMicrotask, "queueMicrotask"],
336
+ [globalThis.setImmediate, "setImmediate"],
337
+ [globalThis.setInterval, "setInterval"],
338
+ [globalThis.setTimeout, "setTimeout"],
339
+ [globalThis.structuredClone, "structuredClone"],
340
+ [globalThis.URL, "URL"],
341
+ [globalThis.URLSearchParams, "URLSearchParams"],
342
+ [globalThis.WritableStream, "WritableStream"],
343
+ [Int16Array, "Int16Array"],
344
+ [Int16Array.from, "Int16Array.from"],
345
+ [Int16Array.of, "Int16Array.of"],
346
+ [Int32Array, "Int32Array"],
347
+ [Int32Array.from, "Int32Array.from"],
348
+ [Int32Array.of, "Int32Array.of"],
349
+ [Int8Array, "Int8Array"],
350
+ [Int8Array.from, "Int8Array.from"],
351
+ [Int8Array.of, "Int8Array.of"],
352
+ [Intl.Collator, "Intl.Collator"],
353
+ [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
354
+ [Intl.DisplayNames, "Intl.DisplayNames"],
355
+ [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
356
+ [Intl.ListFormat, "Intl.ListFormat"],
357
+ [Intl.Locale, "Intl.Locale"],
358
+ [Intl.NumberFormat, "Intl.NumberFormat"],
359
+ [Intl.PluralRules, "Intl.PluralRules"],
360
+ [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
361
+ [Intl.Segmenter, "Intl.Segmenter"],
362
+ [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
363
+ [isFinite, "isFinite"],
364
+ [isNaN, "isNaN"],
365
+ [JSON.parse, "JSON.parse"],
366
+ [JSON.stringify, "JSON.stringify"],
367
+ [Map, "Map"],
368
+ [Map.groupBy, "Map.groupBy"],
369
+ [Math.abs, "Math.abs"],
370
+ [Math.acos, "Math.acos"],
371
+ [Math.acosh, "Math.acosh"],
372
+ [Math.asin, "Math.asin"],
373
+ [Math.asinh, "Math.asinh"],
374
+ [Math.atan, "Math.atan"],
375
+ [Math.atan2, "Math.atan2"],
376
+ [Math.atanh, "Math.atanh"],
377
+ [Math.cbrt, "Math.cbrt"],
378
+ [Math.ceil, "Math.ceil"],
379
+ [Math.clz32, "Math.clz32"],
380
+ [Math.cos, "Math.cos"],
381
+ [Math.cosh, "Math.cosh"],
382
+ [Math.exp, "Math.exp"],
383
+ [Math.expm1, "Math.expm1"],
384
+ [Math.floor, "Math.floor"],
385
+ [Math.fround, "Math.fround"],
386
+ [Math.hypot, "Math.hypot"],
387
+ [Math.imul, "Math.imul"],
388
+ [Math.log, "Math.log"],
389
+ [Math.log10, "Math.log10"],
390
+ [Math.log1p, "Math.log1p"],
391
+ [Math.log2, "Math.log2"],
392
+ [Math.max, "Math.max"],
393
+ [Math.min, "Math.min"],
394
+ [Math.pow, "Math.pow"],
395
+ [Math.random, "Math.random"],
396
+ [Math.round, "Math.round"],
397
+ [Math.sign, "Math.sign"],
398
+ [Math.sin, "Math.sin"],
399
+ [Math.sinh, "Math.sinh"],
400
+ [Math.sqrt, "Math.sqrt"],
401
+ [Math.tan, "Math.tan"],
402
+ [Math.tanh, "Math.tanh"],
403
+ [Math.trunc, "Math.trunc"],
404
+ [Number, "Number"],
405
+ [Number.isFinite, "Number.isFinite"],
406
+ [Number.isInteger, "Number.isInteger"],
407
+ [Number.isNaN, "Number.isNaN"],
408
+ [Number.isSafeInteger, "Number.isSafeInteger"],
409
+ [Number.parseFloat, "Number.parseFloat"],
410
+ [Number.parseInt, "Number.parseInt"],
411
+ [Object, "Object"],
412
+ [Object.assign, "Object.assign"],
413
+ [Object.create, "Object.create"],
414
+ [Object.defineProperties, "Object.defineProperties"],
415
+ [Object.defineProperty, "Object.defineProperty"],
416
+ [Object.entries, "Object.entries"],
417
+ [Object.freeze, "Object.freeze"],
418
+ [Object.fromEntries, "Object.fromEntries"],
419
+ [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
420
+ [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
421
+ [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
422
+ [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
423
+ [Object.getPrototypeOf, "Object.getPrototypeOf"],
424
+ [Object.is, "Object.is"],
425
+ [Object.isExtensible, "Object.isExtensible"],
426
+ [Object.isFrozen, "Object.isFrozen"],
427
+ [Object.isSealed, "Object.isSealed"],
428
+ [Object.keys, "Object.keys"],
429
+ [Object.preventExtensions, "Object.preventExtensions"],
430
+ [Object.seal, "Object.seal"],
431
+ [Object.setPrototypeOf, "Object.setPrototypeOf"],
432
+ [Object.values, "Object.values"],
433
+ [parseFloat, "parseFloat"],
434
+ [parseInt, "parseInt"],
435
+ [Promise, "Promise"],
436
+ [Proxy, "Proxy"],
437
+ [RangeError, "RangeError"],
438
+ [ReferenceError, "ReferenceError"],
439
+ [Reflect.apply, "Reflect.apply"],
440
+ [Reflect.construct, "Reflect.construct"],
441
+ [Reflect.defineProperty, "Reflect.defineProperty"],
442
+ [Reflect.deleteProperty, "Reflect.deleteProperty"],
443
+ [Reflect.get, "Reflect.get"],
444
+ [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
445
+ [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
446
+ [Reflect.has, "Reflect.has"],
447
+ [Reflect.isExtensible, "Reflect.isExtensible"],
448
+ [Reflect.ownKeys, "Reflect.ownKeys"],
449
+ [Reflect.preventExtensions, "Reflect.preventExtensions"],
450
+ [Reflect.set, "Reflect.set"],
451
+ [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
452
+ [RegExp, "RegExp"],
453
+ [Set, "Set"],
454
+ [String, "String"],
455
+ [String.fromCharCode, "String.fromCharCode"],
456
+ [String.fromCodePoint, "String.fromCodePoint"],
457
+ [String.raw, "String.raw"],
458
+ [Symbol, "Symbol"],
459
+ [Symbol.for, "Symbol.for"],
460
+ [SyntaxError, "SyntaxError"],
461
+ [TypeError, "TypeError"],
462
+ [Uint16Array, "Uint16Array"],
463
+ [Uint16Array.from, "Uint16Array.from"],
464
+ [Uint16Array.of, "Uint16Array.of"],
465
+ [Uint32Array, "Uint32Array"],
466
+ [Uint32Array.from, "Uint32Array.from"],
467
+ [Uint32Array.of, "Uint32Array.of"],
468
+ [Uint8Array, "Uint8Array"],
469
+ [Uint8Array.from, "Uint8Array.from"],
470
+ [Uint8Array.of, "Uint8Array.of"],
471
+ [Uint8ClampedArray, "Uint8ClampedArray"],
472
+ [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
473
+ [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
474
+ [URIError, "URIError"],
475
+ [WeakMap, "WeakMap"],
476
+ [WeakSet, "WeakSet"]
477
+ ]);
478
+ var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
479
+ [Atomics, "Atomics"],
480
+ [console, "console"],
481
+ [globalThis, "globalThis"],
482
+ [globalThis.crypto, "crypto"],
483
+ [Intl, "Intl"],
484
+ [JSON, "JSON"],
485
+ [Math, "Math"],
486
+ [Reflect, "Reflect"]
487
+ ]);
488
+ function toAccess(accessor) {
489
+ const start = accessor[0];
490
+ return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
491
+ }
492
+ function patchIteratorNext(proto) {
493
+ const { next } = proto;
494
+ proto.next = function(value) {
495
+ this[kTouchedIterator] = 1;
496
+ return next.call(this, value);
497
+ };
498
+ }
499
+
238
500
  // src/translator/util/for-each-identifier.ts
239
501
  function forEachIdentifier(node, cb) {
240
502
  switch (node.type) {
@@ -588,7 +850,7 @@ var Sorted = class {
588
850
  }
589
851
  if (b) {
590
852
  if (Array.isArray(b)) {
591
- return addSorted(this.compare, [...b], a);
853
+ return addSorted(this.compare, b, a);
592
854
  }
593
855
  return joinRepeatable(this.compare, b, a);
594
856
  }
@@ -735,6 +997,21 @@ function find(data, cb) {
735
997
  function toArray(data, cb) {
736
998
  return data ? Array.isArray(data) ? data.map(cb) : [cb(data, 0)] : [];
737
999
  }
1000
+ function mapToString(data, sep, cb) {
1001
+ if (data) {
1002
+ if (Array.isArray(data)) {
1003
+ let str = "";
1004
+ let curSep = "";
1005
+ for (let i = 0; i < data.length; i++) {
1006
+ str += curSep + cb(data[i], i);
1007
+ curSep = sep;
1008
+ }
1009
+ return str;
1010
+ }
1011
+ return cb(data, 0);
1012
+ }
1013
+ return "";
1014
+ }
738
1015
  function filterMap(data, cb) {
739
1016
  if (data) {
740
1017
  if (Array.isArray(data)) {
@@ -899,436 +1176,174 @@ var entry_builder_default = {
899
1176
  );
900
1177
  body.push(
901
1178
  import_compiler5.types.expressionStatement(import_compiler5.types.callExpression(import_compiler5.types.identifier("init"), []))
902
- );
903
- }
904
- return body;
905
- },
906
- visit(file, entryFile, visitChild) {
907
- const state = entryFile[kState] ||= {
908
- imports: [],
909
- init: false
910
- };
911
- const { analyzedTags } = file.metadata.marko;
912
- state.imports.push(
913
- (0, import_babel_utils6.resolveRelativePath)(entryFile, file.opts.filename)
914
- );
915
- state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
916
- for (const tag of analyzedTags || []) {
917
- visitChild(tag);
918
- }
919
- }
920
- };
921
-
922
- // src/translator/util/get-known-attr-values.ts
923
- function getKnownAttrValues(tag) {
924
- const attrs2 = {};
925
- for (const attr2 of tag.attributes) {
926
- if (attr2.type === "MarkoAttribute") {
927
- attrs2[attr2.name] = attr2.value;
928
- }
929
- }
930
- return attrs2;
931
- }
932
-
933
- // src/translator/util/is-core-tag.ts
934
- var import_babel_utils7 = require("@marko/compiler/babel-utils");
935
-
936
- // src/translator/util/get-tag-name.ts
937
- function getTagName(tag) {
938
- return tag.node.name.value;
939
- }
940
-
941
- // src/translator/util/is-core-tag.ts
942
- var { taglibId } = runtime_info_default;
943
- var htmlTaglibId = "marko-html";
944
- var interopTaglibId = "@marko/translator-interop-class-tags";
945
- function isCoreTag(tag) {
946
- if (tag.isMarkoTag()) {
947
- const tagDef = (0, import_babel_utils7.getTagDef)(tag);
948
- if (tagDef) {
949
- switch (tagDef.taglibId) {
950
- case taglibId:
951
- case interopTaglibId:
952
- return true;
953
- case htmlTaglibId:
954
- switch (tagDef.name) {
955
- case "script":
956
- case "style":
957
- return true;
958
- }
959
- break;
960
- }
961
- }
962
- }
963
- return false;
964
- }
965
- function isCoreTagName(tag, name2) {
966
- return isCoreTag(tag) && getTagName(tag) === name2;
967
- }
968
- function isConditionTag(tag) {
969
- if (isCoreTag(tag)) {
970
- switch (getTagName(tag)) {
971
- case "if":
972
- case "else-if":
973
- case "else":
974
- return true;
975
- }
976
- }
977
- return false;
978
- }
979
- function isControlFlowTag(tag) {
980
- if (isCoreTag(tag)) {
981
- switch (getTagName(tag)) {
982
- case "if":
983
- case "else-if":
984
- case "else":
985
- case "for":
986
- case "await":
987
- case "try":
988
- return true;
989
- }
990
- }
991
- return false;
992
- }
993
-
994
- // src/translator/util/runtime.ts
995
- var import_compiler7 = require("@marko/compiler");
996
- var import_babel_utils8 = require("@marko/compiler/babel-utils");
997
-
998
- // src/common/attr-tag.ts
999
- var rest = false ? Symbol("Attribute Tag") : Symbol();
1000
-
1001
- // src/common/helpers.ts
1002
- function classValue(classValue2) {
1003
- return toDelimitedString(classValue2, " ", stringifyClassObject);
1004
- }
1005
- function stringifyClassObject(name2, value) {
1006
- return value ? name2 : "";
1007
- }
1008
- function styleValue(styleValue2) {
1009
- return toDelimitedString(styleValue2, ";", stringifyStyleObject);
1010
- }
1011
- function stringifyStyleObject(name2, value) {
1012
- return value || value === 0 ? name2 + ":" + value : "";
1013
- }
1014
- function toDelimitedString(val, delimiter, stringify) {
1015
- let str = "";
1016
- let sep = "";
1017
- let part;
1018
- if (val) {
1019
- if (typeof val !== "object") {
1020
- str += val;
1021
- } else if (Array.isArray(val)) {
1022
- for (const v of val) {
1023
- part = toDelimitedString(v, delimiter, stringify);
1024
- if (part) {
1025
- str += sep + part;
1026
- sep = delimiter;
1027
- }
1028
- }
1029
- } else {
1030
- for (const name2 in val) {
1031
- part = stringify(name2, val[name2]);
1032
- if (part) {
1033
- str += sep + part;
1034
- sep = delimiter;
1035
- }
1036
- }
1037
- }
1038
- }
1039
- return str;
1040
- }
1041
- function isEventHandler(name2) {
1042
- return /^on[A-Z-]/.test(name2);
1043
- }
1044
- function getEventHandlerName(name2) {
1045
- return name2[2] === "-" ? name2.slice(3) : name2.slice(2).toLowerCase();
1046
- }
1047
- function isVoid(value) {
1048
- return value == null || value === false;
1049
- }
1050
-
1051
- // src/html/content.ts
1052
- function toString(val) {
1053
- return val ? val + "" : val === 0 ? "0" : "";
1054
- }
1055
- var unsafeXMLReg = /[<&]/g;
1056
- var replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;";
1057
- var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
1058
- function escapeXML(val) {
1059
- return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
1060
- }
1061
- var unsafeScriptReg = /<\/script/g;
1062
- var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
1063
- function escapeScript(val) {
1064
- return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
1065
- }
1066
- var unsafeStyleReg = /<\/style/g;
1067
- var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
1068
- function escapeStyle(val) {
1069
- return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
1070
- }
1071
-
1072
- // src/html/serializer.ts
1073
- var kTouchedIterator = Symbol();
1074
- var { hasOwnProperty } = {};
1075
- var Generator = function* () {
1076
- }().constructor;
1077
- var AsyncGenerator = async function* () {
1078
- }().constructor;
1079
- patchIteratorNext(Generator.prototype);
1080
- patchIteratorNext(AsyncGenerator.prototype);
1081
- var KNOWN_SYMBOLS = (() => {
1082
- const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
1083
- for (const name2 of Object.getOwnPropertyNames(Symbol)) {
1084
- const symbol = Symbol[name2];
1085
- if (typeof symbol === "symbol") {
1086
- KNOWN_SYMBOLS2.set(symbol, "Symbol." + name2);
1179
+ );
1180
+ }
1181
+ return body;
1182
+ },
1183
+ visit(file, entryFile, visitChild) {
1184
+ const state = entryFile[kState] ||= {
1185
+ imports: [],
1186
+ init: false
1187
+ };
1188
+ const { analyzedTags } = file.metadata.marko;
1189
+ state.imports.push(
1190
+ (0, import_babel_utils6.resolveRelativePath)(entryFile, file.opts.filename)
1191
+ );
1192
+ state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
1193
+ for (const tag of analyzedTags || []) {
1194
+ visitChild(tag);
1087
1195
  }
1088
1196
  }
1089
- return KNOWN_SYMBOLS2;
1090
- })();
1091
- var KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
1092
- // This is by no means an exhaustive list,
1093
- // but it should cover most of the built-in functions.
1094
- [AggregateError, "AggregateError"],
1095
- [Array, "Array"],
1096
- [Array.from, "Array.from"],
1097
- [Array.isArray, "Array.isArray"],
1098
- [Array.of, "Array.of"],
1099
- [ArrayBuffer, "ArrayBuffer"],
1100
- [ArrayBuffer.isView, "ArrayBuffer.isView"],
1101
- [Atomics.add, "Atomics.add"],
1102
- [Atomics.and, "Atomics.and"],
1103
- [Atomics.compareExchange, "Atomics.compareExchange"],
1104
- [Atomics.exchange, "Atomics.exchange"],
1105
- [Atomics.isLockFree, "Atomics.isLockFree"],
1106
- [Atomics.load, "Atomics.load"],
1107
- [Atomics.notify, "Atomics.notify"],
1108
- [Atomics.or, "Atomics.or"],
1109
- [Atomics.store, "Atomics.store"],
1110
- [Atomics.sub, "Atomics.sub"],
1111
- [Atomics.wait, "Atomics.wait"],
1112
- [BigInt, "BigInt"],
1113
- [BigInt.asIntN, "BigInt.asIntN"],
1114
- [BigInt.asUintN, "BigInt.asUintN"],
1115
- [BigInt64Array, "BigInt64Array"],
1116
- [BigInt64Array.from, "BigInt64Array.from"],
1117
- [BigInt64Array.of, "BigInt64Array.of"],
1118
- [BigUint64Array, "BigUint64Array"],
1119
- [BigUint64Array.from, "BigUint64Array.from"],
1120
- [BigUint64Array.of, "BigUint64Array.of"],
1121
- [Boolean, "Boolean"],
1122
- [console.assert, "console.assert"],
1123
- [console.clear, "console.clear"],
1124
- [console.count, "console.count"],
1125
- [console.countReset, "console.countReset"],
1126
- [console.debug, "console.debug"],
1127
- [console.dir, "console.dir"],
1128
- [console.dirxml, "console.dirxml"],
1129
- [console.error, "console.error"],
1130
- [console.group, "console.group"],
1131
- [console.groupCollapsed, "console.groupCollapsed"],
1132
- [console.groupEnd, "console.groupEnd"],
1133
- [console.info, "console.info"],
1134
- [console.log, "console.log"],
1135
- [console.table, "console.table"],
1136
- [console.time, "console.time"],
1137
- [console.timeEnd, "console.timeEnd"],
1138
- [console.timeLog, "console.timeLog"],
1139
- [console.timeStamp, "console.timeStamp"],
1140
- [console.trace, "console.trace"],
1141
- [console.warn, "console.warn"],
1142
- [DataView, "DataView"],
1143
- [Date, "Date"],
1144
- [Date.now, "Date.now"],
1145
- [Date.parse, "Date.parse"],
1146
- [Date.UTC, "Date.UTC"],
1147
- [decodeURI, "decodeURI"],
1148
- [decodeURIComponent, "decodeURIComponent"],
1149
- [encodeURI, "encodeURI"],
1150
- [encodeURIComponent, "encodeURIComponent"],
1151
- [Error, "Error"],
1152
- [EvalError, "EvalError"],
1153
- [Float32Array, "Float32Array"],
1154
- [Float32Array.from, "Float32Array.from"],
1155
- [Float32Array.of, "Float32Array.of"],
1156
- [Float64Array, "Float64Array"],
1157
- [Float64Array.from, "Float64Array.from"],
1158
- [Float64Array.of, "Float64Array.of"],
1159
- [Function, "Function"],
1160
- [globalThis.atob, "atob"],
1161
- [globalThis.btoa, "btoa"],
1162
- [globalThis.clearImmediate, "clearImmediate"],
1163
- [globalThis.clearInterval, "clearInterval"],
1164
- [globalThis.clearTimeout, "clearTimeout"],
1165
- [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
1166
- [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
1167
- [globalThis.fetch, "fetch"],
1168
- [globalThis.performance?.now, "performance.now"],
1169
- [globalThis.queueMicrotask, "queueMicrotask"],
1170
- [globalThis.setImmediate, "setImmediate"],
1171
- [globalThis.setInterval, "setInterval"],
1172
- [globalThis.setTimeout, "setTimeout"],
1173
- [globalThis.structuredClone, "structuredClone"],
1174
- [globalThis.URL, "URL"],
1175
- [globalThis.URLSearchParams, "URLSearchParams"],
1176
- [globalThis.WritableStream, "WritableStream"],
1177
- [Int16Array, "Int16Array"],
1178
- [Int16Array.from, "Int16Array.from"],
1179
- [Int16Array.of, "Int16Array.of"],
1180
- [Int32Array, "Int32Array"],
1181
- [Int32Array.from, "Int32Array.from"],
1182
- [Int32Array.of, "Int32Array.of"],
1183
- [Int8Array, "Int8Array"],
1184
- [Int8Array.from, "Int8Array.from"],
1185
- [Int8Array.of, "Int8Array.of"],
1186
- [Intl.Collator, "Intl.Collator"],
1187
- [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
1188
- [Intl.DisplayNames, "Intl.DisplayNames"],
1189
- [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
1190
- [Intl.ListFormat, "Intl.ListFormat"],
1191
- [Intl.Locale, "Intl.Locale"],
1192
- [Intl.NumberFormat, "Intl.NumberFormat"],
1193
- [Intl.PluralRules, "Intl.PluralRules"],
1194
- [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
1195
- [Intl.Segmenter, "Intl.Segmenter"],
1196
- [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
1197
- [isFinite, "isFinite"],
1198
- [isNaN, "isNaN"],
1199
- [JSON.parse, "JSON.parse"],
1200
- [JSON.stringify, "JSON.stringify"],
1201
- [Map, "Map"],
1202
- [Map.groupBy, "Map.groupBy"],
1203
- [Math.abs, "Math.abs"],
1204
- [Math.acos, "Math.acos"],
1205
- [Math.acosh, "Math.acosh"],
1206
- [Math.asin, "Math.asin"],
1207
- [Math.asinh, "Math.asinh"],
1208
- [Math.atan, "Math.atan"],
1209
- [Math.atan2, "Math.atan2"],
1210
- [Math.atanh, "Math.atanh"],
1211
- [Math.cbrt, "Math.cbrt"],
1212
- [Math.ceil, "Math.ceil"],
1213
- [Math.clz32, "Math.clz32"],
1214
- [Math.cos, "Math.cos"],
1215
- [Math.cosh, "Math.cosh"],
1216
- [Math.exp, "Math.exp"],
1217
- [Math.expm1, "Math.expm1"],
1218
- [Math.floor, "Math.floor"],
1219
- [Math.fround, "Math.fround"],
1220
- [Math.hypot, "Math.hypot"],
1221
- [Math.imul, "Math.imul"],
1222
- [Math.log, "Math.log"],
1223
- [Math.log10, "Math.log10"],
1224
- [Math.log1p, "Math.log1p"],
1225
- [Math.log2, "Math.log2"],
1226
- [Math.max, "Math.max"],
1227
- [Math.min, "Math.min"],
1228
- [Math.pow, "Math.pow"],
1229
- [Math.random, "Math.random"],
1230
- [Math.round, "Math.round"],
1231
- [Math.sign, "Math.sign"],
1232
- [Math.sin, "Math.sin"],
1233
- [Math.sinh, "Math.sinh"],
1234
- [Math.sqrt, "Math.sqrt"],
1235
- [Math.tan, "Math.tan"],
1236
- [Math.tanh, "Math.tanh"],
1237
- [Math.trunc, "Math.trunc"],
1238
- [Number, "Number"],
1239
- [Number.isFinite, "Number.isFinite"],
1240
- [Number.isInteger, "Number.isInteger"],
1241
- [Number.isNaN, "Number.isNaN"],
1242
- [Number.isSafeInteger, "Number.isSafeInteger"],
1243
- [Number.parseFloat, "Number.parseFloat"],
1244
- [Number.parseInt, "Number.parseInt"],
1245
- [Object, "Object"],
1246
- [Object.assign, "Object.assign"],
1247
- [Object.create, "Object.create"],
1248
- [Object.defineProperties, "Object.defineProperties"],
1249
- [Object.defineProperty, "Object.defineProperty"],
1250
- [Object.entries, "Object.entries"],
1251
- [Object.freeze, "Object.freeze"],
1252
- [Object.fromEntries, "Object.fromEntries"],
1253
- [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
1254
- [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
1255
- [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
1256
- [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
1257
- [Object.getPrototypeOf, "Object.getPrototypeOf"],
1258
- [Object.is, "Object.is"],
1259
- [Object.isExtensible, "Object.isExtensible"],
1260
- [Object.isFrozen, "Object.isFrozen"],
1261
- [Object.isSealed, "Object.isSealed"],
1262
- [Object.keys, "Object.keys"],
1263
- [Object.preventExtensions, "Object.preventExtensions"],
1264
- [Object.seal, "Object.seal"],
1265
- [Object.setPrototypeOf, "Object.setPrototypeOf"],
1266
- [Object.values, "Object.values"],
1267
- [parseFloat, "parseFloat"],
1268
- [parseInt, "parseInt"],
1269
- [Promise, "Promise"],
1270
- [Proxy, "Proxy"],
1271
- [RangeError, "RangeError"],
1272
- [ReferenceError, "ReferenceError"],
1273
- [Reflect.apply, "Reflect.apply"],
1274
- [Reflect.construct, "Reflect.construct"],
1275
- [Reflect.defineProperty, "Reflect.defineProperty"],
1276
- [Reflect.deleteProperty, "Reflect.deleteProperty"],
1277
- [Reflect.get, "Reflect.get"],
1278
- [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
1279
- [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
1280
- [Reflect.has, "Reflect.has"],
1281
- [Reflect.isExtensible, "Reflect.isExtensible"],
1282
- [Reflect.ownKeys, "Reflect.ownKeys"],
1283
- [Reflect.preventExtensions, "Reflect.preventExtensions"],
1284
- [Reflect.set, "Reflect.set"],
1285
- [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
1286
- [RegExp, "RegExp"],
1287
- [Set, "Set"],
1288
- [String, "String"],
1289
- [String.fromCharCode, "String.fromCharCode"],
1290
- [String.fromCodePoint, "String.fromCodePoint"],
1291
- [String.raw, "String.raw"],
1292
- [Symbol, "Symbol"],
1293
- [Symbol.for, "Symbol.for"],
1294
- [SyntaxError, "SyntaxError"],
1295
- [TypeError, "TypeError"],
1296
- [Uint16Array, "Uint16Array"],
1297
- [Uint16Array.from, "Uint16Array.from"],
1298
- [Uint16Array.of, "Uint16Array.of"],
1299
- [Uint32Array, "Uint32Array"],
1300
- [Uint32Array.from, "Uint32Array.from"],
1301
- [Uint32Array.of, "Uint32Array.of"],
1302
- [Uint8Array, "Uint8Array"],
1303
- [Uint8Array.from, "Uint8Array.from"],
1304
- [Uint8Array.of, "Uint8Array.of"],
1305
- [Uint8ClampedArray, "Uint8ClampedArray"],
1306
- [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
1307
- [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
1308
- [URIError, "URIError"],
1309
- [WeakMap, "WeakMap"],
1310
- [WeakSet, "WeakSet"]
1311
- ]);
1312
- var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
1313
- [Atomics, "Atomics"],
1314
- [console, "console"],
1315
- [globalThis, "globalThis"],
1316
- [globalThis.crypto, "crypto"],
1317
- [Intl, "Intl"],
1318
- [JSON, "JSON"],
1319
- [Math, "Math"],
1320
- [Reflect, "Reflect"]
1321
- ]);
1322
- function toAccess(accessor) {
1323
- const start = accessor[0];
1324
- return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1197
+ };
1198
+
1199
+ // src/translator/util/get-known-attr-values.ts
1200
+ function getKnownAttrValues(tag) {
1201
+ const attrs2 = {};
1202
+ for (const attr2 of tag.attributes) {
1203
+ if (attr2.type === "MarkoAttribute") {
1204
+ attrs2[attr2.name] = attr2.value;
1205
+ }
1206
+ }
1207
+ return attrs2;
1325
1208
  }
1326
- function patchIteratorNext(proto) {
1327
- const { next } = proto;
1328
- proto.next = function(value) {
1329
- this[kTouchedIterator] = 1;
1330
- return next.call(this, value);
1331
- };
1209
+
1210
+ // src/translator/util/is-core-tag.ts
1211
+ var import_babel_utils7 = require("@marko/compiler/babel-utils");
1212
+
1213
+ // src/translator/util/get-tag-name.ts
1214
+ function getTagName(tag) {
1215
+ return tag.node.name.value;
1216
+ }
1217
+
1218
+ // src/translator/util/is-core-tag.ts
1219
+ var { taglibId } = runtime_info_default;
1220
+ var htmlTaglibId = "marko-html";
1221
+ var interopTaglibId = "@marko/translator-interop-class-tags";
1222
+ function isCoreTag(tag) {
1223
+ if (tag.isMarkoTag()) {
1224
+ const tagDef = (0, import_babel_utils7.getTagDef)(tag);
1225
+ if (tagDef) {
1226
+ switch (tagDef.taglibId) {
1227
+ case taglibId:
1228
+ case interopTaglibId:
1229
+ return true;
1230
+ case htmlTaglibId:
1231
+ switch (tagDef.name) {
1232
+ case "script":
1233
+ case "style":
1234
+ return true;
1235
+ }
1236
+ break;
1237
+ }
1238
+ }
1239
+ }
1240
+ return false;
1241
+ }
1242
+ function isCoreTagName(tag, name2) {
1243
+ return isCoreTag(tag) && getTagName(tag) === name2;
1244
+ }
1245
+ function isConditionTag(tag) {
1246
+ if (isCoreTag(tag)) {
1247
+ switch (getTagName(tag)) {
1248
+ case "if":
1249
+ case "else-if":
1250
+ case "else":
1251
+ return true;
1252
+ }
1253
+ }
1254
+ return false;
1255
+ }
1256
+ function isControlFlowTag(tag) {
1257
+ if (isCoreTag(tag)) {
1258
+ switch (getTagName(tag)) {
1259
+ case "if":
1260
+ case "else-if":
1261
+ case "else":
1262
+ case "for":
1263
+ case "await":
1264
+ case "try":
1265
+ return true;
1266
+ }
1267
+ }
1268
+ return false;
1269
+ }
1270
+
1271
+ // src/translator/util/runtime.ts
1272
+ var import_compiler7 = require("@marko/compiler");
1273
+ var import_babel_utils8 = require("@marko/compiler/babel-utils");
1274
+
1275
+ // src/common/attr-tag.ts
1276
+ var rest = false ? Symbol("Attribute Tag") : Symbol();
1277
+
1278
+ // src/common/helpers.ts
1279
+ function classValue(classValue2) {
1280
+ return toDelimitedString(classValue2, " ", stringifyClassObject);
1281
+ }
1282
+ function stringifyClassObject(name2, value) {
1283
+ return value ? name2 : "";
1284
+ }
1285
+ function styleValue(styleValue2) {
1286
+ return toDelimitedString(styleValue2, ";", stringifyStyleObject);
1287
+ }
1288
+ function stringifyStyleObject(name2, value) {
1289
+ return value || value === 0 ? name2 + ":" + value : "";
1290
+ }
1291
+ function toDelimitedString(val, delimiter, stringify) {
1292
+ let str = "";
1293
+ let sep = "";
1294
+ let part;
1295
+ if (val) {
1296
+ if (typeof val !== "object") {
1297
+ str += val;
1298
+ } else if (Array.isArray(val)) {
1299
+ for (const v of val) {
1300
+ part = toDelimitedString(v, delimiter, stringify);
1301
+ if (part) {
1302
+ str += sep + part;
1303
+ sep = delimiter;
1304
+ }
1305
+ }
1306
+ } else {
1307
+ for (const name2 in val) {
1308
+ part = stringify(name2, val[name2]);
1309
+ if (part) {
1310
+ str += sep + part;
1311
+ sep = delimiter;
1312
+ }
1313
+ }
1314
+ }
1315
+ }
1316
+ return str;
1317
+ }
1318
+ function isEventHandler(name2) {
1319
+ return /^on[A-Z-]/.test(name2);
1320
+ }
1321
+ function getEventHandlerName(name2) {
1322
+ return name2[2] === "-" ? name2.slice(3) : name2.slice(2).toLowerCase();
1323
+ }
1324
+ function isVoid(value) {
1325
+ return value == null || value === false;
1326
+ }
1327
+
1328
+ // src/html/content.ts
1329
+ function toString(val) {
1330
+ return val ? val + "" : val === 0 ? "0" : "";
1331
+ }
1332
+ var unsafeXMLReg = /[<&]/g;
1333
+ var replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;";
1334
+ var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
1335
+ function escapeXML(val) {
1336
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
1337
+ }
1338
+ var unsafeScriptReg = /<\/script/g;
1339
+ var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
1340
+ function escapeScript(val) {
1341
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
1342
+ }
1343
+ var unsafeStyleReg = /<\/style/g;
1344
+ var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
1345
+ function escapeStyle(val) {
1346
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
1332
1347
  }
1333
1348
 
1334
1349
  // src/html/writer.ts
@@ -1609,9 +1624,7 @@ function addSectionSerializeReasonRef(section, ref, prop) {
1609
1624
  forceSectionSerialize(section);
1610
1625
  } else {
1611
1626
  const reason = getSerializeSourcesForRef(ref);
1612
- if (reason === true) {
1613
- forceSectionSerialize(section);
1614
- } else {
1627
+ if (reason) {
1615
1628
  setSectionSerializeReason(
1616
1629
  section,
1617
1630
  mergeSerializeReasons(existingReason, reason)
@@ -1629,9 +1642,7 @@ function addKeyedSerializeReasonRef(section, key, ref) {
1629
1642
  forceSerializeKey(section, key);
1630
1643
  } else {
1631
1644
  const reason = getSerializeSourcesForRef(ref);
1632
- if (reason === true) {
1633
- forceSerializeKey(section, key);
1634
- } else {
1645
+ if (reason) {
1635
1646
  setSectionKeyedSerializeReason(
1636
1647
  section,
1637
1648
  key,
@@ -1757,7 +1768,9 @@ function finalizeSectionSerializeReasons(section) {
1757
1768
  }
1758
1769
  reason = mergeSerializeReasons(reason, keyedReason);
1759
1770
  }
1760
- setSectionSerializeReason(section, reason);
1771
+ if (reason) {
1772
+ setSectionSerializeReason(section, reason);
1773
+ }
1761
1774
  }
1762
1775
  }
1763
1776
  function getSerializeSourcesForExpr(expr) {
@@ -1768,13 +1781,11 @@ function getSerializeSourcesForExpr(expr) {
1768
1781
  function getSerializeSourcesForExprs(exprs) {
1769
1782
  if (exprs) {
1770
1783
  if (Array.isArray(exprs)) {
1771
- let serializeSource;
1784
+ let allSources;
1772
1785
  for (const expr of exprs) {
1773
- const exprSources = getSerializeSourcesForExpr(expr);
1774
- if (exprSources === true) return true;
1775
- serializeSource = bindingUtil.union(serializeSource, exprSources);
1786
+ allSources = mergeSources(allSources, getSerializeSourcesForExpr(expr));
1776
1787
  }
1777
- return serializeSource;
1788
+ return allSources;
1778
1789
  } else {
1779
1790
  return getSerializeSourcesForExpr(exprs);
1780
1791
  }
@@ -1782,24 +1793,20 @@ function getSerializeSourcesForExprs(exprs) {
1782
1793
  }
1783
1794
  function getSerializeSourcesForRef(ref) {
1784
1795
  if (ref) {
1785
- let allSerializeSources;
1796
+ let allSources;
1786
1797
  if (Array.isArray(ref)) {
1787
- for (const { serializeSources } of ref) {
1788
- if (serializeSources === true) return serializeSources;
1789
- allSerializeSources = bindingUtil.union(
1790
- allSerializeSources,
1791
- serializeSources
1792
- );
1798
+ for (const { sources } of ref) {
1799
+ allSources = mergeSources(allSources, sources);
1793
1800
  }
1794
- return allSerializeSources;
1801
+ return allSources;
1795
1802
  } else {
1796
- return ref.serializeSources;
1803
+ return ref.sources;
1797
1804
  }
1798
1805
  }
1799
1806
  }
1800
1807
  function mergeSerializeReasons(a, b) {
1801
1808
  if (a === true || b === true) return true;
1802
- return bindingUtil.union(a, b);
1809
+ return mergeSources(a, b);
1803
1810
  }
1804
1811
  function setSectionSerializeReason(section, reason) {
1805
1812
  section.serializeReason = reason;
@@ -2347,35 +2354,77 @@ function simplifyFunction(fn) {
2347
2354
  }
2348
2355
  }
2349
2356
 
2357
+ // src/translator/util/with-comment.ts
2358
+ function withLeadingComment(node, value) {
2359
+ const comment = {
2360
+ type: "CommentBlock",
2361
+ value: ` ${value} `
2362
+ };
2363
+ node.leadingComments = node.leadingComments ? [...node.leadingComments, comment] : [comment];
2364
+ return node;
2365
+ }
2366
+
2350
2367
  // src/translator/visitors/program/html.ts
2351
2368
  function getTemplateContentName() {
2352
2369
  return getSharedUid("content");
2353
2370
  }
2371
+ function getSerializeGuard(reason, optional) {
2372
+ return !reason ? import_compiler13.types.numericLiteral(0) : reason === true || reason.state ? optional ? void 0 : reason === true ? import_compiler13.types.numericLiteral(1) : withLeadingComment(
2373
+ import_compiler13.types.numericLiteral(1),
2374
+ `state: ${mapToString(reason.state, ", ", getDebugName)}`
2375
+ ) : getInputSerializeReasonGuard(reason.input);
2376
+ }
2377
+ function getSerializeGuardForAny(reasons, optional) {
2378
+ if (!reasons || reasons === true) {
2379
+ return getSerializeGuard(reasons, optional);
2380
+ }
2381
+ if (reasons.length === 1) {
2382
+ return getSerializeGuard(reasons[0], optional);
2383
+ }
2384
+ let expr;
2385
+ for (const reason of reasons) {
2386
+ if (reason.state) {
2387
+ return optional ? void 0 : withLeadingComment(
2388
+ import_compiler13.types.numericLiteral(1),
2389
+ `state: ${mapToString(reason.state, ", ", getDebugName)}`
2390
+ );
2391
+ }
2392
+ const guard = getSerializeGuard(reason, false);
2393
+ expr = expr ? import_compiler13.types.logicalExpression("||", expr, guard) : guard;
2394
+ }
2395
+ return expr;
2396
+ }
2354
2397
  function getExprIfSerialized(reason, expr) {
2355
- return reason ? reason === true ? expr : import_compiler13.types.logicalExpression(
2398
+ return reason ? reason === true || reason.state ? expr : import_compiler13.types.logicalExpression(
2356
2399
  "&&",
2357
2400
  callRuntime(
2358
2401
  "serializeIf",
2359
2402
  import_compiler13.types.identifier(getSharedUid("serialize")),
2360
- import_compiler13.types.numericLiteral(
2361
- resolveSerializeReasonId(
2362
- (0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
2363
- reason
2364
- )
2403
+ withLeadingComment(
2404
+ import_compiler13.types.numericLiteral(
2405
+ resolveSerializeReasonId(
2406
+ (0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
2407
+ reason.input
2408
+ )
2409
+ ),
2410
+ mapToString(reason.input, ", ", getInputDebugName)
2365
2411
  )
2366
2412
  ),
2367
2413
  expr
2368
2414
  ) : void 0;
2369
2415
  }
2370
- function getSerializeGuard(reason) {
2416
+ function getInputSerializeReasonGuard(reason) {
2371
2417
  return callRuntime(
2372
2418
  "serializeGuard",
2373
2419
  import_compiler13.types.identifier(getSharedUid("serialize")),
2374
- import_compiler13.types.numericLiteral(
2375
- resolveSerializeReasonId(
2376
- (0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
2377
- reason
2378
- )
2420
+ withLeadingComment(
2421
+ import_compiler13.types.numericLiteral(
2422
+ resolveSerializeReasonId(
2423
+ (0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
2424
+ reason
2425
+ )
2426
+ ),
2427
+ mapToString(reason, ",", getDebugName)
2379
2428
  )
2380
2429
  );
2381
2430
  }
@@ -2700,12 +2749,7 @@ function getWalkString(section) {
2700
2749
  const walks = getWalks(section);
2701
2750
  const walkLiteral = normalizeStringExpression([prefix2, ...walks, postfix]);
2702
2751
  if (walkLiteral && walkLiteral.value !== "") {
2703
- walkLiteral.leadingComments = [
2704
- {
2705
- type: "CommentBlock",
2706
- value: " " + getWalkComment(section).join(", ") + " "
2707
- }
2708
- ];
2752
+ withLeadingComment(walkLiteral, getWalkComment(section).join(", "));
2709
2753
  }
2710
2754
  return walkLiteral;
2711
2755
  }
@@ -2790,7 +2834,7 @@ function markNode(path5, nodeBinding, reason) {
2790
2834
  "markResumeNode",
2791
2835
  getScopeIdIdentifier(section),
2792
2836
  getScopeAccessorLiteral(nodeBinding),
2793
- reason === true ? void 0 : getSerializeGuard(reason)
2837
+ getSerializeGuard(reason, true)
2794
2838
  )}`;
2795
2839
  }
2796
2840
  }
@@ -3734,7 +3778,7 @@ function writeHTMLResumeStatements(path5) {
3734
3778
  serializedProperties.push(
3735
3779
  toObjectProperty(
3736
3780
  accessor,
3737
- sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSerializeReasons(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(reason, getDeclaredBindingExpression(binding))
3781
+ sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSources(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(reason, getDeclaredBindingExpression(binding))
3738
3782
  )
3739
3783
  );
3740
3784
  });
@@ -3750,7 +3794,7 @@ function writeHTMLResumeStatements(path5) {
3750
3794
  serializedProperties.push(
3751
3795
  toObjectProperty(
3752
3796
  ownerAccessor,
3753
- sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSerializeReasons(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(ownerReason, getOwnerExpr)
3797
+ sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSources(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(ownerReason, getOwnerExpr)
3754
3798
  )
3755
3799
  );
3756
3800
  }
@@ -3777,14 +3821,7 @@ function writeHTMLResumeStatements(path5) {
3777
3821
  if (binding.type === 0 /* dom */) return;
3778
3822
  const serializeReason = getBindingSerializeReason(section, binding);
3779
3823
  if (!serializeReason) return;
3780
- let root = binding;
3781
- let access = "";
3782
- while (!(root.loc || root.declared) && root.upstreamAlias) {
3783
- if (root.property !== void 0) {
3784
- access = toAccess(root.property) + access;
3785
- }
3786
- root = root.upstreamAlias;
3787
- }
3824
+ const { root, access } = getDebugScopeAccess(binding);
3788
3825
  const locExpr = root.loc && import_compiler20.types.stringLiteral(
3789
3826
  `${root.loc.start.line}:${root.loc.start.column + 1}`
3790
3827
  );
@@ -3808,10 +3845,10 @@ function writeHTMLResumeStatements(path5) {
3808
3845
  }
3809
3846
  }
3810
3847
  let writeScopeCall = writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs);
3811
- if (sectionSerializeReason !== true) {
3848
+ if (sectionSerializeReason !== true && !sectionSerializeReason.state) {
3812
3849
  writeScopeCall = import_compiler20.types.logicalExpression(
3813
3850
  "&&",
3814
- getSerializeGuard(sectionSerializeReason),
3851
+ getSerializeGuard(sectionSerializeReason, false),
3815
3852
  writeScopeCall
3816
3853
  );
3817
3854
  }
@@ -4223,11 +4260,7 @@ var program_default = {
4223
4260
  }
4224
4261
  };
4225
4262
  function resolveSerializeReasonId(inputSerializeReasons, reason) {
4226
- const id = findIndexSorted(
4227
- compareSerializeReasons,
4228
- inputSerializeReasons,
4229
- reason
4230
- );
4263
+ const id = findIndexSorted(compareReferences, inputSerializeReasons, reason);
4231
4264
  if (id === -1) {
4232
4265
  throw new Error("Unable to resolve serialize reason against input");
4233
4266
  }
@@ -4340,7 +4373,6 @@ function createBinding(name2, type, section, upstreamAlias, property, loc = null
4340
4373
  closureSections: void 0,
4341
4374
  assignmentSections: void 0,
4342
4375
  excludeProperties: void 0,
4343
- serializeSources: void 0,
4344
4376
  sources: void 0,
4345
4377
  aliases: /* @__PURE__ */ new Set(),
4346
4378
  hoists: /* @__PURE__ */ new Map(),
@@ -4649,8 +4681,8 @@ function mergeReferences(section, target, nodes) {
4649
4681
  getMergedReferences().set(target, nodes);
4650
4682
  return targetExtra;
4651
4683
  }
4652
- function compareSerializeReasons(a, b) {
4653
- return Array.isArray(a) ? Array.isArray(b) ? compareIntersections(a, b) : -1 : Array.isArray(b) ? 1 : bindingUtil.compare(a, b);
4684
+ function compareReferences(a, b) {
4685
+ return a === b ? 0 : Array.isArray(a) ? Array.isArray(b) ? compareIntersections(a, b) : -1 : Array.isArray(b) ? 1 : bindingUtil.compare(a, b);
4654
4686
  }
4655
4687
  function compareIntersections(a, b) {
4656
4688
  const len = a.length;
@@ -4753,7 +4785,7 @@ function finalizeReferences() {
4753
4785
  addOwnersSerializeReason(
4754
4786
  section2,
4755
4787
  binding.section,
4756
- binding.serializeSources,
4788
+ binding.sources,
4757
4789
  getAccessorProp().Owner
4758
4790
  );
4759
4791
  }
@@ -4804,18 +4836,44 @@ function finalizeReferences() {
4804
4836
  for (let j = i + 1; j < numReferences; j++) {
4805
4837
  const binding1 = intersection[i];
4806
4838
  const binding2 = intersection[j];
4807
- if (!isBindingForceSerialized(section, binding1) && !bindingUtil.isSuperset(binding1.sources, binding2.sources)) {
4839
+ if (!isBindingForceSerialized(section, binding1) && !isSupersetSources(binding1, binding2)) {
4840
+ if (!isSameOrChildSection(section, binding1.section)) {
4841
+ addOwnersSerializeReason(
4842
+ section,
4843
+ binding1.section,
4844
+ mergeSerializeReasons(
4845
+ // TODO should check for an actual intersection, not just stateful
4846
+ binding1.sources,
4847
+ binding2.sources
4848
+ ),
4849
+ getAccessorProp().Owner
4850
+ );
4851
+ }
4808
4852
  addBindingSerializeReason(
4809
- section,
4853
+ binding1.section,
4810
4854
  binding1,
4811
- binding2.serializeSources
4855
+ binding2.sources
4856
+ // TODO should check for an actual intersection, not just binding2.sources stateful
4812
4857
  );
4813
4858
  }
4814
- if (!isBindingForceSerialized(section, binding2) && !bindingUtil.isSuperset(binding2.sources, binding1.sources)) {
4859
+ if (!isBindingForceSerialized(section, binding2) && !isSupersetSources(binding2, binding1)) {
4860
+ if (!isSameOrChildSection(section, binding2.section)) {
4861
+ addOwnersSerializeReason(
4862
+ section,
4863
+ binding2.section,
4864
+ mergeSerializeReasons(
4865
+ // TODO should check for an actual intersection, not just stateful
4866
+ binding1.sources,
4867
+ binding2.sources
4868
+ ),
4869
+ getAccessorProp().Owner
4870
+ );
4871
+ }
4815
4872
  addBindingSerializeReason(
4816
- section,
4873
+ binding2.section,
4817
4874
  binding2,
4818
- binding1.serializeSources
4875
+ binding1.sources
4876
+ // TODO should check for an actual intersection, not just binding1.sources stateful
4819
4877
  );
4820
4878
  }
4821
4879
  }
@@ -4847,17 +4905,17 @@ function finalizeReferences() {
4847
4905
  getBindingSerializeReason(closure.section, closure)
4848
4906
  );
4849
4907
  }
4850
- if (closure.serializeSources && isDynamicClosure(section, closure)) {
4908
+ if (closure.sources && isDynamicClosure(section, closure)) {
4851
4909
  addBindingSerializeReason(
4852
4910
  closure.section,
4853
4911
  closure,
4854
- closure.serializeSources,
4912
+ closure.sources,
4855
4913
  getAccessorPrefix().ClosureScopes
4856
4914
  );
4857
4915
  addBindingSerializeReason(
4858
4916
  section,
4859
4917
  closure,
4860
- closure.serializeSources,
4918
+ closure.sources,
4861
4919
  getAccessorPrefix().ClosureSignalIndex
4862
4920
  );
4863
4921
  }
@@ -4866,21 +4924,28 @@ function finalizeReferences() {
4866
4924
  let inputSerializeReasons;
4867
4925
  forEachSection((section) => {
4868
4926
  finalizeSectionSerializeReasons(section);
4869
- if (section.serializeReason && section.serializeReason !== true) {
4927
+ if (section.serializeReason && section.serializeReason !== true && section.serializeReason.input) {
4870
4928
  inputSerializeReasons = inputSerializeReasons ? addSorted(
4871
- compareSerializeReasons,
4929
+ compareReferences,
4872
4930
  inputSerializeReasons,
4873
- section.serializeReason
4874
- ) : [section.serializeReason];
4931
+ section.serializeReason.input
4932
+ ) : [section.serializeReason.input];
4875
4933
  }
4876
4934
  for (const [, reason] of section.serializeReasons) {
4877
- if (reason !== true) {
4878
- inputSerializeReasons = inputSerializeReasons ? addSorted(compareSerializeReasons, inputSerializeReasons, reason) : [reason];
4935
+ if (reason !== true && reason.input) {
4936
+ inputSerializeReasons = inputSerializeReasons ? addSorted(compareReferences, inputSerializeReasons, reason.input) : [reason.input];
4879
4937
  }
4880
4938
  }
4881
4939
  });
4882
4940
  const programExtra = (0, import_babel_utils17.getProgram)().node.extra;
4883
- programExtra.returnSerializeReason = programExtra.returnValueExpr && getSerializeSourcesForExpr(programExtra.returnValueExpr);
4941
+ if (programExtra.returnValueExpr) {
4942
+ const returnSources = getSerializeSourcesForExpr(
4943
+ programExtra.returnValueExpr
4944
+ );
4945
+ if (returnSources) {
4946
+ programExtra.returnSerializeReason = returnSources.state ? true : returnSources.input;
4947
+ }
4948
+ }
4884
4949
  programExtra.inputSerializeReasons = inputSerializeReasons;
4885
4950
  forEachSection((section) => {
4886
4951
  let intersectionIndex = 0;
@@ -4913,12 +4978,14 @@ function finalizeReferences() {
4913
4978
  function getMaxOwnSourceOffset(intersection, section) {
4914
4979
  let scopeOffset;
4915
4980
  for (const binding of intersection) {
4916
- if (binding.section === section) {
4917
- forEach(binding.sources, (source) => {
4981
+ if (binding.section === section && binding.sources) {
4982
+ const trackScopeOffset = (source) => {
4918
4983
  if (source.scopeOffset && (!scopeOffset || scopeOffset.id < source.scopeOffset.id)) {
4919
4984
  scopeOffset = source.scopeOffset;
4920
4985
  }
4921
- });
4986
+ };
4987
+ forEach(binding.sources.state, trackScopeOffset);
4988
+ forEach(binding.sources.input, trackScopeOffset);
4922
4989
  }
4923
4990
  }
4924
4991
  return scopeOffset;
@@ -4934,60 +5001,82 @@ function resolveBindingSources(binding) {
4934
5001
  resolvedSources.add(binding);
4935
5002
  switch (binding.type) {
4936
5003
  case 1 /* let */:
4937
- binding.sources = binding;
4938
- binding.serializeSources = true;
5004
+ binding.sources = createSources(binding, void 0);
4939
5005
  return;
4940
5006
  case 2 /* input */:
4941
- binding.sources = binding;
4942
- binding.serializeSources = binding;
5007
+ binding.sources = createSources(void 0, binding);
4943
5008
  return;
4944
5009
  }
4945
- let alias;
4946
- let source = binding;
4947
- while (alias = source.upstreamAlias) {
4948
- source = alias;
4949
- }
4950
- if (source === binding) {
5010
+ if (binding.upstreamAlias) {
5011
+ let alias;
5012
+ let source = binding;
5013
+ while (alias = source.upstreamAlias) {
5014
+ source = alias;
5015
+ }
5016
+ if (!resolvedSources.has(source)) {
5017
+ resolvedSources.add(source);
5018
+ resolveDerivedSources(source);
5019
+ }
5020
+ binding.sources = source.sources;
5021
+ } else {
4951
5022
  resolveDerivedSources(binding);
4952
- return;
4953
- }
4954
- if (!resolvedSources.has(source)) {
4955
- resolvedSources.add(source);
4956
- resolveDerivedSources(source);
4957
5023
  }
4958
- binding.sources = source.sources;
4959
- binding.serializeSources = source.serializeSources;
4960
5024
  }
4961
5025
  function resolveDerivedSources(binding) {
4962
5026
  const exprs = bindingValueExprs.get(binding);
4963
5027
  bindingValueExprs.delete(binding);
4964
5028
  if (exprs === void 0 || exprs === true) {
4965
- binding.serializeSources = true;
4966
- binding.sources = binding;
5029
+ binding.sources = createSources(binding, void 0);
4967
5030
  } else if (exprs) {
4968
5031
  const seen = /* @__PURE__ */ new Set();
4969
- let onlyInputSources = true;
4970
- let sources;
4971
5032
  forEach(exprs, (expr) => {
4972
5033
  if (isReferencedExtra(expr)) {
4973
5034
  forEach(expr.referencedBindings, (ref) => {
4974
5035
  if (!seen.has(ref)) {
4975
5036
  seen.add(ref);
4976
5037
  resolveBindingSources(ref);
4977
- sources = bindingUtil.union(sources, ref.sources);
4978
- onlyInputSources &&= ref.serializeSources !== true;
5038
+ binding.sources = mergeSources(binding.sources, ref.sources);
4979
5039
  }
4980
5040
  });
4981
5041
  }
4982
5042
  });
4983
- if (sources) {
4984
- binding.sources = sources;
4985
- binding.serializeSources = onlyInputSources ? sources : true;
4986
- }
4987
5043
  }
4988
5044
  }
5045
+ function createSources(state, input) {
5046
+ if (!(state || input)) {
5047
+ throw new Error(
5048
+ "Cannot create a serialize reason that does not reference state or input."
5049
+ );
5050
+ }
5051
+ return { state, input };
5052
+ }
5053
+ function compareSources(a, b) {
5054
+ let delta = 0;
5055
+ if (a.input) {
5056
+ if (!b.input) return 1;
5057
+ if (delta = compareReferences(a.input, b.input)) return delta;
5058
+ } else if (b.input) {
5059
+ return -1;
5060
+ }
5061
+ if (a.state) {
5062
+ if (!b.state) return 1;
5063
+ if (delta = compareReferences(a.state, b.state)) return delta;
5064
+ } else if (b.state) {
5065
+ return -1;
5066
+ }
5067
+ return 0;
5068
+ }
5069
+ function mergeSources(a, b) {
5070
+ if (!a) return b;
5071
+ if (!b) return a;
5072
+ if (a.state === b.state && a.input === b.input) return a;
5073
+ return createSources(
5074
+ bindingUtil.union(a.state, b.state),
5075
+ bindingUtil.union(a.input, b.input)
5076
+ );
5077
+ }
4989
5078
  var bindingUtil = new Sorted(function compareBindings(a, b) {
4990
- return a.section.id - b.section.id || a.type !== b.type && (a.type === 0 /* dom */ || b.type === 0 /* dom */) ? a.type - b.type || a.id - b.id : a.id - b.id;
5079
+ return a === b ? 0 : a.section.id - b.section.id || a.type !== b.type && (a.type === 0 /* dom */ || b.type === 0 /* dom */) ? a.type - b.type || a.id - b.id : a.id - b.id;
4991
5080
  });
4992
5081
  var [getReadsByExpression] = createProgramState(
4993
5082
  () => /* @__PURE__ */ new Map()
@@ -5054,6 +5143,35 @@ function getScopeAccessor(binding, includeId) {
5054
5143
  }
5055
5144
  return binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "");
5056
5145
  }
5146
+ function getDebugScopeAccess(binding) {
5147
+ let root = binding;
5148
+ let access = "";
5149
+ while (!(root.loc || root.declared) && root.upstreamAlias) {
5150
+ if (root.property !== void 0) {
5151
+ access = toAccess(root.property) + access;
5152
+ }
5153
+ root = root.upstreamAlias;
5154
+ }
5155
+ return {
5156
+ root,
5157
+ access
5158
+ };
5159
+ }
5160
+ function getDebugName(binding) {
5161
+ const { root, access } = getDebugScopeAccess(binding);
5162
+ return root.name + access;
5163
+ }
5164
+ function getInputDebugName(binding) {
5165
+ let root = binding;
5166
+ let access = "";
5167
+ while (root.upstreamAlias !== root.section.params) {
5168
+ if (root.property !== void 0) {
5169
+ access = toAccess(root.property) + access;
5170
+ }
5171
+ root = root.upstreamAlias;
5172
+ }
5173
+ return root.name + access;
5174
+ }
5057
5175
  function getSectionInstancesAccessor(section) {
5058
5176
  return section.sectionAccessor ? section.sectionAccessor.prefix + getScopeAccessor(section.sectionAccessor.binding) : getAccessorPrefix().ClosureScopes + section.id;
5059
5177
  }
@@ -5177,6 +5295,11 @@ function resolveExpressionReference(reads, readBinding, readProps) {
5177
5295
  }
5178
5296
  return createRead(readBinding, readProps);
5179
5297
  }
5298
+ function isSupersetSources(a, b) {
5299
+ if (!b.sources) return true;
5300
+ if (!a.sources) return false;
5301
+ return bindingUtil.isSuperset(a.sources.state, b.sources.state) && bindingUtil.isSuperset(a.sources.input, b.sources.input);
5302
+ }
5180
5303
  function getCanonicalProperty(binding) {
5181
5304
  return binding.property ?? binding.upstreamAlias?.property;
5182
5305
  }
@@ -5266,7 +5389,6 @@ var await_default = {
5266
5389
  const tagBody = tag.get("body");
5267
5390
  const section = getSection(tag);
5268
5391
  const bodySection = getSectionForBody(tagBody);
5269
- const serializeReason = bodySection && getSectionSerializeReason(bodySection);
5270
5392
  flushInto(tag);
5271
5393
  writeHTMLResumeStatements(tagBody);
5272
5394
  tag.replaceWith(
@@ -5280,7 +5402,10 @@ var await_default = {
5280
5402
  node.body.params,
5281
5403
  toFirstExpressionOrBlock(node.body.body)
5282
5404
  ),
5283
- !serializeReason ? import_compiler25.types.numericLiteral(0) : serializeReason === true ? void 0 : getSerializeGuard(serializeReason)
5405
+ getSerializeGuard(
5406
+ bodySection && getSectionSerializeReason(bodySection),
5407
+ true
5408
+ )
5284
5409
  )
5285
5410
  )
5286
5411
  )[0].skip();
@@ -6599,12 +6724,16 @@ var for_default = {
6599
6724
  if (markerSerializeReason && onlyChildInParentOptimization) {
6600
6725
  getParentTag(tag).node.extra[kSkipMark] = true;
6601
6726
  }
6727
+ const markerSerializeArg = getSerializeGuard(
6728
+ markerSerializeReason,
6729
+ !onlyChildInParentOptimization
6730
+ );
6602
6731
  forTagArgs.push(
6603
6732
  forAttrs.by || import_compiler33.types.numericLiteral(0),
6604
6733
  getScopeIdIdentifier(tagSection),
6605
6734
  getScopeAccessorLiteral(nodeBinding),
6606
- branchSerializeReason === true ? markerSerializeReason === true && !onlyChildInParentOptimization ? void 0 : import_compiler33.types.numericLiteral(1) : getSerializeGuard(branchSerializeReason),
6607
- !markerSerializeReason ? import_compiler33.types.numericLiteral(0) : markerSerializeReason === true ? onlyChildInParentOptimization ? import_compiler33.types.numericLiteral(1) : void 0 : getSerializeGuard(markerSerializeReason)
6735
+ getSerializeGuard(branchSerializeReason, !markerSerializeArg),
6736
+ markerSerializeArg
6608
6737
  );
6609
6738
  if (onlyChildInParentOptimization) {
6610
6739
  forTagArgs.push(import_compiler33.types.numericLiteral(1));
@@ -8463,11 +8592,11 @@ var IfTag = {
8463
8592
  );
8464
8593
  if (branchSerializeReason) {
8465
8594
  if (branchSerializeReasons !== true) {
8466
- if (branchSerializeReason === true) {
8595
+ if (branchSerializeReason === true || branchSerializeReason.state) {
8467
8596
  branchSerializeReasons = true;
8468
8597
  } else if (branchSerializeReasons) {
8469
8598
  branchSerializeReasons = addSorted(
8470
- compareSerializeReasons,
8599
+ compareSources,
8471
8600
  branchSerializeReasons,
8472
8601
  branchSerializeReason
8473
8602
  );
@@ -8501,24 +8630,44 @@ var IfTag = {
8501
8630
  [],
8502
8631
  import_compiler42.types.blockStatement([statement])
8503
8632
  );
8504
- statement = import_compiler42.types.expressionStatement(
8505
- singleNodeOptimization ? callRuntime(
8506
- "resumeSingleNodeConditional",
8507
- cbNode,
8508
- getScopeIdIdentifier(ifTagSection),
8509
- getScopeAccessorLiteral(nodeBinding),
8510
- branchSerializeReasons === true ? markerSerializeReason === true && !onlyChildInParentOptimization ? void 0 : import_compiler42.types.numericLiteral(1) : getSerializeGuardForAny(branchSerializeReasons),
8511
- !markerSerializeReason ? import_compiler42.types.numericLiteral(0) : markerSerializeReason === true ? onlyChildInParentOptimization ? import_compiler42.types.numericLiteral(1) : void 0 : getSerializeGuard(markerSerializeReason),
8512
- onlyChildInParentOptimization && import_compiler42.types.numericLiteral(1)
8513
- ) : callRuntime(
8514
- "resumeConditional",
8515
- cbNode,
8516
- getScopeIdIdentifier(ifTagSection),
8517
- getScopeAccessorLiteral(nodeBinding),
8518
- branchSerializeReasons === true ? markerSerializeReason === true ? void 0 : import_compiler42.types.numericLiteral(1) : getSerializeGuardForAny(branchSerializeReasons),
8519
- !markerSerializeReason ? import_compiler42.types.numericLiteral(0) : markerSerializeReason === true ? void 0 : getSerializeGuard(markerSerializeReason)
8520
- )
8521
- );
8633
+ if (singleNodeOptimization) {
8634
+ const markerSerializeArg = getSerializeGuard(
8635
+ markerSerializeReason,
8636
+ !onlyChildInParentOptimization
8637
+ );
8638
+ statement = import_compiler42.types.expressionStatement(
8639
+ callRuntime(
8640
+ "resumeSingleNodeConditional",
8641
+ cbNode,
8642
+ getScopeIdIdentifier(ifTagSection),
8643
+ getScopeAccessorLiteral(nodeBinding),
8644
+ getSerializeGuardForAny(
8645
+ branchSerializeReasons,
8646
+ !markerSerializeArg
8647
+ ),
8648
+ markerSerializeArg,
8649
+ onlyChildInParentOptimization && import_compiler42.types.numericLiteral(1)
8650
+ )
8651
+ );
8652
+ } else {
8653
+ const markerSerializeArg = getSerializeGuard(
8654
+ markerSerializeReason,
8655
+ true
8656
+ );
8657
+ statement = import_compiler42.types.expressionStatement(
8658
+ callRuntime(
8659
+ "resumeConditional",
8660
+ cbNode,
8661
+ getScopeIdIdentifier(ifTagSection),
8662
+ getScopeAccessorLiteral(nodeBinding),
8663
+ getSerializeGuardForAny(
8664
+ branchSerializeReasons,
8665
+ !markerSerializeArg
8666
+ ),
8667
+ markerSerializeArg
8668
+ )
8669
+ );
8670
+ }
8522
8671
  }
8523
8672
  nextTag.insertBefore(statement);
8524
8673
  }
@@ -8698,13 +8847,6 @@ function getBranches(tag) {
8698
8847
  }
8699
8848
  return branches;
8700
8849
  }
8701
- function getSerializeGuardForAny(reasons) {
8702
- let expr = getSerializeGuard(reasons[0]);
8703
- for (let i = 1; i < reasons.length; i++) {
8704
- expr = import_compiler42.types.logicalExpression("||", expr, getSerializeGuard(reasons[i]));
8705
- }
8706
- return expr;
8707
- }
8708
8850
  function isLastBranch(tag) {
8709
8851
  const branches = getBranches(tag);
8710
8852
  return branches[branches.length - 1][0] === tag;
@@ -9630,10 +9772,10 @@ var placeholder_default = {
9630
9772
  } else {
9631
9773
  if (siblingText === 1 /* Before */) {
9632
9774
  if (isHTML && markerSerializeReason) {
9633
- if (markerSerializeReason === true) {
9775
+ if (markerSerializeReason === true || markerSerializeReason.state) {
9634
9776
  write2`<!>`;
9635
9777
  } else {
9636
- write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason))}`;
9778
+ write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason, true))}`;
9637
9779
  }
9638
9780
  }
9639
9781
  visit(placeholder, 37 /* Replace */);
@@ -10039,7 +10181,7 @@ function translateHTML(tag) {
10039
10181
  childScopeBinding,
10040
10182
  childSerializeReasonIds[0]
10041
10183
  );
10042
- childSerializeReasonExpr = !reason ? void 0 : reason == true ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason);
10184
+ childSerializeReasonExpr = !reason ? void 0 : reason == true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, true);
10043
10185
  } else {
10044
10186
  const props = [];
10045
10187
  let hasDynamicReasons = false;
@@ -10051,11 +10193,15 @@ function translateHTML(tag) {
10051
10193
  childSerializeReasonIds[i]
10052
10194
  );
10053
10195
  if (reason) {
10054
- hasDynamicReasons ||= reason !== true;
10196
+ hasDynamicReasons ||= reason !== true && !reason.state;
10197
+ const childReason = childExtra.inputSerializeReasons[i];
10055
10198
  props.push(
10056
10199
  import_compiler56.types.objectProperty(
10057
- import_compiler56.types.numericLiteral(i),
10058
- reason === true ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason)
10200
+ withLeadingComment(
10201
+ import_compiler56.types.numericLiteral(i),
10202
+ mapToString(childReason, ", ", getInputDebugName)
10203
+ ),
10204
+ reason === true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, false)
10059
10205
  )
10060
10206
  );
10061
10207
  } else {
@@ -10796,11 +10942,10 @@ var dynamic_tag_default = {
10796
10942
  if (isOutputHTML()) {
10797
10943
  flushInto(tag);
10798
10944
  writeHTMLResumeStatements(tag.get("body"));
10799
- const serializeReason = getBindingSerializeReason(
10800
- tagSection,
10801
- nodeBinding
10945
+ const serializeArg = getSerializeGuard(
10946
+ getBindingSerializeReason(tagSection, nodeBinding),
10947
+ true
10802
10948
  );
10803
- const serializeArg = !serializeReason ? import_compiler57.types.numericLiteral(0) : serializeReason === true ? void 0 : getSerializeGuard(serializeReason);
10804
10949
  const dynamicTagExpr = hasTagArgs ? callRuntime(
10805
10950
  "dynamicTag",
10806
10951
  getScopeIdIdentifier(tagSection),