@marko/runtime-tags 6.0.103 → 6.0.104

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.
@@ -2454,9 +2454,11 @@ var Boundary = class extends AbortController {
2454
2454
  }
2455
2455
  onNext = NOOP;
2456
2456
  count = 0;
2457
- get done() {
2458
- flushSerializer(this);
2459
- return !this.count;
2457
+ flush() {
2458
+ if (!this.signal.aborted) {
2459
+ flushSerializer(this);
2460
+ }
2461
+ return this.count ? 1 /* continue */ : this.signal.aborted ? 2 /* aborted */ : 0 /* complete */;
2460
2462
  }
2461
2463
  startAsync() {
2462
2464
  if (!this.signal.aborted) {
@@ -3262,7 +3264,7 @@ var compat = {
3262
3264
  },
3263
3265
  flushScript($global2) {
3264
3266
  const boundary = new Boundary(this.ensureState($global2));
3265
- if (!boundary.done) {
3267
+ if (boundary.flush() === 1 /* continue */) {
3266
3268
  throw new Error(
3267
3269
  "Cannot serialize promise across tags/class compat layer."
3268
3270
  );
@@ -3508,11 +3510,14 @@ var ServerRendered = class {
3508
3510
  }
3509
3511
  const { boundary } = head;
3510
3512
  (boundary.onNext = () => {
3511
- if (boundary.signal.aborted) {
3512
- boundary.onNext = NOOP3;
3513
- reject(boundary.signal.reason);
3514
- } else if (!boundary.count && boundary.done) {
3515
- resolve(head.consume().flushHTML());
3513
+ switch (!boundary.count && boundary.flush()) {
3514
+ case 2 /* aborted */:
3515
+ boundary.onNext = NOOP3;
3516
+ reject(boundary.signal.reason);
3517
+ break;
3518
+ case 0 /* complete */:
3519
+ resolve(head.consume().flushHTML());
3520
+ break;
3516
3521
  }
3517
3522
  })();
3518
3523
  });
@@ -3527,25 +3532,23 @@ var ServerRendered = class {
3527
3532
  }
3528
3533
  const { boundary } = head;
3529
3534
  const onNext = boundary.onNext = (write) => {
3530
- if (boundary.signal.aborted) {
3535
+ const status = boundary.flush();
3536
+ if (status === 2 /* aborted */) {
3531
3537
  if (!tick2) offTick(onNext);
3532
3538
  boundary.onNext = NOOP3;
3533
3539
  onAbort(boundary.signal.reason);
3534
- } else {
3535
- const { done } = boundary;
3536
- if (done || write) {
3537
- const html = (head = head.consume()).flushHTML();
3538
- if (html) onWrite(html);
3539
- if (done) {
3540
- if (!tick2) offTick(onNext);
3541
- onClose();
3542
- } else {
3543
- tick2 = true;
3544
- }
3545
- } else if (tick2) {
3546
- tick2 = false;
3547
- queueTick(onNext);
3540
+ } else if (write || status === 0 /* complete */) {
3541
+ const html = (head = head.consume()).flushHTML();
3542
+ if (html) onWrite(html);
3543
+ if (status === 0 /* complete */) {
3544
+ if (!tick2) offTick(onNext);
3545
+ onClose();
3546
+ } else {
3547
+ tick2 = true;
3548
3548
  }
3549
+ } else if (tick2) {
3550
+ tick2 = false;
3551
+ queueTick(onNext);
3549
3552
  }
3550
3553
  };
3551
3554
  onNext();
@@ -3556,10 +3559,12 @@ var ServerRendered = class {
3556
3559
  this.#head = null;
3557
3560
  if (!head) throw new Error("Cannot read from a consumed render result");
3558
3561
  const { boundary } = head;
3559
- if (!boundary.done) {
3560
- throw new Error("Cannot consume asynchronous render with 'toString'");
3562
+ switch (boundary.flush()) {
3563
+ case 2 /* aborted */:
3564
+ throw boundary.signal.reason;
3565
+ case 1 /* continue */:
3566
+ throw new Error("Cannot consume asynchronous render with 'toString'");
3561
3567
  }
3562
- if (boundary.signal.aborted) throw boundary.signal.reason;
3563
3568
  return head.consume().flushHTML();
3564
3569
  }
3565
3570
  };
@@ -2362,9 +2362,11 @@ var Boundary = class extends AbortController {
2362
2362
  }
2363
2363
  onNext = NOOP;
2364
2364
  count = 0;
2365
- get done() {
2366
- flushSerializer(this);
2367
- return !this.count;
2365
+ flush() {
2366
+ if (!this.signal.aborted) {
2367
+ flushSerializer(this);
2368
+ }
2369
+ return this.count ? 1 /* continue */ : this.signal.aborted ? 2 /* aborted */ : 0 /* complete */;
2368
2370
  }
2369
2371
  startAsync() {
2370
2372
  if (!this.signal.aborted) {
@@ -3170,7 +3172,7 @@ var compat = {
3170
3172
  },
3171
3173
  flushScript($global2) {
3172
3174
  const boundary = new Boundary(this.ensureState($global2));
3173
- if (!boundary.done) {
3175
+ if (boundary.flush() === 1 /* continue */) {
3174
3176
  throw new Error(
3175
3177
  "Cannot serialize promise across tags/class compat layer."
3176
3178
  );
@@ -3416,11 +3418,14 @@ var ServerRendered = class {
3416
3418
  }
3417
3419
  const { boundary } = head;
3418
3420
  (boundary.onNext = () => {
3419
- if (boundary.signal.aborted) {
3420
- boundary.onNext = NOOP3;
3421
- reject(boundary.signal.reason);
3422
- } else if (!boundary.count && boundary.done) {
3423
- resolve(head.consume().flushHTML());
3421
+ switch (!boundary.count && boundary.flush()) {
3422
+ case 2 /* aborted */:
3423
+ boundary.onNext = NOOP3;
3424
+ reject(boundary.signal.reason);
3425
+ break;
3426
+ case 0 /* complete */:
3427
+ resolve(head.consume().flushHTML());
3428
+ break;
3424
3429
  }
3425
3430
  })();
3426
3431
  });
@@ -3435,25 +3440,23 @@ var ServerRendered = class {
3435
3440
  }
3436
3441
  const { boundary } = head;
3437
3442
  const onNext = boundary.onNext = (write) => {
3438
- if (boundary.signal.aborted) {
3443
+ const status = boundary.flush();
3444
+ if (status === 2 /* aborted */) {
3439
3445
  if (!tick2) offTick(onNext);
3440
3446
  boundary.onNext = NOOP3;
3441
3447
  onAbort(boundary.signal.reason);
3442
- } else {
3443
- const { done } = boundary;
3444
- if (done || write) {
3445
- const html = (head = head.consume()).flushHTML();
3446
- if (html) onWrite(html);
3447
- if (done) {
3448
- if (!tick2) offTick(onNext);
3449
- onClose();
3450
- } else {
3451
- tick2 = true;
3452
- }
3453
- } else if (tick2) {
3454
- tick2 = false;
3455
- queueTick(onNext);
3448
+ } else if (write || status === 0 /* complete */) {
3449
+ const html = (head = head.consume()).flushHTML();
3450
+ if (html) onWrite(html);
3451
+ if (status === 0 /* complete */) {
3452
+ if (!tick2) offTick(onNext);
3453
+ onClose();
3454
+ } else {
3455
+ tick2 = true;
3456
3456
  }
3457
+ } else if (tick2) {
3458
+ tick2 = false;
3459
+ queueTick(onNext);
3457
3460
  }
3458
3461
  };
3459
3462
  onNext();
@@ -3464,10 +3467,12 @@ var ServerRendered = class {
3464
3467
  this.#head = null;
3465
3468
  if (!head) throw new Error("Cannot read from a consumed render result");
3466
3469
  const { boundary } = head;
3467
- if (!boundary.done) {
3468
- throw new Error("Cannot consume asynchronous render with 'toString'");
3470
+ switch (boundary.flush()) {
3471
+ case 2 /* aborted */:
3472
+ throw boundary.signal.reason;
3473
+ case 1 /* continue */:
3474
+ throw new Error("Cannot consume asynchronous render with 'toString'");
3469
3475
  }
3470
- if (boundary.signal.aborted) throw boundary.signal.reason;
3471
3476
  return head.consume().flushHTML();
3472
3477
  }
3473
3478
  };
@@ -98,12 +98,17 @@ export declare class State {
98
98
  nextReorderId(): string;
99
99
  mark(code: ResumeSymbol | Mark, str: string): string;
100
100
  }
101
+ export declare enum FlushStatus {
102
+ complete = 0,
103
+ continue = 1,
104
+ aborted = 2
105
+ }
101
106
  export declare class Boundary extends AbortController {
102
107
  state: State;
103
108
  onNext: () => void;
104
109
  count: number;
105
110
  constructor(state: State, parent?: AbortSignal);
106
- get done(): boolean;
111
+ flush(): FlushStatus;
107
112
  startAsync(): void;
108
113
  endAsync(chunk?: Chunk): void;
109
114
  }
package/dist/html.js CHANGED
@@ -1539,7 +1539,8 @@ var State2 = class {
1539
1539
  mark(code, str) {
1540
1540
  return "<!--" + this.commentPrefix + code + str + "-->";
1541
1541
  }
1542
- }, Boundary = class extends AbortController {
1542
+ };
1543
+ var Boundary = class extends AbortController {
1543
1544
  constructor(state, parent) {
1544
1545
  super();
1545
1546
  this.state = state;
@@ -1551,8 +1552,8 @@ var State2 = class {
1551
1552
  }
1552
1553
  onNext = NOOP;
1553
1554
  count = 0;
1554
- get done() {
1555
- return flushSerializer(this), !this.count;
1555
+ flush() {
1556
+ return this.signal.aborted || flushSerializer(this), this.count ? 1 /* continue */ : this.signal.aborted ? 2 /* aborted */ : 0 /* complete */;
1556
1557
  }
1557
1558
  startAsync() {
1558
1559
  this.signal.aborted || this.count++;
@@ -2079,7 +2080,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2079
2080
  },
2080
2081
  flushScript($global2) {
2081
2082
  let boundary = new Boundary(this.ensureState($global2));
2082
- if (!boundary.done)
2083
+ if (boundary.flush() === 1 /* continue */)
2083
2084
  throw new Error(
2084
2085
  "Cannot serialize promise across tags/class compat layer."
2085
2086
  );
@@ -2236,7 +2237,14 @@ var ServerRendered = class {
2236
2237
  return reject(new Error("Cannot read from a consumed render result"));
2237
2238
  let { boundary } = head;
2238
2239
  (boundary.onNext = () => {
2239
- boundary.signal.aborted ? (boundary.onNext = NOOP3, reject(boundary.signal.reason)) : !boundary.count && boundary.done && resolve(head.consume().flushHTML());
2240
+ switch (!boundary.count && boundary.flush()) {
2241
+ case 2 /* aborted */:
2242
+ boundary.onNext = NOOP3, reject(boundary.signal.reason);
2243
+ break;
2244
+ case 0 /* complete */:
2245
+ resolve(head.consume().flushHTML());
2246
+ break;
2247
+ }
2240
2248
  })();
2241
2249
  });
2242
2250
  }
@@ -2247,15 +2255,13 @@ var ServerRendered = class {
2247
2255
  return;
2248
2256
  }
2249
2257
  let { boundary } = head, onNext = boundary.onNext = (write) => {
2250
- if (boundary.signal.aborted)
2258
+ let status = boundary.flush();
2259
+ if (status === 2 /* aborted */)
2251
2260
  tick2 || offTick(onNext), boundary.onNext = NOOP3, onAbort(boundary.signal.reason);
2252
- else {
2253
- let { done } = boundary;
2254
- if (done || write) {
2255
- let html = (head = head.consume()).flushHTML();
2256
- html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2257
- } else tick2 && (tick2 = !1, queueTick(onNext));
2258
- }
2261
+ else if (write || status === 0 /* complete */) {
2262
+ let html = (head = head.consume()).flushHTML();
2263
+ html && onWrite(html), status === 0 /* complete */ ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2264
+ } else tick2 && (tick2 = !1, queueTick(onNext));
2259
2265
  };
2260
2266
  return onNext(), boundary;
2261
2267
  }
@@ -2263,9 +2269,12 @@ var ServerRendered = class {
2263
2269
  let head = this.#head;
2264
2270
  if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
2265
2271
  let { boundary } = head;
2266
- if (!boundary.done)
2267
- throw new Error("Cannot consume asynchronous render with 'toString'");
2268
- if (boundary.signal.aborted) throw boundary.signal.reason;
2272
+ switch (boundary.flush()) {
2273
+ case 2 /* aborted */:
2274
+ throw boundary.signal.reason;
2275
+ case 1 /* continue */:
2276
+ throw new Error("Cannot consume asynchronous render with 'toString'");
2277
+ }
2269
2278
  return head.consume().flushHTML();
2270
2279
  }
2271
2280
  };
package/dist/html.mjs CHANGED
@@ -1450,7 +1450,8 @@ var State2 = class {
1450
1450
  mark(code, str) {
1451
1451
  return "<!--" + this.commentPrefix + code + str + "-->";
1452
1452
  }
1453
- }, Boundary = class extends AbortController {
1453
+ };
1454
+ var Boundary = class extends AbortController {
1454
1455
  constructor(state, parent) {
1455
1456
  super();
1456
1457
  this.state = state;
@@ -1462,8 +1463,8 @@ var State2 = class {
1462
1463
  }
1463
1464
  onNext = NOOP;
1464
1465
  count = 0;
1465
- get done() {
1466
- return flushSerializer(this), !this.count;
1466
+ flush() {
1467
+ return this.signal.aborted || flushSerializer(this), this.count ? 1 /* continue */ : this.signal.aborted ? 2 /* aborted */ : 0 /* complete */;
1467
1468
  }
1468
1469
  startAsync() {
1469
1470
  this.signal.aborted || this.count++;
@@ -1990,7 +1991,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
1990
1991
  },
1991
1992
  flushScript($global2) {
1992
1993
  let boundary = new Boundary(this.ensureState($global2));
1993
- if (!boundary.done)
1994
+ if (boundary.flush() === 1 /* continue */)
1994
1995
  throw new Error(
1995
1996
  "Cannot serialize promise across tags/class compat layer."
1996
1997
  );
@@ -2147,7 +2148,14 @@ var ServerRendered = class {
2147
2148
  return reject(new Error("Cannot read from a consumed render result"));
2148
2149
  let { boundary } = head;
2149
2150
  (boundary.onNext = () => {
2150
- boundary.signal.aborted ? (boundary.onNext = NOOP3, reject(boundary.signal.reason)) : !boundary.count && boundary.done && resolve(head.consume().flushHTML());
2151
+ switch (!boundary.count && boundary.flush()) {
2152
+ case 2 /* aborted */:
2153
+ boundary.onNext = NOOP3, reject(boundary.signal.reason);
2154
+ break;
2155
+ case 0 /* complete */:
2156
+ resolve(head.consume().flushHTML());
2157
+ break;
2158
+ }
2151
2159
  })();
2152
2160
  });
2153
2161
  }
@@ -2158,15 +2166,13 @@ var ServerRendered = class {
2158
2166
  return;
2159
2167
  }
2160
2168
  let { boundary } = head, onNext = boundary.onNext = (write) => {
2161
- if (boundary.signal.aborted)
2169
+ let status = boundary.flush();
2170
+ if (status === 2 /* aborted */)
2162
2171
  tick2 || offTick(onNext), boundary.onNext = NOOP3, onAbort(boundary.signal.reason);
2163
- else {
2164
- let { done } = boundary;
2165
- if (done || write) {
2166
- let html = (head = head.consume()).flushHTML();
2167
- html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2168
- } else tick2 && (tick2 = !1, queueTick(onNext));
2169
- }
2172
+ else if (write || status === 0 /* complete */) {
2173
+ let html = (head = head.consume()).flushHTML();
2174
+ html && onWrite(html), status === 0 /* complete */ ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
2175
+ } else tick2 && (tick2 = !1, queueTick(onNext));
2170
2176
  };
2171
2177
  return onNext(), boundary;
2172
2178
  }
@@ -2174,9 +2180,12 @@ var ServerRendered = class {
2174
2180
  let head = this.#head;
2175
2181
  if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
2176
2182
  let { boundary } = head;
2177
- if (!boundary.done)
2178
- throw new Error("Cannot consume asynchronous render with 'toString'");
2179
- if (boundary.signal.aborted) throw boundary.signal.reason;
2183
+ switch (boundary.flush()) {
2184
+ case 2 /* aborted */:
2185
+ throw boundary.signal.reason;
2186
+ case 1 /* continue */:
2187
+ throw new Error("Cannot consume asynchronous render with 'toString'");
2188
+ }
2180
2189
  return head.consume().flushHTML();
2181
2190
  }
2182
2191
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.0.103",
3
+ "version": "6.0.104",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",