marko 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/debug/dom.js CHANGED
@@ -276,6 +276,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
276
276
  };
277
277
  const branchIds = /* @__PURE__ */ new Set();
278
278
  const parentBranchIds = /* @__PURE__ */ new Map();
279
+ let lastEffect;
279
280
  let currentBranchId;
280
281
  let $global;
281
282
  let lastScopeId = 0;
@@ -361,7 +362,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
361
362
  render.r = [];
362
363
  isResuming = 1;
363
364
  for (let i = 0; i < resumes.length; i++) {
364
- const serialized = resumes[i];
365
+ let serialized = resumes[i];
365
366
  if (typeof serialized === "function") {
366
367
  for (const scope of serialized(serializeContext)) {
367
368
  if (!$global) {
@@ -403,7 +404,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
403
404
  }
404
405
  }
405
406
  } else {
406
- registeredValues[resumes[++i]](
407
+ if (typeof serialized === "string") {
408
+ lastEffect = serialized;
409
+ serialized = resumes[++i];
410
+ }
411
+ registeredValues[lastEffect](
407
412
  scopeLookup[serialized],
408
413
  scopeLookup[serialized]
409
414
  );
@@ -188,6 +188,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
188
188
  };
189
189
  const branchIds = /* @__PURE__ */ new Set();
190
190
  const parentBranchIds = /* @__PURE__ */ new Map();
191
+ let lastEffect;
191
192
  let currentBranchId;
192
193
  let $global;
193
194
  let lastScopeId = 0;
@@ -273,7 +274,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
273
274
  render.r = [];
274
275
  isResuming = 1;
275
276
  for (let i = 0; i < resumes.length; i++) {
276
- const serialized = resumes[i];
277
+ let serialized = resumes[i];
277
278
  if (typeof serialized === "function") {
278
279
  for (const scope of serialized(serializeContext)) {
279
280
  if (!$global) {
@@ -315,7 +316,11 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
315
316
  }
316
317
  }
317
318
  } else {
318
- registeredValues[resumes[++i]](
319
+ if (typeof serialized === "string") {
320
+ lastEffect = serialized;
321
+ serialized = resumes[++i];
322
+ }
323
+ registeredValues[lastEffect](
319
324
  scopeLookup[serialized],
320
325
  scopeLookup[serialized]
321
326
  );
@@ -2197,7 +2197,7 @@ function tryCatch(content, catchContent) {
2197
2197
  cur.async = false;
2198
2198
  cur.next = bodyNext;
2199
2199
  cur.html = endMarker;
2200
- cur.scripts = cur.effects = "";
2200
+ cur.scripts = cur.effects = cur.lastEffect = "";
2201
2201
  cur.placeholderBody = cur.placeholderRender = cur.reorderId = null;
2202
2202
  }
2203
2203
  cur = next;
@@ -2328,6 +2328,7 @@ var Chunk = class {
2328
2328
  html = "";
2329
2329
  scripts = "";
2330
2330
  effects = "";
2331
+ lastEffect = "";
2331
2332
  async = false;
2332
2333
  consumed = false;
2333
2334
  reorderId = null;
@@ -2337,10 +2338,15 @@ var Chunk = class {
2337
2338
  this.html += html;
2338
2339
  }
2339
2340
  writeEffect(scopeId, registryId) {
2340
- this.effects = concatEffects(
2341
- this.effects,
2342
- scopeId + ',"' + registryId + '"'
2343
- );
2341
+ if (this.lastEffect === registryId) {
2342
+ this.effects += "," + scopeId;
2343
+ } else {
2344
+ this.effects = concatEffects(
2345
+ this.effects,
2346
+ '"' + registryId + '",' + scopeId
2347
+ );
2348
+ }
2349
+ this.lastEffect = registryId;
2344
2350
  }
2345
2351
  writeScript(script) {
2346
2352
  this.scripts = concatScripts(this.scripts, script);
@@ -2349,6 +2355,7 @@ var Chunk = class {
2349
2355
  this.html += chunk.html;
2350
2356
  this.effects = concatEffects(this.effects, chunk.effects);
2351
2357
  this.scripts = concatScripts(this.scripts, chunk.scripts);
2358
+ this.lastEffect = chunk.lastEffect || this.lastEffect;
2352
2359
  }
2353
2360
  flushPlaceholder() {
2354
2361
  if (this.placeholderBody) {
@@ -2378,17 +2385,20 @@ var Chunk = class {
2378
2385
  let html = "";
2379
2386
  let effects = "";
2380
2387
  let scripts = "";
2388
+ let lastEffect = "";
2381
2389
  do {
2382
2390
  cur.flushPlaceholder();
2383
2391
  html += cur.html;
2384
2392
  effects = concatEffects(effects, cur.effects);
2385
2393
  scripts = concatScripts(scripts, cur.scripts);
2394
+ lastEffect = cur.lastEffect || lastEffect;
2386
2395
  cur.consumed = true;
2387
2396
  cur = cur.next;
2388
2397
  } while (cur.next && !cur.async);
2389
2398
  cur.html = html + cur.html;
2390
2399
  cur.effects = concatEffects(effects, cur.effects);
2391
2400
  cur.scripts = concatScripts(scripts, cur.scripts);
2401
+ cur.lastEffect = lastEffect;
2392
2402
  }
2393
2403
  return cur;
2394
2404
  }
@@ -2467,7 +2477,7 @@ var Chunk = class {
2467
2477
  "#" /* ReorderMarker */,
2468
2478
  cur.reorderId = state.nextReorderId()
2469
2479
  );
2470
- cur.html = cur.effects = cur.scripts = "";
2480
+ cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2471
2481
  cur.next = null;
2472
2482
  }
2473
2483
  if (next) {
@@ -2112,7 +2112,7 @@ function tryCatch(content, catchContent) {
2112
2112
  cur.async = false;
2113
2113
  cur.next = bodyNext;
2114
2114
  cur.html = endMarker;
2115
- cur.scripts = cur.effects = "";
2115
+ cur.scripts = cur.effects = cur.lastEffect = "";
2116
2116
  cur.placeholderBody = cur.placeholderRender = cur.reorderId = null;
2117
2117
  }
2118
2118
  cur = next;
@@ -2243,6 +2243,7 @@ var Chunk = class {
2243
2243
  html = "";
2244
2244
  scripts = "";
2245
2245
  effects = "";
2246
+ lastEffect = "";
2246
2247
  async = false;
2247
2248
  consumed = false;
2248
2249
  reorderId = null;
@@ -2252,10 +2253,15 @@ var Chunk = class {
2252
2253
  this.html += html;
2253
2254
  }
2254
2255
  writeEffect(scopeId, registryId) {
2255
- this.effects = concatEffects(
2256
- this.effects,
2257
- scopeId + ',"' + registryId + '"'
2258
- );
2256
+ if (this.lastEffect === registryId) {
2257
+ this.effects += "," + scopeId;
2258
+ } else {
2259
+ this.effects = concatEffects(
2260
+ this.effects,
2261
+ '"' + registryId + '",' + scopeId
2262
+ );
2263
+ }
2264
+ this.lastEffect = registryId;
2259
2265
  }
2260
2266
  writeScript(script) {
2261
2267
  this.scripts = concatScripts(this.scripts, script);
@@ -2264,6 +2270,7 @@ var Chunk = class {
2264
2270
  this.html += chunk.html;
2265
2271
  this.effects = concatEffects(this.effects, chunk.effects);
2266
2272
  this.scripts = concatScripts(this.scripts, chunk.scripts);
2273
+ this.lastEffect = chunk.lastEffect || this.lastEffect;
2267
2274
  }
2268
2275
  flushPlaceholder() {
2269
2276
  if (this.placeholderBody) {
@@ -2293,17 +2300,20 @@ var Chunk = class {
2293
2300
  let html = "";
2294
2301
  let effects = "";
2295
2302
  let scripts = "";
2303
+ let lastEffect = "";
2296
2304
  do {
2297
2305
  cur.flushPlaceholder();
2298
2306
  html += cur.html;
2299
2307
  effects = concatEffects(effects, cur.effects);
2300
2308
  scripts = concatScripts(scripts, cur.scripts);
2309
+ lastEffect = cur.lastEffect || lastEffect;
2301
2310
  cur.consumed = true;
2302
2311
  cur = cur.next;
2303
2312
  } while (cur.next && !cur.async);
2304
2313
  cur.html = html + cur.html;
2305
2314
  cur.effects = concatEffects(effects, cur.effects);
2306
2315
  cur.scripts = concatScripts(scripts, cur.scripts);
2316
+ cur.lastEffect = lastEffect;
2307
2317
  }
2308
2318
  return cur;
2309
2319
  }
@@ -2382,7 +2392,7 @@ var Chunk = class {
2382
2392
  "#" /* ReorderMarker */,
2383
2393
  cur.reorderId = state.nextReorderId()
2384
2394
  );
2385
- cur.html = cur.effects = cur.scripts = "";
2395
+ cur.html = cur.effects = cur.scripts = cur.lastEffect = "";
2386
2396
  cur.next = null;
2387
2397
  }
2388
2398
  if (next) {
package/dist/dom.js CHANGED
@@ -213,7 +213,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
213
213
  value: resumeRender = (renderId) => {
214
214
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
215
215
  _: registeredValues
216
- }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), currentBranchId, $global, lastScopeId = 0;
216
+ }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEffect, currentBranchId, $global, lastScopeId = 0;
217
217
  return render.w = () => {
218
218
  walk2.call(render);
219
219
  let visits = render.v, resumes = render.r;
@@ -287,7 +287,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
287
287
  }
288
288
  }
289
289
  else
290
- registeredValues[resumes[++i]](
290
+ typeof serialized == "string" && (lastEffect = serialized, serialized = resumes[++i]), registeredValues[lastEffect](
291
291
  scopeLookup[serialized],
292
292
  scopeLookup[serialized]
293
293
  );
package/dist/dom.mjs CHANGED
@@ -128,7 +128,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
128
128
  value: resumeRender = (renderId) => {
129
129
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
130
130
  _: registeredValues
131
- }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), currentBranchId, $global, lastScopeId = 0;
131
+ }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEffect, currentBranchId, $global, lastScopeId = 0;
132
132
  return render.w = () => {
133
133
  walk2.call(render);
134
134
  let visits = render.v, resumes = render.r;
@@ -202,7 +202,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
202
202
  }
203
203
  }
204
204
  else
205
- registeredValues[resumes[++i]](
205
+ typeof serialized == "string" && (lastEffect = serialized, serialized = resumes[++i]), registeredValues[lastEffect](
206
206
  scopeLookup[serialized],
207
207
  scopeLookup[serialized]
208
208
  );
@@ -108,6 +108,7 @@ export declare class Chunk {
108
108
  html: string;
109
109
  scripts: string;
110
110
  effects: string;
111
+ lastEffect: string;
111
112
  async: boolean;
112
113
  consumed: boolean;
113
114
  reorderId: string | null;
package/dist/html.js CHANGED
@@ -1432,7 +1432,7 @@ function tryCatch(content, catchContent) {
1432
1432
  let cur = body, writeMarker = !0;
1433
1433
  do {
1434
1434
  let next = cur.next;
1435
- cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1435
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1436
1436
  } while (cur !== bodyNext);
1437
1437
  }
1438
1438
  let catchChunk = new Chunk(boundary, null, chunk.context);
@@ -1513,6 +1513,7 @@ var State2 = class {
1513
1513
  html = "";
1514
1514
  scripts = "";
1515
1515
  effects = "";
1516
+ lastEffect = "";
1516
1517
  async = !1;
1517
1518
  consumed = !1;
1518
1519
  reorderId = null;
@@ -1522,16 +1523,16 @@ var State2 = class {
1522
1523
  this.html += html;
1523
1524
  }
1524
1525
  writeEffect(scopeId, registryId) {
1525
- this.effects = concatEffects(
1526
+ this.lastEffect === registryId ? this.effects += "," + scopeId : this.effects = concatEffects(
1526
1527
  this.effects,
1527
- scopeId + ',"' + registryId + '"'
1528
- );
1528
+ '"' + registryId + '",' + scopeId
1529
+ ), this.lastEffect = registryId;
1529
1530
  }
1530
1531
  writeScript(script) {
1531
1532
  this.scripts = concatScripts(this.scripts, script);
1532
1533
  }
1533
1534
  append(chunk) {
1534
- this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts);
1535
+ this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect;
1535
1536
  }
1536
1537
  flushPlaceholder() {
1537
1538
  if (this.placeholderBody) {
@@ -1551,11 +1552,11 @@ var State2 = class {
1551
1552
  consume() {
1552
1553
  let cur = this;
1553
1554
  if (cur.next && !cur.async) {
1554
- let html = "", effects = "", scripts = "";
1555
+ let html = "", effects = "", scripts = "", lastEffect = "";
1555
1556
  do
1556
- cur.flushPlaceholder(), html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), cur.consumed = !0, cur = cur.next;
1557
+ cur.flushPlaceholder(), html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), lastEffect = cur.lastEffect || lastEffect, cur.consumed = !0, cur = cur.next;
1557
1558
  while (cur.next && !cur.async);
1558
- cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts);
1559
+ cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts), cur.lastEffect = lastEffect;
1559
1560
  }
1560
1561
  return cur;
1561
1562
  }
@@ -1595,7 +1596,7 @@ var State2 = class {
1595
1596
  if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1596
1597
  "#" /* ReorderMarker */,
1597
1598
  cur.reorderId = state.nextReorderId()
1598
- ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1599
+ ), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next)
1599
1600
  cur = next;
1600
1601
  else
1601
1602
  break;
package/dist/html.mjs CHANGED
@@ -1350,7 +1350,7 @@ function tryCatch(content, catchContent) {
1350
1350
  let cur = body, writeMarker = !0;
1351
1351
  do {
1352
1352
  let next = cur.next;
1353
- cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1353
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = cur.lastEffect = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1354
1354
  } while (cur !== bodyNext);
1355
1355
  }
1356
1356
  let catchChunk = new Chunk(boundary, null, chunk.context);
@@ -1431,6 +1431,7 @@ var State2 = class {
1431
1431
  html = "";
1432
1432
  scripts = "";
1433
1433
  effects = "";
1434
+ lastEffect = "";
1434
1435
  async = !1;
1435
1436
  consumed = !1;
1436
1437
  reorderId = null;
@@ -1440,16 +1441,16 @@ var State2 = class {
1440
1441
  this.html += html;
1441
1442
  }
1442
1443
  writeEffect(scopeId, registryId) {
1443
- this.effects = concatEffects(
1444
+ this.lastEffect === registryId ? this.effects += "," + scopeId : this.effects = concatEffects(
1444
1445
  this.effects,
1445
- scopeId + ',"' + registryId + '"'
1446
- );
1446
+ '"' + registryId + '",' + scopeId
1447
+ ), this.lastEffect = registryId;
1447
1448
  }
1448
1449
  writeScript(script) {
1449
1450
  this.scripts = concatScripts(this.scripts, script);
1450
1451
  }
1451
1452
  append(chunk) {
1452
- this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts);
1453
+ this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect;
1453
1454
  }
1454
1455
  flushPlaceholder() {
1455
1456
  if (this.placeholderBody) {
@@ -1469,11 +1470,11 @@ var State2 = class {
1469
1470
  consume() {
1470
1471
  let cur = this;
1471
1472
  if (cur.next && !cur.async) {
1472
- let html = "", effects = "", scripts = "";
1473
+ let html = "", effects = "", scripts = "", lastEffect = "";
1473
1474
  do
1474
- cur.flushPlaceholder(), html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), cur.consumed = !0, cur = cur.next;
1475
+ cur.flushPlaceholder(), html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), lastEffect = cur.lastEffect || lastEffect, cur.consumed = !0, cur = cur.next;
1475
1476
  while (cur.next && !cur.async);
1476
- cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts);
1477
+ cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts), cur.lastEffect = lastEffect;
1477
1478
  }
1478
1479
  return cur;
1479
1480
  }
@@ -1513,7 +1514,7 @@ var State2 = class {
1513
1514
  if (cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1514
1515
  "#" /* ReorderMarker */,
1515
1516
  cur.reorderId = state.nextReorderId()
1516
- ), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
1517
+ ), cur.html = cur.effects = cur.scripts = cur.lastEffect = "", cur.next = null), next)
1517
1518
  cur = next;
1518
1519
  else
1519
1520
  break;
@@ -1518,6 +1518,22 @@ var reasonExprs = /* @__PURE__ */ new WeakMap();
1518
1518
  var keyedReasonExprs = /* @__PURE__ */ new WeakMap();
1519
1519
  var serializeKeysByBinding = /* @__PURE__ */ new WeakMap();
1520
1520
  var serializeKeyBySourceModifier = {};
1521
+ function forceOwnersSerialize(from, to, prop) {
1522
+ let cur = from;
1523
+ while (cur !== to && cur.parent) {
1524
+ forceSectionSerialize(cur, prop);
1525
+ cur = cur.parent;
1526
+ }
1527
+ }
1528
+ function addOwnersSerializeReason(from, to, reason, prop) {
1529
+ if (reason) {
1530
+ let cur = from;
1531
+ while (cur !== to && cur.parent) {
1532
+ addSectionSerializeReason(cur, reason, prop);
1533
+ cur = cur.parent;
1534
+ }
1535
+ }
1536
+ }
1521
1537
  function forceSectionSerialize(section, prop) {
1522
1538
  if (prop) {
1523
1539
  forceSerializeKey(section, getSectionPropSerializeReasonKey(section, prop));
@@ -1961,7 +1977,6 @@ function startSection(path5) {
1961
1977
  bindings: void 0,
1962
1978
  hoisted: void 0,
1963
1979
  isHoistThrough: void 0,
1964
- assignments: void 0,
1965
1980
  serializeReason: void 0,
1966
1981
  serializeReasons: /* @__PURE__ */ new Map(),
1967
1982
  content: getContentInfo(path5),
@@ -2105,9 +2120,6 @@ var isSerializedSection = (section) => {
2105
2120
  }
2106
2121
  return true;
2107
2122
  };
2108
- function isSectionWithHoists(section) {
2109
- return !!(section.hoisted || section.isHoistThrough || section.referencedHoists);
2110
- }
2111
2123
  function isImmediateOwner(section, binding) {
2112
2124
  return section.parent?.id === binding.section.id;
2113
2125
  }
@@ -2811,7 +2823,7 @@ var return_default = {
2811
2823
  }
2812
2824
  if (attrs2.valueChange) {
2813
2825
  forceSectionSerialize(
2814
- getSection(tag),
2826
+ getOrCreateSection(tag),
2815
2827
  getAccessorProp().TagVariableChange
2816
2828
  );
2817
2829
  }
@@ -3588,12 +3600,8 @@ function writeHTMLResumeStatements(path5) {
3588
3600
  const body = path5.node.body;
3589
3601
  const allSignals = Array.from(getSignals(section).values());
3590
3602
  const scopeIdIdentifier = getScopeIdIdentifier(section);
3591
- const serializeOwnersUntilBinding = (binding) => serializeOwners(section, binding.section);
3592
- forEach(section.assignments, serializeOwnersUntilBinding);
3593
- forEach(section.referencedHoists, serializeOwnersUntilBinding);
3594
3603
  forEach(section.referencedClosures, (closure) => {
3595
3604
  if (closure.sources) {
3596
- serializeOwnersUntilBinding(closure);
3597
3605
  if (isDynamicClosure(section, closure)) {
3598
3606
  const closureSignal = getSignal(closure.section, closure);
3599
3607
  let identifier = htmlDynamicClosureInstancesIdentifier.get(closureSignal);
@@ -3722,6 +3730,23 @@ function writeHTMLResumeStatements(path5) {
3722
3730
  )
3723
3731
  );
3724
3732
  });
3733
+ if (section.parent) {
3734
+ const ownerAccessor = getAccessorProp().Owner;
3735
+ const ownerReason = getSectionSerializeReason(section, ownerAccessor);
3736
+ if (ownerReason) {
3737
+ const getOwnerExpr = callRuntime(
3738
+ "ensureScopeWithId",
3739
+ getScopeIdIdentifier(section.parent)
3740
+ );
3741
+ serializedLookup.delete(ownerAccessor);
3742
+ serializedProperties.push(
3743
+ toObjectProperty(
3744
+ ownerAccessor,
3745
+ sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSerializeReasons(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(ownerReason, getOwnerExpr)
3746
+ )
3747
+ );
3748
+ }
3749
+ }
3725
3750
  for (const [key, { expression, reason }] of serializedLookup) {
3726
3751
  serializedProperties.push(
3727
3752
  toObjectProperty(key, getExprIfSerialized(reason, expression))
@@ -3806,23 +3831,6 @@ function writeHTMLResumeStatements(path5) {
3806
3831
  body.push(import_compiler20.types.returnStatement(returnIdentifier));
3807
3832
  }
3808
3833
  }
3809
- function serializeOwners(from, to) {
3810
- const ownerProp = getAccessorProp().Owner;
3811
- let cur = from;
3812
- while (cur !== to) {
3813
- const parent = cur.parent;
3814
- if (!parent) break;
3815
- const serialized = getSerializedAccessors(cur);
3816
- nonAnalyzedForceSerializedSection.add(cur);
3817
- cur = parent;
3818
- if (!serialized.has(ownerProp)) {
3819
- serialized.set(ownerProp, {
3820
- expression: callRuntime("ensureScopeWithId", getScopeIdIdentifier(cur)),
3821
- reason: true
3822
- });
3823
- }
3824
- }
3825
- }
3826
3834
  function getSetup(section) {
3827
3835
  return getSignals(section).get(void 0)?.identifier;
3828
3836
  }
@@ -4321,6 +4329,7 @@ function createBinding(name2, type, section, upstreamAlias, property, loc = null
4321
4329
  property,
4322
4330
  declared,
4323
4331
  closureSections: void 0,
4332
+ assignmentSections: void 0,
4324
4333
  excludeProperties: void 0,
4325
4334
  serializeSources: void 0,
4326
4335
  sources: void 0,
@@ -4418,7 +4427,6 @@ function trackHoistedReference(referencePath, binding) {
4418
4427
  currentSection = currentSection.parent;
4419
4428
  }
4420
4429
  }
4421
- extra.hoistedBinding = hoistedBinding;
4422
4430
  if (isInvokedFunction(referencePath)) {
4423
4431
  extra.read = createRead(hoistedBinding, void 0);
4424
4432
  extra.section = referenceSection;
@@ -4461,7 +4469,10 @@ function trackAssignment(assignment, binding) {
4461
4469
  forEachIdentifier(assignment.node, (id) => {
4462
4470
  if (id.name === binding.name) {
4463
4471
  const extra = id.extra ??= {};
4464
- section.assignments = bindingUtil.add(section.assignments, binding);
4472
+ binding.assignmentSections = sectionUtil.add(
4473
+ binding.assignmentSections,
4474
+ section
4475
+ );
4465
4476
  extra.assignment = binding;
4466
4477
  extra.section = section;
4467
4478
  }
@@ -4707,6 +4718,10 @@ function finalizeReferences() {
4707
4718
  if (binding.hoists.size) {
4708
4719
  forceBindingSerialize(binding.section, binding);
4709
4720
  }
4721
+ forEach(
4722
+ binding.assignmentSections,
4723
+ (assignedSection) => forceOwnersSerialize(assignedSection, section, getAccessorProp().Owner)
4724
+ );
4710
4725
  if (find(section.bindings, ({ name: name3 }) => name3 === binding.name)) {
4711
4726
  binding.name = generateUid(name2);
4712
4727
  }
@@ -4726,6 +4741,12 @@ function finalizeReferences() {
4726
4741
  section2.referencedClosures,
4727
4742
  binding
4728
4743
  );
4744
+ addOwnersSerializeReason(
4745
+ section2,
4746
+ binding.section,
4747
+ binding.serializeSources,
4748
+ getAccessorProp().Owner
4749
+ );
4729
4750
  }
4730
4751
  if (isEffect) {
4731
4752
  forEach(
@@ -4736,9 +4757,16 @@ function finalizeReferences() {
4736
4757
  }
4737
4758
  }
4738
4759
  forEachSection((section) => {
4739
- if (isSectionWithHoists(section)) {
4760
+ if (section.isHoistThrough) {
4740
4761
  forceSectionSerialize(section);
4741
4762
  }
4763
+ forEach(section.referencedHoists, (hoistedBinding) => {
4764
+ forceOwnersSerialize(
4765
+ section,
4766
+ hoistedBinding.section,
4767
+ getAccessorProp().Owner
4768
+ );
4769
+ });
4742
4770
  if (section.parent && section.isBranch && section.sectionAccessor && section.upstreamExpression) {
4743
4771
  addSectionSerializeReasonRef(section, getDirectClosures(section));
4744
4772
  addSectionSerializeReasonExpr(section, section.upstreamExpression);
@@ -5756,22 +5784,27 @@ var native_tag_default = {
5756
5784
  );
5757
5785
  }
5758
5786
  if (node.var) {
5759
- forceSectionSerialize(tagSection);
5760
5787
  forceBindingSerialize(tagSection, nodeBinding);
5761
- const varBinding = tag.scope.getBinding(node.var.name);
5762
- for (const referencePath of varBinding.referencePaths) {
5763
- const referenceSection = getSection(referencePath);
5764
- setReferencesScope(referencePath);
5765
- if (!isSameOrChildSection(tagSection, referenceSection)) {
5788
+ for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
5789
+ const refSection = getOrCreateSection(ref);
5790
+ setReferencesScope(ref);
5791
+ if (isSameOrChildSection(tagSection, refSection)) {
5792
+ forceOwnersSerialize(
5793
+ refSection,
5794
+ tagSection,
5795
+ getAccessorProp().Owner
5796
+ );
5797
+ if (!isInvokedFunction(ref)) {
5798
+ tagExtra[kGetterId] ||= getRegisterUID(
5799
+ tagSection,
5800
+ nodeBinding.name
5801
+ );
5802
+ }
5803
+ } else {
5766
5804
  trackHoistedReference(
5767
- referencePath,
5805
+ ref,
5768
5806
  nodeBinding
5769
5807
  );
5770
- } else if (!isInvokedFunction(referencePath)) {
5771
- tagExtra[kGetterId] ||= getRegisterUID(
5772
- tagSection,
5773
- nodeBinding.name
5774
- );
5775
5808
  }
5776
5809
  }
5777
5810
  } else if (hasEventHandlers || spreadReferenceNodes) {
@@ -5804,12 +5837,6 @@ var native_tag_default = {
5804
5837
  const varBinding = tag.scope.getBinding(varName);
5805
5838
  const getterId = tagExtra[kGetterId];
5806
5839
  if (isHTML) {
5807
- for (const reference of varBinding.referencePaths) {
5808
- const referenceSection = getSection(reference);
5809
- if (!reference.node.extra?.hoist) {
5810
- serializeOwners(referenceSection, tagSection);
5811
- }
5812
- }
5813
5840
  translateVar(
5814
5841
  tag,
5815
5842
  callRuntime(
@@ -5838,8 +5865,8 @@ var native_tag_default = {
5838
5865
  );
5839
5866
  }
5840
5867
  for (const reference of varBinding.referencePaths) {
5841
- if (!reference.node.extra?.hoistedBinding) {
5842
- const referenceSection = getSection(reference);
5868
+ const referenceSection = getSection(reference);
5869
+ if (isSameOrChildSection(tagSection, referenceSection)) {
5843
5870
  if (isInvokedFunction(reference)) {
5844
5871
  reference.parentPath.replaceWith(
5845
5872
  import_compiler31.types.expressionStatement(
@@ -6378,7 +6405,7 @@ var for_default = {
6378
6405
  forAttrs.by || import_compiler33.types.numericLiteral(0),
6379
6406
  getScopeIdIdentifier(tagSection),
6380
6407
  getScopeAccessorLiteral(nodeBinding),
6381
- branchSerializeReason !== true && markerSerializeReason && markerSerializeReason !== true && !bindingUtil.isSuperset(
6408
+ branchSerializeReason === true || markerSerializeReason === true ? import_compiler33.types.numericLiteral(1) : markerSerializeReason && !bindingUtil.isSuperset(
6382
6409
  branchSerializeReason,
6383
6410
  markerSerializeReason
6384
6411
  ) ? import_compiler33.types.logicalExpression(
@@ -7347,9 +7374,19 @@ var html_script_default = {
7347
7374
  if (node.var) {
7348
7375
  forceBindingSerialize(tagSection, nodeBinding);
7349
7376
  for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
7350
- if (!isInvokedFunction(ref)) {
7351
- tagExtra[kGetterId3] = getRegisterUID(tagSection, "#script");
7352
- break;
7377
+ const refSection = getOrCreateSection(ref);
7378
+ setReferencesScope(ref);
7379
+ if (isSameOrChildSection(tagSection, refSection)) {
7380
+ forceOwnersSerialize(
7381
+ refSection,
7382
+ tagSection,
7383
+ getAccessorProp().Owner
7384
+ );
7385
+ if (!tagExtra[kGetterId3] && !isInvokedFunction(ref)) {
7386
+ tagExtra[kGetterId3] = getRegisterUID(tagSection, "#script");
7387
+ }
7388
+ } else {
7389
+ trackHoistedReference(ref, nodeBinding);
7353
7390
  }
7354
7391
  }
7355
7392
  } else if (hasEventHandlers || spreadReferenceNodes) {
@@ -7374,11 +7411,6 @@ var html_script_default = {
7374
7411
  if (hasVar) {
7375
7412
  const getterId = tagExtra[kGetterId3];
7376
7413
  if (isHTML) {
7377
- const varName = tag.node.var.name;
7378
- const references = tag.scope.getBinding(varName).referencePaths;
7379
- for (const reference of references) {
7380
- serializeOwners(getSection(reference), tagSection);
7381
- }
7382
7414
  translateVar(
7383
7415
  tag,
7384
7416
  callRuntime(
@@ -7754,9 +7786,19 @@ var html_style_default = {
7754
7786
  if (node.var) {
7755
7787
  forceBindingSerialize(tagSection, nodeBinding);
7756
7788
  for (const ref of tag.scope.getBinding(node.var.name).referencePaths) {
7757
- if (!isInvokedFunction(ref)) {
7758
- tagExtra[kGetterId4] = getRegisterUID(tagSection, "#style");
7759
- break;
7789
+ const refSection = getOrCreateSection(ref);
7790
+ setReferencesScope(ref);
7791
+ if (isSameOrChildSection(tagSection, refSection)) {
7792
+ forceOwnersSerialize(
7793
+ refSection,
7794
+ tagSection,
7795
+ getAccessorProp().Owner
7796
+ );
7797
+ if (!tagExtra[kGetterId4] && !isInvokedFunction(ref)) {
7798
+ tagExtra[kGetterId4] = getRegisterUID(tagSection, "#style");
7799
+ }
7800
+ } else {
7801
+ trackHoistedReference(ref, nodeBinding);
7760
7802
  }
7761
7803
  }
7762
7804
  } else if (hasEventHandlers || spreadReferenceNodes) {
@@ -7781,11 +7823,6 @@ var html_style_default = {
7781
7823
  if (hasVar) {
7782
7824
  const getterId = tagExtra[kGetterId4];
7783
7825
  if (isHTML) {
7784
- const varName = tag.node.var.name;
7785
- const references = tag.scope.getBinding(varName).referencePaths;
7786
- for (const reference of references) {
7787
- serializeOwners(getSection(reference), tagSection);
7788
- }
7789
7826
  translateVar(
7790
7827
  tag,
7791
7828
  callRuntime(
@@ -8545,17 +8582,18 @@ var let_default = {
8545
8582
  "The `let` tag `valueChange` attribute must be a function."
8546
8583
  );
8547
8584
  }
8585
+ const tagSection = getOrCreateSection(tag);
8548
8586
  const binding = trackVarReferences(tag, 1 /* let */);
8549
8587
  setBindingValueExpr(
8550
8588
  binding,
8551
- mergeReferences(getOrCreateSection(tag), tag.node, [
8589
+ mergeReferences(tagSection, tag.node, [
8552
8590
  valueAttr?.value,
8553
8591
  valueChangeAttr?.value
8554
8592
  ])
8555
8593
  );
8556
8594
  if (valueChangeAttr) {
8557
8595
  forceBindingSerialize(
8558
- getSection(tag),
8596
+ tagSection,
8559
8597
  binding,
8560
8598
  getAccessorPrefix().TagVariableChange
8561
8599
  );
@@ -21,6 +21,7 @@ export interface Binding {
21
21
  loc: t.SourceLocation | null;
22
22
  section: Section;
23
23
  closureSections: Opt<Section>;
24
+ assignmentSections: Opt<Section>;
24
25
  sources: Opt<Binding>;
25
26
  serializeSources: undefined | SerializeReason;
26
27
  aliases: Set<Binding>;
@@ -45,7 +46,6 @@ declare module "@marko/compiler/dist/types" {
45
46
  section?: Section;
46
47
  referencedBindings?: ReferencedBindings;
47
48
  binding?: Binding;
48
- hoistedBinding?: Binding;
49
49
  assignment?: Binding;
50
50
  read?: {
51
51
  binding: Binding;
@@ -28,7 +28,6 @@ export interface Section {
28
28
  serializeReason: undefined | SerializeReason;
29
29
  serializeReasons: Map<symbol, SerializeReason>;
30
30
  isHoistThrough: true | undefined;
31
- assignments: ReferencedBindings;
32
31
  upstreamExpression: t.NodeExtra | undefined;
33
32
  downstreamBinding: Binding | undefined;
34
33
  hasAbortSignal: boolean;
@@ -53,7 +52,6 @@ export declare function startSection(path: t.NodePath<t.MarkoTagBody | t.Program
53
52
  export declare function getOrCreateSection(path: t.NodePath<any>): Section;
54
53
  export declare function getSectionForBody(body: t.NodePath<t.MarkoTagBody | t.Program>): Section | undefined;
55
54
  export declare function getSection(path: t.NodePath): Section;
56
- export declare function getParentSection(path: t.NodePath): Section;
57
55
  export declare const getScopeIdIdentifier: (section: Section) => t.Identifier;
58
56
  export declare const getSectionParentIsOwner: (section: Section) => boolean, setSectionParentIsOwner: (section: Section, value: boolean) => void;
59
57
  export declare const getScopeIdentifier: (section: Section, ignoreDefault?: boolean) => t.Identifier;
@@ -12,7 +12,8 @@ export type SerializeReason = true | DynamicSerializeReason;
12
12
  export type SerializeKey = symbol & {
13
13
  __serialize_key__: 1;
14
14
  };
15
- export declare function forceParentSectionsSerialize(from: Section, to?: Section): void;
15
+ export declare function forceOwnersSerialize(from: Section, to: Section, prop?: AccessorProp | symbol): void;
16
+ export declare function addOwnersSerializeReason(from: Section, to: Section, reason: undefined | boolean | SerializeReason, prop?: AccessorProp | symbol): void;
16
17
  export declare function forceSectionSerialize(section: Section, prop?: AccessorProp | symbol): void;
17
18
  export declare function forceBindingSerialize(section: Section, binding: Binding, prefix?: AccessorPrefix | symbol): void;
18
19
  export declare function isSectionForceSerialized(section: Section, prop?: AccessorProp | symbol): boolean;
@@ -56,7 +56,6 @@ export declare function writeSignals(section: Section): void;
56
56
  export declare function writeRegisteredFns(): void;
57
57
  export declare function addHTMLEffectCall(section: Section, referencedBindings?: ReferencedBindings): void;
58
58
  export declare function writeHTMLResumeStatements(path: t.NodePath<t.MarkoTagBody | t.Program>): void;
59
- export declare function serializeOwners(from: Section, to?: Section): void;
60
59
  export declare function getSetup(section: Section): t.Identifier | undefined;
61
60
  export declare function replaceRegisteredFunctionNode(node: t.Node): t.CallExpression | t.ClassPrivateProperty | t.ClassProperty | t.VariableDeclaration | t.Identifier | t.ObjectProperty | undefined;
62
61
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",