octane 0.14.0 → 0.14.1

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 (107) hide show
  1. package/dist/cjs/dom-bindings.cjs +161 -46
  2. package/dist/cjs/dom-focused-move.cjs +1 -1
  3. package/dist/cjs/hydration-flag.cjs +8 -0
  4. package/dist/cjs/hydration-input-control.cjs +31 -0
  5. package/dist/cjs/hydration-inputs.cjs +184 -0
  6. package/dist/cjs/internal/client.cjs +17 -0
  7. package/dist/cjs/method-dep.cjs +2 -0
  8. package/dist/cjs/runtime/block.cjs +1 -1
  9. package/dist/cjs/runtime/commit.cjs +1 -1
  10. package/dist/cjs/runtime/component-slots.cjs +8 -1
  11. package/dist/cjs/runtime/drivers.cjs +1 -0
  12. package/dist/cjs/runtime/engine.cjs +58 -0
  13. package/dist/cjs/runtime/events.cjs +8 -6
  14. package/dist/cjs/runtime/host-props.cjs +22 -13
  15. package/dist/cjs/runtime/hydration-presentation.cjs +72 -27
  16. package/dist/cjs/runtime/hydration.cjs +100 -0
  17. package/dist/cjs/runtime/render.cjs +39 -5
  18. package/dist/cjs/runtime/signal-owners.cjs +19 -10
  19. package/dist/cjs/runtime/suspense.cjs +40 -11
  20. package/dist/cjs/runtime/templates.cjs +2 -1
  21. package/dist/cjs/runtime.cjs +2 -0
  22. package/dist/cjs/runtime.server.cjs +2 -2
  23. package/dist/cjs/signals/graph.cjs +18 -3
  24. package/dist/cjs/version.cjs +1 -1
  25. package/dist/compiler/bundler.js +16 -4
  26. package/dist/compiler/compile-universal.js +69 -6
  27. package/dist/compiler/compile.js +966 -53
  28. package/dist/compiler/dom-binding-program.js +63 -9
  29. package/dist/compiler/dom-bindings.js +98 -52
  30. package/dist/compiler/signal-declarations.js +41 -0
  31. package/dist/dom-binding-program.d.ts +3 -1
  32. package/dist/dom-binding-program.js +18 -5
  33. package/dist/dom-bindings.d.ts +27 -4
  34. package/dist/dom-bindings.js +157 -46
  35. package/dist/dom-focused-move.js +1 -1
  36. package/dist/hydration-flag.d.ts +4 -0
  37. package/dist/hydration-flag.js +6 -0
  38. package/dist/hydration-input-control.d.ts +2 -0
  39. package/dist/hydration-input-control.js +7 -0
  40. package/dist/hydration-inputs.d.ts +21 -0
  41. package/dist/hydration-inputs.js +153 -0
  42. package/dist/internal/client.d.ts +1 -0
  43. package/dist/internal/client.js +18 -0
  44. package/dist/method-dep.d.ts +1 -0
  45. package/dist/method-dep.js +1 -0
  46. package/dist/node/dom-binding-program.js +18 -5
  47. package/dist/node/dom-bindings.js +157 -46
  48. package/dist/node/dom-focused-move.js +1 -1
  49. package/dist/node/hydration-flag.js +6 -0
  50. package/dist/node/hydration-input-control.js +7 -0
  51. package/dist/node/hydration-inputs.js +153 -0
  52. package/dist/node/internal/client.js +18 -0
  53. package/dist/node/method-dep.js +1 -0
  54. package/dist/node/runtime/block.js +1 -1
  55. package/dist/node/runtime/commit.js +1 -1
  56. package/dist/node/runtime/component-slots.js +8 -1
  57. package/dist/node/runtime/drivers.js +2 -0
  58. package/dist/node/runtime/engine.js +57 -0
  59. package/dist/node/runtime/events.js +8 -6
  60. package/dist/node/runtime/host-props.js +21 -13
  61. package/dist/node/runtime/hydration-presentation.js +73 -28
  62. package/dist/node/runtime/hydration.js +102 -1
  63. package/dist/node/runtime/render.js +42 -5
  64. package/dist/node/runtime/signal-owners.js +19 -10
  65. package/dist/node/runtime/suspense.js +40 -12
  66. package/dist/node/runtime/templates.js +2 -1
  67. package/dist/node/runtime.js +2 -0
  68. package/dist/node/runtime.server.js +2 -2
  69. package/dist/node/signals/graph.js +16 -3
  70. package/dist/node/signals/hydration-input-source.js +21 -0
  71. package/dist/node/universal-core.js +46 -7
  72. package/dist/node/version.js +1 -1
  73. package/dist/runtime/block.js +1 -1
  74. package/dist/runtime/commit.d.ts +4 -3
  75. package/dist/runtime/commit.js +1 -1
  76. package/dist/runtime/component-slots.d.ts +1 -0
  77. package/dist/runtime/component-slots.js +8 -1
  78. package/dist/runtime/drivers.d.ts +3 -1
  79. package/dist/runtime/drivers.js +2 -0
  80. package/dist/runtime/engine.d.ts +2 -0
  81. package/dist/runtime/engine.js +57 -0
  82. package/dist/runtime/events.js +8 -6
  83. package/dist/runtime/host-props.d.ts +2 -0
  84. package/dist/runtime/host-props.js +21 -13
  85. package/dist/runtime/hydration-presentation.d.ts +4 -2
  86. package/dist/runtime/hydration-presentation.js +73 -28
  87. package/dist/runtime/hydration.d.ts +5 -0
  88. package/dist/runtime/hydration.js +102 -1
  89. package/dist/runtime/render.js +42 -5
  90. package/dist/runtime/signal-owners.js +19 -10
  91. package/dist/runtime/suspense.d.ts +2 -1
  92. package/dist/runtime/suspense.js +40 -12
  93. package/dist/runtime/templates.d.ts +1 -1
  94. package/dist/runtime/templates.js +2 -1
  95. package/dist/runtime/types.d.ts +11 -0
  96. package/dist/runtime.d.ts +1 -1
  97. package/dist/runtime.js +2 -0
  98. package/dist/runtime.server.d.ts +1 -1
  99. package/dist/runtime.server.js +2 -2
  100. package/dist/signals/graph.d.ts +7 -1
  101. package/dist/signals/graph.js +16 -3
  102. package/dist/signals/hydration-input-source.d.ts +3 -0
  103. package/dist/signals/hydration-input-source.js +21 -0
  104. package/dist/universal-core.d.ts +1 -1
  105. package/dist/universal-core.js +46 -7
  106. package/dist/version.js +1 -1
  107. package/package.json +6 -1
@@ -19,14 +19,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var dom_bindings_exports = {};
20
20
  __export(dom_bindings_exports, {
21
21
  __adoptBindings: () => __adoptBindings,
22
+ __adoptFixedScalarViewBindings: () => __adoptFixedScalarViewBindings,
23
+ __adoptFixedViewBindings: () => __adoptFixedViewBindings,
22
24
  __adoptScalarBindings: () => __adoptScalarBindings,
23
25
  __bindingURL: () => __bindingURL,
24
26
  __claimBinding: () => __claimBinding,
25
27
  __createBindingStyleRestoration: () => __createBindingStyleRestoration,
28
+ __isBindingTextLeaf: () => __isBindingTextLeaf,
26
29
  __mountBindings: () => __mountBindings,
27
30
  __normalizeBinding: () => normalize,
28
31
  __releaseBinding: () => __releaseBinding,
29
32
  __writeBinding: () => write,
33
+ __writeBindingWithTextWitness: () => __writeBindingWithTextWitness,
30
34
  adoptBindings: () => adoptBindings,
31
35
  mountBindings: () => mountBindings,
32
36
  unbound: () => unbound
@@ -105,7 +109,7 @@ function assertBindingRoot(root, descriptor) {
105
109
  }
106
110
  return root;
107
111
  }
108
- function isTextLeaf(node) {
112
+ function __isBindingTextLeaf(node) {
109
113
  const first = node.firstChild;
110
114
  return first === null || !first.nextSibling && first.nodeType === 3;
111
115
  }
@@ -117,7 +121,7 @@ function resolveFixedNodes(root, descriptor) {
117
121
  for (let i = 0; i < descriptor.nodes.length; i++) {
118
122
  const [parent, tag, namespace, children, openChildren, text] = descriptor.nodes[i];
119
123
  const node = i === 0 ? parent === -1 ? root : void 0 : cursors[parent];
120
- if (node == null || openChildren === true || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || text && !isTextLeaf(node)) {
124
+ if (node == null || openChildren === true || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || text && !__isBindingTextLeaf(node)) {
121
125
  throw new Error(__octaneDev ? "DOM bindings cannot adopt a mismatched static element topology." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(318));
122
126
  }
123
127
  if (i !== 0) {
@@ -136,6 +140,18 @@ function resolveFixedNodes(root, descriptor) {
136
140
  }
137
141
  return nodes;
138
142
  }
143
+ function matchesFixedNodes(root, descriptor, nodes, text) {
144
+ try {
145
+ if (!resolveFixedNodes(root, descriptor).every((node, index) => node === nodes[index]))
146
+ return false;
147
+ if (text !== void 0) {
148
+ for (const [node, original] of text) if (node.firstChild !== original) return false;
149
+ }
150
+ return true;
151
+ } catch {
152
+ return false;
153
+ }
154
+ }
139
155
  function resolveAddressedNodes(root, descriptor) {
140
156
  const nodes = [];
141
157
  const prefix = `${descriptor.id}:`;
@@ -168,7 +184,7 @@ function resolveAddressedNodes(root, descriptor) {
168
184
  const [parent, tag, namespace, children, openChildren, text] = descriptor.nodes[i];
169
185
  const node = nodes[i];
170
186
  if (node === void 0 || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || (i === 0 ? parent !== -1 || node !== root : parent < 0 || parent >= i || node.parentElement !== nodes[parent] || // A parent without a cursor claims no children.
171
- descriptor.nodes[parent][4] !== true && cursors[parent] !== node) || openChildren && children === null || text && !isTextLeaf(node)) {
187
+ descriptor.nodes[parent][4] !== true && cursors[parent] !== node) || openChildren && children === null || text && !__isBindingTextLeaf(node)) {
172
188
  throw new Error(__octaneDev ? "DOM bindings cannot adopt a mismatched addressed element topology." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(321));
173
189
  }
174
190
  if (parent !== -1) {
@@ -271,6 +287,19 @@ function write(node, binding, value) {
271
287
  }
272
288
  } else return writeFixedScalar(node, binding, value);
273
289
  }
290
+ function writeBindingWithTextWitness(node, binding, value, fixedText, writer) {
291
+ if (binding[1] === "text" && fixedText.get(node) === null) {
292
+ if (node.firstChild !== null) throw new Error(__octaneDev ? "DOM bindings cannot adopt a mismatched static element topology." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(318));
293
+ const text = node.ownerDocument.createTextNode(value);
294
+ node.appendChild(text);
295
+ fixedText.set(node, text);
296
+ return value;
297
+ }
298
+ return writer(node, binding, value);
299
+ }
300
+ function __writeBindingWithTextWitness(node, binding, value, fixedText) {
301
+ return writeBindingWithTextWitness(node, binding, value, fixedText, write);
302
+ }
274
303
  const __bindingURL = [
275
304
  (binding) => binding[1] === "url" || isFixedScalarChannel(binding),
276
305
  normalize,
@@ -323,11 +352,91 @@ function __createBindingStyleRestoration(node, binding) {
323
352
  }
324
353
  };
325
354
  }
326
- function __adoptBindings(root, descriptor, source, options) {
355
+ function skipBindingSidecars(next, previous) {
356
+ while (next?.nodeType === 1 && next.localName === "script" && (next.hasAttribute(import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR) || next.hasAttribute(import_stream_protocol.SUSPENSE_SCRIPT_ATTR) || next.hasAttribute(import_stream_protocol.STREAM_SCRIPT_ATTR)))
357
+ next = previous ? next.previousSibling : next.nextSibling;
358
+ return next;
359
+ }
360
+ function bindingSibling(node, previous) {
361
+ return skipBindingSidecars(previous ? node.previousSibling : node.nextSibling, previous);
362
+ }
363
+ function captureBindingSite(root) {
364
+ const ancestry = [];
365
+ for (let node = root; node !== null; node = node.parentNode)
366
+ ancestry.push([node, node.parentNode]);
367
+ return {
368
+ document: root.ownerDocument,
369
+ ancestry,
370
+ parent: root.parentNode,
371
+ previous: bindingSibling(root, true),
372
+ next: bindingSibling(root, false)
373
+ };
374
+ }
375
+ function validBindingSite(root, id, site) {
376
+ return root.parentNode !== null && root.ownerDocument === site.document && site.ancestry.every(([node, parent]) => node.parentNode === parent) && bindingSibling(root, true) === site.previous && bindingSibling(root, false) === site.next && root.getAttribute("data-octane-bindings") === id;
377
+ }
378
+ function displacedBindingSite(root, site, parent, node) {
379
+ return parent === site.parent && node !== root && (node === null || node.parentNode === parent) && (node === null ? skipBindingSidecars(parent.lastChild, true) : bindingSibling(node, true)) === site.previous;
380
+ }
381
+ function flushBindingPublication(retries, active) {
382
+ if (!retries?.size) return;
383
+ const pending = [...retries];
384
+ retries.clear();
385
+ for (const retry of pending)
386
+ queueMicrotask(() => {
387
+ if (active()) retry();
388
+ });
389
+ }
390
+ function prepareFixedBindingView(root, descriptor, nodes, writer) {
391
+ let fixedText;
392
+ for (let index = 0; index < nodes.length; index++)
393
+ if (descriptor.nodes[index][5])
394
+ (fixedText ??= /* @__PURE__ */ new Map()).set(nodes[index], nodes[index].firstChild);
395
+ return {
396
+ valid: () => matchesFixedNodes(root, descriptor, nodes, fixedText),
397
+ write: fixedText === void 0 ? writer : (node, binding, value) => writeBindingWithTextWitness(node, binding, value, fixedText, writer)
398
+ };
399
+ }
400
+ function prepareFixedScalarBindingView(root, descriptor, nodes, writer, lifetime) {
401
+ const fixed = prepareFixedBindingView(root, descriptor, nodes, writer);
402
+ const site = captureBindingSite(root);
403
+ let retries;
404
+ let handoff;
405
+ const view = {
406
+ revision: 0,
407
+ write: fixed.write,
408
+ published: () => flushBindingPublication(retries, lifetime.active),
409
+ dispose: () => retries?.clear()
410
+ };
411
+ lifetime.handle[import_control_handoff.BINDING_HANDOFF] = () => handoff ??= {
412
+ id: descriptor.id,
413
+ root,
414
+ anchor: root,
415
+ end: root,
416
+ revision: () => lifetime.busy() ? -1 : view.revision,
417
+ afterPublication: (callback) => {
418
+ (retries ??= /* @__PURE__ */ new Set()).add(callback);
419
+ return () => retries.delete(callback);
420
+ },
421
+ valid: () => validBindingSite(root, descriptor.id, site) && fixed.valid(),
422
+ active: lifetime.active,
423
+ retire: lifetime.retire
424
+ };
425
+ return view;
426
+ }
427
+ function __adoptFixedViewBindings(root, descriptor, source, options) {
428
+ return __adoptBindings(root, descriptor, source, options, prepareFixedBindingView);
429
+ }
430
+ function __adoptFixedScalarViewBindings(root, descriptor, source, options) {
431
+ return __adoptScalarBindings(root, descriptor, source, options, prepareFixedScalarBindingView);
432
+ }
433
+ function __adoptBindings(root, descriptor, source, options, prepareView) {
327
434
  if ("root" in descriptor) return descriptor.adopt(root, descriptor, source, options);
328
435
  if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
329
436
  throw new TypeError(__octaneDev ? "DOM bindings require synchronous getSnapshot() and subscribe() methods." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(325));
330
437
  const nodes = descriptor.addressed ? resolveAddressedNodes(assertBindingRoot(root, descriptor), descriptor) : resolveFixedNodes(root, descriptor);
438
+ const view = prepareView?.(root, descriptor, nodes, write);
439
+ const writeChannel = view?.write ?? write;
331
440
  const bindings = descriptor.bindings;
332
441
  const owned = [];
333
442
  const previous = [];
@@ -462,7 +571,7 @@ function __adoptBindings(root, descriptor, source, options) {
462
571
  if (!style)
463
572
  styles.set(i, style = __createBindingStyleRestoration(nodes[binding[0]], binding));
464
573
  style.write(prepared);
465
- } else written = write(nodes[binding[0]], binding, prepared);
574
+ } else written = writeChannel(nodes[binding[0]], binding, prepared);
466
575
  if (!disposed) {
467
576
  previous[i] = prepared;
468
577
  if (binding[1] === "attr" || binding[1] === "boolean" || binding[1] === "aria" || binding[1] === "class" || binding[1] === "url" || binding[1] === "styleProperty" || binding[1] === "styleObject" || binding[1] === "text") {
@@ -670,53 +779,35 @@ function __adoptBindings(root, descriptor, source, options) {
670
779
  drain();
671
780
  };
672
781
  const handle = { refresh, dispose };
673
- if (descriptor.handoff === "host") {
674
- published = () => {
675
- if (!publicationRetries?.size) return;
676
- const pending = [...publicationRetries];
677
- publicationRetries.clear();
678
- for (const retry of pending)
679
- queueMicrotask(() => {
680
- if (!disposed) retry();
681
- });
682
- };
782
+ if (descriptor.handoff) {
783
+ const active = () => !disposed;
784
+ published = () => flushBindingPublication(publicationRetries, active);
683
785
  const host = root;
684
- const document = host.ownerDocument;
685
- const ancestry = [];
686
- for (let node = host; node !== null; node = node.parentNode)
687
- ancestry.push([node, node.parentNode]);
688
- const skip = (next, previous2) => {
689
- while (next?.nodeType === 1 && next.localName === "script" && (next.hasAttribute(import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR) || next.hasAttribute(import_stream_protocol.SUSPENSE_SCRIPT_ATTR) || next.hasAttribute(import_stream_protocol.STREAM_SCRIPT_ATTR)))
690
- next = previous2 ? next.previousSibling : next.nextSibling;
691
- return next;
692
- };
693
- const sibling = (node, previous2) => skip(previous2 ? node.previousSibling : node.nextSibling, previous2);
694
- const site = host.parentNode;
695
- const previousSibling = sibling(host, true);
696
- const nextSibling = sibling(host, false);
786
+ const site = captureBindingSite(host);
697
787
  let handoff;
698
788
  handle[import_control_handoff.BINDING_HANDOFF] = () => {
699
789
  if (handoff !== void 0) return handoff;
700
- const adjacent = (recorded, previous2) => sibling(host, previous2) === recorded;
701
790
  return handoff = {
702
791
  id: descriptor.id,
703
792
  root: host,
704
793
  anchor: host,
705
- host: new Set(
706
- bindings.map(
707
- (binding) => binding[1] === "styleProperty" ? "style:" + binding[2] : binding[1].startsWith("style") ? "style" : binding[2]
708
- )
709
- ),
794
+ ...view ? { end: host } : {
795
+ host: new Set(
796
+ bindings.map(
797
+ (binding) => binding[1] === "styleProperty" ? "style:" + binding[2] : binding[1].startsWith("style") ? "style" : binding[2]
798
+ )
799
+ ),
800
+ // The authored node before the host still marks its site after the
801
+ // host leaves, including when an external clone now stands there.
802
+ displaced: (parent, node) => displacedBindingSite(host, site, parent, node)
803
+ },
710
804
  revision: () => busy ? -1 : revision,
711
805
  afterPublication: (callback) => {
712
806
  (publicationRetries ??= /* @__PURE__ */ new Set()).add(callback);
713
807
  return () => publicationRetries.delete(callback);
714
808
  },
715
- valid: () => host.parentNode !== null && host.ownerDocument === document && ancestry.every(([node, parent]) => node.parentNode === parent) && adjacent(previousSibling, true) && adjacent(nextSibling, false) && host.getAttribute("data-octane-bindings") === descriptor.id,
716
- // The authored node before the host still marks its site after the
717
- // host leaves, including when an external clone now stands there.
718
- displaced: (parent, node) => parent === site && node !== host && (node === null || node.parentNode === parent) && (node === null ? skip(parent.lastChild, true) : sibling(node, true)) === previousSibling,
719
- active: () => !disposed,
809
+ valid: () => validBindingSite(host, descriptor.id, site) && (view?.valid() ?? true),
810
+ active,
720
811
  retire: (publish) => dispose(void 0, publish, true)
721
812
  };
722
813
  };
@@ -765,13 +856,13 @@ function __adoptBindings(root, descriptor, source, options) {
765
856
  throw error;
766
857
  }
767
858
  }
768
- function __adoptScalarBindings(root, descriptor, source, options) {
859
+ function __adoptScalarBindings(root, descriptor, source, options, prepareView) {
769
860
  const [
770
861
  accepts = isFixedScalarChannel,
771
862
  normalizeChannel = normalizeFixedScalar,
772
- writeChannel = writeFixedScalar
863
+ selectedWriter = writeFixedScalar
773
864
  ] = descriptor.url ?? [];
774
- if (descriptor.addressed || descriptor.handoff || descriptor.connectProjection || !descriptor.bindings.every(accepts))
865
+ if (descriptor.addressed || descriptor.handoff !== (prepareView ? "view" : void 0) || descriptor.connectProjection || !descriptor.bindings.every(accepts))
775
866
  throw new TypeError(__octaneDev ? "This DOM binding view requires the general adopter." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(330));
776
867
  if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
777
868
  throw new TypeError(__octaneDev ? "DOM bindings require synchronous getSnapshot() and subscribe() methods." : (0, import_error_message_no_arguments.formatNoArgumentErrorMessage)(325));
@@ -786,16 +877,25 @@ function __adoptScalarBindings(root, descriptor, source, options) {
786
877
  let busy = true;
787
878
  let dirty = false;
788
879
  let unsubscribe;
789
- const signal = options?.signal;
790
- const dispose = () => {
791
- if (disposed) return;
880
+ const dispose = (_disposal, publish, preservePresentation = false) => {
881
+ if (disposed) {
882
+ publish?.();
883
+ return;
884
+ }
792
885
  disposed = true;
886
+ view?.dispose();
793
887
  signal?.removeEventListener("abort", dispose);
794
888
  let failed = false;
795
889
  let failure;
890
+ try {
891
+ publish?.();
892
+ } catch (error) {
893
+ failed = true;
894
+ failure = error;
895
+ }
796
896
  for (const connection of signalConnections?.values() ?? []) {
797
897
  try {
798
- connection.dispose();
898
+ connection.dispose(preservePresentation);
799
899
  } catch (error) {
800
900
  if (!failed) {
801
901
  failed = true;
@@ -864,6 +964,7 @@ function __adoptScalarBindings(root, descriptor, source, options) {
864
964
  if (!connection && signalFactory.isSignal(values[index])) {
865
965
  connection = signalFactory.connect(() => {
866
966
  if (!disposed) {
967
+ if (view) view.revision++;
867
968
  signalUpdates.add(index);
868
969
  drain();
869
970
  }
@@ -903,6 +1004,7 @@ function __adoptScalarBindings(root, descriptor, source, options) {
903
1004
  throw error;
904
1005
  } finally {
905
1006
  busy = false;
1007
+ view?.published();
906
1008
  }
907
1009
  };
908
1010
  const resume = () => {
@@ -911,10 +1013,19 @@ function __adoptScalarBindings(root, descriptor, source, options) {
911
1013
  };
912
1014
  const refresh = () => {
913
1015
  if (disposed) return;
1016
+ if (view) view.revision++;
914
1017
  dirty = true;
915
1018
  drain();
916
1019
  };
917
1020
  const handle = { refresh, dispose };
1021
+ const view = prepareView?.(root, descriptor, nodes, selectedWriter, {
1022
+ handle,
1023
+ active: () => !disposed,
1024
+ busy: () => busy,
1025
+ retire: (publish) => dispose(void 0, publish, true)
1026
+ });
1027
+ const writeChannel = view?.write ?? selectedWriter;
1028
+ const signal = options?.signal;
918
1029
  if (signal?.aborted) {
919
1030
  dispose();
920
1031
  return handle;
@@ -945,14 +1056,18 @@ function __adoptScalarBindings(root, descriptor, source, options) {
945
1056
  // Annotate the CommonJS export names for ESM import in node:
946
1057
  0 && (module.exports = {
947
1058
  __adoptBindings,
1059
+ __adoptFixedScalarViewBindings,
1060
+ __adoptFixedViewBindings,
948
1061
  __adoptScalarBindings,
949
1062
  __bindingURL,
950
1063
  __claimBinding,
951
1064
  __createBindingStyleRestoration,
1065
+ __isBindingTextLeaf,
952
1066
  __mountBindings,
953
1067
  __normalizeBinding,
954
1068
  __releaseBinding,
955
1069
  __writeBinding,
1070
+ __writeBindingWithTextWitness,
956
1071
  adoptBindings,
957
1072
  mountBindings,
958
1073
  unbound
@@ -39,7 +39,7 @@ function moveNativeNodeBefore(parent, node, anchor, focused, contentEditable) {
39
39
  return;
40
40
  }
41
41
  const moveBefore = parent.moveBefore;
42
- if (!contentEditable && typeof moveBefore === "function") {
42
+ if (!contentEditable && typeof moveBefore === "function" && parent.isConnected && node.isConnected && parent.ownerDocument === node.ownerDocument) {
43
43
  moveBefore.call(parent, node, anchor);
44
44
  return;
45
45
  }
@@ -18,14 +18,20 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var hydration_flag_exports = {};
20
20
  __export(hydration_flag_exports, {
21
+ changePendingInitialHydrations: () => changePendingInitialHydrations,
21
22
  hydrating: () => hydrating,
22
23
  hydrationStarted: () => hydrationStarted,
24
+ pendingInitialHydrations: () => pendingInitialHydrations,
23
25
  setHydrating: () => setHydrating,
24
26
  startHydration: () => startHydration
25
27
  });
26
28
  module.exports = __toCommonJS(hydration_flag_exports);
27
29
  let hydrating = false;
28
30
  let hydrationStarted = false;
31
+ let pendingInitialHydrations = 0;
32
+ function changePendingInitialHydrations(delta) {
33
+ pendingInitialHydrations += delta;
34
+ }
29
35
  function setHydrating(value) {
30
36
  hydrating = value;
31
37
  if (value) hydrationStarted = true;
@@ -35,8 +41,10 @@ function startHydration() {
35
41
  }
36
42
  // Annotate the CommonJS export names for ESM import in node:
37
43
  0 && (module.exports = {
44
+ changePendingInitialHydrations,
38
45
  hydrating,
39
46
  hydrationStarted,
47
+ pendingInitialHydrations,
40
48
  setHydrating,
41
49
  startHydration
42
50
  });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var hydration_input_control_exports = {};
20
+ __export(hydration_input_control_exports, {
21
+ INITIAL_ADOPTION_INPUT_CHANGED: () => INITIAL_ADOPTION_INPUT_CHANGED
22
+ });
23
+ module.exports = __toCommonJS(hydration_input_control_exports);
24
+ var import_read_protocol = require("./signals/read-protocol.cjs");
25
+ const INITIAL_ADOPTION_INPUT_CHANGED = /* @__PURE__ */ Object.freeze(
26
+ /* @__PURE__ */ Object.create(null, { [import_read_protocol.ADOPTION_CONTROL]: { value: true } })
27
+ );
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ INITIAL_ADOPTION_INPUT_CHANGED
31
+ });
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var hydration_inputs_exports = {};
20
+ __export(hydration_inputs_exports, {
21
+ __captureHydrationInput: () => __captureHydrationInput,
22
+ __hydrationComponentSlot: () => __hydrationComponentSlot,
23
+ __observeHydrationOptionalInput: () => __observeHydrationOptionalInput,
24
+ __ownedHydrationInputs: () => __ownedHydrationInputs,
25
+ __registerHydrationInputComponent: () => __registerHydrationInputComponent,
26
+ __sameHydrationInput: () => __sameHydrationInput,
27
+ __sameHydrationOptionalInput: () => __sameHydrationOptionalInput,
28
+ __sameHydrationSource: () => __sameHydrationSource
29
+ });
30
+ module.exports = __toCommonJS(hydration_inputs_exports);
31
+ var import_has_own = require("./has-own.cjs");
32
+ var import_hydration_flag = require("./hydration-flag.cjs");
33
+ var import_method_dep = require("./method-dep.cjs");
34
+ var import_hydration_input_control = require("./hydration-input-control.cjs");
35
+ let hydrationInputTuples;
36
+ let hydrationInputComponents;
37
+ let currentHydrationProps = null;
38
+ let currentHydrationPlan = null;
39
+ const UNSAFE_OPTIONAL_INPUT = /* @__PURE__ */ Symbol();
40
+ const ABSENT_OPTIONAL_INPUT = /* @__PURE__ */ Symbol();
41
+ let optionalInputObservations;
42
+ function __registerHydrationInputComponent(component, required) {
43
+ (hydrationInputComponents ??= /* @__PURE__ */ new WeakMap()).set(component, required);
44
+ return component;
45
+ }
46
+ function __hydrationComponentSlot(writer, scope, slot, parent, component, props, site, anchor, localPlan) {
47
+ let plan = localPlan;
48
+ if (import_hydration_flag.hydrating || import_hydration_flag.pendingInitialHydrations > 0) {
49
+ if (plan === void 0) {
50
+ plan = hydrationInputComponents?.get(component);
51
+ if (plan !== void 0) {
52
+ for (let index = 1; index < plan.length; index++) {
53
+ const descriptor = Object.getOwnPropertyDescriptor(props, plan[index]);
54
+ if (!descriptor || !import_has_own.hasOwnProp.call(descriptor, "value")) {
55
+ plan = void 0;
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ if (plan !== void 0) {
62
+ const previousProps = currentHydrationProps;
63
+ const previousPlan = currentHydrationPlan;
64
+ currentHydrationProps = props;
65
+ currentHydrationPlan = plan;
66
+ try {
67
+ return writer(scope, slot, parent, component, props, site, anchor);
68
+ } finally {
69
+ currentHydrationProps = previousProps;
70
+ currentHydrationPlan = previousPlan;
71
+ }
72
+ }
73
+ }
74
+ writer(scope, slot, parent, component, props, site, anchor);
75
+ }
76
+ function __captureHydrationInput(env, propsIndex, plan, closed = false, source) {
77
+ const props = env[propsIndex];
78
+ if (!closed) {
79
+ if (currentHydrationProps !== props || currentHydrationPlan !== plan) return env;
80
+ currentHydrationProps = null;
81
+ currentHydrationPlan = null;
82
+ }
83
+ if (!import_hydration_flag.hydrating && import_hydration_flag.pendingInitialHydrations === 0) return env;
84
+ for (let index = 1; index <= plan[0]; index++) {
85
+ const descriptor = Object.getOwnPropertyDescriptor(props, plan[index]);
86
+ if (!descriptor || !import_has_own.hasOwnProp.call(descriptor, "value") || !isHydrationArrow(descriptor.value))
87
+ return env;
88
+ }
89
+ let witness = null;
90
+ if (source !== void 0) {
91
+ try {
92
+ witness = source() ?? null;
93
+ } catch {
94
+ return env;
95
+ }
96
+ if (witness === null) return env;
97
+ }
98
+ (hydrationInputTuples ??= /* @__PURE__ */ new WeakMap()).set(env, witness);
99
+ return env;
100
+ }
101
+ function __ownedHydrationInputs(previous, next, source = false) {
102
+ const tuples = hydrationInputTuples;
103
+ if (tuples === void 0) return false;
104
+ if (!source) return tuples.has(previous) && tuples.has(next);
105
+ const left = tuples.get(previous);
106
+ const right = tuples.get(next);
107
+ return left != null && right != null && left[0] === right[0] && left[1] === right[1];
108
+ }
109
+ function __sameHydrationSource(previous, source) {
110
+ const left = hydrationInputTuples?.get(previous);
111
+ if (left == null) return false;
112
+ try {
113
+ const right = source();
114
+ return right !== void 0 && left[0] === right[0] && left[1] === right[1];
115
+ } catch {
116
+ return false;
117
+ }
118
+ }
119
+ function __sameHydrationInput(previous, next, name, method = false) {
120
+ const left = Object.getOwnPropertyDescriptor(previous, name);
121
+ const right = Object.getOwnPropertyDescriptor(next, name);
122
+ if (!left || !right || !import_has_own.hasOwnProp.call(left, "value") || !import_has_own.hasOwnProp.call(right, "value") || !Object.is(left.value, right.value))
123
+ return false;
124
+ return !method || isHydrationArrow(left.value);
125
+ }
126
+ function optionalInputValue(props, name) {
127
+ const descriptor = Object.getOwnPropertyDescriptor(props, name);
128
+ if (descriptor !== void 0) {
129
+ if (!import_has_own.hasOwnProp.call(descriptor, "value")) return UNSAFE_OPTIONAL_INPUT;
130
+ const value = descriptor.value;
131
+ return value == null || isHydrationArrow(value) ? value : UNSAFE_OPTIONAL_INPUT;
132
+ }
133
+ const prototype = Object.getPrototypeOf(props);
134
+ return prototype === null || prototype === Object.prototype && Object.getOwnPropertyDescriptor(prototype, name) === void 0 ? ABSENT_OPTIONAL_INPUT : UNSAFE_OPTIONAL_INPUT;
135
+ }
136
+ function __observeHydrationOptionalInput(env, props, name) {
137
+ if (!import_hydration_flag.hydrating) return;
138
+ const observation = optionalInputObservations?.get(env);
139
+ if (observation?.armed) {
140
+ observation.armed = false;
141
+ if (observation.props !== props || observation.name !== name || !Object.is(observation.value, optionalInputValue(props, name))) {
142
+ optionalInputObservations.delete(env);
143
+ throw import_hydration_input_control.INITIAL_ADOPTION_INPUT_CHANGED;
144
+ }
145
+ return;
146
+ }
147
+ if (!hydrationInputTuples?.has(env) && (observation?.props !== props || observation.name !== name)) {
148
+ if (observation !== void 0) optionalInputObservations.delete(env);
149
+ return;
150
+ }
151
+ const value = optionalInputValue(props, name);
152
+ if (value !== UNSAFE_OPTIONAL_INPUT)
153
+ (optionalInputObservations ??= /* @__PURE__ */ new WeakMap()).set(env, { props, name, value, armed: false });
154
+ else if (observation !== void 0) optionalInputObservations.delete(env);
155
+ }
156
+ function __sameHydrationOptionalInput(previous, next, props, name) {
157
+ const observation = optionalInputObservations?.get(previous);
158
+ if (!observation || observation.armed || observation.name !== name || observation.props !== props && !hydrationInputTuples?.has(next))
159
+ return false;
160
+ const value = optionalInputValue(props, name);
161
+ if (value === UNSAFE_OPTIONAL_INPUT || !Object.is(observation.value, value)) return false;
162
+ optionalInputObservations.set(next, { props, name, value, armed: true });
163
+ return true;
164
+ }
165
+ function isHydrationArrow(value) {
166
+ if (typeof value !== "function") return false;
167
+ try {
168
+ const source = Function.prototype.toString.call(value);
169
+ return import_method_dep.ARROW_HEAD.test(source) && (source[0] === "(" || !/^async\b/.test(source));
170
+ } catch {
171
+ return false;
172
+ }
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ __captureHydrationInput,
177
+ __hydrationComponentSlot,
178
+ __observeHydrationOptionalInput,
179
+ __ownedHydrationInputs,
180
+ __registerHydrationInputComponent,
181
+ __sameHydrationInput,
182
+ __sameHydrationOptionalInput,
183
+ __sameHydrationSource
184
+ });
@@ -19,18 +19,35 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var client_exports = {};
21
21
  __export(client_exports, {
22
+ __captureHydrationInput: () => import_hydration_inputs.__captureHydrationInput,
23
+ __hydrationComponentSlot: () => import_hydration_inputs.__hydrationComponentSlot,
24
+ __observeHydrationOptionalInput: () => import_hydration_inputs.__observeHydrationOptionalInput,
25
+ __ownedHydrationInputs: () => import_hydration_inputs.__ownedHydrationInputs,
26
+ __registerHydrationInputComponent: () => import_hydration_inputs.__registerHydrationInputComponent,
22
27
  __s: () => import_runtime.markSingleRoot,
28
+ __sameHydrationInput: () => import_hydration_inputs.__sameHydrationInput,
29
+ __sameHydrationOptionalInput: () => import_hydration_inputs.__sameHydrationOptionalInput,
30
+ __sameHydrationSource: () => import_hydration_inputs.__sameHydrationSource,
23
31
  isContext: () => import_context_identity.isContext,
24
32
  signalOwnerUse: () => import_owner_context.signalOwnerUse
25
33
  });
26
34
  module.exports = __toCommonJS(client_exports);
27
35
  __reExport(client_exports, require("../runtime.cjs"), module.exports);
28
36
  var import_context_identity = require("../context-identity.cjs");
37
+ var import_hydration_inputs = require("../hydration-inputs.cjs");
29
38
  var import_runtime = require("../runtime.cjs");
30
39
  var import_owner_context = require("../signals/owner-context.cjs");
31
40
  // Annotate the CommonJS export names for ESM import in node:
32
41
  0 && (module.exports = {
42
+ __captureHydrationInput,
43
+ __hydrationComponentSlot,
44
+ __observeHydrationOptionalInput,
45
+ __ownedHydrationInputs,
46
+ __registerHydrationInputComponent,
33
47
  __s,
48
+ __sameHydrationInput,
49
+ __sameHydrationOptionalInput,
50
+ __sameHydrationSource,
34
51
  isContext,
35
52
  signalOwnerUse,
36
53
  ...require("../runtime.cjs")
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var method_dep_exports = {};
20
20
  __export(method_dep_exports, {
21
+ ARROW_HEAD: () => ARROW_HEAD,
21
22
  __methodDep: () => __methodDep
22
23
  });
23
24
  module.exports = __toCommonJS(method_dep_exports);
@@ -60,5 +61,6 @@ function ownMethodDep(receiver, method) {
60
61
  }
61
62
  // Annotate the CommonJS export names for ESM import in node:
62
63
  0 && (module.exports = {
64
+ ARROW_HEAD,
63
65
  __methodDep
64
66
  });
@@ -589,7 +589,7 @@ function unmountBlockInner(block, detachDom) {
589
589
  function registerSlot(scope, slot) {
590
590
  const slots = scope._slots;
591
591
  const transaction = import_render.ROOT_RENDER_TRANSACTION;
592
- if (transaction !== null && scope.mounted && !(0, import_engine.isCreatedInRootRender)(transaction, scope.block)) {
592
+ if (transaction !== null && !(0, import_engine.isCreatedInRootRender)(transaction, (0, import_branches.owningBlock)(scope.block))) {
593
593
  (0, import_engine.journalUndo)(() => {
594
594
  unmountSlot(slot, true);
595
595
  const index = scope.slots.indexOf(slot);