octane 0.15.0 → 0.16.0

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 (170) hide show
  1. package/dist/cjs/dom-focused-move.cjs +62 -33
  2. package/dist/cjs/hydration/dev-values.cjs +1 -1
  3. package/dist/cjs/index.cjs +2 -0
  4. package/dist/cjs/runtime/actions.cjs +73 -34
  5. package/dist/cjs/runtime/child-slots.cjs +11 -0
  6. package/dist/cjs/runtime/commit.cjs +17 -5
  7. package/dist/cjs/runtime/deopt.cjs +3 -2
  8. package/dist/cjs/runtime/engine.cjs +44 -32
  9. package/dist/cjs/runtime/events.cjs +19 -12
  10. package/dist/cjs/runtime/host-props.cjs +20 -16
  11. package/dist/cjs/runtime/hydration.cjs +4 -5
  12. package/dist/cjs/runtime/lists.cjs +20 -20
  13. package/dist/cjs/runtime/render.cjs +2 -0
  14. package/dist/cjs/runtime/roots.cjs +3 -2
  15. package/dist/cjs/runtime/signal-bindings.cjs +59 -9
  16. package/dist/cjs/runtime/suspense.cjs +18 -18
  17. package/dist/cjs/runtime/templates.cjs +4 -2
  18. package/dist/cjs/runtime/transitions.cjs +61 -3
  19. package/dist/cjs/runtime.server.cjs +1 -1
  20. package/dist/cjs/server/streamed-region.cjs +2 -2
  21. package/dist/cjs/server-rpc-batch-client.cjs +34 -59
  22. package/dist/cjs/server-rpc-client.cjs +114 -104
  23. package/dist/cjs/server-rpc-protocol.cjs +0 -59
  24. package/dist/cjs/server-rpc-stream-client.cjs +57 -1
  25. package/dist/cjs/signals/computations.cjs +74 -67
  26. package/dist/cjs/signals/engine.cjs +0 -24
  27. package/dist/cjs/signals/facade.cjs +15 -81
  28. package/dist/cjs/signals/index.cjs +14 -4
  29. package/dist/cjs/signals/native-adoption.cjs +112 -0
  30. package/dist/cjs/signals/native-read-seeds.cjs +4 -85
  31. package/dist/cjs/signals/requests.cjs +77 -72
  32. package/dist/cjs/signals/scalar-computations.cjs +59 -52
  33. package/dist/cjs/signals/server-reads.cjs +11 -2
  34. package/dist/cjs/signals/streamed-results.cjs +122 -0
  35. package/dist/cjs/trusted-types.cjs +41 -0
  36. package/dist/cjs/version.cjs +1 -1
  37. package/dist/compiler/compile-universal.js +287 -52
  38. package/dist/compiler/compile.js +130 -81
  39. package/dist/compiler/index.d.ts +11 -1
  40. package/dist/compiler/signal-declarations.js +33 -1
  41. package/dist/compiler/style-scopes.js +4 -1
  42. package/dist/compiler/typescript-output.js +6 -2
  43. package/dist/compiler/vite.js +20 -0
  44. package/dist/dom-binding-program.js +3 -1
  45. package/dist/dom-focused-move.d.ts +8 -3
  46. package/dist/dom-focused-move.js +61 -33
  47. package/dist/hydration/dev-values.d.ts +2 -1
  48. package/dist/hydration/dev-values.js +1 -1
  49. package/dist/hydration/stream-receiver.js +2 -1
  50. package/dist/hydration/streamed-signals.js +2 -1
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +2 -1
  53. package/dist/internal/server-rpc.d.ts +8 -0
  54. package/dist/internal/server-rpc.js +7 -0
  55. package/dist/node/dom-binding-program.js +3 -1
  56. package/dist/node/dom-focused-move.js +61 -33
  57. package/dist/node/hydration/dev-values.js +1 -1
  58. package/dist/node/hydration/stream-receiver.js +2 -1
  59. package/dist/node/hydration/streamed-signals.js +2 -1
  60. package/dist/node/index.js +2 -1
  61. package/dist/node/internal/server-rpc.js +7 -0
  62. package/dist/node/runtime/actions.js +78 -39
  63. package/dist/node/runtime/child-slots.js +10 -0
  64. package/dist/node/runtime/commit.js +16 -5
  65. package/dist/node/runtime/deopt.js +4 -3
  66. package/dist/node/runtime/engine.js +40 -29
  67. package/dist/node/runtime/events.js +19 -12
  68. package/dist/node/runtime/host-props.js +20 -16
  69. package/dist/node/runtime/hydration.js +4 -5
  70. package/dist/node/runtime/lists.js +21 -21
  71. package/dist/node/runtime/render.js +2 -0
  72. package/dist/node/runtime/roots.js +4 -2
  73. package/dist/node/runtime/signal-bindings.js +60 -10
  74. package/dist/node/runtime/suspense.js +25 -19
  75. package/dist/node/runtime/templates.js +4 -2
  76. package/dist/node/runtime/transitions.js +59 -2
  77. package/dist/node/runtime.server.js +1 -1
  78. package/dist/node/server/streamed-region.js +1 -1
  79. package/dist/node/server-rpc-batch-client.js +38 -58
  80. package/dist/node/server-rpc-client.js +106 -93
  81. package/dist/node/server-rpc-protocol.js +0 -57
  82. package/dist/node/server-rpc-response.js +131 -0
  83. package/dist/node/server-rpc-stream-client.js +56 -1
  84. package/dist/node/signals/computations.js +72 -66
  85. package/dist/node/signals/engine.js +0 -21
  86. package/dist/node/signals/facade.js +7 -82
  87. package/dist/node/signals/index.js +12 -4
  88. package/dist/node/signals/native-adoption.js +91 -0
  89. package/dist/node/signals/native-read-seeds.js +2 -82
  90. package/dist/node/signals/requests.js +73 -69
  91. package/dist/node/signals/scalar-computations.js +57 -51
  92. package/dist/node/signals/server-reads-elsewhere.js +17 -1
  93. package/dist/node/signals/server-reads.js +11 -1
  94. package/dist/node/signals/streamed-results.js +106 -0
  95. package/dist/node/trusted-types.js +16 -0
  96. package/dist/node/universal-core.js +61 -26
  97. package/dist/node/universal-native.js +3 -0
  98. package/dist/node/universal-styles.js +21 -0
  99. package/dist/node/universal.js +3 -0
  100. package/dist/node/version.js +1 -1
  101. package/dist/runtime/actions.js +78 -39
  102. package/dist/runtime/child-slots.d.ts +8 -0
  103. package/dist/runtime/child-slots.js +10 -0
  104. package/dist/runtime/commit.d.ts +8 -1
  105. package/dist/runtime/commit.js +16 -5
  106. package/dist/runtime/deopt.js +4 -3
  107. package/dist/runtime/effects.d.ts +1 -1
  108. package/dist/runtime/engine.d.ts +6 -3
  109. package/dist/runtime/engine.js +40 -29
  110. package/dist/runtime/events.js +19 -12
  111. package/dist/runtime/host-props.d.ts +2 -2
  112. package/dist/runtime/host-props.js +20 -16
  113. package/dist/runtime/hydration.d.ts +5 -6
  114. package/dist/runtime/hydration.js +4 -5
  115. package/dist/runtime/lists.js +21 -21
  116. package/dist/runtime/render.js +2 -0
  117. package/dist/runtime/roots.js +4 -2
  118. package/dist/runtime/signal-bindings.d.ts +2 -1
  119. package/dist/runtime/signal-bindings.js +60 -10
  120. package/dist/runtime/suspense.d.ts +1 -1
  121. package/dist/runtime/suspense.js +25 -19
  122. package/dist/runtime/templates.js +4 -2
  123. package/dist/runtime/transitions.d.ts +12 -1
  124. package/dist/runtime/transitions.js +59 -2
  125. package/dist/runtime/types.d.ts +5 -2
  126. package/dist/runtime.server.js +1 -1
  127. package/dist/server/streamed-region.js +1 -1
  128. package/dist/server-rpc-batch-client.d.ts +12 -4
  129. package/dist/server-rpc-batch-client.js +38 -58
  130. package/dist/server-rpc-client.d.ts +24 -1
  131. package/dist/server-rpc-client.js +106 -93
  132. package/dist/server-rpc-protocol.d.ts +0 -6
  133. package/dist/server-rpc-protocol.js +0 -57
  134. package/dist/server-rpc-response.d.ts +6 -0
  135. package/dist/server-rpc-response.js +131 -0
  136. package/dist/server-rpc-stream-client.js +56 -1
  137. package/dist/signals/computations.d.ts +22 -9
  138. package/dist/signals/computations.js +72 -66
  139. package/dist/signals/engine.d.ts +1 -11
  140. package/dist/signals/engine.js +0 -21
  141. package/dist/signals/facade.d.ts +10 -16
  142. package/dist/signals/facade.js +7 -82
  143. package/dist/signals/index.d.ts +5 -1
  144. package/dist/signals/index.js +12 -4
  145. package/dist/signals/native-adoption.d.ts +18 -0
  146. package/dist/signals/native-adoption.js +91 -0
  147. package/dist/signals/native-read-seeds.d.ts +12 -17
  148. package/dist/signals/native-read-seeds.js +2 -82
  149. package/dist/signals/redeclaration.d.ts +9 -4
  150. package/dist/signals/requests.d.ts +19 -10
  151. package/dist/signals/requests.js +73 -69
  152. package/dist/signals/scalar-computations.d.ts +2 -0
  153. package/dist/signals/scalar-computations.js +57 -51
  154. package/dist/signals/server-reads-elsewhere.d.ts +4 -0
  155. package/dist/signals/server-reads-elsewhere.js +17 -1
  156. package/dist/signals/server-reads.d.ts +3 -1
  157. package/dist/signals/server-reads.js +11 -1
  158. package/dist/signals/streamed-results.d.ts +18 -0
  159. package/dist/signals/streamed-results.js +106 -0
  160. package/dist/trusted-types.d.ts +18 -0
  161. package/dist/trusted-types.js +16 -0
  162. package/dist/universal-core.js +61 -26
  163. package/dist/universal-native.d.ts +2 -0
  164. package/dist/universal-native.js +3 -0
  165. package/dist/universal-styles.d.ts +15 -0
  166. package/dist/universal-styles.js +21 -0
  167. package/dist/universal.d.ts +2 -0
  168. package/dist/universal.js +3 -0
  169. package/dist/version.js +1 -1
  170. package/package.json +6 -1
@@ -18,54 +18,83 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var dom_focused_move_exports = {};
20
20
  __export(dom_focused_move_exports, {
21
+ isChildOf: () => isChildOf,
21
22
  moveNativeNodeBefore: () => moveNativeNodeBefore
22
23
  });
23
24
  module.exports = __toCommonJS(dom_focused_move_exports);
24
25
  function moveNativeNodeBefore(parent, node, anchor, focused, contentEditable) {
25
- let containsFocused = node === focused;
26
- if (!containsFocused && focused !== null && node.nodeType === 1) {
27
- let candidate = focused;
28
- do {
29
- if (node.contains(candidate)) {
30
- containsFocused = true;
31
- break;
32
- }
33
- const root = candidate.getRootNode();
34
- candidate = root.nodeType === 11 ? root.host : void 0;
35
- } while (candidate !== void 0);
36
- }
37
- if (!containsFocused) {
38
- parent.insertBefore(node, anchor);
26
+ const move = nativeMove(parent);
27
+ if (move !== null && node.isConnected === true && parent.ownerDocument === node.ownerDocument && !(contentEditable && containsFocus(node, focused))) {
28
+ move.call(parent, node, anchor);
39
29
  return;
40
30
  }
41
- const moveBefore = parent.moveBefore;
42
- if (!contentEditable && typeof moveBefore === "function" && parent.isConnected && node.isConnected && parent.ownerDocument === node.ownerDocument) {
43
- moveBefore.call(parent, node, anchor);
31
+ if (!containsFocus(node, focused)) {
32
+ parent.insertBefore(node, anchor);
44
33
  return;
45
34
  }
46
- if (node.parentNode !== parent || anchor !== null && anchor.parentNode !== parent) {
35
+ if (!isChildOf(node, parent) || anchor !== null && !isChildOf(anchor, parent)) {
47
36
  parent.insertBefore(node, anchor);
48
37
  return;
49
38
  }
50
- if (node === anchor || node.nextSibling === anchor) return;
51
- if (anchor === null || (node.compareDocumentPosition(anchor) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) {
52
- let cursor = node.nextSibling;
53
- while (cursor !== anchor) {
54
- const next = cursor.nextSibling;
55
- parent.insertBefore(cursor, node);
56
- cursor = next;
57
- }
58
- } else {
59
- const end = node.nextSibling;
60
- let cursor = anchor;
61
- while (cursor !== node) {
62
- const next = cursor.nextSibling;
63
- parent.insertBefore(cursor, end);
64
- cursor = next;
39
+ if (node === anchor || nextOf(node) === anchor) return;
40
+ const forward = anchor === null || // 4 is Node.DOCUMENT_POSITION_FOLLOWING.
41
+ (nodeProto(node).compareDocumentPosition.call(node, anchor) & 4) !== 0;
42
+ const siblings = [];
43
+ for (let cursor = forward ? nextOf(node) : anchor; cursor !== null && cursor !== (forward ? anchor : node); cursor = nextOf(cursor))
44
+ siblings.push(cursor);
45
+ const rotate = move ?? parent.insertBefore;
46
+ let after = node;
47
+ for (let i = 0; i < siblings.length; i++) {
48
+ const sibling = siblings[i];
49
+ if (!isChildOf(sibling, parent)) continue;
50
+ if (forward) rotate.call(parent, sibling, node);
51
+ else {
52
+ rotate.call(parent, sibling, nextOf(after));
53
+ if (isChildOf(sibling, parent)) after = sibling;
65
54
  }
66
55
  }
67
56
  }
57
+ let NODE_PROTO;
58
+ let parentNodeGetter;
59
+ let nextSiblingGetter;
60
+ function nodeProto(node) {
61
+ if (NODE_PROTO === void 0) {
62
+ let proto = Object.getPrototypeOf(node);
63
+ while (!Object.prototype.hasOwnProperty.call(proto, "nextSibling"))
64
+ proto = Object.getPrototypeOf(proto);
65
+ NODE_PROTO = proto;
66
+ }
67
+ return NODE_PROTO;
68
+ }
69
+ function nodeGetter(node, name) {
70
+ return Object.getOwnPropertyDescriptor(nodeProto(node), name).get;
71
+ }
72
+ function isChildOf(node, parent) {
73
+ parentNodeGetter ??= nodeGetter(node, "parentNode");
74
+ return parentNodeGetter.call(node) === parent;
75
+ }
76
+ function nextOf(node) {
77
+ nextSiblingGetter ??= nodeGetter(node, "nextSibling");
78
+ return nextSiblingGetter.call(node);
79
+ }
80
+ function nativeMove(parent) {
81
+ if (parent.isConnected !== true) return null;
82
+ const move = parent.moveBefore;
83
+ return typeof move === "function" ? move : null;
84
+ }
85
+ function containsFocus(node, focused) {
86
+ if (node === focused) return true;
87
+ if (focused === null || node.nodeType !== 1) return false;
88
+ let candidate = focused;
89
+ do {
90
+ if (nodeProto(node).contains.call(node, candidate)) return true;
91
+ const root = candidate.getRootNode();
92
+ candidate = root.nodeType === 11 ? root.host : void 0;
93
+ } while (candidate !== void 0);
94
+ return false;
95
+ }
68
96
  // Annotate the CommonJS export names for ESM import in node:
69
97
  0 && (module.exports = {
98
+ isChildOf,
70
99
  moveNativeNodeBefore
71
100
  });
@@ -77,7 +77,7 @@ function unpatchedHTML(pass, el, next) {
77
77
  let client;
78
78
  if (el.localName === "script") {
79
79
  server = el.textContent ?? "";
80
- client = next.replace(
80
+ client = String(next).replace(
81
81
  INLINE_SCRIPT_TOKEN,
82
82
  (_match, prefix, s, suffix) => `${prefix}${s === "s" ? "\\u0073" : "\\u0053"}${suffix}`
83
83
  ).replace(SCRIPT_DATA_NORMALIZATION, (match) => match === "\0" ? "\uFFFD" : "\n");
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  __runOnCatch: () => import_runtime.__runOnCatch,
45
45
  __s: () => import_runtime.markSingleRoot,
46
46
  __serverRpc: () => import_server_rpc_client.__serverRpc,
47
+ __serverRpcStream: () => import_server_rpc_client.__serverRpcStream,
47
48
  __useCommittedState: () => import_runtime.__useCommittedState,
48
49
  __useLinkedStateWithGetter: () => import_runtime.__useLinkedStateWithGetter,
49
50
  __useReducerWithGetter: () => import_runtime.__useReducerWithGetter,
@@ -302,6 +303,7 @@ var import_method_dep = require("./method-dep.cjs");
302
303
  __runOnCatch,
303
304
  __s,
304
305
  __serverRpc,
306
+ __serverRpcStream,
305
307
  __useCommittedState,
306
308
  __useLinkedStateWithGetter,
307
309
  __useReducerWithGetter,
@@ -44,6 +44,7 @@ var import_hydration = require("./hydration.cjs");
44
44
  var import_portals = require("./portals.cjs");
45
45
  var import_suspense = require("./suspense.cjs");
46
46
  var import_render = require("./render.cjs");
47
+ var import_commit = require("./commit.cjs");
47
48
  var import_host_props = require("./host-props.cjs");
48
49
  var import_events = require("./events.cjs");
49
50
  var import_forms = require("./forms.cjs");
@@ -405,33 +406,38 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
405
406
  const block = import_render.CURRENT_BLOCK;
406
407
  let s = scope.hooks?.get(slot);
407
408
  if (s === void 0) {
408
- let unownedIndices = null;
409
- const clear = (indices) => {
410
- if (indices !== void 0 && unownedIndices !== indices) return;
411
- unownedIndices = null;
412
- const hadUpdates = slotRef.queue.length > 0;
413
- if (indices === void 0) {
414
- slotRef.armed = false;
415
- slotRef.queue.length = 0;
416
- } else {
417
- let write = indices[0];
418
- let skip = 0;
419
- for (let read = write; read < slotRef.queue.length; read++) {
420
- if (read === indices[skip]) skip++;
421
- else slotRef.queue[write++] = slotRef.queue[read];
422
- }
423
- slotRef.queue.length = write;
409
+ const compact = (owner) => {
410
+ const queue2 = slotRef.queue;
411
+ const owners2 = slotRef.owners;
412
+ if (owners2 === null) {
413
+ if (owner !== null || queue2.length === 0) return false;
414
+ queue2.length = 0;
415
+ return true;
424
416
  }
425
- if (hadUpdates && !block.disposed) {
426
- if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
427
- (0, import_profiling.__profileSchedule)(block, "optimistic-revert", slot);
428
- if (indices === void 0) (0, import_engine.scheduleRender)(block);
429
- else (0, import_engine.scheduleUrgentRender)(block);
417
+ let write = 0;
418
+ for (let read = 0; read < queue2.length; read++) {
419
+ if (owners2[read] === owner) continue;
420
+ queue2[write] = queue2[read];
421
+ owners2[write++] = owners2[read];
430
422
  }
423
+ const removed = write !== queue2.length;
424
+ queue2.length = write;
425
+ owners2.length = write;
426
+ if (slotRef.batches === null || slotRef.batches.size === 0) slotRef.owners = null;
427
+ return removed;
428
+ };
429
+ const revert = () => {
430
+ if (block.disposed) return;
431
+ if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
432
+ (0, import_profiling.__profileSchedule)(block, "optimistic-revert", slot);
433
+ (0, import_engine.scheduleHookPublication)(block);
431
434
  };
432
435
  const slotRef = {
433
436
  queue: [],
434
- armed: false,
437
+ owners: null,
438
+ batches: null,
439
+ unownedPending: false,
440
+ compact,
435
441
  add: (value) => {
436
442
  const inAction = (0, import_engine.isTransitionUpdateContext)();
437
443
  if (__octaneDev && !inAction) {
@@ -440,13 +446,33 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
440
446
  );
441
447
  }
442
448
  slotRef.queue.push(value);
443
- if (inAction && import_engine.TRANSITION_PENDING_COUNT > 0) {
444
- slotRef.armed = true;
449
+ const batch = inAction ? (0, import_transitions.transitionActionBatchForUpdate)() : null;
450
+ if (batch !== null) {
451
+ const owners2 = slotRef.owners ?? (slotRef.owners = new Array(slotRef.queue.length - 1).fill(null));
452
+ owners2.push(batch);
453
+ if (batch.finished) compact(batch);
454
+ else {
455
+ let batches = slotRef.batches;
456
+ if (batches === null) slotRef.batches = batches = /* @__PURE__ */ new Map();
457
+ if (!batches.has(batch))
458
+ batches.set(
459
+ batch,
460
+ (0, import_transitions.onTransitionBatchFinished)(batch, () => {
461
+ batches.delete(batch);
462
+ if (batches.size === 0) slotRef.batches = null;
463
+ if (compact(batch)) revert();
464
+ })
465
+ );
466
+ }
445
467
  } else {
446
- if (unownedIndices === null) {
447
- const indices = unownedIndices = [slotRef.queue.length - 1];
448
- queueMicrotask(() => clear(indices));
449
- } else unownedIndices.push(slotRef.queue.length - 1);
468
+ slotRef.owners?.push(null);
469
+ if (!slotRef.unownedPending) {
470
+ slotRef.unownedPending = true;
471
+ queueMicrotask(() => {
472
+ slotRef.unownedPending = false;
473
+ if (compact(null)) revert();
474
+ });
475
+ }
450
476
  }
451
477
  if (!block.disposed) {
452
478
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
@@ -458,15 +484,28 @@ function useOptimistic(passthrough, updateFnOrSlot, slot) {
458
484
  };
459
485
  s = slotRef;
460
486
  (0, import_hooks.ensureHooks)(scope).set(slot, slotRef);
461
- const listener = () => {
462
- if (import_engine.TRANSITION_PENDING_COUNT === 0 && slotRef.armed) clear();
463
- };
464
- import_transitions.TRANSITION_LISTENERS.add(listener);
465
- (0, import_hooks.registerHookCleanup)(scope, () => import_transitions.TRANSITION_LISTENERS.delete(listener));
487
+ (0, import_hooks.registerHookCleanup)(scope, () => {
488
+ const batches = slotRef.batches;
489
+ if (batches === null) return;
490
+ for (const unsubscribe of batches.values()) unsubscribe();
491
+ batches.clear();
492
+ slotRef.batches = null;
493
+ });
466
494
  }
467
495
  let optimistic = passthrough;
468
496
  const reduce = updateFn ?? basicOptimisticReducer;
469
- for (let i = 0; i < s.queue.length; i++) optimistic = reduce(optimistic, s.queue[i]);
497
+ const queue = s.queue;
498
+ const owners = s.owners;
499
+ const transition = block.currentRenderMode === "transition";
500
+ let reverted = null;
501
+ for (let i = 0; i < queue.length; i++) {
502
+ const owner = owners === null ? null : owners[i];
503
+ if (owner !== null && import_drivers.TRANSITION_ROOT_DRIVER && (transition || ((0, import_transitions.rootTransitionBatch)(owner).pendingHolds ?? 0) !== 0) && import_drivers.TRANSITION_ROOT_DRIVER.fold(owner, transition, import_render.ROOT_RENDER_TRANSACTION)) {
504
+ if (reverted === null) reverted = [owner];
505
+ else if (reverted.indexOf(owner) === -1) reverted.push(owner);
506
+ } else optimistic = reduce(optimistic, queue[i]);
507
+ }
508
+ if (reverted !== null) for (const owner of reverted) (0, import_commit.atCommit)(s.compact, owner);
470
509
  return [optimistic, s.add];
471
510
  }
472
511
  // Annotate the CommonJS export names for ESM import in node:
@@ -30,6 +30,7 @@ __export(child_slots_exports, {
30
30
  compilerCacheImmutableArrayFilter: () => compilerCacheImmutableArrayFilter,
31
31
  compilerCacheMappedArray: () => compilerCacheMappedArray,
32
32
  mapSlot: () => mapSlot,
33
+ renderSignalChildSlot: () => renderSignalChildSlot,
33
34
  textHole: () => textHole,
34
35
  textHoleUpdate: () => textHoleUpdate,
35
36
  textSlot: () => textSlot
@@ -267,6 +268,13 @@ function mapSlot(scopeOrItems, slotOrMethod, domParent, items, method, native, c
267
268
  }
268
269
  }
269
270
  }
271
+ function renderSignalChildSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable, onlyChild, bindingMarker, cachedText) {
272
+ if (onlyChild) return childTextHole(parentScope, slotKey, domParent, value, cachedText);
273
+ if (bindingMarker === void 0)
274
+ childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsHost, compactable);
275
+ else bindingChildSlot(parentScope, slotKey, domParent, value, bindingMarker, anchor, ownEnd);
276
+ return null;
277
+ }
270
278
  function bindingChildSlot(parentScope, slotKey, domParent, value, marker, anchor, ownEnd) {
271
279
  const frame = import_hydration_flag.hydrationStarted ? import_hydration_presentation.PRESENTATION_HYDRATION : null;
272
280
  if (frame?.revision !== void 0) {
@@ -337,6 +345,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
337
345
  }
338
346
  if (import_drivers.SIGNAL_CHILD) {
339
347
  if ((0, import_drivers.SIGNAL_CHILD)(
348
+ renderSignalChildSlot,
340
349
  parentScope,
341
350
  slotKey,
342
351
  domParent,
@@ -349,6 +358,7 @@ function childSlot(parentScope, slotKey, domParent, value, anchor, ownEnd, ownsH
349
358
  ))
350
359
  return;
351
360
  } else if (import_read_protocol.nativeSignalHydration && (0, import_signal_bindings.bindImplicitSignalChild)(
361
+ renderSignalChildSlot,
352
362
  parentScope,
353
363
  slotKey,
354
364
  domParent,
@@ -1108,6 +1118,7 @@ function childTextHole(parentScope, slotKey, domParent, value, cachedNode) {
1108
1118
  compilerCacheImmutableArrayFilter,
1109
1119
  compilerCacheMappedArray,
1110
1120
  mapSlot,
1121
+ renderSignalChildSlot,
1111
1122
  textHole,
1112
1123
  textHoleUpdate,
1113
1124
  textSlot
@@ -42,6 +42,7 @@ __export(commit_exports, {
42
42
  bagRecord: () => bagRecord,
43
43
  captureFocusSelection: () => captureFocusSelection,
44
44
  captureQueuedFocusSelection: () => captureQueuedFocusSelection,
45
+ commitQueuedBag: () => commitQueuedBag,
45
46
  defersRootUnmount: () => defersRootUnmount,
46
47
  discardMarker: () => discardMarker,
47
48
  dropRootOps: () => dropRootOps,
@@ -130,7 +131,7 @@ function bagRecord(s, next, cell, value, committed, bundle, a0, a1) {
130
131
  next[size] = s;
131
132
  next[size + 1] = transaction.ops.length;
132
133
  bag.$ = state | BAG_QUEUED;
133
- transaction.ops.push(next[size + 2], bag);
134
+ transaction.ops.push(commitQueuedBag, bag);
134
135
  }
135
136
  }
136
137
  next[cell] = changed ? value : bag;
@@ -147,9 +148,19 @@ function bagResume(bag) {
147
148
  journalObjectOnce(next);
148
149
  return next;
149
150
  }
150
- function bagDone(s, bag, commit) {
151
- bag.next[bag.$ & BAG_SIZE] = s;
152
- commit(bag, import_render.TRANSITION_JOURNAL !== null || import_events._dispatchDepth !== 0 && import_events.CAPTURE_SLOTS.length !== 0);
151
+ function bagDone(s, bag) {
152
+ const next = bag.next;
153
+ const size = bag.$ &= BAG_SIZE;
154
+ next[size] = s;
155
+ next[size + 2](
156
+ bag,
157
+ next,
158
+ import_render.TRANSITION_JOURNAL !== null || import_events._dispatchDepth !== 0 && import_events.CAPTURE_SLOTS.length !== 0
159
+ );
160
+ }
161
+ function commitQueuedBag(bag, careful) {
162
+ const next = bag.next;
163
+ next[(bag.$ &= BAG_SIZE) + 2](bag, next, careful);
153
164
  }
154
165
  function slotNext(slot) {
155
166
  const tx = import_render.ROOT_RENDER_TRANSACTION;
@@ -404,7 +415,7 @@ function dropRootOps(transaction, from, retired) {
404
415
  for (let i = from; i < ops.length; i += 2) {
405
416
  const target = ops[i + 1];
406
417
  if (ops[i] === applySlotNext) target.next = null;
407
- else if (typeof target?.$ === "number") target.$ &= BAG_SIZE;
418
+ else if (ops[i] === commitQueuedBag) target.$ &= BAG_SIZE;
408
419
  }
409
420
  ops.length = from;
410
421
  const set = transaction.retired;
@@ -1061,6 +1072,7 @@ function withRegisteredRefDetachSuppression(entries, fn) {
1061
1072
  bagRecord,
1062
1073
  captureFocusSelection,
1063
1074
  captureQueuedFocusSelection,
1075
+ commitQueuedBag,
1064
1076
  defersRootUnmount,
1065
1077
  discardMarker,
1066
1078
  dropRootOps,
@@ -52,6 +52,7 @@ module.exports = __toCommonJS(deopt_exports);
52
52
  var import_branches = require("./branches.cjs");
53
53
  var import_hydration_flag = require("../hydration-flag.cjs");
54
54
  var import_has_own = require("../has-own.cjs");
55
+ var import_dom_focused_move = require("../dom-focused-move.cjs");
55
56
  var import_shared_value_helpers = require("../shared-value-helpers.cjs");
56
57
  var import_profiling = require("../profiling.cjs");
57
58
  var import_error_codes_client_generated = require("../error-codes.client.generated.cjs");
@@ -795,7 +796,7 @@ function applyDeoptOrder(order) {
795
796
  }
796
797
  if (order.desc !== null) {
797
798
  if (order.owner === null) stampDeoptDesc(node, order.desc);
798
- else (0, import_render.commitInScope)(order.owner, commitDeoptHost, node, order.desc);
799
+ else (0, import_render.commitInScope)((0, import_branches.owningBlock)(order.owner), commitDeoptHost, node, order.desc);
799
800
  }
800
801
  if (order.nodes !== null) placeDeoptChildren(node, order.nodes, true, false);
801
802
  }
@@ -810,7 +811,7 @@ function placeDeoptChildren(el, result, skip, adopt) {
810
811
  const want = result[i];
811
812
  const at = skip ? nextDeoptOwnedChild(cursor, adopt) : cursor;
812
813
  if (at !== want) {
813
- if (import_engine.renderingFocus === null) el.insertBefore(want, at);
814
+ if (import_engine.renderingFocus === null) (0, import_dom_focused_move.moveNativeNodeBefore)(el, want, at, null, false);
814
815
  else {
815
816
  (0, import_engine.captureFocusedMovement)(el, import_engine.renderingFocus);
816
817
  (0, import_lists.moveFocusedNodeBefore)(el, want, at, import_engine.renderingFocus);
@@ -136,6 +136,7 @@ __export(engine_exports, {
136
136
  runEffectCleanupCallback: () => runEffectCleanupCallback,
137
137
  runEffectLifecycleCallback: () => runEffectLifecycleCallback,
138
138
  runTransition: () => runTransition,
139
+ scheduleHookPublication: () => scheduleHookPublication,
139
140
  scheduleNativeRead: () => scheduleNativeRead,
140
141
  scheduleRender: () => scheduleRender,
141
142
  scheduleRenderCleanup: () => scheduleRenderCleanup,
@@ -171,7 +172,7 @@ var import_error_codes_client_generated = require("../error-codes.client.generat
171
172
  var import_native_read_client = require("../signals/native-read-client.cjs");
172
173
  var import_transition_state = require("../signals/transition-state.cjs");
173
174
  var import_read_protocol = require("../signals/read-protocol.cjs");
174
- var import_native_read_seeds = require("../signals/native-read-seeds.cjs");
175
+ var import_native_adoption = require("../signals/native-adoption.cjs");
175
176
  var import_owner_context = require("../signals/owner-context.cjs");
176
177
  var import_document_owner = require("../signals/document-owner.cjs");
177
178
  var import_profile_probes = require("./profile-probes.cjs");
@@ -235,16 +236,16 @@ function ownNativeAdoption(scope, manifest, consume) {
235
236
  const initial = renderOwner?.initialDocumentSignals;
236
237
  const signalOwner = renderOwner?.signalOwner;
237
238
  const initialScopeKey = (signalOwner?.documentOwner ?? signalOwner)?.scopeKey ?? "octane:document";
238
- let state = import_read_protocol.nativeSignalHydration ? (0, import_native_read_seeds.createNativeAdoptionState)(
239
- typeof manifest === "string" ? (0, import_native_read_seeds.parseNativeSignalManifest)(manifest) : manifest,
239
+ let state = import_read_protocol.nativeSignalHydration ? (0, import_native_adoption.createNativeAdoptionState)(
240
+ typeof manifest === "string" ? (0, import_native_adoption.parseNativeSignalManifest)(manifest) : manifest,
240
241
  initial,
241
242
  initialScopeKey
242
243
  ) : void 0;
243
244
  const adoption = state ?? {
244
245
  resolve(owner) {
245
246
  if (state === null || !import_read_protocol.nativeSignalHydration) return void 0;
246
- state ??= (0, import_native_read_seeds.createNativeAdoptionState)(
247
- typeof manifest === "string" ? (0, import_native_read_seeds.parseNativeSignalManifest)(manifest) : manifest,
247
+ state ??= (0, import_native_adoption.createNativeAdoptionState)(
248
+ typeof manifest === "string" ? (0, import_native_adoption.parseNativeSignalManifest)(manifest) : manifest,
248
249
  initial,
249
250
  initialScopeKey
250
251
  );
@@ -423,7 +424,15 @@ function unsuspendTransitionHolder(holder) {
423
424
  scheduleTransitionTask();
424
425
  }
425
426
  }
426
- let TRANSITION_LISTENER_PUBLISH_DEPTH = 0;
427
+ let TRANSITION_HOOK_PUBLISH_DEPTH = 0;
428
+ function scheduleHookPublication(block) {
429
+ TRANSITION_HOOK_PUBLISH_DEPTH++;
430
+ try {
431
+ scheduleUrgentRender(block);
432
+ } finally {
433
+ TRANSITION_HOOK_PUBLISH_DEPTH--;
434
+ }
435
+ }
427
436
  let TRANSITION_ORIGIN = null;
428
437
  let TRANSITION_HARVEST = null;
429
438
  let TRANSITION_CELL_HARVEST = null;
@@ -821,19 +830,22 @@ function commitRootRenders() {
821
830
  try {
822
831
  for (let i = 0; i < ops.length; i += 2) {
823
832
  if (owner.disposed || owner.generation !== COMMITTING_GENERATION) break;
833
+ const op = ops[i];
824
834
  const target = ops[i + 1];
835
+ const bag = op === import_commit.commitQueuedBag;
825
836
  COMMIT_OP = i;
826
837
  try {
827
- ops[i](
828
- target,
829
- import_render.TRANSITION_JOURNAL !== null || import_events._dispatchDepth !== 0 && import_events.CAPTURE_SLOTS.length !== 0
830
- );
838
+ const careful = import_render.TRANSITION_JOURNAL !== null || import_events._dispatchDepth !== 0 && import_events.CAPTURE_SLOTS.length !== 0;
839
+ if (bag) {
840
+ const next = target.next;
841
+ next[(target.$ &= import_commit.BAG_SIZE) + 2](target, next, careful);
842
+ } else op(target, careful);
831
843
  } catch (error) {
832
- if (typeof target?.$ !== "number") throw error;
844
+ if (!bag) throw error;
833
845
  if (import_drivers.SIGNAL_COMMIT_RETRY ? !(0, import_drivers.SIGNAL_COMMIT_RETRY)(target, error) : true)
834
846
  reportEffectError(target.next[target.$ & import_commit.BAG_SIZE].block, error);
835
847
  }
836
- if (import_commit.BAG_POOL.length < 8 && target?.$ <= import_commit.BAG_SIZE) {
848
+ if (bag && import_commit.BAG_POOL.length < 8 && target.$ <= import_commit.BAG_SIZE) {
837
849
  const next = target.next;
838
850
  import_commit.BAG_POOL.push(next);
839
851
  target.next = next[target.$ + 2];
@@ -1008,18 +1020,6 @@ function tickTransitionCount(delta) {
1008
1020
  if (TRANSITION_PENDING_COUNT < 0) TRANSITION_PENDING_COUNT = 0;
1009
1021
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
1010
1022
  (0, import_devtools_hook.__devtoolsSetTransitionCount)(TRANSITION_PENDING_COUNT);
1011
- TRANSITION_LISTENER_PUBLISH_DEPTH++;
1012
- try {
1013
- for (const fn of import_transitions.TRANSITION_LISTENERS) {
1014
- try {
1015
- fn();
1016
- } catch (err) {
1017
- console.error(err);
1018
- }
1019
- }
1020
- } finally {
1021
- TRANSITION_LISTENER_PUBLISH_DEPTH--;
1022
- }
1023
1023
  }
1024
1024
  const refAttachQueue = [];
1025
1025
  function attachLiveFragmentRef(instance) {
@@ -1167,7 +1167,7 @@ This ensures you're testing the behavior the user would see in the browser.`
1167
1167
  );
1168
1168
  }
1169
1169
  const renderPhaseSelf = import_render.CURRENT_BLOCK === block;
1170
- const renderPhaseOther = import_render.CURRENT_BLOCK !== null && (!renderPhaseSelf || import_render.CURRENT_SCOPE !== block) && TRANSITION_LISTENER_PUBLISH_DEPTH === 0 && EFFECT_EVENT_LIFECYCLE_DEPTH === 0;
1170
+ const renderPhaseOther = import_render.CURRENT_BLOCK !== null && (!renderPhaseSelf || import_render.CURRENT_SCOPE !== block) && TRANSITION_HOOK_PUBLISH_DEPTH === 0 && EFFECT_EVENT_LIFECYCLE_DEPTH === 0;
1171
1171
  if (renderPhaseOther) {
1172
1172
  block.crossRenderUpdate = true;
1173
1173
  warnCrossComponentRenderUpdate(block, import_render.CURRENT_BLOCK);
@@ -3271,14 +3271,14 @@ function useTransition(slot) {
3271
3271
  hook.tentative = false;
3272
3272
  if (hook.isPending === pending || block.disposed) return;
3273
3273
  hook.isPending = pending;
3274
- TRANSITION_LISTENER_PUBLISH_DEPTH++;
3274
+ TRANSITION_HOOK_PUBLISH_DEPTH++;
3275
3275
  try {
3276
3276
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
3277
3277
  (0, import_profiling.__profileSchedule)(block, "transition-pending", slot);
3278
3278
  if (pending) (0, import_transitions.markTransitionCue)(block);
3279
3279
  scheduleRender(block, false, pending);
3280
3280
  } finally {
3281
- TRANSITION_LISTENER_PUBLISH_DEPTH--;
3281
+ TRANSITION_HOOK_PUBLISH_DEPTH--;
3282
3282
  }
3283
3283
  }
3284
3284
  };
@@ -3309,16 +3309,25 @@ function runDeferredSwaps() {
3309
3309
  DEFERRED_SWAPS = null;
3310
3310
  if (slots === null) return;
3311
3311
  TRANSITION_TASK_ACTIVE = true;
3312
+ let roots = null;
3312
3313
  try {
3313
- for (let i = 0; i < slots.length; i++) swapDeferredValue(slots[i]);
3314
+ for (let i = 0; i < slots.length; i++) {
3315
+ const root = swapDeferredValue(slots[i]);
3316
+ if (root !== null && !(roots ??= []).includes(root)) roots.push(root);
3317
+ }
3318
+ if (roots !== null) for (const root of roots) root.retry(true);
3314
3319
  } finally {
3315
3320
  TRANSITION_TASK_ACTIVE = false;
3316
3321
  }
3317
3322
  }
3318
3323
  function swapDeferredValue(s) {
3319
- if (!s.scheduled || s.block.disposed) return;
3324
+ if (!s.scheduled) return null;
3320
3325
  s.scheduled = false;
3321
- if (Object.is(s.value, s.next)) return;
3326
+ if (s.block.disposed) {
3327
+ const owner = s.block.idState.renderOwner;
3328
+ return owner !== void 0 && owner.wakeable !== null && (owner.current === null || owner.current.disposed) ? owner : null;
3329
+ }
3330
+ if (Object.is(s.value, s.next)) return null;
3322
3331
  (0, import_transitions.startTransition)(() => {
3323
3332
  DEFERRED_SPAWN = true;
3324
3333
  try {
@@ -3334,6 +3343,7 @@ function swapDeferredValue(s) {
3334
3343
  DEFERRED_SPAWN = false;
3335
3344
  }
3336
3345
  });
3346
+ return null;
3337
3347
  }
3338
3348
  function hideActivityRefs(activity) {
3339
3349
  if (!activity.hasRefs) return;
@@ -3399,7 +3409,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
3399
3409
  spareOps: []
3400
3410
  };
3401
3411
  idState.renderOwner = renderOwner;
3402
- const renderResolved = (body, props, nextKey, mode) => {
3412
+ const renderResolved = (body, props, nextKey, mode, deferred = false) => {
3403
3413
  if (unmounted) return;
3404
3414
  (0, import_context_epoch.bumpContextEpoch)();
3405
3415
  if (rootBlock && !rootBlock.disposed && currentBody === body && Object.is(currentKey, nextKey)) {
@@ -3509,6 +3519,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
3509
3519
  }
3510
3520
  const mountedRoot = rootBlock;
3511
3521
  mountedRoot.pendingMode = mode ?? null;
3522
+ mountedRoot.pendingDeferred = deferred;
3512
3523
  try {
3513
3524
  (0, import_signal_owners.renderBlock)(mountedRoot);
3514
3525
  if (QUEUE.length > 0) drainHydrationRenderPhaseUpdates(mountedRoot);
@@ -3621,7 +3632,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
3621
3632
  renderOwner.retryKey = null;
3622
3633
  renderOwner.request = null;
3623
3634
  if (renderOwner.transaction?.aborted === true) renderOwner.transaction = null;
3624
- renderOwner.retry = () => renderResolved(body, props, nextKey);
3635
+ renderOwner.retry = (deferred) => renderResolved(body, props, nextKey, deferred ? "transition" : void 0, deferred);
3625
3636
  renderResolved(body, props, nextKey);
3626
3637
  },
3627
3638
  unmount() {
@@ -3812,6 +3823,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
3812
3823
  runEffectCleanupCallback,
3813
3824
  runEffectLifecycleCallback,
3814
3825
  runTransition,
3826
+ scheduleHookPublication,
3815
3827
  scheduleNativeRead,
3816
3828
  scheduleRender,
3817
3829
  scheduleRenderCleanup,