octane 0.2.3 → 0.2.5

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.
Files changed (41) hide show
  1. package/dist/cjs/constants.cjs +9 -0
  2. package/dist/cjs/css.cjs +9 -0
  3. package/dist/cjs/dom-tables.cjs +6 -1
  4. package/dist/cjs/error-codes.client.generated.cjs +2 -0
  5. package/dist/cjs/host-property-diagnostics.cjs +2 -0
  6. package/dist/cjs/index.cjs +2 -0
  7. package/dist/cjs/runtime.cjs +604 -78
  8. package/dist/cjs/runtime.server.cjs +280 -68
  9. package/dist/cjs/server/index.cjs +4 -0
  10. package/dist/cjs/version.cjs +1 -1
  11. package/dist/compiler/bundler.js +14 -1
  12. package/dist/compiler/compile.js +270 -528
  13. package/dist/compiler/hook-methods.js +164 -0
  14. package/dist/compiler/hydrate-boundaries.js +165 -15
  15. package/dist/compiler/parser-output.js +37 -0
  16. package/dist/compiler/parser.browser.js +145 -1
  17. package/dist/compiler/parser.node.js +28 -36
  18. package/dist/compiler/plain-hook-memo.js +37 -0
  19. package/dist/compiler/slot-hooks.js +129 -5
  20. package/dist/compiler/strong-mode.js +836 -3
  21. package/dist/compiler/style-scopes.js +1134 -0
  22. package/dist/compiler/volar.LICENSES.txt +1 -1
  23. package/dist/compiler/volar.js +5781 -3934
  24. package/dist/constants.d.ts +3 -0
  25. package/dist/constants.js +6 -0
  26. package/dist/css.d.ts +7 -0
  27. package/dist/css.js +8 -0
  28. package/dist/dom-tables.js +6 -1
  29. package/dist/error-codes.client.generated.d.ts +1 -0
  30. package/dist/error-codes.client.generated.js +2 -0
  31. package/dist/host-property-diagnostics.js +2 -0
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +2 -0
  34. package/dist/runtime.d.ts +35 -15
  35. package/dist/runtime.js +612 -79
  36. package/dist/runtime.server.d.ts +30 -1
  37. package/dist/runtime.server.js +287 -69
  38. package/dist/server/index.d.ts +1 -1
  39. package/dist/server/index.js +4 -0
  40. package/dist/version.js +1 -1
  41. package/package.json +5 -5
@@ -33,6 +33,7 @@ __export(runtime_server_exports, {
33
33
  addTransitionType: () => addTransitionType,
34
34
  beginNativeReadScope: () => beginNativeReadScope,
35
35
  beginNativeReadWitness: () => beginNativeReadWitness,
36
+ callWithReceiver: () => callWithReceiver,
36
37
  cloneElement: () => cloneElement,
37
38
  createContext: () => createContext,
38
39
  createElement: () => createElement,
@@ -136,6 +137,8 @@ __export(runtime_server_exports, {
136
137
  ssrValueAttr: () => ssrValueAttr,
137
138
  ssrVoidContent: () => ssrVoidContent,
138
139
  startTransition: () => startTransition,
140
+ styleMap: () => styleMap,
141
+ touchStyleMap: () => touchStyleMap,
139
142
  use: () => use,
140
143
  useActionState: () => useActionState,
141
144
  useCallback: () => useCallback,
@@ -965,9 +968,13 @@ function ssrComponentDescriptor(d, scope) {
965
968
  if (SCOPED_ELEMENT_PROPS.has(d.props)) {
966
969
  return ssrComponent(scope, d.type, d.props);
967
970
  }
971
+ const children = d.children;
972
+ if (children == null || children === d.props?.children) {
973
+ return ssrComponent(scope, d.type, d.props);
974
+ }
968
975
  return ssrComponent(scope, d.type, {
969
976
  ...d.props,
970
- children: d.children ?? d.props?.children
977
+ children
971
978
  });
972
979
  }
973
980
  function ssrChild(v, scope) {
@@ -1565,8 +1572,9 @@ function isAggregatedFormAttribute(tag, name) {
1565
1572
  function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1566
1573
  namespace = resolveAttributeNamespace(namespace);
1567
1574
  const props = /* @__PURE__ */ new Map();
1575
+ let classMerges = null;
1568
1576
  let sourceOrder = 0;
1569
- const record = (rawName, value) => {
1577
+ function record(rawName, value) {
1570
1578
  if (typeof rawName !== "string") return;
1571
1579
  const order = sourceOrder++;
1572
1580
  const previous = props.get(rawName);
@@ -1576,9 +1584,17 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1576
1584
  firstOrder: previous?.firstOrder ?? order,
1577
1585
  lastOrder: order
1578
1586
  });
1579
- };
1580
- for (const [isSpread, sourceOrName, directValue] of sources) {
1587
+ }
1588
+ for (const [isSpread, sourceOrName, directValue, merge] of sources) {
1581
1589
  if (!isSpread) {
1590
+ if (merge === true && typeof sourceOrName === "string" && (sourceOrName === "class" || sourceOrName === "className")) {
1591
+ (classMerges ??= []).push({
1592
+ rawName: sourceOrName,
1593
+ value: directValue,
1594
+ order: sourceOrder++
1595
+ });
1596
+ continue;
1597
+ }
1582
1598
  record(sourceOrName, directValue);
1583
1599
  continue;
1584
1600
  }
@@ -1590,6 +1606,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1590
1606
  record(name, source[name]);
1591
1607
  }
1592
1608
  }
1609
+ if (process.env.NODE_ENV === "production" && classMerges === null) {
1610
+ let canonical = true;
1611
+ for (const name of props.keys()) {
1612
+ if (normalizeSsrAttributeName(name, tag, namespace) !== name || namespace === "html" && name.toLowerCase() !== name) {
1613
+ canonical = false;
1614
+ break;
1615
+ }
1616
+ }
1617
+ if (canonical) {
1618
+ let out2 = "";
1619
+ for (const { rawName, value } of props.values()) {
1620
+ if (rawName === "dangerouslySetInnerHTML" || skipFormControls && isAggregatedFormAttribute(tag, rawName))
1621
+ continue;
1622
+ out2 += ssrAttrEntry(rawName, value, tag, namespace);
1623
+ }
1624
+ return out2;
1625
+ }
1626
+ }
1593
1627
  const resolved = /* @__PURE__ */ new Map();
1594
1628
  let needsWinningOrderSort = false;
1595
1629
  for (const writer of props.values()) {
@@ -1616,6 +1650,24 @@ function ssrAttrs(sources, tag, namespace = "html", skipFormControls = false) {
1616
1650
  lastOrder
1617
1651
  ]);
1618
1652
  }
1653
+ if (classMerges !== null) {
1654
+ for (const extra of classMerges) {
1655
+ const name = normalizeSsrAttributeName(extra.rawName, tag, namespace);
1656
+ if (!import_constants.VALID_ATTR_NAME.test(name)) continue;
1657
+ const identity = namespace === "html" ? name.toLowerCase() : name;
1658
+ const previous = resolved.get(identity);
1659
+ if (previous !== void 0) {
1660
+ resolved.set(identity, [
1661
+ previous[0],
1662
+ (0, import_css.mergeClass)(previous[1], extra.value),
1663
+ previous[2],
1664
+ extra.order
1665
+ ]);
1666
+ continue;
1667
+ }
1668
+ resolved.set(identity, [name, extra.value, extra.order, extra.order]);
1669
+ }
1670
+ }
1619
1671
  let out = "";
1620
1672
  const ordered = [...resolved.values()];
1621
1673
  if (needsWinningOrderSort) ordered.sort((a, b) => a[2] - b[2]);
@@ -3613,6 +3665,9 @@ function manualHook(fn, name) {
3613
3665
  Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
3614
3666
  return provider;
3615
3667
  }
3668
+ function callWithReceiver(fn, receiver, ...args) {
3669
+ return NATIVE_REFLECT_APPLY(fn, receiver, args);
3670
+ }
3616
3671
  function withSlot(sym, fn, ...args) {
3617
3672
  const driver = MANUAL_HOOK_DRIVER;
3618
3673
  const pending = driver?.pending;
@@ -3654,6 +3709,28 @@ function isChildrenBlock(value) {
3654
3709
  function injectStyle(id, css, nonce) {
3655
3710
  if (CSS !== null) CSS.set(id, nonce === void 0 ? { css } : { css, nonce });
3656
3711
  }
3712
+ function styleMap(id, css, map, applied = []) {
3713
+ let touching = false;
3714
+ const touch = () => {
3715
+ if (CSS === null || touching) return;
3716
+ touching = true;
3717
+ try {
3718
+ for (const dependency of applied) touchStyleMap(dependency);
3719
+ if (id !== null && css !== null) injectStyle(id, css);
3720
+ } finally {
3721
+ touching = false;
3722
+ }
3723
+ };
3724
+ return new Proxy(map, {
3725
+ get(target, key, receiver) {
3726
+ touch();
3727
+ return Reflect.get(target, key, receiver);
3728
+ }
3729
+ });
3730
+ }
3731
+ function touchStyleMap(map) {
3732
+ if (map !== null && typeof map === "object") void map.$class;
3733
+ }
3657
3734
  const HEAD_VOID_ELEMENTS = /* @__PURE__ */ new Set(["meta", "link", "base"]);
3658
3735
  function ssrHeadEl(key, tag, attrs, text) {
3659
3736
  if (HEAD === null || FALLBACK_HOIST_DEPTH !== 0) return "";
@@ -3775,14 +3852,14 @@ function serializeSuspenseSeedJson(values) {
3775
3852
  return value;
3776
3853
  }).replace(/</g, "\\u003c");
3777
3854
  }
3778
- function serializeSuspenseSeeds(values, nonceAttr) {
3855
+ function serializeSuspenseSeeds(values, nonceAttr, attr = import_constants.SUSPENSE_SCRIPT_ATTR) {
3779
3856
  const json = serializeSuspenseSeedJson(values);
3780
3857
  if (json === "[]") return "";
3781
- return '<script type="application/json" ' + import_constants.SUSPENSE_SCRIPT_ATTR + nonceAttr + ">" + json + "</script>";
3858
+ return '<script type="application/json" ' + attr + nonceAttr + ">" + json + "</script>";
3782
3859
  }
3783
- function serializeNativeSignalSeeds(signals, nonceAttr) {
3860
+ function serializeNativeSignalSeeds(signals, nonceAttr, attr = import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR) {
3784
3861
  const json = JSON.stringify(signals).replace(/</g, "\\u003c");
3785
- return '<script type="application/json" ' + import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR + nonceAttr + ">" + json + "</script>";
3862
+ return '<script type="application/json" ' + attr + nonceAttr + ">" + json + "</script>";
3786
3863
  }
3787
3864
  function newResolvedMap(resourceOptions) {
3788
3865
  const m = /* @__PURE__ */ new Map();
@@ -4777,6 +4854,14 @@ function ssrTry(scope, siteKey, tryFn, pendFn, catchFn, namespace = FRAME?.names
4777
4854
  return pendingForm();
4778
4855
  }
4779
4856
  appendNativeSeedReads(nativeReads);
4857
+ if (MARKERS && pendFn !== null) {
4858
+ const idCount = ID_COUNTER - outerIdCounter;
4859
+ const seeds = SERIAL === null ? [] : SERIAL.splice(serialStart);
4860
+ const native = NATIVE_READ_COLLECTOR?.serialize(nativeReads);
4861
+ return ssrBlock(
4862
+ `<!--${import_constants.SUSPENSE_RESOLVED_COMMENT}${idCount}-->` + (seeds.length === 0 ? "" : serializeSuspenseSeeds(seeds, NONCE_ATTR, import_constants.SUSPENSE_RESOLVED_SEED_ATTR)) + (native === void 0 ? "" : serializeNativeSignalSeeds(native, NONCE_ATTR, import_constants.SUSPENSE_RESOLVED_NATIVE_ATTR)) + inner
4863
+ );
4864
+ }
4780
4865
  return ssrBlock(inner);
4781
4866
  } catch (e) {
4782
4867
  nativeFresh = NATIVE_SERVER_FAILURES !== nativeFailureStart;
@@ -5007,19 +5092,30 @@ async function runStream(component, props, options, sink, resolved) {
5007
5092
  };
5008
5093
  const injection = options?.injection;
5009
5094
  if (injection !== void 0) injection.done.then(NOOP, NOOP);
5095
+ let injectionCompleted = false;
5096
+ const completeInjection = injection === void 0 ? NOOP : () => {
5097
+ if (injectionCompleted) return;
5098
+ injectionCompleted = true;
5099
+ injection.renderComplete?.();
5100
+ };
5010
5101
  let injectionUnsubscribe;
5011
5102
  let injectionFailure;
5012
5103
  let injectionFailed = false;
5104
+ const unacceptedInjection = injection === void 0 ? void 0 : [];
5105
+ const rememberUnaccepted = injection === void 0 ? NOOP : (chunk) => {
5106
+ unacceptedInjection.push(chunk);
5107
+ };
5013
5108
  let signalInjectionFailure;
5014
5109
  const failInjection = (err) => {
5110
+ if (signal?.aborted && err === signal.reason) return;
5015
5111
  if (injectionFailed) return;
5016
5112
  injectionFailed = true;
5017
5113
  injectionFailure = err;
5018
5114
  signalInjectionFailure?.();
5019
5115
  };
5020
5116
  let writeChain = injection === void 0 ? null : Promise.resolve();
5021
- const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal) => {
5022
- const operation = writeChain.then(() => sink.write(chunk, terminal));
5117
+ const write = injection === void 0 ? (chunk, terminal) => sink.write(chunk, terminal) : (chunk, terminal, onUnaccepted) => {
5118
+ const operation = writeChain.then(() => sink.write(chunk, terminal, onUnaccepted));
5023
5119
  writeChain = operation.then(NOOP, NOOP);
5024
5120
  return operation;
5025
5121
  };
@@ -5033,11 +5129,34 @@ async function runStream(component, props, options, sink, resolved) {
5033
5129
  return;
5034
5130
  }
5035
5131
  if (!html) return;
5036
- return write(html);
5132
+ return write(html, false, rememberUnaccepted);
5133
+ };
5134
+ const recoveryInjection = injection === void 0 ? void 0 : async () => {
5135
+ if (signal?.aborted) {
5136
+ await writeChain;
5137
+ for (const html of unacceptedInjection) {
5138
+ const replay = write(html, "recovery");
5139
+ if (replay !== void 0) await replay;
5140
+ }
5141
+ unacceptedInjection.length = 0;
5142
+ }
5143
+ if (injectionFailed) return "";
5144
+ let queued;
5145
+ try {
5146
+ queued = injection.take();
5147
+ } catch {
5148
+ return "";
5149
+ }
5150
+ if (queued !== "" && signal?.aborted) {
5151
+ const replay = write(queued, "recovery");
5152
+ if (replay !== void 0) await replay;
5153
+ return "";
5154
+ }
5155
+ return queued;
5037
5156
  };
5038
5157
  const notifyInjection = () => {
5039
5158
  const drained = drainInjection();
5040
- if (drained !== void 0) drained.catch(NOOP);
5159
+ if (drained !== void 0) drained.catch(failInjection);
5041
5160
  };
5042
5161
  const waitForInjectionDone = () => new Promise((resolve, reject) => {
5043
5162
  let settled = false;
@@ -5140,12 +5259,24 @@ async function runStream(component, props, options, sink, resolved) {
5140
5259
  }
5141
5260
  pruneStreamBoundariesAbsentFromShell(stream, shellBoundaryKeys);
5142
5261
  } catch (err) {
5262
+ try {
5263
+ completeInjection();
5264
+ } catch {
5265
+ }
5143
5266
  const reports = signal?.aborted ? Math.max(1, preShellSuspended.length) : 1;
5144
5267
  for (let i = 0; i < reports; i++) options?.onError?.(err);
5145
5268
  sink.shellError(err);
5146
5269
  return;
5147
5270
  }
5148
- reportRecoverableBoundaryErrors();
5271
+ try {
5272
+ reportRecoverableBoundaryErrors();
5273
+ } catch (err) {
5274
+ try {
5275
+ completeInjection();
5276
+ } catch {
5277
+ }
5278
+ throw err;
5279
+ }
5149
5280
  if (pass.sheets !== null) for (const key of pass.sheets.keys()) flushedSheets.add(key);
5150
5281
  let leadingStyles = "";
5151
5282
  for (const [hash, sheet] of pass.cssEntries) {
@@ -5153,7 +5284,17 @@ async function runStream(component, props, options, sink, resolved) {
5153
5284
  leadingStyles += '<style data-octane="' + hash + '"' + (sheet.nonce === void 0 ? nonceAttr : ' nonce="' + escapeAttr(sheet.nonce) + '"') + ">" + escapeEntireInlineStyleContent(sheet.css) + "</style>";
5154
5285
  }
5155
5286
  const separateHead = options?.headChannel === "separate";
5156
- if (separateHead) options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5287
+ if (separateHead) {
5288
+ try {
5289
+ options?.onHeadReady?.(pass.vtCandidates ? vtSsrStrip(pass.head) : pass.head);
5290
+ } catch (err) {
5291
+ try {
5292
+ completeInjection();
5293
+ } catch {
5294
+ }
5295
+ throw err;
5296
+ }
5297
+ }
5157
5298
  const shellHead = separateHead ? "" : pass.head;
5158
5299
  const documentRoot = isDocumentRoot(pass.body);
5159
5300
  let shell = documentRoot ? "<!DOCTYPE html>" : "";
@@ -5180,11 +5321,23 @@ async function runStream(component, props, options, sink, resolved) {
5180
5321
  const shellWrite = write(pass.vtCandidates ? vtSsrStrip(shell) : shell);
5181
5322
  if (shellWrite !== void 0) await shellWrite;
5182
5323
  } catch (err) {
5324
+ try {
5325
+ completeInjection();
5326
+ } catch {
5327
+ }
5183
5328
  options?.onError?.(err);
5184
5329
  sink.shellError(err);
5185
5330
  return;
5186
5331
  }
5187
- sink.shellReady();
5332
+ try {
5333
+ sink.shellReady();
5334
+ } catch (err) {
5335
+ try {
5336
+ completeInjection();
5337
+ } catch {
5338
+ }
5339
+ throw err;
5340
+ }
5188
5341
  if (injection !== void 0) {
5189
5342
  try {
5190
5343
  injectionUnsubscribe = injection.subscribe(notifyInjection);
@@ -5274,14 +5427,14 @@ async function runStream(component, props, options, sink, resolved) {
5274
5427
  injectionUnsubscribe?.();
5275
5428
  injectionUnsubscribe = void 0;
5276
5429
  try {
5277
- injection.renderComplete?.();
5430
+ completeInjection();
5278
5431
  } catch {
5279
5432
  }
5280
5433
  }
5281
5434
  let tail = "";
5282
- if (injection !== void 0 && !injectionFailed) {
5435
+ if (recoveryInjection !== void 0) {
5283
5436
  try {
5284
- tail += injection.take();
5437
+ tail = await recoveryInjection();
5285
5438
  } catch {
5286
5439
  }
5287
5440
  }
@@ -5301,7 +5454,7 @@ async function runStream(component, props, options, sink, resolved) {
5301
5454
  }
5302
5455
  if (injection !== void 0) {
5303
5456
  try {
5304
- injection.renderComplete?.();
5457
+ completeInjection();
5305
5458
  } catch (err) {
5306
5459
  failInjection(err);
5307
5460
  }
@@ -5309,11 +5462,14 @@ async function runStream(component, props, options, sink, resolved) {
5309
5462
  await waitForInjectionDone();
5310
5463
  const finalDrain = drainInjection();
5311
5464
  if (finalDrain !== void 0) await finalDrain;
5465
+ await writeChain;
5312
5466
  if (injectionFailed) throw injectionFailure;
5313
5467
  if (heldDocumentTail !== "") {
5314
5468
  const tailChunk = heldDocumentTail;
5315
5469
  heldDocumentTail = "";
5316
- const tailWrite = write(tailChunk);
5470
+ const tailWrite = write(tailChunk, false, (unaccepted) => {
5471
+ heldDocumentTail = unaccepted;
5472
+ });
5317
5473
  if (tailWrite !== void 0) await tailWrite;
5318
5474
  }
5319
5475
  } catch (err) {
@@ -5321,11 +5477,9 @@ async function runStream(component, props, options, sink, resolved) {
5321
5477
  injectionUnsubscribe?.();
5322
5478
  injectionUnsubscribe = void 0;
5323
5479
  let terminal = "";
5324
- if (!injectionFailed) {
5325
- try {
5326
- terminal = injection.take();
5327
- } catch {
5328
- }
5480
+ try {
5481
+ terminal = await recoveryInjection();
5482
+ } catch {
5329
5483
  }
5330
5484
  terminal += heldDocumentTail;
5331
5485
  if (terminal !== "") {
@@ -5390,7 +5544,8 @@ function renderToPipeableStream(entryComponent, props, options) {
5390
5544
  destinationFailure(err);
5391
5545
  }
5392
5546
  };
5393
- const waitForDrain = (dest) => {
5547
+ const waitForDrain = (dest, allowAborted = false) => {
5548
+ if (allowAborted && closed) return Promise.reject(new Error((0, import_error_codes_server_generated.formatServerError)(38)));
5394
5549
  if (dest.once === void 0) {
5395
5550
  return Promise.reject(new TypeError((0, import_error_codes_server_generated.formatServerError)(39)));
5396
5551
  }
@@ -5426,14 +5581,17 @@ function renderToPipeableStream(entryComponent, props, options) {
5426
5581
  dest.once("drain", onDrain);
5427
5582
  dest.once("error", onError);
5428
5583
  dest.once("close", onClose);
5429
- if (controller.signal.aborted) onAbort();
5430
- else controller.signal.addEventListener("abort", onAbort, { once: true });
5584
+ if (!allowAborted) {
5585
+ if (controller.signal.aborted) onAbort();
5586
+ else controller.signal.addEventListener("abort", onAbort, { once: true });
5587
+ }
5431
5588
  });
5432
5589
  };
5433
- const writeNow = (chunk, terminal) => {
5590
+ const writeNow = (chunk, terminal, onUnaccepted) => {
5434
5591
  const dest = destination;
5435
5592
  if (closed) return Promise.reject(new Error((0, import_error_codes_server_generated.formatServerError)(40)));
5436
- if (!terminal && controller.signal.aborted) {
5593
+ if (terminal === false && controller.signal.aborted) {
5594
+ onUnaccepted?.(chunk);
5437
5595
  return Promise.reject(controller.signal.reason);
5438
5596
  }
5439
5597
  let accepted;
@@ -5443,7 +5601,7 @@ function renderToPipeableStream(entryComponent, props, options) {
5443
5601
  destinationFailure(err);
5444
5602
  return Promise.reject(err);
5445
5603
  }
5446
- return accepted === false && !terminal ? waitForDrain(dest) : void 0;
5604
+ return accepted === false && terminal !== true ? waitForDrain(dest, terminal === "recovery") : void 0;
5447
5605
  };
5448
5606
  const trackWrite = (operation) => {
5449
5607
  const gate = operation.then(
@@ -5464,16 +5622,18 @@ function renderToPipeableStream(entryComponent, props, options) {
5464
5622
  });
5465
5623
  return operation;
5466
5624
  };
5467
- const queueWrite = (chunk, terminal = false) => {
5625
+ const queueWrite = (chunk, terminal = false, onUnaccepted) => {
5468
5626
  if (destination === null) {
5469
- buffered.push({ chunk, terminal });
5627
+ buffered.push(
5628
+ onUnaccepted === void 0 ? { chunk, terminal } : { chunk, terminal, onUnaccepted }
5629
+ );
5470
5630
  return;
5471
5631
  }
5472
5632
  if (writeGate !== null) {
5473
- const operation2 = writeGate.then(() => writeNow(chunk, terminal));
5633
+ const operation2 = writeGate.then(() => writeNow(chunk, terminal, onUnaccepted));
5474
5634
  return trackWrite(operation2);
5475
5635
  }
5476
- const operation = writeNow(chunk, terminal);
5636
+ const operation = writeNow(chunk, terminal, onUnaccepted);
5477
5637
  return operation === void 0 ? void 0 : trackWrite(operation);
5478
5638
  };
5479
5639
  const flushEnd = () => {
@@ -5493,8 +5653,8 @@ function renderToPipeableStream(entryComponent, props, options) {
5493
5653
  props,
5494
5654
  renderOptions,
5495
5655
  {
5496
- write(chunk, terminal) {
5497
- return queueWrite(chunk, terminal);
5656
+ write(chunk, terminal, onUnaccepted) {
5657
+ return queueWrite(chunk, terminal, onUnaccepted);
5498
5658
  },
5499
5659
  shellReady() {
5500
5660
  options?.onShellReady?.();
@@ -5538,7 +5698,11 @@ function renderToPipeableStream(entryComponent, props, options) {
5538
5698
  });
5539
5699
  }
5540
5700
  for (const item of buffered) {
5541
- queueWrite(item.chunk, item.terminal || controller.signal.aborted);
5701
+ queueWrite(
5702
+ item.chunk,
5703
+ item.terminal === "recovery" ? "recovery" : item.terminal || controller.signal.aborted,
5704
+ item.onUnaccepted
5705
+ );
5542
5706
  }
5543
5707
  buffered.length = 0;
5544
5708
  finishEnd();
@@ -5604,7 +5768,10 @@ function renderToReadableStream(entryComponent, props, options) {
5604
5768
  });
5605
5769
  stream.allReady = allReady;
5606
5770
  let shellDone = false;
5607
- const waitForDemand = () => new Promise((resolve, reject) => {
5771
+ let terminal = false;
5772
+ let released = false;
5773
+ let callbackFailure;
5774
+ const waitForDemand = (allowAborted = false) => new Promise((resolve, reject) => {
5608
5775
  let settled = false;
5609
5776
  const cleanup = () => {
5610
5777
  renderController.signal.removeEventListener("abort", onAbort);
@@ -5619,18 +5786,21 @@ function renderToReadableStream(entryComponent, props, options) {
5619
5786
  const onDemand = () => finish(resolve);
5620
5787
  const onAbort = () => finish(() => reject(renderController.signal.reason));
5621
5788
  wakeDemand = onDemand;
5622
- if (renderController.signal.aborted) onAbort();
5623
- else renderController.signal.addEventListener("abort", onAbort, { once: true });
5789
+ if (!allowAborted) {
5790
+ if (renderController.signal.aborted) onAbort();
5791
+ else renderController.signal.addEventListener("abort", onAbort, { once: true });
5792
+ }
5624
5793
  });
5625
- const writeReadable = (chunk, terminal = false) => {
5794
+ const writeReadable = (chunk, terminal2 = false, onUnaccepted) => {
5626
5795
  if (closed || consumerCancelled) {
5627
5796
  return Promise.reject(cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44)));
5628
5797
  }
5629
- if (!terminal && renderController.signal.aborted) {
5798
+ if (terminal2 === false && renderController.signal.aborted) {
5799
+ onUnaccepted?.(chunk);
5630
5800
  return Promise.reject(renderController.signal.reason);
5631
5801
  }
5632
5802
  const bytes = encoder.encode(chunk);
5633
- if (terminal) {
5803
+ if (terminal2 === true) {
5634
5804
  readableController.enqueue(bytes);
5635
5805
  return;
5636
5806
  }
@@ -5639,13 +5809,18 @@ function renderToReadableStream(entryComponent, props, options) {
5639
5809
  return;
5640
5810
  }
5641
5811
  return (async () => {
5642
- while ((readableController.desiredSize ?? 0) <= 0) {
5643
- await waitForDemand();
5644
- if (closed || consumerCancelled) {
5645
- throw cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44));
5812
+ try {
5813
+ while ((readableController.desiredSize ?? 0) <= 0) {
5814
+ await waitForDemand(terminal2 === "recovery");
5815
+ if (closed || consumerCancelled) {
5816
+ throw cancelReason ?? new Error((0, import_error_codes_server_generated.formatServerError)(44));
5817
+ }
5646
5818
  }
5819
+ readableController.enqueue(bytes);
5820
+ } catch (err) {
5821
+ if (!consumerCancelled && renderController.signal.aborted) onUnaccepted?.(chunk);
5822
+ throw err;
5647
5823
  }
5648
- readableController.enqueue(bytes);
5649
5824
  })();
5650
5825
  };
5651
5826
  const closeReadable = () => {
@@ -5659,46 +5834,80 @@ function renderToReadableStream(entryComponent, props, options) {
5659
5834
  }
5660
5835
  };
5661
5836
  const renderOptions = { ...options, signal: renderController.signal };
5837
+ if (options?.onError !== void 0) {
5838
+ renderOptions.onError = (error) => {
5839
+ try {
5840
+ options.onError(error);
5841
+ } catch (err) {
5842
+ callbackFailure ??= { error: err };
5843
+ }
5844
+ };
5845
+ }
5662
5846
  const resolved = newResolvedMap(renderOptions);
5847
+ const release = () => {
5848
+ if (released) return;
5849
+ released = true;
5850
+ releaseServerRenderResources(resolved);
5851
+ };
5852
+ const settleFailure = (error) => {
5853
+ if (terminal) return;
5854
+ terminal = true;
5855
+ try {
5856
+ release();
5857
+ } catch (err) {
5858
+ error = err;
5859
+ }
5860
+ const reason = callbackFailure === void 0 ? error : callbackFailure.error;
5861
+ if (!shellDone) rejectShell(reason);
5862
+ allReadyReject(reason);
5863
+ closeReadable();
5864
+ };
5663
5865
  runStream(
5664
5866
  component,
5665
5867
  props,
5666
5868
  renderOptions,
5667
5869
  {
5668
- write(chunk, terminal) {
5669
- return writeReadable(chunk, terminal);
5870
+ write(chunk, terminal2, onUnaccepted) {
5871
+ return writeReadable(chunk, terminal2, onUnaccepted);
5670
5872
  },
5671
5873
  shellReady() {
5672
- shellDone = true;
5673
5874
  options?.onShellReady?.();
5875
+ shellDone = true;
5674
5876
  resolveShell(stream);
5675
5877
  },
5676
5878
  shellError(err) {
5677
- releaseServerRenderResources(resolved);
5678
- options?.onShellError?.(err);
5679
- if (!shellDone) rejectShell(err);
5680
- allReadyReject(err);
5681
- closeReadable();
5879
+ try {
5880
+ release();
5881
+ options?.onShellError?.(err);
5882
+ } catch (callbackError) {
5883
+ settleFailure(callbackError);
5884
+ return;
5885
+ }
5886
+ settleFailure(err);
5682
5887
  },
5683
5888
  allReady() {
5684
- releaseServerRenderResources(resolved);
5685
- options?.onAllReady?.();
5686
- allReadyResolve();
5889
+ if (terminal) return;
5890
+ try {
5891
+ release();
5892
+ options?.onAllReady?.();
5893
+ } catch (err) {
5894
+ renderOptions.onError?.(err);
5895
+ settleFailure(err);
5896
+ return;
5897
+ }
5898
+ terminal = true;
5899
+ if (callbackFailure === void 0) allReadyResolve();
5900
+ else allReadyReject(callbackFailure.error);
5687
5901
  closeReadable();
5688
5902
  },
5689
5903
  fatal(err) {
5690
- releaseServerRenderResources(resolved);
5691
- allReadyReject(err);
5692
- closeReadable();
5904
+ settleFailure(err);
5693
5905
  }
5694
5906
  },
5695
5907
  resolved
5696
5908
  ).catch((err) => {
5697
- releaseServerRenderResources(resolved);
5698
- options?.onError?.(err);
5699
- if (!shellDone) rejectShell(err);
5700
- allReadyReject(err);
5701
- closeReadable();
5909
+ renderOptions.onError?.(err);
5910
+ settleFailure(err);
5702
5911
  });
5703
5912
  });
5704
5913
  }
@@ -5985,6 +6194,7 @@ function preinitModule(href, options) {
5985
6194
  addTransitionType,
5986
6195
  beginNativeReadScope,
5987
6196
  beginNativeReadWitness,
6197
+ callWithReceiver,
5988
6198
  cloneElement,
5989
6199
  createContext,
5990
6200
  createElement,
@@ -6088,6 +6298,8 @@ function preinitModule(href, options) {
6088
6298
  ssrValueAttr,
6089
6299
  ssrVoidContent,
6090
6300
  startTransition,
6301
+ styleMap,
6302
+ touchStyleMap,
6091
6303
  use,
6092
6304
  useActionState,
6093
6305
  useCallback,
@@ -123,7 +123,9 @@ __export(server_exports, {
123
123
  ssrValueAttr: () => import_runtime_server.ssrValueAttr,
124
124
  ssrVoidContent: () => import_runtime_server.ssrVoidContent,
125
125
  startTransition: () => import_runtime_server.startTransition,
126
+ styleMap: () => import_runtime_server.styleMap,
126
127
  subSlot: () => import_sub_slot.subSlot,
128
+ touchStyleMap: () => import_runtime_server.touchStyleMap,
127
129
  unstable_Activity: () => import_runtime_server.Activity,
128
130
  unstable_ViewTransition: () => import_runtime_server.ViewTransition,
129
131
  unstable_addTransitionType: () => import_runtime_server.addTransitionType,
@@ -269,7 +271,9 @@ var import_runtime_server = require("../runtime.server.cjs");
269
271
  ssrValueAttr,
270
272
  ssrVoidContent,
271
273
  startTransition,
274
+ styleMap,
272
275
  subSlot,
276
+ touchStyleMap,
273
277
  unstable_Activity,
274
278
  unstable_ViewTransition,
275
279
  unstable_addTransitionType,
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "0.2.3";
24
+ const version = "0.2.5";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version