marko 6.0.0-next.3.65 → 6.0.0-next.3.67

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.
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/translator/index.ts
31
- var translator_exports = {};
32
- __export(translator_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  analyze: () => analyze,
34
34
  getRuntimeEntryFiles: () => getRuntimeEntryFiles,
35
35
  internalEntryBuilder: () => entry_builder_default,
@@ -39,7 +39,7 @@ __export(translator_exports, {
39
39
  transform: () => transform,
40
40
  translate: () => translate
41
41
  });
42
- module.exports = __toCommonJS(translator_exports);
42
+ module.exports = __toCommonJS(index_exports);
43
43
 
44
44
  // src/translator/util/runtime-info.ts
45
45
  var import_package = require("../../package.json");
@@ -109,7 +109,7 @@ var attrs_default = {
109
109
  };
110
110
 
111
111
  // src/translator/core/await.ts
112
- var import_compiler23 = require("@marko/compiler");
112
+ var import_compiler24 = require("@marko/compiler");
113
113
  var import_babel_utils12 = require("@marko/compiler/babel-utils");
114
114
 
115
115
  // src/common/accessor.debug.ts
@@ -163,10 +163,10 @@ function evaluate(value) {
163
163
  }
164
164
 
165
165
  // src/translator/util/references.ts
166
- var import_compiler22 = require("@marko/compiler");
166
+ var import_compiler23 = require("@marko/compiler");
167
167
 
168
168
  // src/translator/visitors/program/index.ts
169
- var import_compiler20 = require("@marko/compiler");
169
+ var import_compiler21 = require("@marko/compiler");
170
170
  var import_babel_utils11 = require("@marko/compiler/babel-utils");
171
171
  var import_path2 = __toESM(require("path"));
172
172
 
@@ -853,6 +853,47 @@ var Sorted = class {
853
853
  }
854
854
  }
855
855
  }
856
+ findIndex(data, item) {
857
+ if (data) {
858
+ if (Array.isArray(data)) {
859
+ let max = data.length;
860
+ let pos = 0;
861
+ while (pos < max) {
862
+ const mid = pos + max >>> 1;
863
+ const compareResult = this.compare(data[mid], item);
864
+ if (compareResult === 0) return mid;
865
+ if (compareResult > 0) max = mid;
866
+ else pos = mid + 1;
867
+ }
868
+ return -1;
869
+ }
870
+ if (this.compare(data, item) === 0) {
871
+ return 0;
872
+ }
873
+ }
874
+ return -1;
875
+ }
876
+ isSuperset(superset, subset) {
877
+ if (!subset) {
878
+ return true;
879
+ }
880
+ if (!Array.isArray(subset)) {
881
+ return this.findIndex(superset, subset) !== -1;
882
+ }
883
+ if (!Array.isArray(superset)) {
884
+ return false;
885
+ }
886
+ const subLen = subset.length;
887
+ const supLen = superset.length;
888
+ if (subLen > supLen) {
889
+ return false;
890
+ }
891
+ for (let i = subLen; i--; ) {
892
+ const supIndex = this.findIndex(superset, subset[i]);
893
+ if (supIndex === -1 || supLen - supIndex <= i) return false;
894
+ }
895
+ return true;
896
+ }
856
897
  };
857
898
  function push(data, item) {
858
899
  if (data) {
@@ -1328,17 +1369,26 @@ function getNodeContentType(path5, extraMember, contentInfo) {
1328
1369
  var isSerializedSection = (section) => {
1329
1370
  return !(section.isBranch || section.downstreamBinding?.serialize === false);
1330
1371
  };
1331
- var checkStatefulClosures = (section, immediateOnly) => {
1332
- return !!find(
1333
- section.referencedClosures,
1334
- (closure) => (!immediateOnly || section.parent === closure.section) && isStatefulReferences(closure)
1335
- );
1336
- };
1372
+ function isSectionWithHoists(section) {
1373
+ if (section.hoisted || section.isHoistThrough || section.referencedHoists)
1374
+ return true;
1375
+ }
1337
1376
  function isImmediateOwner(section, binding) {
1338
1377
  return section.parent?.id === binding.section.id;
1339
1378
  }
1379
+ function isDirectClosure(section, closure) {
1380
+ return section.isBranch && isImmediateOwner(section, closure);
1381
+ }
1340
1382
  function isDynamicClosure(section, closure) {
1341
- return !section.isBranch || !isImmediateOwner(section, closure);
1383
+ return !isDirectClosure(section, closure);
1384
+ }
1385
+ function getDirectClosures(section) {
1386
+ if (section.isBranch) {
1387
+ return filter(
1388
+ section.referencedClosures,
1389
+ (closure) => isImmediateOwner(section, closure)
1390
+ );
1391
+ }
1342
1392
  }
1343
1393
  function isSameOrChildSection(section, other) {
1344
1394
  do {
@@ -1380,7 +1430,7 @@ function isNativeNode(tag) {
1380
1430
  }
1381
1431
 
1382
1432
  // src/translator/visitors/program/dom.ts
1383
- var import_compiler18 = require("@marko/compiler");
1433
+ var import_compiler19 = require("@marko/compiler");
1384
1434
  var import_babel_utils10 = require("@marko/compiler/babel-utils");
1385
1435
 
1386
1436
  // src/translator/util/get-style-file.ts
@@ -1420,7 +1470,7 @@ function escapeRegExp(str) {
1420
1470
  }
1421
1471
 
1422
1472
  // src/translator/util/signals.ts
1423
- var import_compiler17 = require("@marko/compiler");
1473
+ var import_compiler18 = require("@marko/compiler");
1424
1474
  var import_babel_utils9 = require("@marko/compiler/babel-utils");
1425
1475
 
1426
1476
  // src/translator/core/return.ts
@@ -1878,7 +1928,9 @@ var return_default = {
1878
1928
  setSerializedProperty(
1879
1929
  section,
1880
1930
  getAccessorProp().TagVariableChange,
1881
- attrs2.valueChange
1931
+ attrs2.valueChange,
1932
+ true
1933
+ // TODO: this should be based on the child actually mutating the tag variable.
1882
1934
  );
1883
1935
  }
1884
1936
  if (attrs2.value) {
@@ -1935,6 +1987,95 @@ var return_default = {
1935
1987
  ]
1936
1988
  };
1937
1989
 
1990
+ // src/translator/util/dynamic-sources.ts
1991
+ var import_compiler12 = require("@marko/compiler");
1992
+ function getDynamicSourcesForBinding(binding) {
1993
+ if (binding.sources) {
1994
+ if (Array.isArray(binding.sources) ? binding.sources.every(isInputBinding) : isInputBinding(binding.sources)) {
1995
+ return binding.sources;
1996
+ }
1997
+ return true;
1998
+ }
1999
+ }
2000
+ function getDynamicSourcesForReferences(referencedBindings) {
2001
+ if (referencedBindings) {
2002
+ let dynamicSources;
2003
+ if (Array.isArray(referencedBindings)) {
2004
+ for (const binding of referencedBindings) {
2005
+ const newDynamicSources = getDynamicSourcesForBinding(binding);
2006
+ if (newDynamicSources === true) return true;
2007
+ dynamicSources = bindingUtil.union(dynamicSources, newDynamicSources);
2008
+ }
2009
+ return dynamicSources;
2010
+ } else {
2011
+ return getDynamicSourcesForBinding(referencedBindings);
2012
+ }
2013
+ }
2014
+ }
2015
+ function getDynamicSourcesForExtra(extra) {
2016
+ if (isReferencedExtra(extra)) {
2017
+ return getDynamicSourcesForReferences(extra.referencedBindings);
2018
+ }
2019
+ }
2020
+ function getDynamicSourcesForExtras(extras) {
2021
+ let allDynamicSources;
2022
+ for (const extra of extras) {
2023
+ const dynamicSources = getDynamicSourcesForExtra(extra);
2024
+ if (dynamicSources === true) return true;
2025
+ allDynamicSources = bindingUtil.union(allDynamicSources, dynamicSources);
2026
+ }
2027
+ return allDynamicSources;
2028
+ }
2029
+ function getDynamicSourcesForSection(section) {
2030
+ const referenced = getDynamicSourcesForReferences(
2031
+ section.upstreamExpression?.referencedBindings
2032
+ );
2033
+ const closures = getDynamicSourcesForReferences(getDirectClosures(section));
2034
+ if (referenced || closures) {
2035
+ return {
2036
+ referenced,
2037
+ closures,
2038
+ all: referenced === true || closures === true ? true : bindingUtil.union(referenced, closures)
2039
+ };
2040
+ }
2041
+ }
2042
+ function getDynamicSourcesForSections(sections) {
2043
+ let first;
2044
+ let merged;
2045
+ for (const section of sections) {
2046
+ const sources = section && getDynamicSourcesForSection(section);
2047
+ if (sources) {
2048
+ if (merged) {
2049
+ merged.referenced = mergeDynamicSources(
2050
+ merged.referenced,
2051
+ sources.referenced
2052
+ );
2053
+ merged.closures = mergeDynamicSources(
2054
+ merged.closures,
2055
+ sources.closures
2056
+ );
2057
+ merged.all = mergeDynamicSources(merged.all, sources.all);
2058
+ } else if (first) {
2059
+ merged = {
2060
+ referenced: mergeDynamicSources(first.referenced, sources.referenced),
2061
+ closures: mergeDynamicSources(first.closures, sources.closures),
2062
+ all: mergeDynamicSources(first.all, sources.all)
2063
+ };
2064
+ } else {
2065
+ first = sources;
2066
+ }
2067
+ }
2068
+ }
2069
+ return merged || first;
2070
+ }
2071
+ function mergeDynamicSources(a, b) {
2072
+ if (a === true || b === true) return true;
2073
+ return bindingUtil.union(a, b);
2074
+ }
2075
+ function isInputBinding(binding) {
2076
+ return binding.type === 2 /* input */;
2077
+ }
2078
+
1938
2079
  // src/translator/util/for-each-identifier.ts
1939
2080
  function forEachIdentifier(node, cb) {
1940
2081
  switch (node.type) {
@@ -1978,10 +2119,10 @@ function forEachIdentifier(node, cb) {
1978
2119
  }
1979
2120
 
1980
2121
  // src/translator/util/get-defined-binding-expression.ts
1981
- var import_compiler12 = require("@marko/compiler");
2122
+ var import_compiler13 = require("@marko/compiler");
1982
2123
  function getDeclaredBindingExpression(binding) {
1983
2124
  if (binding.declared || !binding.upstreamAlias) {
1984
- return import_compiler12.types.identifier(binding.name);
2125
+ return import_compiler13.types.identifier(binding.name);
1985
2126
  } else if (binding.property !== void 0) {
1986
2127
  return toMemberExpression(
1987
2128
  getDeclaredBindingExpression(binding.upstreamAlias),
@@ -1994,10 +2135,10 @@ function getDeclaredBindingExpression(binding) {
1994
2135
  }
1995
2136
 
1996
2137
  // src/translator/util/scope-read.ts
1997
- var import_compiler13 = require("@marko/compiler");
2138
+ var import_compiler14 = require("@marko/compiler");
1998
2139
  function createScopeReadPattern(section, referencedBindings) {
1999
2140
  const rootDepth = section.depth;
2000
- const rootPattern = import_compiler13.types.objectPattern([]);
2141
+ const rootPattern = import_compiler14.types.objectPattern([]);
2001
2142
  let nestedPatterns;
2002
2143
  forEach(referencedBindings, (ref) => {
2003
2144
  const propertyValue = ref.name;
@@ -2011,9 +2152,9 @@ function createScopeReadPattern(section, referencedBindings) {
2011
2152
  let i = nestedPatterns.length;
2012
2153
  let prev = nestedPatterns[i - 1];
2013
2154
  for (; i <= relativeDepth; i++) {
2014
- const nestedPattern = import_compiler13.types.objectPattern([]);
2155
+ const nestedPattern = import_compiler14.types.objectPattern([]);
2015
2156
  prev.properties.push(
2016
- import_compiler13.types.objectProperty(import_compiler13.types.identifier("_"), nestedPattern)
2157
+ import_compiler14.types.objectProperty(import_compiler14.types.identifier("_"), nestedPattern)
2017
2158
  );
2018
2159
  nestedPatterns.push(nestedPattern);
2019
2160
  prev = nestedPattern;
@@ -2021,9 +2162,9 @@ function createScopeReadPattern(section, referencedBindings) {
2021
2162
  pattern = nestedPatterns[relativeDepth];
2022
2163
  }
2023
2164
  pattern.properties.push(
2024
- import_compiler13.types.objectProperty(
2165
+ import_compiler14.types.objectProperty(
2025
2166
  toPropertyName(propertyKey),
2026
- import_compiler13.types.identifier(propertyValue),
2167
+ import_compiler14.types.identifier(propertyValue),
2027
2168
  false,
2028
2169
  isShorthand
2029
2170
  )
@@ -2032,10 +2173,10 @@ function createScopeReadPattern(section, referencedBindings) {
2032
2173
  return rootPattern;
2033
2174
  }
2034
2175
  function getScopeExpression(section, targetSection) {
2035
- let scope = scopeIdentifier ?? import_compiler13.types.identifier("undefined");
2176
+ let scope = scopeIdentifier ?? import_compiler14.types.identifier("undefined");
2036
2177
  const diff = section.depth - targetSection.depth;
2037
2178
  for (let i = 0; i < diff; i++) {
2038
- scope = import_compiler13.types.memberExpression(scope, import_compiler13.types.identifier("_"));
2179
+ scope = import_compiler14.types.memberExpression(scope, import_compiler14.types.identifier("_"));
2039
2180
  }
2040
2181
  if (diff < 0) {
2041
2182
  throw new Error("Unable to find scope for reference.");
@@ -2044,7 +2185,7 @@ function getScopeExpression(section, targetSection) {
2044
2185
  }
2045
2186
  function createScopeReadExpression(section, reference) {
2046
2187
  const propName = toPropertyName(getScopeAccessor(reference));
2047
- return import_compiler13.types.memberExpression(
2188
+ return import_compiler14.types.memberExpression(
2048
2189
  getScopeExpression(section, reference.section),
2049
2190
  propName,
2050
2191
  propName.type !== "Identifier"
@@ -2052,7 +2193,7 @@ function createScopeReadExpression(section, reference) {
2052
2193
  }
2053
2194
 
2054
2195
  // src/translator/util/simplify-fn.ts
2055
- var import_compiler14 = require("@marko/compiler");
2196
+ var import_compiler15 = require("@marko/compiler");
2056
2197
  function simplifyFunction(fn) {
2057
2198
  switch (fn.type) {
2058
2199
  case "FunctionDeclaration":
@@ -2060,7 +2201,7 @@ function simplifyFunction(fn) {
2060
2201
  case "ArrowFunctionExpression":
2061
2202
  return fn;
2062
2203
  default:
2063
- return import_compiler14.types.functionExpression(
2204
+ return import_compiler15.types.functionExpression(
2064
2205
  null,
2065
2206
  fn.params,
2066
2207
  fn.body,
@@ -2071,9 +2212,9 @@ function simplifyFunction(fn) {
2071
2212
  }
2072
2213
 
2073
2214
  // src/translator/util/to-first-expression-or-block.ts
2074
- var import_compiler15 = require("@marko/compiler");
2215
+ var import_compiler16 = require("@marko/compiler");
2075
2216
  function toFirstExpressionOrBlock(stmts) {
2076
- if (stmts.length === 1 && import_compiler15.types.isExpressionStatement(stmts[0])) {
2217
+ if (stmts.length === 1 && import_compiler16.types.isExpressionStatement(stmts[0])) {
2077
2218
  const { expression } = stmts[0];
2078
2219
  switch (expression.type) {
2079
2220
  case "ObjectExpression":
@@ -2083,20 +2224,20 @@ function toFirstExpressionOrBlock(stmts) {
2083
2224
  return expression;
2084
2225
  }
2085
2226
  }
2086
- return import_compiler15.types.blockStatement(stmts);
2227
+ return import_compiler16.types.blockStatement(stmts);
2087
2228
  }
2088
2229
  function toParenthesizedExpressionIfNeeded(expr) {
2089
2230
  switch (expr.type) {
2090
2231
  case "ObjectExpression":
2091
2232
  case "AssignmentExpression":
2092
- return import_compiler15.types.parenthesizedExpression(expr);
2233
+ return import_compiler16.types.parenthesizedExpression(expr);
2093
2234
  default:
2094
2235
  return expr;
2095
2236
  }
2096
2237
  }
2097
2238
 
2098
2239
  // src/translator/util/traverse.ts
2099
- var import_compiler16 = require("@marko/compiler");
2240
+ var import_compiler17 = require("@marko/compiler");
2100
2241
  var skip = Symbol("skip");
2101
2242
  function traverseReplace(container, key, enter3) {
2102
2243
  const node = container[key];
@@ -2106,7 +2247,7 @@ function traverseReplace(container, key, enter3) {
2106
2247
  traverseReplace(node, i, enter3);
2107
2248
  }
2108
2249
  } else {
2109
- const keys = import_compiler16.types.VISITOR_KEYS[node.type];
2250
+ const keys = import_compiler17.types.VISITOR_KEYS[node.type];
2110
2251
  for (let i = keys.length; i--; ) {
2111
2252
  traverseReplace(node, keys[i], enter3);
2112
2253
  }
@@ -2130,7 +2271,7 @@ function traverseContains(node, check) {
2130
2271
  case skip:
2131
2272
  return false;
2132
2273
  }
2133
- for (const key of import_compiler16.types.VISITOR_KEYS[node.type]) {
2274
+ for (const key of import_compiler17.types.VISITOR_KEYS[node.type]) {
2134
2275
  if (traverseContains(node[key], check)) {
2135
2276
  return true;
2136
2277
  }
@@ -2149,13 +2290,26 @@ var [getClosureSignalBuilder, _setClosureSignalBuilder] = createSectionState("qu
2149
2290
  function setClosureSignalBuilder(tag, builder) {
2150
2291
  _setClosureSignalBuilder(getSectionForBody(tag.get("body")), builder);
2151
2292
  }
2152
- var [forceResumeScope, _setForceResumeScope] = createSectionState("forceResumeScope");
2153
- function setForceResumeScope(section) {
2154
- _setForceResumeScope(section, true);
2293
+ var [serializeSectionReason, setSerializeSectionReason] = createSectionState("serializeSectionSources");
2294
+ function serializeSectionIfNeeded(section, reason) {
2295
+ if (reason) {
2296
+ const existingReason = serializeSectionReason(section);
2297
+ if (existingReason === true) return;
2298
+ if (!existingReason || reason === true) {
2299
+ setSerializeSectionReason(section, reason);
2300
+ } else {
2301
+ setSerializeSectionReason(
2302
+ section,
2303
+ bindingUtil.union(existingReason, reason)
2304
+ );
2305
+ }
2306
+ }
2155
2307
  }
2156
2308
  var [getSerializedScopeProperties] = createSectionState("serializedScopeProperties", () => /* @__PURE__ */ new Map());
2157
- function setSerializedProperty(section, key, value) {
2158
- getSerializedScopeProperties(section).set(key, value);
2309
+ function setSerializedProperty(section, key, expression, reason) {
2310
+ if (reason) {
2311
+ getSerializedScopeProperties(section).set(key, { expression, reason });
2312
+ }
2159
2313
  }
2160
2314
  var [getSectionWriteScopeBuilder, setSectionWriteScopeBuilder] = createSectionState(
2161
2315
  "sectionWriteScopeBuilder"
@@ -2187,7 +2341,7 @@ function getHoistFunctionIdentifier(hoistedBinding) {
2187
2341
  return identifier;
2188
2342
  }
2189
2343
  var unimplementedBuild = () => {
2190
- return import_compiler17.types.stringLiteral("SIGNAL NOT INITIALIZED");
2344
+ return import_compiler18.types.stringLiteral("SIGNAL NOT INITIALIZED");
2191
2345
  };
2192
2346
  function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
2193
2347
  const signals = getSignals(section);
@@ -2197,7 +2351,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2197
2351
  signals.set(
2198
2352
  referencedBindings,
2199
2353
  signal = {
2200
- identifier: exportName ? import_compiler17.types.identifier(exportName) : currentProgramPath.scope.generateUidIdentifier(
2354
+ identifier: exportName ? import_compiler18.types.identifier(exportName) : currentProgramPath.scope.generateUidIdentifier(
2201
2355
  name2 + section.name.replace("_", "$")
2202
2356
  ),
2203
2357
  referencedBindings,
@@ -2254,9 +2408,13 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2254
2408
  const { id, scopeOffset } = intersectionMeta.get(referencedBindings);
2255
2409
  return callRuntime(
2256
2410
  "intersection",
2257
- import_compiler17.types.numericLiteral(id),
2258
- getSignalFn(signal, [scopeIdentifier], referencedBindings),
2259
- scopeOffset || referencedBindings.length > 2 ? import_compiler17.types.numericLiteral(referencedBindings.length - 1) : void 0,
2411
+ import_compiler18.types.numericLiteral(id),
2412
+ getSignalFn(
2413
+ signal,
2414
+ [scopeIdentifier],
2415
+ signal.renderReferencedBindings
2416
+ ),
2417
+ scopeOffset || referencedBindings.length > 2 ? import_compiler18.types.numericLiteral(referencedBindings.length - 1) : void 0,
2260
2418
  scopeOffset && getScopeAccessorLiteral(scopeOffset)
2261
2419
  );
2262
2420
  };
@@ -2264,14 +2422,14 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2264
2422
  signal.build = () => {
2265
2423
  const render = getSignalFn(signal, [
2266
2424
  scopeIdentifier,
2267
- import_compiler17.types.identifier(referencedBindings.name)
2425
+ import_compiler18.types.identifier(referencedBindings.name)
2268
2426
  ]);
2269
2427
  const closureSignalBuilder = getClosureSignalBuilder(section);
2270
2428
  return !closureSignalBuilder || isDynamicClosure(section, referencedBindings) ? callRuntime(
2271
2429
  "dynamicClosureRead",
2272
2430
  getScopeAccessorLiteral(referencedBindings),
2273
2431
  render,
2274
- isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler17.types.arrowFunctionExpression(
2432
+ isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler18.types.arrowFunctionExpression(
2275
2433
  [scopeIdentifier],
2276
2434
  getScopeExpression(section, referencedBindings.section)
2277
2435
  )
@@ -2287,7 +2445,7 @@ function initValue(binding, runtimeHelper = "value") {
2287
2445
  signal.build = () => {
2288
2446
  const fn = getSignalFn(signal, [
2289
2447
  scopeIdentifier,
2290
- import_compiler17.types.identifier(binding.name)
2448
+ import_compiler18.types.identifier(binding.name)
2291
2449
  ]);
2292
2450
  const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 2 /* input */);
2293
2451
  const isNakedAlias = binding.upstreamAlias && !binding.property;
@@ -2322,8 +2480,8 @@ function getSignalFn(signal, params, referencedBindings) {
2322
2480
  for (const alias of binding.aliases) {
2323
2481
  const aliasSignal = getSignal(alias.section, alias);
2324
2482
  signal.render.push(
2325
- import_compiler17.types.expressionStatement(
2326
- import_compiler17.types.callExpression(aliasSignal.identifier, [
2483
+ import_compiler18.types.expressionStatement(
2484
+ import_compiler18.types.callExpression(aliasSignal.identifier, [
2327
2485
  scopeIdentifier2,
2328
2486
  valueIdentifier,
2329
2487
  ...getTranslatedExtraArgs(aliasSignal)
@@ -2334,8 +2492,8 @@ function getSignalFn(signal, params, referencedBindings) {
2334
2492
  for (const [key, alias] of binding.propertyAliases) {
2335
2493
  const aliasSignal = getSignal(alias.section, alias);
2336
2494
  signal.render.push(
2337
- import_compiler17.types.expressionStatement(
2338
- import_compiler17.types.callExpression(aliasSignal.identifier, [
2495
+ import_compiler18.types.expressionStatement(
2496
+ import_compiler18.types.callExpression(aliasSignal.identifier, [
2339
2497
  scopeIdentifier2,
2340
2498
  toMemberExpression(valueIdentifier, key, binding.nullable),
2341
2499
  ...getTranslatedExtraArgs(aliasSignal)
@@ -2346,8 +2504,8 @@ function getSignalFn(signal, params, referencedBindings) {
2346
2504
  }
2347
2505
  for (const value of signal.values) {
2348
2506
  signal.render.push(
2349
- import_compiler17.types.expressionStatement(
2350
- import_compiler17.types.callExpression(value.signal.identifier, [
2507
+ import_compiler18.types.expressionStatement(
2508
+ import_compiler18.types.callExpression(value.signal.identifier, [
2351
2509
  value.scope,
2352
2510
  value.value,
2353
2511
  ...getTranslatedExtraArgs(value.signal)
@@ -2357,14 +2515,14 @@ function getSignalFn(signal, params, referencedBindings) {
2357
2515
  }
2358
2516
  forEach(signal.intersection, (intersection) => {
2359
2517
  signal.render.push(
2360
- import_compiler17.types.expressionStatement(import_compiler17.types.callExpression(intersection, [scopeIdentifier2]))
2518
+ import_compiler18.types.expressionStatement(import_compiler18.types.callExpression(intersection, [scopeIdentifier2]))
2361
2519
  );
2362
2520
  });
2363
2521
  if (isValueSignal) {
2364
2522
  let dynamicClosureArgs;
2365
2523
  let dynamicClosureSignalIdentifier;
2366
2524
  forEach(binding.closureSections, (closureSection) => {
2367
- if (isStatefulReferences(binding)) {
2525
+ if (binding.sources) {
2368
2526
  if (isDynamicClosure(closureSection, binding)) {
2369
2527
  if (!dynamicClosureArgs) {
2370
2528
  dynamicClosureArgs = [];
@@ -2372,8 +2530,8 @@ function getSignalFn(signal, params, referencedBindings) {
2372
2530
  signal.identifier.name + "_closure"
2373
2531
  );
2374
2532
  signal.render.push(
2375
- import_compiler17.types.expressionStatement(
2376
- import_compiler17.types.callExpression(dynamicClosureSignalIdentifier, [
2533
+ import_compiler18.types.expressionStatement(
2534
+ import_compiler18.types.callExpression(dynamicClosureSignalIdentifier, [
2377
2535
  scopeIdentifier2
2378
2536
  ])
2379
2537
  )
@@ -2384,8 +2542,8 @@ function getSignalFn(signal, params, referencedBindings) {
2384
2542
  );
2385
2543
  } else {
2386
2544
  signal.render.push(
2387
- import_compiler17.types.expressionStatement(
2388
- import_compiler17.types.callExpression(getSignal(closureSection, binding).identifier, [
2545
+ import_compiler18.types.expressionStatement(
2546
+ import_compiler18.types.callExpression(getSignal(closureSection, binding).identifier, [
2389
2547
  scopeIdentifier2
2390
2548
  ])
2391
2549
  )
@@ -2395,8 +2553,8 @@ function getSignalFn(signal, params, referencedBindings) {
2395
2553
  });
2396
2554
  if (dynamicClosureSignalIdentifier) {
2397
2555
  (signal.prependStatements ||= []).push(
2398
- import_compiler17.types.variableDeclaration("const", [
2399
- import_compiler17.types.variableDeclarator(
2556
+ import_compiler18.types.variableDeclaration("const", [
2557
+ import_compiler18.types.variableDeclarator(
2400
2558
  dynamicClosureSignalIdentifier,
2401
2559
  callRuntime("dynamicClosure", ...dynamicClosureArgs)
2402
2560
  )
@@ -2405,24 +2563,24 @@ function getSignalFn(signal, params, referencedBindings) {
2405
2563
  }
2406
2564
  }
2407
2565
  if (signal.effect.length) {
2408
- const effectIdentifier = import_compiler17.types.identifier(`${signal.identifier.name}_effect`);
2566
+ const effectIdentifier = import_compiler18.types.identifier(`${signal.identifier.name}_effect`);
2409
2567
  signal.render.push(
2410
- import_compiler17.types.expressionStatement(
2411
- import_compiler17.types.callExpression(effectIdentifier, [scopeIdentifier2])
2568
+ import_compiler18.types.expressionStatement(
2569
+ import_compiler18.types.callExpression(effectIdentifier, [scopeIdentifier2])
2412
2570
  )
2413
2571
  );
2414
2572
  }
2415
2573
  if (referencedBindings) {
2416
2574
  signal.render.unshift(
2417
- import_compiler17.types.variableDeclaration("const", [
2418
- import_compiler17.types.variableDeclarator(
2575
+ import_compiler18.types.variableDeclaration("const", [
2576
+ import_compiler18.types.variableDeclarator(
2419
2577
  createScopeReadPattern(section, referencedBindings),
2420
2578
  scopeIdentifier2
2421
2579
  )
2422
2580
  ])
2423
2581
  );
2424
2582
  }
2425
- return import_compiler17.types.arrowFunctionExpression(params, import_compiler17.types.blockStatement(signal.render));
2583
+ return import_compiler18.types.arrowFunctionExpression(params, import_compiler18.types.blockStatement(signal.render));
2426
2584
  }
2427
2585
  var hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
2428
2586
  var emptyExtraArgs = [];
@@ -2467,19 +2625,19 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
2467
2625
  for (let i = args.length; i--; ) {
2468
2626
  const arg = args[i];
2469
2627
  if (!arg) {
2470
- args[i] = import_compiler17.types.numericLiteral(0);
2471
- } else if (import_compiler17.types.isArrowFunctionExpression(arg) && import_compiler17.types.isBlockStatement(arg.body)) {
2628
+ args[i] = import_compiler18.types.numericLiteral(0);
2629
+ } else if (import_compiler18.types.isArrowFunctionExpression(arg) && import_compiler18.types.isBlockStatement(arg.body)) {
2472
2630
  const body = arg.body.body;
2473
2631
  if (body.length === 0) {
2474
- args[i] = import_compiler17.types.numericLiteral(0);
2475
- } else if (body.length === 1 && import_compiler17.types.isExpressionStatement(body[0])) {
2632
+ args[i] = import_compiler18.types.numericLiteral(0);
2633
+ } else if (body.length === 1 && import_compiler18.types.isExpressionStatement(body[0])) {
2476
2634
  arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
2477
2635
  }
2478
- } else if (import_compiler17.types.isNullLiteral(arg) || import_compiler17.types.isUnaryExpression(arg) && arg.operator === "void") {
2479
- args[i] = import_compiler17.types.numericLiteral(0);
2636
+ } else if (import_compiler18.types.isNullLiteral(arg) || import_compiler18.types.isUnaryExpression(arg) && arg.operator === "void") {
2637
+ args[i] = import_compiler18.types.numericLiteral(0);
2480
2638
  }
2481
2639
  }
2482
- for (let i = args.length - 1; import_compiler17.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
2640
+ for (let i = args.length - 1; import_compiler18.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
2483
2641
  args.length = i--;
2484
2642
  }
2485
2643
  return args;
@@ -2516,7 +2674,9 @@ function addRenderReferences(signal, referencedBindings) {
2516
2674
  );
2517
2675
  }
2518
2676
  function addValue(targetSection, referencedBindings, signal, value, scope = scopeIdentifier) {
2519
- getSignal(targetSection, referencedBindings).values.push({
2677
+ const parentSignal = getSignal(targetSection, referencedBindings);
2678
+ addRenderReferences(parentSignal, referencedBindings);
2679
+ parentSignal.values.push({
2520
2680
  signal,
2521
2681
  value,
2522
2682
  scope
@@ -2570,7 +2730,7 @@ function writeSignals(section) {
2570
2730
  forEach(section.hoisted, (binding) => {
2571
2731
  for (const hoistedBinding of binding.hoists.values()) {
2572
2732
  const accessors = [
2573
- binding.type === 0 /* dom */ ? import_compiler17.types.stringLiteral(
2733
+ binding.type === 0 /* dom */ ? import_compiler18.types.stringLiteral(
2574
2734
  getAccessorPrefix().Getter + getScopeAccessor(binding)
2575
2735
  ) : getScopeAccessorLiteral(binding)
2576
2736
  ];
@@ -2585,12 +2745,12 @@ function writeSignals(section) {
2585
2745
  const hoistIdentifier = getHoistFunctionIdentifier(hoistedBinding);
2586
2746
  currentProgramPath.pushContainer(
2587
2747
  "body",
2588
- import_compiler17.types.variableDeclaration("const", [
2589
- import_compiler17.types.variableDeclarator(
2748
+ import_compiler18.types.variableDeclaration("const", [
2749
+ import_compiler18.types.variableDeclarator(
2590
2750
  hoistIdentifier,
2591
2751
  hoistedBinding.downstreamExpressions.size ? callRuntime(
2592
2752
  "register",
2593
- import_compiler17.types.stringLiteral(
2753
+ import_compiler18.types.stringLiteral(
2594
2754
  getResumeRegisterId(
2595
2755
  hoistedBinding.section,
2596
2756
  hoistedBinding,
@@ -2607,7 +2767,7 @@ function writeSignals(section) {
2607
2767
  hoistedBinding.section,
2608
2768
  void 0,
2609
2769
  initValue(hoistedBinding),
2610
- import_compiler17.types.callExpression(hoistIdentifier, [scopeIdentifier])
2770
+ import_compiler18.types.callExpression(hoistIdentifier, [scopeIdentifier])
2611
2771
  );
2612
2772
  }
2613
2773
  }
@@ -2621,20 +2781,20 @@ function writeSignals(section) {
2621
2781
  let effectDeclarator;
2622
2782
  if (signal.effect.length) {
2623
2783
  traverseReplace(signal, "effect", replaceEffectNode);
2624
- const effectIdentifier = import_compiler17.types.identifier(`${signal.identifier.name}_effect`);
2784
+ const effectIdentifier = import_compiler18.types.identifier(`${signal.identifier.name}_effect`);
2625
2785
  const referencedBindings = signal.effectReferencedBindings;
2626
2786
  const referencesScope = traverseContains(
2627
2787
  signal.effect,
2628
2788
  isScopeIdentifier
2629
2789
  );
2630
- effectDeclarator = import_compiler17.types.variableDeclarator(
2790
+ effectDeclarator = import_compiler18.types.variableDeclarator(
2631
2791
  effectIdentifier,
2632
2792
  callRuntime(
2633
2793
  "effect",
2634
- import_compiler17.types.stringLiteral(
2794
+ import_compiler18.types.stringLiteral(
2635
2795
  getResumeRegisterId(section, signal.referencedBindings)
2636
2796
  ),
2637
- import_compiler17.types.arrowFunctionExpression(
2797
+ import_compiler18.types.arrowFunctionExpression(
2638
2798
  referencedBindings ? referencesScope ? [
2639
2799
  scopeIdentifier,
2640
2800
  createScopeReadPattern(section, referencedBindings)
@@ -2645,30 +2805,30 @@ function writeSignals(section) {
2645
2805
  );
2646
2806
  }
2647
2807
  let value = signal.build();
2648
- if (import_compiler17.types.isCallExpression(value)) {
2808
+ if (import_compiler18.types.isCallExpression(value)) {
2649
2809
  replaceNullishAndEmptyFunctionsWith0(value.arguments);
2650
2810
  }
2651
2811
  if (signal.register) {
2652
2812
  value = callRuntime(
2653
2813
  "registerBoundSignal",
2654
- import_compiler17.types.stringLiteral(
2814
+ import_compiler18.types.stringLiteral(
2655
2815
  getResumeRegisterId(section, signal.referencedBindings, "var")
2656
2816
  ),
2657
2817
  value
2658
2818
  );
2659
2819
  }
2660
- const signalDeclarator = import_compiler17.types.variableDeclarator(signal.identifier, value);
2661
- let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler17.types.isFunctionExpression(value) || import_compiler17.types.isArrowFunctionExpression(value)) ? import_compiler17.types.functionDeclaration(
2820
+ const signalDeclarator = import_compiler18.types.variableDeclarator(signal.identifier, value);
2821
+ let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler18.types.isFunctionExpression(value) || import_compiler18.types.isArrowFunctionExpression(value)) ? import_compiler18.types.functionDeclaration(
2662
2822
  signal.identifier,
2663
2823
  value.params,
2664
- import_compiler17.types.isExpression(value.body) ? import_compiler17.types.blockStatement([import_compiler17.types.expressionStatement(value.body)]) : value.body
2665
- ) : import_compiler17.types.variableDeclaration("const", [signalDeclarator]);
2824
+ import_compiler18.types.isExpression(value.body) ? import_compiler18.types.blockStatement([import_compiler18.types.expressionStatement(value.body)]) : value.body
2825
+ ) : import_compiler18.types.variableDeclaration("const", [signalDeclarator]);
2666
2826
  if (signal.export) {
2667
- signalDeclaration = import_compiler17.types.exportNamedDeclaration(signalDeclaration);
2827
+ signalDeclaration = import_compiler18.types.exportNamedDeclaration(signalDeclaration);
2668
2828
  }
2669
2829
  const signalStatements = signal.prependStatements || [];
2670
2830
  if (effectDeclarator) {
2671
- signalStatements.push(import_compiler17.types.variableDeclaration("const", [effectDeclarator]));
2831
+ signalStatements.push(import_compiler18.types.variableDeclaration("const", [effectDeclarator]));
2672
2832
  }
2673
2833
  signalStatements.push(signalDeclaration);
2674
2834
  currentProgramPath.pushContainer("body", signalStatements);
@@ -2682,7 +2842,7 @@ function writeRegisteredFns() {
2682
2842
  let fn;
2683
2843
  const params = registeredFn.referencedBindings ? registeredFn.referencesScope ? [
2684
2844
  scopeIdentifier,
2685
- import_compiler17.types.assignmentPattern(
2845
+ import_compiler18.types.assignmentPattern(
2686
2846
  createScopeReadPattern(
2687
2847
  registeredFn.section,
2688
2848
  registeredFn.referencedBindings
@@ -2696,18 +2856,18 @@ function writeRegisteredFns() {
2696
2856
  )
2697
2857
  ] : registeredFn.referencesScope ? [scopeIdentifier] : void 0;
2698
2858
  if (params) {
2699
- fn = import_compiler17.types.functionDeclaration(
2700
- import_compiler17.types.identifier(registeredFn.id),
2859
+ fn = import_compiler18.types.functionDeclaration(
2860
+ import_compiler18.types.identifier(registeredFn.id),
2701
2861
  params,
2702
- import_compiler17.types.blockStatement(toReturnedFunction(registeredFn.node))
2862
+ import_compiler18.types.blockStatement(toReturnedFunction(registeredFn.node))
2703
2863
  );
2704
2864
  } else if (registeredFn.node.type === "FunctionDeclaration" && registeredFn.node.id?.name === registeredFn.id) {
2705
2865
  fn = registeredFn.node;
2706
2866
  } else {
2707
- fn = import_compiler17.types.functionDeclaration(
2708
- import_compiler17.types.identifier(registeredFn.id),
2867
+ fn = import_compiler18.types.functionDeclaration(
2868
+ import_compiler18.types.identifier(registeredFn.id),
2709
2869
  registeredFn.node.params,
2710
- registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body : import_compiler17.types.blockStatement([import_compiler17.types.returnStatement(registeredFn.node.body)]),
2870
+ registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body : import_compiler18.types.blockStatement([import_compiler18.types.returnStatement(registeredFn.node.body)]),
2711
2871
  registeredFn.node.generator,
2712
2872
  registeredFn.node.async
2713
2873
  );
@@ -2716,11 +2876,11 @@ function writeRegisteredFns() {
2716
2876
  }
2717
2877
  for (const registeredFn of registeredFns) {
2718
2878
  statements.push(
2719
- import_compiler17.types.expressionStatement(
2879
+ import_compiler18.types.expressionStatement(
2720
2880
  callRuntime(
2721
2881
  "register",
2722
- import_compiler17.types.stringLiteral(registeredFn.registerId),
2723
- import_compiler17.types.identifier(registeredFn.id)
2882
+ import_compiler18.types.stringLiteral(registeredFn.registerId),
2883
+ import_compiler18.types.identifier(registeredFn.id)
2724
2884
  )
2725
2885
  )
2726
2886
  );
@@ -2732,7 +2892,7 @@ function writeRegisteredFns() {
2732
2892
  }
2733
2893
  function toReturnedFunction(rawFn) {
2734
2894
  const fn = simplifyFunction(rawFn);
2735
- return fn.type === "FunctionDeclaration" ? [fn, import_compiler17.types.returnStatement(fn.id)] : [import_compiler17.types.returnStatement(fn)];
2895
+ return fn.type === "FunctionDeclaration" ? [fn, import_compiler18.types.returnStatement(fn.id)] : [import_compiler18.types.returnStatement(fn)];
2736
2896
  }
2737
2897
  function sortSignals(a, b) {
2738
2898
  const aReferencedBindings = getReferencedBindings(a);
@@ -2767,9 +2927,10 @@ function writeHTMLResumeStatements(path5) {
2767
2927
  forEach(section.assignments, serializeOwnersUntilBinding);
2768
2928
  forEach(section.referencedHoists, serializeOwnersUntilBinding);
2769
2929
  forEach(section.referencedClosures, (closure) => {
2770
- if (isStatefulReferences(closure)) {
2930
+ if (closure.sources) {
2931
+ const serializeReason = getDynamicSourcesForBinding(closure);
2771
2932
  serializeOwnersUntilBinding(closure);
2772
- setForceResumeScope(closure.section);
2933
+ serializeSectionIfNeeded(closure.section, serializeReason);
2773
2934
  if (isDynamicClosure(section, closure)) {
2774
2935
  const closureSignal = getSignal(closure.section, closure);
2775
2936
  let identifier = htmlDynamicClosureInstancesIdentifier.get(closureSignal);
@@ -2781,23 +2942,25 @@ function writeHTMLResumeStatements(path5) {
2781
2942
  )
2782
2943
  );
2783
2944
  getHTMLSectionStatements(closure.section).push(
2784
- import_compiler17.types.variableDeclaration("const", [
2785
- import_compiler17.types.variableDeclarator(
2945
+ import_compiler18.types.variableDeclaration("const", [
2946
+ import_compiler18.types.variableDeclarator(
2786
2947
  identifier,
2787
- import_compiler17.types.newExpression(import_compiler17.types.identifier("Set"), [])
2948
+ import_compiler18.types.newExpression(import_compiler18.types.identifier("Set"), [])
2788
2949
  )
2789
2950
  ])
2790
2951
  );
2791
2952
  setSerializedProperty(
2792
2953
  closure.section,
2793
2954
  getAccessorPrefix().ClosureScopes + getScopeAccessor(closure),
2794
- identifier
2955
+ identifier,
2956
+ serializeReason
2795
2957
  );
2796
2958
  }
2797
2959
  setSerializedProperty(
2798
2960
  section,
2799
2961
  getAccessorPrefix().ClosureSignalIndex + getScopeAccessor(closure),
2800
- import_compiler17.types.numericLiteral(getDynamicClosureIndex(closure, section))
2962
+ import_compiler18.types.numericLiteral(getDynamicClosureIndex(closure, section)),
2963
+ serializeReason
2801
2964
  );
2802
2965
  addWriteScopeBuilder(
2803
2966
  section,
@@ -2811,13 +2974,13 @@ function writeHTMLResumeStatements(path5) {
2811
2974
  for (const hoistedBinding of binding.hoists.values()) {
2812
2975
  if (hoistedBinding.downstreamExpressions.size) {
2813
2976
  getHTMLSectionStatements(hoistedBinding.section).push(
2814
- import_compiler17.types.variableDeclaration("const", [
2815
- import_compiler17.types.variableDeclarator(
2816
- import_compiler17.types.identifier(hoistedBinding.name),
2977
+ import_compiler18.types.variableDeclaration("const", [
2978
+ import_compiler18.types.variableDeclarator(
2979
+ import_compiler18.types.identifier(hoistedBinding.name),
2817
2980
  callRuntime(
2818
2981
  "hoist",
2819
2982
  getScopeIdIdentifier(hoistedBinding.section),
2820
- import_compiler17.types.stringLiteral(
2983
+ import_compiler18.types.stringLiteral(
2821
2984
  getResumeRegisterId(
2822
2985
  hoistedBinding.section,
2823
2986
  hoistedBinding,
@@ -2838,10 +3001,10 @@ function writeHTMLResumeStatements(path5) {
2838
3001
  );
2839
3002
  sectionDynamicSubscribers.add(currentSection);
2840
3003
  getHTMLSectionStatements(parentSection).push(
2841
- import_compiler17.types.variableDeclaration("const", [
2842
- import_compiler17.types.variableDeclarator(
3004
+ import_compiler18.types.variableDeclaration("const", [
3005
+ import_compiler18.types.variableDeclarator(
2843
3006
  subscribersIdentifier,
2844
- import_compiler17.types.newExpression(import_compiler17.types.identifier("Set"), [])
3007
+ import_compiler18.types.newExpression(import_compiler18.types.identifier("Set"), [])
2845
3008
  )
2846
3009
  ])
2847
3010
  );
@@ -2852,7 +3015,8 @@ function writeHTMLResumeStatements(path5) {
2852
3015
  setSerializedProperty(
2853
3016
  parentSection,
2854
3017
  getSectionInstancesAccessor(currentSection),
2855
- subscribersIdentifier
3018
+ subscribersIdentifier,
3019
+ true
2856
3020
  );
2857
3021
  }
2858
3022
  currentSection = parentSection;
@@ -2862,7 +3026,8 @@ function writeHTMLResumeStatements(path5) {
2862
3026
  setSerializedProperty(
2863
3027
  section,
2864
3028
  getScopeAccessor(binding),
2865
- getDeclaredBindingExpression(binding)
3029
+ getDeclaredBindingExpression(binding),
3030
+ true
2866
3031
  );
2867
3032
  }
2868
3033
  });
@@ -2871,11 +3036,11 @@ function writeHTMLResumeStatements(path5) {
2871
3036
  const signalRefs = allSignals[i].referencedBindings;
2872
3037
  path5.pushContainer(
2873
3038
  "body",
2874
- import_compiler17.types.expressionStatement(
3039
+ import_compiler18.types.expressionStatement(
2875
3040
  callRuntime(
2876
3041
  "writeEffect",
2877
3042
  scopeIdIdentifier,
2878
- import_compiler17.types.stringLiteral(getResumeRegisterId(section, signalRefs))
3043
+ import_compiler18.types.stringLiteral(getResumeRegisterId(section, signalRefs))
2879
3044
  )
2880
3045
  )
2881
3046
  );
@@ -2892,11 +3057,12 @@ function writeHTMLResumeStatements(path5) {
2892
3057
  );
2893
3058
  }
2894
3059
  });
2895
- for (const [key, value] of serializedLookup) {
2896
- serializedProperties.push(toObjectProperty(key, value));
3060
+ for (const [key, { expression }] of serializedLookup) {
3061
+ serializedProperties.push(toObjectProperty(key, expression));
2897
3062
  }
2898
3063
  const writeScopeBuilder = getSectionWriteScopeBuilder(section);
2899
- if (writeScopeBuilder || serializedProperties.length || forceResumeScope(section)) {
3064
+ const forceSerializeReason = serializeSectionReason(section);
3065
+ if (writeScopeBuilder || serializedProperties.length || forceSerializeReason) {
2900
3066
  for (const prop of serializedProperties) {
2901
3067
  if (prop.key.type === "Identifier" && prop.value.type === "Identifier" && prop.key.name === prop.value.name) {
2902
3068
  prop.shorthand = true;
@@ -2904,7 +3070,7 @@ function writeHTMLResumeStatements(path5) {
2904
3070
  }
2905
3071
  const writeScopeArgs = [
2906
3072
  scopeIdIdentifier,
2907
- import_compiler17.types.objectExpression(serializedProperties)
3073
+ import_compiler18.types.objectExpression(serializedProperties)
2908
3074
  ];
2909
3075
  if (!isOptimize()) {
2910
3076
  let debugVars;
@@ -2918,31 +3084,31 @@ function writeHTMLResumeStatements(path5) {
2918
3084
  }
2919
3085
  root = root.upstreamAlias;
2920
3086
  }
2921
- const locExpr = root.loc && import_compiler17.types.stringLiteral(
3087
+ const locExpr = root.loc && import_compiler18.types.stringLiteral(
2922
3088
  `${root.loc.start.line}:${root.loc.start.column + 1}`
2923
3089
  );
2924
3090
  (debugVars ||= []).push(
2925
3091
  toObjectProperty(
2926
3092
  getScopeAccessor(binding),
2927
- root !== binding ? import_compiler17.types.arrayExpression(
2928
- locExpr ? [import_compiler17.types.stringLiteral(root.name + access), locExpr] : [import_compiler17.types.stringLiteral(root.name + access)]
2929
- ) : locExpr || import_compiler17.types.numericLiteral(0)
3093
+ root !== binding ? import_compiler18.types.arrayExpression(
3094
+ locExpr ? [import_compiler18.types.stringLiteral(root.name + access), locExpr] : [import_compiler18.types.stringLiteral(root.name + access)]
3095
+ ) : locExpr || import_compiler18.types.numericLiteral(0)
2930
3096
  )
2931
3097
  );
2932
3098
  });
2933
3099
  writeScopeArgs.push(
2934
- import_compiler17.types.stringLiteral(path5.hub.file.opts.filenameRelative),
2935
- section.loc && section.loc.start.line != null ? import_compiler17.types.stringLiteral(
3100
+ import_compiler18.types.stringLiteral(path5.hub.file.opts.filenameRelative),
3101
+ section.loc && section.loc.start.line != null ? import_compiler18.types.stringLiteral(
2936
3102
  `${section.loc.start.line}:${section.loc.start.column + 1}`
2937
- ) : import_compiler17.types.numericLiteral(0)
3103
+ ) : import_compiler18.types.numericLiteral(0)
2938
3104
  );
2939
3105
  if (debugVars) {
2940
- writeScopeArgs.push(import_compiler17.types.objectExpression(debugVars));
3106
+ writeScopeArgs.push(import_compiler18.types.objectExpression(debugVars));
2941
3107
  }
2942
3108
  }
2943
3109
  path5.pushContainer(
2944
3110
  "body",
2945
- import_compiler17.types.expressionStatement(
3111
+ import_compiler18.types.expressionStatement(
2946
3112
  writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs)
2947
3113
  )
2948
3114
  );
@@ -2951,7 +3117,7 @@ function writeHTMLResumeStatements(path5) {
2951
3117
  if (resumeClosestBranch2) {
2952
3118
  path5.pushContainer(
2953
3119
  "body",
2954
- import_compiler17.types.expressionStatement(
3120
+ import_compiler18.types.expressionStatement(
2955
3121
  callRuntime("resumeClosestBranch", scopeIdIdentifier)
2956
3122
  )
2957
3123
  );
@@ -2959,15 +3125,15 @@ function writeHTMLResumeStatements(path5) {
2959
3125
  const additionalStatements = getHTMLSectionStatements(section);
2960
3126
  if (path5.get("body").length || additionalStatements.length) {
2961
3127
  path5.unshiftContainer("body", [
2962
- import_compiler17.types.variableDeclaration("const", [
2963
- import_compiler17.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
3128
+ import_compiler18.types.variableDeclaration("const", [
3129
+ import_compiler18.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
2964
3130
  ]),
2965
3131
  ...additionalStatements
2966
3132
  ]);
2967
3133
  }
2968
3134
  const returnIdentifier = getSectionReturnValueIdentifier(section);
2969
3135
  if (returnIdentifier !== void 0) {
2970
- path5.pushContainer("body", import_compiler17.types.returnStatement(returnIdentifier));
3136
+ path5.pushContainer("body", import_compiler18.types.returnStatement(returnIdentifier));
2971
3137
  }
2972
3138
  }
2973
3139
  function serializeOwners(from, to) {
@@ -2978,10 +3144,10 @@ function serializeOwners(from, to) {
2978
3144
  const serialized = getSerializedScopeProperties(cur);
2979
3145
  cur = parent;
2980
3146
  if (!serialized.has("_")) {
2981
- serialized.set(
2982
- "_",
2983
- callRuntime("ensureScopeWithId", getScopeIdIdentifier(cur))
2984
- );
3147
+ serialized.set("_", {
3148
+ expression: callRuntime("ensureScopeWithId", getScopeIdIdentifier(cur)),
3149
+ reason: true
3150
+ });
2985
3151
  }
2986
3152
  }
2987
3153
  }
@@ -3014,14 +3180,14 @@ function replaceAssignedNode(node) {
3014
3180
  if (buildAssignment) {
3015
3181
  const replacement = buildAssignment(
3016
3182
  extra.section,
3017
- import_compiler17.types.binaryExpression(
3183
+ import_compiler18.types.binaryExpression(
3018
3184
  node.operator === "++" ? "+" : "-",
3019
3185
  node.argument,
3020
- import_compiler17.types.numericLiteral(1)
3186
+ import_compiler18.types.numericLiteral(1)
3021
3187
  )
3022
3188
  );
3023
3189
  if (!node.prefix) {
3024
- return import_compiler17.types.sequenceExpression([replacement, node.argument]);
3190
+ return import_compiler18.types.sequenceExpression([replacement, node.argument]);
3025
3191
  }
3026
3192
  return replacement;
3027
3193
  }
@@ -3040,7 +3206,7 @@ function replaceAssignedNode(node) {
3040
3206
  if (buildAssignment) {
3041
3207
  return buildAssignment(
3042
3208
  extra.section,
3043
- node.operator === "=" ? node.right : import_compiler17.types.binaryExpression(
3209
+ node.operator === "=" ? node.right : import_compiler18.types.binaryExpression(
3044
3210
  node.operator.slice(
3045
3211
  0,
3046
3212
  -1
@@ -3066,26 +3232,26 @@ function replaceAssignedNode(node) {
3066
3232
  );
3067
3233
  if (signal?.buildAssignment) {
3068
3234
  id.name = currentProgramPath.scope.generateUid(id.name);
3069
- (params ||= []).push(import_compiler17.types.identifier(id.name));
3235
+ (params ||= []).push(import_compiler18.types.identifier(id.name));
3070
3236
  (assignments ||= []).push(
3071
- signal.buildAssignment(extra.section, import_compiler17.types.identifier(id.name))
3237
+ signal.buildAssignment(extra.section, import_compiler18.types.identifier(id.name))
3072
3238
  );
3073
3239
  }
3074
3240
  }
3075
3241
  });
3076
3242
  if (params && assignments) {
3077
3243
  const resultId = currentProgramPath.scope.generateUid("result");
3078
- return import_compiler17.types.callExpression(
3079
- import_compiler17.types.arrowFunctionExpression(
3080
- [import_compiler17.types.identifier(resultId), ...params],
3081
- import_compiler17.types.sequenceExpression([
3082
- import_compiler17.types.assignmentExpression(
3244
+ return import_compiler18.types.callExpression(
3245
+ import_compiler18.types.arrowFunctionExpression(
3246
+ [import_compiler18.types.identifier(resultId), ...params],
3247
+ import_compiler18.types.sequenceExpression([
3248
+ import_compiler18.types.assignmentExpression(
3083
3249
  "=",
3084
3250
  node.left,
3085
- import_compiler17.types.identifier(resultId)
3251
+ import_compiler18.types.identifier(resultId)
3086
3252
  ),
3087
3253
  ...assignments,
3088
- import_compiler17.types.identifier(resultId)
3254
+ import_compiler18.types.identifier(resultId)
3089
3255
  ])
3090
3256
  ),
3091
3257
  [node.right]
@@ -3102,15 +3268,15 @@ function replaceRegisteredFunctionNode(node) {
3102
3268
  switch (node.type) {
3103
3269
  case "ClassMethod": {
3104
3270
  const replacement = getRegisteredFnExpression(node);
3105
- return replacement && import_compiler17.types.classProperty(node.key, replacement);
3271
+ return replacement && import_compiler18.types.classProperty(node.key, replacement);
3106
3272
  }
3107
3273
  case "ClassPrivateMethod": {
3108
3274
  const replacement = getRegisteredFnExpression(node);
3109
- return replacement && import_compiler17.types.classPrivateProperty(node.key, replacement);
3275
+ return replacement && import_compiler18.types.classPrivateProperty(node.key, replacement);
3110
3276
  }
3111
3277
  case "ObjectMethod": {
3112
3278
  const replacement = getRegisteredFnExpression(node);
3113
- return replacement && import_compiler17.types.objectProperty(node.key, replacement);
3279
+ return replacement && import_compiler18.types.objectProperty(node.key, replacement);
3114
3280
  }
3115
3281
  case "ArrowFunctionExpression":
3116
3282
  case "FunctionExpression": {
@@ -3119,8 +3285,8 @@ function replaceRegisteredFunctionNode(node) {
3119
3285
  case "FunctionDeclaration": {
3120
3286
  const replacement = getRegisteredFnExpression(node);
3121
3287
  if (replacement) {
3122
- return import_compiler17.types.variableDeclaration("const", [
3123
- import_compiler17.types.variableDeclarator(node.id, replacement)
3288
+ return import_compiler18.types.variableDeclaration("const", [
3289
+ import_compiler18.types.variableDeclarator(node.id, replacement)
3124
3290
  ]);
3125
3291
  }
3126
3292
  break;
@@ -3146,9 +3312,9 @@ function getRegisteredFnExpression(node) {
3146
3312
  referencedBindings
3147
3313
  });
3148
3314
  if (referencesScope || referencedBindings) {
3149
- return import_compiler17.types.callExpression(import_compiler17.types.identifier(id), [scopeIdentifier]);
3315
+ return import_compiler18.types.callExpression(import_compiler18.types.identifier(id), [scopeIdentifier]);
3150
3316
  } else {
3151
- return import_compiler17.types.identifier(id);
3317
+ return import_compiler18.types.identifier(id);
3152
3318
  }
3153
3319
  }
3154
3320
  }
@@ -3172,9 +3338,9 @@ var dom_default = {
3172
3338
  const section = getSectionForBody(program);
3173
3339
  const { walks, writes, setup } = getSectionMeta(section);
3174
3340
  const domExports = program.node.extra.domExports;
3175
- const templateIdentifier = import_compiler18.types.identifier(domExports.template);
3176
- const walksIdentifier = import_compiler18.types.identifier(domExports.walks);
3177
- const setupIdentifier = import_compiler18.types.identifier(domExports.setup);
3341
+ const templateIdentifier = import_compiler19.types.identifier(domExports.template);
3342
+ const walksIdentifier = import_compiler19.types.identifier(domExports.walks);
3343
+ const setupIdentifier = import_compiler19.types.identifier(domExports.setup);
3178
3344
  const inputBinding = program.node.params[0].extra?.binding;
3179
3345
  const programInputSignal = inputBinding && bindingHasDownstreamExpressions(inputBinding) ? initValue(inputBinding) : void 0;
3180
3346
  const styleFile = getStyleFile(program.hub.file);
@@ -3185,17 +3351,17 @@ var dom_default = {
3185
3351
  if (childSection !== section) {
3186
3352
  const tagParamsSignal = childSection.params && initValue(childSection.params);
3187
3353
  const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
3188
- const identifier = import_compiler18.types.identifier(childSection.name);
3189
- const referencedClosures = childSection.referencedClosures ? import_compiler18.types.arrowFunctionExpression(
3354
+ const identifier = import_compiler19.types.identifier(childSection.name);
3355
+ const referencedClosures = childSection.referencedClosures ? import_compiler19.types.arrowFunctionExpression(
3190
3356
  [scopeIdentifier],
3191
3357
  toFirstExpressionOrBlock(
3192
3358
  map(childSection.referencedClosures, (closure) => {
3193
3359
  const closureSignal = getSignal(childSection, closure);
3194
- return import_compiler18.types.expressionStatement(
3195
- import_compiler18.types.callExpression(
3196
- isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler18.types.memberExpression(
3360
+ return import_compiler19.types.expressionStatement(
3361
+ import_compiler19.types.callExpression(
3362
+ isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler19.types.memberExpression(
3197
3363
  closureSignal.identifier,
3198
- import_compiler18.types.identifier("_")
3364
+ import_compiler19.types.identifier("_")
3199
3365
  ),
3200
3366
  [scopeIdentifier]
3201
3367
  )
@@ -3214,7 +3380,7 @@ var dom_default = {
3214
3380
  ])
3215
3381
  ) : callRuntime(
3216
3382
  isSerializedSection(childSection) ? "registerContent" : "createContent",
3217
- import_compiler18.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
3383
+ import_compiler19.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
3218
3384
  ...replaceNullishAndEmptyFunctionsWith0([
3219
3385
  writes2,
3220
3386
  walks2,
@@ -3226,8 +3392,8 @@ var dom_default = {
3226
3392
  );
3227
3393
  writeSignals(childSection);
3228
3394
  program.node.body.push(
3229
- import_compiler18.types.variableDeclaration("const", [
3230
- import_compiler18.types.variableDeclarator(identifier, renderer)
3395
+ import_compiler19.types.variableDeclaration("const", [
3396
+ import_compiler19.types.variableDeclarator(identifier, renderer)
3231
3397
  ])
3232
3398
  );
3233
3399
  }
@@ -3236,36 +3402,36 @@ var dom_default = {
3236
3402
  writeRegisteredFns();
3237
3403
  if (!setup) {
3238
3404
  program.node.body.unshift(
3239
- import_compiler18.types.exportNamedDeclaration(
3240
- import_compiler18.types.variableDeclaration("const", [
3241
- import_compiler18.types.variableDeclarator(
3405
+ import_compiler19.types.exportNamedDeclaration(
3406
+ import_compiler19.types.variableDeclaration("const", [
3407
+ import_compiler19.types.variableDeclarator(
3242
3408
  setupIdentifier,
3243
- import_compiler18.types.arrowFunctionExpression([], import_compiler18.types.blockStatement([]))
3409
+ import_compiler19.types.arrowFunctionExpression([], import_compiler19.types.blockStatement([]))
3244
3410
  )
3245
3411
  ])
3246
3412
  )
3247
3413
  );
3248
3414
  }
3249
3415
  program.node.body.unshift(
3250
- import_compiler18.types.exportNamedDeclaration(
3251
- import_compiler18.types.variableDeclaration("const", [
3252
- import_compiler18.types.variableDeclarator(
3416
+ import_compiler19.types.exportNamedDeclaration(
3417
+ import_compiler19.types.variableDeclaration("const", [
3418
+ import_compiler19.types.variableDeclarator(
3253
3419
  templateIdentifier,
3254
- writes || import_compiler18.types.stringLiteral("")
3420
+ writes || import_compiler19.types.stringLiteral("")
3255
3421
  )
3256
3422
  ])
3257
3423
  ),
3258
- import_compiler18.types.exportNamedDeclaration(
3259
- import_compiler18.types.variableDeclaration("const", [
3260
- import_compiler18.types.variableDeclarator(walksIdentifier, walks || import_compiler18.types.stringLiteral(""))
3424
+ import_compiler19.types.exportNamedDeclaration(
3425
+ import_compiler19.types.variableDeclaration("const", [
3426
+ import_compiler19.types.variableDeclarator(walksIdentifier, walks || import_compiler19.types.stringLiteral(""))
3261
3427
  ])
3262
3428
  )
3263
3429
  );
3264
3430
  program.node.body.push(
3265
- import_compiler18.types.exportDefaultDeclaration(
3431
+ import_compiler19.types.exportDefaultDeclaration(
3266
3432
  callRuntime(
3267
3433
  "createTemplate",
3268
- import_compiler18.types.stringLiteral(program.hub.file.metadata.marko.id),
3434
+ import_compiler19.types.stringLiteral(program.hub.file.metadata.marko.id),
3269
3435
  templateIdentifier,
3270
3436
  walksIdentifier,
3271
3437
  setupIdentifier,
@@ -3278,7 +3444,7 @@ var dom_default = {
3278
3444
  };
3279
3445
 
3280
3446
  // src/translator/visitors/program/html.ts
3281
- var import_compiler19 = require("@marko/compiler");
3447
+ var import_compiler20 = require("@marko/compiler");
3282
3448
 
3283
3449
  // src/translator/util/is-static.ts
3284
3450
  function isStatic(path5) {
@@ -3317,22 +3483,22 @@ var html_default = {
3317
3483
  }
3318
3484
  }
3319
3485
  const contentId = templateContentIdentifierForProgram.get(program);
3320
- const contentFn = import_compiler19.types.arrowFunctionExpression(
3321
- [import_compiler19.types.identifier("input")],
3322
- import_compiler19.types.blockStatement(renderContent)
3486
+ const contentFn = import_compiler20.types.arrowFunctionExpression(
3487
+ [import_compiler20.types.identifier("input")],
3488
+ import_compiler20.types.blockStatement(renderContent)
3323
3489
  );
3324
- const exportDefault = import_compiler19.types.exportDefaultDeclaration(
3490
+ const exportDefault = import_compiler20.types.exportDefaultDeclaration(
3325
3491
  callRuntime(
3326
3492
  "createTemplate",
3327
- import_compiler19.types.stringLiteral(program.hub.file.metadata.marko.id),
3328
- contentId ? import_compiler19.types.identifier(contentId) : contentFn
3493
+ import_compiler20.types.stringLiteral(program.hub.file.metadata.marko.id),
3494
+ contentId ? import_compiler20.types.identifier(contentId) : contentFn
3329
3495
  )
3330
3496
  );
3331
3497
  program.pushContainer(
3332
3498
  "body",
3333
3499
  contentId ? [
3334
- import_compiler19.types.variableDeclaration("const", [
3335
- import_compiler19.types.variableDeclarator(import_compiler19.types.identifier(contentId), contentFn)
3500
+ import_compiler20.types.variableDeclaration("const", [
3501
+ import_compiler20.types.variableDeclarator(import_compiler20.types.identifier(contentId), contentFn)
3336
3502
  ]),
3337
3503
  exportDefault
3338
3504
  ] : exportDefault
@@ -3358,15 +3524,15 @@ function replaceRegisteredFunctionNode2(node, container) {
3358
3524
  switch (node.type) {
3359
3525
  case "ClassMethod": {
3360
3526
  const replacement = getRegisteredFnExpression2(node);
3361
- return replacement && import_compiler19.types.classProperty(node.key, replacement);
3527
+ return replacement && import_compiler20.types.classProperty(node.key, replacement);
3362
3528
  }
3363
3529
  case "ClassPrivateMethod": {
3364
3530
  const replacement = getRegisteredFnExpression2(node);
3365
- return replacement && import_compiler19.types.classPrivateProperty(node.key, replacement);
3531
+ return replacement && import_compiler20.types.classPrivateProperty(node.key, replacement);
3366
3532
  }
3367
3533
  case "ObjectMethod": {
3368
3534
  const replacement = getRegisteredFnExpression2(node);
3369
- return replacement && import_compiler19.types.objectProperty(node.key, replacement);
3535
+ return replacement && import_compiler20.types.objectProperty(node.key, replacement);
3370
3536
  }
3371
3537
  case "FunctionDeclaration": {
3372
3538
  const { extra } = node;
@@ -3403,11 +3569,11 @@ function addRegisteredDeclarations(body) {
3403
3569
  if (registeredFnDeclarations) {
3404
3570
  for (const { id, registerId } of registeredFnDeclarations) {
3405
3571
  body.push(
3406
- import_compiler19.types.expressionStatement(
3572
+ import_compiler20.types.expressionStatement(
3407
3573
  callRuntime(
3408
3574
  "register",
3409
- import_compiler19.types.identifier(id),
3410
- import_compiler19.types.stringLiteral(registerId)
3575
+ import_compiler20.types.identifier(id),
3576
+ import_compiler20.types.stringLiteral(registerId)
3411
3577
  )
3412
3578
  )
3413
3579
  );
@@ -3420,7 +3586,7 @@ function getRegisteredFnExpression2(node) {
3420
3586
  return callRuntime(
3421
3587
  "register",
3422
3588
  simplifyFunction(node),
3423
- import_compiler19.types.stringLiteral(extra.registerId),
3589
+ import_compiler20.types.stringLiteral(extra.registerId),
3424
3590
  (extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section)
3425
3591
  );
3426
3592
  }
@@ -3438,7 +3604,7 @@ var program_default = {
3438
3604
  migrate: {
3439
3605
  enter(program) {
3440
3606
  previousProgramPath.set(program, currentProgramPath);
3441
- program.node.params = [import_compiler20.types.identifier("input")];
3607
+ program.node.params = [import_compiler21.types.identifier("input")];
3442
3608
  currentProgramPath = program;
3443
3609
  },
3444
3610
  exit() {
@@ -3521,7 +3687,7 @@ var program_default = {
3521
3687
  body.push(child);
3522
3688
  }
3523
3689
  }
3524
- body[0] ??= import_compiler20.types.importDeclaration([], import_compiler20.types.stringLiteral(compatFile));
3690
+ body[0] ??= import_compiler21.types.importDeclaration([], import_compiler21.types.stringLiteral(compatFile));
3525
3691
  program.node.body = body;
3526
3692
  }
3527
3693
  currentProgramPath = previousProgramPath.get(currentProgramPath);
@@ -3612,7 +3778,7 @@ function isFunction(path5) {
3612
3778
  }
3613
3779
 
3614
3780
  // src/translator/util/is-invoked-function.ts
3615
- var import_compiler21 = require("@marko/compiler");
3781
+ var import_compiler22 = require("@marko/compiler");
3616
3782
  function isInvokedFunction(expr) {
3617
3783
  let curPath = expr;
3618
3784
  while (curPath) {
@@ -3655,7 +3821,7 @@ function createBinding(name2, type, section, upstreamAlias, upstreamExpression,
3655
3821
  closureSections: void 0,
3656
3822
  excludeProperties: void 0,
3657
3823
  serialize: false,
3658
- sources: /* @__PURE__ */ new Set(),
3824
+ sources: void 0,
3659
3825
  aliases: /* @__PURE__ */ new Set(),
3660
3826
  hoists: /* @__PURE__ */ new Map(),
3661
3827
  propertyAliases: /* @__PURE__ */ new Map(),
@@ -3929,7 +4095,7 @@ function trackReference(referencePath, binding) {
3929
4095
  let propPath = binding.name;
3930
4096
  while (true) {
3931
4097
  const { parent } = root;
3932
- if (!import_compiler22.types.isMemberExpression(parent)) break;
4098
+ if (!import_compiler23.types.isMemberExpression(parent)) break;
3933
4099
  const prop = getMemberExpressionPropString(parent);
3934
4100
  if (prop === void 0) break;
3935
4101
  if (reference.propertyAliases.has(prop)) {
@@ -4081,10 +4247,10 @@ function finalizeReferences() {
4081
4247
  for (let j = i + 1; j < numReferences; j++) {
4082
4248
  const binding1 = intersection[i];
4083
4249
  const binding2 = intersection[j];
4084
- if (!binding1.serialize && !isSuperset(binding1.sources, binding2.sources)) {
4250
+ if (!binding1.serialize && !bindingUtil.isSuperset(binding1.sources, binding2.sources)) {
4085
4251
  binding1.serialize = true;
4086
4252
  }
4087
- if (!binding2.serialize && !isSuperset(binding2.sources, binding1.sources)) {
4253
+ if (!binding2.serialize && !bindingUtil.isSuperset(binding2.sources, binding1.sources)) {
4088
4254
  binding2.serialize = true;
4089
4255
  }
4090
4256
  }
@@ -4096,7 +4262,7 @@ function finalizeReferences() {
4096
4262
  let serialize = false;
4097
4263
  const sourceSection = binding.section;
4098
4264
  let currentSection = section;
4099
- while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || isStatefulReferences(
4265
+ while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || !!getDynamicSourcesForReferences(
4100
4266
  currentSection.upstreamExpression.referencedBindings
4101
4267
  ))) {
4102
4268
  currentSection = currentSection.parent;
@@ -4137,28 +4303,21 @@ function getMaxOwnSourceOffset(intersection, section) {
4137
4303
  let scopeOffset;
4138
4304
  for (const binding of intersection) {
4139
4305
  if (binding.section === section) {
4140
- for (const sourceBinding of binding.sources) {
4141
- if (sourceBinding.scopeOffset && (!scopeOffset || scopeOffset.id < sourceBinding.scopeOffset.id)) {
4142
- scopeOffset = sourceBinding.scopeOffset;
4306
+ forEach(binding.sources, (source) => {
4307
+ if (source.scopeOffset && (!scopeOffset || scopeOffset.id < source.scopeOffset.id)) {
4308
+ scopeOffset = source.scopeOffset;
4143
4309
  }
4144
- }
4310
+ });
4145
4311
  }
4146
4312
  }
4147
4313
  return scopeOffset;
4148
4314
  }
4149
4315
  var intersectionMeta = /* @__PURE__ */ new WeakMap();
4150
- function isSuperset(set, subset) {
4151
- for (const elem of subset) {
4152
- if (!set.has(elem)) {
4153
- return false;
4154
- }
4155
- }
4156
- return true;
4157
- }
4158
4316
  function resolveBindingSources(binding) {
4159
4317
  const derived = /* @__PURE__ */ new Set();
4160
- const { sources } = binding;
4318
+ let sources;
4161
4319
  crawl(binding);
4320
+ binding.sources = sources;
4162
4321
  function crawl(binding2) {
4163
4322
  if (binding2.type === 4 /* derived */ || binding2.type === 3 /* param */) {
4164
4323
  let alias;
@@ -4171,12 +4330,12 @@ function resolveBindingSources(binding) {
4171
4330
  derived.add(curBinding);
4172
4331
  forEach(curBinding.upstreamExpression.referencedBindings, crawl);
4173
4332
  } else if (curBinding.type === 2 /* input */) {
4174
- sources.add(binding2);
4333
+ sources = bindingUtil.add(sources, binding2);
4175
4334
  } else {
4176
- sources.add(curBinding);
4335
+ sources = bindingUtil.add(sources, curBinding);
4177
4336
  }
4178
4337
  } else {
4179
- sources.add(binding2);
4338
+ sources = bindingUtil.add(sources, binding2);
4180
4339
  }
4181
4340
  }
4182
4341
  }
@@ -4236,9 +4395,9 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
4236
4395
  }
4237
4396
  function getScopeAccessorLiteral(binding, includeId) {
4238
4397
  if (isOptimize()) {
4239
- return import_compiler22.types.numericLiteral(binding.id);
4398
+ return import_compiler23.types.numericLiteral(binding.id);
4240
4399
  }
4241
- return import_compiler22.types.stringLiteral(
4400
+ return import_compiler23.types.stringLiteral(
4242
4401
  binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "")
4243
4402
  );
4244
4403
  }
@@ -4253,7 +4412,7 @@ function getSectionInstancesAccessor(section) {
4253
4412
  }
4254
4413
  function getSectionInstancesAccessorLiteral(section) {
4255
4414
  const accessor = getSectionInstancesAccessor(section);
4256
- return accessor ? typeof accessor === "number" ? import_compiler22.types.numericLiteral(accessor) : import_compiler22.types.stringLiteral(accessor) : void 0;
4415
+ return accessor ? typeof accessor === "number" ? import_compiler23.types.numericLiteral(accessor) : import_compiler23.types.stringLiteral(accessor) : void 0;
4257
4416
  }
4258
4417
  function getReadReplacement(node) {
4259
4418
  const { extra } = node;
@@ -4271,18 +4430,18 @@ function getReadReplacement(node) {
4271
4430
  if (binding) {
4272
4431
  if (node.type === "Identifier") {
4273
4432
  if (binding.type === 5 /* hoist */) {
4274
- replacement = node.extra?.[kIsInvoked] ? import_compiler22.types.callExpression(getHoistFunctionIdentifier(binding), [
4433
+ replacement = node.extra?.[kIsInvoked] ? import_compiler23.types.callExpression(getHoistFunctionIdentifier(binding), [
4275
4434
  getScopeExpression(node.extra.section, binding.section)
4276
- ]) : import_compiler22.types.identifier(getScopeAccessor(binding));
4435
+ ]) : import_compiler23.types.identifier(getScopeAccessor(binding));
4277
4436
  } else if (binding.name !== node.name) {
4278
4437
  node.name = binding.name;
4279
4438
  }
4280
4439
  } else {
4281
- replacement = import_compiler22.types.identifier(binding.name);
4440
+ replacement = import_compiler23.types.identifier(binding.name);
4282
4441
  }
4283
4442
  } else if (read) {
4284
4443
  replacement = toMemberExpression(
4285
- import_compiler22.types.identifier(read.binding.name),
4444
+ import_compiler23.types.identifier(read.binding.name),
4286
4445
  Array.isArray(read.props) ? read.props[0] : read.props
4287
4446
  );
4288
4447
  if (Array.isArray(read.props)) {
@@ -4398,31 +4557,6 @@ function isRegisteredFnExtra(extra) {
4398
4557
  return isReferencedExtra(extra) && extra.registerId !== void 0;
4399
4558
  }
4400
4559
 
4401
- // src/translator/util/is-stateful.ts
4402
- function isStatefulReferences(referencedBindings) {
4403
- if (referencedBindings) {
4404
- if (Array.isArray(referencedBindings)) {
4405
- for (const ref of referencedBindings) {
4406
- if (isStatefulBinding(ref)) {
4407
- return true;
4408
- }
4409
- }
4410
- } else {
4411
- return isStatefulBinding(referencedBindings);
4412
- }
4413
- }
4414
- return false;
4415
- }
4416
- function isStatefulBinding(binding) {
4417
- switch (binding.type) {
4418
- case 1 /* let */:
4419
- case 2 /* input */:
4420
- return true;
4421
- default:
4422
- return binding.upstreamAlias ? isStatefulBinding(binding.upstreamAlias) : !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
4423
- }
4424
- }
4425
-
4426
4560
  // src/translator/core/await.ts
4427
4561
  var kDOMBinding = Symbol("await tag dom binding");
4428
4562
  var await_default = {
@@ -4446,7 +4580,7 @@ var await_default = {
4446
4580
  if (!valueAttr) {
4447
4581
  throw tag.get("name").buildCodeFrameError("The `await` tag requires a value.");
4448
4582
  }
4449
- if (node.attributes.length > 1 || !import_compiler23.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
4583
+ if (node.attributes.length > 1 || !import_compiler24.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
4450
4584
  throw tag.get("name").buildCodeFrameError(
4451
4585
  "The `await` tag only supports the `value` attribute."
4452
4586
  );
@@ -4454,12 +4588,12 @@ var await_default = {
4454
4588
  if (!node.body.body.length) {
4455
4589
  throw tag.get("name").buildCodeFrameError("The `await` tag requires body content.");
4456
4590
  }
4457
- if (node.body.params.length && (node.body.params.length > 1 || import_compiler23.types.isSpreadElement(node.body.params[0]))) {
4591
+ if (node.body.params.length && (node.body.params.length > 1 || import_compiler24.types.isSpreadElement(node.body.params[0]))) {
4458
4592
  throw tag.get("name").buildCodeFrameError(
4459
4593
  "The `await` tag only supports a single parameter."
4460
4594
  );
4461
4595
  }
4462
- startSection(tagBody);
4596
+ const bodySection = startSection(tagBody);
4463
4597
  getOrCreateSection(tag);
4464
4598
  trackParamsReferences(
4465
4599
  tagBody,
@@ -4467,6 +4601,7 @@ var await_default = {
4467
4601
  void 0,
4468
4602
  evaluate(valueAttr.value)
4469
4603
  );
4604
+ bodySection.upstreamExpression = valueAttr.value.extra;
4470
4605
  },
4471
4606
  translate: translateByTarget({
4472
4607
  html: {
@@ -4487,20 +4622,16 @@ var await_default = {
4487
4622
  const nodeRef2 = tagExtra[kDOMBinding];
4488
4623
  const tagBody = tag.get("body");
4489
4624
  const section = getSection(tag);
4490
- const bodySection = getSectionForBody(tagBody);
4491
- if (isStatefulReferences(valueAttr.extra?.referencedBindings) || checkStatefulClosures(bodySection, true)) {
4492
- setForceResumeScope(bodySection);
4493
- }
4494
4625
  flushInto(tag);
4495
4626
  writeHTMLResumeStatements(tagBody);
4496
4627
  tag.replaceWith(
4497
- import_compiler23.types.expressionStatement(
4628
+ import_compiler24.types.expressionStatement(
4498
4629
  callRuntime(
4499
4630
  "fork",
4500
4631
  getScopeIdIdentifier(section),
4501
4632
  getScopeAccessorLiteral(nodeRef2),
4502
4633
  valueAttr.value,
4503
- import_compiler23.types.arrowFunctionExpression(
4634
+ import_compiler24.types.arrowFunctionExpression(
4504
4635
  node.body.params,
4505
4636
  toFirstExpressionOrBlock(node.body.body)
4506
4637
  )
@@ -4532,12 +4663,12 @@ var await_default = {
4532
4663
  return callRuntime(
4533
4664
  "awaitTag",
4534
4665
  getScopeAccessorLiteral(nodeRef2),
4535
- import_compiler23.types.identifier(bodySection.name)
4666
+ import_compiler24.types.identifier(bodySection.name)
4536
4667
  );
4537
4668
  };
4538
4669
  addValue(
4539
4670
  section,
4540
- tag.node.attributes[0].value.extra?.referencedBindings,
4671
+ bodySection.upstreamExpression?.referencedBindings,
4541
4672
  signal,
4542
4673
  tag.node.attributes[0].value
4543
4674
  );
@@ -4556,7 +4687,7 @@ var await_default = {
4556
4687
  };
4557
4688
 
4558
4689
  // src/translator/core/client.ts
4559
- var import_compiler24 = require("@marko/compiler");
4690
+ var import_compiler25 = require("@marko/compiler");
4560
4691
  var import_babel_utils13 = require("@marko/compiler/babel-utils");
4561
4692
  var client_default = {
4562
4693
  parse(tag) {
@@ -4568,10 +4699,10 @@ var client_default = {
4568
4699
  const code = rawValue.replace(/^client\s*/, "").trim();
4569
4700
  const start = node.name.start + (rawValue.length - code.length);
4570
4701
  let body = (0, import_babel_utils13.parseStatements)(file, code, start, start + code.length);
4571
- if (body.length === 1 && import_compiler24.types.isBlockStatement(body[0])) {
4702
+ if (body.length === 1 && import_compiler25.types.isBlockStatement(body[0])) {
4572
4703
  body = body[0].body;
4573
4704
  }
4574
- tag.replaceWith(import_compiler24.types.markoScriptlet(body, true, "client"));
4705
+ tag.replaceWith(import_compiler25.types.markoScriptlet(body, true, "client"));
4575
4706
  },
4576
4707
  parseOptions: {
4577
4708
  statement: true,
@@ -4587,11 +4718,11 @@ var client_default = {
4587
4718
  };
4588
4719
 
4589
4720
  // src/translator/core/const.ts
4590
- var import_compiler26 = require("@marko/compiler");
4721
+ var import_compiler27 = require("@marko/compiler");
4591
4722
  var import_babel_utils14 = require("@marko/compiler/babel-utils");
4592
4723
 
4593
4724
  // src/translator/util/translate-var.ts
4594
- var import_compiler25 = require("@marko/compiler");
4725
+ var import_compiler26 = require("@marko/compiler");
4595
4726
  function translateVar(tag, initialValue, kind = "const") {
4596
4727
  const {
4597
4728
  node: { var: tagVar }
@@ -4600,7 +4731,7 @@ function translateVar(tag, initialValue, kind = "const") {
4600
4731
  return;
4601
4732
  }
4602
4733
  tag.insertBefore(
4603
- import_compiler25.types.variableDeclaration(kind, [import_compiler25.types.variableDeclarator(tagVar, initialValue)])
4734
+ import_compiler26.types.variableDeclaration(kind, [import_compiler26.types.variableDeclarator(tagVar, initialValue)])
4604
4735
  );
4605
4736
  }
4606
4737
 
@@ -4618,12 +4749,12 @@ var const_default = {
4618
4749
  if (!valueAttr) {
4619
4750
  throw tag.get("name").buildCodeFrameError("The `const` tag requires a value.");
4620
4751
  }
4621
- if (node.attributes.length > 1 || !import_compiler26.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
4752
+ if (node.attributes.length > 1 || !import_compiler27.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
4622
4753
  throw tag.get("name").buildCodeFrameError(
4623
4754
  "The `const` tag only supports the `value` attribute."
4624
4755
  );
4625
4756
  }
4626
- const upstreamAlias = import_compiler26.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
4757
+ const upstreamAlias = import_compiler27.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
4627
4758
  trackVarReferences(
4628
4759
  tag,
4629
4760
  4 /* derived */,
@@ -4664,7 +4795,7 @@ var const_default = {
4664
4795
  };
4665
4796
 
4666
4797
  // src/translator/core/debug.ts
4667
- var import_compiler27 = require("@marko/compiler");
4798
+ var import_compiler28 = require("@marko/compiler");
4668
4799
  var import_babel_utils15 = require("@marko/compiler/babel-utils");
4669
4800
  var debug_default = {
4670
4801
  analyze(tag) {
@@ -4673,7 +4804,7 @@ var debug_default = {
4673
4804
  (0, import_babel_utils15.assertNoArgs)(tag);
4674
4805
  (0, import_babel_utils15.assertNoParams)(tag);
4675
4806
  assertNoBodyContent(tag);
4676
- if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler27.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
4807
+ if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler28.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
4677
4808
  throw tag.get("name").buildCodeFrameError(
4678
4809
  "The `debug` tag only supports the `value` attribute."
4679
4810
  );
@@ -4684,7 +4815,7 @@ var debug_default = {
4684
4815
  const section = getSection(tag);
4685
4816
  const [valueAttr] = tag.node.attributes;
4686
4817
  const referencedBindings = valueAttr?.value.extra?.referencedBindings;
4687
- const statement = withPreviousLocation(import_compiler27.types.debuggerStatement(), tag.node);
4818
+ const statement = withPreviousLocation(import_compiler28.types.debuggerStatement(), tag.node);
4688
4819
  if (isOutputHTML()) {
4689
4820
  tag.insertBefore(statement);
4690
4821
  } else {
@@ -4707,11 +4838,11 @@ var debug_default = {
4707
4838
  };
4708
4839
 
4709
4840
  // src/translator/core/define.ts
4710
- var import_compiler33 = require("@marko/compiler");
4841
+ var import_compiler34 = require("@marko/compiler");
4711
4842
  var import_babel_utils21 = require("@marko/compiler/babel-utils");
4712
4843
 
4713
4844
  // src/translator/util/nested-attribute-tags.ts
4714
- var import_compiler28 = require("@marko/compiler");
4845
+ var import_compiler29 = require("@marko/compiler");
4715
4846
  var import_babel_utils16 = require("@marko/compiler/babel-utils");
4716
4847
  var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
4717
4848
  function getAttrTagIdentifier(meta) {
@@ -4720,7 +4851,7 @@ function getAttrTagIdentifier(meta) {
4720
4851
  name2 = currentProgramPath.scope.generateUid(meta.name);
4721
4852
  attrTagToIdentifierLookup.set(meta, name2);
4722
4853
  }
4723
- return import_compiler28.types.identifier(name2);
4854
+ return import_compiler29.types.identifier(name2);
4724
4855
  }
4725
4856
  function analyzeAttributeTags(tag) {
4726
4857
  if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
@@ -4833,19 +4964,19 @@ function getConditionRoot(tag) {
4833
4964
  }
4834
4965
 
4835
4966
  // src/translator/util/translate-attrs.ts
4836
- var import_compiler32 = require("@marko/compiler");
4967
+ var import_compiler33 = require("@marko/compiler");
4837
4968
  var import_babel_utils20 = require("@marko/compiler/babel-utils");
4838
4969
 
4839
4970
  // src/translator/core/for.ts
4840
- var import_compiler31 = require("@marko/compiler");
4971
+ var import_compiler32 = require("@marko/compiler");
4841
4972
  var import_babel_utils19 = require("@marko/compiler/babel-utils");
4842
4973
 
4843
4974
  // src/translator/util/is-only-child-in-parent.ts
4844
- var import_compiler30 = require("@marko/compiler");
4975
+ var import_compiler31 = require("@marko/compiler");
4845
4976
  var import_babel_utils18 = require("@marko/compiler/babel-utils");
4846
4977
 
4847
4978
  // src/translator/visitors/tag/native-tag.ts
4848
- var import_compiler29 = require("@marko/compiler");
4979
+ var import_compiler30 = require("@marko/compiler");
4849
4980
  var import_babel_utils17 = require("@marko/compiler/babel-utils");
4850
4981
  var kNativeTagBinding = Symbol("native tag binding");
4851
4982
  var kSerializeMarker = Symbol("serialize marker");
@@ -4937,7 +5068,7 @@ var native_tag_default = {
4937
5068
  }
4938
5069
  }
4939
5070
  tag.node.attributes.push(
4940
- import_compiler29.types.markoAttribute(
5071
+ import_compiler30.types.markoAttribute(
4941
5072
  "value",
4942
5073
  normalizeStringExpression(parts) || buildUndefined()
4943
5074
  )
@@ -4952,7 +5083,7 @@ var native_tag_default = {
4952
5083
  (0, import_babel_utils17.assertNoParams)(tag);
4953
5084
  (0, import_babel_utils17.assertNoAttributeTags)(tag);
4954
5085
  const { node } = tag;
4955
- if (node.var && !import_compiler29.types.isIdentifier(node.var)) {
5086
+ if (node.var && !import_compiler30.types.isIdentifier(node.var)) {
4956
5087
  throw tag.get("var").buildCodeFrameError(
4957
5088
  "Tag variables on native elements cannot be destructured."
4958
5089
  );
@@ -4967,7 +5098,7 @@ var native_tag_default = {
4967
5098
  let spreadReferenceNodes;
4968
5099
  for (let i = attributes.length; i--; ) {
4969
5100
  const attr2 = attributes[i];
4970
- if (import_compiler29.types.isMarkoAttribute(attr2)) {
5101
+ if (import_compiler30.types.isMarkoAttribute(attr2)) {
4971
5102
  if (seen[attr2.name]) {
4972
5103
  dropReferences(attr2.value);
4973
5104
  continue;
@@ -4979,14 +5110,14 @@ var native_tag_default = {
4979
5110
  } else if (!evaluate(attr2.value).confident) {
4980
5111
  hasDynamicAttributes = true;
4981
5112
  }
4982
- } else if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5113
+ } else if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
4983
5114
  hasEventHandlers = true;
4984
5115
  hasDynamicAttributes = true;
4985
5116
  (attr2.value.extra ??= {}).isEffect = true;
4986
5117
  }
4987
5118
  if (spreadReferenceNodes) {
4988
5119
  spreadReferenceNodes.push(attr2.value);
4989
- } else if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5120
+ } else if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
4990
5121
  spreadReferenceNodes = [attr2.value];
4991
5122
  relatedControllable = getRelatedControllable(tagName, seen);
4992
5123
  }
@@ -5014,7 +5145,7 @@ var native_tag_default = {
5014
5145
  }
5015
5146
  if (node.var || hasEventHandlers || hasDynamicAttributes) {
5016
5147
  currentProgramPath.node.extra.isInteractive ||= hasEventHandlers;
5017
- const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler29.types.toIdentifier(tag.get("name"));
5148
+ const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler30.types.toIdentifier(tag.get("name"));
5018
5149
  const tagExtra = node.extra ??= {};
5019
5150
  const bindingName = "#" + tagName2;
5020
5151
  if (hasEventHandlers || node.var) {
@@ -5067,13 +5198,13 @@ var native_tag_default = {
5067
5198
  serializeOwners(referenceSection, section);
5068
5199
  }
5069
5200
  }
5070
- setForceResumeScope(section);
5201
+ serializeSectionIfNeeded(section, true);
5071
5202
  translateVar(
5072
5203
  tag,
5073
5204
  callRuntime(
5074
5205
  "nodeRef",
5075
5206
  getterId && getScopeIdIdentifier(section),
5076
- getterId && import_compiler29.types.stringLiteral(getterId)
5207
+ getterId && import_compiler30.types.stringLiteral(getterId)
5077
5208
  )
5078
5209
  );
5079
5210
  } else {
@@ -5084,13 +5215,13 @@ var native_tag_default = {
5084
5215
  );
5085
5216
  currentProgramPath.pushContainer(
5086
5217
  "body",
5087
- import_compiler29.types.variableDeclaration("const", [
5088
- import_compiler29.types.variableDeclarator(
5218
+ import_compiler30.types.variableDeclaration("const", [
5219
+ import_compiler30.types.variableDeclarator(
5089
5220
  getterFnIdentifier,
5090
5221
  callRuntime(
5091
5222
  "nodeRef",
5092
- import_compiler29.types.stringLiteral(getterId),
5093
- import_compiler29.types.stringLiteral(
5223
+ import_compiler30.types.stringLiteral(getterId),
5224
+ import_compiler30.types.stringLiteral(
5094
5225
  getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
5095
5226
  )
5096
5227
  )
@@ -5103,22 +5234,22 @@ var native_tag_default = {
5103
5234
  const referenceSection = getSection(reference);
5104
5235
  if (isInvokedFunction(reference)) {
5105
5236
  reference.parentPath.replaceWith(
5106
- import_compiler29.types.expressionStatement(
5237
+ import_compiler30.types.expressionStatement(
5107
5238
  createScopeReadExpression(referenceSection, nodeRef2)
5108
5239
  )
5109
5240
  );
5110
5241
  } else if (getterFnIdentifier) {
5111
5242
  reference.replaceWith(
5112
- import_compiler29.types.callExpression(getterFnIdentifier, [
5243
+ import_compiler30.types.callExpression(getterFnIdentifier, [
5113
5244
  getScopeExpression(referenceSection, getSection(tag))
5114
5245
  ])
5115
5246
  );
5116
5247
  } else {
5117
5248
  reference.replaceWith(
5118
- import_compiler29.types.expressionStatement(
5119
- import_compiler29.types.memberExpression(
5249
+ import_compiler30.types.expressionStatement(
5250
+ import_compiler30.types.memberExpression(
5120
5251
  getScopeExpression(section, referenceSection),
5121
- import_compiler29.types.stringLiteral(
5252
+ import_compiler30.types.stringLiteral(
5122
5253
  getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
5123
5254
  ),
5124
5255
  true
@@ -5154,7 +5285,7 @@ var native_tag_default = {
5154
5285
  "render",
5155
5286
  section,
5156
5287
  referencedBindings,
5157
- import_compiler29.types.expressionStatement(
5288
+ import_compiler30.types.expressionStatement(
5158
5289
  callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
5159
5290
  )
5160
5291
  );
@@ -5162,7 +5293,7 @@ var native_tag_default = {
5162
5293
  "effect",
5163
5294
  section,
5164
5295
  void 0,
5165
- import_compiler29.types.expressionStatement(
5296
+ import_compiler30.types.expressionStatement(
5166
5297
  callRuntime(`${helper}_effect`, scopeIdentifier, visitAccessor)
5167
5298
  )
5168
5299
  );
@@ -5179,18 +5310,18 @@ var native_tag_default = {
5179
5310
  } else if (spreadExpression) {
5180
5311
  const spreadIdentifier = tag.scope.generateUidIdentifier("select_input");
5181
5312
  tag.insertBefore(
5182
- import_compiler29.types.variableDeclaration("const", [
5183
- import_compiler29.types.variableDeclarator(spreadIdentifier, spreadExpression)
5313
+ import_compiler30.types.variableDeclaration("const", [
5314
+ import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
5184
5315
  ])
5185
5316
  );
5186
5317
  htmlSelectArgs.set(tag.node, {
5187
- value: import_compiler29.types.memberExpression(
5318
+ value: import_compiler30.types.memberExpression(
5188
5319
  spreadIdentifier,
5189
- import_compiler29.types.identifier("value")
5320
+ import_compiler30.types.identifier("value")
5190
5321
  ),
5191
- valueChange: import_compiler29.types.memberExpression(
5322
+ valueChange: import_compiler30.types.memberExpression(
5192
5323
  spreadIdentifier,
5193
- import_compiler29.types.identifier("valueChange")
5324
+ import_compiler30.types.identifier("valueChange")
5194
5325
  )
5195
5326
  });
5196
5327
  spreadExpression = spreadIdentifier;
@@ -5204,14 +5335,14 @@ var native_tag_default = {
5204
5335
  } else if (spreadExpression) {
5205
5336
  const spreadIdentifier = tag.scope.generateUidIdentifier("textarea_input");
5206
5337
  tag.insertBefore(
5207
- import_compiler29.types.variableDeclaration("const", [
5208
- import_compiler29.types.variableDeclarator(spreadIdentifier, spreadExpression)
5338
+ import_compiler30.types.variableDeclaration("const", [
5339
+ import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
5209
5340
  ])
5210
5341
  );
5211
- value = import_compiler29.types.memberExpression(spreadIdentifier, import_compiler29.types.identifier("value"));
5212
- valueChange = import_compiler29.types.memberExpression(
5342
+ value = import_compiler30.types.memberExpression(spreadIdentifier, import_compiler30.types.identifier("value"));
5343
+ valueChange = import_compiler30.types.memberExpression(
5213
5344
  spreadIdentifier,
5214
- import_compiler29.types.identifier("valueChange")
5345
+ import_compiler30.types.identifier("valueChange")
5215
5346
  );
5216
5347
  spreadExpression = spreadIdentifier;
5217
5348
  }
@@ -5247,10 +5378,10 @@ var native_tag_default = {
5247
5378
  "render",
5248
5379
  section,
5249
5380
  valueReferences,
5250
- import_compiler29.types.expressionStatement(
5381
+ import_compiler30.types.expressionStatement(
5251
5382
  callRuntime(
5252
5383
  helper,
5253
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5384
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5254
5385
  value
5255
5386
  )
5256
5387
  )
@@ -5265,18 +5396,18 @@ var native_tag_default = {
5265
5396
  if (isEventHandler(name3)) {
5266
5397
  addHTMLEffectCall(section, valueReferences);
5267
5398
  } else {
5268
- write2`${callRuntime("attr", import_compiler29.types.stringLiteral(name3), value)}`;
5399
+ write2`${callRuntime("attr", import_compiler30.types.stringLiteral(name3), value)}`;
5269
5400
  }
5270
5401
  } else if (isEventHandler(name3)) {
5271
5402
  addStatement(
5272
5403
  "effect",
5273
5404
  section,
5274
5405
  valueReferences,
5275
- import_compiler29.types.expressionStatement(
5406
+ import_compiler30.types.expressionStatement(
5276
5407
  callRuntime(
5277
5408
  "on",
5278
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5279
- import_compiler29.types.stringLiteral(getEventHandlerName(name3)),
5409
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5410
+ import_compiler30.types.stringLiteral(getEventHandlerName(name3)),
5280
5411
  value
5281
5412
  )
5282
5413
  )
@@ -5286,11 +5417,11 @@ var native_tag_default = {
5286
5417
  "render",
5287
5418
  section,
5288
5419
  valueReferences,
5289
- import_compiler29.types.expressionStatement(
5420
+ import_compiler30.types.expressionStatement(
5290
5421
  callRuntime(
5291
5422
  "attr",
5292
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5293
- import_compiler29.types.stringLiteral(name3),
5423
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5424
+ import_compiler30.types.stringLiteral(name3),
5294
5425
  value
5295
5426
  )
5296
5427
  )
@@ -5313,7 +5444,7 @@ var native_tag_default = {
5313
5444
  "render",
5314
5445
  section,
5315
5446
  extra.referencedBindings,
5316
- import_compiler29.types.expressionStatement(
5447
+ import_compiler30.types.expressionStatement(
5317
5448
  callRuntime(
5318
5449
  "partialAttrs",
5319
5450
  scopeIdentifier,
@@ -5328,7 +5459,7 @@ var native_tag_default = {
5328
5459
  "render",
5329
5460
  section,
5330
5461
  extra.referencedBindings,
5331
- import_compiler29.types.expressionStatement(
5462
+ import_compiler30.types.expressionStatement(
5332
5463
  callRuntime(
5333
5464
  "attrs",
5334
5465
  scopeIdentifier,
@@ -5342,7 +5473,7 @@ var native_tag_default = {
5342
5473
  "effect",
5343
5474
  section,
5344
5475
  extra.referencedBindings,
5345
- import_compiler29.types.expressionStatement(
5476
+ import_compiler30.types.expressionStatement(
5346
5477
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
5347
5478
  ),
5348
5479
  false
@@ -5363,7 +5494,7 @@ var native_tag_default = {
5363
5494
  write2`>`;
5364
5495
  }
5365
5496
  if (isHTML && extra.tagNameNullable) {
5366
- tag.insertBefore(import_compiler29.types.ifStatement(name2.node, consumeHTML(tag)))[0].skip();
5497
+ tag.insertBefore(import_compiler30.types.ifStatement(name2.node, consumeHTML(tag)))[0].skip();
5367
5498
  }
5368
5499
  if (writeAtStartOfBody) {
5369
5500
  write2`${writeAtStartOfBody}`;
@@ -5384,16 +5515,16 @@ var native_tag_default = {
5384
5515
  writeTo(tag)`</${tag.node.name}>`;
5385
5516
  flushInto(tag);
5386
5517
  tag.insertBefore(
5387
- import_compiler29.types.expressionStatement(
5518
+ import_compiler30.types.expressionStatement(
5388
5519
  callRuntime(
5389
5520
  "controllable_select_value",
5390
5521
  getScopeIdIdentifier(getSection(tag)),
5391
5522
  getScopeAccessorLiteral(nodeRef2),
5392
5523
  selectArgs.value,
5393
5524
  selectArgs.valueChange,
5394
- import_compiler29.types.arrowFunctionExpression(
5525
+ import_compiler30.types.arrowFunctionExpression(
5395
5526
  [],
5396
- import_compiler29.types.blockStatement(tag.node.body.body)
5527
+ import_compiler30.types.blockStatement(tag.node.body.body)
5397
5528
  )
5398
5529
  )
5399
5530
  )
@@ -5401,9 +5532,14 @@ var native_tag_default = {
5401
5532
  } else {
5402
5533
  tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
5403
5534
  }
5404
- const shouldMark = nodeRef2 && (extra[kSerializeMarker] || extra[kSerializeMarker] === void 0 && (isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
5405
- (attr2) => isStatefulReferences(attr2.value.extra?.referencedBindings)
5406
- )));
5535
+ const allExtras = [extra];
5536
+ for (const attr2 of tag.node.attributes) {
5537
+ if (attr2.value.extra) {
5538
+ allExtras.push(attr2.value.extra);
5539
+ }
5540
+ }
5541
+ const serializeReason = getDynamicSourcesForExtras(allExtras);
5542
+ const shouldMark = nodeRef2 && (extra[kSerializeMarker] || extra[kSerializeMarker] === void 0 && !!serializeReason);
5407
5543
  if (!openTagOnly && !selectArgs) {
5408
5544
  writeTo(
5409
5545
  tag,
@@ -5412,7 +5548,7 @@ var native_tag_default = {
5412
5548
  }
5413
5549
  if (isHTML && extra.tagNameNullable) {
5414
5550
  tag.insertBefore(
5415
- import_compiler29.types.ifStatement(tag.node.name, consumeHTML(tag))
5551
+ import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
5416
5552
  )[0].skip();
5417
5553
  }
5418
5554
  if (shouldMark) {
@@ -5435,7 +5571,7 @@ function getUsedAttrs(tagName, tag) {
5435
5571
  for (let i = attributes.length; i--; ) {
5436
5572
  const attr2 = attributes[i];
5437
5573
  const { value } = attr2;
5438
- if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5574
+ if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
5439
5575
  if (!spreadProps) {
5440
5576
  spreadProps = [];
5441
5577
  staticControllable = getRelatedControllable(tagName, seen);
@@ -5449,7 +5585,7 @@ function getUsedAttrs(tagName, tag) {
5449
5585
  staticControllable = void 0;
5450
5586
  }
5451
5587
  }
5452
- spreadProps.push(import_compiler29.types.spreadElement(value));
5588
+ spreadProps.push(import_compiler30.types.spreadElement(value));
5453
5589
  } else if (!seen[attr2.name]) {
5454
5590
  seen[attr2.name] = attr2;
5455
5591
  if (spreadProps) {
@@ -5479,16 +5615,16 @@ function getUsedAttrs(tagName, tag) {
5479
5615
  for (const attr2 of staticControllable.attrs) {
5480
5616
  if (attr2) {
5481
5617
  (skipProps ||= []).push(
5482
- toObjectProperty(attr2.name, import_compiler29.types.numericLiteral(1))
5618
+ toObjectProperty(attr2.name, import_compiler30.types.numericLiteral(1))
5483
5619
  );
5484
5620
  }
5485
5621
  }
5486
5622
  }
5487
5623
  for (const { name: name2 } of staticAttrs) {
5488
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler29.types.numericLiteral(1)));
5624
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler30.types.numericLiteral(1)));
5489
5625
  }
5490
5626
  if (skipProps) {
5491
- skipExpression = import_compiler29.types.objectExpression(skipProps);
5627
+ skipExpression = import_compiler30.types.objectExpression(skipProps);
5492
5628
  }
5493
5629
  spreadExpression = propsToExpression(spreadProps);
5494
5630
  }
@@ -5503,7 +5639,7 @@ function isChangeHandler(propName) {
5503
5639
  return /^(?:value|checked(?:Value)?|open)Change/.test(propName);
5504
5640
  }
5505
5641
  function buildUndefined() {
5506
- return import_compiler29.types.unaryExpression("void", import_compiler29.types.numericLiteral(0));
5642
+ return import_compiler30.types.unaryExpression("void", import_compiler30.types.numericLiteral(0));
5507
5643
  }
5508
5644
 
5509
5645
  // src/translator/util/is-only-child-in-parent.ts
@@ -5606,8 +5742,6 @@ var for_default = {
5606
5742
  const tagSection = getSection(tag);
5607
5743
  const bodySection = getSectionForBody(tagBody);
5608
5744
  const { node } = tag;
5609
- const tagExtra = node.extra;
5610
- const isStateful = isStatefulReferences(tagExtra.referencedBindings);
5611
5745
  const onlyChildInParentOptimization = isOnlyChildInParent(tag);
5612
5746
  const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5613
5747
  const forAttrs = getKnownAttrValues(node);
@@ -5615,14 +5749,16 @@ var for_default = {
5615
5749
  const params = node.body.params;
5616
5750
  const statements = [];
5617
5751
  const bodyStatements = node.body.body;
5618
- const hasStatefulClosures = checkStatefulClosures(bodySection, true);
5619
- const hasHoists = bodySection.hoisted || bodySection.isHoistThrough || bodySection.referencedHoists;
5752
+ const sectionSources = getDynamicSourcesForSection(bodySection);
5753
+ const hasHoists = isSectionWithHoists(bodySection);
5754
+ const serializeReason = hasHoists || sectionSources?.all;
5620
5755
  const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
5621
5756
  let keyExpression;
5622
- if (isStateful && onlyChildInParentOptimization) {
5757
+ if (sectionSources?.referenced && onlyChildInParentOptimization) {
5623
5758
  getParentTag(tag).node.extra[kSerializeMarker] = false;
5624
5759
  }
5625
- if (isStateful || hasStatefulClosures || hasHoists) {
5760
+ if (serializeReason) {
5761
+ serializeSectionIfNeeded(bodySection, serializeReason);
5626
5762
  const defaultParamNames = {
5627
5763
  of: ["list", "index"],
5628
5764
  in: ["key", "value"],
@@ -5630,36 +5766,35 @@ var for_default = {
5630
5766
  }[forType];
5631
5767
  const defaultByParamIndex = forType === "of" ? 1 : 0;
5632
5768
  const requiredParamsIndex = forAttrs.by ? defaultParamNames.length - 1 : defaultByParamIndex;
5633
- setForceResumeScope(bodySection);
5634
5769
  for (let i = 0; i <= requiredParamsIndex; i++) {
5635
5770
  const existingParam = params[i];
5636
- if (!existingParam || !import_compiler31.types.isIdentifier(existingParam)) {
5771
+ if (!existingParam || !import_compiler32.types.isIdentifier(existingParam)) {
5637
5772
  const id = params[i] = currentProgramPath.scope.generateUidIdentifier(
5638
5773
  defaultParamNames[i]
5639
5774
  );
5640
5775
  if (existingParam) {
5641
5776
  bodyStatements.unshift(
5642
- import_compiler31.types.variableDeclaration("let", [
5643
- import_compiler31.types.variableDeclarator(existingParam, id)
5777
+ import_compiler32.types.variableDeclaration("let", [
5778
+ import_compiler32.types.variableDeclarator(existingParam, id)
5644
5779
  ])
5645
5780
  );
5646
5781
  }
5647
5782
  }
5648
5783
  }
5649
5784
  if (forAttrs.by) {
5650
- if (import_compiler31.types.isStringLiteral(forAttrs.by)) {
5785
+ if (import_compiler32.types.isStringLiteral(forAttrs.by)) {
5651
5786
  keyExpression = toMemberExpression(
5652
5787
  params[0],
5653
5788
  forAttrs.by.value
5654
5789
  );
5655
- } else if (import_compiler31.types.isFunction(forAttrs.by)) {
5790
+ } else if (import_compiler32.types.isFunction(forAttrs.by)) {
5656
5791
  const byIdentifier = currentProgramPath.scope.generateUidIdentifier("by");
5657
5792
  statements.push(
5658
- import_compiler31.types.variableDeclaration("const", [
5659
- import_compiler31.types.variableDeclarator(byIdentifier, forAttrs.by)
5793
+ import_compiler32.types.variableDeclaration("const", [
5794
+ import_compiler32.types.variableDeclarator(byIdentifier, forAttrs.by)
5660
5795
  ])
5661
5796
  );
5662
- keyExpression = import_compiler31.types.callExpression(
5797
+ keyExpression = import_compiler32.types.callExpression(
5663
5798
  byIdentifier,
5664
5799
  params
5665
5800
  );
@@ -5675,57 +5810,56 @@ var for_default = {
5675
5810
  }
5676
5811
  const forScopesIdentifier = getScopeIdentifier(bodySection);
5677
5812
  getHTMLSectionStatements(tagSection).push(
5678
- import_compiler31.types.variableDeclaration("const", [
5679
- import_compiler31.types.variableDeclarator(
5813
+ import_compiler32.types.variableDeclaration("const", [
5814
+ import_compiler32.types.variableDeclarator(
5680
5815
  forScopesIdentifier,
5681
- import_compiler31.types.newExpression(import_compiler31.types.identifier("Map"), [])
5816
+ import_compiler32.types.newExpression(import_compiler32.types.identifier("Map"), [])
5682
5817
  )
5683
5818
  ])
5684
5819
  );
5685
- if (isStateful || hasStatefulClosures || hasHoists) {
5686
- bodyStatements.push(
5687
- import_compiler31.types.expressionStatement(
5688
- import_compiler31.types.callExpression(
5689
- import_compiler31.types.memberExpression(forScopesIdentifier, import_compiler31.types.identifier("set")),
5690
- [
5691
- keyExpression,
5692
- callRuntime(
5693
- "ensureScopeWithId",
5694
- getScopeIdIdentifier(bodySection)
5695
- )
5696
- ]
5697
- )
5820
+ bodyStatements.push(
5821
+ import_compiler32.types.expressionStatement(
5822
+ import_compiler32.types.callExpression(
5823
+ import_compiler32.types.memberExpression(forScopesIdentifier, import_compiler32.types.identifier("set")),
5824
+ [
5825
+ keyExpression,
5826
+ callRuntime(
5827
+ "ensureScopeWithId",
5828
+ getScopeIdIdentifier(bodySection)
5829
+ )
5830
+ ]
5698
5831
  )
5699
- );
5700
- }
5832
+ )
5833
+ );
5701
5834
  setSerializedProperty(
5702
5835
  tagSection,
5703
5836
  getAccessorPrefix().LoopScopeMap + getScopeAccessor(nodeRef2),
5704
- import_compiler31.types.conditionalExpression(
5705
- import_compiler31.types.memberExpression(forScopesIdentifier, import_compiler31.types.identifier("size")),
5837
+ import_compiler32.types.conditionalExpression(
5838
+ import_compiler32.types.memberExpression(forScopesIdentifier, import_compiler32.types.identifier("size")),
5706
5839
  forScopesIdentifier,
5707
- import_compiler31.types.identifier("undefined")
5708
- )
5840
+ import_compiler32.types.identifier("undefined")
5841
+ ),
5842
+ serializeReason
5709
5843
  );
5710
5844
  }
5711
5845
  flushInto(tag);
5712
5846
  writeHTMLResumeStatements(tagBody);
5713
5847
  const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
5714
- const forTagHTMLRuntime = isStateful ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5848
+ const forTagHTMLRuntime = sectionSources?.referenced ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5715
5849
  forTagArgs.push(
5716
- import_compiler31.types.arrowFunctionExpression(params, import_compiler31.types.blockStatement(bodyStatements))
5850
+ import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(bodyStatements))
5717
5851
  );
5718
- if (isStateful) {
5852
+ if (sectionSources?.referenced) {
5719
5853
  forTagArgs.push(
5720
5854
  getScopeIdIdentifier(tagSection),
5721
5855
  getScopeAccessorLiteral(nodeRef2)
5722
5856
  );
5723
5857
  if (onlyChildInParentOptimization) {
5724
- forTagArgs.push(import_compiler31.types.numericLiteral(1));
5858
+ forTagArgs.push(import_compiler32.types.numericLiteral(1));
5725
5859
  }
5726
5860
  }
5727
5861
  statements.push(
5728
- import_compiler31.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5862
+ import_compiler32.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5729
5863
  );
5730
5864
  for (const replacement of tag.replaceWithMultiple(statements)) {
5731
5865
  replacement.skip();
@@ -5770,7 +5904,7 @@ var for_default = {
5770
5904
  return callRuntime(
5771
5905
  forTypeToDOMRuntime(forType),
5772
5906
  getScopeAccessorLiteral(nodeRef2),
5773
- import_compiler31.types.identifier(bodySection.name)
5907
+ import_compiler32.types.identifier(bodySection.name)
5774
5908
  );
5775
5909
  };
5776
5910
  const params = node.body.params;
@@ -5801,7 +5935,7 @@ var for_default = {
5801
5935
  tagSection,
5802
5936
  referencedBindings,
5803
5937
  signal,
5804
- import_compiler31.types.arrayExpression(loopArgs)
5938
+ import_compiler32.types.arrayExpression(loopArgs)
5805
5939
  );
5806
5940
  tag.remove();
5807
5941
  }
@@ -5867,11 +6001,11 @@ var for_default = {
5867
6001
  ]
5868
6002
  };
5869
6003
  function buildForRuntimeCall(type, attrs2, params, statements) {
5870
- return import_compiler31.types.expressionStatement(
6004
+ return import_compiler32.types.expressionStatement(
5871
6005
  callRuntime(
5872
6006
  forTypeToRuntime(type),
5873
6007
  ...getBaseArgsInForTag(type, attrs2),
5874
- import_compiler31.types.arrowFunctionExpression(params, import_compiler31.types.blockStatement(statements))
6008
+ import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(statements))
5875
6009
  )
5876
6010
  );
5877
6011
  }
@@ -5947,8 +6081,8 @@ function getBaseArgsInForTag(type, attrs2) {
5947
6081
  case "to":
5948
6082
  return [
5949
6083
  attrs2.to,
5950
- attrs2.from || import_compiler31.types.numericLiteral(0),
5951
- attrs2.step || import_compiler31.types.numericLiteral(1)
6084
+ attrs2.from || import_compiler32.types.numericLiteral(0),
6085
+ attrs2.step || import_compiler32.types.numericLiteral(1)
5952
6086
  ];
5953
6087
  }
5954
6088
  }
@@ -5966,8 +6100,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5966
6100
  seen.add(attrTagMeta.name);
5967
6101
  if (attrTagMeta.dynamic) {
5968
6102
  statements.push(
5969
- import_compiler32.types.variableDeclaration("let", [
5970
- import_compiler32.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
6103
+ import_compiler33.types.variableDeclaration("let", [
6104
+ import_compiler33.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
5971
6105
  ])
5972
6106
  );
5973
6107
  properties.push(
@@ -6049,8 +6183,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
6049
6183
  seen.add(contentKey);
6050
6184
  const contentExpression = buildContent(tag.get("body"));
6051
6185
  if (contentExpression) {
6052
- const contentProp = import_compiler32.types.objectProperty(
6053
- import_compiler32.types.identifier(contentKey),
6186
+ const contentProp = import_compiler33.types.objectProperty(
6187
+ import_compiler33.types.identifier(contentKey),
6054
6188
  contentExpression
6055
6189
  );
6056
6190
  contentProps.add(contentProp);
@@ -6061,8 +6195,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
6061
6195
  for (let i = attributes.length; i--; ) {
6062
6196
  const attr2 = attributes[i];
6063
6197
  const { value } = attr2;
6064
- if (import_compiler32.types.isMarkoSpreadAttribute(attr2)) {
6065
- properties.push(import_compiler32.types.spreadElement(value));
6198
+ if (import_compiler33.types.isMarkoSpreadAttribute(attr2)) {
6199
+ properties.push(import_compiler33.types.spreadElement(value));
6066
6200
  } else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
6067
6201
  seen.add(attr2.name);
6068
6202
  properties.push(toObjectProperty(attr2.name, value));
@@ -6092,8 +6226,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6092
6226
  );
6093
6227
  if (attrTagMeta.repeated) {
6094
6228
  statements.push(
6095
- import_compiler32.types.expressionStatement(
6096
- import_compiler32.types.assignmentExpression(
6229
+ import_compiler33.types.expressionStatement(
6230
+ import_compiler33.types.assignmentExpression(
6097
6231
  "=",
6098
6232
  getAttrTagIdentifier(attrTagMeta),
6099
6233
  callRuntime(
@@ -6106,8 +6240,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6106
6240
  );
6107
6241
  } else {
6108
6242
  statements.push(
6109
- import_compiler32.types.expressionStatement(
6110
- import_compiler32.types.assignmentExpression(
6243
+ import_compiler33.types.expressionStatement(
6244
+ import_compiler33.types.assignmentExpression(
6111
6245
  "=",
6112
6246
  getAttrTagIdentifier(attrTagMeta),
6113
6247
  callRuntime(
@@ -6146,7 +6280,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6146
6280
  return index;
6147
6281
  }
6148
6282
  function propsToExpression(props) {
6149
- return props.length === 1 && import_compiler32.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler32.types.objectExpression(props);
6283
+ return props.length === 1 && import_compiler33.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler33.types.objectExpression(props);
6150
6284
  }
6151
6285
  function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
6152
6286
  const forTag = attrTags2[index];
@@ -6171,9 +6305,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
6171
6305
  function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
6172
6306
  const ifTag = attrTags2[index];
6173
6307
  const consequentStatements = [];
6174
- let ifStatement = import_compiler32.types.ifStatement(
6308
+ let ifStatement = import_compiler33.types.ifStatement(
6175
6309
  getConditionTestValue(ifTag),
6176
- import_compiler32.types.blockStatement(consequentStatements)
6310
+ import_compiler33.types.blockStatement(consequentStatements)
6177
6311
  );
6178
6312
  statements.push(ifStatement);
6179
6313
  addAllAttrTagsAsDynamic(
@@ -6200,14 +6334,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
6200
6334
  contentKey
6201
6335
  );
6202
6336
  if (testValue) {
6203
- ifStatement.alternate = ifStatement = import_compiler32.types.ifStatement(
6337
+ ifStatement.alternate = ifStatement = import_compiler33.types.ifStatement(
6204
6338
  testValue,
6205
- import_compiler32.types.blockStatement(alternateStatements)
6339
+ import_compiler33.types.blockStatement(alternateStatements)
6206
6340
  );
6207
6341
  nextIndex++;
6208
6342
  continue;
6209
6343
  } else {
6210
- ifStatement.alternate = import_compiler32.types.blockStatement(alternateStatements);
6344
+ ifStatement.alternate = import_compiler33.types.blockStatement(alternateStatements);
6211
6345
  break;
6212
6346
  }
6213
6347
  }
@@ -6264,10 +6398,10 @@ function buildContent(body) {
6264
6398
  const serialized = isSerializedSection(bodySection);
6265
6399
  return callRuntime(
6266
6400
  serialized ? "registerContent" : "createContent",
6267
- import_compiler32.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
6268
- import_compiler32.types.arrowFunctionExpression(
6401
+ import_compiler33.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
6402
+ import_compiler33.types.arrowFunctionExpression(
6269
6403
  body.node.params,
6270
- import_compiler32.types.blockStatement(body.node.body)
6404
+ import_compiler33.types.blockStatement(body.node.body)
6271
6405
  ),
6272
6406
  serialized ? getScopeIdIdentifier(
6273
6407
  getSection(
@@ -6278,7 +6412,7 @@ function buildContent(body) {
6278
6412
  ) : void 0
6279
6413
  );
6280
6414
  } else {
6281
- return import_compiler32.types.callExpression(import_compiler32.types.identifier(bodySection.name), [
6415
+ return import_compiler33.types.callExpression(import_compiler33.types.identifier(bodySection.name), [
6282
6416
  scopeIdentifier
6283
6417
  ]);
6284
6418
  }
@@ -6363,7 +6497,7 @@ var define_default = {
6363
6497
  };
6364
6498
 
6365
6499
  // src/translator/core/effect.ts
6366
- var import_compiler34 = require("@marko/compiler");
6500
+ var import_compiler35 = require("@marko/compiler");
6367
6501
  var import_babel_utils22 = require("@marko/compiler/babel-utils");
6368
6502
  var effect_default = {
6369
6503
  migrate: [
@@ -6379,8 +6513,8 @@ var effect_default = {
6379
6513
  fix() {
6380
6514
  const { node } = tag;
6381
6515
  tag.replaceWith(
6382
- import_compiler34.types.markoTag(
6383
- withPreviousLocation(import_compiler34.types.stringLiteral("script"), node.name),
6516
+ import_compiler35.types.markoTag(
6517
+ withPreviousLocation(import_compiler35.types.stringLiteral("script"), node.name),
6384
6518
  node.attributes,
6385
6519
  node.body,
6386
6520
  node.arguments,
@@ -6417,7 +6551,7 @@ var export_default = {
6417
6551
  };
6418
6552
 
6419
6553
  // src/translator/core/html-comment.ts
6420
- var import_compiler35 = require("@marko/compiler");
6554
+ var import_compiler36 = require("@marko/compiler");
6421
6555
  var import_babel_utils24 = require("@marko/compiler/babel-utils");
6422
6556
  var kCommentTagBinding = Symbol("comment tag binding");
6423
6557
  var kGetterId2 = Symbol("node getter id");
@@ -6430,7 +6564,7 @@ var html_comment_default = {
6430
6564
  let needsBinding = false;
6431
6565
  let needsGetter = false;
6432
6566
  if (tagVar) {
6433
- if (!import_compiler35.types.isIdentifier(tagVar)) {
6567
+ if (!import_compiler36.types.isIdentifier(tagVar)) {
6434
6568
  throw tag.get("var").buildCodeFrameError(
6435
6569
  "The `html-comment` tag variable cannot be destructured."
6436
6570
  );
@@ -6481,7 +6615,7 @@ var html_comment_default = {
6481
6615
  callRuntime(
6482
6616
  "nodeRef",
6483
6617
  getterId && getScopeIdIdentifier(getSection(tag)),
6484
- getterId && import_compiler35.types.stringLiteral(getterId)
6618
+ getterId && import_compiler36.types.stringLiteral(getterId)
6485
6619
  )
6486
6620
  );
6487
6621
  } else {
@@ -6494,12 +6628,12 @@ var html_comment_default = {
6494
6628
  );
6495
6629
  currentProgramPath.pushContainer(
6496
6630
  "body",
6497
- import_compiler35.types.variableDeclaration("const", [
6498
- import_compiler35.types.variableDeclarator(
6631
+ import_compiler36.types.variableDeclaration("const", [
6632
+ import_compiler36.types.variableDeclarator(
6499
6633
  getterFnIdentifier,
6500
6634
  callRuntime(
6501
6635
  "nodeRef",
6502
- import_compiler35.types.stringLiteral(getterId),
6636
+ import_compiler36.types.stringLiteral(getterId),
6503
6637
  getScopeAccessorLiteral(commentBinding)
6504
6638
  )
6505
6639
  )
@@ -6510,13 +6644,13 @@ var html_comment_default = {
6510
6644
  const referenceSection = getSection(reference);
6511
6645
  if (isInvokedFunction(reference)) {
6512
6646
  reference.parentPath.replaceWith(
6513
- import_compiler35.types.expressionStatement(
6647
+ import_compiler36.types.expressionStatement(
6514
6648
  createScopeReadExpression(referenceSection, commentBinding)
6515
6649
  )
6516
6650
  );
6517
6651
  } else if (getterFnIdentifier) {
6518
6652
  reference.replaceWith(
6519
- import_compiler35.types.callExpression(getterFnIdentifier, [
6653
+ import_compiler36.types.callExpression(getterFnIdentifier, [
6520
6654
  getScopeExpression(referenceSection, getSection(tag))
6521
6655
  ])
6522
6656
  );
@@ -6532,9 +6666,9 @@ var html_comment_default = {
6532
6666
  write2`<!--`;
6533
6667
  if (isOutputHTML()) {
6534
6668
  for (const child of tag.node.body.body) {
6535
- if (import_compiler35.types.isMarkoText(child)) {
6669
+ if (import_compiler36.types.isMarkoText(child)) {
6536
6670
  write2`${child.value}`;
6537
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6671
+ } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
6538
6672
  write2`${callRuntime("escapeXML", child.value)}`;
6539
6673
  }
6540
6674
  }
@@ -6543,10 +6677,10 @@ var html_comment_default = {
6543
6677
  const templateExpressions = [];
6544
6678
  let currentQuasi = "";
6545
6679
  for (const child of tag.node.body.body) {
6546
- if (import_compiler35.types.isMarkoText(child)) {
6680
+ if (import_compiler36.types.isMarkoText(child)) {
6547
6681
  currentQuasi += child.value;
6548
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6549
- templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6682
+ } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
6683
+ templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
6550
6684
  templateExpressions.push(child.value);
6551
6685
  currentQuasi = "";
6552
6686
  }
@@ -6554,20 +6688,20 @@ var html_comment_default = {
6554
6688
  if (templateExpressions.length === 0) {
6555
6689
  write2`${currentQuasi}`;
6556
6690
  } else {
6557
- templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6691
+ templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
6558
6692
  addStatement(
6559
6693
  "render",
6560
6694
  getSection(tag),
6561
6695
  tagExtra.referencedBindings,
6562
- import_compiler35.types.expressionStatement(
6696
+ import_compiler36.types.expressionStatement(
6563
6697
  callRuntime(
6564
6698
  "data",
6565
- import_compiler35.types.memberExpression(
6699
+ import_compiler36.types.memberExpression(
6566
6700
  scopeIdentifier,
6567
6701
  getScopeAccessorLiteral(commentBinding),
6568
6702
  true
6569
6703
  ),
6570
- import_compiler35.types.templateLiteral(templateQuasis, templateExpressions)
6704
+ import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
6571
6705
  )
6572
6706
  )
6573
6707
  );
@@ -6593,7 +6727,7 @@ var html_comment_default = {
6593
6727
  };
6594
6728
 
6595
6729
  // src/translator/core/html-script.ts
6596
- var import_compiler36 = require("@marko/compiler");
6730
+ var import_compiler37 = require("@marko/compiler");
6597
6731
  var import_babel_utils25 = require("@marko/compiler/babel-utils");
6598
6732
  var kGetterId3 = Symbol("node getter id");
6599
6733
  var html_script_default = {
@@ -6601,7 +6735,7 @@ var html_script_default = {
6601
6735
  (0, import_babel_utils25.assertNoArgs)(tag);
6602
6736
  (0, import_babel_utils25.assertNoParams)(tag);
6603
6737
  const { node } = tag;
6604
- if (node.var && !import_compiler36.types.isIdentifier(node.var)) {
6738
+ if (node.var && !import_compiler37.types.isIdentifier(node.var)) {
6605
6739
  throw tag.get("var").buildCodeFrameError(
6606
6740
  "Tag variables on native elements cannot be destructured."
6607
6741
  );
@@ -6614,7 +6748,7 @@ var html_script_default = {
6614
6748
  let spreadReferenceNodes;
6615
6749
  for (let i = attributes.length; i--; ) {
6616
6750
  const attr2 = attributes[i];
6617
- if (import_compiler36.types.isMarkoAttribute(attr2)) {
6751
+ if (import_compiler37.types.isMarkoAttribute(attr2)) {
6618
6752
  if (seen[attr2.name]) {
6619
6753
  dropReferences(attr2.value);
6620
6754
  continue;
@@ -6626,14 +6760,14 @@ var html_script_default = {
6626
6760
  } else if (!evaluate(attr2.value).confident) {
6627
6761
  hasDynamicAttributes = true;
6628
6762
  }
6629
- } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6763
+ } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6630
6764
  hasEventHandlers = true;
6631
6765
  hasDynamicAttributes = true;
6632
6766
  (attr2.value.extra ??= {}).isEffect = true;
6633
6767
  }
6634
6768
  if (spreadReferenceNodes) {
6635
6769
  spreadReferenceNodes.push(attr2.value);
6636
- } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6770
+ } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6637
6771
  spreadReferenceNodes = [attr2.value];
6638
6772
  }
6639
6773
  }
@@ -6643,10 +6777,10 @@ var html_script_default = {
6643
6777
  const bodyPlaceholderNodes = [];
6644
6778
  let hasBodyPlaceholders = false;
6645
6779
  for (const child of tag.node.body.body) {
6646
- if (import_compiler36.types.isMarkoPlaceholder(child)) {
6780
+ if (import_compiler37.types.isMarkoPlaceholder(child)) {
6647
6781
  bodyPlaceholderNodes.push(child.value);
6648
6782
  hasBodyPlaceholders = true;
6649
- } else if (!import_compiler36.types.isMarkoText(child)) {
6783
+ } else if (!import_compiler37.types.isMarkoText(child)) {
6650
6784
  throw tag.hub.buildError(
6651
6785
  child,
6652
6786
  "Invalid child. Only text is allowed inside an html-script."
@@ -6700,7 +6834,7 @@ var html_script_default = {
6700
6834
  callRuntime(
6701
6835
  "nodeRef",
6702
6836
  getterId && getScopeIdIdentifier(section),
6703
- getterId && import_compiler36.types.stringLiteral(getterId)
6837
+ getterId && import_compiler37.types.stringLiteral(getterId)
6704
6838
  )
6705
6839
  );
6706
6840
  } else {
@@ -6713,12 +6847,12 @@ var html_script_default = {
6713
6847
  );
6714
6848
  currentProgramPath.pushContainer(
6715
6849
  "body",
6716
- import_compiler36.types.variableDeclaration("const", [
6717
- import_compiler36.types.variableDeclarator(
6850
+ import_compiler37.types.variableDeclaration("const", [
6851
+ import_compiler37.types.variableDeclarator(
6718
6852
  getterFnIdentifier,
6719
6853
  callRuntime(
6720
6854
  "nodeRef",
6721
- import_compiler36.types.stringLiteral(getterId),
6855
+ import_compiler37.types.stringLiteral(getterId),
6722
6856
  getScopeAccessorLiteral(nodeRef2)
6723
6857
  )
6724
6858
  )
@@ -6729,13 +6863,13 @@ var html_script_default = {
6729
6863
  const referenceSection = getSection(reference);
6730
6864
  if (isInvokedFunction(reference)) {
6731
6865
  reference.parentPath.replaceWith(
6732
- import_compiler36.types.expressionStatement(
6866
+ import_compiler37.types.expressionStatement(
6733
6867
  createScopeReadExpression(referenceSection, nodeRef2)
6734
6868
  )
6735
6869
  );
6736
6870
  } else if (getterFnIdentifier) {
6737
6871
  reference.replaceWith(
6738
- import_compiler36.types.callExpression(getterFnIdentifier, [
6872
+ import_compiler37.types.callExpression(getterFnIdentifier, [
6739
6873
  getScopeExpression(referenceSection, getSection(tag))
6740
6874
  ])
6741
6875
  );
@@ -6768,10 +6902,10 @@ var html_script_default = {
6768
6902
  "render",
6769
6903
  section,
6770
6904
  valueReferences,
6771
- import_compiler36.types.expressionStatement(
6905
+ import_compiler37.types.expressionStatement(
6772
6906
  callRuntime(
6773
6907
  helper,
6774
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6908
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6775
6909
  value
6776
6910
  )
6777
6911
  )
@@ -6786,18 +6920,18 @@ var html_script_default = {
6786
6920
  if (isEventHandler(name2)) {
6787
6921
  addHTMLEffectCall(section, valueReferences);
6788
6922
  } else {
6789
- write2`${callRuntime("attr", import_compiler36.types.stringLiteral(name2), value)}`;
6923
+ write2`${callRuntime("attr", import_compiler37.types.stringLiteral(name2), value)}`;
6790
6924
  }
6791
6925
  } else if (isEventHandler(name2)) {
6792
6926
  addStatement(
6793
6927
  "effect",
6794
6928
  section,
6795
6929
  valueReferences,
6796
- import_compiler36.types.expressionStatement(
6930
+ import_compiler37.types.expressionStatement(
6797
6931
  callRuntime(
6798
6932
  "on",
6799
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6800
- import_compiler36.types.stringLiteral(getEventHandlerName(name2)),
6933
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6934
+ import_compiler37.types.stringLiteral(getEventHandlerName(name2)),
6801
6935
  value
6802
6936
  )
6803
6937
  )
@@ -6807,11 +6941,11 @@ var html_script_default = {
6807
6941
  "render",
6808
6942
  section,
6809
6943
  valueReferences,
6810
- import_compiler36.types.expressionStatement(
6944
+ import_compiler37.types.expressionStatement(
6811
6945
  callRuntime(
6812
6946
  "attr",
6813
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6814
- import_compiler36.types.stringLiteral(name2),
6947
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6948
+ import_compiler37.types.stringLiteral(name2),
6815
6949
  value
6816
6950
  )
6817
6951
  )
@@ -6824,9 +6958,9 @@ var html_script_default = {
6824
6958
  if (isHTML) {
6825
6959
  addHTMLEffectCall(section, tagExtra.referencedBindings);
6826
6960
  if (skipExpression) {
6827
- write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("script"))}`;
6961
+ write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler37.types.stringLiteral("script"))}`;
6828
6962
  } else {
6829
- write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler36.types.stringLiteral("script"))}`;
6963
+ write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler37.types.stringLiteral("script"))}`;
6830
6964
  }
6831
6965
  } else {
6832
6966
  if (skipExpression) {
@@ -6834,7 +6968,7 @@ var html_script_default = {
6834
6968
  "render",
6835
6969
  section,
6836
6970
  tagExtra.referencedBindings,
6837
- import_compiler36.types.expressionStatement(
6971
+ import_compiler37.types.expressionStatement(
6838
6972
  callRuntime(
6839
6973
  "partialAttrs",
6840
6974
  scopeIdentifier,
@@ -6849,7 +6983,7 @@ var html_script_default = {
6849
6983
  "render",
6850
6984
  section,
6851
6985
  tagExtra.referencedBindings,
6852
- import_compiler36.types.expressionStatement(
6986
+ import_compiler37.types.expressionStatement(
6853
6987
  callRuntime(
6854
6988
  "attrs",
6855
6989
  scopeIdentifier,
@@ -6863,7 +6997,7 @@ var html_script_default = {
6863
6997
  "effect",
6864
6998
  section,
6865
6999
  tagExtra.referencedBindings,
6866
- import_compiler36.types.expressionStatement(
7000
+ import_compiler37.types.expressionStatement(
6867
7001
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
6868
7002
  ),
6869
7003
  false
@@ -6874,9 +7008,9 @@ var html_script_default = {
6874
7008
  enter2(tag);
6875
7009
  if (isOutputHTML()) {
6876
7010
  for (const child of tag.node.body.body) {
6877
- if (import_compiler36.types.isMarkoText(child)) {
7011
+ if (import_compiler37.types.isMarkoText(child)) {
6878
7012
  write2`${child.value}`;
6879
- } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
7013
+ } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
6880
7014
  write2`${callRuntime("escapeScript", child.value)}`;
6881
7015
  }
6882
7016
  }
@@ -6886,11 +7020,11 @@ var html_script_default = {
6886
7020
  let currentQuasi = "";
6887
7021
  let referencePlaceholder;
6888
7022
  for (const child of tag.node.body.body) {
6889
- if (import_compiler36.types.isMarkoText(child)) {
7023
+ if (import_compiler37.types.isMarkoText(child)) {
6890
7024
  currentQuasi += child.value;
6891
- } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
7025
+ } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
6892
7026
  referencePlaceholder ||= child;
6893
- templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
7027
+ templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
6894
7028
  templateExpressions.push(child.value);
6895
7029
  currentQuasi = "";
6896
7030
  }
@@ -6898,16 +7032,16 @@ var html_script_default = {
6898
7032
  if (!referencePlaceholder) {
6899
7033
  write2`${currentQuasi}`;
6900
7034
  } else {
6901
- templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
7035
+ templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
6902
7036
  addStatement(
6903
7037
  "render",
6904
7038
  getSection(tag),
6905
7039
  referencePlaceholder.value.extra?.referencedBindings,
6906
- import_compiler36.types.expressionStatement(
7040
+ import_compiler37.types.expressionStatement(
6907
7041
  callRuntime(
6908
7042
  "textContent",
6909
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6910
- import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
7043
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7044
+ import_compiler37.types.templateLiteral(templateQuasis, templateExpressions)
6911
7045
  )
6912
7046
  )
6913
7047
  );
@@ -6946,11 +7080,11 @@ function getUsedAttrs2(tag) {
6946
7080
  for (let i = attributes.length; i--; ) {
6947
7081
  const attr2 = attributes[i];
6948
7082
  const { value } = attr2;
6949
- if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
7083
+ if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6950
7084
  if (!spreadProps) {
6951
7085
  spreadProps = [];
6952
7086
  }
6953
- spreadProps.push(import_compiler36.types.spreadElement(value));
7087
+ spreadProps.push(import_compiler37.types.spreadElement(value));
6954
7088
  } else if (!seen[attr2.name]) {
6955
7089
  seen[attr2.name] = attr2;
6956
7090
  if (spreadProps) {
@@ -6964,10 +7098,10 @@ function getUsedAttrs2(tag) {
6964
7098
  if (spreadProps) {
6965
7099
  spreadProps.reverse();
6966
7100
  for (const { name: name2 } of staticAttrs) {
6967
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler36.types.numericLiteral(1)));
7101
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler37.types.numericLiteral(1)));
6968
7102
  }
6969
7103
  if (skipProps) {
6970
- skipExpression = import_compiler36.types.objectExpression(skipProps);
7104
+ skipExpression = import_compiler37.types.objectExpression(skipProps);
6971
7105
  }
6972
7106
  spreadExpression = propsToExpression(spreadProps);
6973
7107
  }
@@ -6979,7 +7113,7 @@ function getUsedAttrs2(tag) {
6979
7113
  }
6980
7114
 
6981
7115
  // src/translator/core/html-style.ts
6982
- var import_compiler37 = require("@marko/compiler");
7116
+ var import_compiler38 = require("@marko/compiler");
6983
7117
  var import_babel_utils26 = require("@marko/compiler/babel-utils");
6984
7118
  var kGetterId4 = Symbol("node getter id");
6985
7119
  var html_style_default = {
@@ -6987,7 +7121,7 @@ var html_style_default = {
6987
7121
  (0, import_babel_utils26.assertNoArgs)(tag);
6988
7122
  (0, import_babel_utils26.assertNoParams)(tag);
6989
7123
  const { node } = tag;
6990
- if (node.var && !import_compiler37.types.isIdentifier(node.var)) {
7124
+ if (node.var && !import_compiler38.types.isIdentifier(node.var)) {
6991
7125
  throw tag.get("var").buildCodeFrameError(
6992
7126
  "Tag variables on native elements cannot be destructured."
6993
7127
  );
@@ -7000,7 +7134,7 @@ var html_style_default = {
7000
7134
  let spreadReferenceNodes;
7001
7135
  for (let i = attributes.length; i--; ) {
7002
7136
  const attr2 = attributes[i];
7003
- if (import_compiler37.types.isMarkoAttribute(attr2)) {
7137
+ if (import_compiler38.types.isMarkoAttribute(attr2)) {
7004
7138
  if (seen[attr2.name]) {
7005
7139
  dropReferences(attr2.value);
7006
7140
  continue;
@@ -7012,14 +7146,14 @@ var html_style_default = {
7012
7146
  } else if (!evaluate(attr2.value).confident) {
7013
7147
  hasDynamicAttributes = true;
7014
7148
  }
7015
- } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7149
+ } else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7016
7150
  hasEventHandlers = true;
7017
7151
  hasDynamicAttributes = true;
7018
7152
  (attr2.value.extra ??= {}).isEffect = true;
7019
7153
  }
7020
7154
  if (spreadReferenceNodes) {
7021
7155
  spreadReferenceNodes.push(attr2.value);
7022
- } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7156
+ } else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7023
7157
  spreadReferenceNodes = [attr2.value];
7024
7158
  }
7025
7159
  }
@@ -7029,10 +7163,10 @@ var html_style_default = {
7029
7163
  const bodyPlaceholderNodes = [];
7030
7164
  let hasBodyPlaceholders = false;
7031
7165
  for (const child of tag.node.body.body) {
7032
- if (import_compiler37.types.isMarkoPlaceholder(child)) {
7166
+ if (import_compiler38.types.isMarkoPlaceholder(child)) {
7033
7167
  bodyPlaceholderNodes.push(child.value);
7034
7168
  hasBodyPlaceholders = true;
7035
- } else if (!import_compiler37.types.isMarkoText(child)) {
7169
+ } else if (!import_compiler38.types.isMarkoText(child)) {
7036
7170
  throw tag.hub.buildError(
7037
7171
  child,
7038
7172
  "Invalid child. Only text is allowed inside an html-style."
@@ -7086,7 +7220,7 @@ var html_style_default = {
7086
7220
  callRuntime(
7087
7221
  "nodeRef",
7088
7222
  getterId && getScopeIdIdentifier(section),
7089
- getterId && import_compiler37.types.stringLiteral(getterId)
7223
+ getterId && import_compiler38.types.stringLiteral(getterId)
7090
7224
  )
7091
7225
  );
7092
7226
  } else {
@@ -7099,12 +7233,12 @@ var html_style_default = {
7099
7233
  );
7100
7234
  currentProgramPath.pushContainer(
7101
7235
  "body",
7102
- import_compiler37.types.variableDeclaration("const", [
7103
- import_compiler37.types.variableDeclarator(
7236
+ import_compiler38.types.variableDeclaration("const", [
7237
+ import_compiler38.types.variableDeclarator(
7104
7238
  getterFnIdentifier,
7105
7239
  callRuntime(
7106
7240
  "nodeRef",
7107
- import_compiler37.types.stringLiteral(getterId),
7241
+ import_compiler38.types.stringLiteral(getterId),
7108
7242
  getScopeAccessorLiteral(nodeRef2)
7109
7243
  )
7110
7244
  )
@@ -7115,13 +7249,13 @@ var html_style_default = {
7115
7249
  const referenceSection = getSection(reference);
7116
7250
  if (isInvokedFunction(reference)) {
7117
7251
  reference.parentPath.replaceWith(
7118
- import_compiler37.types.expressionStatement(
7252
+ import_compiler38.types.expressionStatement(
7119
7253
  createScopeReadExpression(referenceSection, nodeRef2)
7120
7254
  )
7121
7255
  );
7122
7256
  } else if (getterFnIdentifier) {
7123
7257
  reference.replaceWith(
7124
- import_compiler37.types.callExpression(getterFnIdentifier, [
7258
+ import_compiler38.types.callExpression(getterFnIdentifier, [
7125
7259
  getScopeExpression(referenceSection, getSection(tag))
7126
7260
  ])
7127
7261
  );
@@ -7154,10 +7288,10 @@ var html_style_default = {
7154
7288
  "render",
7155
7289
  section,
7156
7290
  valueReferences,
7157
- import_compiler37.types.expressionStatement(
7291
+ import_compiler38.types.expressionStatement(
7158
7292
  callRuntime(
7159
7293
  helper,
7160
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7294
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7161
7295
  value
7162
7296
  )
7163
7297
  )
@@ -7172,18 +7306,18 @@ var html_style_default = {
7172
7306
  if (isEventHandler(name2)) {
7173
7307
  addHTMLEffectCall(section, valueReferences);
7174
7308
  } else {
7175
- write2`${callRuntime("attr", import_compiler37.types.stringLiteral(name2), value)}`;
7309
+ write2`${callRuntime("attr", import_compiler38.types.stringLiteral(name2), value)}`;
7176
7310
  }
7177
7311
  } else if (isEventHandler(name2)) {
7178
7312
  addStatement(
7179
7313
  "effect",
7180
7314
  section,
7181
7315
  valueReferences,
7182
- import_compiler37.types.expressionStatement(
7316
+ import_compiler38.types.expressionStatement(
7183
7317
  callRuntime(
7184
7318
  "on",
7185
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7186
- import_compiler37.types.stringLiteral(getEventHandlerName(name2)),
7319
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7320
+ import_compiler38.types.stringLiteral(getEventHandlerName(name2)),
7187
7321
  value
7188
7322
  )
7189
7323
  )
@@ -7193,11 +7327,11 @@ var html_style_default = {
7193
7327
  "render",
7194
7328
  section,
7195
7329
  valueReferences,
7196
- import_compiler37.types.expressionStatement(
7330
+ import_compiler38.types.expressionStatement(
7197
7331
  callRuntime(
7198
7332
  "attr",
7199
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7200
- import_compiler37.types.stringLiteral(name2),
7333
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7334
+ import_compiler38.types.stringLiteral(name2),
7201
7335
  value
7202
7336
  )
7203
7337
  )
@@ -7210,9 +7344,9 @@ var html_style_default = {
7210
7344
  if (isHTML) {
7211
7345
  addHTMLEffectCall(section, tagExtra.referencedBindings);
7212
7346
  if (skipExpression) {
7213
- write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler37.types.stringLiteral("style"))}`;
7347
+ write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler38.types.stringLiteral("style"))}`;
7214
7348
  } else {
7215
- write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler37.types.stringLiteral("style"))}`;
7349
+ write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler38.types.stringLiteral("style"))}`;
7216
7350
  }
7217
7351
  } else {
7218
7352
  if (skipExpression) {
@@ -7220,7 +7354,7 @@ var html_style_default = {
7220
7354
  "render",
7221
7355
  section,
7222
7356
  tagExtra.referencedBindings,
7223
- import_compiler37.types.expressionStatement(
7357
+ import_compiler38.types.expressionStatement(
7224
7358
  callRuntime(
7225
7359
  "partialAttrs",
7226
7360
  scopeIdentifier,
@@ -7235,7 +7369,7 @@ var html_style_default = {
7235
7369
  "render",
7236
7370
  section,
7237
7371
  tagExtra.referencedBindings,
7238
- import_compiler37.types.expressionStatement(
7372
+ import_compiler38.types.expressionStatement(
7239
7373
  callRuntime(
7240
7374
  "attrs",
7241
7375
  scopeIdentifier,
@@ -7249,7 +7383,7 @@ var html_style_default = {
7249
7383
  "effect",
7250
7384
  section,
7251
7385
  tagExtra.referencedBindings,
7252
- import_compiler37.types.expressionStatement(
7386
+ import_compiler38.types.expressionStatement(
7253
7387
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
7254
7388
  ),
7255
7389
  false
@@ -7260,9 +7394,9 @@ var html_style_default = {
7260
7394
  enter2(tag);
7261
7395
  if (isOutputHTML()) {
7262
7396
  for (const child of tag.node.body.body) {
7263
- if (import_compiler37.types.isMarkoText(child)) {
7397
+ if (import_compiler38.types.isMarkoText(child)) {
7264
7398
  write2`${child.value}`;
7265
- } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
7399
+ } else if (import_compiler38.types.isMarkoPlaceholder(child)) {
7266
7400
  write2`${callRuntime("escapeStyle", child.value)}`;
7267
7401
  }
7268
7402
  }
@@ -7272,11 +7406,11 @@ var html_style_default = {
7272
7406
  let currentQuasi = "";
7273
7407
  let referencePlaceholder;
7274
7408
  for (const child of tag.node.body.body) {
7275
- if (import_compiler37.types.isMarkoText(child)) {
7409
+ if (import_compiler38.types.isMarkoText(child)) {
7276
7410
  currentQuasi += child.value;
7277
- } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
7411
+ } else if (import_compiler38.types.isMarkoPlaceholder(child)) {
7278
7412
  referencePlaceholder ||= child;
7279
- templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
7413
+ templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
7280
7414
  templateExpressions.push(child.value);
7281
7415
  currentQuasi = "";
7282
7416
  }
@@ -7284,16 +7418,16 @@ var html_style_default = {
7284
7418
  if (!referencePlaceholder) {
7285
7419
  write2`${currentQuasi}`;
7286
7420
  } else {
7287
- templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
7421
+ templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
7288
7422
  addStatement(
7289
7423
  "render",
7290
7424
  getSection(tag),
7291
7425
  referencePlaceholder.value.extra?.referencedBindings,
7292
- import_compiler37.types.expressionStatement(
7426
+ import_compiler38.types.expressionStatement(
7293
7427
  callRuntime(
7294
7428
  "textContent",
7295
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7296
- import_compiler37.types.templateLiteral(templateQuasis, templateExpressions)
7429
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7430
+ import_compiler38.types.templateLiteral(templateQuasis, templateExpressions)
7297
7431
  )
7298
7432
  )
7299
7433
  );
@@ -7327,11 +7461,11 @@ function getUsedAttrs3(tag) {
7327
7461
  for (let i = attributes.length; i--; ) {
7328
7462
  const attr2 = attributes[i];
7329
7463
  const { value } = attr2;
7330
- if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7464
+ if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7331
7465
  if (!spreadProps) {
7332
7466
  spreadProps = [];
7333
7467
  }
7334
- spreadProps.push(import_compiler37.types.spreadElement(value));
7468
+ spreadProps.push(import_compiler38.types.spreadElement(value));
7335
7469
  } else if (!seen[attr2.name]) {
7336
7470
  seen[attr2.name] = attr2;
7337
7471
  if (spreadProps) {
@@ -7345,10 +7479,10 @@ function getUsedAttrs3(tag) {
7345
7479
  if (spreadProps) {
7346
7480
  spreadProps.reverse();
7347
7481
  for (const { name: name2 } of staticAttrs) {
7348
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler37.types.numericLiteral(1)));
7482
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler38.types.numericLiteral(1)));
7349
7483
  }
7350
7484
  if (skipProps) {
7351
- skipExpression = import_compiler37.types.objectExpression(skipProps);
7485
+ skipExpression = import_compiler38.types.objectExpression(skipProps);
7352
7486
  }
7353
7487
  spreadExpression = propsToExpression(spreadProps);
7354
7488
  }
@@ -7360,7 +7494,7 @@ function getUsedAttrs3(tag) {
7360
7494
  }
7361
7495
 
7362
7496
  // src/translator/core/id.ts
7363
- var import_compiler38 = require("@marko/compiler");
7497
+ var import_compiler39 = require("@marko/compiler");
7364
7498
  var import_babel_utils27 = require("@marko/compiler/babel-utils");
7365
7499
  var id_default = {
7366
7500
  analyze(tag) {
@@ -7373,7 +7507,7 @@ var id_default = {
7373
7507
  if (!node.var) {
7374
7508
  throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
7375
7509
  }
7376
- if (!import_compiler38.types.isIdentifier(node.var)) {
7510
+ if (!import_compiler39.types.isIdentifier(node.var)) {
7377
7511
  throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
7378
7512
  }
7379
7513
  trackVarReferences(tag, 4 /* derived */);
@@ -7384,7 +7518,7 @@ var id_default = {
7384
7518
  const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
7385
7519
  if (isOutputHTML()) {
7386
7520
  tag.replaceWith(
7387
- import_compiler38.types.variableDeclaration("const", [import_compiler38.types.variableDeclarator(node.var, id)])
7521
+ import_compiler39.types.variableDeclaration("const", [import_compiler39.types.variableDeclarator(node.var, id)])
7388
7522
  );
7389
7523
  } else {
7390
7524
  const source = initValue(node.var.extra.binding);
@@ -7409,17 +7543,17 @@ var id_default = {
7409
7543
  };
7410
7544
 
7411
7545
  // src/translator/core/if.ts
7412
- var import_compiler40 = require("@marko/compiler");
7546
+ var import_compiler41 = require("@marko/compiler");
7413
7547
  var import_babel_utils28 = require("@marko/compiler/babel-utils");
7414
7548
 
7415
7549
  // src/translator/util/to-first-statement-or-block.ts
7416
- var import_compiler39 = require("@marko/compiler");
7550
+ var import_compiler40 = require("@marko/compiler");
7417
7551
  function toFirstStatementOrBlock(body) {
7418
7552
  if (Array.isArray(body)) {
7419
7553
  if (body.length === 1) {
7420
7554
  return body[0];
7421
7555
  }
7422
- return import_compiler39.types.blockStatement(body);
7556
+ return import_compiler40.types.blockStatement(body);
7423
7557
  }
7424
7558
  return body;
7425
7559
  }
@@ -7485,14 +7619,12 @@ var IfTag = {
7485
7619
  const [isLast, branches] = getBranches(tag, bodySection);
7486
7620
  const [rootTag] = branches[0];
7487
7621
  const rootExtra = rootTag.node.extra;
7488
- const isStateful = isStatefulReferences(rootExtra.referencedBindings);
7489
7622
  const singleNodeOptimization = rootExtra.singleNodeOptimization;
7490
- const hasStatefulClosures = bodySection && checkStatefulClosures(bodySection, true);
7491
- const hasHoists = bodySection && (bodySection.hoisted || bodySection.isHoistThrough || bodySection.referencedHoists);
7623
+ const branchSources = getSourcesForBranches(branches);
7624
+ const hasHoists = hasHoistsInBranches(branches);
7625
+ const serializeReason = hasHoists || branchSources?.all;
7492
7626
  if (bodySection) {
7493
- if (isStateful || hasStatefulClosures || hasHoists) {
7494
- setForceResumeScope(bodySection);
7495
- }
7627
+ serializeSectionIfNeeded(bodySection, serializeReason);
7496
7628
  flushInto(tag);
7497
7629
  writeHTMLResumeStatements(tagBody);
7498
7630
  }
@@ -7503,33 +7635,28 @@ var IfTag = {
7503
7635
  const ifScopeIdIdentifier = rootTag.scope.generateUidIdentifier("ifScopeId");
7504
7636
  const ifBranchIdentifier = rootTag.scope.generateUidIdentifier("ifBranch");
7505
7637
  let statement;
7506
- if (isStateful && onlyChildInParentOptimization) {
7638
+ if (branchSources?.referenced && onlyChildInParentOptimization) {
7507
7639
  getParentTag(rootTag).node.extra[kSerializeMarker] = false;
7508
7640
  }
7509
7641
  for (let i = branches.length; i--; ) {
7510
7642
  const [branchTag, branchBodySection] = branches[i];
7511
7643
  const bodyStatements = branchTag.node.body.body;
7512
7644
  if (branchBodySection) {
7513
- const branchHasStatefulClosures = checkStatefulClosures(
7514
- branchBodySection,
7515
- true
7516
- );
7517
- const branchHasHoists = branchBodySection.hoisted || branchBodySection.isHoistThrough || branchBodySection.referencedHoists;
7518
- if (isStateful) {
7645
+ if (branchSources?.referenced) {
7519
7646
  bodyStatements.push(
7520
- import_compiler40.types.expressionStatement(
7521
- import_compiler40.types.assignmentExpression(
7647
+ import_compiler41.types.expressionStatement(
7648
+ import_compiler41.types.assignmentExpression(
7522
7649
  "=",
7523
7650
  ifBranchIdentifier,
7524
- import_compiler40.types.numericLiteral(i)
7651
+ import_compiler41.types.numericLiteral(i)
7525
7652
  )
7526
7653
  )
7527
7654
  );
7528
7655
  }
7529
- if (isStateful || branchHasStatefulClosures || branchHasHoists) {
7656
+ if (serializeReason) {
7530
7657
  bodyStatements.push(
7531
- import_compiler40.types.expressionStatement(
7532
- import_compiler40.types.assignmentExpression(
7658
+ import_compiler41.types.expressionStatement(
7659
+ import_compiler41.types.assignmentExpression(
7533
7660
  "=",
7534
7661
  ifScopeIdIdentifier,
7535
7662
  getScopeIdIdentifier(branchBodySection)
@@ -7541,7 +7668,7 @@ var IfTag = {
7541
7668
  const [testAttr] = branchTag.node.attributes;
7542
7669
  const curStatement = toFirstStatementOrBlock(bodyStatements);
7543
7670
  if (testAttr) {
7544
- statement = import_compiler40.types.ifStatement(
7671
+ statement = import_compiler41.types.ifStatement(
7545
7672
  testAttr.value,
7546
7673
  curStatement,
7547
7674
  statement
@@ -7551,24 +7678,25 @@ var IfTag = {
7551
7678
  }
7552
7679
  branchTag.remove();
7553
7680
  }
7554
- if (isStateful || hasStatefulClosures || hasHoists) {
7555
- if (isStateful) {
7681
+ if (serializeReason) {
7682
+ if (branchSources?.referenced) {
7556
7683
  setSerializedProperty(
7557
7684
  section,
7558
7685
  getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
7559
- ifBranchIdentifier
7686
+ ifBranchIdentifier,
7687
+ branchSources.referenced
7560
7688
  );
7561
- const cbNode = import_compiler40.types.arrowFunctionExpression(
7689
+ const cbNode = import_compiler41.types.arrowFunctionExpression(
7562
7690
  [],
7563
- import_compiler40.types.blockStatement([statement])
7691
+ import_compiler41.types.blockStatement([statement])
7564
7692
  );
7565
- statement = import_compiler40.types.expressionStatement(
7693
+ statement = import_compiler41.types.expressionStatement(
7566
7694
  singleNodeOptimization ? callRuntime(
7567
7695
  "resumeSingleNodeConditional",
7568
7696
  cbNode,
7569
7697
  getScopeIdIdentifier(section),
7570
7698
  getScopeAccessorLiteral(nodeRef2),
7571
- onlyChildInParentOptimization && import_compiler40.types.numericLiteral(1)
7699
+ onlyChildInParentOptimization && import_compiler41.types.numericLiteral(1)
7572
7700
  ) : callRuntime(
7573
7701
  "resumeConditional",
7574
7702
  cbNode,
@@ -7579,18 +7707,19 @@ var IfTag = {
7579
7707
  }
7580
7708
  nextTag.insertBefore(statement);
7581
7709
  getHTMLSectionStatements(section).push(
7582
- import_compiler40.types.variableDeclaration(
7710
+ import_compiler41.types.variableDeclaration(
7583
7711
  "let",
7584
7712
  [
7585
- import_compiler40.types.variableDeclarator(ifScopeIdIdentifier),
7586
- isStateful && import_compiler40.types.variableDeclarator(ifBranchIdentifier)
7713
+ import_compiler41.types.variableDeclarator(ifScopeIdIdentifier),
7714
+ branchSources?.referenced && import_compiler41.types.variableDeclarator(ifBranchIdentifier)
7587
7715
  ].filter(Boolean)
7588
7716
  )
7589
7717
  );
7590
7718
  setSerializedProperty(
7591
7719
  section,
7592
7720
  getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
7593
- callRuntime("getScopeById", ifScopeIdIdentifier)
7721
+ callRuntime("getScopeById", ifScopeIdIdentifier),
7722
+ serializeReason
7594
7723
  );
7595
7724
  } else {
7596
7725
  nextTag.insertBefore(statement);
@@ -7623,25 +7752,25 @@ var IfTag = {
7623
7752
  const rootExtra = branches[0][0].node.extra;
7624
7753
  const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
7625
7754
  const rendererIdentifiers = [];
7626
- let expr = import_compiler40.types.numericLiteral(branches.length);
7755
+ let expr = import_compiler41.types.numericLiteral(branches.length);
7627
7756
  for (let i = branches.length; i--; ) {
7628
7757
  const [branchTag, branchBodySection] = branches[i];
7629
7758
  const [testAttr] = branchTag.node.attributes;
7630
- const consequent = import_compiler40.types.numericLiteral(branchBodySection ? i : -1);
7759
+ const consequent = import_compiler41.types.numericLiteral(branchBodySection ? i : -1);
7631
7760
  if (branchBodySection) {
7632
- rendererIdentifiers.push(import_compiler40.types.identifier(branchBodySection.name));
7761
+ rendererIdentifiers.push(import_compiler41.types.identifier(branchBodySection.name));
7633
7762
  setClosureSignalBuilder(branchTag, (closure, render) => {
7634
7763
  return callRuntime(
7635
7764
  "conditionalClosure",
7636
7765
  getScopeAccessorLiteral(closure),
7637
7766
  getScopeAccessorLiteral(nodeRef2),
7638
- import_compiler40.types.numericLiteral(i),
7767
+ import_compiler41.types.numericLiteral(i),
7639
7768
  render
7640
7769
  );
7641
7770
  });
7642
7771
  }
7643
7772
  branchTag.remove();
7644
- expr = testAttr ? import_compiler40.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7773
+ expr = testAttr ? import_compiler41.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7645
7774
  }
7646
7775
  const signal = getSignal(section, nodeRef2, "if");
7647
7776
  signal.build = () => {
@@ -7723,7 +7852,7 @@ function assertHasBody(tag) {
7723
7852
  function assertHasValueAttribute(tag) {
7724
7853
  const { node } = tag;
7725
7854
  const [valueAttr] = node.attributes;
7726
- if (!import_compiler40.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7855
+ if (!import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7727
7856
  throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
7728
7857
  }
7729
7858
  if (node.attributes.length > 1) {
@@ -7770,6 +7899,21 @@ function getBranches(tag, bodySection) {
7770
7899
  }
7771
7900
  return [isLast, branches];
7772
7901
  }
7902
+ function hasHoistsInBranches(branches) {
7903
+ for (const [, section] of branches) {
7904
+ if (section && isSectionWithHoists(section)) return true;
7905
+ }
7906
+ }
7907
+ function getSourcesForBranches(branches) {
7908
+ if (branches.length === 1) {
7909
+ return getDynamicSourcesForSection(branches[0][1]);
7910
+ }
7911
+ const branchSections = [];
7912
+ for (const [, branchSection] of branches) {
7913
+ branchSections.push(branchSection);
7914
+ }
7915
+ return getDynamicSourcesForSections(branchSections);
7916
+ }
7773
7917
  function isRoot(tag) {
7774
7918
  return isCoreTagName(tag, "if");
7775
7919
  }
@@ -7798,7 +7942,7 @@ var import_default = {
7798
7942
  };
7799
7943
 
7800
7944
  // src/translator/core/let.ts
7801
- var import_compiler41 = require("@marko/compiler");
7945
+ var import_compiler42 = require("@marko/compiler");
7802
7946
  var import_babel_utils30 = require("@marko/compiler/babel-utils");
7803
7947
  var let_default = {
7804
7948
  analyze(tag) {
@@ -7807,7 +7951,7 @@ var let_default = {
7807
7951
  let valueAttr;
7808
7952
  let valueChangeAttr;
7809
7953
  for (const attr2 of node.attributes) {
7810
- if (import_compiler41.types.isMarkoAttribute(attr2)) {
7954
+ if (import_compiler42.types.isMarkoAttribute(attr2)) {
7811
7955
  if (attr2.name === "value") {
7812
7956
  valueAttr = attr2;
7813
7957
  } else if (attr2.name === "valueChange") {
@@ -7835,7 +7979,7 @@ var let_default = {
7835
7979
  if (!tagVar) {
7836
7980
  throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
7837
7981
  }
7838
- if (!import_compiler41.types.isIdentifier(tagVar)) {
7982
+ if (!import_compiler42.types.isIdentifier(tagVar)) {
7839
7983
  throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
7840
7984
  }
7841
7985
  if (valueChangeAttr && (0, import_babel_utils30.computeNode)(valueChangeAttr.value)) {
@@ -7854,10 +7998,10 @@ var let_default = {
7854
7998
  const { node } = tag;
7855
7999
  const tagVar = node.var;
7856
8000
  const valueAttr = node.attributes.find(
7857
- (attr2) => import_compiler41.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
7858
- ) ?? import_compiler41.types.markoAttribute("value", import_compiler41.types.identifier("undefined"));
8001
+ (attr2) => import_compiler42.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
8002
+ ) ?? import_compiler42.types.markoAttribute("value", import_compiler42.types.identifier("undefined"));
7859
8003
  const valueChangeAttr = node.attributes.find(
7860
- (attr2) => import_compiler41.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
8004
+ (attr2) => import_compiler42.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
7861
8005
  );
7862
8006
  const section = getSection(tag);
7863
8007
  const binding = tagVar.extra.binding;
@@ -7870,7 +8014,7 @@ var let_default = {
7870
8014
  }
7871
8015
  signal.buildAssignment = (valueSection, value) => {
7872
8016
  const scope = getScopeExpression(valueSection, signal.section);
7873
- return import_compiler41.types.callExpression(signal.identifier, [scope, value]);
8017
+ return import_compiler42.types.callExpression(signal.identifier, [scope, value]);
7874
8018
  };
7875
8019
  } else {
7876
8020
  translateVar(tag, valueAttr.value, "let");
@@ -7878,7 +8022,9 @@ var let_default = {
7878
8022
  setSerializedProperty(
7879
8023
  section,
7880
8024
  getAccessorPrefix().TagVariableChange + getScopeAccessor(binding),
7881
- valueChangeAttr.value
8025
+ valueChangeAttr.value,
8026
+ true
8027
+ // TODO: could be based on if there are actually assignments.
7882
8028
  );
7883
8029
  }
7884
8030
  }
@@ -7899,7 +8045,7 @@ var let_default = {
7899
8045
  };
7900
8046
 
7901
8047
  // src/translator/core/lifecycle.ts
7902
- var import_compiler42 = require("@marko/compiler");
8048
+ var import_compiler43 = require("@marko/compiler");
7903
8049
  var import_babel_utils31 = require("@marko/compiler/babel-utils");
7904
8050
  var kRef = Symbol("lifecycle attrs reference");
7905
8051
  var lifecycle_default = {
@@ -7924,7 +8070,7 @@ var lifecycle_default = {
7924
8070
  );
7925
8071
  }
7926
8072
  for (const attr2 of node.attributes) {
7927
- if (import_compiler42.types.isMarkoSpreadAttribute(attr2)) {
8073
+ if (import_compiler43.types.isMarkoSpreadAttribute(attr2)) {
7928
8074
  throw tag.get("name").buildCodeFrameError(
7929
8075
  "The `lifecycle` tag does not support `...spread` attributes."
7930
8076
  );
@@ -7944,7 +8090,7 @@ var lifecycle_default = {
7944
8090
  if (isOutputDOM()) {
7945
8091
  const translatedAttrs = translateAttrs(tag);
7946
8092
  translatedAttrs.statements.push(
7947
- import_compiler42.types.expressionStatement(
8093
+ import_compiler43.types.expressionStatement(
7948
8094
  callRuntime(
7949
8095
  "lifecycle",
7950
8096
  scopeIdentifier,
@@ -7979,7 +8125,7 @@ var lifecycle_default = {
7979
8125
  };
7980
8126
 
7981
8127
  // src/translator/core/log.ts
7982
- var import_compiler43 = require("@marko/compiler");
8128
+ var import_compiler44 = require("@marko/compiler");
7983
8129
  var import_babel_utils32 = require("@marko/compiler/babel-utils");
7984
8130
  var log_default = {
7985
8131
  analyze(tag) {
@@ -7991,7 +8137,7 @@ var log_default = {
7991
8137
  if (!valueAttr) {
7992
8138
  throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
7993
8139
  }
7994
- if (tag.node.attributes.length > 1 || !import_compiler43.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
8140
+ if (tag.node.attributes.length > 1 || !import_compiler44.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
7995
8141
  throw tag.get("name").buildCodeFrameError(
7996
8142
  "The `log` tag only supports the `value` attribute."
7997
8143
  );
@@ -8003,9 +8149,9 @@ var log_default = {
8003
8149
  const [valueAttr] = tag.node.attributes;
8004
8150
  const { value } = valueAttr;
8005
8151
  const referencedBindings = value.extra?.referencedBindings;
8006
- const statement = import_compiler43.types.expressionStatement(
8007
- import_compiler43.types.callExpression(
8008
- import_compiler43.types.memberExpression(import_compiler43.types.identifier("console"), import_compiler43.types.identifier("log")),
8152
+ const statement = import_compiler44.types.expressionStatement(
8153
+ import_compiler44.types.callExpression(
8154
+ import_compiler44.types.memberExpression(import_compiler44.types.identifier("console"), import_compiler44.types.identifier("log")),
8009
8155
  [value]
8010
8156
  )
8011
8157
  );
@@ -8031,7 +8177,7 @@ var log_default = {
8031
8177
  };
8032
8178
 
8033
8179
  // src/translator/core/script.ts
8034
- var import_compiler44 = require("@marko/compiler");
8180
+ var import_compiler45 = require("@marko/compiler");
8035
8181
  var import_babel_utils33 = require("@marko/compiler/babel-utils");
8036
8182
  var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
8037
8183
  var script_default = {
@@ -8053,12 +8199,12 @@ var script_default = {
8053
8199
  const start = body[0]?.start;
8054
8200
  const end = body[body.length - 1]?.end;
8055
8201
  const bodyStatements = (0, import_babel_utils33.parseStatements)(tag.hub.file, code, start, end);
8056
- const valueFn = import_compiler44.types.arrowFunctionExpression(
8202
+ const valueFn = import_compiler45.types.arrowFunctionExpression(
8057
8203
  [],
8058
- import_compiler44.types.blockStatement(bodyStatements),
8204
+ import_compiler45.types.blockStatement(bodyStatements),
8059
8205
  traverseContains(bodyStatements, isAwaitExpression)
8060
8206
  );
8061
- node.attributes.push(import_compiler44.types.markoAttribute("value", valueFn));
8207
+ node.attributes.push(import_compiler45.types.markoAttribute("value", valueFn));
8062
8208
  node.body.body = [];
8063
8209
  }
8064
8210
  },
@@ -8107,28 +8253,28 @@ var script_default = {
8107
8253
  const referencedBindings = value.extra?.referencedBindings;
8108
8254
  if (isOutputDOM()) {
8109
8255
  const { value: value2 } = valueAttr;
8110
- const isFunction2 = import_compiler44.types.isFunctionExpression(value2) || import_compiler44.types.isArrowFunctionExpression(value2);
8256
+ const isFunction2 = import_compiler45.types.isFunctionExpression(value2) || import_compiler45.types.isArrowFunctionExpression(value2);
8111
8257
  let inlineBody = null;
8112
8258
  if (isFunction2 && !(value2.async || value2.generator)) {
8113
- if (import_compiler44.types.isBlockStatement(value2.body)) {
8259
+ if (import_compiler45.types.isBlockStatement(value2.body)) {
8114
8260
  let hasDeclaration = false;
8115
8261
  for (const child of value2.body.body) {
8116
- if (import_compiler44.types.isDeclaration(child)) {
8262
+ if (import_compiler45.types.isDeclaration(child)) {
8117
8263
  hasDeclaration = true;
8118
8264
  break;
8119
8265
  }
8120
8266
  }
8121
8267
  inlineBody = hasDeclaration ? value2.body : value2.body.body;
8122
8268
  } else {
8123
- inlineBody = import_compiler44.types.expressionStatement(value2.body);
8269
+ inlineBody = import_compiler45.types.expressionStatement(value2.body);
8124
8270
  }
8125
8271
  }
8126
8272
  addStatement(
8127
8273
  "effect",
8128
8274
  section,
8129
8275
  referencedBindings,
8130
- inlineBody || import_compiler44.types.expressionStatement(
8131
- import_compiler44.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
8276
+ inlineBody || import_compiler45.types.expressionStatement(
8277
+ import_compiler45.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
8132
8278
  )
8133
8279
  );
8134
8280
  } else {
@@ -8168,7 +8314,7 @@ function isAwaitExpression(node) {
8168
8314
  }
8169
8315
 
8170
8316
  // src/translator/core/server.ts
8171
- var import_compiler45 = require("@marko/compiler");
8317
+ var import_compiler46 = require("@marko/compiler");
8172
8318
  var import_babel_utils34 = require("@marko/compiler/babel-utils");
8173
8319
  var server_default = {
8174
8320
  parse(tag) {
@@ -8180,10 +8326,10 @@ var server_default = {
8180
8326
  const code = rawValue.replace(/^server\s*/, "").trim();
8181
8327
  const start = node.name.start + (rawValue.length - code.length);
8182
8328
  let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
8183
- if (body.length === 1 && import_compiler45.types.isBlockStatement(body[0])) {
8329
+ if (body.length === 1 && import_compiler46.types.isBlockStatement(body[0])) {
8184
8330
  body = body[0].body;
8185
8331
  }
8186
- tag.replaceWith(import_compiler45.types.markoScriptlet(body, true, "server"));
8332
+ tag.replaceWith(import_compiler46.types.markoScriptlet(body, true, "server"));
8187
8333
  },
8188
8334
  parseOptions: {
8189
8335
  statement: true,
@@ -8199,7 +8345,7 @@ var server_default = {
8199
8345
  };
8200
8346
 
8201
8347
  // src/translator/core/static.ts
8202
- var import_compiler46 = require("@marko/compiler");
8348
+ var import_compiler47 = require("@marko/compiler");
8203
8349
  var import_babel_utils35 = require("@marko/compiler/babel-utils");
8204
8350
  var static_default = {
8205
8351
  parse(tag) {
@@ -8211,10 +8357,10 @@ var static_default = {
8211
8357
  const code = rawValue.replace(/^static\s*/, "").trim();
8212
8358
  const start = node.name.start + (rawValue.length - code.length);
8213
8359
  let body = (0, import_babel_utils35.parseStatements)(file, code, start, start + code.length);
8214
- if (body.length === 1 && import_compiler46.types.isBlockStatement(body[0])) {
8360
+ if (body.length === 1 && import_compiler47.types.isBlockStatement(body[0])) {
8215
8361
  body = body[0].body;
8216
8362
  }
8217
- tag.replaceWith(import_compiler46.types.markoScriptlet(body, true));
8363
+ tag.replaceWith(import_compiler47.types.markoScriptlet(body, true));
8218
8364
  },
8219
8365
  parseOptions: {
8220
8366
  statement: true,
@@ -8230,7 +8376,7 @@ var static_default = {
8230
8376
  };
8231
8377
 
8232
8378
  // src/translator/core/style.ts
8233
- var import_compiler47 = require("@marko/compiler");
8379
+ var import_compiler48 = require("@marko/compiler");
8234
8380
  var import_babel_utils36 = require("@marko/compiler/babel-utils");
8235
8381
  var import_magic_string = __toESM(require("magic-string"));
8236
8382
  var import_path3 = __toESM(require("path"));
@@ -8308,21 +8454,21 @@ var style_default = {
8308
8454
  if (!node.var) {
8309
8455
  currentProgramPath.pushContainer(
8310
8456
  "body",
8311
- import_compiler47.types.importDeclaration([], import_compiler47.types.stringLiteral(importPath))
8457
+ import_compiler48.types.importDeclaration([], import_compiler48.types.stringLiteral(importPath))
8312
8458
  );
8313
- } else if (import_compiler47.types.isIdentifier(node.var)) {
8459
+ } else if (import_compiler48.types.isIdentifier(node.var)) {
8314
8460
  currentProgramPath.pushContainer(
8315
8461
  "body",
8316
- import_compiler47.types.importDeclaration(
8317
- [import_compiler47.types.importDefaultSpecifier(node.var)],
8318
- import_compiler47.types.stringLiteral(importPath)
8462
+ import_compiler48.types.importDeclaration(
8463
+ [import_compiler48.types.importDefaultSpecifier(node.var)],
8464
+ import_compiler48.types.stringLiteral(importPath)
8319
8465
  )
8320
8466
  );
8321
8467
  } else {
8322
8468
  currentProgramPath.pushContainer(
8323
8469
  "body",
8324
- import_compiler47.types.variableDeclaration("const", [
8325
- import_compiler47.types.variableDeclarator(
8470
+ import_compiler48.types.variableDeclaration("const", [
8471
+ import_compiler48.types.variableDeclarator(
8326
8472
  node.var,
8327
8473
  (0, import_babel_utils36.importDefault)(file, importPath, "style")
8328
8474
  )
@@ -8342,7 +8488,7 @@ var style_default = {
8342
8488
  };
8343
8489
 
8344
8490
  // src/translator/core/try.ts
8345
- var import_compiler48 = require("@marko/compiler");
8491
+ var import_compiler49 = require("@marko/compiler");
8346
8492
  var import_babel_utils37 = require("@marko/compiler/babel-utils");
8347
8493
  var kDOMBinding2 = Symbol("try tag dom binding");
8348
8494
  var try_default = {
@@ -8402,7 +8548,7 @@ var try_default = {
8402
8548
  writeHTMLResumeStatements(tagBody);
8403
8549
  tag.insertBefore(translatedAttrs.statements);
8404
8550
  tag.replaceWith(
8405
- import_compiler48.types.expressionStatement(
8551
+ import_compiler49.types.expressionStatement(
8406
8552
  callRuntime(
8407
8553
  "tryContent",
8408
8554
  getScopeIdIdentifier(section),
@@ -8444,7 +8590,7 @@ var try_default = {
8444
8590
  return callRuntime(
8445
8591
  "createTry",
8446
8592
  getScopeAccessorLiteral(nodeRef2),
8447
- import_compiler48.types.identifier(bodySection.name)
8593
+ import_compiler49.types.identifier(bodySection.name)
8448
8594
  );
8449
8595
  };
8450
8596
  if (translatedAttrs.statements.length) {
@@ -8457,7 +8603,7 @@ var try_default = {
8457
8603
  }
8458
8604
  currentProgramPath.pushContainer(
8459
8605
  "body",
8460
- import_compiler48.types.expressionStatement(callRuntime("enableCatch"))
8606
+ import_compiler49.types.expressionStatement(callRuntime("enableCatch"))
8461
8607
  );
8462
8608
  addValue(
8463
8609
  section,
@@ -8555,7 +8701,7 @@ var document_type_default = {
8555
8701
  };
8556
8702
 
8557
8703
  // src/translator/visitors/function.ts
8558
- var import_compiler49 = require("@marko/compiler");
8704
+ var import_compiler50 = require("@marko/compiler");
8559
8705
  var import_babel_utils38 = require("@marko/compiler/babel-utils");
8560
8706
  var functionIdsBySection = /* @__PURE__ */ new WeakMap();
8561
8707
  var function_default = {
@@ -8572,9 +8718,9 @@ var function_default = {
8572
8718
  }
8573
8719
  const { node } = fn;
8574
8720
  const extra = node.extra ??= {};
8575
- const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler49.types.toIdentifier(
8721
+ const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler50.types.toIdentifier(
8576
8722
  markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
8577
- ) : markoRoot.node.name : import_compiler49.types.isVariableDeclarator(fn.parent) && import_compiler49.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler49.types.isObjectMethod(node) && import_compiler49.types.isIdentifier(node.key) ? node.key.name : "anonymous");
8723
+ ) : markoRoot.node.name : import_compiler50.types.isVariableDeclarator(fn.parent) && import_compiler50.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler50.types.isObjectMethod(node) && import_compiler50.types.isIdentifier(node.key) ? node.key.name : "anonymous");
8578
8724
  const {
8579
8725
  markoOpts,
8580
8726
  opts: { filename }
@@ -8635,7 +8781,7 @@ var import_declaration_default = {
8635
8781
  };
8636
8782
 
8637
8783
  // src/translator/visitors/placeholder.ts
8638
- var import_compiler50 = require("@marko/compiler");
8784
+ var import_compiler51 = require("@marko/compiler");
8639
8785
  var kBinding = Symbol("placeholder node binding");
8640
8786
  var kSiblingText = Symbol("placeholder has sibling text");
8641
8787
  var placeholder_default = {
@@ -8669,13 +8815,13 @@ var placeholder_default = {
8669
8815
  const nodeBinding = extra[kBinding];
8670
8816
  const canWriteHTML = isHTML || confident && node.escape;
8671
8817
  const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
8672
- const isStateful = isStatefulReferences(referencedBindings);
8818
+ const serializeReason = getDynamicSourcesForReferences(referencedBindings);
8673
8819
  const siblingText = extra[kSiblingText];
8674
8820
  if (confident && canWriteHTML) {
8675
8821
  write2`${getHTMLRuntime()[method](computed)}`;
8676
8822
  } else {
8677
8823
  if (siblingText === 1 /* Before */) {
8678
- if (isHTML && isStateful) {
8824
+ if (isHTML && serializeReason) {
8679
8825
  write2`<!>`;
8680
8826
  }
8681
8827
  visit(placeholder, 37 /* Replace */);
@@ -8687,7 +8833,7 @@ var placeholder_default = {
8687
8833
  }
8688
8834
  if (isHTML) {
8689
8835
  write2`${callRuntime(method, value)}`;
8690
- if (isStateful) {
8836
+ if (serializeReason) {
8691
8837
  markNode(placeholder, nodeBinding);
8692
8838
  }
8693
8839
  } else {
@@ -8695,10 +8841,10 @@ var placeholder_default = {
8695
8841
  "render",
8696
8842
  getSection(placeholder),
8697
8843
  value.extra?.referencedBindings,
8698
- import_compiler50.types.expressionStatement(
8844
+ import_compiler51.types.expressionStatement(
8699
8845
  method === "data" ? callRuntime(
8700
8846
  "data",
8701
- import_compiler50.types.memberExpression(
8847
+ import_compiler51.types.memberExpression(
8702
8848
  scopeIdentifier,
8703
8849
  getScopeAccessorLiteral(nodeBinding),
8704
8850
  true
@@ -8735,7 +8881,7 @@ function analyzeSiblingText(placeholder) {
8735
8881
  break;
8736
8882
  }
8737
8883
  }
8738
- if (!prev.node && import_compiler50.types.isProgram(placeholder.parentPath)) {
8884
+ if (!prev.node && import_compiler51.types.isProgram(placeholder.parentPath)) {
8739
8885
  return placeholderExtra[kSiblingText] = 1 /* Before */;
8740
8886
  }
8741
8887
  let next = placeholder.getNextSibling();
@@ -8752,7 +8898,7 @@ function analyzeSiblingText(placeholder) {
8752
8898
  break;
8753
8899
  }
8754
8900
  }
8755
- if (!next.node && import_compiler50.types.isProgram(placeholder.parentPath)) {
8901
+ if (!next.node && import_compiler51.types.isProgram(placeholder.parentPath)) {
8756
8902
  return placeholderExtra[kSiblingText] = 2 /* After */;
8757
8903
  }
8758
8904
  return placeholderExtra[kSiblingText] = 0 /* None */;
@@ -8774,7 +8920,7 @@ function isVoid2(value) {
8774
8920
  }
8775
8921
 
8776
8922
  // src/translator/visitors/referenced-identifier.ts
8777
- var import_compiler51 = require("@marko/compiler");
8923
+ var import_compiler52 = require("@marko/compiler");
8778
8924
  var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
8779
8925
  var referenced_identifier_default = {
8780
8926
  migrate(identifier) {
@@ -8782,8 +8928,8 @@ var referenced_identifier_default = {
8782
8928
  if (identifier.scope.hasBinding(name2)) return;
8783
8929
  switch (name2) {
8784
8930
  case "out":
8785
- if (import_compiler51.types.isMemberExpression(identifier.parent) && import_compiler51.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
8786
- identifier.parentPath.replaceWith(import_compiler51.types.identifier("$global"));
8931
+ if (import_compiler52.types.isMemberExpression(identifier.parent) && import_compiler52.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
8932
+ identifier.parentPath.replaceWith(import_compiler52.types.identifier("$global"));
8787
8933
  } else {
8788
8934
  throw identifier.buildCodeFrameError(
8789
8935
  "Only `out.global` is supported for compatibility."
@@ -8810,24 +8956,24 @@ var referenced_identifier_default = {
8810
8956
  case "$global":
8811
8957
  if (isOutputHTML()) {
8812
8958
  identifier.replaceWith(
8813
- import_compiler51.types.callExpression(importRuntime("$global"), [])
8959
+ import_compiler52.types.callExpression(importRuntime("$global"), [])
8814
8960
  );
8815
8961
  } else {
8816
8962
  identifier.replaceWith(
8817
- import_compiler51.types.memberExpression(scopeIdentifier, import_compiler51.types.identifier("$global"))
8963
+ import_compiler52.types.memberExpression(scopeIdentifier, import_compiler52.types.identifier("$global"))
8818
8964
  );
8819
8965
  }
8820
8966
  break;
8821
8967
  case "$signal":
8822
8968
  if (isOutputHTML()) {
8823
8969
  identifier.replaceWith(
8824
- import_compiler51.types.callExpression(
8825
- import_compiler51.types.arrowFunctionExpression(
8970
+ import_compiler52.types.callExpression(
8971
+ import_compiler52.types.arrowFunctionExpression(
8826
8972
  [],
8827
- import_compiler51.types.blockStatement([
8828
- import_compiler51.types.throwStatement(
8829
- import_compiler51.types.newExpression(import_compiler51.types.identifier("Error"), [
8830
- import_compiler51.types.stringLiteral("Cannot use $signal in a server render.")
8973
+ import_compiler52.types.blockStatement([
8974
+ import_compiler52.types.throwStatement(
8975
+ import_compiler52.types.newExpression(import_compiler52.types.identifier("Error"), [
8976
+ import_compiler52.types.stringLiteral("Cannot use $signal in a server render.")
8831
8977
  ])
8832
8978
  )
8833
8979
  ])
@@ -8853,18 +8999,19 @@ var referenced_identifier_default = {
8853
8999
  "render",
8854
9000
  section,
8855
9001
  exprRoot.node.extra?.referencedBindings,
8856
- import_compiler51.types.expressionStatement(
8857
- import_compiler51.types.callExpression(importRuntime("resetAbortSignal"), [
9002
+ import_compiler52.types.expressionStatement(
9003
+ import_compiler52.types.callExpression(importRuntime("resetAbortSignal"), [
8858
9004
  scopeIdentifier,
8859
- import_compiler51.types.numericLiteral(exprId)
9005
+ import_compiler52.types.numericLiteral(exprId)
8860
9006
  ])
8861
- )
9007
+ ),
9008
+ false
8862
9009
  );
8863
9010
  }
8864
9011
  identifier.replaceWith(
8865
- import_compiler51.types.callExpression(importRuntime("getAbortSignal"), [
9012
+ import_compiler52.types.callExpression(importRuntime("getAbortSignal"), [
8866
9013
  scopeIdentifier,
8867
- import_compiler51.types.numericLiteral(exprId)
9014
+ import_compiler52.types.numericLiteral(exprId)
8868
9015
  ])
8869
9016
  );
8870
9017
  }
@@ -8904,11 +9051,11 @@ var scriptlet_default = {
8904
9051
  };
8905
9052
 
8906
9053
  // src/translator/visitors/tag/index.ts
8907
- var import_compiler55 = require("@marko/compiler");
9054
+ var import_compiler56 = require("@marko/compiler");
8908
9055
  var import_babel_utils43 = require("@marko/compiler/babel-utils");
8909
9056
 
8910
9057
  // src/translator/visitors/tag/attribute-tag.ts
8911
- var import_compiler52 = require("@marko/compiler");
9058
+ var import_compiler53 = require("@marko/compiler");
8912
9059
  var import_babel_utils40 = require("@marko/compiler/babel-utils");
8913
9060
  var attribute_tag_default = {
8914
9061
  analyze: {
@@ -8939,7 +9086,7 @@ var attribute_tag_default = {
8939
9086
  };
8940
9087
 
8941
9088
  // src/translator/visitors/tag/custom-tag.ts
8942
- var import_compiler53 = require("@marko/compiler");
9089
+ var import_compiler54 = require("@marko/compiler");
8943
9090
  var import_babel_utils41 = require("@marko/compiler/babel-utils");
8944
9091
  var import_path4 = __toESM(require("path"));
8945
9092
  var kChildScopeBinding = Symbol("custom tag child scope");
@@ -9021,9 +9168,9 @@ function translateHTML(tag) {
9021
9168
  let tagIdentifier;
9022
9169
  flushInto(tag);
9023
9170
  writeHTMLResumeStatements(tagBody);
9024
- if (import_compiler53.types.isStringLiteral(node.name)) {
9171
+ if (import_compiler54.types.isStringLiteral(node.name)) {
9025
9172
  const relativePath = getTagRelativePath(tag);
9026
- tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler53.types.identifier(getTemplateContentName()) : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
9173
+ tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler54.types.identifier(getTemplateContentName()) : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
9027
9174
  } else {
9028
9175
  tagIdentifier = node.name;
9029
9176
  }
@@ -9034,37 +9181,32 @@ function translateHTML(tag) {
9034
9181
  properties: [],
9035
9182
  statements: []
9036
9183
  };
9037
- let providesStatefulAttrs = false;
9038
- for (const expr of tagExtra[kChildAttrExprs]) {
9039
- if (isReferencedExtra(expr) && isStatefulReferences(expr.referencedBindings)) {
9040
- providesStatefulAttrs = true;
9041
- break;
9042
- }
9043
- }
9044
- if (providesStatefulAttrs || tagVar) {
9184
+ const serializeReason = !!tagVar || getDynamicSourcesForExtras(tagExtra[kChildAttrExprs]);
9185
+ if (serializeReason) {
9045
9186
  const childScopeBinding = tagExtra[kChildScopeBinding];
9046
9187
  const peekScopeId = tag.scope.generateUidIdentifier(
9047
9188
  childScopeBinding?.name
9048
9189
  );
9049
9190
  tag.insertBefore(
9050
- import_compiler53.types.variableDeclaration("const", [
9051
- import_compiler53.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
9191
+ import_compiler54.types.variableDeclaration("const", [
9192
+ import_compiler54.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
9052
9193
  ])
9053
9194
  );
9054
9195
  setSerializedProperty(
9055
9196
  section,
9056
9197
  getScopeAccessor(childScopeBinding),
9057
- callRuntime("writeExistingScope", peekScopeId)
9198
+ callRuntime("writeExistingScope", peekScopeId),
9199
+ serializeReason
9058
9200
  );
9059
9201
  if (tagVar) {
9060
9202
  statements.push(
9061
- import_compiler53.types.expressionStatement(
9203
+ import_compiler54.types.expressionStatement(
9062
9204
  callRuntime(
9063
9205
  "setTagVar",
9064
9206
  getScopeIdIdentifier(section),
9065
9207
  getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
9066
9208
  peekScopeId,
9067
- import_compiler53.types.stringLiteral(
9209
+ import_compiler54.types.stringLiteral(
9068
9210
  getResumeRegisterId(
9069
9211
  section,
9070
9212
  node.var.extra?.binding,
@@ -9084,8 +9226,8 @@ function translateHTML(tag) {
9084
9226
  const contentExpression = contentProp.value;
9085
9227
  contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
9086
9228
  const [contentPath] = tag.insertBefore(
9087
- import_compiler53.types.variableDeclaration("const", [
9088
- import_compiler53.types.variableDeclarator(
9229
+ import_compiler54.types.variableDeclaration("const", [
9230
+ import_compiler54.types.variableDeclarator(
9089
9231
  contentId,
9090
9232
  // TODO: only register if needed (child template analysis)
9091
9233
  contentExpression
@@ -9099,13 +9241,13 @@ function translateHTML(tag) {
9099
9241
  propsToExpression(properties)
9100
9242
  );
9101
9243
  if (tagVar) {
9102
- translateVar(tag, import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0)), "let");
9103
- renderTagExpr = import_compiler53.types.assignmentExpression("=", tagVar, renderTagExpr);
9244
+ translateVar(tag, import_compiler54.types.unaryExpression("void", import_compiler54.types.numericLiteral(0)), "let");
9245
+ renderTagExpr = import_compiler54.types.assignmentExpression("=", tagVar, renderTagExpr);
9104
9246
  }
9105
9247
  statements.push(
9106
- import_compiler53.types.ifStatement(
9248
+ import_compiler54.types.ifStatement(
9107
9249
  tagIdentifier,
9108
- import_compiler53.types.expressionStatement(renderTagExpr),
9250
+ import_compiler54.types.expressionStatement(renderTagExpr),
9109
9251
  contentId && callStatement(contentId)
9110
9252
  )
9111
9253
  );
@@ -9114,7 +9256,7 @@ function translateHTML(tag) {
9114
9256
  tag,
9115
9257
  callExpression(tagIdentifier, propsToExpression(properties))
9116
9258
  );
9117
- setForceResumeScope(section);
9259
+ serializeSectionIfNeeded(section, true);
9118
9260
  } else {
9119
9261
  statements.push(
9120
9262
  callStatement(tagIdentifier, propsToExpression(properties))
@@ -9131,7 +9273,7 @@ function translateDOM(tag) {
9131
9273
  const childScopeBinding = extra[kChildScopeBinding];
9132
9274
  const write2 = writeTo(tag);
9133
9275
  const { file } = tag.hub;
9134
- const tagName = import_compiler53.types.isIdentifier(node.name) ? node.name.name : import_compiler53.types.isStringLiteral(node.name) ? node.name.value : "tag";
9276
+ const tagName = import_compiler54.types.isIdentifier(node.name) ? node.name.name : import_compiler54.types.isStringLiteral(node.name) ? node.name.value : "tag";
9135
9277
  const relativePath = getTagRelativePath(tag);
9136
9278
  const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
9137
9279
  const childExports = childFile.ast.program.extra.domExports;
@@ -9163,7 +9305,7 @@ function translateDOM(tag) {
9163
9305
  );
9164
9306
  source.register = true;
9165
9307
  source.buildAssignment = (valueSection, value) => {
9166
- return import_compiler53.types.callExpression(importRuntime("tagVarSignalChange"), [
9308
+ return import_compiler54.types.callExpression(importRuntime("tagVarSignalChange"), [
9167
9309
  createScopeReadExpression(valueSection, childScopeBinding),
9168
9310
  value
9169
9311
  ]);
@@ -9172,7 +9314,7 @@ function translateDOM(tag) {
9172
9314
  "render",
9173
9315
  tagSection,
9174
9316
  void 0,
9175
- import_compiler53.types.expressionStatement(
9317
+ import_compiler54.types.expressionStatement(
9176
9318
  callRuntime(
9177
9319
  "setTagVar",
9178
9320
  scopeIdentifier,
@@ -9186,8 +9328,8 @@ function translateDOM(tag) {
9186
9328
  "render",
9187
9329
  tagSection,
9188
9330
  void 0,
9189
- import_compiler53.types.expressionStatement(
9190
- import_compiler53.types.callExpression(tagIdentifier, [
9331
+ import_compiler54.types.expressionStatement(
9332
+ import_compiler54.types.callExpression(tagIdentifier, [
9191
9333
  createScopeReadExpression(tagSection, childScopeBinding)
9192
9334
  ])
9193
9335
  )
@@ -9200,7 +9342,7 @@ function getTagRelativePath(tag) {
9200
9342
  hub: { file }
9201
9343
  } = tag;
9202
9344
  let relativePath;
9203
- if (import_compiler53.types.isStringLiteral(node.name)) {
9345
+ if (import_compiler54.types.isStringLiteral(node.name)) {
9204
9346
  const template = (0, import_babel_utils41.getTagTemplate)(tag);
9205
9347
  relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
9206
9348
  } else if (node.extra?.tagNameImported) {
@@ -9293,7 +9435,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
9293
9435
  let spreadReferenceNodes;
9294
9436
  for (let i = attributes.length; i--; ) {
9295
9437
  const attr2 = attributes[i];
9296
- if (import_compiler53.types.isMarkoAttribute(attr2)) {
9438
+ if (import_compiler54.types.isMarkoAttribute(attr2)) {
9297
9439
  if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
9298
9440
  dropReferences(attr2.value);
9299
9441
  continue;
@@ -9302,7 +9444,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
9302
9444
  }
9303
9445
  if (spreadReferenceNodes) {
9304
9446
  spreadReferenceNodes.push(attr2.value);
9305
- } else if (import_compiler53.types.isMarkoSpreadAttribute(attr2)) {
9447
+ } else if (import_compiler54.types.isMarkoSpreadAttribute(attr2)) {
9306
9448
  spreadReferenceNodes = [attr2.value];
9307
9449
  } else {
9308
9450
  rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
@@ -9327,7 +9469,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9327
9469
  // but we should probably ensure all other references are dropped in this case before we do that.
9328
9470
  tag.node.extra?.referencedBindings,
9329
9471
  identifierToSignal(tagInputIdentifier),
9330
- import_compiler53.types.isSpreadElement(arg) ? import_compiler53.types.memberExpression(arg.argument, import_compiler53.types.numericLiteral(0), true) : arg,
9472
+ import_compiler54.types.isSpreadElement(arg) ? import_compiler54.types.memberExpression(arg.argument, import_compiler54.types.numericLiteral(0), true) : arg,
9331
9473
  createScopeReadExpression(info.tagSection, info.childScopeBinding)
9332
9474
  );
9333
9475
  return;
@@ -9375,7 +9517,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9375
9517
  } else {
9376
9518
  attrTagCallsForTag.set(
9377
9519
  attrTagName,
9378
- translatedProps = import_compiler53.types.parenthesizedExpression(
9520
+ translatedProps = import_compiler54.types.parenthesizedExpression(
9379
9521
  callRuntime("attrTag", translatedProps)
9380
9522
  )
9381
9523
  );
@@ -9460,7 +9602,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9460
9602
  childAttrExports.id,
9461
9603
  `${importAlias}_${attrTagMeta.name}`
9462
9604
  );
9463
- decls.push(import_compiler53.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
9605
+ decls.push(import_compiler54.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
9464
9606
  addValue(
9465
9607
  info.tagSection,
9466
9608
  referencedBindings,
@@ -9470,7 +9612,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9470
9612
  );
9471
9613
  }
9472
9614
  addStatement("render", info.tagSection, referencedBindings, [
9473
- import_compiler53.types.variableDeclaration("let", decls),
9615
+ import_compiler54.types.variableDeclaration("let", decls),
9474
9616
  ...statements
9475
9617
  ]);
9476
9618
  }
@@ -9490,7 +9632,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9490
9632
  void 0,
9491
9633
  // TODO: pretty sure content needs to have the reference group of it's param defaults.
9492
9634
  identifierToSignal(contentExportIdentifier),
9493
- import_compiler53.types.callExpression(import_compiler53.types.identifier(bodySection.name), [scopeIdentifier]),
9635
+ import_compiler54.types.callExpression(import_compiler54.types.identifier(bodySection.name), [scopeIdentifier]),
9494
9636
  createScopeReadExpression(info.tagSection, info.childScopeBinding)
9495
9637
  );
9496
9638
  }
@@ -9500,7 +9642,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9500
9642
  let spreadProps;
9501
9643
  for (let i = attributes.length; i--; ) {
9502
9644
  const attr2 = attributes[i];
9503
- if (import_compiler53.types.isMarkoAttribute(attr2)) {
9645
+ if (import_compiler54.types.isMarkoAttribute(attr2)) {
9504
9646
  const childAttrExports = templateExport.props[attr2.name];
9505
9647
  if (!childAttrExports || seen.has(attr2.name)) continue;
9506
9648
  seen.add(attr2.name);
@@ -9510,9 +9652,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9510
9652
  }
9511
9653
  staticAttrs.push(attr2);
9512
9654
  } else if (spreadProps) {
9513
- spreadProps.push(import_compiler53.types.spreadElement(attr2.value));
9655
+ spreadProps.push(import_compiler54.types.spreadElement(attr2.value));
9514
9656
  } else {
9515
- spreadProps = [import_compiler53.types.spreadElement(attr2.value)];
9657
+ spreadProps = [import_compiler54.types.spreadElement(attr2.value)];
9516
9658
  }
9517
9659
  }
9518
9660
  for (const attr2 of staticAttrs.reverse()) {
@@ -9541,8 +9683,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9541
9683
  spreadProps.reverse();
9542
9684
  getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
9543
9685
  addStatement("render", info.tagSection, referencedBindings, [
9544
- import_compiler53.types.variableDeclaration("const", [
9545
- import_compiler53.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
9686
+ import_compiler54.types.variableDeclaration("const", [
9687
+ import_compiler54.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
9546
9688
  ])
9547
9689
  ]);
9548
9690
  }
@@ -9566,7 +9708,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9566
9708
  }
9567
9709
  function importOrSelfReferenceName(file, request, name2, nameHint) {
9568
9710
  if (isCircularRequest(file, request)) {
9569
- return import_compiler53.types.identifier(name2);
9711
+ return import_compiler54.types.identifier(name2);
9570
9712
  }
9571
9713
  return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
9572
9714
  }
@@ -9575,10 +9717,10 @@ function isCircularRequest(file, request) {
9575
9717
  return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
9576
9718
  }
9577
9719
  function callStatement(id, ...args) {
9578
- return import_compiler53.types.expressionStatement(callExpression(id, ...args));
9720
+ return import_compiler54.types.expressionStatement(callExpression(id, ...args));
9579
9721
  }
9580
9722
  function callExpression(id, ...args) {
9581
- return import_compiler53.types.callExpression(id, args.filter(Boolean));
9723
+ return import_compiler54.types.callExpression(id, args.filter(Boolean));
9582
9724
  }
9583
9725
  function identifierToSignal(identifier) {
9584
9726
  return {
@@ -9587,14 +9729,14 @@ function identifierToSignal(identifier) {
9587
9729
  };
9588
9730
  }
9589
9731
  function buildUndefined2() {
9590
- return import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0));
9732
+ return import_compiler54.types.unaryExpression("void", import_compiler54.types.numericLiteral(0));
9591
9733
  }
9592
9734
  function always() {
9593
9735
  return true;
9594
9736
  }
9595
9737
 
9596
9738
  // src/translator/visitors/tag/dynamic-tag.ts
9597
- var import_compiler54 = require("@marko/compiler");
9739
+ var import_compiler55 = require("@marko/compiler");
9598
9740
  var import_babel_utils42 = require("@marko/compiler/babel-utils");
9599
9741
  var kDOMBinding3 = Symbol("dynamic tag dom binding");
9600
9742
  var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
@@ -9650,7 +9792,7 @@ var dynamic_tag_default = {
9650
9792
  const isClassAPI = tagExtra.featureType === "class";
9651
9793
  const referencedBindings = tagExtra.referencedBindings;
9652
9794
  let tagExpression = node.name;
9653
- if (import_compiler54.types.isStringLiteral(tagExpression)) {
9795
+ if (import_compiler55.types.isStringLiteral(tagExpression)) {
9654
9796
  tagExpression = (0, import_babel_utils42.importDefault)(
9655
9797
  tag.hub.file,
9656
9798
  getTagRelativePath(tag),
@@ -9661,14 +9803,14 @@ var dynamic_tag_default = {
9661
9803
  if (isOutputHTML()) {
9662
9804
  currentProgramPath.pushContainer(
9663
9805
  "body",
9664
- import_compiler54.types.markoScriptlet(
9806
+ import_compiler55.types.markoScriptlet(
9665
9807
  [
9666
- import_compiler54.types.expressionStatement(
9667
- import_compiler54.types.callExpression(
9808
+ import_compiler55.types.expressionStatement(
9809
+ import_compiler55.types.callExpression(
9668
9810
  (0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
9669
9811
  [
9670
- import_compiler54.types.identifier(tagExpression.name),
9671
- import_compiler54.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
9812
+ import_compiler55.types.identifier(tagExpression.name),
9813
+ import_compiler55.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
9672
9814
  ]
9673
9815
  )
9674
9816
  )
@@ -9679,11 +9821,11 @@ var dynamic_tag_default = {
9679
9821
  } else {
9680
9822
  currentProgramPath.pushContainer(
9681
9823
  "body",
9682
- import_compiler54.types.expressionStatement(
9824
+ import_compiler55.types.expressionStatement(
9683
9825
  callRuntime(
9684
9826
  "register",
9685
- import_compiler54.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
9686
- import_compiler54.types.identifier(tagExpression.name)
9827
+ import_compiler55.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
9828
+ import_compiler55.types.identifier(tagExpression.name)
9687
9829
  )
9688
9830
  )
9689
9831
  );
@@ -9703,7 +9845,7 @@ var dynamic_tag_default = {
9703
9845
  hasMultipleArgs = true;
9704
9846
  args.push(propsToExpression(properties));
9705
9847
  } else {
9706
- hasMultipleArgs = node.arguments.length > 1 || import_compiler54.types.isSpreadElement(node.arguments[0]);
9848
+ hasMultipleArgs = node.arguments.length > 1 || import_compiler55.types.isSpreadElement(node.arguments[0]);
9707
9849
  }
9708
9850
  } else {
9709
9851
  const contentProp = getTranslatedBodyContentProperty(properties);
@@ -9719,7 +9861,7 @@ var dynamic_tag_default = {
9719
9861
  writeHTMLResumeStatements(tag.get("body"));
9720
9862
  if (node.var) {
9721
9863
  if (!hasMultipleArgs && args.length === 1) {
9722
- args.push(import_compiler54.types.unaryExpression("void", import_compiler54.types.numericLiteral(0)));
9864
+ args.push(import_compiler55.types.unaryExpression("void", import_compiler55.types.numericLiteral(0)));
9723
9865
  }
9724
9866
  }
9725
9867
  const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
@@ -9728,7 +9870,7 @@ var dynamic_tag_default = {
9728
9870
  getScopeIdIdentifier(section),
9729
9871
  getScopeAccessorLiteral(nodeRef2),
9730
9872
  tagExpression,
9731
- import_compiler54.types.arrayExpression(args)
9873
+ import_compiler55.types.arrayExpression(args)
9732
9874
  ) : callRuntime(
9733
9875
  "dynamicTagInput",
9734
9876
  getScopeIdIdentifier(section),
@@ -9737,8 +9879,8 @@ var dynamic_tag_default = {
9737
9879
  ...args
9738
9880
  );
9739
9881
  statements.push(
9740
- import_compiler54.types.variableDeclaration("const", [
9741
- import_compiler54.types.variableDeclarator(
9882
+ import_compiler55.types.variableDeclaration("const", [
9883
+ import_compiler55.types.variableDeclarator(
9742
9884
  dynamicScopeIdentifier,
9743
9885
  callRuntime("peekNextScope")
9744
9886
  )
@@ -9746,10 +9888,10 @@ var dynamic_tag_default = {
9746
9888
  );
9747
9889
  if (node.var) {
9748
9890
  statements.push(
9749
- import_compiler54.types.variableDeclaration("const", [
9750
- import_compiler54.types.variableDeclarator(node.var, dynamicTagExpr)
9891
+ import_compiler55.types.variableDeclaration("const", [
9892
+ import_compiler55.types.variableDeclarator(node.var, dynamicTagExpr)
9751
9893
  ]),
9752
- import_compiler54.types.expressionStatement(
9894
+ import_compiler55.types.expressionStatement(
9753
9895
  callRuntime(
9754
9896
  "setTagVar",
9755
9897
  getScopeIdIdentifier(section),
@@ -9757,7 +9899,7 @@ var dynamic_tag_default = {
9757
9899
  tag.node.extra[kChildOffsetScopeBinding2]
9758
9900
  ),
9759
9901
  dynamicScopeIdentifier,
9760
- import_compiler54.types.stringLiteral(
9902
+ import_compiler55.types.stringLiteral(
9761
9903
  getResumeRegisterId(
9762
9904
  section,
9763
9905
  node.var.extra?.binding,
@@ -9769,21 +9911,26 @@ var dynamic_tag_default = {
9769
9911
  )
9770
9912
  );
9771
9913
  } else {
9772
- statements.push(import_compiler54.types.expressionStatement(dynamicTagExpr));
9914
+ statements.push(import_compiler55.types.expressionStatement(dynamicTagExpr));
9915
+ }
9916
+ const serializeReason = isClassAPI || !!node.var || getDynamicSourcesForReferences(referencedBindings);
9917
+ if (serializeReason) {
9918
+ setSerializedProperty(
9919
+ section,
9920
+ getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
9921
+ callRuntime("writeExistingScope", dynamicScopeIdentifier),
9922
+ serializeReason
9923
+ );
9924
+ setSerializedProperty(
9925
+ section,
9926
+ getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
9927
+ callRuntime(
9928
+ "dynamicTagId",
9929
+ import_compiler55.types.isIdentifier(tagExpression) ? import_compiler55.types.identifier(tagExpression.name) : tagExpression
9930
+ ),
9931
+ serializeReason
9932
+ );
9773
9933
  }
9774
- setSerializedProperty(
9775
- section,
9776
- getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
9777
- callRuntime("writeExistingScope", dynamicScopeIdentifier)
9778
- );
9779
- setSerializedProperty(
9780
- section,
9781
- getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
9782
- callRuntime(
9783
- "dynamicTagId",
9784
- import_compiler54.types.isIdentifier(tagExpression) ? import_compiler54.types.identifier(tagExpression.name) : tagExpression
9785
- )
9786
- );
9787
9934
  for (const replacement of tag.replaceWithMultiple(statements)) {
9788
9935
  replacement.skip();
9789
9936
  }
@@ -9799,10 +9946,10 @@ var dynamic_tag_default = {
9799
9946
  );
9800
9947
  tagVarSignal.register = true;
9801
9948
  tagVarSignal.buildAssignment = (valueSection, value) => {
9802
- return import_compiler54.types.callExpression(importRuntime("tagVarSignalChange"), [
9803
- import_compiler54.types.memberExpression(
9949
+ return import_compiler55.types.callExpression(importRuntime("tagVarSignalChange"), [
9950
+ import_compiler55.types.memberExpression(
9804
9951
  getScopeExpression(tagVarSignal.section, valueSection),
9805
- import_compiler54.types.stringLiteral(
9952
+ import_compiler55.types.stringLiteral(
9806
9953
  getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
9807
9954
  ),
9808
9955
  true
@@ -9815,19 +9962,19 @@ var dynamic_tag_default = {
9815
9962
  return callRuntime(
9816
9963
  "dynamicTag",
9817
9964
  getScopeAccessorLiteral(nodeRef2),
9818
- bodySection && import_compiler54.types.identifier(bodySection.name),
9819
- tagVarSignal ? import_compiler54.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
9820
- hasMultipleArgs && import_compiler54.types.numericLiteral(1)
9965
+ bodySection && import_compiler55.types.identifier(bodySection.name),
9966
+ tagVarSignal ? import_compiler55.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
9967
+ hasMultipleArgs && import_compiler55.types.numericLiteral(1)
9821
9968
  );
9822
9969
  };
9823
9970
  if (args.length) {
9824
- const argsOrInput = hasMultipleArgs ? import_compiler54.types.arrayExpression(args) : args[0];
9825
- if (!import_compiler54.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
9971
+ const argsOrInput = hasMultipleArgs ? import_compiler55.types.arrayExpression(args) : args[0];
9972
+ if (!import_compiler55.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
9826
9973
  signal.extraArgs = [
9827
- import_compiler54.types.arrowFunctionExpression(
9974
+ import_compiler55.types.arrowFunctionExpression(
9828
9975
  [],
9829
- statements.length ? import_compiler54.types.blockStatement(
9830
- statements.concat(import_compiler54.types.returnStatement(argsOrInput))
9976
+ statements.length ? import_compiler55.types.blockStatement(
9977
+ statements.concat(import_compiler55.types.returnStatement(argsOrInput))
9831
9978
  ) : argsOrInput
9832
9979
  )
9833
9980
  ];
@@ -9850,16 +9997,16 @@ var tag_default = {
9850
9997
  const { node } = tag;
9851
9998
  const { name: name2, attributes } = tag.node;
9852
9999
  let crawl = false;
9853
- if (import_compiler55.types.isStringLiteral(name2)) {
10000
+ if (import_compiler56.types.isStringLiteral(name2)) {
9854
10001
  const tagName = name2.value;
9855
10002
  if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
9856
- node.name = withPreviousLocation(import_compiler55.types.identifier(tagName), name2);
10003
+ node.name = withPreviousLocation(import_compiler56.types.identifier(tagName), name2);
9857
10004
  crawl = true;
9858
10005
  }
9859
10006
  }
9860
10007
  for (let i = 0; i < attributes.length; i++) {
9861
10008
  const attr2 = attributes[i];
9862
- if (import_compiler55.types.isMarkoAttribute(attr2) && attr2.bound) {
10009
+ if (import_compiler56.types.isMarkoAttribute(attr2) && attr2.bound) {
9863
10010
  attr2.bound = false;
9864
10011
  attributes.splice(++i, 0, getChangeHandler(tag, attr2));
9865
10012
  crawl = true;
@@ -9935,8 +10082,8 @@ var tag_default = {
9935
10082
  if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
9936
10083
  const tagNameId = tag.scope.generateUidIdentifier("tagName");
9937
10084
  const [tagNameVarPath] = tag.insertBefore(
9938
- import_compiler55.types.variableDeclaration("const", [
9939
- import_compiler55.types.variableDeclarator(tagNameId, tag.node.name)
10085
+ import_compiler56.types.variableDeclaration("const", [
10086
+ import_compiler56.types.variableDeclarator(tagNameId, tag.node.name)
9940
10087
  ])
9941
10088
  );
9942
10089
  tagNameVarPath.skip();
@@ -9983,16 +10130,16 @@ var tag_default = {
9983
10130
  function getChangeHandler(tag, attr2) {
9984
10131
  const attrName = attr2.name;
9985
10132
  const changeAttrName = attrName + "Change";
9986
- if (import_compiler55.types.isIdentifier(attr2.value)) {
10133
+ if (import_compiler56.types.isIdentifier(attr2.value)) {
9987
10134
  const binding = tag.scope.getBinding(attr2.value.name);
9988
10135
  if (!binding)
9989
- return import_compiler55.types.markoAttribute(
10136
+ return import_compiler56.types.markoAttribute(
9990
10137
  changeAttrName,
9991
10138
  buildChangeHandlerFunction(attr2.value)
9992
10139
  );
9993
10140
  const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
9994
10141
  if (!existingChangedAttr) {
9995
- const changeHandlerAttr = import_compiler55.types.markoAttribute(
10142
+ const changeHandlerAttr = import_compiler56.types.markoAttribute(
9996
10143
  changeAttrName,
9997
10144
  buildChangeHandlerFunction(attr2.value)
9998
10145
  );
@@ -10000,10 +10147,10 @@ function getChangeHandler(tag, attr2) {
10000
10147
  return changeHandlerAttr;
10001
10148
  }
10002
10149
  if (existingChangedAttr.type === "Identifier") {
10003
- return import_compiler55.types.markoAttribute(
10150
+ return import_compiler56.types.markoAttribute(
10004
10151
  changeAttrName,
10005
10152
  withPreviousLocation(
10006
- import_compiler55.types.identifier(existingChangedAttr.name),
10153
+ import_compiler56.types.identifier(existingChangedAttr.name),
10007
10154
  attr2.value
10008
10155
  )
10009
10156
  );
@@ -10013,37 +10160,37 @@ function getChangeHandler(tag, attr2) {
10013
10160
  throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
10014
10161
  }
10015
10162
  const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
10016
- const changeHandlerConst = import_compiler55.types.markoTag(
10017
- import_compiler55.types.stringLiteral("const"),
10018
- [import_compiler55.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
10019
- import_compiler55.types.markoTagBody([]),
10163
+ const changeHandlerConst = import_compiler56.types.markoTag(
10164
+ import_compiler56.types.stringLiteral("const"),
10165
+ [import_compiler56.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
10166
+ import_compiler56.types.markoTagBody([]),
10020
10167
  null,
10021
- import_compiler55.types.identifier(changeHandlerId)
10168
+ import_compiler56.types.identifier(changeHandlerId)
10022
10169
  );
10023
10170
  BINDING_CHANGE_HANDLER.set(
10024
10171
  binding.identifier,
10025
- existingChangedAttr.value = import_compiler55.types.identifier(changeHandlerId)
10172
+ existingChangedAttr.value = import_compiler56.types.identifier(changeHandlerId)
10026
10173
  );
10027
10174
  if (markoRoot.isMarkoTag()) {
10028
10175
  markoRoot.insertAfter(changeHandlerConst);
10029
10176
  } else {
10030
10177
  markoRoot.unshiftContainer("body", changeHandlerConst);
10031
10178
  }
10032
- return import_compiler55.types.markoAttribute(
10179
+ return import_compiler56.types.markoAttribute(
10033
10180
  changeAttrName,
10034
- withPreviousLocation(import_compiler55.types.identifier(changeHandlerId), attr2.value)
10181
+ withPreviousLocation(import_compiler56.types.identifier(changeHandlerId), attr2.value)
10035
10182
  );
10036
- } else if (import_compiler55.types.isMemberExpression(attr2.value)) {
10183
+ } else if (import_compiler56.types.isMemberExpression(attr2.value)) {
10037
10184
  const prop = attr2.value.property;
10038
- if (!import_compiler55.types.isPrivateName(attr2.value.property)) {
10039
- return import_compiler55.types.markoAttribute(
10185
+ if (!import_compiler56.types.isPrivateName(attr2.value.property)) {
10186
+ return import_compiler56.types.markoAttribute(
10040
10187
  changeAttrName,
10041
- import_compiler55.types.memberExpression(
10042
- import_compiler55.types.cloneNode(attr2.value.object),
10043
- prop.type === "Identifier" ? withPreviousLocation(import_compiler55.types.identifier(prop.name + "Change"), prop) : import_compiler55.types.binaryExpression(
10188
+ import_compiler56.types.memberExpression(
10189
+ import_compiler56.types.cloneNode(attr2.value.object),
10190
+ prop.type === "Identifier" ? withPreviousLocation(import_compiler56.types.identifier(prop.name + "Change"), prop) : import_compiler56.types.binaryExpression(
10044
10191
  "+",
10045
- import_compiler55.types.cloneNode(prop),
10046
- import_compiler55.types.stringLiteral("Change")
10192
+ import_compiler56.types.cloneNode(prop),
10193
+ import_compiler56.types.stringLiteral("Change")
10047
10194
  ),
10048
10195
  prop.type !== "Identifier"
10049
10196
  )
@@ -10057,14 +10204,14 @@ function getChangeHandler(tag, attr2) {
10057
10204
  }
10058
10205
  function buildChangeHandlerFunction(id) {
10059
10206
  const newId = "_new_" + id.name;
10060
- return import_compiler55.types.arrowFunctionExpression(
10061
- [withPreviousLocation(import_compiler55.types.identifier(newId), id)],
10062
- import_compiler55.types.blockStatement([
10063
- import_compiler55.types.expressionStatement(
10064
- import_compiler55.types.assignmentExpression(
10207
+ return import_compiler56.types.arrowFunctionExpression(
10208
+ [withPreviousLocation(import_compiler56.types.identifier(newId), id)],
10209
+ import_compiler56.types.blockStatement([
10210
+ import_compiler56.types.expressionStatement(
10211
+ import_compiler56.types.assignmentExpression(
10065
10212
  "=",
10066
- withPreviousLocation(import_compiler55.types.identifier(id.name), id),
10067
- withPreviousLocation(import_compiler55.types.identifier(newId), id)
10213
+ withPreviousLocation(import_compiler56.types.identifier(id.name), id),
10214
+ withPreviousLocation(import_compiler56.types.identifier(newId), id)
10068
10215
  )
10069
10216
  )
10070
10217
  ])
@@ -10072,7 +10219,7 @@ function buildChangeHandlerFunction(id) {
10072
10219
  }
10073
10220
 
10074
10221
  // src/translator/visitors/text.ts
10075
- var import_compiler56 = require("@marko/compiler");
10222
+ var import_compiler57 = require("@marko/compiler");
10076
10223
  var text_default = {
10077
10224
  translate: {
10078
10225
  exit(text) {