marko 6.3.44 → 6.3.46

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.
Files changed (60) hide show
  1. package/cheatsheet.md +7 -3
  2. package/dist/debug/dom/catch.feat.js +1 -1
  3. package/dist/debug/dom/catch.feat.mjs +1 -1
  4. package/dist/debug/dom/controllable-input.feat.js +1 -1
  5. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  6. package/dist/debug/dom/controllable-open.feat.js +1 -1
  7. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  8. package/dist/debug/dom/controllable-select.feat.js +1 -1
  9. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable.feat.js +1 -1
  13. package/dist/debug/dom/controllable.feat.mjs +1 -1
  14. package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
  15. package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
  16. package/dist/debug/dom/placeholder.feat.js +1 -1
  17. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  18. package/dist/debug/{dom-ky42a_qY.mjs → dom-CIt3_Sdm.mjs} +7 -1
  19. package/dist/debug/{dom-DBuLwSOh.js → dom-WyMgkHne.js} +12 -0
  20. package/dist/debug/dom.js +2 -1
  21. package/dist/debug/dom.mjs +2 -2
  22. package/dist/debug/html.js +16 -14
  23. package/dist/debug/html.mjs +16 -14
  24. package/dist/dom/catch.feat.js +3 -3
  25. package/dist/dom/catch.feat.mjs +1 -1
  26. package/dist/dom/controllable-input.feat.js +1 -1
  27. package/dist/dom/controllable-input.feat.mjs +1 -1
  28. package/dist/dom/controllable-open.feat.js +1 -1
  29. package/dist/dom/controllable-open.feat.mjs +1 -1
  30. package/dist/dom/controllable-select.feat.js +1 -1
  31. package/dist/dom/controllable-select.feat.mjs +1 -1
  32. package/dist/dom/controllable-textarea.feat.js +1 -1
  33. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  34. package/dist/dom/controllable.feat.js +1 -1
  35. package/dist/dom/controllable.feat.mjs +1 -1
  36. package/dist/dom/dynamic-tag-var.feat.js +1 -1
  37. package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
  38. package/dist/dom/placeholder.feat.js +3 -3
  39. package/dist/dom/placeholder.feat.mjs +1 -1
  40. package/dist/dom/resume.d.ts +1 -0
  41. package/dist/{dom-BSAs0ur8.mjs → dom-DN6BTUmH.mjs} +2 -1
  42. package/dist/{dom-DHJCbngT.js → dom-R3sALHJt.js} +53 -47
  43. package/dist/dom.d.ts +1 -1
  44. package/dist/dom.js +24 -24
  45. package/dist/dom.mjs +2 -2
  46. package/dist/html.js +6 -6
  47. package/dist/html.mjs +6 -6
  48. package/dist/translator/index.js +238 -525
  49. package/dist/translator/interop/index.d.ts +8 -0
  50. package/dist/translator/util/entry-builder.d.ts +17 -3
  51. package/dist/translator/util/known-tag.d.ts +1 -5
  52. package/dist/translator/util/references.d.ts +10 -1
  53. package/dist/translator/util/sections.d.ts +3 -1
  54. package/dist/translator/util/serialize-reasons.d.ts +3 -1
  55. package/dist/translator/util/set-tag-sections-downstream.d.ts +2 -2
  56. package/dist/translator/util/signals.d.ts +4 -1
  57. package/dist/translator/util/tag-name-type.d.ts +2 -0
  58. package/dist/translator/visitors/import-declaration.d.ts +4 -0
  59. package/dist/translator/visitors/program/index.d.ts +1 -0
  60. package/package.json +4 -4
@@ -35,8 +35,6 @@ let package_json = require("../../package.json");
35
35
  package_json = __toESM(package_json, 1);
36
36
  let _marko_compiler = require("@marko/compiler");
37
37
  let _marko_compiler_babel_utils = require("@marko/compiler/babel-utils");
38
- let node_path = require("node:path");
39
- node_path = __toESM(node_path, 1);
40
38
  let path = require("path");
41
39
  path = __toESM(path, 1);
42
40
  let magic_string = require("magic-string");
@@ -205,7 +203,6 @@ const StartNode$1 = "#StartNode";
205
203
  const Subscriptions$1 = "#Subscriptions";
206
204
  const TagVariable$1 = "#TagVariable";
207
205
  const TagVariableChange$2 = "#TagVariableChange";
208
- const Owner$1 = "owner";
209
206
  //#endregion
210
207
  //#region src/translator/util/evaluate.ts
211
208
  function evaluate(value) {
@@ -356,120 +353,20 @@ function getEventHandlerName(name) {
356
353
  function isVoid(value) {
357
354
  return value == null || value === false;
358
355
  }
359
- function isNotVoid(value) {
360
- return value != null && value !== false;
361
- }
362
- function normalizeDynamicRenderer(value) {
363
- if (value) {
364
- if (typeof value === "string") return value;
365
- const normalized = value.content || value.default || value;
366
- if ("id" in normalized) return normalized;
367
- }
368
- }
369
356
  const decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36);
370
357
  //#endregion
371
358
  //#region src/html/serializer.ts
372
- const K_SCOPE_ID = Symbol("Scope ID");
373
- const kTouchedIterator = Symbol.for("marko.touchedIterator");
359
+ const kTouchedIterator = /* @__PURE__ */ Symbol.for("marko.touchedIterator");
374
360
  const { hasOwnProperty } = {};
375
361
  Array.prototype;
376
- const Generator = (function* () {})().constructor;
377
- const AsyncGenerator = (async function* () {})().constructor;
362
+ const Generator = (/* @__PURE__ */ (function* () {})()).constructor;
363
+ const AsyncGenerator = (/* @__PURE__ */ (async function* () {})()).constructor;
378
364
  patchIteratorNext(Generator.prototype);
379
365
  patchIteratorNext(AsyncGenerator.prototype);
380
- const REGISTRY = /* @__PURE__ */ new WeakMap();
381
- (() => {
382
- const KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
383
- for (const name of Object.getOwnPropertyNames(Symbol)) {
384
- const symbol = Symbol[name];
385
- if (typeof symbol === "symbol") KNOWN_SYMBOLS.set(symbol, "Symbol." + name);
386
- }
387
- return KNOWN_SYMBOLS;
388
- })();
389
- Array.from, Array.isArray, Array.of, ArrayBuffer.isView, Atomics.add, Atomics.and, Atomics.compareExchange, Atomics.exchange, Atomics.isLockFree, Atomics.load, Atomics.notify, Atomics.or, Atomics.store, Atomics.sub, Atomics.wait, BigInt.asIntN, BigInt.asUintN, BigInt64Array, BigInt64Array.from, BigInt64Array.of, BigUint64Array, BigUint64Array.from, BigUint64Array.of, console.timeStamp, Date.now, Date.parse, Date.UTC, Float32Array.from, Float32Array.of, Float64Array.from, Float64Array.of, globalThis.atob, globalThis.btoa, globalThis.clearImmediate, globalThis.clearInterval, globalThis.clearTimeout, globalThis.crypto?.getRandomValues, globalThis.crypto?.randomUUID, globalThis.fetch, globalThis.performance?.now, globalThis.queueMicrotask, globalThis.setImmediate, globalThis.setInterval, globalThis.setTimeout, globalThis.structuredClone, globalThis.URL, globalThis.URLSearchParams, globalThis.WritableStream, Int16Array.from, Int16Array.of, Int32Array.from, Int32Array.of, Int8Array.from, Int8Array.of, Intl.Collator, Intl.DateTimeFormat, Intl.DisplayNames, Intl.getCanonicalLocales, Intl.ListFormat, Intl.Locale, Intl.NumberFormat, Intl.PluralRules, Intl.RelativeTimeFormat, Intl.Segmenter, Intl.supportedValuesOf, Map.groupBy, Number.isFinite, Number.isInteger, Number.isNaN, Number.isSafeInteger, Number.parseFloat, Number.parseInt, String.fromCharCode, String.fromCodePoint, String.raw, Symbol.for, Uint16Array.from, Uint16Array.of, Uint32Array.from, Uint32Array.of, Uint8Array.from, Uint8Array.of, Uint8ClampedArray.from, Uint8ClampedArray.of;
390
- Atomics, globalThis.crypto;
391
- function register(id, val, scope) {
392
- REGISTRY.set(val, {
393
- id,
394
- scope,
395
- access: "_._" + toAccess(toObjectKey(id))
396
- });
397
- return val;
398
- }
399
- function toObjectKey(name) {
400
- if (name === "") return "\"\"";
401
- if (name === "__proto__") return "[\"__proto__\"]";
402
- const len = name.length;
403
- const c0 = name.charCodeAt(0);
404
- if (c0 >= 48 && c0 <= 57) if (c0 === 48) {
405
- if (len !== 1) return quote(name, 1);
406
- } else {
407
- for (let i = 1; i < len; i++) {
408
- const c = name.charCodeAt(i);
409
- if (c < 48 || c > 57) return quote(name, i);
410
- }
411
- if (len > 15 && "" + +name !== name) return quote(name, 0);
412
- }
413
- else if (c0 >= 97 && c0 <= 122 || c0 >= 65 && c0 <= 90 || c0 === 95 || c0 === 36) for (let i = 1; i < len; i++) {
414
- const c = name.charCodeAt(i);
415
- if (!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95 || c === 36)) return quote(name, i);
416
- }
417
- else return quote(name, 0);
418
- return name;
419
- }
420
366
  function toAccess(accessor) {
421
367
  const start = accessor[0];
422
368
  return start === "[" ? accessor : start === "\"" || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
423
369
  }
424
- const unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u;
425
- function quote(str, startPos) {
426
- if (!unsafeQuoteReg.test(str)) return "\"" + str + "\"";
427
- let result = "";
428
- let lastPos = 0;
429
- for (let i = startPos; i < str.length; i++) {
430
- let replacement;
431
- const code = str.charCodeAt(i);
432
- switch (code) {
433
- case 34:
434
- replacement = "\\\"";
435
- break;
436
- case 92:
437
- replacement = "\\\\";
438
- break;
439
- case 60:
440
- replacement = "\\x3C";
441
- break;
442
- case 10:
443
- replacement = "\\n";
444
- break;
445
- case 13:
446
- replacement = "\\r";
447
- break;
448
- case 8232:
449
- replacement = "\\u2028";
450
- break;
451
- case 8233:
452
- replacement = "\\u2029";
453
- break;
454
- case 0:
455
- replacement = "\\x00";
456
- break;
457
- default:
458
- if (code < 55296 || code > 57343) continue;
459
- if (code < 56320) {
460
- const next = str.charCodeAt(i + 1);
461
- if (next >= 56320 && next <= 57343) {
462
- i++;
463
- continue;
464
- }
465
- }
466
- replacement = "\\u" + code.toString(16);
467
- }
468
- result += str.slice(lastPos, i) + replacement;
469
- lastPos = i + 1;
470
- }
471
- return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
472
- }
473
370
  function patchIteratorNext(proto) {
474
371
  if (proto.next[kTouchedIterator]) return;
475
372
  const { next } = proto;
@@ -1201,6 +1098,37 @@ function getSerializeSourcesForRef(ref) {
1201
1098
  } else return ref.sources;
1202
1099
  }
1203
1100
  }
1101
+ function mapCrossProgramReason(program, reason, exprs) {
1102
+ let params;
1103
+ let mapped;
1104
+ let crossProgram = false;
1105
+ forEach(reason.param, (param) => {
1106
+ if (param.section.program === program) params = bindingUtil.add(params, param);
1107
+ else {
1108
+ crossProgram = true;
1109
+ mapped = exprs ? mergeSerializeReasons(mapped, getSerializeSourcesForExprs(mapParamBindingToExpr(exprs, param))) : true;
1110
+ }
1111
+ });
1112
+ if (!crossProgram) return reason;
1113
+ return mergeRemappedSources(reason, params, mapped);
1114
+ }
1115
+ function mapDownstreamReason(program, reason, exprs) {
1116
+ let params;
1117
+ let mapped;
1118
+ let downstream = false;
1119
+ forEach(reason.param, (param) => {
1120
+ if (param.section.program === program) {
1121
+ downstream = true;
1122
+ mapped = mergeSerializeReasons(mapped, getSerializeSourcesForExprs(mapParamBindingToExpr(exprs, param)));
1123
+ } else params = bindingUtil.add(params, param);
1124
+ });
1125
+ if (!downstream) return reason;
1126
+ return mergeRemappedSources(reason, params, mapped);
1127
+ }
1128
+ function mergeRemappedSources(reason, params, mapped) {
1129
+ if (mapped !== true && (reason.state || reason.global || params)) mapped = mergeSerializeReasons(mapped, createSources(reason.state, params, reason.global));
1130
+ return mapped;
1131
+ }
1204
1132
  function mergeSerializeReasons(a, b) {
1205
1133
  if (a === true || b === true) return true;
1206
1134
  return mergeSources(a, b);
@@ -1347,6 +1275,7 @@ function analyzeTagNameType(tag, allowDynamic) {
1347
1275
  extra.tagNameType = 2;
1348
1276
  extra.tagNameDynamic = true;
1349
1277
  extra.featureType = "class";
1278
+ if (childFile?.ast.program.extra?.hydratesTags) (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
1350
1279
  } else if (!childFile) {
1351
1280
  extra.tagNameType = 2;
1352
1281
  extra.tagNameDynamic = true;
@@ -1447,6 +1376,7 @@ function startSection(path) {
1447
1376
  loc: parentTag?.node.name.loc || void 0,
1448
1377
  depth: parentSection ? parentSection.depth + 1 : 0,
1449
1378
  parent: parentSection,
1379
+ program: void 0,
1450
1380
  sectionAccessor: void 0,
1451
1381
  params: void 0,
1452
1382
  referencedLocalClosures: void 0,
@@ -1470,6 +1400,7 @@ function startSection(path) {
1470
1400
  isBranch: false,
1471
1401
  structure: parentSection && !parentSection.structure ? null : []
1472
1402
  };
1403
+ section.program = parentSection ? parentSection.program : section;
1473
1404
  sections.push(section);
1474
1405
  }
1475
1406
  return section;
@@ -1573,7 +1504,8 @@ function getSectionRegisterReasons(section) {
1573
1504
  if (section.isBranch) return false;
1574
1505
  const { downstreamBinding } = section;
1575
1506
  if (downstreamBinding) {
1576
- const downstreamReasons = getAllSerializeReasonsForBinding(downstreamBinding.binding, downstreamBinding.properties);
1507
+ let downstreamReasons = getAllSerializeReasonsForBinding(downstreamBinding.binding, downstreamBinding.properties);
1508
+ if (downstreamReasons && downstreamReasons !== true) downstreamReasons = mapCrossProgramReason(section.program, downstreamReasons, downstreamBinding.exprs);
1577
1509
  if (!downstreamReasons) return false;
1578
1510
  if (isReasonDynamic(downstreamReasons) && !section.serializeReason && !section.serializeReasons.size && !section.parent?.serializeReason && !section.parent?.serializeReasons.size) return false;
1579
1511
  return downstreamReasons;
@@ -1677,10 +1609,11 @@ var function_default = { analyze(fn) {
1677
1609
  throw fn.hub.buildError(highlight, "Attribute methods containing `await` must be `async`. Add `async` before the method name.");
1678
1610
  }
1679
1611
  if (fn !== getFnRoot(fn)) return;
1612
+ const { node } = fn;
1613
+ if ((_marko_compiler.types.isObjectMethod(node) || _marko_compiler.types.isClassMethod(node)) && (node.kind === "get" || node.kind === "set")) return;
1680
1614
  const exprRoot = getExprRoot(fn);
1681
1615
  const markoRoot = getMarkoRoot(exprRoot);
1682
1616
  if (!markoRoot || canIgnoreRegister(markoRoot, exprRoot)) return;
1683
- const { node } = fn;
1684
1617
  const section = getSection(fn);
1685
1618
  const fnExtra = node.extra ??= {};
1686
1619
  fnExtra.section = section;
@@ -1913,6 +1846,26 @@ function isClientAssetImport(file, request) {
1913
1846
  return typeof hydrateIncludeImports === "function" ? hydrateIncludeImports(request) : !!hydrateIncludeImports?.test(request);
1914
1847
  }
1915
1848
  //#endregion
1849
+ //#region src/translator/util/binding-has-prop.ts
1850
+ function isSectionRendererElided(section) {
1851
+ return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
1852
+ }
1853
+ function bindingHasProperty(binding, properties) {
1854
+ if (binding.pruned) return false;
1855
+ else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
1856
+ if (binding.reads.size || !properties) return true;
1857
+ let property;
1858
+ let rest;
1859
+ if (Array.isArray(properties)) {
1860
+ property = properties[0];
1861
+ rest = properties.length === 2 ? properties[1] : properties.slice(1);
1862
+ } else property = properties;
1863
+ const propBinding = binding.propertyAliases.get(property);
1864
+ if (propBinding && bindingHasProperty(propBinding, rest)) return true;
1865
+ for (const alias of binding.aliases) if (bindingHasProperty(alias, properties)) return true;
1866
+ return false;
1867
+ }
1868
+ //#endregion
1916
1869
  //#region src/translator/util/binding-prop-tree.ts
1917
1870
  const kDirectContent = Symbol("direct content");
1918
1871
  function getBindingPropTree(binding) {
@@ -1973,35 +1926,70 @@ function resolveRelativeToEntry(entryFile, file, req) {
1973
1926
  //#endregion
1974
1927
  //#region src/translator/util/entry-builder.ts
1975
1928
  const kState = Symbol();
1976
- var entry_builder_default = {
1929
+ const builder = {
1977
1930
  build(entryFile, exportInit) {
1978
1931
  const state = entryFile[kState];
1979
1932
  if (!state) throw entryFile.path.buildCodeFrameError("Unable to build hydrate code, no files were visited before finalizing the build");
1980
1933
  const body = [];
1981
- if (state.init) {
1934
+ for (const asset of state.assets) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(asset)));
1935
+ if (state.init || state.load) {
1982
1936
  const isPage = entryFile.path.node.extra.page;
1983
1937
  const initHelper = isPage ? "init" : "initEmbedded";
1984
- body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`)), _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`./${node_path.default.basename(entryFile.opts.filename)}`)));
1938
+ if (state.init) body.push(_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier(initHelper), _marko_compiler.types.identifier(initHelper))], _marko_compiler.types.stringLiteral(`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`)));
1939
+ for (const root of state.roots) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(root)));
1940
+ if (!state.init) {
1941
+ if (exportInit) body.push(_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))));
1942
+ return body;
1943
+ }
1985
1944
  const { runtimeId } = entryFile.markoOpts;
1986
1945
  const readyId = !isPage && (0, _marko_compiler_babel_utils.getTemplateId)(entryFile.markoOpts, entryFile.opts.filename);
1987
1946
  const initExpression = _marko_compiler.types.callExpression(_marko_compiler.types.identifier(initHelper), readyId ? runtimeId ? [_marko_compiler.types.stringLiteral(readyId), _marko_compiler.types.stringLiteral(runtimeId)] : [_marko_compiler.types.stringLiteral(readyId)] : runtimeId ? [_marko_compiler.types.stringLiteral(runtimeId)] : []);
1988
1947
  body.push(exportInit ? _marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], initExpression)) : _marko_compiler.types.expressionStatement(initExpression));
1989
1948
  } else {
1990
- for (const asset of state.assets) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(asset)));
1949
+ for (const asset of state.bundledAssets) body.push(_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(asset)));
1991
1950
  if (exportInit) body.push(_marko_compiler.types.exportDefaultDeclaration(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([]))));
1992
1951
  }
1993
1952
  return body;
1994
1953
  },
1995
- visit(file, entryFile, visitChild) {
1954
+ visit(file, entryFile, visitChild = (id, bundled = false) => {
1955
+ const state = entryFile[kState];
1956
+ const resolved = resolveRelativeToEntry(entryFile, file, id);
1957
+ const seenBundled = state.visited.get(resolved);
1958
+ if (seenBundled === false || seenBundled && bundled) return;
1959
+ state.visited.set(resolved, bundled);
1960
+ const childFile = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
1961
+ if (childFile) builder.visit(childFile, entryFile);
1962
+ }) {
1996
1963
  const state = entryFile[kState] ||= {
1997
1964
  init: false,
1998
- assets: /* @__PURE__ */ new Set()
1965
+ load: false,
1966
+ bundled: 0,
1967
+ roots: [],
1968
+ assets: /* @__PURE__ */ new Set(),
1969
+ bundledAssets: /* @__PURE__ */ new Set(),
1970
+ visited: /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]])
1999
1971
  };
2000
1972
  const programExtra = file.path.node.extra;
2001
1973
  const { analyzedTags, assetImports } = file.metadata.marko;
2002
- if (programExtra.isInteractive || programExtra.needsCompat) state.init = true;
2003
- if (assetImports) for (const request of assetImports) state.assets.add(resolveRelativeToEntry(entryFile, file, request));
2004
- for (const tag of analyzedTags || []) visitChild(tag);
1974
+ const { loadImports } = programExtra;
1975
+ const init = !!(programExtra.isInteractive || programExtra.needsCompat);
1976
+ const load = !!programExtra.hasClientStatement;
1977
+ const isRoot = !state.bundled && (init || load || !!programExtra.hasResumes);
1978
+ if (init) state.init = true;
1979
+ if (load) state.load = true;
1980
+ if (isRoot) state.roots.push((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, file.opts.filename));
1981
+ if (assetImports) {
1982
+ const assets = isRoot || state.bundled ? state.bundledAssets : state.assets;
1983
+ for (const request of assetImports) assets.add(resolveRelativeToEntry(entryFile, file, request));
1984
+ }
1985
+ if (isRoot) state.bundled++;
1986
+ for (const tag of analyzedTags ? [...analyzedTags] : []) {
1987
+ const lazy = loadImports?.has(tag);
1988
+ if (lazy) state.bundled++;
1989
+ visitChild(tag, !!state.bundled);
1990
+ if (lazy) state.bundled--;
1991
+ }
1992
+ if (isRoot) state.bundled--;
2005
1993
  }
2006
1994
  };
2007
1995
  //#endregion
@@ -2039,6 +2027,8 @@ const regexpCharsReg = /[\\^$.*+?()[\]{}|]/g;
2039
2027
  function escapeRegExp(str) {
2040
2028
  return str.replace(regexpCharsReg, "\\$&");
2041
2029
  }
2030
+ //#endregion
2031
+ //#region src/common/errors.ts
2042
2032
  function assertExclusiveAttrs(attrs, onError = throwErr) {
2043
2033
  if (attrs) {
2044
2034
  let exclusiveAttrs;
@@ -2094,95 +2084,6 @@ const escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsaf
2094
2084
  function _escape_comment(val) {
2095
2085
  return val ? escapeCommentStr(val + "") : val === 0 ? "0" : "";
2096
2086
  }
2097
- //#endregion
2098
- //#region src/html/writer.ts
2099
- let $chunk;
2100
- function getContext(key) {
2101
- return $chunk.context?.[key];
2102
- }
2103
- function getState() {
2104
- return $chunk.boundary.state;
2105
- }
2106
- function rendererKey(renderer) {
2107
- return renderer?.["owner"] === void 0 ? renderer?.["id"] || renderer : renderer["id"] + " " + renderer[Owner$1];
2108
- }
2109
- function getScopeById(scopeId) {
2110
- if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
2111
- }
2112
- function _scope_id() {
2113
- return $chunk.boundary.state.scopeId++;
2114
- }
2115
- function _peek_scope_id() {
2116
- return $chunk.boundary.state.scopeId;
2117
- }
2118
- const kPendingContexts = Symbol("Pending Contexts");
2119
- function withContext(key, value, cb, cbValue) {
2120
- const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
2121
- const prev = ctx[key];
2122
- ctx[kPendingContexts]++;
2123
- ctx[key] = value;
2124
- try {
2125
- return cb(cbValue);
2126
- } finally {
2127
- ctx[kPendingContexts]--;
2128
- ctx[key] = prev;
2129
- }
2130
- }
2131
- const kBranchId = Symbol("Branch Id");
2132
- const kIsAsync = Symbol("Is Async");
2133
- function withBranchId(branchId, cb) {
2134
- return withContext(kBranchId, branchId, cb);
2135
- }
2136
- function _html(html) {
2137
- $chunk.writeHTML(html);
2138
- }
2139
- function _script(scopeId, registryId) {
2140
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
2141
- $chunk.boundary.state.needsMainRuntime = true;
2142
- $chunk.writeEffect(scopeId, registryId);
2143
- }
2144
- function _resume(val, id, scopeId) {
2145
- return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
2146
- }
2147
- function _el(scopeId, id) {
2148
- return _resume(() => void 0, id, scopeId);
2149
- }
2150
- function _resume_branch(scopeId) {
2151
- const branchId = $chunk.context?.[kBranchId];
2152
- if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { [ClosestBranchId$1]: branchId });
2153
- }
2154
- function deferBranchStart(chunk) {
2155
- const beforeBranch = chunk.html;
2156
- chunk.html = "";
2157
- return beforeBranch;
2158
- }
2159
- function applyBranchStart(chunk, beforeBranch, rendered) {
2160
- chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
2161
- }
2162
- let writeScope = (scopeId, partialScope) => {
2163
- const { state } = $chunk.boundary;
2164
- const target = $chunk.serializeState;
2165
- const scope = scopeWithId(state, scopeId);
2166
- const pending = target.writeScopes[scopeId];
2167
- state.needsMainRuntime = true;
2168
- Object.assign(scope, partialScope);
2169
- if (pending && pending !== partialScope) Object.assign(pending, partialScope);
2170
- else target.writeScopes[scopeId] = partialScope;
2171
- target.flushScopes = true;
2172
- return scope;
2173
- };
2174
- function _scope_with_id(scopeId) {
2175
- return scopeWithId($chunk.boundary.state, scopeId);
2176
- }
2177
- function scopeWithId(state, scopeId) {
2178
- const { scopes } = state;
2179
- let scope = scopes.get(scopeId);
2180
- if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
2181
- return scope;
2182
- }
2183
- function _set_serialize_reason(reason) {
2184
- $chunk.boundary.state.serializeReason = reason;
2185
- }
2186
2087
  globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
2187
2088
  //#endregion
2188
2089
  //#region src/html/attrs.ts
@@ -2192,124 +2093,9 @@ function _attr_class(value) {
2192
2093
  function _attr_style(value) {
2193
2094
  return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
2194
2095
  }
2195
- function _attr_option_value(value) {
2196
- const valueAttr = _attr("value", value);
2197
- const selectedValue = getContext(kSelectedValue);
2198
- if (selectedValue !== void 0 && normalizedValueMatches(selectedValue, value)) return valueAttr + " selected";
2199
- return valueAttr;
2200
- }
2201
- const kSelectedValue = Symbol("selectedValue");
2202
- function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
2203
- if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2204
- if (content) withContext(kSelectedValue, value ?? "", content);
2205
- }
2206
- function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2207
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2208
- return _textarea_value(value);
2209
- }
2210
- function _textarea_value(value) {
2211
- const escaped = _escape(normalizeStrAttrValue(value));
2212
- return escaped[0] === "\n" ? "\n" + escaped : escaped;
2213
- }
2214
- function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
2215
- if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
2216
- return _attr("value", value);
2217
- }
2218
- function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
2219
- if (checkedChange) writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType);
2220
- return isNotVoid(checked) ? " checked" : "";
2221
- }
2222
- function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
2223
- const valueAttr = _attr("value", value);
2224
- if (checkedValueChange) writeControlledScope(1, scopeId, nodeAccessor, getCheckedValueRef(checkedValue), checkedValueChange, serializeType);
2225
- return normalizedValueMatches(checkedValue, value) ? valueAttr + " checked" : valueAttr;
2226
- }
2227
- const checkedValuesRefs = /* @__PURE__ */ new WeakMap();
2228
- function getCheckedValueRef(checkedValue) {
2229
- if (Array.isArray(checkedValue)) {
2230
- let ref = checkedValuesRefs.get(checkedValue);
2231
- if (!ref) {
2232
- ref = [];
2233
- checkedValuesRefs.set(checkedValue, ref);
2234
- }
2235
- return ref;
2236
- }
2237
- }
2238
- function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
2239
- const normalizedOpen = isNotVoid(open);
2240
- if (openChange) writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType);
2241
- return normalizedOpen ? " open" : "";
2242
- }
2243
2096
  function _attr(name, value) {
2244
2097
  return isVoid(value) ? "" : nonVoidAttr(name, value);
2245
2098
  }
2246
- function _attrs(data, nodeAccessor, scopeId, tagName) {
2247
- let result = "";
2248
- let skip = /[\s/>"'=]/;
2249
- let events;
2250
- switch (data && tagName) {
2251
- case "input":
2252
- if (data.checkedChange) {
2253
- result += _attr_input_checked(scopeId, nodeAccessor, data.checked, data.checkedChange, 1);
2254
- skip = /^checked(?:Value)?(?:Change)?$|[\s/>"'=]/;
2255
- } else if ("checkedValue" in data || data.checkedValueChange) {
2256
- result += _attr_input_checkedValue(scopeId, nodeAccessor, data.checkedValue, data.checkedValueChange, data.value, 1);
2257
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2258
- } else if (data.valueChange) {
2259
- result += _attr_input_value(scopeId, nodeAccessor, data.value, data.valueChange, 1);
2260
- skip = /^value(?:Change)?$|[\s/>"'=]/;
2261
- }
2262
- break;
2263
- case "select":
2264
- case "textarea":
2265
- if ("value" in data || data.valueChange) skip = /^value(?:Change)?$|[\s/>"'=]/;
2266
- break;
2267
- case "option":
2268
- if ("value" in data) {
2269
- result += _attr_option_value(data.value);
2270
- skip = /^value$|[\s/>"'=]/;
2271
- }
2272
- break;
2273
- case "details":
2274
- case "dialog":
2275
- if (data.openChange) {
2276
- result += _attr_details_or_dialog_open(scopeId, nodeAccessor, data.open, data.openChange, 1);
2277
- skip = /^open(?:Change)?$|[\s/>"'=]/;
2278
- }
2279
- break;
2280
- }
2281
- for (const name in data) {
2282
- const value = data[name];
2283
- switch (name) {
2284
- case "class":
2285
- result += _attr_class(value);
2286
- break;
2287
- case "style":
2288
- result += _attr_style(value);
2289
- break;
2290
- default:
2291
- if (name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta")) if (isEventHandler(name)) {
2292
- if (!events) {
2293
- events = {};
2294
- writeScope(scopeId, { [EventAttributes$1 + nodeAccessor]: events });
2295
- }
2296
- events[getEventHandlerName(name)] = value;
2297
- } else result += nonVoidAttr(name, value);
2298
- break;
2299
- }
2300
- }
2301
- return result;
2302
- }
2303
- function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, serializeType) {
2304
- writeScope(scopeId, serializeType ? {
2305
- [ControlledType$1 + nodeAccessor]: type,
2306
- [ControlledValue$1 + nodeAccessor]: value,
2307
- [ControlledHandler$1 + nodeAccessor]: valueChange
2308
- } : {
2309
- [ControlledValue$1 + nodeAccessor]: value,
2310
- [ControlledHandler$1 + nodeAccessor]: valueChange
2311
- });
2312
- }
2313
2099
  function stringAttr(name, value) {
2314
2100
  return value && " " + name + attrAssignment(value);
2315
2101
  }
@@ -2339,83 +2125,6 @@ function escapeDoubleQuotedAttrValue(value) {
2339
2125
  function replaceUnsafeDoubleQuoteAttrChar(match) {
2340
2126
  return match === "\"" ? "&#34;" : match === "\r" ? "&#13;" : "&amp;";
2341
2127
  }
2342
- function normalizedValueMatches(a, b) {
2343
- const value = normalizeStrAttrValue(b);
2344
- if (Array.isArray(a)) {
2345
- for (const item of a) if (normalizeStrAttrValue(item) === value) return true;
2346
- } else if (normalizeStrAttrValue(a) === value) return true;
2347
- return false;
2348
- }
2349
- function normalizeStrAttrValue(value) {
2350
- return isNotVoid(value) && value !== true ? value + "" : "";
2351
- }
2352
- //#endregion
2353
- //#region src/html/dynamic-tag.ts
2354
- const voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2355
- let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
2356
- const shouldResume = serializeReason !== 0;
2357
- const renderer = normalizeDynamicRenderer(tag);
2358
- const state = getState();
2359
- const branchId = _peek_scope_id();
2360
- let rendered;
2361
- let result;
2362
- if (typeof renderer === "string") {
2363
- const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2364
- rendered = true;
2365
- const renderNative = () => {
2366
- _scope_id();
2367
- _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`);
2368
- if (!voidElementsReg.test(renderer)) {
2369
- const renderContent = content || normalizeDynamicRenderer(input.content);
2370
- if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
2371
- else {
2372
- if (renderContent && typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2373
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason) : void 0, 1);
2374
- else if (renderContent) _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
2375
- }
2376
- _html(`</${renderer}>`);
2377
- }
2378
- const childScope = getScopeById(branchId);
2379
- const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
2380
- if (needsScript) _script(branchId, "_d");
2381
- if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2382
- };
2383
- renderNative();
2384
- result = _el(branchId, "_e");
2385
- } else {
2386
- const chunk = void 0;
2387
- const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
2388
- const render = () => {
2389
- if (renderer) try {
2390
- _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0);
2391
- return inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
2392
- ...inputOrArgs,
2393
- content
2394
- } : inputOrArgs);
2395
- } finally {
2396
- _set_serialize_reason(void 0);
2397
- }
2398
- else if (content) return content();
2399
- };
2400
- result = shouldResume ? withBranchId(branchId, render) : render();
2401
- rendered = _peek_scope_id() !== branchId;
2402
- if (beforeBranch !== void 0) {
2403
- applyBranchStart(chunk, beforeBranch, rendered);
2404
- _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : "")));
2405
- }
2406
- }
2407
- if (rendered) {
2408
- if (shouldResume) writeScope(scopeId, { [ConditionalRenderer$1 + accessor]: rendererKey(renderer) });
2409
- } else _scope_id();
2410
- return result;
2411
- };
2412
- ((originalDynamicTag) => (patch) => {
2413
- _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2414
- const patched = patch(tag, scopeId, accessor);
2415
- if (patched !== tag) patched["id"] = tag;
2416
- return originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
2417
- };
2418
- })(_dynamic_tag);
2419
2128
  //#endregion
2420
2129
  //#region src/translator/util/runtime.ts
2421
2130
  const pureDOMFunctions = /* @__PURE__ */ new Set([
@@ -2536,26 +2245,6 @@ function sectionHasSetupStatements(section) {
2536
2245
  return false;
2537
2246
  }
2538
2247
  //#endregion
2539
- //#region src/translator/util/binding-has-prop.ts
2540
- function isSectionRendererElided(section) {
2541
- return !!section.downstreamBinding && !bindingHasProperty(section.downstreamBinding.binding, section.downstreamBinding.properties);
2542
- }
2543
- function bindingHasProperty(binding, properties) {
2544
- if (binding.pruned) return false;
2545
- else if (binding.pruned === void 0) throw new Error("Binding must be pruned before checking properties");
2546
- if (binding.reads.size || !properties) return true;
2547
- let property;
2548
- let rest;
2549
- if (Array.isArray(properties)) {
2550
- property = properties[0];
2551
- rest = properties.length === 2 ? properties[1] : properties.slice(1);
2552
- } else property = properties;
2553
- const propBinding = binding.propertyAliases.get(property);
2554
- if (propBinding && bindingHasProperty(propBinding, rest)) return true;
2555
- for (const alias of binding.aliases) if (bindingHasProperty(alias, properties)) return true;
2556
- return false;
2557
- }
2558
- //#endregion
2559
2248
  //#region src/translator/util/module-registrations.ts
2560
2249
  /**
2561
2250
  * Writes the registrations for module scoped functions: the ones this template
@@ -3211,6 +2900,7 @@ function getSignal(section, referencedBindings, name) {
3211
2900
  values: [],
3212
2901
  intersection: void 0,
3213
2902
  forwards: void 0,
2903
+ prepare: [],
3214
2904
  render: [],
3215
2905
  effect: [],
3216
2906
  hasHTMLEffect: false,
@@ -3275,7 +2965,7 @@ function initValue(binding, isLet = false) {
3275
2965
  return signal;
3276
2966
  }
3277
2967
  function signalHasStatements(signal) {
3278
- if (signal.extraArgs || signal.forcePersist || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
2968
+ if (signal.extraArgs || signal.forcePersist || signal.prepare.length || signal.render.length || signal.effect.length || signal.hasHTMLEffect || signal.values.length || signal.intersection) return true;
3279
2969
  const binding = signal.referencedBindings;
3280
2970
  if (binding) {
3281
2971
  if (!Array.isArray(binding) && (binding.closureSections || binding.type === 0 || binding.section === signal.section && (binding.hoists || binding.aliases.size || hasNonConstantPropertyAlias(binding)))) return true;
@@ -3373,20 +3063,21 @@ function getSignalFn(signal) {
3373
3063
  signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(effectIdentifier, [scopeIdentifier])));
3374
3064
  }
3375
3065
  if (isValue && getSerializeReason(section, binding)) signal.hasSideEffect = true;
3066
+ const render = signal.prepare.length ? signal.prepare.concat(signal.render) : signal.render;
3376
3067
  if (!signal.hasSideEffect) {
3377
- if (isValue && signal.render.length === 1) {
3378
- const render = signal.render[0];
3379
- if (render.type === "ExpressionStatement") {
3380
- const { expression } = render;
3068
+ if (isValue && render.length === 1) {
3069
+ const first = render[0];
3070
+ if (first.type === "ExpressionStatement") {
3071
+ const { expression } = first;
3381
3072
  if (expression.type === "CallExpression" && expression.callee.type === "Identifier" && expression.arguments.length === 2 && expression.arguments[0] === scopeIdentifier && isOwnValueRead(expression.arguments[1], binding)) return expression.callee;
3382
3073
  }
3383
3074
  }
3384
- return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(signal.render));
3075
+ return _marko_compiler.types.arrowFunctionExpression(isValue ? [scopeIdentifier, getSignalValueIdentifier(signal)] : [scopeIdentifier], toFirstExpressionOrBlock(render));
3385
3076
  }
3386
- if (signal.render.length === 1) {
3387
- const render = signal.render[0];
3388
- if (render.type === "ExpressionStatement") {
3389
- const { expression } = render;
3077
+ if (render.length === 1) {
3078
+ const first = render[0];
3079
+ if (first.type === "ExpressionStatement") {
3080
+ const { expression } = first;
3390
3081
  if (expression.type === "CallExpression") {
3391
3082
  const args = expression.arguments;
3392
3083
  if (args.length === 1 && args[0] === scopeIdentifier) {
@@ -3396,7 +3087,7 @@ function getSignalFn(signal) {
3396
3087
  }
3397
3088
  }
3398
3089
  }
3399
- return _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], _marko_compiler.types.blockStatement(signal.render));
3090
+ return _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], _marko_compiler.types.blockStatement(render));
3400
3091
  }
3401
3092
  const hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
3402
3093
  const emptyExtraArgs = [];
@@ -5796,7 +5487,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
5796
5487
  const extra = tag.node.extra;
5797
5488
  if (extra[kOnlyChildInParent] !== void 0) return extra[kOnlyChildInParent];
5798
5489
  const parentTag = getParentTag(tag);
5799
- return extra[kOnlyChildInParent] = parentTag && (0, _marko_compiler_babel_utils.getTagDef)(parentTag)?.html && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
5490
+ return extra[kOnlyChildInParent] = parentTag && analyzeTagNameType(parentTag) === 0 && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter((node) => node.type !== "MarkoComment").length === branchSize ? parentTag.node.name.value : false;
5800
5491
  }
5801
5492
  function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
5802
5493
  if (getOnlyChildParentTagName(tag, branchSize)) {
@@ -6364,6 +6055,9 @@ var program_default = {
6364
6055
  const paramsBinding = programExtra.binding;
6365
6056
  if (paramsBinding && !paramsBinding.pruned) programExtra.domExports.params = getBindingPropTree(paramsBinding);
6366
6057
  const section = programExtra.section;
6058
+ forEachSection((childSection) => {
6059
+ programExtra.hasResumes ||= !!(childSection.serializeReason || childSection.serializeReasons.size || childSection !== section && !isSectionRendererElided(childSection) && getSectionRegisterReasons(childSection));
6060
+ });
6367
6061
  if (!section.hoistedTo && !sectionHasSetupStatements(section)) programExtra.domExports.setupEmpty = true;
6368
6062
  }
6369
6063
  },
@@ -6382,22 +6076,16 @@ var program_default = {
6382
6076
  if (isLoadEntry) {
6383
6077
  const entryFile = program.hub.file;
6384
6078
  const { filename } = entryFile.opts;
6385
- program.node.body = [_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("ready"), _marko_compiler.types.identifier("ready"))], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))), _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename))]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("ready"), [_marko_compiler.types.stringLiteral(getReadyId(entryFile))]))]))];
6079
+ const readyId = getReadyId(entryFile);
6080
+ const report = !markoOpts.optimize;
6081
+ program.node.body = [_marko_compiler.types.importDeclaration([_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("ready"), _marko_compiler.types.identifier("ready")), ...report ? [_marko_compiler.types.importSpecifier(_marko_compiler.types.identifier("readyFailed"), _marko_compiler.types.identifier("readyFailed"))] : []], _marko_compiler.types.stringLiteral(getRuntimePath("dom"))), _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.memberExpression(_marko_compiler.types.callExpression(_marko_compiler.types.import(), [_marko_compiler.types.stringLiteral((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename))]), _marko_compiler.types.identifier("then")), [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("ready"), [_marko_compiler.types.stringLiteral(readyId)])), ...report ? [_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.callExpression(_marko_compiler.types.identifier("readyFailed"), [_marko_compiler.types.stringLiteral(readyId)]))] : []]))];
6386
6082
  program.skip();
6387
6083
  return;
6388
6084
  }
6389
6085
  if (isDOMPageEntry) {
6390
6086
  const entryFile = program.hub.file;
6391
- const { filename } = entryFile.opts;
6392
- const visitedFiles = /* @__PURE__ */ new Set([(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, filename)]);
6393
- entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
6394
- if (!visitedFiles.has(resolved)) {
6395
- visitedFiles.add(resolved);
6396
- const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
6397
- if (file) entry_builder_default.visit(file, entryFile, (id) => visitChild(resolveRelativeToEntry(entryFile, file, id)));
6398
- }
6399
- });
6400
- program.node.body = entry_builder_default.build(entryFile);
6087
+ builder.visit(entryFile, entryFile);
6088
+ program.node.body = builder.build(entryFile);
6401
6089
  program.skip();
6402
6090
  return;
6403
6091
  }
@@ -6444,13 +6132,16 @@ var program_default = {
6444
6132
  //#endregion
6445
6133
  //#region src/translator/util/set-tag-sections-downstream.ts
6446
6134
  const [getTagDownstreams] = createSectionState("tag-downstreams", () => /* @__PURE__ */ new Map());
6447
- function setTagDownstream(tag, binding) {
6448
- if (binding) getTagDownstreams(getSection(tag)).set(tag, binding);
6135
+ function setTagDownstream(tag, binding, exprs) {
6136
+ if (binding) getTagDownstreams(getSection(tag)).set(tag, {
6137
+ binding,
6138
+ exprs
6139
+ });
6449
6140
  }
6450
6141
  function finalizeTagDownstreams(section) {
6451
- for (const [tag, binding] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding);
6142
+ for (const [tag, { binding, exprs }] of getTagDownstreams(section)) crawlSectionsAndSetBinding(tag, binding, exprs);
6452
6143
  }
6453
- function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
6144
+ function crawlSectionsAndSetBinding(tag, binding, exprs, properties, skip) {
6454
6145
  if (!skip) {
6455
6146
  const contentSection = getSectionForBody(tag.get("body"));
6456
6147
  if (contentSection) {
@@ -6460,7 +6151,8 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
6460
6151
  });
6461
6152
  contentSection.downstreamBinding = target && (target.noSerialize || includes(target.noSerializeProperties, "content")) ? false : {
6462
6153
  binding,
6463
- properties: concat(properties, "content")
6154
+ properties: concat(properties, "content"),
6155
+ exprs
6464
6156
  };
6465
6157
  }
6466
6158
  }
@@ -6469,8 +6161,8 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip) {
6469
6161
  const attrTags = getAttrTagPaths(tag);
6470
6162
  for (const child of attrTags) if (child.isMarkoTag()) if ((0, _marko_compiler_babel_utils.isAttributeTag)(child)) {
6471
6163
  const attrTagMeta = attrTagLookup[getTagName(child)];
6472
- crawlSectionsAndSetBinding(child, binding, concat(properties, attrTagMeta.name));
6473
- } else crawlSectionsAndSetBinding(child, binding, properties, true);
6164
+ crawlSectionsAndSetBinding(child, binding, exprs, concat(properties, attrTagMeta.name));
6165
+ } else crawlSectionsAndSetBinding(child, binding, exprs, properties, true);
6474
6166
  }
6475
6167
  //#endregion
6476
6168
  //#region src/translator/util/translate-var.ts
@@ -6537,10 +6229,10 @@ function knownTagAnalyze(tag, contentSection, propTree) {
6537
6229
  startSection(tagBody);
6538
6230
  trackParamsReferences(tagBody, 3);
6539
6231
  getKnownTags(section).push(tagExtra);
6540
- setTagDownstream(tag, propTree?.props?.[0]?.binding);
6541
6232
  tagExtra[kContentSection] = contentSection;
6542
6233
  const varBinding = trackVarReferences(tag, 5);
6543
6234
  const exprs = tagExtra[kKnownExprs] = analyzeParams(tagExtra, section, tag, propTree, attrExprs);
6235
+ setTagDownstream(tag, propTree?.props?.[0]?.binding, exprs);
6544
6236
  if (varBinding) {
6545
6237
  addSetupStatement(section);
6546
6238
  const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
@@ -6630,7 +6322,7 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
6630
6322
  if (!isOptimize()) changeArgs.push(_marko_compiler.types.stringLiteral(varBinding.name));
6631
6323
  return _marko_compiler.types.callExpression(importRuntime("_var_change"), changeArgs);
6632
6324
  };
6633
- addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6325
+ addStatement("prepare", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
6634
6326
  }
6635
6327
  callSetup?.(tagSection, childScopeBinding);
6636
6328
  if (propTree) writeParamsToSignals(tag, propTree, getTagName(tag) || "tag", {
@@ -6656,7 +6348,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6656
6348
  }
6657
6349
  if (!propTree.props || propTree.rest || tag.node.arguments?.some((node) => _marko_compiler.types.isSpreadElement(node))) {
6658
6350
  const extra = inputExpr.value = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
6659
- setBindingDownstream(propTree.binding, extra);
6351
+ setBindingDownstream(propTree.binding, extra, inputExpr);
6660
6352
  return inputExpr;
6661
6353
  }
6662
6354
  const known = inputExpr.known = {};
@@ -6671,7 +6363,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6671
6363
  i++;
6672
6364
  }
6673
6365
  const attrPropsTree = propTree.props[i];
6674
- if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs);
6366
+ if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs, inputExpr);
6675
6367
  else {
6676
6368
  const args = tag.node.arguments;
6677
6369
  tag.node.arguments = null;
@@ -6680,11 +6372,11 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6680
6372
  }
6681
6373
  return inputExpr;
6682
6374
  }
6683
- function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6375
+ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs, rootExprs) {
6684
6376
  const inputExpr = {};
6685
6377
  if (!propTree.props) {
6686
6378
  const extra = inputExpr.value = mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
6687
- setBindingDownstream(propTree.binding, extra);
6379
+ setBindingDownstream(propTree.binding, extra, rootExprs);
6688
6380
  return inputExpr;
6689
6381
  }
6690
6382
  const known = inputExpr.known = {};
@@ -6716,7 +6408,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6716
6408
  known[attrTagMeta.name] = { value: rootTagExtra };
6717
6409
  } else if (childAttrExport.props) {
6718
6410
  remaining.delete(attrTagMeta.name);
6719
- known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs);
6411
+ known[attrTagMeta.name] = analyzeAttrs(rootTagExtra, section, child, childAttrExport, rootAttrExprs, rootExprs);
6720
6412
  } else analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
6721
6413
  } else {
6722
6414
  const group = child.node.extra.attributeTagGroup;
@@ -6752,7 +6444,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6752
6444
  const groupKnownValue = { value: groupExtra };
6753
6445
  rootAttrExprs.add(groupExtra);
6754
6446
  forEach(bindings, (binding) => {
6755
- setBindingDownstream(binding, groupExtra);
6447
+ setBindingDownstream(binding, groupExtra, rootExprs);
6756
6448
  });
6757
6449
  for (const name of group) {
6758
6450
  const attrTagMeta = attrTagLookup[name];
@@ -6795,7 +6487,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6795
6487
  known[attr.name] = { value: attrExtra };
6796
6488
  rootAttrExprs.add(attrExtra);
6797
6489
  addSetupExpr(section, attr.value);
6798
- setBindingDownstream(templateExportAttr.binding, attrExtra);
6490
+ setBindingDownstream(templateExportAttr.binding, attrExtra, rootExprs);
6799
6491
  if (getRootSection(templateExportAttr.binding.section) !== (0, _marko_compiler_babel_utils.getProgram)().node.extra.section && isInvokeOnlyBinding(templateExportAttr.binding)) attrExtra.invokeOnly = true;
6800
6492
  if (knownSpread && !includes(knownSpread.binding.excludeProperties, attr.name)) addRead(attrExtra, {}, getOrCreatePropertyAlias(knownSpread.binding, attr.name), section, void 0);
6801
6493
  }
@@ -6813,16 +6505,16 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
6813
6505
  known[prop] = { value: propExtra };
6814
6506
  rootAttrExprs.add(propExtra);
6815
6507
  addRead(propExtra, propExtra, propBinding, section, void 0);
6816
- setBindingDownstream(templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding, propExtra);
6508
+ setBindingDownstream(templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding, propExtra, rootExprs);
6817
6509
  }
6818
6510
  else if (spreadReferenceNodes) if (remaining.size || propTree.rest && !propTree.rest.props) {
6819
6511
  inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
6820
- setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value);
6512
+ setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value, rootExprs);
6821
6513
  } else dropNodes(spreadReferenceNodes);
6822
6514
  else {
6823
6515
  if (restReferenceNodes) {
6824
6516
  inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
6825
- setBindingDownstream(propTree.rest.binding, inputExpr.value);
6517
+ setBindingDownstream(propTree.rest.binding, inputExpr.value, rootExprs);
6826
6518
  }
6827
6519
  if (remaining.size) addSetupStatement(section);
6828
6520
  if (propTree.rest && !propTree.rest.props) addSetupExpr(section, tag.node);
@@ -7057,41 +6749,6 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
7057
6749
  if (propTree.rest && !propTree.rest.props) addStatement("render", info.tagSection, tagReferencedBindings, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(info.getBindingIdentifier(propTree.rest.binding, importAlias + "_$rest"), [createScopeReadExpression(info.childScopeBinding, info.tagSection), _marko_compiler.types.objectExpression(restProps || [])])), true);
7058
6750
  }
7059
6751
  }
7060
- function mapParamReasonToExpr(exprs, reason) {
7061
- if (reason) {
7062
- if (reason === true) return true;
7063
- const result = /* @__PURE__ */ new Set();
7064
- forEach(reason, (prop) => {
7065
- forEach(mapParamBindingToExpr(exprs, prop), (expr) => {
7066
- result.add(expr);
7067
- });
7068
- });
7069
- return fromIter(result);
7070
- }
7071
- }
7072
- function mapParamBindingToExpr(exprs, binding) {
7073
- const isWholeAlias = binding.property === void 0 && binding.upstreamAlias !== void 0;
7074
- const props = [];
7075
- let curBinding = isWholeAlias ? binding.upstreamAlias : binding;
7076
- while (curBinding && (curBinding.property !== void 0 || curBinding.upstreamAlias)) {
7077
- if (curBinding.property !== void 0) props.push(curBinding.property);
7078
- curBinding = curBinding.upstreamAlias;
7079
- }
7080
- let curExpr = exprs;
7081
- for (let i = props.length; i--;) {
7082
- const nestedExpr = curExpr.known?.[props[i]];
7083
- if (!nestedExpr) return curExpr.value;
7084
- curExpr = nestedExpr;
7085
- }
7086
- if (isWholeAlias) {
7087
- let result = curExpr.value;
7088
- if (curExpr.known) {
7089
- for (const key in curExpr.known) if (!includes(binding.excludeProperties, key)) result = concat(result, curExpr.known[key].value);
7090
- }
7091
- return result;
7092
- }
7093
- return curExpr.value;
7094
- }
7095
6752
  function callStatement(id, ...args) {
7096
6753
  return _marko_compiler.types.expressionStatement(callExpression(id, ...args));
7097
6754
  }
@@ -7730,10 +7387,11 @@ function getCollapsibleIntersectionSource(intersection, section) {
7730
7387
  const source = sources.state || sources.param;
7731
7388
  return source && !Array.isArray(source) && source.section === section && !source.scopeOffset ? source : void 0;
7732
7389
  }
7733
- function setBindingDownstream(binding, expr) {
7390
+ function setBindingDownstream(binding, expr, exprs) {
7734
7391
  getBindingValueExprs().set(binding, expr || false);
7735
7392
  if (expr && expr !== true) forEach(expr, (expr) => {
7736
7393
  expr.downstream = bindingUtil.add(expr.downstream, binding);
7394
+ if (exprs) expr.downstreamExprs = exprs;
7737
7395
  });
7738
7396
  }
7739
7397
  const [getResolvedSources] = createProgramState(() => /* @__PURE__ */ new Set());
@@ -8301,7 +7959,12 @@ function getAllSerializeReasonsForExtra(extra) {
8301
7959
  else {
8302
7960
  serializeReasonCache.set(extra, false);
8303
7961
  forEach(extra.downstream, (binding) => {
8304
- reason = mergeSerializeReasons(reason, getAllSerializeReasonsForBinding(binding, true));
7962
+ let linked = getAllSerializeReasonsForBinding(binding, true);
7963
+ if (linked && linked !== true) {
7964
+ const exprs = extra.downstreamExprs;
7965
+ if (exprs) linked = mapDownstreamReason(binding.section.program, linked, exprs);
7966
+ }
7967
+ reason = mergeSerializeReasons(reason, linked);
8305
7968
  });
8306
7969
  }
8307
7970
  if (reason) serializeReasonCache.set(extra, reason);
@@ -8383,6 +8046,41 @@ function setReadsOwner(from, to) {
8383
8046
  cur = cur.parent;
8384
8047
  }
8385
8048
  }
8049
+ function mapParamReasonToExpr(exprs, reason) {
8050
+ if (reason) {
8051
+ if (reason === true) return true;
8052
+ const result = /* @__PURE__ */ new Set();
8053
+ forEach(reason, (prop) => {
8054
+ forEach(mapParamBindingToExpr(exprs, prop), (expr) => {
8055
+ result.add(expr);
8056
+ });
8057
+ });
8058
+ return fromIter(result);
8059
+ }
8060
+ }
8061
+ function mapParamBindingToExpr(exprs, binding) {
8062
+ const isWholeAlias = binding.property === void 0 && binding.upstreamAlias !== void 0;
8063
+ const props = [];
8064
+ let curBinding = isWholeAlias ? binding.upstreamAlias : binding;
8065
+ while (curBinding && (curBinding.property !== void 0 || curBinding.upstreamAlias)) {
8066
+ if (curBinding.property !== void 0) props.push(curBinding.property);
8067
+ curBinding = curBinding.upstreamAlias;
8068
+ }
8069
+ let curExpr = exprs;
8070
+ for (let i = props.length; i--;) {
8071
+ const nestedExpr = curExpr.known?.[props[i]];
8072
+ if (!nestedExpr) return curExpr.value;
8073
+ curExpr = nestedExpr;
8074
+ }
8075
+ if (isWholeAlias) {
8076
+ let result = curExpr.value;
8077
+ if (curExpr.known) {
8078
+ for (const key in curExpr.known) if (!includes(binding.excludeProperties, key)) result = concat(result, curExpr.known[key].value);
8079
+ }
8080
+ return result;
8081
+ }
8082
+ return curExpr.value;
8083
+ }
8386
8084
  //#endregion
8387
8085
  //#region src/translator/core/await.ts
8388
8086
  const kDOMBinding$2 = Symbol("await tag dom binding");
@@ -9811,6 +9509,7 @@ var import_declaration_default = {
9811
9509
  const { file } = importDecl.hub;
9812
9510
  const loadFile = tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value);
9813
9511
  if (!loadFile) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
9512
+ (file.path.node.extra.loadImports ??= /* @__PURE__ */ new Set()).add(loadFile.opts.filename);
9814
9513
  if (loadFile.ast.program.extra?.featureType === "class") throw importDecl.buildCodeFrameError(`The [\`load\` import attribute](https://markojs.com/docs/reference/lazy-loading) is not supported for the Marko 5 (class API) tag \`${value}\`. Import it without \`load\`, or migrate the tag to the tags API.`);
9815
9514
  }
9816
9515
  },
@@ -10173,7 +9872,7 @@ var scriptlet_default = {
10173
9872
  return;
10174
9873
  }
10175
9874
  mergeReferences(getOrCreateSection(scriptlet), scriptlet.node, scriptlet.node.body);
10176
- if (scriptlet.node.target === "client") (0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
9875
+ if (scriptlet.node.target === "client") (0, _marko_compiler_babel_utils.getProgram)().node.extra.hasClientStatement = true;
10177
9876
  },
10178
9877
  translate: { exit(scriptlet) {
10179
9878
  const { node } = scriptlet;
@@ -10335,10 +10034,18 @@ function getTagRelativePath(tag) {
10335
10034
  if (!relativePath) throw tagNotFoundError(tag);
10336
10035
  return relativePath;
10337
10036
  }
10037
+ const staticHint = "To declare module level JavaScript, prefix the statement with `static`.";
10338
10038
  const knownWrongTags = /* @__PURE__ */ new Map([
10339
10039
  ["slot", "To render content passed to this tag, use a [dynamic tag](https://markojs.com/docs/reference/language#dynamic-tags): `<${input.content}/>`."],
10340
10040
  ["state", "Reactive state is declared with the [`<let>` tag](https://markojs.com/docs/reference/core-tag#let): `<let/name=initialValue>`."],
10341
- ["fragment", "Marko templates and tag bodies may have multiple root nodes; no fragment wrapper is needed."]
10041
+ ["fragment", "Marko templates and tag bodies may have multiple root nodes; no fragment wrapper is needed."],
10042
+ ["async", staticHint],
10043
+ ["class", staticHint],
10044
+ ["declare", staticHint],
10045
+ ["enum", staticHint],
10046
+ ["function", staticHint],
10047
+ ["interface", staticHint],
10048
+ ["type", staticHint]
10342
10049
  ]);
10343
10050
  function tagNotFoundError(tag) {
10344
10051
  const tagName = getTagName(tag);
@@ -10352,7 +10059,7 @@ function tagNotFoundError(tag) {
10352
10059
  const closestTag = (0, fastest_levenshtein.closest)(tagName, Object.keys((0, _marko_compiler_babel_utils.getTaglibLookup)(tag.hub.file).merged.tags));
10353
10060
  if ((0, fastest_levenshtein.distance)(tagName, closestTag) < 4) didYouMean = ` Did you mean \`<${closestTag}>\`?`;
10354
10061
  }
10355
- return tag.get("name").buildCodeFrameError(`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.${didYouMean}`);
10062
+ return tag.get("name").buildCodeFrameError(`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName ?? getStaticTagName(tag.node)}>\`.${didYouMean}`);
10356
10063
  }
10357
10064
  const wordReg = /^[A-Za-z]+$/;
10358
10065
  function getProseText(tag) {
@@ -10720,7 +10427,7 @@ var text_default = {
10720
10427
  function buildAggregateError(file, rootMsg, ...paths) {
10721
10428
  const err = /* @__PURE__ */ new SyntaxError();
10722
10429
  const fileName = path.default.relative(_marko_compiler_modules.cwd, file.opts.filename);
10723
- const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$14]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, path$14)}:\x1b[0m\n${getFrame(file, path$14)}`).join("\n\n")}`;
10430
+ const finalMsg = `${rootMsg}:\n\n${paths.map(([msg, path$13]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, path$13)}:\x1b[0m\n${getFrame(file, path$13)}`).join("\n\n")}`;
10724
10431
  if (!("MARKO_DEBUG" in process.env)) err.stack = finalMsg;
10725
10432
  Object.defineProperty(err, "message", {
10726
10433
  get() {
@@ -10884,24 +10591,30 @@ function createInteropTranslator(translate5) {
10884
10591
  })));
10885
10592
  };
10886
10593
  return [
10887
- importHydrateProgram("6", entry_builder_default.build(entryFile, true)),
10594
+ ...state.needsCompat ? [_marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(getCompatRuntimeFile()))] : [],
10595
+ ...Array.from(state.compatFiles, (compatFile) => _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(compatFile))),
10596
+ importHydrateProgram("6", builder.build(entryFile, true)),
10888
10597
  importHydrateProgram("5", translate5.internalEntryBuilder.build(entryFile, true)),
10889
10598
  _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init6"), [])),
10890
10599
  _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier("init5"), []))
10891
10600
  ];
10892
10601
  } else return translate5.internalEntryBuilder.build(entryFile);
10893
- else return entry_builder_default.build(entryFile);
10602
+ else return builder.build(entryFile);
10894
10603
  },
10895
10604
  visit(file, entryFile, visitChild) {
10896
10605
  const state = entryFile[kState] ||= {
10897
10606
  has5: false,
10898
- has6: false
10607
+ has6: false,
10608
+ needsCompat: false,
10609
+ compatFiles: /* @__PURE__ */ new Set()
10899
10610
  };
10900
10611
  if (isTagsAPI(file)) {
10901
10612
  state.has6 = true;
10902
- entry_builder_default.visit(file, entryFile, visitChild);
10613
+ builder.visit(file, entryFile, visitChild);
10903
10614
  } else {
10904
10615
  state.has5 = true;
10616
+ if (file.path.node.extra?.resumesCompat) state.needsCompat = true;
10617
+ if (file.path.node.extra?.resumesClassFns) state.compatFiles.add((0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, file.opts.filename));
10905
10618
  translate5.internalEntryBuilder.visit(file, entryFile, visitChild);
10906
10619
  }
10907
10620
  }
@@ -10914,13 +10627,13 @@ function createInteropTranslator(translate5) {
10914
10627
  const entryFile = program.hub.file;
10915
10628
  const { output, entry } = entryFile.markoOpts;
10916
10629
  if (!(output === "dom" && entry === "page" || output === "hydrate")) return enterProgram?.call(this, program, state);
10917
- const visitedFiles = /* @__PURE__ */ new Set([(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename)]);
10918
- entryBuilder.visit(entryFile, entryFile, function visitChild(resolved) {
10919
- if (!visitedFiles.has(resolved)) {
10920
- visitedFiles.add(resolved);
10921
- const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
10922
- if (file) entryBuilder.visit(file, entryFile, (id) => visitChild(resolveRelativeToEntry(entryFile, file, id)));
10923
- }
10630
+ const visitedFiles = /* @__PURE__ */ new Map([[(0, _marko_compiler_babel_utils.resolveRelativePath)(entryFile, entryFile.opts.filename), false]]);
10631
+ entryBuilder.visit(entryFile, entryFile, function visitChild(resolved, bundled = false) {
10632
+ const seenBundled = visitedFiles.get(resolved);
10633
+ if (seenBundled === false || seenBundled && bundled) return;
10634
+ visitedFiles.set(resolved, bundled);
10635
+ const file = (0, _marko_compiler_babel_utils.loadFileForImport)(entryFile, resolved);
10636
+ if (file) entryBuilder.visit(file, entryFile, (id, childBundled = false) => visitChild(resolveRelativeToEntry(entryFile, file, id), childBundled || bundled));
10924
10637
  });
10925
10638
  program.node.body = entryBuilder.build(entryFile);
10926
10639
  program.skip();
@@ -10936,13 +10649,13 @@ function mergeVisitors(visitor5, visitor6) {
10936
10649
  function mergeVisit(visit5, visit6) {
10937
10650
  const enter5 = getVisitorEnter(visit5);
10938
10651
  const enter6 = getVisitorEnter(visit6);
10939
- const enter = (enter5 || enter6) && function enter(path$10, state) {
10940
- return (isTagsAPI() ? enter6 : enter5)?.call(this, path$10, state);
10652
+ const enter = (enter5 || enter6) && function enter(path$9, state) {
10653
+ return (isTagsAPI() ? enter6 : enter5)?.call(this, path$9, state);
10941
10654
  };
10942
10655
  const exit5 = getVisitorExit(visit5);
10943
10656
  const exit6 = getVisitorExit(visit6);
10944
- const exit = (exit5 || exit6) && function exit(path$11, state) {
10945
- return (isTagsAPI() ? exit6 : exit5)?.call(this, path$11, state);
10657
+ const exit = (exit5 || exit6) && function exit(path$10, state) {
10658
+ return (isTagsAPI() ? exit6 : exit5)?.call(this, path$10, state);
10946
10659
  };
10947
10660
  return exit ? enter ? {
10948
10661
  enter,
@@ -11025,17 +10738,17 @@ function sequenceVisit(first, second) {
11025
10738
  if (!first || !second) return first || second;
11026
10739
  const enterFirst = getVisitorEnter(first);
11027
10740
  const enterSecond = getVisitorEnter(second);
11028
- const enter = (enterFirst || enterSecond) && function enter(path$12, state) {
11029
- const { node } = path$12;
11030
- enterFirst?.call(this, path$12, state);
11031
- if (path$12.node === node) enterSecond?.call(this, path$12, state);
10741
+ const enter = (enterFirst || enterSecond) && function enter(path$11, state) {
10742
+ const { node } = path$11;
10743
+ enterFirst?.call(this, path$11, state);
10744
+ if (path$11.node === node) enterSecond?.call(this, path$11, state);
11032
10745
  };
11033
10746
  const exitFirst = getVisitorExit(first);
11034
10747
  const exitSecond = getVisitorExit(second);
11035
- const exit = (exitFirst || exitSecond) && function exit(path$13, state) {
11036
- const { node } = path$13;
11037
- exitFirst?.call(this, path$13, state);
11038
- if (path$13.node === node) exitSecond?.call(this, path$13, state);
10748
+ const exit = (exitFirst || exitSecond) && function exit(path$12, state) {
10749
+ const { node } = path$12;
10750
+ exitFirst?.call(this, path$12, state);
10751
+ if (path$12.node === node) exitSecond?.call(this, path$12, state);
11039
10752
  };
11040
10753
  return exit ? enter ? {
11041
10754
  enter,
@@ -11083,7 +10796,7 @@ exports.analyze = analyze;
11083
10796
  exports.cheatsheet = cheatsheet;
11084
10797
  exports.createInteropTranslator = createInteropTranslator;
11085
10798
  exports.getRuntimeEntryFiles = getRuntimeEntryFiles;
11086
- exports.internalEntryBuilder = entry_builder_default;
10799
+ exports.internalEntryBuilder = builder;
11087
10800
  exports.preferAPI = preferAPI;
11088
10801
  exports.tagDiscoveryDirs = tagDiscoveryDirs;
11089
10802
  exports.taglibs = taglibs;