marko 6.0.6 → 6.0.7

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.
@@ -2088,22 +2088,27 @@ function ensureScopeWithId(scopeId) {
2088
2088
  function $global() {
2089
2089
  return $chunk.boundary.state.$global;
2090
2090
  }
2091
- function fork(scopeId, accessor, promise, content) {
2091
+ function fork(scopeId, accessor, promise, content, serializeMarker) {
2092
+ const resumeMarker = serializeMarker !== 0;
2092
2093
  if (!isPromise(promise)) {
2093
- const branchId = peekNextScopeId();
2094
- $chunk.writeHTML(
2095
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2096
- );
2097
- content(promise);
2098
- writeScope(scopeId, {
2099
- ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2100
- });
2101
- $chunk.writeHTML(
2102
- $chunk.boundary.state.mark(
2103
- "]" /* BranchEnd */,
2104
- scopeId + " " + accessor
2105
- )
2106
- );
2094
+ if (resumeMarker) {
2095
+ const branchId = peekNextScopeId();
2096
+ $chunk.writeHTML(
2097
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2098
+ );
2099
+ content(promise);
2100
+ writeScope(scopeId, {
2101
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2102
+ });
2103
+ $chunk.writeHTML(
2104
+ $chunk.boundary.state.mark(
2105
+ "]" /* BranchEnd */,
2106
+ scopeId + " " + accessor
2107
+ )
2108
+ );
2109
+ } else {
2110
+ content(promise);
2111
+ }
2107
2112
  return;
2108
2113
  }
2109
2114
  const chunk = $chunk;
@@ -2120,25 +2125,29 @@ function fork(scopeId, accessor, promise, content) {
2120
2125
  chunk.async = false;
2121
2126
  if (!boundary.signal.aborted) {
2122
2127
  chunk.render(() => {
2123
- const branchId = peekNextScopeId();
2124
- $chunk.writeHTML(
2125
- $chunk.boundary.state.mark(
2126
- "[" /* BranchStart */,
2127
- branchId + ""
2128
- )
2129
- );
2130
- content(value);
2131
- boundary.state.serializer.writeAssign(
2132
- writeScope(branchId, {}),
2133
- ensureScopeWithId(scopeId),
2134
- "ConditionalScope:" /* ConditionalScope */ + accessor
2135
- );
2136
- $chunk.writeHTML(
2137
- $chunk.boundary.state.mark(
2138
- "]" /* BranchEnd */,
2139
- scopeId + " " + accessor
2140
- )
2141
- );
2128
+ if (resumeMarker) {
2129
+ const branchId = peekNextScopeId();
2130
+ $chunk.writeHTML(
2131
+ $chunk.boundary.state.mark(
2132
+ "[" /* BranchStart */,
2133
+ branchId + ""
2134
+ )
2135
+ );
2136
+ content(value);
2137
+ boundary.state.serializer.writeAssign(
2138
+ writeScope(branchId, {}),
2139
+ ensureScopeWithId(scopeId),
2140
+ "ConditionalScope:" /* ConditionalScope */ + accessor
2141
+ );
2142
+ $chunk.writeHTML(
2143
+ $chunk.boundary.state.mark(
2144
+ "]" /* BranchEnd */,
2145
+ scopeId + " " + accessor
2146
+ )
2147
+ );
2148
+ } else {
2149
+ content(value);
2150
+ }
2142
2151
  });
2143
2152
  boundary.endAsync(chunk);
2144
2153
  }
@@ -2376,12 +2385,12 @@ var Chunk = class {
2376
2385
  if (this.lastEffect === registryId) {
2377
2386
  this.effects += "," + scopeId;
2378
2387
  } else {
2388
+ this.lastEffect = registryId;
2379
2389
  this.effects = concatEffects(
2380
2390
  this.effects,
2381
2391
  '"' + registryId + '",' + scopeId
2382
2392
  );
2383
2393
  }
2384
- this.lastEffect = registryId;
2385
2394
  }
2386
2395
  writeScript(script) {
2387
2396
  this.scripts = concatScripts(this.scripts, script);
@@ -2545,9 +2554,9 @@ var Chunk = class {
2545
2554
  if (hasWalk) {
2546
2555
  scripts = concatScripts(scripts, runtimePrefix + ".w()");
2547
2556
  }
2548
- this.effects = state.resumes = "";
2549
2557
  this.html = html;
2550
2558
  this.scripts = scripts;
2559
+ this.effects = this.lastEffect = state.resumes = "";
2551
2560
  return this;
2552
2561
  }
2553
2562
  flushHTML() {
@@ -2003,22 +2003,27 @@ function ensureScopeWithId(scopeId) {
2003
2003
  function $global() {
2004
2004
  return $chunk.boundary.state.$global;
2005
2005
  }
2006
- function fork(scopeId, accessor, promise, content) {
2006
+ function fork(scopeId, accessor, promise, content, serializeMarker) {
2007
+ const resumeMarker = serializeMarker !== 0;
2007
2008
  if (!isPromise(promise)) {
2008
- const branchId = peekNextScopeId();
2009
- $chunk.writeHTML(
2010
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2011
- );
2012
- content(promise);
2013
- writeScope(scopeId, {
2014
- ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2015
- });
2016
- $chunk.writeHTML(
2017
- $chunk.boundary.state.mark(
2018
- "]" /* BranchEnd */,
2019
- scopeId + " " + accessor
2020
- )
2021
- );
2009
+ if (resumeMarker) {
2010
+ const branchId = peekNextScopeId();
2011
+ $chunk.writeHTML(
2012
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2013
+ );
2014
+ content(promise);
2015
+ writeScope(scopeId, {
2016
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2017
+ });
2018
+ $chunk.writeHTML(
2019
+ $chunk.boundary.state.mark(
2020
+ "]" /* BranchEnd */,
2021
+ scopeId + " " + accessor
2022
+ )
2023
+ );
2024
+ } else {
2025
+ content(promise);
2026
+ }
2022
2027
  return;
2023
2028
  }
2024
2029
  const chunk = $chunk;
@@ -2035,25 +2040,29 @@ function fork(scopeId, accessor, promise, content) {
2035
2040
  chunk.async = false;
2036
2041
  if (!boundary.signal.aborted) {
2037
2042
  chunk.render(() => {
2038
- const branchId = peekNextScopeId();
2039
- $chunk.writeHTML(
2040
- $chunk.boundary.state.mark(
2041
- "[" /* BranchStart */,
2042
- branchId + ""
2043
- )
2044
- );
2045
- content(value);
2046
- boundary.state.serializer.writeAssign(
2047
- writeScope(branchId, {}),
2048
- ensureScopeWithId(scopeId),
2049
- "ConditionalScope:" /* ConditionalScope */ + accessor
2050
- );
2051
- $chunk.writeHTML(
2052
- $chunk.boundary.state.mark(
2053
- "]" /* BranchEnd */,
2054
- scopeId + " " + accessor
2055
- )
2056
- );
2043
+ if (resumeMarker) {
2044
+ const branchId = peekNextScopeId();
2045
+ $chunk.writeHTML(
2046
+ $chunk.boundary.state.mark(
2047
+ "[" /* BranchStart */,
2048
+ branchId + ""
2049
+ )
2050
+ );
2051
+ content(value);
2052
+ boundary.state.serializer.writeAssign(
2053
+ writeScope(branchId, {}),
2054
+ ensureScopeWithId(scopeId),
2055
+ "ConditionalScope:" /* ConditionalScope */ + accessor
2056
+ );
2057
+ $chunk.writeHTML(
2058
+ $chunk.boundary.state.mark(
2059
+ "]" /* BranchEnd */,
2060
+ scopeId + " " + accessor
2061
+ )
2062
+ );
2063
+ } else {
2064
+ content(value);
2065
+ }
2057
2066
  });
2058
2067
  boundary.endAsync(chunk);
2059
2068
  }
@@ -2291,12 +2300,12 @@ var Chunk = class {
2291
2300
  if (this.lastEffect === registryId) {
2292
2301
  this.effects += "," + scopeId;
2293
2302
  } else {
2303
+ this.lastEffect = registryId;
2294
2304
  this.effects = concatEffects(
2295
2305
  this.effects,
2296
2306
  '"' + registryId + '",' + scopeId
2297
2307
  );
2298
2308
  }
2299
- this.lastEffect = registryId;
2300
2309
  }
2301
2310
  writeScript(script) {
2302
2311
  this.scripts = concatScripts(this.scripts, script);
@@ -2460,9 +2469,9 @@ var Chunk = class {
2460
2469
  if (hasWalk) {
2461
2470
  scripts = concatScripts(scripts, runtimePrefix + ".w()");
2462
2471
  }
2463
- this.effects = state.resumes = "";
2464
2472
  this.html = html;
2465
2473
  this.scripts = scripts;
2474
+ this.effects = this.lastEffect = state.resumes = "";
2466
2475
  return this;
2467
2476
  }
2468
2477
  flushHTML() {
@@ -51,7 +51,7 @@ export declare function $global(): $Global & {
51
51
  renderId: string;
52
52
  runtimeId: string;
53
53
  };
54
- export declare function fork<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void): void;
54
+ export declare function fork<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void, serializeMarker?: 0 | 1): void;
55
55
  export declare function tryContent(scopeId: number, accessor: Accessor, content: () => void, input: {
56
56
  placeholder?: {
57
57
  content?(): void;
package/dist/html.js CHANGED
@@ -1349,41 +1349,48 @@ function ensureScopeWithId(scopeId) {
1349
1349
  function $global() {
1350
1350
  return $chunk.boundary.state.$global;
1351
1351
  }
1352
- function fork(scopeId, accessor, promise, content) {
1352
+ function fork(scopeId, accessor, promise, content, serializeMarker) {
1353
+ let resumeMarker = serializeMarker !== 0;
1353
1354
  if (!isPromise(promise)) {
1354
- let branchId = peekNextScopeId();
1355
- $chunk.writeHTML(
1356
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1357
- ), content(promise), writeScope(scopeId, {
1358
- ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1359
- }), $chunk.writeHTML(
1360
- $chunk.boundary.state.mark(
1361
- "]" /* BranchEnd */,
1362
- scopeId + " " + accessor
1363
- )
1364
- );
1355
+ if (resumeMarker) {
1356
+ let branchId = peekNextScopeId();
1357
+ $chunk.writeHTML(
1358
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1359
+ ), content(promise), writeScope(scopeId, {
1360
+ ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1361
+ }), $chunk.writeHTML(
1362
+ $chunk.boundary.state.mark(
1363
+ "]" /* BranchEnd */,
1364
+ scopeId + " " + accessor
1365
+ )
1366
+ );
1367
+ } else
1368
+ content(promise);
1365
1369
  return;
1366
1370
  }
1367
1371
  let chunk = $chunk, { boundary } = chunk;
1368
1372
  chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
1369
1373
  (value) => {
1370
1374
  chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
1371
- let branchId = peekNextScopeId();
1372
- $chunk.writeHTML(
1373
- $chunk.boundary.state.mark(
1374
- "[" /* BranchStart */,
1375
- branchId + ""
1376
- )
1377
- ), content(value), boundary.state.serializer.writeAssign(
1378
- writeScope(branchId, {}),
1379
- ensureScopeWithId(scopeId),
1380
- "d" /* ConditionalScope */ + accessor
1381
- ), $chunk.writeHTML(
1382
- $chunk.boundary.state.mark(
1383
- "]" /* BranchEnd */,
1384
- scopeId + " " + accessor
1385
- )
1386
- );
1375
+ if (resumeMarker) {
1376
+ let branchId = peekNextScopeId();
1377
+ $chunk.writeHTML(
1378
+ $chunk.boundary.state.mark(
1379
+ "[" /* BranchStart */,
1380
+ branchId + ""
1381
+ )
1382
+ ), content(value), boundary.state.serializer.writeAssign(
1383
+ writeScope(branchId, {}),
1384
+ ensureScopeWithId(scopeId),
1385
+ "d" /* ConditionalScope */ + accessor
1386
+ ), $chunk.writeHTML(
1387
+ $chunk.boundary.state.mark(
1388
+ "]" /* BranchEnd */,
1389
+ scopeId + " " + accessor
1390
+ )
1391
+ );
1392
+ } else
1393
+ content(value);
1387
1394
  }), boundary.endAsync(chunk)));
1388
1395
  },
1389
1396
  (err) => {
@@ -1530,10 +1537,10 @@ var State2 = class {
1530
1537
  this.html += html;
1531
1538
  }
1532
1539
  writeEffect(scopeId, registryId) {
1533
- this.lastEffect === registryId ? this.effects += "," + scopeId : this.effects = concatEffects(
1540
+ this.lastEffect === registryId ? this.effects += "," + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(
1534
1541
  this.effects,
1535
1542
  '"' + registryId + '",' + scopeId
1536
- ), this.lastEffect = registryId;
1543
+ ));
1537
1544
  }
1538
1545
  writeScript(script) {
1539
1546
  this.scripts = concatScripts(this.scripts, script);
@@ -1621,7 +1628,7 @@ var State2 = class {
1621
1628
  }
1622
1629
  state.writeReorders = null;
1623
1630
  }
1624
- return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.effects = state.resumes = "", this.html = html, this.scripts = scripts, this;
1631
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
1625
1632
  }
1626
1633
  flushHTML() {
1627
1634
  this.flushScript();
package/dist/html.mjs CHANGED
@@ -1267,41 +1267,48 @@ function ensureScopeWithId(scopeId) {
1267
1267
  function $global() {
1268
1268
  return $chunk.boundary.state.$global;
1269
1269
  }
1270
- function fork(scopeId, accessor, promise, content) {
1270
+ function fork(scopeId, accessor, promise, content, serializeMarker) {
1271
+ let resumeMarker = serializeMarker !== 0;
1271
1272
  if (!isPromise(promise)) {
1272
- let branchId = peekNextScopeId();
1273
- $chunk.writeHTML(
1274
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1275
- ), content(promise), writeScope(scopeId, {
1276
- ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1277
- }), $chunk.writeHTML(
1278
- $chunk.boundary.state.mark(
1279
- "]" /* BranchEnd */,
1280
- scopeId + " " + accessor
1281
- )
1282
- );
1273
+ if (resumeMarker) {
1274
+ let branchId = peekNextScopeId();
1275
+ $chunk.writeHTML(
1276
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1277
+ ), content(promise), writeScope(scopeId, {
1278
+ ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1279
+ }), $chunk.writeHTML(
1280
+ $chunk.boundary.state.mark(
1281
+ "]" /* BranchEnd */,
1282
+ scopeId + " " + accessor
1283
+ )
1284
+ );
1285
+ } else
1286
+ content(promise);
1283
1287
  return;
1284
1288
  }
1285
1289
  let chunk = $chunk, { boundary } = chunk;
1286
1290
  chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
1287
1291
  (value) => {
1288
1292
  chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
1289
- let branchId = peekNextScopeId();
1290
- $chunk.writeHTML(
1291
- $chunk.boundary.state.mark(
1292
- "[" /* BranchStart */,
1293
- branchId + ""
1294
- )
1295
- ), content(value), boundary.state.serializer.writeAssign(
1296
- writeScope(branchId, {}),
1297
- ensureScopeWithId(scopeId),
1298
- "d" /* ConditionalScope */ + accessor
1299
- ), $chunk.writeHTML(
1300
- $chunk.boundary.state.mark(
1301
- "]" /* BranchEnd */,
1302
- scopeId + " " + accessor
1303
- )
1304
- );
1293
+ if (resumeMarker) {
1294
+ let branchId = peekNextScopeId();
1295
+ $chunk.writeHTML(
1296
+ $chunk.boundary.state.mark(
1297
+ "[" /* BranchStart */,
1298
+ branchId + ""
1299
+ )
1300
+ ), content(value), boundary.state.serializer.writeAssign(
1301
+ writeScope(branchId, {}),
1302
+ ensureScopeWithId(scopeId),
1303
+ "d" /* ConditionalScope */ + accessor
1304
+ ), $chunk.writeHTML(
1305
+ $chunk.boundary.state.mark(
1306
+ "]" /* BranchEnd */,
1307
+ scopeId + " " + accessor
1308
+ )
1309
+ );
1310
+ } else
1311
+ content(value);
1305
1312
  }), boundary.endAsync(chunk)));
1306
1313
  },
1307
1314
  (err) => {
@@ -1448,10 +1455,10 @@ var State2 = class {
1448
1455
  this.html += html;
1449
1456
  }
1450
1457
  writeEffect(scopeId, registryId) {
1451
- this.lastEffect === registryId ? this.effects += "," + scopeId : this.effects = concatEffects(
1458
+ this.lastEffect === registryId ? this.effects += "," + scopeId : (this.lastEffect = registryId, this.effects = concatEffects(
1452
1459
  this.effects,
1453
1460
  '"' + registryId + '",' + scopeId
1454
- ), this.lastEffect = registryId;
1461
+ ));
1455
1462
  }
1456
1463
  writeScript(script) {
1457
1464
  this.scripts = concatScripts(this.scripts, script);
@@ -1539,7 +1546,7 @@ var State2 = class {
1539
1546
  }
1540
1547
  state.writeReorders = null;
1541
1548
  }
1542
- return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.effects = state.resumes = "", this.html = html, this.scripts = scripts, this;
1549
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
1543
1550
  }
1544
1551
  flushHTML() {
1545
1552
  this.flushScript();
@@ -5265,6 +5265,8 @@ var await_default = {
5265
5265
  const nodeRef2 = tagExtra[kDOMBinding];
5266
5266
  const tagBody = tag.get("body");
5267
5267
  const section = getSection(tag);
5268
+ const bodySection = getSectionForBody(tagBody);
5269
+ const serializeReason = bodySection && getSectionSerializeReason(bodySection);
5268
5270
  flushInto(tag);
5269
5271
  writeHTMLResumeStatements(tagBody);
5270
5272
  tag.replaceWith(
@@ -5277,7 +5279,8 @@ var await_default = {
5277
5279
  import_compiler25.types.arrowFunctionExpression(
5278
5280
  node.body.params,
5279
5281
  toFirstExpressionOrBlock(node.body.body)
5280
- )
5282
+ ),
5283
+ !serializeReason ? import_compiler25.types.numericLiteral(0) : serializeReason === true ? void 0 : getSerializeGuard(serializeReason)
5281
5284
  )
5282
5285
  )
5283
5286
  )[0].skip();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",