octane 0.2.13 → 0.2.14

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.
@@ -33,7 +33,7 @@ __export(constants_exports, {
33
33
  HYDRATE_SEED_ATTR: () => HYDRATE_SEED_ATTR,
34
34
  HYDRATE_STATIC_END: () => HYDRATE_STATIC_END,
35
35
  HYDRATE_STATIC_ID_COUNT_PREFIX: () => HYDRATE_STATIC_ID_COUNT_PREFIX,
36
- HYDRATE_STREAM_TOKEN_ATTR: () => import_stream_protocol.HYDRATE_STREAM_TOKEN_ATTR,
36
+ HYDRATE_STREAM_TOKEN_ATTR: () => import_stream_protocol2.HYDRATE_STREAM_TOKEN_ATTR,
37
37
  HYDRATE_WHEN_ATTR: () => HYDRATE_WHEN_ATTR,
38
38
  HYDRATION_END: () => HYDRATION_END,
39
39
  HYDRATION_FOR_EMPTY: () => HYDRATION_FOR_EMPTY,
@@ -46,16 +46,16 @@ __export(constants_exports, {
46
46
  POSITIVE_NUMERIC_ATTR_PROPS: () => POSITIVE_NUMERIC_ATTR_PROPS,
47
47
  REJECTION_SENTINEL_KEY: () => REJECTION_SENTINEL_KEY,
48
48
  SIGNAL_CONTROL_ATTR: () => import_hydration_markers.SIGNAL_CONTROL_ATTR,
49
- STREAM_BOUNDARY_ATTR: () => import_stream_protocol2.STREAM_BOUNDARY_ATTR,
49
+ STREAM_BOUNDARY_ATTR: () => import_stream_protocol3.STREAM_BOUNDARY_ATTR,
50
50
  STREAM_RESOURCE_ATTR: () => STREAM_RESOURCE_ATTR,
51
- STREAM_SCRIPT_ATTR: () => STREAM_SCRIPT_ATTR,
51
+ STREAM_SCRIPT_ATTR: () => import_stream_protocol4.STREAM_SCRIPT_ATTR,
52
52
  STREAM_SEED_ATTR: () => STREAM_SEED_ATTR,
53
53
  STREAM_SEED_COMMENT: () => STREAM_SEED_COMMENT,
54
54
  STREAM_SEGMENT_ATTR: () => STREAM_SEGMENT_ATTR,
55
55
  SUSPENSE_RESOLVED_COMMENT: () => SUSPENSE_RESOLVED_COMMENT,
56
56
  SUSPENSE_RESOLVED_NATIVE_ATTR: () => SUSPENSE_RESOLVED_NATIVE_ATTR,
57
57
  SUSPENSE_RESOLVED_SEED_ATTR: () => SUSPENSE_RESOLVED_SEED_ATTR,
58
- SUSPENSE_SCRIPT_ATTR: () => SUSPENSE_SCRIPT_ATTR,
58
+ SUSPENSE_SCRIPT_ATTR: () => import_stream_protocol.SUSPENSE_SCRIPT_ATTR,
59
59
  SUSPENSE_SEED_WIRE_PREFIX: () => SUSPENSE_SEED_WIRE_PREFIX,
60
60
  SVG_ONLY_TAGS: () => SVG_ONLY_TAGS,
61
61
  UNDEFINED_SENTINEL_KEY: () => UNDEFINED_SENTINEL_KEY,
@@ -67,8 +67,10 @@ __export(constants_exports, {
67
67
  });
68
68
  module.exports = __toCommonJS(constants_exports);
69
69
  var import_stream_protocol = require("./stream-protocol.cjs");
70
- var import_hydration_markers = require("./hydration-markers.cjs");
71
70
  var import_stream_protocol2 = require("./stream-protocol.cjs");
71
+ var import_hydration_markers = require("./hydration-markers.cjs");
72
+ var import_stream_protocol3 = require("./stream-protocol.cjs");
73
+ var import_stream_protocol4 = require("./stream-protocol.cjs");
72
74
  var import_dom_tables = require("./dom-tables.cjs");
73
75
  const HYDRATION_START = "[";
74
76
  const HYDRATION_END = "]";
@@ -80,7 +82,6 @@ const FOR_BLOCK_OPEN_EMPTY = `<!--${HYDRATION_FOR_EMPTY}-->`;
80
82
  const FOR_BLOCK_OPEN_ITEMS = `<!--${HYDRATION_FOR_ITEMS}-->`;
81
83
  const EMPTY_COMMENT = "<!---->";
82
84
  const HYDRATION_TEXT_SEP = " ";
83
- const SUSPENSE_SCRIPT_ATTR = "data-octane-suspense";
84
85
  const SUSPENSE_RESOLVED_COMMENT = "oct-suspense:";
85
86
  const SUSPENSE_RESOLVED_SEED_ATTR = "data-octane-suspense-seeds";
86
87
  const SUSPENSE_RESOLVED_NATIVE_ATTR = "data-octane-suspense-signals";
@@ -101,7 +102,6 @@ const HYDRATE_ID_COUNT_ATTR = "data-octane-hydrate-id-count";
101
102
  const HYDRATE_SEED_ATTR = "data-octane-hydrate-seed";
102
103
  const STREAM_SEGMENT_ATTR = "data-oct-s";
103
104
  const STREAM_SEED_ATTR = "data-oct-seed";
104
- const STREAM_SCRIPT_ATTR = "data-octane-stream";
105
105
  const STREAM_RESOURCE_ATTR = "data-oct-fr";
106
106
  const STREAM_SEED_COMMENT = "oct-seed:";
107
107
  const VOID_ELEMENTS = import_dom_tables.VOID_ELEMENTS;
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var dom_binding_handoff_exports = {};
20
20
  __export(dom_binding_handoff_exports, {
21
- BINDING_HANDOFF: () => BINDING_HANDOFF,
21
+ BINDING_HANDOFF: () => import_control_handoff.BINDING_HANDOFF,
22
22
  beginBindingEvent: () => beginBindingEvent,
23
23
  claimBindingHandoff: () => claimBindingHandoff,
24
24
  consumeBindingEvent: () => consumeBindingEvent,
@@ -28,7 +28,7 @@ __export(dom_binding_handoff_exports, {
28
28
  releaseBindingHandoff: () => releaseBindingHandoff
29
29
  });
30
30
  module.exports = __toCommonJS(dom_binding_handoff_exports);
31
- const BINDING_HANDOFF = /* @__PURE__ */ Symbol.for("octane.binding-handoff");
31
+ var import_control_handoff = require("./signals/control-handoff.cjs");
32
32
  const events = /* @__PURE__ */ new WeakMap();
33
33
  const delivered = /* @__PURE__ */ new WeakMap();
34
34
  function registerBindingEvent(node, type) {
@@ -32,6 +32,9 @@ __export(dom_bindings_exports, {
32
32
  module.exports = __toCommonJS(dom_bindings_exports);
33
33
  var import_class_names = require("./class-names.cjs");
34
34
  var import_sanitize_url = require("./sanitize-url.cjs");
35
+ var import_stream_protocol = require("./stream-protocol.cjs");
36
+ var import_native_read_seeds = require("./signals/native-read-seeds.cjs");
37
+ var import_control_handoff = require("./signals/control-handoff.cjs");
35
38
  var import_owner_context = require("./signals/owner-context.cjs");
36
39
  var import_read_protocol = require("./signals/read-protocol.cjs");
37
40
  function unbound(value) {
@@ -283,16 +286,28 @@ function __adoptBindings(root, descriptor, source, options) {
283
286
  let dirty = false;
284
287
  let revision = 0;
285
288
  let unsubscribe;
289
+ let publicationRetries;
290
+ let published;
286
291
  const signal = options?.signal;
287
- const dispose = () => {
288
- if (disposed) return;
292
+ const dispose = (_disposal, publish, preservePresentation = false) => {
293
+ if (disposed) {
294
+ publish?.();
295
+ return;
296
+ }
289
297
  disposed = true;
298
+ publicationRetries?.clear();
290
299
  signal?.removeEventListener("abort", dispose);
291
300
  let failed = false;
292
301
  let failure;
302
+ try {
303
+ publish?.();
304
+ } catch (error) {
305
+ failed = true;
306
+ failure = error;
307
+ }
293
308
  for (const connection of signalConnections?.values() ?? []) {
294
309
  try {
295
- connection.dispose();
310
+ connection.dispose(preservePresentation);
296
311
  } catch (error) {
297
312
  if (!failed) {
298
313
  failed = true;
@@ -302,7 +317,7 @@ function __adoptBindings(root, descriptor, source, options) {
302
317
  }
303
318
  for (const connection of projections ? new Set(projections.values()) : []) {
304
319
  try {
305
- connection.dispose();
320
+ connection.dispose(preservePresentation);
306
321
  } catch (error) {
307
322
  if (!failed) {
308
323
  failed = true;
@@ -327,9 +342,9 @@ function __adoptBindings(root, descriptor, source, options) {
327
342
  for (let i = 0; i < owned.length; i++) {
328
343
  const [node, name] = owned[i];
329
344
  try {
330
- groups?.get(i)?.dispose();
331
- styles?.get(i)?.dispose();
332
- if (bindings[i][1] === "classToken" && previous[i] === "")
345
+ groups?.get(i)?.dispose(preservePresentation);
346
+ styles?.get(i)?.dispose(preservePresentation);
347
+ if (!preservePresentation && bindings[i][1] === "classToken" && previous[i] === "")
333
348
  node.classList.remove(bindings[i][2]);
334
349
  } catch (error) {
335
350
  if (!failed) {
@@ -600,6 +615,7 @@ function __adoptBindings(root, descriptor, source, options) {
600
615
  writePrepared(next, indices, preparedControls, preparedGroups);
601
616
  } finally {
602
617
  busy = false;
618
+ published?.();
603
619
  }
604
620
  }
605
621
  };
@@ -622,6 +638,7 @@ function __adoptBindings(root, descriptor, source, options) {
622
638
  for (const index of previousUpdates ?? []) signalUpdates.add(index);
623
639
  }
624
640
  busy = false;
641
+ if (!preview) published?.();
625
642
  }
626
643
  };
627
644
  const refresh = () => {
@@ -637,6 +654,52 @@ function __adoptBindings(root, descriptor, source, options) {
637
654
  prepare: () => run(() => drain(true))
638
655
  };
639
656
  const handle = { refresh, dispose };
657
+ if (descriptor.handoff === "host") {
658
+ published = () => {
659
+ if (!publicationRetries?.size) return;
660
+ const pending = [...publicationRetries];
661
+ publicationRetries.clear();
662
+ for (const retry of pending)
663
+ queueMicrotask(() => {
664
+ if (!disposed) retry();
665
+ });
666
+ };
667
+ const host = root;
668
+ const document = host.ownerDocument;
669
+ const ancestry = [];
670
+ for (let node = host; node !== null; node = node.parentNode)
671
+ ancestry.push([node, node.parentNode]);
672
+ const sibling = (node, previous2) => {
673
+ let next = previous2 ? node.previousSibling : node.nextSibling;
674
+ 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)))
675
+ next = previous2 ? next.previousSibling : next.nextSibling;
676
+ return next;
677
+ };
678
+ const previousSibling = sibling(host, true);
679
+ const nextSibling = sibling(host, false);
680
+ let handoff;
681
+ handle[import_control_handoff.BINDING_HANDOFF] = () => {
682
+ if (handoff !== void 0) return handoff;
683
+ return handoff = {
684
+ id: descriptor.id,
685
+ root: host,
686
+ anchor: host,
687
+ host: new Set(
688
+ bindings.map(
689
+ (binding) => binding[1] === "styleProperty" ? "style:" + binding[2] : binding[1].startsWith("style") ? "style" : binding[2]
690
+ )
691
+ ),
692
+ revision: () => busy ? -1 : revision,
693
+ afterPublication: (callback) => {
694
+ (publicationRetries ??= /* @__PURE__ */ new Set()).add(callback);
695
+ return () => publicationRetries.delete(callback);
696
+ },
697
+ valid: () => host.parentNode !== null && host.ownerDocument === document && ancestry.every(([node, parent]) => node.parentNode === parent) && sibling(host, true) === previousSibling && sibling(host, false) === nextSibling && host.getAttribute("data-octane-bindings") === descriptor.id,
698
+ active: () => !disposed,
699
+ retire: (publish) => dispose(void 0, publish, true)
700
+ };
701
+ };
702
+ }
640
703
  if (signal?.aborted) {
641
704
  dispose();
642
705
  return handle;