marko 6.0.0-next.3.66 → 6.0.0-next.3.68

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.
@@ -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,13 +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),
2411
+ import_compiler18.types.numericLiteral(id),
2258
2412
  getSignalFn(
2259
2413
  signal,
2260
2414
  [scopeIdentifier],
2261
2415
  signal.renderReferencedBindings
2262
2416
  ),
2263
- scopeOffset || referencedBindings.length > 2 ? import_compiler17.types.numericLiteral(referencedBindings.length - 1) : void 0,
2417
+ scopeOffset || referencedBindings.length > 2 ? import_compiler18.types.numericLiteral(referencedBindings.length - 1) : void 0,
2264
2418
  scopeOffset && getScopeAccessorLiteral(scopeOffset)
2265
2419
  );
2266
2420
  };
@@ -2268,14 +2422,14 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
2268
2422
  signal.build = () => {
2269
2423
  const render = getSignalFn(signal, [
2270
2424
  scopeIdentifier,
2271
- import_compiler17.types.identifier(referencedBindings.name)
2425
+ import_compiler18.types.identifier(referencedBindings.name)
2272
2426
  ]);
2273
2427
  const closureSignalBuilder = getClosureSignalBuilder(section);
2274
2428
  return !closureSignalBuilder || isDynamicClosure(section, referencedBindings) ? callRuntime(
2275
2429
  "dynamicClosureRead",
2276
2430
  getScopeAccessorLiteral(referencedBindings),
2277
2431
  render,
2278
- isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler17.types.arrowFunctionExpression(
2432
+ isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler18.types.arrowFunctionExpression(
2279
2433
  [scopeIdentifier],
2280
2434
  getScopeExpression(section, referencedBindings.section)
2281
2435
  )
@@ -2291,7 +2445,7 @@ function initValue(binding, runtimeHelper = "value") {
2291
2445
  signal.build = () => {
2292
2446
  const fn = getSignalFn(signal, [
2293
2447
  scopeIdentifier,
2294
- import_compiler17.types.identifier(binding.name)
2448
+ import_compiler18.types.identifier(binding.name)
2295
2449
  ]);
2296
2450
  const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 2 /* input */);
2297
2451
  const isNakedAlias = binding.upstreamAlias && !binding.property;
@@ -2326,8 +2480,8 @@ function getSignalFn(signal, params, referencedBindings) {
2326
2480
  for (const alias of binding.aliases) {
2327
2481
  const aliasSignal = getSignal(alias.section, alias);
2328
2482
  signal.render.push(
2329
- import_compiler17.types.expressionStatement(
2330
- import_compiler17.types.callExpression(aliasSignal.identifier, [
2483
+ import_compiler18.types.expressionStatement(
2484
+ import_compiler18.types.callExpression(aliasSignal.identifier, [
2331
2485
  scopeIdentifier2,
2332
2486
  valueIdentifier,
2333
2487
  ...getTranslatedExtraArgs(aliasSignal)
@@ -2338,8 +2492,8 @@ function getSignalFn(signal, params, referencedBindings) {
2338
2492
  for (const [key, alias] of binding.propertyAliases) {
2339
2493
  const aliasSignal = getSignal(alias.section, alias);
2340
2494
  signal.render.push(
2341
- import_compiler17.types.expressionStatement(
2342
- import_compiler17.types.callExpression(aliasSignal.identifier, [
2495
+ import_compiler18.types.expressionStatement(
2496
+ import_compiler18.types.callExpression(aliasSignal.identifier, [
2343
2497
  scopeIdentifier2,
2344
2498
  toMemberExpression(valueIdentifier, key, binding.nullable),
2345
2499
  ...getTranslatedExtraArgs(aliasSignal)
@@ -2350,8 +2504,8 @@ function getSignalFn(signal, params, referencedBindings) {
2350
2504
  }
2351
2505
  for (const value of signal.values) {
2352
2506
  signal.render.push(
2353
- import_compiler17.types.expressionStatement(
2354
- import_compiler17.types.callExpression(value.signal.identifier, [
2507
+ import_compiler18.types.expressionStatement(
2508
+ import_compiler18.types.callExpression(value.signal.identifier, [
2355
2509
  value.scope,
2356
2510
  value.value,
2357
2511
  ...getTranslatedExtraArgs(value.signal)
@@ -2361,14 +2515,14 @@ function getSignalFn(signal, params, referencedBindings) {
2361
2515
  }
2362
2516
  forEach(signal.intersection, (intersection) => {
2363
2517
  signal.render.push(
2364
- import_compiler17.types.expressionStatement(import_compiler17.types.callExpression(intersection, [scopeIdentifier2]))
2518
+ import_compiler18.types.expressionStatement(import_compiler18.types.callExpression(intersection, [scopeIdentifier2]))
2365
2519
  );
2366
2520
  });
2367
2521
  if (isValueSignal) {
2368
2522
  let dynamicClosureArgs;
2369
2523
  let dynamicClosureSignalIdentifier;
2370
2524
  forEach(binding.closureSections, (closureSection) => {
2371
- if (isStatefulReferences(binding)) {
2525
+ if (binding.sources) {
2372
2526
  if (isDynamicClosure(closureSection, binding)) {
2373
2527
  if (!dynamicClosureArgs) {
2374
2528
  dynamicClosureArgs = [];
@@ -2376,8 +2530,8 @@ function getSignalFn(signal, params, referencedBindings) {
2376
2530
  signal.identifier.name + "_closure"
2377
2531
  );
2378
2532
  signal.render.push(
2379
- import_compiler17.types.expressionStatement(
2380
- import_compiler17.types.callExpression(dynamicClosureSignalIdentifier, [
2533
+ import_compiler18.types.expressionStatement(
2534
+ import_compiler18.types.callExpression(dynamicClosureSignalIdentifier, [
2381
2535
  scopeIdentifier2
2382
2536
  ])
2383
2537
  )
@@ -2388,8 +2542,8 @@ function getSignalFn(signal, params, referencedBindings) {
2388
2542
  );
2389
2543
  } else {
2390
2544
  signal.render.push(
2391
- import_compiler17.types.expressionStatement(
2392
- import_compiler17.types.callExpression(getSignal(closureSection, binding).identifier, [
2545
+ import_compiler18.types.expressionStatement(
2546
+ import_compiler18.types.callExpression(getSignal(closureSection, binding).identifier, [
2393
2547
  scopeIdentifier2
2394
2548
  ])
2395
2549
  )
@@ -2399,8 +2553,8 @@ function getSignalFn(signal, params, referencedBindings) {
2399
2553
  });
2400
2554
  if (dynamicClosureSignalIdentifier) {
2401
2555
  (signal.prependStatements ||= []).push(
2402
- import_compiler17.types.variableDeclaration("const", [
2403
- import_compiler17.types.variableDeclarator(
2556
+ import_compiler18.types.variableDeclaration("const", [
2557
+ import_compiler18.types.variableDeclarator(
2404
2558
  dynamicClosureSignalIdentifier,
2405
2559
  callRuntime("dynamicClosure", ...dynamicClosureArgs)
2406
2560
  )
@@ -2409,24 +2563,24 @@ function getSignalFn(signal, params, referencedBindings) {
2409
2563
  }
2410
2564
  }
2411
2565
  if (signal.effect.length) {
2412
- const effectIdentifier = import_compiler17.types.identifier(`${signal.identifier.name}_effect`);
2566
+ const effectIdentifier = import_compiler18.types.identifier(`${signal.identifier.name}_effect`);
2413
2567
  signal.render.push(
2414
- import_compiler17.types.expressionStatement(
2415
- import_compiler17.types.callExpression(effectIdentifier, [scopeIdentifier2])
2568
+ import_compiler18.types.expressionStatement(
2569
+ import_compiler18.types.callExpression(effectIdentifier, [scopeIdentifier2])
2416
2570
  )
2417
2571
  );
2418
2572
  }
2419
2573
  if (referencedBindings) {
2420
2574
  signal.render.unshift(
2421
- import_compiler17.types.variableDeclaration("const", [
2422
- import_compiler17.types.variableDeclarator(
2575
+ import_compiler18.types.variableDeclaration("const", [
2576
+ import_compiler18.types.variableDeclarator(
2423
2577
  createScopeReadPattern(section, referencedBindings),
2424
2578
  scopeIdentifier2
2425
2579
  )
2426
2580
  ])
2427
2581
  );
2428
2582
  }
2429
- 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));
2430
2584
  }
2431
2585
  var hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
2432
2586
  var emptyExtraArgs = [];
@@ -2471,19 +2625,19 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
2471
2625
  for (let i = args.length; i--; ) {
2472
2626
  const arg = args[i];
2473
2627
  if (!arg) {
2474
- args[i] = import_compiler17.types.numericLiteral(0);
2475
- } 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)) {
2476
2630
  const body = arg.body.body;
2477
2631
  if (body.length === 0) {
2478
- args[i] = import_compiler17.types.numericLiteral(0);
2479
- } 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])) {
2480
2634
  arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
2481
2635
  }
2482
- } else if (import_compiler17.types.isNullLiteral(arg) || import_compiler17.types.isUnaryExpression(arg) && arg.operator === "void") {
2483
- 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);
2484
2638
  }
2485
2639
  }
2486
- 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; ) {
2487
2641
  args.length = i--;
2488
2642
  }
2489
2643
  return args;
@@ -2576,7 +2730,7 @@ function writeSignals(section) {
2576
2730
  forEach(section.hoisted, (binding) => {
2577
2731
  for (const hoistedBinding of binding.hoists.values()) {
2578
2732
  const accessors = [
2579
- binding.type === 0 /* dom */ ? import_compiler17.types.stringLiteral(
2733
+ binding.type === 0 /* dom */ ? import_compiler18.types.stringLiteral(
2580
2734
  getAccessorPrefix().Getter + getScopeAccessor(binding)
2581
2735
  ) : getScopeAccessorLiteral(binding)
2582
2736
  ];
@@ -2591,12 +2745,12 @@ function writeSignals(section) {
2591
2745
  const hoistIdentifier = getHoistFunctionIdentifier(hoistedBinding);
2592
2746
  currentProgramPath.pushContainer(
2593
2747
  "body",
2594
- import_compiler17.types.variableDeclaration("const", [
2595
- import_compiler17.types.variableDeclarator(
2748
+ import_compiler18.types.variableDeclaration("const", [
2749
+ import_compiler18.types.variableDeclarator(
2596
2750
  hoistIdentifier,
2597
2751
  hoistedBinding.downstreamExpressions.size ? callRuntime(
2598
2752
  "register",
2599
- import_compiler17.types.stringLiteral(
2753
+ import_compiler18.types.stringLiteral(
2600
2754
  getResumeRegisterId(
2601
2755
  hoistedBinding.section,
2602
2756
  hoistedBinding,
@@ -2613,7 +2767,7 @@ function writeSignals(section) {
2613
2767
  hoistedBinding.section,
2614
2768
  void 0,
2615
2769
  initValue(hoistedBinding),
2616
- import_compiler17.types.callExpression(hoistIdentifier, [scopeIdentifier])
2770
+ import_compiler18.types.callExpression(hoistIdentifier, [scopeIdentifier])
2617
2771
  );
2618
2772
  }
2619
2773
  }
@@ -2627,20 +2781,20 @@ function writeSignals(section) {
2627
2781
  let effectDeclarator;
2628
2782
  if (signal.effect.length) {
2629
2783
  traverseReplace(signal, "effect", replaceEffectNode);
2630
- const effectIdentifier = import_compiler17.types.identifier(`${signal.identifier.name}_effect`);
2784
+ const effectIdentifier = import_compiler18.types.identifier(`${signal.identifier.name}_effect`);
2631
2785
  const referencedBindings = signal.effectReferencedBindings;
2632
2786
  const referencesScope = traverseContains(
2633
2787
  signal.effect,
2634
2788
  isScopeIdentifier
2635
2789
  );
2636
- effectDeclarator = import_compiler17.types.variableDeclarator(
2790
+ effectDeclarator = import_compiler18.types.variableDeclarator(
2637
2791
  effectIdentifier,
2638
2792
  callRuntime(
2639
2793
  "effect",
2640
- import_compiler17.types.stringLiteral(
2794
+ import_compiler18.types.stringLiteral(
2641
2795
  getResumeRegisterId(section, signal.referencedBindings)
2642
2796
  ),
2643
- import_compiler17.types.arrowFunctionExpression(
2797
+ import_compiler18.types.arrowFunctionExpression(
2644
2798
  referencedBindings ? referencesScope ? [
2645
2799
  scopeIdentifier,
2646
2800
  createScopeReadPattern(section, referencedBindings)
@@ -2651,30 +2805,30 @@ function writeSignals(section) {
2651
2805
  );
2652
2806
  }
2653
2807
  let value = signal.build();
2654
- if (import_compiler17.types.isCallExpression(value)) {
2808
+ if (import_compiler18.types.isCallExpression(value)) {
2655
2809
  replaceNullishAndEmptyFunctionsWith0(value.arguments);
2656
2810
  }
2657
2811
  if (signal.register) {
2658
2812
  value = callRuntime(
2659
2813
  "registerBoundSignal",
2660
- import_compiler17.types.stringLiteral(
2814
+ import_compiler18.types.stringLiteral(
2661
2815
  getResumeRegisterId(section, signal.referencedBindings, "var")
2662
2816
  ),
2663
2817
  value
2664
2818
  );
2665
2819
  }
2666
- const signalDeclarator = import_compiler17.types.variableDeclarator(signal.identifier, value);
2667
- 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(
2668
2822
  signal.identifier,
2669
2823
  value.params,
2670
- import_compiler17.types.isExpression(value.body) ? import_compiler17.types.blockStatement([import_compiler17.types.expressionStatement(value.body)]) : value.body
2671
- ) : 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]);
2672
2826
  if (signal.export) {
2673
- signalDeclaration = import_compiler17.types.exportNamedDeclaration(signalDeclaration);
2827
+ signalDeclaration = import_compiler18.types.exportNamedDeclaration(signalDeclaration);
2674
2828
  }
2675
2829
  const signalStatements = signal.prependStatements || [];
2676
2830
  if (effectDeclarator) {
2677
- signalStatements.push(import_compiler17.types.variableDeclaration("const", [effectDeclarator]));
2831
+ signalStatements.push(import_compiler18.types.variableDeclaration("const", [effectDeclarator]));
2678
2832
  }
2679
2833
  signalStatements.push(signalDeclaration);
2680
2834
  currentProgramPath.pushContainer("body", signalStatements);
@@ -2688,7 +2842,7 @@ function writeRegisteredFns() {
2688
2842
  let fn;
2689
2843
  const params = registeredFn.referencedBindings ? registeredFn.referencesScope ? [
2690
2844
  scopeIdentifier,
2691
- import_compiler17.types.assignmentPattern(
2845
+ import_compiler18.types.assignmentPattern(
2692
2846
  createScopeReadPattern(
2693
2847
  registeredFn.section,
2694
2848
  registeredFn.referencedBindings
@@ -2702,18 +2856,18 @@ function writeRegisteredFns() {
2702
2856
  )
2703
2857
  ] : registeredFn.referencesScope ? [scopeIdentifier] : void 0;
2704
2858
  if (params) {
2705
- fn = import_compiler17.types.functionDeclaration(
2706
- import_compiler17.types.identifier(registeredFn.id),
2859
+ fn = import_compiler18.types.functionDeclaration(
2860
+ import_compiler18.types.identifier(registeredFn.id),
2707
2861
  params,
2708
- import_compiler17.types.blockStatement(toReturnedFunction(registeredFn.node))
2862
+ import_compiler18.types.blockStatement(toReturnedFunction(registeredFn.node))
2709
2863
  );
2710
2864
  } else if (registeredFn.node.type === "FunctionDeclaration" && registeredFn.node.id?.name === registeredFn.id) {
2711
2865
  fn = registeredFn.node;
2712
2866
  } else {
2713
- fn = import_compiler17.types.functionDeclaration(
2714
- import_compiler17.types.identifier(registeredFn.id),
2867
+ fn = import_compiler18.types.functionDeclaration(
2868
+ import_compiler18.types.identifier(registeredFn.id),
2715
2869
  registeredFn.node.params,
2716
- 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)]),
2717
2871
  registeredFn.node.generator,
2718
2872
  registeredFn.node.async
2719
2873
  );
@@ -2722,11 +2876,11 @@ function writeRegisteredFns() {
2722
2876
  }
2723
2877
  for (const registeredFn of registeredFns) {
2724
2878
  statements.push(
2725
- import_compiler17.types.expressionStatement(
2879
+ import_compiler18.types.expressionStatement(
2726
2880
  callRuntime(
2727
2881
  "register",
2728
- import_compiler17.types.stringLiteral(registeredFn.registerId),
2729
- import_compiler17.types.identifier(registeredFn.id)
2882
+ import_compiler18.types.stringLiteral(registeredFn.registerId),
2883
+ import_compiler18.types.identifier(registeredFn.id)
2730
2884
  )
2731
2885
  )
2732
2886
  );
@@ -2738,7 +2892,7 @@ function writeRegisteredFns() {
2738
2892
  }
2739
2893
  function toReturnedFunction(rawFn) {
2740
2894
  const fn = simplifyFunction(rawFn);
2741
- 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)];
2742
2896
  }
2743
2897
  function sortSignals(a, b) {
2744
2898
  const aReferencedBindings = getReferencedBindings(a);
@@ -2773,9 +2927,10 @@ function writeHTMLResumeStatements(path5) {
2773
2927
  forEach(section.assignments, serializeOwnersUntilBinding);
2774
2928
  forEach(section.referencedHoists, serializeOwnersUntilBinding);
2775
2929
  forEach(section.referencedClosures, (closure) => {
2776
- if (isStatefulReferences(closure)) {
2930
+ if (closure.sources) {
2931
+ const serializeReason = getDynamicSourcesForBinding(closure);
2777
2932
  serializeOwnersUntilBinding(closure);
2778
- setForceResumeScope(closure.section);
2933
+ serializeSectionIfNeeded(closure.section, serializeReason);
2779
2934
  if (isDynamicClosure(section, closure)) {
2780
2935
  const closureSignal = getSignal(closure.section, closure);
2781
2936
  let identifier = htmlDynamicClosureInstancesIdentifier.get(closureSignal);
@@ -2787,23 +2942,25 @@ function writeHTMLResumeStatements(path5) {
2787
2942
  )
2788
2943
  );
2789
2944
  getHTMLSectionStatements(closure.section).push(
2790
- import_compiler17.types.variableDeclaration("const", [
2791
- import_compiler17.types.variableDeclarator(
2945
+ import_compiler18.types.variableDeclaration("const", [
2946
+ import_compiler18.types.variableDeclarator(
2792
2947
  identifier,
2793
- import_compiler17.types.newExpression(import_compiler17.types.identifier("Set"), [])
2948
+ import_compiler18.types.newExpression(import_compiler18.types.identifier("Set"), [])
2794
2949
  )
2795
2950
  ])
2796
2951
  );
2797
2952
  setSerializedProperty(
2798
2953
  closure.section,
2799
2954
  getAccessorPrefix().ClosureScopes + getScopeAccessor(closure),
2800
- identifier
2955
+ identifier,
2956
+ serializeReason
2801
2957
  );
2802
2958
  }
2803
2959
  setSerializedProperty(
2804
2960
  section,
2805
2961
  getAccessorPrefix().ClosureSignalIndex + getScopeAccessor(closure),
2806
- import_compiler17.types.numericLiteral(getDynamicClosureIndex(closure, section))
2962
+ import_compiler18.types.numericLiteral(getDynamicClosureIndex(closure, section)),
2963
+ serializeReason
2807
2964
  );
2808
2965
  addWriteScopeBuilder(
2809
2966
  section,
@@ -2817,13 +2974,13 @@ function writeHTMLResumeStatements(path5) {
2817
2974
  for (const hoistedBinding of binding.hoists.values()) {
2818
2975
  if (hoistedBinding.downstreamExpressions.size) {
2819
2976
  getHTMLSectionStatements(hoistedBinding.section).push(
2820
- import_compiler17.types.variableDeclaration("const", [
2821
- import_compiler17.types.variableDeclarator(
2822
- import_compiler17.types.identifier(hoistedBinding.name),
2977
+ import_compiler18.types.variableDeclaration("const", [
2978
+ import_compiler18.types.variableDeclarator(
2979
+ import_compiler18.types.identifier(hoistedBinding.name),
2823
2980
  callRuntime(
2824
2981
  "hoist",
2825
2982
  getScopeIdIdentifier(hoistedBinding.section),
2826
- import_compiler17.types.stringLiteral(
2983
+ import_compiler18.types.stringLiteral(
2827
2984
  getResumeRegisterId(
2828
2985
  hoistedBinding.section,
2829
2986
  hoistedBinding,
@@ -2844,10 +3001,10 @@ function writeHTMLResumeStatements(path5) {
2844
3001
  );
2845
3002
  sectionDynamicSubscribers.add(currentSection);
2846
3003
  getHTMLSectionStatements(parentSection).push(
2847
- import_compiler17.types.variableDeclaration("const", [
2848
- import_compiler17.types.variableDeclarator(
3004
+ import_compiler18.types.variableDeclaration("const", [
3005
+ import_compiler18.types.variableDeclarator(
2849
3006
  subscribersIdentifier,
2850
- import_compiler17.types.newExpression(import_compiler17.types.identifier("Set"), [])
3007
+ import_compiler18.types.newExpression(import_compiler18.types.identifier("Set"), [])
2851
3008
  )
2852
3009
  ])
2853
3010
  );
@@ -2858,7 +3015,8 @@ function writeHTMLResumeStatements(path5) {
2858
3015
  setSerializedProperty(
2859
3016
  parentSection,
2860
3017
  getSectionInstancesAccessor(currentSection),
2861
- subscribersIdentifier
3018
+ subscribersIdentifier,
3019
+ true
2862
3020
  );
2863
3021
  }
2864
3022
  currentSection = parentSection;
@@ -2868,7 +3026,8 @@ function writeHTMLResumeStatements(path5) {
2868
3026
  setSerializedProperty(
2869
3027
  section,
2870
3028
  getScopeAccessor(binding),
2871
- getDeclaredBindingExpression(binding)
3029
+ getDeclaredBindingExpression(binding),
3030
+ true
2872
3031
  );
2873
3032
  }
2874
3033
  });
@@ -2877,11 +3036,11 @@ function writeHTMLResumeStatements(path5) {
2877
3036
  const signalRefs = allSignals[i].referencedBindings;
2878
3037
  path5.pushContainer(
2879
3038
  "body",
2880
- import_compiler17.types.expressionStatement(
3039
+ import_compiler18.types.expressionStatement(
2881
3040
  callRuntime(
2882
3041
  "writeEffect",
2883
3042
  scopeIdIdentifier,
2884
- import_compiler17.types.stringLiteral(getResumeRegisterId(section, signalRefs))
3043
+ import_compiler18.types.stringLiteral(getResumeRegisterId(section, signalRefs))
2885
3044
  )
2886
3045
  )
2887
3046
  );
@@ -2898,11 +3057,12 @@ function writeHTMLResumeStatements(path5) {
2898
3057
  );
2899
3058
  }
2900
3059
  });
2901
- for (const [key, value] of serializedLookup) {
2902
- serializedProperties.push(toObjectProperty(key, value));
3060
+ for (const [key, { expression }] of serializedLookup) {
3061
+ serializedProperties.push(toObjectProperty(key, expression));
2903
3062
  }
2904
3063
  const writeScopeBuilder = getSectionWriteScopeBuilder(section);
2905
- if (writeScopeBuilder || serializedProperties.length || forceResumeScope(section)) {
3064
+ const forceSerializeReason = serializeSectionReason(section);
3065
+ if (writeScopeBuilder || serializedProperties.length || forceSerializeReason) {
2906
3066
  for (const prop of serializedProperties) {
2907
3067
  if (prop.key.type === "Identifier" && prop.value.type === "Identifier" && prop.key.name === prop.value.name) {
2908
3068
  prop.shorthand = true;
@@ -2910,7 +3070,7 @@ function writeHTMLResumeStatements(path5) {
2910
3070
  }
2911
3071
  const writeScopeArgs = [
2912
3072
  scopeIdIdentifier,
2913
- import_compiler17.types.objectExpression(serializedProperties)
3073
+ import_compiler18.types.objectExpression(serializedProperties)
2914
3074
  ];
2915
3075
  if (!isOptimize()) {
2916
3076
  let debugVars;
@@ -2924,31 +3084,31 @@ function writeHTMLResumeStatements(path5) {
2924
3084
  }
2925
3085
  root = root.upstreamAlias;
2926
3086
  }
2927
- const locExpr = root.loc && import_compiler17.types.stringLiteral(
3087
+ const locExpr = root.loc && import_compiler18.types.stringLiteral(
2928
3088
  `${root.loc.start.line}:${root.loc.start.column + 1}`
2929
3089
  );
2930
3090
  (debugVars ||= []).push(
2931
3091
  toObjectProperty(
2932
3092
  getScopeAccessor(binding),
2933
- root !== binding ? import_compiler17.types.arrayExpression(
2934
- locExpr ? [import_compiler17.types.stringLiteral(root.name + access), locExpr] : [import_compiler17.types.stringLiteral(root.name + access)]
2935
- ) : 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)
2936
3096
  )
2937
3097
  );
2938
3098
  });
2939
3099
  writeScopeArgs.push(
2940
- import_compiler17.types.stringLiteral(path5.hub.file.opts.filenameRelative),
2941
- 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(
2942
3102
  `${section.loc.start.line}:${section.loc.start.column + 1}`
2943
- ) : import_compiler17.types.numericLiteral(0)
3103
+ ) : import_compiler18.types.numericLiteral(0)
2944
3104
  );
2945
3105
  if (debugVars) {
2946
- writeScopeArgs.push(import_compiler17.types.objectExpression(debugVars));
3106
+ writeScopeArgs.push(import_compiler18.types.objectExpression(debugVars));
2947
3107
  }
2948
3108
  }
2949
3109
  path5.pushContainer(
2950
3110
  "body",
2951
- import_compiler17.types.expressionStatement(
3111
+ import_compiler18.types.expressionStatement(
2952
3112
  writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs)
2953
3113
  )
2954
3114
  );
@@ -2957,7 +3117,7 @@ function writeHTMLResumeStatements(path5) {
2957
3117
  if (resumeClosestBranch2) {
2958
3118
  path5.pushContainer(
2959
3119
  "body",
2960
- import_compiler17.types.expressionStatement(
3120
+ import_compiler18.types.expressionStatement(
2961
3121
  callRuntime("resumeClosestBranch", scopeIdIdentifier)
2962
3122
  )
2963
3123
  );
@@ -2965,15 +3125,15 @@ function writeHTMLResumeStatements(path5) {
2965
3125
  const additionalStatements = getHTMLSectionStatements(section);
2966
3126
  if (path5.get("body").length || additionalStatements.length) {
2967
3127
  path5.unshiftContainer("body", [
2968
- import_compiler17.types.variableDeclaration("const", [
2969
- import_compiler17.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
3128
+ import_compiler18.types.variableDeclaration("const", [
3129
+ import_compiler18.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
2970
3130
  ]),
2971
3131
  ...additionalStatements
2972
3132
  ]);
2973
3133
  }
2974
3134
  const returnIdentifier = getSectionReturnValueIdentifier(section);
2975
3135
  if (returnIdentifier !== void 0) {
2976
- path5.pushContainer("body", import_compiler17.types.returnStatement(returnIdentifier));
3136
+ path5.pushContainer("body", import_compiler18.types.returnStatement(returnIdentifier));
2977
3137
  }
2978
3138
  }
2979
3139
  function serializeOwners(from, to) {
@@ -2984,10 +3144,10 @@ function serializeOwners(from, to) {
2984
3144
  const serialized = getSerializedScopeProperties(cur);
2985
3145
  cur = parent;
2986
3146
  if (!serialized.has("_")) {
2987
- serialized.set(
2988
- "_",
2989
- callRuntime("ensureScopeWithId", getScopeIdIdentifier(cur))
2990
- );
3147
+ serialized.set("_", {
3148
+ expression: callRuntime("ensureScopeWithId", getScopeIdIdentifier(cur)),
3149
+ reason: true
3150
+ });
2991
3151
  }
2992
3152
  }
2993
3153
  }
@@ -3020,14 +3180,14 @@ function replaceAssignedNode(node) {
3020
3180
  if (buildAssignment) {
3021
3181
  const replacement = buildAssignment(
3022
3182
  extra.section,
3023
- import_compiler17.types.binaryExpression(
3183
+ import_compiler18.types.binaryExpression(
3024
3184
  node.operator === "++" ? "+" : "-",
3025
3185
  node.argument,
3026
- import_compiler17.types.numericLiteral(1)
3186
+ import_compiler18.types.numericLiteral(1)
3027
3187
  )
3028
3188
  );
3029
3189
  if (!node.prefix) {
3030
- return import_compiler17.types.sequenceExpression([replacement, node.argument]);
3190
+ return import_compiler18.types.sequenceExpression([replacement, node.argument]);
3031
3191
  }
3032
3192
  return replacement;
3033
3193
  }
@@ -3046,7 +3206,7 @@ function replaceAssignedNode(node) {
3046
3206
  if (buildAssignment) {
3047
3207
  return buildAssignment(
3048
3208
  extra.section,
3049
- node.operator === "=" ? node.right : import_compiler17.types.binaryExpression(
3209
+ node.operator === "=" ? node.right : import_compiler18.types.binaryExpression(
3050
3210
  node.operator.slice(
3051
3211
  0,
3052
3212
  -1
@@ -3072,26 +3232,26 @@ function replaceAssignedNode(node) {
3072
3232
  );
3073
3233
  if (signal?.buildAssignment) {
3074
3234
  id.name = currentProgramPath.scope.generateUid(id.name);
3075
- (params ||= []).push(import_compiler17.types.identifier(id.name));
3235
+ (params ||= []).push(import_compiler18.types.identifier(id.name));
3076
3236
  (assignments ||= []).push(
3077
- signal.buildAssignment(extra.section, import_compiler17.types.identifier(id.name))
3237
+ signal.buildAssignment(extra.section, import_compiler18.types.identifier(id.name))
3078
3238
  );
3079
3239
  }
3080
3240
  }
3081
3241
  });
3082
3242
  if (params && assignments) {
3083
3243
  const resultId = currentProgramPath.scope.generateUid("result");
3084
- return import_compiler17.types.callExpression(
3085
- import_compiler17.types.arrowFunctionExpression(
3086
- [import_compiler17.types.identifier(resultId), ...params],
3087
- import_compiler17.types.sequenceExpression([
3088
- 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(
3089
3249
  "=",
3090
3250
  node.left,
3091
- import_compiler17.types.identifier(resultId)
3251
+ import_compiler18.types.identifier(resultId)
3092
3252
  ),
3093
3253
  ...assignments,
3094
- import_compiler17.types.identifier(resultId)
3254
+ import_compiler18.types.identifier(resultId)
3095
3255
  ])
3096
3256
  ),
3097
3257
  [node.right]
@@ -3108,15 +3268,15 @@ function replaceRegisteredFunctionNode(node) {
3108
3268
  switch (node.type) {
3109
3269
  case "ClassMethod": {
3110
3270
  const replacement = getRegisteredFnExpression(node);
3111
- return replacement && import_compiler17.types.classProperty(node.key, replacement);
3271
+ return replacement && import_compiler18.types.classProperty(node.key, replacement);
3112
3272
  }
3113
3273
  case "ClassPrivateMethod": {
3114
3274
  const replacement = getRegisteredFnExpression(node);
3115
- return replacement && import_compiler17.types.classPrivateProperty(node.key, replacement);
3275
+ return replacement && import_compiler18.types.classPrivateProperty(node.key, replacement);
3116
3276
  }
3117
3277
  case "ObjectMethod": {
3118
3278
  const replacement = getRegisteredFnExpression(node);
3119
- return replacement && import_compiler17.types.objectProperty(node.key, replacement);
3279
+ return replacement && import_compiler18.types.objectProperty(node.key, replacement);
3120
3280
  }
3121
3281
  case "ArrowFunctionExpression":
3122
3282
  case "FunctionExpression": {
@@ -3125,8 +3285,8 @@ function replaceRegisteredFunctionNode(node) {
3125
3285
  case "FunctionDeclaration": {
3126
3286
  const replacement = getRegisteredFnExpression(node);
3127
3287
  if (replacement) {
3128
- return import_compiler17.types.variableDeclaration("const", [
3129
- import_compiler17.types.variableDeclarator(node.id, replacement)
3288
+ return import_compiler18.types.variableDeclaration("const", [
3289
+ import_compiler18.types.variableDeclarator(node.id, replacement)
3130
3290
  ]);
3131
3291
  }
3132
3292
  break;
@@ -3152,9 +3312,9 @@ function getRegisteredFnExpression(node) {
3152
3312
  referencedBindings
3153
3313
  });
3154
3314
  if (referencesScope || referencedBindings) {
3155
- return import_compiler17.types.callExpression(import_compiler17.types.identifier(id), [scopeIdentifier]);
3315
+ return import_compiler18.types.callExpression(import_compiler18.types.identifier(id), [scopeIdentifier]);
3156
3316
  } else {
3157
- return import_compiler17.types.identifier(id);
3317
+ return import_compiler18.types.identifier(id);
3158
3318
  }
3159
3319
  }
3160
3320
  }
@@ -3178,9 +3338,9 @@ var dom_default = {
3178
3338
  const section = getSectionForBody(program);
3179
3339
  const { walks, writes, setup } = getSectionMeta(section);
3180
3340
  const domExports = program.node.extra.domExports;
3181
- const templateIdentifier = import_compiler18.types.identifier(domExports.template);
3182
- const walksIdentifier = import_compiler18.types.identifier(domExports.walks);
3183
- 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);
3184
3344
  const inputBinding = program.node.params[0].extra?.binding;
3185
3345
  const programInputSignal = inputBinding && bindingHasDownstreamExpressions(inputBinding) ? initValue(inputBinding) : void 0;
3186
3346
  const styleFile = getStyleFile(program.hub.file);
@@ -3191,17 +3351,17 @@ var dom_default = {
3191
3351
  if (childSection !== section) {
3192
3352
  const tagParamsSignal = childSection.params && initValue(childSection.params);
3193
3353
  const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
3194
- const identifier = import_compiler18.types.identifier(childSection.name);
3195
- 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(
3196
3356
  [scopeIdentifier],
3197
3357
  toFirstExpressionOrBlock(
3198
3358
  map(childSection.referencedClosures, (closure) => {
3199
3359
  const closureSignal = getSignal(childSection, closure);
3200
- return import_compiler18.types.expressionStatement(
3201
- import_compiler18.types.callExpression(
3202
- 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(
3203
3363
  closureSignal.identifier,
3204
- import_compiler18.types.identifier("_")
3364
+ import_compiler19.types.identifier("_")
3205
3365
  ),
3206
3366
  [scopeIdentifier]
3207
3367
  )
@@ -3220,7 +3380,7 @@ var dom_default = {
3220
3380
  ])
3221
3381
  ) : callRuntime(
3222
3382
  isSerializedSection(childSection) ? "registerContent" : "createContent",
3223
- import_compiler18.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
3383
+ import_compiler19.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
3224
3384
  ...replaceNullishAndEmptyFunctionsWith0([
3225
3385
  writes2,
3226
3386
  walks2,
@@ -3232,8 +3392,8 @@ var dom_default = {
3232
3392
  );
3233
3393
  writeSignals(childSection);
3234
3394
  program.node.body.push(
3235
- import_compiler18.types.variableDeclaration("const", [
3236
- import_compiler18.types.variableDeclarator(identifier, renderer)
3395
+ import_compiler19.types.variableDeclaration("const", [
3396
+ import_compiler19.types.variableDeclarator(identifier, renderer)
3237
3397
  ])
3238
3398
  );
3239
3399
  }
@@ -3242,36 +3402,36 @@ var dom_default = {
3242
3402
  writeRegisteredFns();
3243
3403
  if (!setup) {
3244
3404
  program.node.body.unshift(
3245
- import_compiler18.types.exportNamedDeclaration(
3246
- import_compiler18.types.variableDeclaration("const", [
3247
- import_compiler18.types.variableDeclarator(
3405
+ import_compiler19.types.exportNamedDeclaration(
3406
+ import_compiler19.types.variableDeclaration("const", [
3407
+ import_compiler19.types.variableDeclarator(
3248
3408
  setupIdentifier,
3249
- import_compiler18.types.arrowFunctionExpression([], import_compiler18.types.blockStatement([]))
3409
+ import_compiler19.types.arrowFunctionExpression([], import_compiler19.types.blockStatement([]))
3250
3410
  )
3251
3411
  ])
3252
3412
  )
3253
3413
  );
3254
3414
  }
3255
3415
  program.node.body.unshift(
3256
- import_compiler18.types.exportNamedDeclaration(
3257
- import_compiler18.types.variableDeclaration("const", [
3258
- import_compiler18.types.variableDeclarator(
3416
+ import_compiler19.types.exportNamedDeclaration(
3417
+ import_compiler19.types.variableDeclaration("const", [
3418
+ import_compiler19.types.variableDeclarator(
3259
3419
  templateIdentifier,
3260
- writes || import_compiler18.types.stringLiteral("")
3420
+ writes || import_compiler19.types.stringLiteral("")
3261
3421
  )
3262
3422
  ])
3263
3423
  ),
3264
- import_compiler18.types.exportNamedDeclaration(
3265
- import_compiler18.types.variableDeclaration("const", [
3266
- 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(""))
3267
3427
  ])
3268
3428
  )
3269
3429
  );
3270
3430
  program.node.body.push(
3271
- import_compiler18.types.exportDefaultDeclaration(
3431
+ import_compiler19.types.exportDefaultDeclaration(
3272
3432
  callRuntime(
3273
3433
  "createTemplate",
3274
- import_compiler18.types.stringLiteral(program.hub.file.metadata.marko.id),
3434
+ import_compiler19.types.stringLiteral(program.hub.file.metadata.marko.id),
3275
3435
  templateIdentifier,
3276
3436
  walksIdentifier,
3277
3437
  setupIdentifier,
@@ -3284,7 +3444,7 @@ var dom_default = {
3284
3444
  };
3285
3445
 
3286
3446
  // src/translator/visitors/program/html.ts
3287
- var import_compiler19 = require("@marko/compiler");
3447
+ var import_compiler20 = require("@marko/compiler");
3288
3448
 
3289
3449
  // src/translator/util/is-static.ts
3290
3450
  function isStatic(path5) {
@@ -3323,22 +3483,22 @@ var html_default = {
3323
3483
  }
3324
3484
  }
3325
3485
  const contentId = templateContentIdentifierForProgram.get(program);
3326
- const contentFn = import_compiler19.types.arrowFunctionExpression(
3327
- [import_compiler19.types.identifier("input")],
3328
- import_compiler19.types.blockStatement(renderContent)
3486
+ const contentFn = import_compiler20.types.arrowFunctionExpression(
3487
+ [import_compiler20.types.identifier("input")],
3488
+ import_compiler20.types.blockStatement(renderContent)
3329
3489
  );
3330
- const exportDefault = import_compiler19.types.exportDefaultDeclaration(
3490
+ const exportDefault = import_compiler20.types.exportDefaultDeclaration(
3331
3491
  callRuntime(
3332
3492
  "createTemplate",
3333
- import_compiler19.types.stringLiteral(program.hub.file.metadata.marko.id),
3334
- 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
3335
3495
  )
3336
3496
  );
3337
3497
  program.pushContainer(
3338
3498
  "body",
3339
3499
  contentId ? [
3340
- import_compiler19.types.variableDeclaration("const", [
3341
- 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)
3342
3502
  ]),
3343
3503
  exportDefault
3344
3504
  ] : exportDefault
@@ -3364,15 +3524,15 @@ function replaceRegisteredFunctionNode2(node, container) {
3364
3524
  switch (node.type) {
3365
3525
  case "ClassMethod": {
3366
3526
  const replacement = getRegisteredFnExpression2(node);
3367
- return replacement && import_compiler19.types.classProperty(node.key, replacement);
3527
+ return replacement && import_compiler20.types.classProperty(node.key, replacement);
3368
3528
  }
3369
3529
  case "ClassPrivateMethod": {
3370
3530
  const replacement = getRegisteredFnExpression2(node);
3371
- return replacement && import_compiler19.types.classPrivateProperty(node.key, replacement);
3531
+ return replacement && import_compiler20.types.classPrivateProperty(node.key, replacement);
3372
3532
  }
3373
3533
  case "ObjectMethod": {
3374
3534
  const replacement = getRegisteredFnExpression2(node);
3375
- return replacement && import_compiler19.types.objectProperty(node.key, replacement);
3535
+ return replacement && import_compiler20.types.objectProperty(node.key, replacement);
3376
3536
  }
3377
3537
  case "FunctionDeclaration": {
3378
3538
  const { extra } = node;
@@ -3409,11 +3569,11 @@ function addRegisteredDeclarations(body) {
3409
3569
  if (registeredFnDeclarations) {
3410
3570
  for (const { id, registerId } of registeredFnDeclarations) {
3411
3571
  body.push(
3412
- import_compiler19.types.expressionStatement(
3572
+ import_compiler20.types.expressionStatement(
3413
3573
  callRuntime(
3414
3574
  "register",
3415
- import_compiler19.types.identifier(id),
3416
- import_compiler19.types.stringLiteral(registerId)
3575
+ import_compiler20.types.identifier(id),
3576
+ import_compiler20.types.stringLiteral(registerId)
3417
3577
  )
3418
3578
  )
3419
3579
  );
@@ -3426,7 +3586,7 @@ function getRegisteredFnExpression2(node) {
3426
3586
  return callRuntime(
3427
3587
  "register",
3428
3588
  simplifyFunction(node),
3429
- import_compiler19.types.stringLiteral(extra.registerId),
3589
+ import_compiler20.types.stringLiteral(extra.registerId),
3430
3590
  (extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section)
3431
3591
  );
3432
3592
  }
@@ -3444,7 +3604,7 @@ var program_default = {
3444
3604
  migrate: {
3445
3605
  enter(program) {
3446
3606
  previousProgramPath.set(program, currentProgramPath);
3447
- program.node.params = [import_compiler20.types.identifier("input")];
3607
+ program.node.params = [import_compiler21.types.identifier("input")];
3448
3608
  currentProgramPath = program;
3449
3609
  },
3450
3610
  exit() {
@@ -3527,7 +3687,7 @@ var program_default = {
3527
3687
  body.push(child);
3528
3688
  }
3529
3689
  }
3530
- body[0] ??= import_compiler20.types.importDeclaration([], import_compiler20.types.stringLiteral(compatFile));
3690
+ body[0] ??= import_compiler21.types.importDeclaration([], import_compiler21.types.stringLiteral(compatFile));
3531
3691
  program.node.body = body;
3532
3692
  }
3533
3693
  currentProgramPath = previousProgramPath.get(currentProgramPath);
@@ -3618,7 +3778,7 @@ function isFunction(path5) {
3618
3778
  }
3619
3779
 
3620
3780
  // src/translator/util/is-invoked-function.ts
3621
- var import_compiler21 = require("@marko/compiler");
3781
+ var import_compiler22 = require("@marko/compiler");
3622
3782
  function isInvokedFunction(expr) {
3623
3783
  let curPath = expr;
3624
3784
  while (curPath) {
@@ -3661,7 +3821,7 @@ function createBinding(name2, type, section, upstreamAlias, upstreamExpression,
3661
3821
  closureSections: void 0,
3662
3822
  excludeProperties: void 0,
3663
3823
  serialize: false,
3664
- sources: /* @__PURE__ */ new Set(),
3824
+ sources: void 0,
3665
3825
  aliases: /* @__PURE__ */ new Set(),
3666
3826
  hoists: /* @__PURE__ */ new Map(),
3667
3827
  propertyAliases: /* @__PURE__ */ new Map(),
@@ -3935,7 +4095,7 @@ function trackReference(referencePath, binding) {
3935
4095
  let propPath = binding.name;
3936
4096
  while (true) {
3937
4097
  const { parent } = root;
3938
- if (!import_compiler22.types.isMemberExpression(parent)) break;
4098
+ if (!import_compiler23.types.isMemberExpression(parent)) break;
3939
4099
  const prop = getMemberExpressionPropString(parent);
3940
4100
  if (prop === void 0) break;
3941
4101
  if (reference.propertyAliases.has(prop)) {
@@ -4087,10 +4247,10 @@ function finalizeReferences() {
4087
4247
  for (let j = i + 1; j < numReferences; j++) {
4088
4248
  const binding1 = intersection[i];
4089
4249
  const binding2 = intersection[j];
4090
- if (!binding1.serialize && !isSuperset(binding1.sources, binding2.sources)) {
4250
+ if (!binding1.serialize && !bindingUtil.isSuperset(binding1.sources, binding2.sources)) {
4091
4251
  binding1.serialize = true;
4092
4252
  }
4093
- if (!binding2.serialize && !isSuperset(binding2.sources, binding1.sources)) {
4253
+ if (!binding2.serialize && !bindingUtil.isSuperset(binding2.sources, binding1.sources)) {
4094
4254
  binding2.serialize = true;
4095
4255
  }
4096
4256
  }
@@ -4102,7 +4262,7 @@ function finalizeReferences() {
4102
4262
  let serialize = false;
4103
4263
  const sourceSection = binding.section;
4104
4264
  let currentSection = section;
4105
- while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || isStatefulReferences(
4265
+ while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || !!getDynamicSourcesForReferences(
4106
4266
  currentSection.upstreamExpression.referencedBindings
4107
4267
  ))) {
4108
4268
  currentSection = currentSection.parent;
@@ -4143,28 +4303,21 @@ function getMaxOwnSourceOffset(intersection, section) {
4143
4303
  let scopeOffset;
4144
4304
  for (const binding of intersection) {
4145
4305
  if (binding.section === section) {
4146
- for (const sourceBinding of binding.sources) {
4147
- if (sourceBinding.scopeOffset && (!scopeOffset || scopeOffset.id < sourceBinding.scopeOffset.id)) {
4148
- scopeOffset = sourceBinding.scopeOffset;
4306
+ forEach(binding.sources, (source) => {
4307
+ if (source.scopeOffset && (!scopeOffset || scopeOffset.id < source.scopeOffset.id)) {
4308
+ scopeOffset = source.scopeOffset;
4149
4309
  }
4150
- }
4310
+ });
4151
4311
  }
4152
4312
  }
4153
4313
  return scopeOffset;
4154
4314
  }
4155
4315
  var intersectionMeta = /* @__PURE__ */ new WeakMap();
4156
- function isSuperset(set, subset) {
4157
- for (const elem of subset) {
4158
- if (!set.has(elem)) {
4159
- return false;
4160
- }
4161
- }
4162
- return true;
4163
- }
4164
4316
  function resolveBindingSources(binding) {
4165
4317
  const derived = /* @__PURE__ */ new Set();
4166
- const { sources } = binding;
4318
+ let sources;
4167
4319
  crawl(binding);
4320
+ binding.sources = sources;
4168
4321
  function crawl(binding2) {
4169
4322
  if (binding2.type === 4 /* derived */ || binding2.type === 3 /* param */) {
4170
4323
  let alias;
@@ -4177,12 +4330,12 @@ function resolveBindingSources(binding) {
4177
4330
  derived.add(curBinding);
4178
4331
  forEach(curBinding.upstreamExpression.referencedBindings, crawl);
4179
4332
  } else if (curBinding.type === 2 /* input */) {
4180
- sources.add(binding2);
4333
+ sources = bindingUtil.add(sources, binding2);
4181
4334
  } else {
4182
- sources.add(curBinding);
4335
+ sources = bindingUtil.add(sources, curBinding);
4183
4336
  }
4184
4337
  } else {
4185
- sources.add(binding2);
4338
+ sources = bindingUtil.add(sources, binding2);
4186
4339
  }
4187
4340
  }
4188
4341
  }
@@ -4242,9 +4395,9 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
4242
4395
  }
4243
4396
  function getScopeAccessorLiteral(binding, includeId) {
4244
4397
  if (isOptimize()) {
4245
- return import_compiler22.types.numericLiteral(binding.id);
4398
+ return import_compiler23.types.numericLiteral(binding.id);
4246
4399
  }
4247
- return import_compiler22.types.stringLiteral(
4400
+ return import_compiler23.types.stringLiteral(
4248
4401
  binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "")
4249
4402
  );
4250
4403
  }
@@ -4259,7 +4412,7 @@ function getSectionInstancesAccessor(section) {
4259
4412
  }
4260
4413
  function getSectionInstancesAccessorLiteral(section) {
4261
4414
  const accessor = getSectionInstancesAccessor(section);
4262
- 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;
4263
4416
  }
4264
4417
  function getReadReplacement(node) {
4265
4418
  const { extra } = node;
@@ -4277,18 +4430,18 @@ function getReadReplacement(node) {
4277
4430
  if (binding) {
4278
4431
  if (node.type === "Identifier") {
4279
4432
  if (binding.type === 5 /* hoist */) {
4280
- replacement = node.extra?.[kIsInvoked] ? import_compiler22.types.callExpression(getHoistFunctionIdentifier(binding), [
4433
+ replacement = node.extra?.[kIsInvoked] ? import_compiler23.types.callExpression(getHoistFunctionIdentifier(binding), [
4281
4434
  getScopeExpression(node.extra.section, binding.section)
4282
- ]) : import_compiler22.types.identifier(getScopeAccessor(binding));
4435
+ ]) : import_compiler23.types.identifier(getScopeAccessor(binding));
4283
4436
  } else if (binding.name !== node.name) {
4284
4437
  node.name = binding.name;
4285
4438
  }
4286
4439
  } else {
4287
- replacement = import_compiler22.types.identifier(binding.name);
4440
+ replacement = import_compiler23.types.identifier(binding.name);
4288
4441
  }
4289
4442
  } else if (read) {
4290
4443
  replacement = toMemberExpression(
4291
- import_compiler22.types.identifier(read.binding.name),
4444
+ import_compiler23.types.identifier(read.binding.name),
4292
4445
  Array.isArray(read.props) ? read.props[0] : read.props
4293
4446
  );
4294
4447
  if (Array.isArray(read.props)) {
@@ -4404,31 +4557,6 @@ function isRegisteredFnExtra(extra) {
4404
4557
  return isReferencedExtra(extra) && extra.registerId !== void 0;
4405
4558
  }
4406
4559
 
4407
- // src/translator/util/is-stateful.ts
4408
- function isStatefulReferences(referencedBindings) {
4409
- if (referencedBindings) {
4410
- if (Array.isArray(referencedBindings)) {
4411
- for (const ref of referencedBindings) {
4412
- if (isStatefulBinding(ref)) {
4413
- return true;
4414
- }
4415
- }
4416
- } else {
4417
- return isStatefulBinding(referencedBindings);
4418
- }
4419
- }
4420
- return false;
4421
- }
4422
- function isStatefulBinding(binding) {
4423
- switch (binding.type) {
4424
- case 1 /* let */:
4425
- case 2 /* input */:
4426
- return true;
4427
- default:
4428
- return binding.upstreamAlias ? isStatefulBinding(binding.upstreamAlias) : !binding.upstreamExpression || isStatefulReferences(binding.upstreamExpression.referencedBindings);
4429
- }
4430
- }
4431
-
4432
4560
  // src/translator/core/await.ts
4433
4561
  var kDOMBinding = Symbol("await tag dom binding");
4434
4562
  var await_default = {
@@ -4452,7 +4580,7 @@ var await_default = {
4452
4580
  if (!valueAttr) {
4453
4581
  throw tag.get("name").buildCodeFrameError("The `await` tag requires a value.");
4454
4582
  }
4455
- 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") {
4456
4584
  throw tag.get("name").buildCodeFrameError(
4457
4585
  "The `await` tag only supports the `value` attribute."
4458
4586
  );
@@ -4460,12 +4588,12 @@ var await_default = {
4460
4588
  if (!node.body.body.length) {
4461
4589
  throw tag.get("name").buildCodeFrameError("The `await` tag requires body content.");
4462
4590
  }
4463
- 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]))) {
4464
4592
  throw tag.get("name").buildCodeFrameError(
4465
4593
  "The `await` tag only supports a single parameter."
4466
4594
  );
4467
4595
  }
4468
- startSection(tagBody);
4596
+ const bodySection = startSection(tagBody);
4469
4597
  getOrCreateSection(tag);
4470
4598
  trackParamsReferences(
4471
4599
  tagBody,
@@ -4473,6 +4601,7 @@ var await_default = {
4473
4601
  void 0,
4474
4602
  evaluate(valueAttr.value)
4475
4603
  );
4604
+ bodySection.upstreamExpression = valueAttr.value.extra;
4476
4605
  },
4477
4606
  translate: translateByTarget({
4478
4607
  html: {
@@ -4493,20 +4622,16 @@ var await_default = {
4493
4622
  const nodeRef2 = tagExtra[kDOMBinding];
4494
4623
  const tagBody = tag.get("body");
4495
4624
  const section = getSection(tag);
4496
- const bodySection = getSectionForBody(tagBody);
4497
- if (isStatefulReferences(valueAttr.extra?.referencedBindings) || checkStatefulClosures(bodySection, true)) {
4498
- setForceResumeScope(bodySection);
4499
- }
4500
4625
  flushInto(tag);
4501
4626
  writeHTMLResumeStatements(tagBody);
4502
4627
  tag.replaceWith(
4503
- import_compiler23.types.expressionStatement(
4628
+ import_compiler24.types.expressionStatement(
4504
4629
  callRuntime(
4505
4630
  "fork",
4506
4631
  getScopeIdIdentifier(section),
4507
4632
  getScopeAccessorLiteral(nodeRef2),
4508
4633
  valueAttr.value,
4509
- import_compiler23.types.arrowFunctionExpression(
4634
+ import_compiler24.types.arrowFunctionExpression(
4510
4635
  node.body.params,
4511
4636
  toFirstExpressionOrBlock(node.body.body)
4512
4637
  )
@@ -4538,12 +4663,12 @@ var await_default = {
4538
4663
  return callRuntime(
4539
4664
  "awaitTag",
4540
4665
  getScopeAccessorLiteral(nodeRef2),
4541
- import_compiler23.types.identifier(bodySection.name)
4666
+ import_compiler24.types.identifier(bodySection.name)
4542
4667
  );
4543
4668
  };
4544
4669
  addValue(
4545
4670
  section,
4546
- tag.node.attributes[0].value.extra?.referencedBindings,
4671
+ bodySection.upstreamExpression?.referencedBindings,
4547
4672
  signal,
4548
4673
  tag.node.attributes[0].value
4549
4674
  );
@@ -4562,7 +4687,7 @@ var await_default = {
4562
4687
  };
4563
4688
 
4564
4689
  // src/translator/core/client.ts
4565
- var import_compiler24 = require("@marko/compiler");
4690
+ var import_compiler25 = require("@marko/compiler");
4566
4691
  var import_babel_utils13 = require("@marko/compiler/babel-utils");
4567
4692
  var client_default = {
4568
4693
  parse(tag) {
@@ -4574,10 +4699,10 @@ var client_default = {
4574
4699
  const code = rawValue.replace(/^client\s*/, "").trim();
4575
4700
  const start = node.name.start + (rawValue.length - code.length);
4576
4701
  let body = (0, import_babel_utils13.parseStatements)(file, code, start, start + code.length);
4577
- if (body.length === 1 && import_compiler24.types.isBlockStatement(body[0])) {
4702
+ if (body.length === 1 && import_compiler25.types.isBlockStatement(body[0])) {
4578
4703
  body = body[0].body;
4579
4704
  }
4580
- tag.replaceWith(import_compiler24.types.markoScriptlet(body, true, "client"));
4705
+ tag.replaceWith(import_compiler25.types.markoScriptlet(body, true, "client"));
4581
4706
  },
4582
4707
  parseOptions: {
4583
4708
  statement: true,
@@ -4593,11 +4718,11 @@ var client_default = {
4593
4718
  };
4594
4719
 
4595
4720
  // src/translator/core/const.ts
4596
- var import_compiler26 = require("@marko/compiler");
4721
+ var import_compiler27 = require("@marko/compiler");
4597
4722
  var import_babel_utils14 = require("@marko/compiler/babel-utils");
4598
4723
 
4599
4724
  // src/translator/util/translate-var.ts
4600
- var import_compiler25 = require("@marko/compiler");
4725
+ var import_compiler26 = require("@marko/compiler");
4601
4726
  function translateVar(tag, initialValue, kind = "const") {
4602
4727
  const {
4603
4728
  node: { var: tagVar }
@@ -4606,7 +4731,7 @@ function translateVar(tag, initialValue, kind = "const") {
4606
4731
  return;
4607
4732
  }
4608
4733
  tag.insertBefore(
4609
- import_compiler25.types.variableDeclaration(kind, [import_compiler25.types.variableDeclarator(tagVar, initialValue)])
4734
+ import_compiler26.types.variableDeclaration(kind, [import_compiler26.types.variableDeclarator(tagVar, initialValue)])
4610
4735
  );
4611
4736
  }
4612
4737
 
@@ -4624,12 +4749,12 @@ var const_default = {
4624
4749
  if (!valueAttr) {
4625
4750
  throw tag.get("name").buildCodeFrameError("The `const` tag requires a value.");
4626
4751
  }
4627
- 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") {
4628
4753
  throw tag.get("name").buildCodeFrameError(
4629
4754
  "The `const` tag only supports the `value` attribute."
4630
4755
  );
4631
4756
  }
4632
- 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;
4633
4758
  trackVarReferences(
4634
4759
  tag,
4635
4760
  4 /* derived */,
@@ -4670,7 +4795,7 @@ var const_default = {
4670
4795
  };
4671
4796
 
4672
4797
  // src/translator/core/debug.ts
4673
- var import_compiler27 = require("@marko/compiler");
4798
+ var import_compiler28 = require("@marko/compiler");
4674
4799
  var import_babel_utils15 = require("@marko/compiler/babel-utils");
4675
4800
  var debug_default = {
4676
4801
  analyze(tag) {
@@ -4679,7 +4804,7 @@ var debug_default = {
4679
4804
  (0, import_babel_utils15.assertNoArgs)(tag);
4680
4805
  (0, import_babel_utils15.assertNoParams)(tag);
4681
4806
  assertNoBodyContent(tag);
4682
- 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")) {
4683
4808
  throw tag.get("name").buildCodeFrameError(
4684
4809
  "The `debug` tag only supports the `value` attribute."
4685
4810
  );
@@ -4690,7 +4815,7 @@ var debug_default = {
4690
4815
  const section = getSection(tag);
4691
4816
  const [valueAttr] = tag.node.attributes;
4692
4817
  const referencedBindings = valueAttr?.value.extra?.referencedBindings;
4693
- const statement = withPreviousLocation(import_compiler27.types.debuggerStatement(), tag.node);
4818
+ const statement = withPreviousLocation(import_compiler28.types.debuggerStatement(), tag.node);
4694
4819
  if (isOutputHTML()) {
4695
4820
  tag.insertBefore(statement);
4696
4821
  } else {
@@ -4713,11 +4838,11 @@ var debug_default = {
4713
4838
  };
4714
4839
 
4715
4840
  // src/translator/core/define.ts
4716
- var import_compiler33 = require("@marko/compiler");
4841
+ var import_compiler34 = require("@marko/compiler");
4717
4842
  var import_babel_utils21 = require("@marko/compiler/babel-utils");
4718
4843
 
4719
4844
  // src/translator/util/nested-attribute-tags.ts
4720
- var import_compiler28 = require("@marko/compiler");
4845
+ var import_compiler29 = require("@marko/compiler");
4721
4846
  var import_babel_utils16 = require("@marko/compiler/babel-utils");
4722
4847
  var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
4723
4848
  function getAttrTagIdentifier(meta) {
@@ -4726,7 +4851,7 @@ function getAttrTagIdentifier(meta) {
4726
4851
  name2 = currentProgramPath.scope.generateUid(meta.name);
4727
4852
  attrTagToIdentifierLookup.set(meta, name2);
4728
4853
  }
4729
- return import_compiler28.types.identifier(name2);
4854
+ return import_compiler29.types.identifier(name2);
4730
4855
  }
4731
4856
  function analyzeAttributeTags(tag) {
4732
4857
  if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
@@ -4839,19 +4964,19 @@ function getConditionRoot(tag) {
4839
4964
  }
4840
4965
 
4841
4966
  // src/translator/util/translate-attrs.ts
4842
- var import_compiler32 = require("@marko/compiler");
4967
+ var import_compiler33 = require("@marko/compiler");
4843
4968
  var import_babel_utils20 = require("@marko/compiler/babel-utils");
4844
4969
 
4845
4970
  // src/translator/core/for.ts
4846
- var import_compiler31 = require("@marko/compiler");
4971
+ var import_compiler32 = require("@marko/compiler");
4847
4972
  var import_babel_utils19 = require("@marko/compiler/babel-utils");
4848
4973
 
4849
4974
  // src/translator/util/is-only-child-in-parent.ts
4850
- var import_compiler30 = require("@marko/compiler");
4975
+ var import_compiler31 = require("@marko/compiler");
4851
4976
  var import_babel_utils18 = require("@marko/compiler/babel-utils");
4852
4977
 
4853
4978
  // src/translator/visitors/tag/native-tag.ts
4854
- var import_compiler29 = require("@marko/compiler");
4979
+ var import_compiler30 = require("@marko/compiler");
4855
4980
  var import_babel_utils17 = require("@marko/compiler/babel-utils");
4856
4981
  var kNativeTagBinding = Symbol("native tag binding");
4857
4982
  var kSerializeMarker = Symbol("serialize marker");
@@ -4943,7 +5068,7 @@ var native_tag_default = {
4943
5068
  }
4944
5069
  }
4945
5070
  tag.node.attributes.push(
4946
- import_compiler29.types.markoAttribute(
5071
+ import_compiler30.types.markoAttribute(
4947
5072
  "value",
4948
5073
  normalizeStringExpression(parts) || buildUndefined()
4949
5074
  )
@@ -4958,7 +5083,7 @@ var native_tag_default = {
4958
5083
  (0, import_babel_utils17.assertNoParams)(tag);
4959
5084
  (0, import_babel_utils17.assertNoAttributeTags)(tag);
4960
5085
  const { node } = tag;
4961
- if (node.var && !import_compiler29.types.isIdentifier(node.var)) {
5086
+ if (node.var && !import_compiler30.types.isIdentifier(node.var)) {
4962
5087
  throw tag.get("var").buildCodeFrameError(
4963
5088
  "Tag variables on native elements cannot be destructured."
4964
5089
  );
@@ -4973,7 +5098,7 @@ var native_tag_default = {
4973
5098
  let spreadReferenceNodes;
4974
5099
  for (let i = attributes.length; i--; ) {
4975
5100
  const attr2 = attributes[i];
4976
- if (import_compiler29.types.isMarkoAttribute(attr2)) {
5101
+ if (import_compiler30.types.isMarkoAttribute(attr2)) {
4977
5102
  if (seen[attr2.name]) {
4978
5103
  dropReferences(attr2.value);
4979
5104
  continue;
@@ -4985,14 +5110,14 @@ var native_tag_default = {
4985
5110
  } else if (!evaluate(attr2.value).confident) {
4986
5111
  hasDynamicAttributes = true;
4987
5112
  }
4988
- } else if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5113
+ } else if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
4989
5114
  hasEventHandlers = true;
4990
5115
  hasDynamicAttributes = true;
4991
5116
  (attr2.value.extra ??= {}).isEffect = true;
4992
5117
  }
4993
5118
  if (spreadReferenceNodes) {
4994
5119
  spreadReferenceNodes.push(attr2.value);
4995
- } else if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5120
+ } else if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
4996
5121
  spreadReferenceNodes = [attr2.value];
4997
5122
  relatedControllable = getRelatedControllable(tagName, seen);
4998
5123
  }
@@ -5020,7 +5145,7 @@ var native_tag_default = {
5020
5145
  }
5021
5146
  if (node.var || hasEventHandlers || hasDynamicAttributes) {
5022
5147
  currentProgramPath.node.extra.isInteractive ||= hasEventHandlers;
5023
- 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"));
5024
5149
  const tagExtra = node.extra ??= {};
5025
5150
  const bindingName = "#" + tagName2;
5026
5151
  if (hasEventHandlers || node.var) {
@@ -5073,13 +5198,13 @@ var native_tag_default = {
5073
5198
  serializeOwners(referenceSection, section);
5074
5199
  }
5075
5200
  }
5076
- setForceResumeScope(section);
5201
+ serializeSectionIfNeeded(section, true);
5077
5202
  translateVar(
5078
5203
  tag,
5079
5204
  callRuntime(
5080
5205
  "nodeRef",
5081
5206
  getterId && getScopeIdIdentifier(section),
5082
- getterId && import_compiler29.types.stringLiteral(getterId)
5207
+ getterId && import_compiler30.types.stringLiteral(getterId)
5083
5208
  )
5084
5209
  );
5085
5210
  } else {
@@ -5090,13 +5215,13 @@ var native_tag_default = {
5090
5215
  );
5091
5216
  currentProgramPath.pushContainer(
5092
5217
  "body",
5093
- import_compiler29.types.variableDeclaration("const", [
5094
- import_compiler29.types.variableDeclarator(
5218
+ import_compiler30.types.variableDeclaration("const", [
5219
+ import_compiler30.types.variableDeclarator(
5095
5220
  getterFnIdentifier,
5096
5221
  callRuntime(
5097
5222
  "nodeRef",
5098
- import_compiler29.types.stringLiteral(getterId),
5099
- import_compiler29.types.stringLiteral(
5223
+ import_compiler30.types.stringLiteral(getterId),
5224
+ import_compiler30.types.stringLiteral(
5100
5225
  getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
5101
5226
  )
5102
5227
  )
@@ -5109,22 +5234,22 @@ var native_tag_default = {
5109
5234
  const referenceSection = getSection(reference);
5110
5235
  if (isInvokedFunction(reference)) {
5111
5236
  reference.parentPath.replaceWith(
5112
- import_compiler29.types.expressionStatement(
5237
+ import_compiler30.types.expressionStatement(
5113
5238
  createScopeReadExpression(referenceSection, nodeRef2)
5114
5239
  )
5115
5240
  );
5116
5241
  } else if (getterFnIdentifier) {
5117
5242
  reference.replaceWith(
5118
- import_compiler29.types.callExpression(getterFnIdentifier, [
5243
+ import_compiler30.types.callExpression(getterFnIdentifier, [
5119
5244
  getScopeExpression(referenceSection, getSection(tag))
5120
5245
  ])
5121
5246
  );
5122
5247
  } else {
5123
5248
  reference.replaceWith(
5124
- import_compiler29.types.expressionStatement(
5125
- import_compiler29.types.memberExpression(
5249
+ import_compiler30.types.expressionStatement(
5250
+ import_compiler30.types.memberExpression(
5126
5251
  getScopeExpression(section, referenceSection),
5127
- import_compiler29.types.stringLiteral(
5252
+ import_compiler30.types.stringLiteral(
5128
5253
  getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
5129
5254
  ),
5130
5255
  true
@@ -5160,7 +5285,7 @@ var native_tag_default = {
5160
5285
  "render",
5161
5286
  section,
5162
5287
  referencedBindings,
5163
- import_compiler29.types.expressionStatement(
5288
+ import_compiler30.types.expressionStatement(
5164
5289
  callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
5165
5290
  )
5166
5291
  );
@@ -5168,7 +5293,7 @@ var native_tag_default = {
5168
5293
  "effect",
5169
5294
  section,
5170
5295
  void 0,
5171
- import_compiler29.types.expressionStatement(
5296
+ import_compiler30.types.expressionStatement(
5172
5297
  callRuntime(`${helper}_effect`, scopeIdentifier, visitAccessor)
5173
5298
  )
5174
5299
  );
@@ -5185,18 +5310,18 @@ var native_tag_default = {
5185
5310
  } else if (spreadExpression) {
5186
5311
  const spreadIdentifier = tag.scope.generateUidIdentifier("select_input");
5187
5312
  tag.insertBefore(
5188
- import_compiler29.types.variableDeclaration("const", [
5189
- import_compiler29.types.variableDeclarator(spreadIdentifier, spreadExpression)
5313
+ import_compiler30.types.variableDeclaration("const", [
5314
+ import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
5190
5315
  ])
5191
5316
  );
5192
5317
  htmlSelectArgs.set(tag.node, {
5193
- value: import_compiler29.types.memberExpression(
5318
+ value: import_compiler30.types.memberExpression(
5194
5319
  spreadIdentifier,
5195
- import_compiler29.types.identifier("value")
5320
+ import_compiler30.types.identifier("value")
5196
5321
  ),
5197
- valueChange: import_compiler29.types.memberExpression(
5322
+ valueChange: import_compiler30.types.memberExpression(
5198
5323
  spreadIdentifier,
5199
- import_compiler29.types.identifier("valueChange")
5324
+ import_compiler30.types.identifier("valueChange")
5200
5325
  )
5201
5326
  });
5202
5327
  spreadExpression = spreadIdentifier;
@@ -5210,14 +5335,14 @@ var native_tag_default = {
5210
5335
  } else if (spreadExpression) {
5211
5336
  const spreadIdentifier = tag.scope.generateUidIdentifier("textarea_input");
5212
5337
  tag.insertBefore(
5213
- import_compiler29.types.variableDeclaration("const", [
5214
- import_compiler29.types.variableDeclarator(spreadIdentifier, spreadExpression)
5338
+ import_compiler30.types.variableDeclaration("const", [
5339
+ import_compiler30.types.variableDeclarator(spreadIdentifier, spreadExpression)
5215
5340
  ])
5216
5341
  );
5217
- value = import_compiler29.types.memberExpression(spreadIdentifier, import_compiler29.types.identifier("value"));
5218
- valueChange = import_compiler29.types.memberExpression(
5342
+ value = import_compiler30.types.memberExpression(spreadIdentifier, import_compiler30.types.identifier("value"));
5343
+ valueChange = import_compiler30.types.memberExpression(
5219
5344
  spreadIdentifier,
5220
- import_compiler29.types.identifier("valueChange")
5345
+ import_compiler30.types.identifier("valueChange")
5221
5346
  );
5222
5347
  spreadExpression = spreadIdentifier;
5223
5348
  }
@@ -5253,10 +5378,10 @@ var native_tag_default = {
5253
5378
  "render",
5254
5379
  section,
5255
5380
  valueReferences,
5256
- import_compiler29.types.expressionStatement(
5381
+ import_compiler30.types.expressionStatement(
5257
5382
  callRuntime(
5258
5383
  helper,
5259
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5384
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5260
5385
  value
5261
5386
  )
5262
5387
  )
@@ -5271,18 +5396,18 @@ var native_tag_default = {
5271
5396
  if (isEventHandler(name3)) {
5272
5397
  addHTMLEffectCall(section, valueReferences);
5273
5398
  } else {
5274
- write2`${callRuntime("attr", import_compiler29.types.stringLiteral(name3), value)}`;
5399
+ write2`${callRuntime("attr", import_compiler30.types.stringLiteral(name3), value)}`;
5275
5400
  }
5276
5401
  } else if (isEventHandler(name3)) {
5277
5402
  addStatement(
5278
5403
  "effect",
5279
5404
  section,
5280
5405
  valueReferences,
5281
- import_compiler29.types.expressionStatement(
5406
+ import_compiler30.types.expressionStatement(
5282
5407
  callRuntime(
5283
5408
  "on",
5284
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5285
- import_compiler29.types.stringLiteral(getEventHandlerName(name3)),
5409
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5410
+ import_compiler30.types.stringLiteral(getEventHandlerName(name3)),
5286
5411
  value
5287
5412
  )
5288
5413
  )
@@ -5292,11 +5417,11 @@ var native_tag_default = {
5292
5417
  "render",
5293
5418
  section,
5294
5419
  valueReferences,
5295
- import_compiler29.types.expressionStatement(
5420
+ import_compiler30.types.expressionStatement(
5296
5421
  callRuntime(
5297
5422
  "attr",
5298
- import_compiler29.types.memberExpression(scopeIdentifier, visitAccessor, true),
5299
- import_compiler29.types.stringLiteral(name3),
5423
+ import_compiler30.types.memberExpression(scopeIdentifier, visitAccessor, true),
5424
+ import_compiler30.types.stringLiteral(name3),
5300
5425
  value
5301
5426
  )
5302
5427
  )
@@ -5319,7 +5444,7 @@ var native_tag_default = {
5319
5444
  "render",
5320
5445
  section,
5321
5446
  extra.referencedBindings,
5322
- import_compiler29.types.expressionStatement(
5447
+ import_compiler30.types.expressionStatement(
5323
5448
  callRuntime(
5324
5449
  "partialAttrs",
5325
5450
  scopeIdentifier,
@@ -5334,7 +5459,7 @@ var native_tag_default = {
5334
5459
  "render",
5335
5460
  section,
5336
5461
  extra.referencedBindings,
5337
- import_compiler29.types.expressionStatement(
5462
+ import_compiler30.types.expressionStatement(
5338
5463
  callRuntime(
5339
5464
  "attrs",
5340
5465
  scopeIdentifier,
@@ -5348,7 +5473,7 @@ var native_tag_default = {
5348
5473
  "effect",
5349
5474
  section,
5350
5475
  extra.referencedBindings,
5351
- import_compiler29.types.expressionStatement(
5476
+ import_compiler30.types.expressionStatement(
5352
5477
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
5353
5478
  ),
5354
5479
  false
@@ -5369,7 +5494,7 @@ var native_tag_default = {
5369
5494
  write2`>`;
5370
5495
  }
5371
5496
  if (isHTML && extra.tagNameNullable) {
5372
- 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();
5373
5498
  }
5374
5499
  if (writeAtStartOfBody) {
5375
5500
  write2`${writeAtStartOfBody}`;
@@ -5390,16 +5515,16 @@ var native_tag_default = {
5390
5515
  writeTo(tag)`</${tag.node.name}>`;
5391
5516
  flushInto(tag);
5392
5517
  tag.insertBefore(
5393
- import_compiler29.types.expressionStatement(
5518
+ import_compiler30.types.expressionStatement(
5394
5519
  callRuntime(
5395
5520
  "controllable_select_value",
5396
5521
  getScopeIdIdentifier(getSection(tag)),
5397
5522
  getScopeAccessorLiteral(nodeRef2),
5398
5523
  selectArgs.value,
5399
5524
  selectArgs.valueChange,
5400
- import_compiler29.types.arrowFunctionExpression(
5525
+ import_compiler30.types.arrowFunctionExpression(
5401
5526
  [],
5402
- import_compiler29.types.blockStatement(tag.node.body.body)
5527
+ import_compiler30.types.blockStatement(tag.node.body.body)
5403
5528
  )
5404
5529
  )
5405
5530
  )
@@ -5407,9 +5532,14 @@ var native_tag_default = {
5407
5532
  } else {
5408
5533
  tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
5409
5534
  }
5410
- const shouldMark = nodeRef2 && (extra[kSerializeMarker] || extra[kSerializeMarker] === void 0 && (isStatefulReferences(extra.referencedBindings) || tag.node.attributes.some(
5411
- (attr2) => isStatefulReferences(attr2.value.extra?.referencedBindings)
5412
- )));
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);
5413
5543
  if (!openTagOnly && !selectArgs) {
5414
5544
  writeTo(
5415
5545
  tag,
@@ -5418,7 +5548,7 @@ var native_tag_default = {
5418
5548
  }
5419
5549
  if (isHTML && extra.tagNameNullable) {
5420
5550
  tag.insertBefore(
5421
- import_compiler29.types.ifStatement(tag.node.name, consumeHTML(tag))
5551
+ import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
5422
5552
  )[0].skip();
5423
5553
  }
5424
5554
  if (shouldMark) {
@@ -5441,7 +5571,7 @@ function getUsedAttrs(tagName, tag) {
5441
5571
  for (let i = attributes.length; i--; ) {
5442
5572
  const attr2 = attributes[i];
5443
5573
  const { value } = attr2;
5444
- if (import_compiler29.types.isMarkoSpreadAttribute(attr2)) {
5574
+ if (import_compiler30.types.isMarkoSpreadAttribute(attr2)) {
5445
5575
  if (!spreadProps) {
5446
5576
  spreadProps = [];
5447
5577
  staticControllable = getRelatedControllable(tagName, seen);
@@ -5455,7 +5585,7 @@ function getUsedAttrs(tagName, tag) {
5455
5585
  staticControllable = void 0;
5456
5586
  }
5457
5587
  }
5458
- spreadProps.push(import_compiler29.types.spreadElement(value));
5588
+ spreadProps.push(import_compiler30.types.spreadElement(value));
5459
5589
  } else if (!seen[attr2.name]) {
5460
5590
  seen[attr2.name] = attr2;
5461
5591
  if (spreadProps) {
@@ -5485,16 +5615,16 @@ function getUsedAttrs(tagName, tag) {
5485
5615
  for (const attr2 of staticControllable.attrs) {
5486
5616
  if (attr2) {
5487
5617
  (skipProps ||= []).push(
5488
- toObjectProperty(attr2.name, import_compiler29.types.numericLiteral(1))
5618
+ toObjectProperty(attr2.name, import_compiler30.types.numericLiteral(1))
5489
5619
  );
5490
5620
  }
5491
5621
  }
5492
5622
  }
5493
5623
  for (const { name: name2 } of staticAttrs) {
5494
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler29.types.numericLiteral(1)));
5624
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler30.types.numericLiteral(1)));
5495
5625
  }
5496
5626
  if (skipProps) {
5497
- skipExpression = import_compiler29.types.objectExpression(skipProps);
5627
+ skipExpression = import_compiler30.types.objectExpression(skipProps);
5498
5628
  }
5499
5629
  spreadExpression = propsToExpression(spreadProps);
5500
5630
  }
@@ -5509,7 +5639,7 @@ function isChangeHandler(propName) {
5509
5639
  return /^(?:value|checked(?:Value)?|open)Change/.test(propName);
5510
5640
  }
5511
5641
  function buildUndefined() {
5512
- return import_compiler29.types.unaryExpression("void", import_compiler29.types.numericLiteral(0));
5642
+ return import_compiler30.types.unaryExpression("void", import_compiler30.types.numericLiteral(0));
5513
5643
  }
5514
5644
 
5515
5645
  // src/translator/util/is-only-child-in-parent.ts
@@ -5612,8 +5742,6 @@ var for_default = {
5612
5742
  const tagSection = getSection(tag);
5613
5743
  const bodySection = getSectionForBody(tagBody);
5614
5744
  const { node } = tag;
5615
- const tagExtra = node.extra;
5616
- const isStateful = isStatefulReferences(tagExtra.referencedBindings);
5617
5745
  const onlyChildInParentOptimization = isOnlyChildInParent(tag);
5618
5746
  const nodeRef2 = getOptimizedOnlyChildNodeRef(tag, tagSection);
5619
5747
  const forAttrs = getKnownAttrValues(node);
@@ -5621,14 +5749,16 @@ var for_default = {
5621
5749
  const params = node.body.params;
5622
5750
  const statements = [];
5623
5751
  const bodyStatements = node.body.body;
5624
- const hasStatefulClosures = checkStatefulClosures(bodySection, true);
5625
- const hasHoists = bodySection.hoisted || bodySection.isHoistThrough || bodySection.referencedHoists;
5752
+ const sectionSources = getDynamicSourcesForSection(bodySection);
5753
+ const hasHoists = isSectionWithHoists(bodySection);
5754
+ const serializeReason = hasHoists || sectionSources?.all;
5626
5755
  const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild && bodySection.content.startType !== 4 /* Text */;
5627
5756
  let keyExpression;
5628
- if (isStateful && onlyChildInParentOptimization) {
5757
+ if (sectionSources?.referenced && onlyChildInParentOptimization) {
5629
5758
  getParentTag(tag).node.extra[kSerializeMarker] = false;
5630
5759
  }
5631
- if (isStateful || hasStatefulClosures || hasHoists) {
5760
+ if (serializeReason) {
5761
+ serializeSectionIfNeeded(bodySection, serializeReason);
5632
5762
  const defaultParamNames = {
5633
5763
  of: ["list", "index"],
5634
5764
  in: ["key", "value"],
@@ -5636,36 +5766,35 @@ var for_default = {
5636
5766
  }[forType];
5637
5767
  const defaultByParamIndex = forType === "of" ? 1 : 0;
5638
5768
  const requiredParamsIndex = forAttrs.by ? defaultParamNames.length - 1 : defaultByParamIndex;
5639
- setForceResumeScope(bodySection);
5640
5769
  for (let i = 0; i <= requiredParamsIndex; i++) {
5641
5770
  const existingParam = params[i];
5642
- if (!existingParam || !import_compiler31.types.isIdentifier(existingParam)) {
5771
+ if (!existingParam || !import_compiler32.types.isIdentifier(existingParam)) {
5643
5772
  const id = params[i] = currentProgramPath.scope.generateUidIdentifier(
5644
5773
  defaultParamNames[i]
5645
5774
  );
5646
5775
  if (existingParam) {
5647
5776
  bodyStatements.unshift(
5648
- import_compiler31.types.variableDeclaration("let", [
5649
- import_compiler31.types.variableDeclarator(existingParam, id)
5777
+ import_compiler32.types.variableDeclaration("let", [
5778
+ import_compiler32.types.variableDeclarator(existingParam, id)
5650
5779
  ])
5651
5780
  );
5652
5781
  }
5653
5782
  }
5654
5783
  }
5655
5784
  if (forAttrs.by) {
5656
- if (import_compiler31.types.isStringLiteral(forAttrs.by)) {
5785
+ if (import_compiler32.types.isStringLiteral(forAttrs.by)) {
5657
5786
  keyExpression = toMemberExpression(
5658
5787
  params[0],
5659
5788
  forAttrs.by.value
5660
5789
  );
5661
- } else if (import_compiler31.types.isFunction(forAttrs.by)) {
5790
+ } else if (import_compiler32.types.isFunction(forAttrs.by)) {
5662
5791
  const byIdentifier = currentProgramPath.scope.generateUidIdentifier("by");
5663
5792
  statements.push(
5664
- import_compiler31.types.variableDeclaration("const", [
5665
- import_compiler31.types.variableDeclarator(byIdentifier, forAttrs.by)
5793
+ import_compiler32.types.variableDeclaration("const", [
5794
+ import_compiler32.types.variableDeclarator(byIdentifier, forAttrs.by)
5666
5795
  ])
5667
5796
  );
5668
- keyExpression = import_compiler31.types.callExpression(
5797
+ keyExpression = import_compiler32.types.callExpression(
5669
5798
  byIdentifier,
5670
5799
  params
5671
5800
  );
@@ -5681,57 +5810,56 @@ var for_default = {
5681
5810
  }
5682
5811
  const forScopesIdentifier = getScopeIdentifier(bodySection);
5683
5812
  getHTMLSectionStatements(tagSection).push(
5684
- import_compiler31.types.variableDeclaration("const", [
5685
- import_compiler31.types.variableDeclarator(
5813
+ import_compiler32.types.variableDeclaration("const", [
5814
+ import_compiler32.types.variableDeclarator(
5686
5815
  forScopesIdentifier,
5687
- import_compiler31.types.newExpression(import_compiler31.types.identifier("Map"), [])
5816
+ import_compiler32.types.newExpression(import_compiler32.types.identifier("Map"), [])
5688
5817
  )
5689
5818
  ])
5690
5819
  );
5691
- if (isStateful || hasStatefulClosures || hasHoists) {
5692
- bodyStatements.push(
5693
- import_compiler31.types.expressionStatement(
5694
- import_compiler31.types.callExpression(
5695
- import_compiler31.types.memberExpression(forScopesIdentifier, import_compiler31.types.identifier("set")),
5696
- [
5697
- keyExpression,
5698
- callRuntime(
5699
- "ensureScopeWithId",
5700
- getScopeIdIdentifier(bodySection)
5701
- )
5702
- ]
5703
- )
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
+ ]
5704
5831
  )
5705
- );
5706
- }
5832
+ )
5833
+ );
5707
5834
  setSerializedProperty(
5708
5835
  tagSection,
5709
5836
  getAccessorPrefix().LoopScopeMap + getScopeAccessor(nodeRef2),
5710
- import_compiler31.types.conditionalExpression(
5711
- 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")),
5712
5839
  forScopesIdentifier,
5713
- import_compiler31.types.identifier("undefined")
5714
- )
5840
+ import_compiler32.types.identifier("undefined")
5841
+ ),
5842
+ serializeReason
5715
5843
  );
5716
5844
  }
5717
5845
  flushInto(tag);
5718
5846
  writeHTMLResumeStatements(tagBody);
5719
5847
  const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
5720
- const forTagHTMLRuntime = isStateful ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5848
+ const forTagHTMLRuntime = sectionSources?.referenced ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
5721
5849
  forTagArgs.push(
5722
- import_compiler31.types.arrowFunctionExpression(params, import_compiler31.types.blockStatement(bodyStatements))
5850
+ import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(bodyStatements))
5723
5851
  );
5724
- if (isStateful) {
5852
+ if (sectionSources?.referenced) {
5725
5853
  forTagArgs.push(
5726
5854
  getScopeIdIdentifier(tagSection),
5727
5855
  getScopeAccessorLiteral(nodeRef2)
5728
5856
  );
5729
5857
  if (onlyChildInParentOptimization) {
5730
- forTagArgs.push(import_compiler31.types.numericLiteral(1));
5858
+ forTagArgs.push(import_compiler32.types.numericLiteral(1));
5731
5859
  }
5732
5860
  }
5733
5861
  statements.push(
5734
- import_compiler31.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5862
+ import_compiler32.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
5735
5863
  );
5736
5864
  for (const replacement of tag.replaceWithMultiple(statements)) {
5737
5865
  replacement.skip();
@@ -5776,7 +5904,7 @@ var for_default = {
5776
5904
  return callRuntime(
5777
5905
  forTypeToDOMRuntime(forType),
5778
5906
  getScopeAccessorLiteral(nodeRef2),
5779
- import_compiler31.types.identifier(bodySection.name)
5907
+ import_compiler32.types.identifier(bodySection.name)
5780
5908
  );
5781
5909
  };
5782
5910
  const params = node.body.params;
@@ -5807,7 +5935,7 @@ var for_default = {
5807
5935
  tagSection,
5808
5936
  referencedBindings,
5809
5937
  signal,
5810
- import_compiler31.types.arrayExpression(loopArgs)
5938
+ import_compiler32.types.arrayExpression(loopArgs)
5811
5939
  );
5812
5940
  tag.remove();
5813
5941
  }
@@ -5873,11 +6001,11 @@ var for_default = {
5873
6001
  ]
5874
6002
  };
5875
6003
  function buildForRuntimeCall(type, attrs2, params, statements) {
5876
- return import_compiler31.types.expressionStatement(
6004
+ return import_compiler32.types.expressionStatement(
5877
6005
  callRuntime(
5878
6006
  forTypeToRuntime(type),
5879
6007
  ...getBaseArgsInForTag(type, attrs2),
5880
- import_compiler31.types.arrowFunctionExpression(params, import_compiler31.types.blockStatement(statements))
6008
+ import_compiler32.types.arrowFunctionExpression(params, import_compiler32.types.blockStatement(statements))
5881
6009
  )
5882
6010
  );
5883
6011
  }
@@ -5953,8 +6081,8 @@ function getBaseArgsInForTag(type, attrs2) {
5953
6081
  case "to":
5954
6082
  return [
5955
6083
  attrs2.to,
5956
- attrs2.from || import_compiler31.types.numericLiteral(0),
5957
- attrs2.step || import_compiler31.types.numericLiteral(1)
6084
+ attrs2.from || import_compiler32.types.numericLiteral(0),
6085
+ attrs2.step || import_compiler32.types.numericLiteral(1)
5958
6086
  ];
5959
6087
  }
5960
6088
  }
@@ -5972,8 +6100,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
5972
6100
  seen.add(attrTagMeta.name);
5973
6101
  if (attrTagMeta.dynamic) {
5974
6102
  statements.push(
5975
- import_compiler32.types.variableDeclaration("let", [
5976
- import_compiler32.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
6103
+ import_compiler33.types.variableDeclaration("let", [
6104
+ import_compiler33.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
5977
6105
  ])
5978
6106
  );
5979
6107
  properties.push(
@@ -6055,8 +6183,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
6055
6183
  seen.add(contentKey);
6056
6184
  const contentExpression = buildContent(tag.get("body"));
6057
6185
  if (contentExpression) {
6058
- const contentProp = import_compiler32.types.objectProperty(
6059
- import_compiler32.types.identifier(contentKey),
6186
+ const contentProp = import_compiler33.types.objectProperty(
6187
+ import_compiler33.types.identifier(contentKey),
6060
6188
  contentExpression
6061
6189
  );
6062
6190
  contentProps.add(contentProp);
@@ -6067,8 +6195,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
6067
6195
  for (let i = attributes.length; i--; ) {
6068
6196
  const attr2 = attributes[i];
6069
6197
  const { value } = attr2;
6070
- if (import_compiler32.types.isMarkoSpreadAttribute(attr2)) {
6071
- properties.push(import_compiler32.types.spreadElement(value));
6198
+ if (import_compiler33.types.isMarkoSpreadAttribute(attr2)) {
6199
+ properties.push(import_compiler33.types.spreadElement(value));
6072
6200
  } else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
6073
6201
  seen.add(attr2.name);
6074
6202
  properties.push(toObjectProperty(attr2.name, value));
@@ -6098,8 +6226,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6098
6226
  );
6099
6227
  if (attrTagMeta.repeated) {
6100
6228
  statements.push(
6101
- import_compiler32.types.expressionStatement(
6102
- import_compiler32.types.assignmentExpression(
6229
+ import_compiler33.types.expressionStatement(
6230
+ import_compiler33.types.assignmentExpression(
6103
6231
  "=",
6104
6232
  getAttrTagIdentifier(attrTagMeta),
6105
6233
  callRuntime(
@@ -6112,8 +6240,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6112
6240
  );
6113
6241
  } else {
6114
6242
  statements.push(
6115
- import_compiler32.types.expressionStatement(
6116
- import_compiler32.types.assignmentExpression(
6243
+ import_compiler33.types.expressionStatement(
6244
+ import_compiler33.types.assignmentExpression(
6117
6245
  "=",
6118
6246
  getAttrTagIdentifier(attrTagMeta),
6119
6247
  callRuntime(
@@ -6152,7 +6280,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
6152
6280
  return index;
6153
6281
  }
6154
6282
  function propsToExpression(props) {
6155
- 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);
6156
6284
  }
6157
6285
  function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
6158
6286
  const forTag = attrTags2[index];
@@ -6177,9 +6305,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
6177
6305
  function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
6178
6306
  const ifTag = attrTags2[index];
6179
6307
  const consequentStatements = [];
6180
- let ifStatement = import_compiler32.types.ifStatement(
6308
+ let ifStatement = import_compiler33.types.ifStatement(
6181
6309
  getConditionTestValue(ifTag),
6182
- import_compiler32.types.blockStatement(consequentStatements)
6310
+ import_compiler33.types.blockStatement(consequentStatements)
6183
6311
  );
6184
6312
  statements.push(ifStatement);
6185
6313
  addAllAttrTagsAsDynamic(
@@ -6206,14 +6334,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
6206
6334
  contentKey
6207
6335
  );
6208
6336
  if (testValue) {
6209
- ifStatement.alternate = ifStatement = import_compiler32.types.ifStatement(
6337
+ ifStatement.alternate = ifStatement = import_compiler33.types.ifStatement(
6210
6338
  testValue,
6211
- import_compiler32.types.blockStatement(alternateStatements)
6339
+ import_compiler33.types.blockStatement(alternateStatements)
6212
6340
  );
6213
6341
  nextIndex++;
6214
6342
  continue;
6215
6343
  } else {
6216
- ifStatement.alternate = import_compiler32.types.blockStatement(alternateStatements);
6344
+ ifStatement.alternate = import_compiler33.types.blockStatement(alternateStatements);
6217
6345
  break;
6218
6346
  }
6219
6347
  }
@@ -6270,10 +6398,10 @@ function buildContent(body) {
6270
6398
  const serialized = isSerializedSection(bodySection);
6271
6399
  return callRuntime(
6272
6400
  serialized ? "registerContent" : "createContent",
6273
- import_compiler32.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
6274
- import_compiler32.types.arrowFunctionExpression(
6401
+ import_compiler33.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
6402
+ import_compiler33.types.arrowFunctionExpression(
6275
6403
  body.node.params,
6276
- import_compiler32.types.blockStatement(body.node.body)
6404
+ import_compiler33.types.blockStatement(body.node.body)
6277
6405
  ),
6278
6406
  serialized ? getScopeIdIdentifier(
6279
6407
  getSection(
@@ -6284,7 +6412,7 @@ function buildContent(body) {
6284
6412
  ) : void 0
6285
6413
  );
6286
6414
  } else {
6287
- return import_compiler32.types.callExpression(import_compiler32.types.identifier(bodySection.name), [
6415
+ return import_compiler33.types.callExpression(import_compiler33.types.identifier(bodySection.name), [
6288
6416
  scopeIdentifier
6289
6417
  ]);
6290
6418
  }
@@ -6369,7 +6497,7 @@ var define_default = {
6369
6497
  };
6370
6498
 
6371
6499
  // src/translator/core/effect.ts
6372
- var import_compiler34 = require("@marko/compiler");
6500
+ var import_compiler35 = require("@marko/compiler");
6373
6501
  var import_babel_utils22 = require("@marko/compiler/babel-utils");
6374
6502
  var effect_default = {
6375
6503
  migrate: [
@@ -6385,8 +6513,8 @@ var effect_default = {
6385
6513
  fix() {
6386
6514
  const { node } = tag;
6387
6515
  tag.replaceWith(
6388
- import_compiler34.types.markoTag(
6389
- withPreviousLocation(import_compiler34.types.stringLiteral("script"), node.name),
6516
+ import_compiler35.types.markoTag(
6517
+ withPreviousLocation(import_compiler35.types.stringLiteral("script"), node.name),
6390
6518
  node.attributes,
6391
6519
  node.body,
6392
6520
  node.arguments,
@@ -6423,7 +6551,7 @@ var export_default = {
6423
6551
  };
6424
6552
 
6425
6553
  // src/translator/core/html-comment.ts
6426
- var import_compiler35 = require("@marko/compiler");
6554
+ var import_compiler36 = require("@marko/compiler");
6427
6555
  var import_babel_utils24 = require("@marko/compiler/babel-utils");
6428
6556
  var kCommentTagBinding = Symbol("comment tag binding");
6429
6557
  var kGetterId2 = Symbol("node getter id");
@@ -6436,7 +6564,7 @@ var html_comment_default = {
6436
6564
  let needsBinding = false;
6437
6565
  let needsGetter = false;
6438
6566
  if (tagVar) {
6439
- if (!import_compiler35.types.isIdentifier(tagVar)) {
6567
+ if (!import_compiler36.types.isIdentifier(tagVar)) {
6440
6568
  throw tag.get("var").buildCodeFrameError(
6441
6569
  "The `html-comment` tag variable cannot be destructured."
6442
6570
  );
@@ -6487,7 +6615,7 @@ var html_comment_default = {
6487
6615
  callRuntime(
6488
6616
  "nodeRef",
6489
6617
  getterId && getScopeIdIdentifier(getSection(tag)),
6490
- getterId && import_compiler35.types.stringLiteral(getterId)
6618
+ getterId && import_compiler36.types.stringLiteral(getterId)
6491
6619
  )
6492
6620
  );
6493
6621
  } else {
@@ -6500,12 +6628,12 @@ var html_comment_default = {
6500
6628
  );
6501
6629
  currentProgramPath.pushContainer(
6502
6630
  "body",
6503
- import_compiler35.types.variableDeclaration("const", [
6504
- import_compiler35.types.variableDeclarator(
6631
+ import_compiler36.types.variableDeclaration("const", [
6632
+ import_compiler36.types.variableDeclarator(
6505
6633
  getterFnIdentifier,
6506
6634
  callRuntime(
6507
6635
  "nodeRef",
6508
- import_compiler35.types.stringLiteral(getterId),
6636
+ import_compiler36.types.stringLiteral(getterId),
6509
6637
  getScopeAccessorLiteral(commentBinding)
6510
6638
  )
6511
6639
  )
@@ -6516,13 +6644,13 @@ var html_comment_default = {
6516
6644
  const referenceSection = getSection(reference);
6517
6645
  if (isInvokedFunction(reference)) {
6518
6646
  reference.parentPath.replaceWith(
6519
- import_compiler35.types.expressionStatement(
6647
+ import_compiler36.types.expressionStatement(
6520
6648
  createScopeReadExpression(referenceSection, commentBinding)
6521
6649
  )
6522
6650
  );
6523
6651
  } else if (getterFnIdentifier) {
6524
6652
  reference.replaceWith(
6525
- import_compiler35.types.callExpression(getterFnIdentifier, [
6653
+ import_compiler36.types.callExpression(getterFnIdentifier, [
6526
6654
  getScopeExpression(referenceSection, getSection(tag))
6527
6655
  ])
6528
6656
  );
@@ -6538,9 +6666,9 @@ var html_comment_default = {
6538
6666
  write2`<!--`;
6539
6667
  if (isOutputHTML()) {
6540
6668
  for (const child of tag.node.body.body) {
6541
- if (import_compiler35.types.isMarkoText(child)) {
6669
+ if (import_compiler36.types.isMarkoText(child)) {
6542
6670
  write2`${child.value}`;
6543
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6671
+ } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
6544
6672
  write2`${callRuntime("escapeXML", child.value)}`;
6545
6673
  }
6546
6674
  }
@@ -6549,10 +6677,10 @@ var html_comment_default = {
6549
6677
  const templateExpressions = [];
6550
6678
  let currentQuasi = "";
6551
6679
  for (const child of tag.node.body.body) {
6552
- if (import_compiler35.types.isMarkoText(child)) {
6680
+ if (import_compiler36.types.isMarkoText(child)) {
6553
6681
  currentQuasi += child.value;
6554
- } else if (import_compiler35.types.isMarkoPlaceholder(child)) {
6555
- 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 }));
6556
6684
  templateExpressions.push(child.value);
6557
6685
  currentQuasi = "";
6558
6686
  }
@@ -6560,20 +6688,20 @@ var html_comment_default = {
6560
6688
  if (templateExpressions.length === 0) {
6561
6689
  write2`${currentQuasi}`;
6562
6690
  } else {
6563
- templateQuasis.push(import_compiler35.types.templateElement({ raw: currentQuasi }));
6691
+ templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
6564
6692
  addStatement(
6565
6693
  "render",
6566
6694
  getSection(tag),
6567
6695
  tagExtra.referencedBindings,
6568
- import_compiler35.types.expressionStatement(
6696
+ import_compiler36.types.expressionStatement(
6569
6697
  callRuntime(
6570
6698
  "data",
6571
- import_compiler35.types.memberExpression(
6699
+ import_compiler36.types.memberExpression(
6572
6700
  scopeIdentifier,
6573
6701
  getScopeAccessorLiteral(commentBinding),
6574
6702
  true
6575
6703
  ),
6576
- import_compiler35.types.templateLiteral(templateQuasis, templateExpressions)
6704
+ import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
6577
6705
  )
6578
6706
  )
6579
6707
  );
@@ -6599,7 +6727,7 @@ var html_comment_default = {
6599
6727
  };
6600
6728
 
6601
6729
  // src/translator/core/html-script.ts
6602
- var import_compiler36 = require("@marko/compiler");
6730
+ var import_compiler37 = require("@marko/compiler");
6603
6731
  var import_babel_utils25 = require("@marko/compiler/babel-utils");
6604
6732
  var kGetterId3 = Symbol("node getter id");
6605
6733
  var html_script_default = {
@@ -6607,7 +6735,7 @@ var html_script_default = {
6607
6735
  (0, import_babel_utils25.assertNoArgs)(tag);
6608
6736
  (0, import_babel_utils25.assertNoParams)(tag);
6609
6737
  const { node } = tag;
6610
- if (node.var && !import_compiler36.types.isIdentifier(node.var)) {
6738
+ if (node.var && !import_compiler37.types.isIdentifier(node.var)) {
6611
6739
  throw tag.get("var").buildCodeFrameError(
6612
6740
  "Tag variables on native elements cannot be destructured."
6613
6741
  );
@@ -6620,7 +6748,7 @@ var html_script_default = {
6620
6748
  let spreadReferenceNodes;
6621
6749
  for (let i = attributes.length; i--; ) {
6622
6750
  const attr2 = attributes[i];
6623
- if (import_compiler36.types.isMarkoAttribute(attr2)) {
6751
+ if (import_compiler37.types.isMarkoAttribute(attr2)) {
6624
6752
  if (seen[attr2.name]) {
6625
6753
  dropReferences(attr2.value);
6626
6754
  continue;
@@ -6632,14 +6760,14 @@ var html_script_default = {
6632
6760
  } else if (!evaluate(attr2.value).confident) {
6633
6761
  hasDynamicAttributes = true;
6634
6762
  }
6635
- } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6763
+ } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6636
6764
  hasEventHandlers = true;
6637
6765
  hasDynamicAttributes = true;
6638
6766
  (attr2.value.extra ??= {}).isEffect = true;
6639
6767
  }
6640
6768
  if (spreadReferenceNodes) {
6641
6769
  spreadReferenceNodes.push(attr2.value);
6642
- } else if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
6770
+ } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6643
6771
  spreadReferenceNodes = [attr2.value];
6644
6772
  }
6645
6773
  }
@@ -6649,10 +6777,10 @@ var html_script_default = {
6649
6777
  const bodyPlaceholderNodes = [];
6650
6778
  let hasBodyPlaceholders = false;
6651
6779
  for (const child of tag.node.body.body) {
6652
- if (import_compiler36.types.isMarkoPlaceholder(child)) {
6780
+ if (import_compiler37.types.isMarkoPlaceholder(child)) {
6653
6781
  bodyPlaceholderNodes.push(child.value);
6654
6782
  hasBodyPlaceholders = true;
6655
- } else if (!import_compiler36.types.isMarkoText(child)) {
6783
+ } else if (!import_compiler37.types.isMarkoText(child)) {
6656
6784
  throw tag.hub.buildError(
6657
6785
  child,
6658
6786
  "Invalid child. Only text is allowed inside an html-script."
@@ -6706,7 +6834,7 @@ var html_script_default = {
6706
6834
  callRuntime(
6707
6835
  "nodeRef",
6708
6836
  getterId && getScopeIdIdentifier(section),
6709
- getterId && import_compiler36.types.stringLiteral(getterId)
6837
+ getterId && import_compiler37.types.stringLiteral(getterId)
6710
6838
  )
6711
6839
  );
6712
6840
  } else {
@@ -6719,12 +6847,12 @@ var html_script_default = {
6719
6847
  );
6720
6848
  currentProgramPath.pushContainer(
6721
6849
  "body",
6722
- import_compiler36.types.variableDeclaration("const", [
6723
- import_compiler36.types.variableDeclarator(
6850
+ import_compiler37.types.variableDeclaration("const", [
6851
+ import_compiler37.types.variableDeclarator(
6724
6852
  getterFnIdentifier,
6725
6853
  callRuntime(
6726
6854
  "nodeRef",
6727
- import_compiler36.types.stringLiteral(getterId),
6855
+ import_compiler37.types.stringLiteral(getterId),
6728
6856
  getScopeAccessorLiteral(nodeRef2)
6729
6857
  )
6730
6858
  )
@@ -6735,13 +6863,13 @@ var html_script_default = {
6735
6863
  const referenceSection = getSection(reference);
6736
6864
  if (isInvokedFunction(reference)) {
6737
6865
  reference.parentPath.replaceWith(
6738
- import_compiler36.types.expressionStatement(
6866
+ import_compiler37.types.expressionStatement(
6739
6867
  createScopeReadExpression(referenceSection, nodeRef2)
6740
6868
  )
6741
6869
  );
6742
6870
  } else if (getterFnIdentifier) {
6743
6871
  reference.replaceWith(
6744
- import_compiler36.types.callExpression(getterFnIdentifier, [
6872
+ import_compiler37.types.callExpression(getterFnIdentifier, [
6745
6873
  getScopeExpression(referenceSection, getSection(tag))
6746
6874
  ])
6747
6875
  );
@@ -6774,10 +6902,10 @@ var html_script_default = {
6774
6902
  "render",
6775
6903
  section,
6776
6904
  valueReferences,
6777
- import_compiler36.types.expressionStatement(
6905
+ import_compiler37.types.expressionStatement(
6778
6906
  callRuntime(
6779
6907
  helper,
6780
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6908
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6781
6909
  value
6782
6910
  )
6783
6911
  )
@@ -6792,18 +6920,18 @@ var html_script_default = {
6792
6920
  if (isEventHandler(name2)) {
6793
6921
  addHTMLEffectCall(section, valueReferences);
6794
6922
  } else {
6795
- write2`${callRuntime("attr", import_compiler36.types.stringLiteral(name2), value)}`;
6923
+ write2`${callRuntime("attr", import_compiler37.types.stringLiteral(name2), value)}`;
6796
6924
  }
6797
6925
  } else if (isEventHandler(name2)) {
6798
6926
  addStatement(
6799
6927
  "effect",
6800
6928
  section,
6801
6929
  valueReferences,
6802
- import_compiler36.types.expressionStatement(
6930
+ import_compiler37.types.expressionStatement(
6803
6931
  callRuntime(
6804
6932
  "on",
6805
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6806
- import_compiler36.types.stringLiteral(getEventHandlerName(name2)),
6933
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6934
+ import_compiler37.types.stringLiteral(getEventHandlerName(name2)),
6807
6935
  value
6808
6936
  )
6809
6937
  )
@@ -6813,11 +6941,11 @@ var html_script_default = {
6813
6941
  "render",
6814
6942
  section,
6815
6943
  valueReferences,
6816
- import_compiler36.types.expressionStatement(
6944
+ import_compiler37.types.expressionStatement(
6817
6945
  callRuntime(
6818
6946
  "attr",
6819
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6820
- import_compiler36.types.stringLiteral(name2),
6947
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
6948
+ import_compiler37.types.stringLiteral(name2),
6821
6949
  value
6822
6950
  )
6823
6951
  )
@@ -6830,9 +6958,9 @@ var html_script_default = {
6830
6958
  if (isHTML) {
6831
6959
  addHTMLEffectCall(section, tagExtra.referencedBindings);
6832
6960
  if (skipExpression) {
6833
- 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"))}`;
6834
6962
  } else {
6835
- 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"))}`;
6836
6964
  }
6837
6965
  } else {
6838
6966
  if (skipExpression) {
@@ -6840,7 +6968,7 @@ var html_script_default = {
6840
6968
  "render",
6841
6969
  section,
6842
6970
  tagExtra.referencedBindings,
6843
- import_compiler36.types.expressionStatement(
6971
+ import_compiler37.types.expressionStatement(
6844
6972
  callRuntime(
6845
6973
  "partialAttrs",
6846
6974
  scopeIdentifier,
@@ -6855,7 +6983,7 @@ var html_script_default = {
6855
6983
  "render",
6856
6984
  section,
6857
6985
  tagExtra.referencedBindings,
6858
- import_compiler36.types.expressionStatement(
6986
+ import_compiler37.types.expressionStatement(
6859
6987
  callRuntime(
6860
6988
  "attrs",
6861
6989
  scopeIdentifier,
@@ -6869,7 +6997,7 @@ var html_script_default = {
6869
6997
  "effect",
6870
6998
  section,
6871
6999
  tagExtra.referencedBindings,
6872
- import_compiler36.types.expressionStatement(
7000
+ import_compiler37.types.expressionStatement(
6873
7001
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
6874
7002
  ),
6875
7003
  false
@@ -6880,9 +7008,9 @@ var html_script_default = {
6880
7008
  enter2(tag);
6881
7009
  if (isOutputHTML()) {
6882
7010
  for (const child of tag.node.body.body) {
6883
- if (import_compiler36.types.isMarkoText(child)) {
7011
+ if (import_compiler37.types.isMarkoText(child)) {
6884
7012
  write2`${child.value}`;
6885
- } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
7013
+ } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
6886
7014
  write2`${callRuntime("escapeScript", child.value)}`;
6887
7015
  }
6888
7016
  }
@@ -6892,11 +7020,11 @@ var html_script_default = {
6892
7020
  let currentQuasi = "";
6893
7021
  let referencePlaceholder;
6894
7022
  for (const child of tag.node.body.body) {
6895
- if (import_compiler36.types.isMarkoText(child)) {
7023
+ if (import_compiler37.types.isMarkoText(child)) {
6896
7024
  currentQuasi += child.value;
6897
- } else if (import_compiler36.types.isMarkoPlaceholder(child)) {
7025
+ } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
6898
7026
  referencePlaceholder ||= child;
6899
- templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
7027
+ templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
6900
7028
  templateExpressions.push(child.value);
6901
7029
  currentQuasi = "";
6902
7030
  }
@@ -6904,16 +7032,16 @@ var html_script_default = {
6904
7032
  if (!referencePlaceholder) {
6905
7033
  write2`${currentQuasi}`;
6906
7034
  } else {
6907
- templateQuasis.push(import_compiler36.types.templateElement({ raw: currentQuasi }));
7035
+ templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
6908
7036
  addStatement(
6909
7037
  "render",
6910
7038
  getSection(tag),
6911
7039
  referencePlaceholder.value.extra?.referencedBindings,
6912
- import_compiler36.types.expressionStatement(
7040
+ import_compiler37.types.expressionStatement(
6913
7041
  callRuntime(
6914
7042
  "textContent",
6915
- import_compiler36.types.memberExpression(scopeIdentifier, visitAccessor, true),
6916
- import_compiler36.types.templateLiteral(templateQuasis, templateExpressions)
7043
+ import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7044
+ import_compiler37.types.templateLiteral(templateQuasis, templateExpressions)
6917
7045
  )
6918
7046
  )
6919
7047
  );
@@ -6952,11 +7080,11 @@ function getUsedAttrs2(tag) {
6952
7080
  for (let i = attributes.length; i--; ) {
6953
7081
  const attr2 = attributes[i];
6954
7082
  const { value } = attr2;
6955
- if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
7083
+ if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
6956
7084
  if (!spreadProps) {
6957
7085
  spreadProps = [];
6958
7086
  }
6959
- spreadProps.push(import_compiler36.types.spreadElement(value));
7087
+ spreadProps.push(import_compiler37.types.spreadElement(value));
6960
7088
  } else if (!seen[attr2.name]) {
6961
7089
  seen[attr2.name] = attr2;
6962
7090
  if (spreadProps) {
@@ -6970,10 +7098,10 @@ function getUsedAttrs2(tag) {
6970
7098
  if (spreadProps) {
6971
7099
  spreadProps.reverse();
6972
7100
  for (const { name: name2 } of staticAttrs) {
6973
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler36.types.numericLiteral(1)));
7101
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler37.types.numericLiteral(1)));
6974
7102
  }
6975
7103
  if (skipProps) {
6976
- skipExpression = import_compiler36.types.objectExpression(skipProps);
7104
+ skipExpression = import_compiler37.types.objectExpression(skipProps);
6977
7105
  }
6978
7106
  spreadExpression = propsToExpression(spreadProps);
6979
7107
  }
@@ -6985,7 +7113,7 @@ function getUsedAttrs2(tag) {
6985
7113
  }
6986
7114
 
6987
7115
  // src/translator/core/html-style.ts
6988
- var import_compiler37 = require("@marko/compiler");
7116
+ var import_compiler38 = require("@marko/compiler");
6989
7117
  var import_babel_utils26 = require("@marko/compiler/babel-utils");
6990
7118
  var kGetterId4 = Symbol("node getter id");
6991
7119
  var html_style_default = {
@@ -6993,7 +7121,7 @@ var html_style_default = {
6993
7121
  (0, import_babel_utils26.assertNoArgs)(tag);
6994
7122
  (0, import_babel_utils26.assertNoParams)(tag);
6995
7123
  const { node } = tag;
6996
- if (node.var && !import_compiler37.types.isIdentifier(node.var)) {
7124
+ if (node.var && !import_compiler38.types.isIdentifier(node.var)) {
6997
7125
  throw tag.get("var").buildCodeFrameError(
6998
7126
  "Tag variables on native elements cannot be destructured."
6999
7127
  );
@@ -7006,7 +7134,7 @@ var html_style_default = {
7006
7134
  let spreadReferenceNodes;
7007
7135
  for (let i = attributes.length; i--; ) {
7008
7136
  const attr2 = attributes[i];
7009
- if (import_compiler37.types.isMarkoAttribute(attr2)) {
7137
+ if (import_compiler38.types.isMarkoAttribute(attr2)) {
7010
7138
  if (seen[attr2.name]) {
7011
7139
  dropReferences(attr2.value);
7012
7140
  continue;
@@ -7018,14 +7146,14 @@ var html_style_default = {
7018
7146
  } else if (!evaluate(attr2.value).confident) {
7019
7147
  hasDynamicAttributes = true;
7020
7148
  }
7021
- } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7149
+ } else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7022
7150
  hasEventHandlers = true;
7023
7151
  hasDynamicAttributes = true;
7024
7152
  (attr2.value.extra ??= {}).isEffect = true;
7025
7153
  }
7026
7154
  if (spreadReferenceNodes) {
7027
7155
  spreadReferenceNodes.push(attr2.value);
7028
- } else if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7156
+ } else if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7029
7157
  spreadReferenceNodes = [attr2.value];
7030
7158
  }
7031
7159
  }
@@ -7035,10 +7163,10 @@ var html_style_default = {
7035
7163
  const bodyPlaceholderNodes = [];
7036
7164
  let hasBodyPlaceholders = false;
7037
7165
  for (const child of tag.node.body.body) {
7038
- if (import_compiler37.types.isMarkoPlaceholder(child)) {
7166
+ if (import_compiler38.types.isMarkoPlaceholder(child)) {
7039
7167
  bodyPlaceholderNodes.push(child.value);
7040
7168
  hasBodyPlaceholders = true;
7041
- } else if (!import_compiler37.types.isMarkoText(child)) {
7169
+ } else if (!import_compiler38.types.isMarkoText(child)) {
7042
7170
  throw tag.hub.buildError(
7043
7171
  child,
7044
7172
  "Invalid child. Only text is allowed inside an html-style."
@@ -7092,7 +7220,7 @@ var html_style_default = {
7092
7220
  callRuntime(
7093
7221
  "nodeRef",
7094
7222
  getterId && getScopeIdIdentifier(section),
7095
- getterId && import_compiler37.types.stringLiteral(getterId)
7223
+ getterId && import_compiler38.types.stringLiteral(getterId)
7096
7224
  )
7097
7225
  );
7098
7226
  } else {
@@ -7105,12 +7233,12 @@ var html_style_default = {
7105
7233
  );
7106
7234
  currentProgramPath.pushContainer(
7107
7235
  "body",
7108
- import_compiler37.types.variableDeclaration("const", [
7109
- import_compiler37.types.variableDeclarator(
7236
+ import_compiler38.types.variableDeclaration("const", [
7237
+ import_compiler38.types.variableDeclarator(
7110
7238
  getterFnIdentifier,
7111
7239
  callRuntime(
7112
7240
  "nodeRef",
7113
- import_compiler37.types.stringLiteral(getterId),
7241
+ import_compiler38.types.stringLiteral(getterId),
7114
7242
  getScopeAccessorLiteral(nodeRef2)
7115
7243
  )
7116
7244
  )
@@ -7121,13 +7249,13 @@ var html_style_default = {
7121
7249
  const referenceSection = getSection(reference);
7122
7250
  if (isInvokedFunction(reference)) {
7123
7251
  reference.parentPath.replaceWith(
7124
- import_compiler37.types.expressionStatement(
7252
+ import_compiler38.types.expressionStatement(
7125
7253
  createScopeReadExpression(referenceSection, nodeRef2)
7126
7254
  )
7127
7255
  );
7128
7256
  } else if (getterFnIdentifier) {
7129
7257
  reference.replaceWith(
7130
- import_compiler37.types.callExpression(getterFnIdentifier, [
7258
+ import_compiler38.types.callExpression(getterFnIdentifier, [
7131
7259
  getScopeExpression(referenceSection, getSection(tag))
7132
7260
  ])
7133
7261
  );
@@ -7160,10 +7288,10 @@ var html_style_default = {
7160
7288
  "render",
7161
7289
  section,
7162
7290
  valueReferences,
7163
- import_compiler37.types.expressionStatement(
7291
+ import_compiler38.types.expressionStatement(
7164
7292
  callRuntime(
7165
7293
  helper,
7166
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7294
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7167
7295
  value
7168
7296
  )
7169
7297
  )
@@ -7178,18 +7306,18 @@ var html_style_default = {
7178
7306
  if (isEventHandler(name2)) {
7179
7307
  addHTMLEffectCall(section, valueReferences);
7180
7308
  } else {
7181
- write2`${callRuntime("attr", import_compiler37.types.stringLiteral(name2), value)}`;
7309
+ write2`${callRuntime("attr", import_compiler38.types.stringLiteral(name2), value)}`;
7182
7310
  }
7183
7311
  } else if (isEventHandler(name2)) {
7184
7312
  addStatement(
7185
7313
  "effect",
7186
7314
  section,
7187
7315
  valueReferences,
7188
- import_compiler37.types.expressionStatement(
7316
+ import_compiler38.types.expressionStatement(
7189
7317
  callRuntime(
7190
7318
  "on",
7191
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7192
- import_compiler37.types.stringLiteral(getEventHandlerName(name2)),
7319
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7320
+ import_compiler38.types.stringLiteral(getEventHandlerName(name2)),
7193
7321
  value
7194
7322
  )
7195
7323
  )
@@ -7199,11 +7327,11 @@ var html_style_default = {
7199
7327
  "render",
7200
7328
  section,
7201
7329
  valueReferences,
7202
- import_compiler37.types.expressionStatement(
7330
+ import_compiler38.types.expressionStatement(
7203
7331
  callRuntime(
7204
7332
  "attr",
7205
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7206
- import_compiler37.types.stringLiteral(name2),
7333
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7334
+ import_compiler38.types.stringLiteral(name2),
7207
7335
  value
7208
7336
  )
7209
7337
  )
@@ -7216,9 +7344,9 @@ var html_style_default = {
7216
7344
  if (isHTML) {
7217
7345
  addHTMLEffectCall(section, tagExtra.referencedBindings);
7218
7346
  if (skipExpression) {
7219
- 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"))}`;
7220
7348
  } else {
7221
- 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"))}`;
7222
7350
  }
7223
7351
  } else {
7224
7352
  if (skipExpression) {
@@ -7226,7 +7354,7 @@ var html_style_default = {
7226
7354
  "render",
7227
7355
  section,
7228
7356
  tagExtra.referencedBindings,
7229
- import_compiler37.types.expressionStatement(
7357
+ import_compiler38.types.expressionStatement(
7230
7358
  callRuntime(
7231
7359
  "partialAttrs",
7232
7360
  scopeIdentifier,
@@ -7241,7 +7369,7 @@ var html_style_default = {
7241
7369
  "render",
7242
7370
  section,
7243
7371
  tagExtra.referencedBindings,
7244
- import_compiler37.types.expressionStatement(
7372
+ import_compiler38.types.expressionStatement(
7245
7373
  callRuntime(
7246
7374
  "attrs",
7247
7375
  scopeIdentifier,
@@ -7255,7 +7383,7 @@ var html_style_default = {
7255
7383
  "effect",
7256
7384
  section,
7257
7385
  tagExtra.referencedBindings,
7258
- import_compiler37.types.expressionStatement(
7386
+ import_compiler38.types.expressionStatement(
7259
7387
  callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
7260
7388
  ),
7261
7389
  false
@@ -7266,9 +7394,9 @@ var html_style_default = {
7266
7394
  enter2(tag);
7267
7395
  if (isOutputHTML()) {
7268
7396
  for (const child of tag.node.body.body) {
7269
- if (import_compiler37.types.isMarkoText(child)) {
7397
+ if (import_compiler38.types.isMarkoText(child)) {
7270
7398
  write2`${child.value}`;
7271
- } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
7399
+ } else if (import_compiler38.types.isMarkoPlaceholder(child)) {
7272
7400
  write2`${callRuntime("escapeStyle", child.value)}`;
7273
7401
  }
7274
7402
  }
@@ -7278,11 +7406,11 @@ var html_style_default = {
7278
7406
  let currentQuasi = "";
7279
7407
  let referencePlaceholder;
7280
7408
  for (const child of tag.node.body.body) {
7281
- if (import_compiler37.types.isMarkoText(child)) {
7409
+ if (import_compiler38.types.isMarkoText(child)) {
7282
7410
  currentQuasi += child.value;
7283
- } else if (import_compiler37.types.isMarkoPlaceholder(child)) {
7411
+ } else if (import_compiler38.types.isMarkoPlaceholder(child)) {
7284
7412
  referencePlaceholder ||= child;
7285
- templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
7413
+ templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
7286
7414
  templateExpressions.push(child.value);
7287
7415
  currentQuasi = "";
7288
7416
  }
@@ -7290,16 +7418,16 @@ var html_style_default = {
7290
7418
  if (!referencePlaceholder) {
7291
7419
  write2`${currentQuasi}`;
7292
7420
  } else {
7293
- templateQuasis.push(import_compiler37.types.templateElement({ raw: currentQuasi }));
7421
+ templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
7294
7422
  addStatement(
7295
7423
  "render",
7296
7424
  getSection(tag),
7297
7425
  referencePlaceholder.value.extra?.referencedBindings,
7298
- import_compiler37.types.expressionStatement(
7426
+ import_compiler38.types.expressionStatement(
7299
7427
  callRuntime(
7300
7428
  "textContent",
7301
- import_compiler37.types.memberExpression(scopeIdentifier, visitAccessor, true),
7302
- import_compiler37.types.templateLiteral(templateQuasis, templateExpressions)
7429
+ import_compiler38.types.memberExpression(scopeIdentifier, visitAccessor, true),
7430
+ import_compiler38.types.templateLiteral(templateQuasis, templateExpressions)
7303
7431
  )
7304
7432
  )
7305
7433
  );
@@ -7333,11 +7461,11 @@ function getUsedAttrs3(tag) {
7333
7461
  for (let i = attributes.length; i--; ) {
7334
7462
  const attr2 = attributes[i];
7335
7463
  const { value } = attr2;
7336
- if (import_compiler37.types.isMarkoSpreadAttribute(attr2)) {
7464
+ if (import_compiler38.types.isMarkoSpreadAttribute(attr2)) {
7337
7465
  if (!spreadProps) {
7338
7466
  spreadProps = [];
7339
7467
  }
7340
- spreadProps.push(import_compiler37.types.spreadElement(value));
7468
+ spreadProps.push(import_compiler38.types.spreadElement(value));
7341
7469
  } else if (!seen[attr2.name]) {
7342
7470
  seen[attr2.name] = attr2;
7343
7471
  if (spreadProps) {
@@ -7351,10 +7479,10 @@ function getUsedAttrs3(tag) {
7351
7479
  if (spreadProps) {
7352
7480
  spreadProps.reverse();
7353
7481
  for (const { name: name2 } of staticAttrs) {
7354
- (skipProps ||= []).push(toObjectProperty(name2, import_compiler37.types.numericLiteral(1)));
7482
+ (skipProps ||= []).push(toObjectProperty(name2, import_compiler38.types.numericLiteral(1)));
7355
7483
  }
7356
7484
  if (skipProps) {
7357
- skipExpression = import_compiler37.types.objectExpression(skipProps);
7485
+ skipExpression = import_compiler38.types.objectExpression(skipProps);
7358
7486
  }
7359
7487
  spreadExpression = propsToExpression(spreadProps);
7360
7488
  }
@@ -7366,7 +7494,7 @@ function getUsedAttrs3(tag) {
7366
7494
  }
7367
7495
 
7368
7496
  // src/translator/core/id.ts
7369
- var import_compiler38 = require("@marko/compiler");
7497
+ var import_compiler39 = require("@marko/compiler");
7370
7498
  var import_babel_utils27 = require("@marko/compiler/babel-utils");
7371
7499
  var id_default = {
7372
7500
  analyze(tag) {
@@ -7379,7 +7507,7 @@ var id_default = {
7379
7507
  if (!node.var) {
7380
7508
  throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
7381
7509
  }
7382
- if (!import_compiler38.types.isIdentifier(node.var)) {
7510
+ if (!import_compiler39.types.isIdentifier(node.var)) {
7383
7511
  throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
7384
7512
  }
7385
7513
  trackVarReferences(tag, 4 /* derived */);
@@ -7390,7 +7518,7 @@ var id_default = {
7390
7518
  const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
7391
7519
  if (isOutputHTML()) {
7392
7520
  tag.replaceWith(
7393
- 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)])
7394
7522
  );
7395
7523
  } else {
7396
7524
  const source = initValue(node.var.extra.binding);
@@ -7415,17 +7543,17 @@ var id_default = {
7415
7543
  };
7416
7544
 
7417
7545
  // src/translator/core/if.ts
7418
- var import_compiler40 = require("@marko/compiler");
7546
+ var import_compiler41 = require("@marko/compiler");
7419
7547
  var import_babel_utils28 = require("@marko/compiler/babel-utils");
7420
7548
 
7421
7549
  // src/translator/util/to-first-statement-or-block.ts
7422
- var import_compiler39 = require("@marko/compiler");
7550
+ var import_compiler40 = require("@marko/compiler");
7423
7551
  function toFirstStatementOrBlock(body) {
7424
7552
  if (Array.isArray(body)) {
7425
7553
  if (body.length === 1) {
7426
7554
  return body[0];
7427
7555
  }
7428
- return import_compiler39.types.blockStatement(body);
7556
+ return import_compiler40.types.blockStatement(body);
7429
7557
  }
7430
7558
  return body;
7431
7559
  }
@@ -7491,14 +7619,12 @@ var IfTag = {
7491
7619
  const [isLast, branches] = getBranches(tag, bodySection);
7492
7620
  const [rootTag] = branches[0];
7493
7621
  const rootExtra = rootTag.node.extra;
7494
- const isStateful = isStatefulReferences(rootExtra.referencedBindings);
7495
7622
  const singleNodeOptimization = rootExtra.singleNodeOptimization;
7496
- const hasStatefulClosures = bodySection && checkStatefulClosures(bodySection, true);
7497
- 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;
7498
7626
  if (bodySection) {
7499
- if (isStateful || hasStatefulClosures || hasHoists) {
7500
- setForceResumeScope(bodySection);
7501
- }
7627
+ serializeSectionIfNeeded(bodySection, serializeReason);
7502
7628
  flushInto(tag);
7503
7629
  writeHTMLResumeStatements(tagBody);
7504
7630
  }
@@ -7509,33 +7635,28 @@ var IfTag = {
7509
7635
  const ifScopeIdIdentifier = rootTag.scope.generateUidIdentifier("ifScopeId");
7510
7636
  const ifBranchIdentifier = rootTag.scope.generateUidIdentifier("ifBranch");
7511
7637
  let statement;
7512
- if (isStateful && onlyChildInParentOptimization) {
7638
+ if (branchSources?.referenced && onlyChildInParentOptimization) {
7513
7639
  getParentTag(rootTag).node.extra[kSerializeMarker] = false;
7514
7640
  }
7515
7641
  for (let i = branches.length; i--; ) {
7516
7642
  const [branchTag, branchBodySection] = branches[i];
7517
7643
  const bodyStatements = branchTag.node.body.body;
7518
7644
  if (branchBodySection) {
7519
- const branchHasStatefulClosures = checkStatefulClosures(
7520
- branchBodySection,
7521
- true
7522
- );
7523
- const branchHasHoists = branchBodySection.hoisted || branchBodySection.isHoistThrough || branchBodySection.referencedHoists;
7524
- if (isStateful) {
7645
+ if (branchSources?.referenced) {
7525
7646
  bodyStatements.push(
7526
- import_compiler40.types.expressionStatement(
7527
- import_compiler40.types.assignmentExpression(
7647
+ import_compiler41.types.expressionStatement(
7648
+ import_compiler41.types.assignmentExpression(
7528
7649
  "=",
7529
7650
  ifBranchIdentifier,
7530
- import_compiler40.types.numericLiteral(i)
7651
+ import_compiler41.types.numericLiteral(i)
7531
7652
  )
7532
7653
  )
7533
7654
  );
7534
7655
  }
7535
- if (isStateful || branchHasStatefulClosures || branchHasHoists) {
7656
+ if (serializeReason) {
7536
7657
  bodyStatements.push(
7537
- import_compiler40.types.expressionStatement(
7538
- import_compiler40.types.assignmentExpression(
7658
+ import_compiler41.types.expressionStatement(
7659
+ import_compiler41.types.assignmentExpression(
7539
7660
  "=",
7540
7661
  ifScopeIdIdentifier,
7541
7662
  getScopeIdIdentifier(branchBodySection)
@@ -7547,7 +7668,7 @@ var IfTag = {
7547
7668
  const [testAttr] = branchTag.node.attributes;
7548
7669
  const curStatement = toFirstStatementOrBlock(bodyStatements);
7549
7670
  if (testAttr) {
7550
- statement = import_compiler40.types.ifStatement(
7671
+ statement = import_compiler41.types.ifStatement(
7551
7672
  testAttr.value,
7552
7673
  curStatement,
7553
7674
  statement
@@ -7557,24 +7678,25 @@ var IfTag = {
7557
7678
  }
7558
7679
  branchTag.remove();
7559
7680
  }
7560
- if (isStateful || hasStatefulClosures || hasHoists) {
7561
- if (isStateful) {
7681
+ if (serializeReason) {
7682
+ if (branchSources?.referenced) {
7562
7683
  setSerializedProperty(
7563
7684
  section,
7564
7685
  getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
7565
- ifBranchIdentifier
7686
+ ifBranchIdentifier,
7687
+ branchSources.referenced
7566
7688
  );
7567
- const cbNode = import_compiler40.types.arrowFunctionExpression(
7689
+ const cbNode = import_compiler41.types.arrowFunctionExpression(
7568
7690
  [],
7569
- import_compiler40.types.blockStatement([statement])
7691
+ import_compiler41.types.blockStatement([statement])
7570
7692
  );
7571
- statement = import_compiler40.types.expressionStatement(
7693
+ statement = import_compiler41.types.expressionStatement(
7572
7694
  singleNodeOptimization ? callRuntime(
7573
7695
  "resumeSingleNodeConditional",
7574
7696
  cbNode,
7575
7697
  getScopeIdIdentifier(section),
7576
7698
  getScopeAccessorLiteral(nodeRef2),
7577
- onlyChildInParentOptimization && import_compiler40.types.numericLiteral(1)
7699
+ onlyChildInParentOptimization && import_compiler41.types.numericLiteral(1)
7578
7700
  ) : callRuntime(
7579
7701
  "resumeConditional",
7580
7702
  cbNode,
@@ -7585,18 +7707,19 @@ var IfTag = {
7585
7707
  }
7586
7708
  nextTag.insertBefore(statement);
7587
7709
  getHTMLSectionStatements(section).push(
7588
- import_compiler40.types.variableDeclaration(
7710
+ import_compiler41.types.variableDeclaration(
7589
7711
  "let",
7590
7712
  [
7591
- import_compiler40.types.variableDeclarator(ifScopeIdIdentifier),
7592
- isStateful && import_compiler40.types.variableDeclarator(ifBranchIdentifier)
7713
+ import_compiler41.types.variableDeclarator(ifScopeIdIdentifier),
7714
+ branchSources?.referenced && import_compiler41.types.variableDeclarator(ifBranchIdentifier)
7593
7715
  ].filter(Boolean)
7594
7716
  )
7595
7717
  );
7596
7718
  setSerializedProperty(
7597
7719
  section,
7598
7720
  getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
7599
- callRuntime("getScopeById", ifScopeIdIdentifier)
7721
+ callRuntime("getScopeById", ifScopeIdIdentifier),
7722
+ serializeReason
7600
7723
  );
7601
7724
  } else {
7602
7725
  nextTag.insertBefore(statement);
@@ -7629,25 +7752,25 @@ var IfTag = {
7629
7752
  const rootExtra = branches[0][0].node.extra;
7630
7753
  const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
7631
7754
  const rendererIdentifiers = [];
7632
- let expr = import_compiler40.types.numericLiteral(branches.length);
7755
+ let expr = import_compiler41.types.numericLiteral(branches.length);
7633
7756
  for (let i = branches.length; i--; ) {
7634
7757
  const [branchTag, branchBodySection] = branches[i];
7635
7758
  const [testAttr] = branchTag.node.attributes;
7636
- const consequent = import_compiler40.types.numericLiteral(branchBodySection ? i : -1);
7759
+ const consequent = import_compiler41.types.numericLiteral(branchBodySection ? i : -1);
7637
7760
  if (branchBodySection) {
7638
- rendererIdentifiers.push(import_compiler40.types.identifier(branchBodySection.name));
7761
+ rendererIdentifiers.push(import_compiler41.types.identifier(branchBodySection.name));
7639
7762
  setClosureSignalBuilder(branchTag, (closure, render) => {
7640
7763
  return callRuntime(
7641
7764
  "conditionalClosure",
7642
7765
  getScopeAccessorLiteral(closure),
7643
7766
  getScopeAccessorLiteral(nodeRef2),
7644
- import_compiler40.types.numericLiteral(i),
7767
+ import_compiler41.types.numericLiteral(i),
7645
7768
  render
7646
7769
  );
7647
7770
  });
7648
7771
  }
7649
7772
  branchTag.remove();
7650
- expr = testAttr ? import_compiler40.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7773
+ expr = testAttr ? import_compiler41.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
7651
7774
  }
7652
7775
  const signal = getSignal(section, nodeRef2, "if");
7653
7776
  signal.build = () => {
@@ -7729,7 +7852,7 @@ function assertHasBody(tag) {
7729
7852
  function assertHasValueAttribute(tag) {
7730
7853
  const { node } = tag;
7731
7854
  const [valueAttr] = node.attributes;
7732
- if (!import_compiler40.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7855
+ if (!import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
7733
7856
  throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
7734
7857
  }
7735
7858
  if (node.attributes.length > 1) {
@@ -7776,6 +7899,21 @@ function getBranches(tag, bodySection) {
7776
7899
  }
7777
7900
  return [isLast, branches];
7778
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
+ }
7779
7917
  function isRoot(tag) {
7780
7918
  return isCoreTagName(tag, "if");
7781
7919
  }
@@ -7804,7 +7942,7 @@ var import_default = {
7804
7942
  };
7805
7943
 
7806
7944
  // src/translator/core/let.ts
7807
- var import_compiler41 = require("@marko/compiler");
7945
+ var import_compiler42 = require("@marko/compiler");
7808
7946
  var import_babel_utils30 = require("@marko/compiler/babel-utils");
7809
7947
  var let_default = {
7810
7948
  analyze(tag) {
@@ -7813,7 +7951,7 @@ var let_default = {
7813
7951
  let valueAttr;
7814
7952
  let valueChangeAttr;
7815
7953
  for (const attr2 of node.attributes) {
7816
- if (import_compiler41.types.isMarkoAttribute(attr2)) {
7954
+ if (import_compiler42.types.isMarkoAttribute(attr2)) {
7817
7955
  if (attr2.name === "value") {
7818
7956
  valueAttr = attr2;
7819
7957
  } else if (attr2.name === "valueChange") {
@@ -7841,7 +7979,7 @@ var let_default = {
7841
7979
  if (!tagVar) {
7842
7980
  throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
7843
7981
  }
7844
- if (!import_compiler41.types.isIdentifier(tagVar)) {
7982
+ if (!import_compiler42.types.isIdentifier(tagVar)) {
7845
7983
  throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
7846
7984
  }
7847
7985
  if (valueChangeAttr && (0, import_babel_utils30.computeNode)(valueChangeAttr.value)) {
@@ -7860,10 +7998,10 @@ var let_default = {
7860
7998
  const { node } = tag;
7861
7999
  const tagVar = node.var;
7862
8000
  const valueAttr = node.attributes.find(
7863
- (attr2) => import_compiler41.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
7864
- ) ?? 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"));
7865
8003
  const valueChangeAttr = node.attributes.find(
7866
- (attr2) => import_compiler41.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
8004
+ (attr2) => import_compiler42.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
7867
8005
  );
7868
8006
  const section = getSection(tag);
7869
8007
  const binding = tagVar.extra.binding;
@@ -7876,7 +8014,7 @@ var let_default = {
7876
8014
  }
7877
8015
  signal.buildAssignment = (valueSection, value) => {
7878
8016
  const scope = getScopeExpression(valueSection, signal.section);
7879
- return import_compiler41.types.callExpression(signal.identifier, [scope, value]);
8017
+ return import_compiler42.types.callExpression(signal.identifier, [scope, value]);
7880
8018
  };
7881
8019
  } else {
7882
8020
  translateVar(tag, valueAttr.value, "let");
@@ -7884,7 +8022,9 @@ var let_default = {
7884
8022
  setSerializedProperty(
7885
8023
  section,
7886
8024
  getAccessorPrefix().TagVariableChange + getScopeAccessor(binding),
7887
- valueChangeAttr.value
8025
+ valueChangeAttr.value,
8026
+ true
8027
+ // TODO: could be based on if there are actually assignments.
7888
8028
  );
7889
8029
  }
7890
8030
  }
@@ -7905,7 +8045,7 @@ var let_default = {
7905
8045
  };
7906
8046
 
7907
8047
  // src/translator/core/lifecycle.ts
7908
- var import_compiler42 = require("@marko/compiler");
8048
+ var import_compiler43 = require("@marko/compiler");
7909
8049
  var import_babel_utils31 = require("@marko/compiler/babel-utils");
7910
8050
  var kRef = Symbol("lifecycle attrs reference");
7911
8051
  var lifecycle_default = {
@@ -7930,7 +8070,7 @@ var lifecycle_default = {
7930
8070
  );
7931
8071
  }
7932
8072
  for (const attr2 of node.attributes) {
7933
- if (import_compiler42.types.isMarkoSpreadAttribute(attr2)) {
8073
+ if (import_compiler43.types.isMarkoSpreadAttribute(attr2)) {
7934
8074
  throw tag.get("name").buildCodeFrameError(
7935
8075
  "The `lifecycle` tag does not support `...spread` attributes."
7936
8076
  );
@@ -7950,7 +8090,7 @@ var lifecycle_default = {
7950
8090
  if (isOutputDOM()) {
7951
8091
  const translatedAttrs = translateAttrs(tag);
7952
8092
  translatedAttrs.statements.push(
7953
- import_compiler42.types.expressionStatement(
8093
+ import_compiler43.types.expressionStatement(
7954
8094
  callRuntime(
7955
8095
  "lifecycle",
7956
8096
  scopeIdentifier,
@@ -7985,7 +8125,7 @@ var lifecycle_default = {
7985
8125
  };
7986
8126
 
7987
8127
  // src/translator/core/log.ts
7988
- var import_compiler43 = require("@marko/compiler");
8128
+ var import_compiler44 = require("@marko/compiler");
7989
8129
  var import_babel_utils32 = require("@marko/compiler/babel-utils");
7990
8130
  var log_default = {
7991
8131
  analyze(tag) {
@@ -7997,7 +8137,7 @@ var log_default = {
7997
8137
  if (!valueAttr) {
7998
8138
  throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
7999
8139
  }
8000
- 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") {
8001
8141
  throw tag.get("name").buildCodeFrameError(
8002
8142
  "The `log` tag only supports the `value` attribute."
8003
8143
  );
@@ -8009,9 +8149,9 @@ var log_default = {
8009
8149
  const [valueAttr] = tag.node.attributes;
8010
8150
  const { value } = valueAttr;
8011
8151
  const referencedBindings = value.extra?.referencedBindings;
8012
- const statement = import_compiler43.types.expressionStatement(
8013
- import_compiler43.types.callExpression(
8014
- 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")),
8015
8155
  [value]
8016
8156
  )
8017
8157
  );
@@ -8037,7 +8177,7 @@ var log_default = {
8037
8177
  };
8038
8178
 
8039
8179
  // src/translator/core/script.ts
8040
- var import_compiler44 = require("@marko/compiler");
8180
+ var import_compiler45 = require("@marko/compiler");
8041
8181
  var import_babel_utils33 = require("@marko/compiler/babel-utils");
8042
8182
  var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
8043
8183
  var script_default = {
@@ -8059,12 +8199,12 @@ var script_default = {
8059
8199
  const start = body[0]?.start;
8060
8200
  const end = body[body.length - 1]?.end;
8061
8201
  const bodyStatements = (0, import_babel_utils33.parseStatements)(tag.hub.file, code, start, end);
8062
- const valueFn = import_compiler44.types.arrowFunctionExpression(
8202
+ const valueFn = import_compiler45.types.arrowFunctionExpression(
8063
8203
  [],
8064
- import_compiler44.types.blockStatement(bodyStatements),
8204
+ import_compiler45.types.blockStatement(bodyStatements),
8065
8205
  traverseContains(bodyStatements, isAwaitExpression)
8066
8206
  );
8067
- node.attributes.push(import_compiler44.types.markoAttribute("value", valueFn));
8207
+ node.attributes.push(import_compiler45.types.markoAttribute("value", valueFn));
8068
8208
  node.body.body = [];
8069
8209
  }
8070
8210
  },
@@ -8113,28 +8253,28 @@ var script_default = {
8113
8253
  const referencedBindings = value.extra?.referencedBindings;
8114
8254
  if (isOutputDOM()) {
8115
8255
  const { value: value2 } = valueAttr;
8116
- 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);
8117
8257
  let inlineBody = null;
8118
8258
  if (isFunction2 && !(value2.async || value2.generator)) {
8119
- if (import_compiler44.types.isBlockStatement(value2.body)) {
8259
+ if (import_compiler45.types.isBlockStatement(value2.body)) {
8120
8260
  let hasDeclaration = false;
8121
8261
  for (const child of value2.body.body) {
8122
- if (import_compiler44.types.isDeclaration(child)) {
8262
+ if (import_compiler45.types.isDeclaration(child)) {
8123
8263
  hasDeclaration = true;
8124
8264
  break;
8125
8265
  }
8126
8266
  }
8127
8267
  inlineBody = hasDeclaration ? value2.body : value2.body.body;
8128
8268
  } else {
8129
- inlineBody = import_compiler44.types.expressionStatement(value2.body);
8269
+ inlineBody = import_compiler45.types.expressionStatement(value2.body);
8130
8270
  }
8131
8271
  }
8132
8272
  addStatement(
8133
8273
  "effect",
8134
8274
  section,
8135
8275
  referencedBindings,
8136
- inlineBody || import_compiler44.types.expressionStatement(
8137
- import_compiler44.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
8276
+ inlineBody || import_compiler45.types.expressionStatement(
8277
+ import_compiler45.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
8138
8278
  )
8139
8279
  );
8140
8280
  } else {
@@ -8174,7 +8314,7 @@ function isAwaitExpression(node) {
8174
8314
  }
8175
8315
 
8176
8316
  // src/translator/core/server.ts
8177
- var import_compiler45 = require("@marko/compiler");
8317
+ var import_compiler46 = require("@marko/compiler");
8178
8318
  var import_babel_utils34 = require("@marko/compiler/babel-utils");
8179
8319
  var server_default = {
8180
8320
  parse(tag) {
@@ -8186,10 +8326,10 @@ var server_default = {
8186
8326
  const code = rawValue.replace(/^server\s*/, "").trim();
8187
8327
  const start = node.name.start + (rawValue.length - code.length);
8188
8328
  let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
8189
- if (body.length === 1 && import_compiler45.types.isBlockStatement(body[0])) {
8329
+ if (body.length === 1 && import_compiler46.types.isBlockStatement(body[0])) {
8190
8330
  body = body[0].body;
8191
8331
  }
8192
- tag.replaceWith(import_compiler45.types.markoScriptlet(body, true, "server"));
8332
+ tag.replaceWith(import_compiler46.types.markoScriptlet(body, true, "server"));
8193
8333
  },
8194
8334
  parseOptions: {
8195
8335
  statement: true,
@@ -8205,7 +8345,7 @@ var server_default = {
8205
8345
  };
8206
8346
 
8207
8347
  // src/translator/core/static.ts
8208
- var import_compiler46 = require("@marko/compiler");
8348
+ var import_compiler47 = require("@marko/compiler");
8209
8349
  var import_babel_utils35 = require("@marko/compiler/babel-utils");
8210
8350
  var static_default = {
8211
8351
  parse(tag) {
@@ -8217,10 +8357,10 @@ var static_default = {
8217
8357
  const code = rawValue.replace(/^static\s*/, "").trim();
8218
8358
  const start = node.name.start + (rawValue.length - code.length);
8219
8359
  let body = (0, import_babel_utils35.parseStatements)(file, code, start, start + code.length);
8220
- if (body.length === 1 && import_compiler46.types.isBlockStatement(body[0])) {
8360
+ if (body.length === 1 && import_compiler47.types.isBlockStatement(body[0])) {
8221
8361
  body = body[0].body;
8222
8362
  }
8223
- tag.replaceWith(import_compiler46.types.markoScriptlet(body, true));
8363
+ tag.replaceWith(import_compiler47.types.markoScriptlet(body, true));
8224
8364
  },
8225
8365
  parseOptions: {
8226
8366
  statement: true,
@@ -8236,7 +8376,7 @@ var static_default = {
8236
8376
  };
8237
8377
 
8238
8378
  // src/translator/core/style.ts
8239
- var import_compiler47 = require("@marko/compiler");
8379
+ var import_compiler48 = require("@marko/compiler");
8240
8380
  var import_babel_utils36 = require("@marko/compiler/babel-utils");
8241
8381
  var import_magic_string = __toESM(require("magic-string"));
8242
8382
  var import_path3 = __toESM(require("path"));
@@ -8314,21 +8454,21 @@ var style_default = {
8314
8454
  if (!node.var) {
8315
8455
  currentProgramPath.pushContainer(
8316
8456
  "body",
8317
- import_compiler47.types.importDeclaration([], import_compiler47.types.stringLiteral(importPath))
8457
+ import_compiler48.types.importDeclaration([], import_compiler48.types.stringLiteral(importPath))
8318
8458
  );
8319
- } else if (import_compiler47.types.isIdentifier(node.var)) {
8459
+ } else if (import_compiler48.types.isIdentifier(node.var)) {
8320
8460
  currentProgramPath.pushContainer(
8321
8461
  "body",
8322
- import_compiler47.types.importDeclaration(
8323
- [import_compiler47.types.importDefaultSpecifier(node.var)],
8324
- import_compiler47.types.stringLiteral(importPath)
8462
+ import_compiler48.types.importDeclaration(
8463
+ [import_compiler48.types.importDefaultSpecifier(node.var)],
8464
+ import_compiler48.types.stringLiteral(importPath)
8325
8465
  )
8326
8466
  );
8327
8467
  } else {
8328
8468
  currentProgramPath.pushContainer(
8329
8469
  "body",
8330
- import_compiler47.types.variableDeclaration("const", [
8331
- import_compiler47.types.variableDeclarator(
8470
+ import_compiler48.types.variableDeclaration("const", [
8471
+ import_compiler48.types.variableDeclarator(
8332
8472
  node.var,
8333
8473
  (0, import_babel_utils36.importDefault)(file, importPath, "style")
8334
8474
  )
@@ -8348,7 +8488,7 @@ var style_default = {
8348
8488
  };
8349
8489
 
8350
8490
  // src/translator/core/try.ts
8351
- var import_compiler48 = require("@marko/compiler");
8491
+ var import_compiler49 = require("@marko/compiler");
8352
8492
  var import_babel_utils37 = require("@marko/compiler/babel-utils");
8353
8493
  var kDOMBinding2 = Symbol("try tag dom binding");
8354
8494
  var try_default = {
@@ -8408,7 +8548,7 @@ var try_default = {
8408
8548
  writeHTMLResumeStatements(tagBody);
8409
8549
  tag.insertBefore(translatedAttrs.statements);
8410
8550
  tag.replaceWith(
8411
- import_compiler48.types.expressionStatement(
8551
+ import_compiler49.types.expressionStatement(
8412
8552
  callRuntime(
8413
8553
  "tryContent",
8414
8554
  getScopeIdIdentifier(section),
@@ -8450,7 +8590,7 @@ var try_default = {
8450
8590
  return callRuntime(
8451
8591
  "createTry",
8452
8592
  getScopeAccessorLiteral(nodeRef2),
8453
- import_compiler48.types.identifier(bodySection.name)
8593
+ import_compiler49.types.identifier(bodySection.name)
8454
8594
  );
8455
8595
  };
8456
8596
  if (translatedAttrs.statements.length) {
@@ -8463,7 +8603,7 @@ var try_default = {
8463
8603
  }
8464
8604
  currentProgramPath.pushContainer(
8465
8605
  "body",
8466
- import_compiler48.types.expressionStatement(callRuntime("enableCatch"))
8606
+ import_compiler49.types.expressionStatement(callRuntime("enableCatch"))
8467
8607
  );
8468
8608
  addValue(
8469
8609
  section,
@@ -8561,7 +8701,7 @@ var document_type_default = {
8561
8701
  };
8562
8702
 
8563
8703
  // src/translator/visitors/function.ts
8564
- var import_compiler49 = require("@marko/compiler");
8704
+ var import_compiler50 = require("@marko/compiler");
8565
8705
  var import_babel_utils38 = require("@marko/compiler/babel-utils");
8566
8706
  var functionIdsBySection = /* @__PURE__ */ new WeakMap();
8567
8707
  var function_default = {
@@ -8578,9 +8718,9 @@ var function_default = {
8578
8718
  }
8579
8719
  const { node } = fn;
8580
8720
  const extra = node.extra ??= {};
8581
- 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(
8582
8722
  markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
8583
- ) : 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");
8584
8724
  const {
8585
8725
  markoOpts,
8586
8726
  opts: { filename }
@@ -8641,7 +8781,7 @@ var import_declaration_default = {
8641
8781
  };
8642
8782
 
8643
8783
  // src/translator/visitors/placeholder.ts
8644
- var import_compiler50 = require("@marko/compiler");
8784
+ var import_compiler51 = require("@marko/compiler");
8645
8785
  var kBinding = Symbol("placeholder node binding");
8646
8786
  var kSiblingText = Symbol("placeholder has sibling text");
8647
8787
  var placeholder_default = {
@@ -8675,13 +8815,13 @@ var placeholder_default = {
8675
8815
  const nodeBinding = extra[kBinding];
8676
8816
  const canWriteHTML = isHTML || confident && node.escape;
8677
8817
  const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
8678
- const isStateful = isStatefulReferences(referencedBindings);
8818
+ const serializeReason = getDynamicSourcesForReferences(referencedBindings);
8679
8819
  const siblingText = extra[kSiblingText];
8680
8820
  if (confident && canWriteHTML) {
8681
8821
  write2`${getHTMLRuntime()[method](computed)}`;
8682
8822
  } else {
8683
8823
  if (siblingText === 1 /* Before */) {
8684
- if (isHTML && isStateful) {
8824
+ if (isHTML && serializeReason) {
8685
8825
  write2`<!>`;
8686
8826
  }
8687
8827
  visit(placeholder, 37 /* Replace */);
@@ -8693,7 +8833,7 @@ var placeholder_default = {
8693
8833
  }
8694
8834
  if (isHTML) {
8695
8835
  write2`${callRuntime(method, value)}`;
8696
- if (isStateful) {
8836
+ if (serializeReason) {
8697
8837
  markNode(placeholder, nodeBinding);
8698
8838
  }
8699
8839
  } else {
@@ -8701,10 +8841,10 @@ var placeholder_default = {
8701
8841
  "render",
8702
8842
  getSection(placeholder),
8703
8843
  value.extra?.referencedBindings,
8704
- import_compiler50.types.expressionStatement(
8844
+ import_compiler51.types.expressionStatement(
8705
8845
  method === "data" ? callRuntime(
8706
8846
  "data",
8707
- import_compiler50.types.memberExpression(
8847
+ import_compiler51.types.memberExpression(
8708
8848
  scopeIdentifier,
8709
8849
  getScopeAccessorLiteral(nodeBinding),
8710
8850
  true
@@ -8741,7 +8881,7 @@ function analyzeSiblingText(placeholder) {
8741
8881
  break;
8742
8882
  }
8743
8883
  }
8744
- if (!prev.node && import_compiler50.types.isProgram(placeholder.parentPath)) {
8884
+ if (!prev.node && import_compiler51.types.isProgram(placeholder.parentPath)) {
8745
8885
  return placeholderExtra[kSiblingText] = 1 /* Before */;
8746
8886
  }
8747
8887
  let next = placeholder.getNextSibling();
@@ -8758,7 +8898,7 @@ function analyzeSiblingText(placeholder) {
8758
8898
  break;
8759
8899
  }
8760
8900
  }
8761
- if (!next.node && import_compiler50.types.isProgram(placeholder.parentPath)) {
8901
+ if (!next.node && import_compiler51.types.isProgram(placeholder.parentPath)) {
8762
8902
  return placeholderExtra[kSiblingText] = 2 /* After */;
8763
8903
  }
8764
8904
  return placeholderExtra[kSiblingText] = 0 /* None */;
@@ -8780,7 +8920,7 @@ function isVoid2(value) {
8780
8920
  }
8781
8921
 
8782
8922
  // src/translator/visitors/referenced-identifier.ts
8783
- var import_compiler51 = require("@marko/compiler");
8923
+ var import_compiler52 = require("@marko/compiler");
8784
8924
  var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
8785
8925
  var referenced_identifier_default = {
8786
8926
  migrate(identifier) {
@@ -8788,8 +8928,8 @@ var referenced_identifier_default = {
8788
8928
  if (identifier.scope.hasBinding(name2)) return;
8789
8929
  switch (name2) {
8790
8930
  case "out":
8791
- if (import_compiler51.types.isMemberExpression(identifier.parent) && import_compiler51.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
8792
- 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"));
8793
8933
  } else {
8794
8934
  throw identifier.buildCodeFrameError(
8795
8935
  "Only `out.global` is supported for compatibility."
@@ -8816,24 +8956,24 @@ var referenced_identifier_default = {
8816
8956
  case "$global":
8817
8957
  if (isOutputHTML()) {
8818
8958
  identifier.replaceWith(
8819
- import_compiler51.types.callExpression(importRuntime("$global"), [])
8959
+ import_compiler52.types.callExpression(importRuntime("$global"), [])
8820
8960
  );
8821
8961
  } else {
8822
8962
  identifier.replaceWith(
8823
- import_compiler51.types.memberExpression(scopeIdentifier, import_compiler51.types.identifier("$global"))
8963
+ import_compiler52.types.memberExpression(scopeIdentifier, import_compiler52.types.identifier("$global"))
8824
8964
  );
8825
8965
  }
8826
8966
  break;
8827
8967
  case "$signal":
8828
8968
  if (isOutputHTML()) {
8829
8969
  identifier.replaceWith(
8830
- import_compiler51.types.callExpression(
8831
- import_compiler51.types.arrowFunctionExpression(
8970
+ import_compiler52.types.callExpression(
8971
+ import_compiler52.types.arrowFunctionExpression(
8832
8972
  [],
8833
- import_compiler51.types.blockStatement([
8834
- import_compiler51.types.throwStatement(
8835
- import_compiler51.types.newExpression(import_compiler51.types.identifier("Error"), [
8836
- 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.")
8837
8977
  ])
8838
8978
  )
8839
8979
  ])
@@ -8859,19 +8999,19 @@ var referenced_identifier_default = {
8859
8999
  "render",
8860
9000
  section,
8861
9001
  exprRoot.node.extra?.referencedBindings,
8862
- import_compiler51.types.expressionStatement(
8863
- import_compiler51.types.callExpression(importRuntime("resetAbortSignal"), [
9002
+ import_compiler52.types.expressionStatement(
9003
+ import_compiler52.types.callExpression(importRuntime("resetAbortSignal"), [
8864
9004
  scopeIdentifier,
8865
- import_compiler51.types.numericLiteral(exprId)
9005
+ import_compiler52.types.numericLiteral(exprId)
8866
9006
  ])
8867
9007
  ),
8868
9008
  false
8869
9009
  );
8870
9010
  }
8871
9011
  identifier.replaceWith(
8872
- import_compiler51.types.callExpression(importRuntime("getAbortSignal"), [
9012
+ import_compiler52.types.callExpression(importRuntime("getAbortSignal"), [
8873
9013
  scopeIdentifier,
8874
- import_compiler51.types.numericLiteral(exprId)
9014
+ import_compiler52.types.numericLiteral(exprId)
8875
9015
  ])
8876
9016
  );
8877
9017
  }
@@ -8911,11 +9051,11 @@ var scriptlet_default = {
8911
9051
  };
8912
9052
 
8913
9053
  // src/translator/visitors/tag/index.ts
8914
- var import_compiler55 = require("@marko/compiler");
9054
+ var import_compiler56 = require("@marko/compiler");
8915
9055
  var import_babel_utils43 = require("@marko/compiler/babel-utils");
8916
9056
 
8917
9057
  // src/translator/visitors/tag/attribute-tag.ts
8918
- var import_compiler52 = require("@marko/compiler");
9058
+ var import_compiler53 = require("@marko/compiler");
8919
9059
  var import_babel_utils40 = require("@marko/compiler/babel-utils");
8920
9060
  var attribute_tag_default = {
8921
9061
  analyze: {
@@ -8946,7 +9086,7 @@ var attribute_tag_default = {
8946
9086
  };
8947
9087
 
8948
9088
  // src/translator/visitors/tag/custom-tag.ts
8949
- var import_compiler53 = require("@marko/compiler");
9089
+ var import_compiler54 = require("@marko/compiler");
8950
9090
  var import_babel_utils41 = require("@marko/compiler/babel-utils");
8951
9091
  var import_path4 = __toESM(require("path"));
8952
9092
  var kChildScopeBinding = Symbol("custom tag child scope");
@@ -9028,9 +9168,9 @@ function translateHTML(tag) {
9028
9168
  let tagIdentifier;
9029
9169
  flushInto(tag);
9030
9170
  writeHTMLResumeStatements(tagBody);
9031
- if (import_compiler53.types.isStringLiteral(node.name)) {
9171
+ if (import_compiler54.types.isStringLiteral(node.name)) {
9032
9172
  const relativePath = getTagRelativePath(tag);
9033
- 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));
9034
9174
  } else {
9035
9175
  tagIdentifier = node.name;
9036
9176
  }
@@ -9041,37 +9181,32 @@ function translateHTML(tag) {
9041
9181
  properties: [],
9042
9182
  statements: []
9043
9183
  };
9044
- let providesStatefulAttrs = false;
9045
- for (const expr of tagExtra[kChildAttrExprs]) {
9046
- if (isReferencedExtra(expr) && isStatefulReferences(expr.referencedBindings)) {
9047
- providesStatefulAttrs = true;
9048
- break;
9049
- }
9050
- }
9051
- if (providesStatefulAttrs || tagVar) {
9184
+ const serializeReason = !!tagVar || getDynamicSourcesForExtras(tagExtra[kChildAttrExprs]);
9185
+ if (serializeReason) {
9052
9186
  const childScopeBinding = tagExtra[kChildScopeBinding];
9053
9187
  const peekScopeId = tag.scope.generateUidIdentifier(
9054
9188
  childScopeBinding?.name
9055
9189
  );
9056
9190
  tag.insertBefore(
9057
- import_compiler53.types.variableDeclaration("const", [
9058
- import_compiler53.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
9191
+ import_compiler54.types.variableDeclaration("const", [
9192
+ import_compiler54.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
9059
9193
  ])
9060
9194
  );
9061
9195
  setSerializedProperty(
9062
9196
  section,
9063
9197
  getScopeAccessor(childScopeBinding),
9064
- callRuntime("writeExistingScope", peekScopeId)
9198
+ callRuntime("writeExistingScope", peekScopeId),
9199
+ serializeReason
9065
9200
  );
9066
9201
  if (tagVar) {
9067
9202
  statements.push(
9068
- import_compiler53.types.expressionStatement(
9203
+ import_compiler54.types.expressionStatement(
9069
9204
  callRuntime(
9070
9205
  "setTagVar",
9071
9206
  getScopeIdIdentifier(section),
9072
9207
  getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
9073
9208
  peekScopeId,
9074
- import_compiler53.types.stringLiteral(
9209
+ import_compiler54.types.stringLiteral(
9075
9210
  getResumeRegisterId(
9076
9211
  section,
9077
9212
  node.var.extra?.binding,
@@ -9091,8 +9226,8 @@ function translateHTML(tag) {
9091
9226
  const contentExpression = contentProp.value;
9092
9227
  contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
9093
9228
  const [contentPath] = tag.insertBefore(
9094
- import_compiler53.types.variableDeclaration("const", [
9095
- import_compiler53.types.variableDeclarator(
9229
+ import_compiler54.types.variableDeclaration("const", [
9230
+ import_compiler54.types.variableDeclarator(
9096
9231
  contentId,
9097
9232
  // TODO: only register if needed (child template analysis)
9098
9233
  contentExpression
@@ -9106,13 +9241,13 @@ function translateHTML(tag) {
9106
9241
  propsToExpression(properties)
9107
9242
  );
9108
9243
  if (tagVar) {
9109
- translateVar(tag, import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0)), "let");
9110
- 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);
9111
9246
  }
9112
9247
  statements.push(
9113
- import_compiler53.types.ifStatement(
9248
+ import_compiler54.types.ifStatement(
9114
9249
  tagIdentifier,
9115
- import_compiler53.types.expressionStatement(renderTagExpr),
9250
+ import_compiler54.types.expressionStatement(renderTagExpr),
9116
9251
  contentId && callStatement(contentId)
9117
9252
  )
9118
9253
  );
@@ -9121,7 +9256,7 @@ function translateHTML(tag) {
9121
9256
  tag,
9122
9257
  callExpression(tagIdentifier, propsToExpression(properties))
9123
9258
  );
9124
- setForceResumeScope(section);
9259
+ serializeSectionIfNeeded(section, true);
9125
9260
  } else {
9126
9261
  statements.push(
9127
9262
  callStatement(tagIdentifier, propsToExpression(properties))
@@ -9138,7 +9273,7 @@ function translateDOM(tag) {
9138
9273
  const childScopeBinding = extra[kChildScopeBinding];
9139
9274
  const write2 = writeTo(tag);
9140
9275
  const { file } = tag.hub;
9141
- 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";
9142
9277
  const relativePath = getTagRelativePath(tag);
9143
9278
  const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
9144
9279
  const childExports = childFile.ast.program.extra.domExports;
@@ -9170,7 +9305,7 @@ function translateDOM(tag) {
9170
9305
  );
9171
9306
  source.register = true;
9172
9307
  source.buildAssignment = (valueSection, value) => {
9173
- return import_compiler53.types.callExpression(importRuntime("tagVarSignalChange"), [
9308
+ return import_compiler54.types.callExpression(importRuntime("tagVarSignalChange"), [
9174
9309
  createScopeReadExpression(valueSection, childScopeBinding),
9175
9310
  value
9176
9311
  ]);
@@ -9179,7 +9314,7 @@ function translateDOM(tag) {
9179
9314
  "render",
9180
9315
  tagSection,
9181
9316
  void 0,
9182
- import_compiler53.types.expressionStatement(
9317
+ import_compiler54.types.expressionStatement(
9183
9318
  callRuntime(
9184
9319
  "setTagVar",
9185
9320
  scopeIdentifier,
@@ -9193,8 +9328,8 @@ function translateDOM(tag) {
9193
9328
  "render",
9194
9329
  tagSection,
9195
9330
  void 0,
9196
- import_compiler53.types.expressionStatement(
9197
- import_compiler53.types.callExpression(tagIdentifier, [
9331
+ import_compiler54.types.expressionStatement(
9332
+ import_compiler54.types.callExpression(tagIdentifier, [
9198
9333
  createScopeReadExpression(tagSection, childScopeBinding)
9199
9334
  ])
9200
9335
  )
@@ -9207,7 +9342,7 @@ function getTagRelativePath(tag) {
9207
9342
  hub: { file }
9208
9343
  } = tag;
9209
9344
  let relativePath;
9210
- if (import_compiler53.types.isStringLiteral(node.name)) {
9345
+ if (import_compiler54.types.isStringLiteral(node.name)) {
9211
9346
  const template = (0, import_babel_utils41.getTagTemplate)(tag);
9212
9347
  relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
9213
9348
  } else if (node.extra?.tagNameImported) {
@@ -9300,7 +9435,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
9300
9435
  let spreadReferenceNodes;
9301
9436
  for (let i = attributes.length; i--; ) {
9302
9437
  const attr2 = attributes[i];
9303
- if (import_compiler53.types.isMarkoAttribute(attr2)) {
9438
+ if (import_compiler54.types.isMarkoAttribute(attr2)) {
9304
9439
  if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
9305
9440
  dropReferences(attr2.value);
9306
9441
  continue;
@@ -9309,7 +9444,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
9309
9444
  }
9310
9445
  if (spreadReferenceNodes) {
9311
9446
  spreadReferenceNodes.push(attr2.value);
9312
- } else if (import_compiler53.types.isMarkoSpreadAttribute(attr2)) {
9447
+ } else if (import_compiler54.types.isMarkoSpreadAttribute(attr2)) {
9313
9448
  spreadReferenceNodes = [attr2.value];
9314
9449
  } else {
9315
9450
  rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
@@ -9334,7 +9469,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9334
9469
  // but we should probably ensure all other references are dropped in this case before we do that.
9335
9470
  tag.node.extra?.referencedBindings,
9336
9471
  identifierToSignal(tagInputIdentifier),
9337
- 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,
9338
9473
  createScopeReadExpression(info.tagSection, info.childScopeBinding)
9339
9474
  );
9340
9475
  return;
@@ -9382,7 +9517,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9382
9517
  } else {
9383
9518
  attrTagCallsForTag.set(
9384
9519
  attrTagName,
9385
- translatedProps = import_compiler53.types.parenthesizedExpression(
9520
+ translatedProps = import_compiler54.types.parenthesizedExpression(
9386
9521
  callRuntime("attrTag", translatedProps)
9387
9522
  )
9388
9523
  );
@@ -9467,7 +9602,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9467
9602
  childAttrExports.id,
9468
9603
  `${importAlias}_${attrTagMeta.name}`
9469
9604
  );
9470
- decls.push(import_compiler53.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
9605
+ decls.push(import_compiler54.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
9471
9606
  addValue(
9472
9607
  info.tagSection,
9473
9608
  referencedBindings,
@@ -9477,7 +9612,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9477
9612
  );
9478
9613
  }
9479
9614
  addStatement("render", info.tagSection, referencedBindings, [
9480
- import_compiler53.types.variableDeclaration("let", decls),
9615
+ import_compiler54.types.variableDeclaration("let", decls),
9481
9616
  ...statements
9482
9617
  ]);
9483
9618
  }
@@ -9497,7 +9632,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9497
9632
  void 0,
9498
9633
  // TODO: pretty sure content needs to have the reference group of it's param defaults.
9499
9634
  identifierToSignal(contentExportIdentifier),
9500
- import_compiler53.types.callExpression(import_compiler53.types.identifier(bodySection.name), [scopeIdentifier]),
9635
+ import_compiler54.types.callExpression(import_compiler54.types.identifier(bodySection.name), [scopeIdentifier]),
9501
9636
  createScopeReadExpression(info.tagSection, info.childScopeBinding)
9502
9637
  );
9503
9638
  }
@@ -9507,7 +9642,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9507
9642
  let spreadProps;
9508
9643
  for (let i = attributes.length; i--; ) {
9509
9644
  const attr2 = attributes[i];
9510
- if (import_compiler53.types.isMarkoAttribute(attr2)) {
9645
+ if (import_compiler54.types.isMarkoAttribute(attr2)) {
9511
9646
  const childAttrExports = templateExport.props[attr2.name];
9512
9647
  if (!childAttrExports || seen.has(attr2.name)) continue;
9513
9648
  seen.add(attr2.name);
@@ -9517,9 +9652,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9517
9652
  }
9518
9653
  staticAttrs.push(attr2);
9519
9654
  } else if (spreadProps) {
9520
- spreadProps.push(import_compiler53.types.spreadElement(attr2.value));
9655
+ spreadProps.push(import_compiler54.types.spreadElement(attr2.value));
9521
9656
  } else {
9522
- spreadProps = [import_compiler53.types.spreadElement(attr2.value)];
9657
+ spreadProps = [import_compiler54.types.spreadElement(attr2.value)];
9523
9658
  }
9524
9659
  }
9525
9660
  for (const attr2 of staticAttrs.reverse()) {
@@ -9548,8 +9683,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9548
9683
  spreadProps.reverse();
9549
9684
  getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
9550
9685
  addStatement("render", info.tagSection, referencedBindings, [
9551
- import_compiler53.types.variableDeclaration("const", [
9552
- import_compiler53.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
9686
+ import_compiler54.types.variableDeclaration("const", [
9687
+ import_compiler54.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
9553
9688
  ])
9554
9689
  ]);
9555
9690
  }
@@ -9573,7 +9708,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
9573
9708
  }
9574
9709
  function importOrSelfReferenceName(file, request, name2, nameHint) {
9575
9710
  if (isCircularRequest(file, request)) {
9576
- return import_compiler53.types.identifier(name2);
9711
+ return import_compiler54.types.identifier(name2);
9577
9712
  }
9578
9713
  return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
9579
9714
  }
@@ -9582,10 +9717,10 @@ function isCircularRequest(file, request) {
9582
9717
  return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
9583
9718
  }
9584
9719
  function callStatement(id, ...args) {
9585
- return import_compiler53.types.expressionStatement(callExpression(id, ...args));
9720
+ return import_compiler54.types.expressionStatement(callExpression(id, ...args));
9586
9721
  }
9587
9722
  function callExpression(id, ...args) {
9588
- return import_compiler53.types.callExpression(id, args.filter(Boolean));
9723
+ return import_compiler54.types.callExpression(id, args.filter(Boolean));
9589
9724
  }
9590
9725
  function identifierToSignal(identifier) {
9591
9726
  return {
@@ -9594,14 +9729,14 @@ function identifierToSignal(identifier) {
9594
9729
  };
9595
9730
  }
9596
9731
  function buildUndefined2() {
9597
- return import_compiler53.types.unaryExpression("void", import_compiler53.types.numericLiteral(0));
9732
+ return import_compiler54.types.unaryExpression("void", import_compiler54.types.numericLiteral(0));
9598
9733
  }
9599
9734
  function always() {
9600
9735
  return true;
9601
9736
  }
9602
9737
 
9603
9738
  // src/translator/visitors/tag/dynamic-tag.ts
9604
- var import_compiler54 = require("@marko/compiler");
9739
+ var import_compiler55 = require("@marko/compiler");
9605
9740
  var import_babel_utils42 = require("@marko/compiler/babel-utils");
9606
9741
  var kDOMBinding3 = Symbol("dynamic tag dom binding");
9607
9742
  var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
@@ -9657,7 +9792,7 @@ var dynamic_tag_default = {
9657
9792
  const isClassAPI = tagExtra.featureType === "class";
9658
9793
  const referencedBindings = tagExtra.referencedBindings;
9659
9794
  let tagExpression = node.name;
9660
- if (import_compiler54.types.isStringLiteral(tagExpression)) {
9795
+ if (import_compiler55.types.isStringLiteral(tagExpression)) {
9661
9796
  tagExpression = (0, import_babel_utils42.importDefault)(
9662
9797
  tag.hub.file,
9663
9798
  getTagRelativePath(tag),
@@ -9668,14 +9803,14 @@ var dynamic_tag_default = {
9668
9803
  if (isOutputHTML()) {
9669
9804
  currentProgramPath.pushContainer(
9670
9805
  "body",
9671
- import_compiler54.types.markoScriptlet(
9806
+ import_compiler55.types.markoScriptlet(
9672
9807
  [
9673
- import_compiler54.types.expressionStatement(
9674
- import_compiler54.types.callExpression(
9808
+ import_compiler55.types.expressionStatement(
9809
+ import_compiler55.types.callExpression(
9675
9810
  (0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
9676
9811
  [
9677
- import_compiler54.types.identifier(tagExpression.name),
9678
- 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)
9679
9814
  ]
9680
9815
  )
9681
9816
  )
@@ -9686,11 +9821,11 @@ var dynamic_tag_default = {
9686
9821
  } else {
9687
9822
  currentProgramPath.pushContainer(
9688
9823
  "body",
9689
- import_compiler54.types.expressionStatement(
9824
+ import_compiler55.types.expressionStatement(
9690
9825
  callRuntime(
9691
9826
  "register",
9692
- import_compiler54.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
9693
- 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)
9694
9829
  )
9695
9830
  )
9696
9831
  );
@@ -9710,7 +9845,7 @@ var dynamic_tag_default = {
9710
9845
  hasMultipleArgs = true;
9711
9846
  args.push(propsToExpression(properties));
9712
9847
  } else {
9713
- 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]);
9714
9849
  }
9715
9850
  } else {
9716
9851
  const contentProp = getTranslatedBodyContentProperty(properties);
@@ -9726,7 +9861,7 @@ var dynamic_tag_default = {
9726
9861
  writeHTMLResumeStatements(tag.get("body"));
9727
9862
  if (node.var) {
9728
9863
  if (!hasMultipleArgs && args.length === 1) {
9729
- 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)));
9730
9865
  }
9731
9866
  }
9732
9867
  const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
@@ -9735,7 +9870,7 @@ var dynamic_tag_default = {
9735
9870
  getScopeIdIdentifier(section),
9736
9871
  getScopeAccessorLiteral(nodeRef2),
9737
9872
  tagExpression,
9738
- import_compiler54.types.arrayExpression(args)
9873
+ import_compiler55.types.arrayExpression(args)
9739
9874
  ) : callRuntime(
9740
9875
  "dynamicTagInput",
9741
9876
  getScopeIdIdentifier(section),
@@ -9744,8 +9879,8 @@ var dynamic_tag_default = {
9744
9879
  ...args
9745
9880
  );
9746
9881
  statements.push(
9747
- import_compiler54.types.variableDeclaration("const", [
9748
- import_compiler54.types.variableDeclarator(
9882
+ import_compiler55.types.variableDeclaration("const", [
9883
+ import_compiler55.types.variableDeclarator(
9749
9884
  dynamicScopeIdentifier,
9750
9885
  callRuntime("peekNextScope")
9751
9886
  )
@@ -9753,10 +9888,10 @@ var dynamic_tag_default = {
9753
9888
  );
9754
9889
  if (node.var) {
9755
9890
  statements.push(
9756
- import_compiler54.types.variableDeclaration("const", [
9757
- import_compiler54.types.variableDeclarator(node.var, dynamicTagExpr)
9891
+ import_compiler55.types.variableDeclaration("const", [
9892
+ import_compiler55.types.variableDeclarator(node.var, dynamicTagExpr)
9758
9893
  ]),
9759
- import_compiler54.types.expressionStatement(
9894
+ import_compiler55.types.expressionStatement(
9760
9895
  callRuntime(
9761
9896
  "setTagVar",
9762
9897
  getScopeIdIdentifier(section),
@@ -9764,7 +9899,7 @@ var dynamic_tag_default = {
9764
9899
  tag.node.extra[kChildOffsetScopeBinding2]
9765
9900
  ),
9766
9901
  dynamicScopeIdentifier,
9767
- import_compiler54.types.stringLiteral(
9902
+ import_compiler55.types.stringLiteral(
9768
9903
  getResumeRegisterId(
9769
9904
  section,
9770
9905
  node.var.extra?.binding,
@@ -9776,21 +9911,26 @@ var dynamic_tag_default = {
9776
9911
  )
9777
9912
  );
9778
9913
  } else {
9779
- 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
+ );
9780
9933
  }
9781
- setSerializedProperty(
9782
- section,
9783
- getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2),
9784
- callRuntime("writeExistingScope", dynamicScopeIdentifier)
9785
- );
9786
- setSerializedProperty(
9787
- section,
9788
- getAccessorPrefix().ConditionalRenderer + getScopeAccessor(nodeRef2),
9789
- callRuntime(
9790
- "dynamicTagId",
9791
- import_compiler54.types.isIdentifier(tagExpression) ? import_compiler54.types.identifier(tagExpression.name) : tagExpression
9792
- )
9793
- );
9794
9934
  for (const replacement of tag.replaceWithMultiple(statements)) {
9795
9935
  replacement.skip();
9796
9936
  }
@@ -9806,10 +9946,10 @@ var dynamic_tag_default = {
9806
9946
  );
9807
9947
  tagVarSignal.register = true;
9808
9948
  tagVarSignal.buildAssignment = (valueSection, value) => {
9809
- return import_compiler54.types.callExpression(importRuntime("tagVarSignalChange"), [
9810
- import_compiler54.types.memberExpression(
9949
+ return import_compiler55.types.callExpression(importRuntime("tagVarSignalChange"), [
9950
+ import_compiler55.types.memberExpression(
9811
9951
  getScopeExpression(tagVarSignal.section, valueSection),
9812
- import_compiler54.types.stringLiteral(
9952
+ import_compiler55.types.stringLiteral(
9813
9953
  getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
9814
9954
  ),
9815
9955
  true
@@ -9822,19 +9962,19 @@ var dynamic_tag_default = {
9822
9962
  return callRuntime(
9823
9963
  "dynamicTag",
9824
9964
  getScopeAccessorLiteral(nodeRef2),
9825
- bodySection && import_compiler54.types.identifier(bodySection.name),
9826
- tagVarSignal ? import_compiler54.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
9827
- 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)
9828
9968
  );
9829
9969
  };
9830
9970
  if (args.length) {
9831
- const argsOrInput = hasMultipleArgs ? import_compiler54.types.arrayExpression(args) : args[0];
9832
- 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) {
9833
9973
  signal.extraArgs = [
9834
- import_compiler54.types.arrowFunctionExpression(
9974
+ import_compiler55.types.arrowFunctionExpression(
9835
9975
  [],
9836
- statements.length ? import_compiler54.types.blockStatement(
9837
- statements.concat(import_compiler54.types.returnStatement(argsOrInput))
9976
+ statements.length ? import_compiler55.types.blockStatement(
9977
+ statements.concat(import_compiler55.types.returnStatement(argsOrInput))
9838
9978
  ) : argsOrInput
9839
9979
  )
9840
9980
  ];
@@ -9857,16 +9997,16 @@ var tag_default = {
9857
9997
  const { node } = tag;
9858
9998
  const { name: name2, attributes } = tag.node;
9859
9999
  let crawl = false;
9860
- if (import_compiler55.types.isStringLiteral(name2)) {
10000
+ if (import_compiler56.types.isStringLiteral(name2)) {
9861
10001
  const tagName = name2.value;
9862
10002
  if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
9863
- node.name = withPreviousLocation(import_compiler55.types.identifier(tagName), name2);
10003
+ node.name = withPreviousLocation(import_compiler56.types.identifier(tagName), name2);
9864
10004
  crawl = true;
9865
10005
  }
9866
10006
  }
9867
10007
  for (let i = 0; i < attributes.length; i++) {
9868
10008
  const attr2 = attributes[i];
9869
- if (import_compiler55.types.isMarkoAttribute(attr2) && attr2.bound) {
10009
+ if (import_compiler56.types.isMarkoAttribute(attr2) && attr2.bound) {
9870
10010
  attr2.bound = false;
9871
10011
  attributes.splice(++i, 0, getChangeHandler(tag, attr2));
9872
10012
  crawl = true;
@@ -9942,8 +10082,8 @@ var tag_default = {
9942
10082
  if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
9943
10083
  const tagNameId = tag.scope.generateUidIdentifier("tagName");
9944
10084
  const [tagNameVarPath] = tag.insertBefore(
9945
- import_compiler55.types.variableDeclaration("const", [
9946
- import_compiler55.types.variableDeclarator(tagNameId, tag.node.name)
10085
+ import_compiler56.types.variableDeclaration("const", [
10086
+ import_compiler56.types.variableDeclarator(tagNameId, tag.node.name)
9947
10087
  ])
9948
10088
  );
9949
10089
  tagNameVarPath.skip();
@@ -9990,16 +10130,16 @@ var tag_default = {
9990
10130
  function getChangeHandler(tag, attr2) {
9991
10131
  const attrName = attr2.name;
9992
10132
  const changeAttrName = attrName + "Change";
9993
- if (import_compiler55.types.isIdentifier(attr2.value)) {
10133
+ if (import_compiler56.types.isIdentifier(attr2.value)) {
9994
10134
  const binding = tag.scope.getBinding(attr2.value.name);
9995
10135
  if (!binding)
9996
- return import_compiler55.types.markoAttribute(
10136
+ return import_compiler56.types.markoAttribute(
9997
10137
  changeAttrName,
9998
10138
  buildChangeHandlerFunction(attr2.value)
9999
10139
  );
10000
10140
  const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
10001
10141
  if (!existingChangedAttr) {
10002
- const changeHandlerAttr = import_compiler55.types.markoAttribute(
10142
+ const changeHandlerAttr = import_compiler56.types.markoAttribute(
10003
10143
  changeAttrName,
10004
10144
  buildChangeHandlerFunction(attr2.value)
10005
10145
  );
@@ -10007,10 +10147,10 @@ function getChangeHandler(tag, attr2) {
10007
10147
  return changeHandlerAttr;
10008
10148
  }
10009
10149
  if (existingChangedAttr.type === "Identifier") {
10010
- return import_compiler55.types.markoAttribute(
10150
+ return import_compiler56.types.markoAttribute(
10011
10151
  changeAttrName,
10012
10152
  withPreviousLocation(
10013
- import_compiler55.types.identifier(existingChangedAttr.name),
10153
+ import_compiler56.types.identifier(existingChangedAttr.name),
10014
10154
  attr2.value
10015
10155
  )
10016
10156
  );
@@ -10020,37 +10160,37 @@ function getChangeHandler(tag, attr2) {
10020
10160
  throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
10021
10161
  }
10022
10162
  const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
10023
- const changeHandlerConst = import_compiler55.types.markoTag(
10024
- import_compiler55.types.stringLiteral("const"),
10025
- [import_compiler55.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
10026
- 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([]),
10027
10167
  null,
10028
- import_compiler55.types.identifier(changeHandlerId)
10168
+ import_compiler56.types.identifier(changeHandlerId)
10029
10169
  );
10030
10170
  BINDING_CHANGE_HANDLER.set(
10031
10171
  binding.identifier,
10032
- existingChangedAttr.value = import_compiler55.types.identifier(changeHandlerId)
10172
+ existingChangedAttr.value = import_compiler56.types.identifier(changeHandlerId)
10033
10173
  );
10034
10174
  if (markoRoot.isMarkoTag()) {
10035
10175
  markoRoot.insertAfter(changeHandlerConst);
10036
10176
  } else {
10037
10177
  markoRoot.unshiftContainer("body", changeHandlerConst);
10038
10178
  }
10039
- return import_compiler55.types.markoAttribute(
10179
+ return import_compiler56.types.markoAttribute(
10040
10180
  changeAttrName,
10041
- withPreviousLocation(import_compiler55.types.identifier(changeHandlerId), attr2.value)
10181
+ withPreviousLocation(import_compiler56.types.identifier(changeHandlerId), attr2.value)
10042
10182
  );
10043
- } else if (import_compiler55.types.isMemberExpression(attr2.value)) {
10183
+ } else if (import_compiler56.types.isMemberExpression(attr2.value)) {
10044
10184
  const prop = attr2.value.property;
10045
- if (!import_compiler55.types.isPrivateName(attr2.value.property)) {
10046
- return import_compiler55.types.markoAttribute(
10185
+ if (!import_compiler56.types.isPrivateName(attr2.value.property)) {
10186
+ return import_compiler56.types.markoAttribute(
10047
10187
  changeAttrName,
10048
- import_compiler55.types.memberExpression(
10049
- import_compiler55.types.cloneNode(attr2.value.object),
10050
- 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(
10051
10191
  "+",
10052
- import_compiler55.types.cloneNode(prop),
10053
- import_compiler55.types.stringLiteral("Change")
10192
+ import_compiler56.types.cloneNode(prop),
10193
+ import_compiler56.types.stringLiteral("Change")
10054
10194
  ),
10055
10195
  prop.type !== "Identifier"
10056
10196
  )
@@ -10064,14 +10204,14 @@ function getChangeHandler(tag, attr2) {
10064
10204
  }
10065
10205
  function buildChangeHandlerFunction(id) {
10066
10206
  const newId = "_new_" + id.name;
10067
- return import_compiler55.types.arrowFunctionExpression(
10068
- [withPreviousLocation(import_compiler55.types.identifier(newId), id)],
10069
- import_compiler55.types.blockStatement([
10070
- import_compiler55.types.expressionStatement(
10071
- 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(
10072
10212
  "=",
10073
- withPreviousLocation(import_compiler55.types.identifier(id.name), id),
10074
- withPreviousLocation(import_compiler55.types.identifier(newId), id)
10213
+ withPreviousLocation(import_compiler56.types.identifier(id.name), id),
10214
+ withPreviousLocation(import_compiler56.types.identifier(newId), id)
10075
10215
  )
10076
10216
  )
10077
10217
  ])
@@ -10079,7 +10219,7 @@ function buildChangeHandlerFunction(id) {
10079
10219
  }
10080
10220
 
10081
10221
  // src/translator/visitors/text.ts
10082
- var import_compiler56 = require("@marko/compiler");
10222
+ var import_compiler57 = require("@marko/compiler");
10083
10223
  var text_default = {
10084
10224
  translate: {
10085
10225
  exit(text) {