octane 0.6.1 → 0.6.3

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 (201) hide show
  1. package/dist/cjs/dom-binding-handoff.cjs +28 -13
  2. package/dist/cjs/dom-binding-protocol.cjs +43 -22
  3. package/dist/cjs/dom-binding-styles.cjs +71 -56
  4. package/dist/cjs/dom-bindings.cjs +312 -222
  5. package/dist/cjs/error-codes.client.generated.cjs +2 -1
  6. package/dist/cjs/error-codes.server.generated.cjs +2 -1
  7. package/dist/cjs/hydration/event-capture.cjs +82 -45
  8. package/dist/cjs/independent-hydration-protocol.cjs +20 -10
  9. package/dist/cjs/runtime.cjs +169 -155
  10. package/dist/cjs/runtime.server.cjs +40 -34
  11. package/dist/cjs/signals/control-binding.cjs +123 -96
  12. package/dist/cjs/signals/derived-facade.cjs +10 -11
  13. package/dist/cjs/signals/document-owner.cjs +14 -9
  14. package/dist/cjs/signals/facade.cjs +93 -82
  15. package/dist/cjs/signals/graph.cjs +140 -79
  16. package/dist/cjs/signals/native-read-client.cjs +79 -38
  17. package/dist/cjs/signals/owner-context.cjs +21 -10
  18. package/dist/cjs/signals/query-attempt-observer.cjs +10 -10
  19. package/dist/cjs/signals/query-facade.cjs +9 -16
  20. package/dist/cjs/signals/scalar-computations.cjs +7 -3
  21. package/dist/cjs/signals/transition-action.cjs +189 -117
  22. package/dist/cjs/signals/transition-candidate.cjs +30 -17
  23. package/dist/cjs/version.cjs +1 -1
  24. package/dist/compiler/compile.js +380 -12
  25. package/dist/dom-binding-classes.js +47 -24
  26. package/dist/dom-binding-handoff.js +27 -13
  27. package/dist/dom-binding-program.js +363 -380
  28. package/dist/dom-binding-projections.js +61 -43
  29. package/dist/dom-binding-protocol.js +43 -29
  30. package/dist/dom-binding-signals.js +39 -38
  31. package/dist/dom-binding-styles.js +71 -63
  32. package/dist/dom-bindings.js +312 -226
  33. package/dist/hydration/document-lifecycle.js +14 -7
  34. package/dist/hydration/event-capture.js +85 -68
  35. package/dist/hydration/independent-island.js +156 -151
  36. package/dist/hydration/stream-delivery.js +83 -65
  37. package/dist/hydration/stream-result-receiver.js +60 -42
  38. package/dist/hydration/streamed-signals.js +52 -55
  39. package/dist/independent-hydration-protocol.js +19 -10
  40. package/dist/node/aria-diagnostics.js +92 -0
  41. package/dist/node/behavior-form-submissions.js +228 -0
  42. package/dist/node/behavior-root-types.js +0 -0
  43. package/dist/node/behavior-root.js +746 -0
  44. package/dist/node/class-names.js +25 -0
  45. package/dist/node/compatibility.js +10 -0
  46. package/dist/node/component-flags.js +23 -0
  47. package/dist/node/constants.js +113 -0
  48. package/dist/node/context-epoch.js +13 -0
  49. package/dist/node/context-identity.js +46 -0
  50. package/dist/node/css.js +80 -0
  51. package/dist/node/data-encoding.js +134 -0
  52. package/dist/node/devtools-hook.js +229 -0
  53. package/dist/node/dom-binding-claims.js +4 -0
  54. package/dist/node/dom-binding-classes.js +152 -0
  55. package/dist/node/dom-binding-controls.js +6 -0
  56. package/dist/node/dom-binding-handoff.js +77 -0
  57. package/dist/node/dom-binding-program.js +1617 -0
  58. package/dist/node/dom-binding-projections.js +204 -0
  59. package/dist/node/dom-binding-protocol.js +130 -0
  60. package/dist/node/dom-binding-signals.js +135 -0
  61. package/dist/node/dom-binding-styles.js +280 -0
  62. package/dist/node/dom-bindings.js +1087 -0
  63. package/dist/node/dom-focused-move.js +46 -0
  64. package/dist/node/dom-stage.js +878 -0
  65. package/dist/node/dom-tables.js +382 -0
  66. package/dist/node/error-codes.client.generated.js +1066 -0
  67. package/dist/node/error-codes.server.generated.js +736 -0
  68. package/dist/node/error-message.js +27 -0
  69. package/dist/node/event-names.js +15 -0
  70. package/dist/node/form-diagnostics.js +96 -0
  71. package/dist/node/form-submission.js +43 -0
  72. package/dist/node/has-own.js +4 -0
  73. package/dist/node/head-ownership.js +31 -0
  74. package/dist/node/hook-slot-cache.js +91 -0
  75. package/dist/node/host-property-diagnostics.js +189 -0
  76. package/dist/node/html-tree-validation.js +193 -0
  77. package/dist/node/hydration/condition.js +15 -0
  78. package/dist/node/hydration/control-capture.js +237 -0
  79. package/dist/node/hydration/document-lifecycle.js +89 -0
  80. package/dist/node/hydration/event-capture.js +362 -0
  81. package/dist/node/hydration/idle.js +23 -0
  82. package/dist/node/hydration/independent-island.js +317 -0
  83. package/dist/node/hydration/index.js +74 -0
  84. package/dist/node/hydration/interaction-config.js +61 -0
  85. package/dist/node/hydration/interaction.js +35 -0
  86. package/dist/node/hydration/load.js +15 -0
  87. package/dist/node/hydration/media.js +33 -0
  88. package/dist/node/hydration/native-intent.js +68 -0
  89. package/dist/node/hydration/never.js +12 -0
  90. package/dist/node/hydration/stream-delivery.js +345 -0
  91. package/dist/node/hydration/stream-receiver.js +190 -0
  92. package/dist/node/hydration/stream-result-receiver.js +276 -0
  93. package/dist/node/hydration/streamed-signals.js +186 -0
  94. package/dist/node/hydration/types.js +0 -0
  95. package/dist/node/hydration/visible.js +69 -0
  96. package/dist/node/hydration-markers.js +44 -0
  97. package/dist/node/independent-hydration-protocol.js +91 -0
  98. package/dist/node/index.js +461 -0
  99. package/dist/node/internal/client.js +7 -0
  100. package/dist/node/internal/context.js +5 -0
  101. package/dist/node/internal/server.js +5 -0
  102. package/dist/node/internal/signal-read.js +4 -0
  103. package/dist/node/method-dep.js +25 -0
  104. package/dist/node/profiling.js +432 -0
  105. package/dist/node/public-types.js +0 -0
  106. package/dist/node/react/fiber-adapter.js +57 -0
  107. package/dist/node/react/index.js +397 -0
  108. package/dist/node/react/react-compat-envelope.js +78 -0
  109. package/dist/node/react/react-compat-server.js +129 -0
  110. package/dist/node/react/react-compat-shared.js +104 -0
  111. package/dist/node/react/react-compat.js +223 -0
  112. package/dist/node/react/server.js +81 -0
  113. package/dist/node/react/shared.js +75 -0
  114. package/dist/node/renderer-bridge.js +35 -0
  115. package/dist/node/resize-observer.js +105 -0
  116. package/dist/node/resource-hint-diagnostics.js +67 -0
  117. package/dist/node/runtime-tags.js +22 -0
  118. package/dist/node/runtime.js +28881 -0
  119. package/dist/node/runtime.server.js +8016 -0
  120. package/dist/node/sanitize-url.js +34 -0
  121. package/dist/node/server/early-signals.js +54 -0
  122. package/dist/node/server/index.js +336 -0
  123. package/dist/node/server/rpc-batch.js +129 -0
  124. package/dist/node/server/rpc-stream.js +125 -0
  125. package/dist/node/server/rpc.js +48 -0
  126. package/dist/node/server/signal-query-observation.js +134 -0
  127. package/dist/node/server/streamed-region.js +31 -0
  128. package/dist/node/server/streamed-signals.js +557 -0
  129. package/dist/node/server-call.js +75 -0
  130. package/dist/node/server-rpc-batch-client.js +119 -0
  131. package/dist/node/server-rpc-client.js +108 -0
  132. package/dist/node/server-rpc-protocol.js +109 -0
  133. package/dist/node/server-rpc-stream-client.js +98 -0
  134. package/dist/node/shared-value-helpers.js +40 -0
  135. package/dist/node/signals/actions.js +463 -0
  136. package/dist/node/signals/client.js +22 -0
  137. package/dist/node/signals/computations.js +452 -0
  138. package/dist/node/signals/control-binding.js +388 -0
  139. package/dist/node/signals/control-handoff.js +12 -0
  140. package/dist/node/signals/derived-facade.js +25 -0
  141. package/dist/node/signals/document-owner.js +48 -0
  142. package/dist/node/signals/early-values.js +124 -0
  143. package/dist/node/signals/encoding.js +6 -0
  144. package/dist/node/signals/engine.js +668 -0
  145. package/dist/node/signals/errors.js +54 -0
  146. package/dist/node/signals/facade.js +441 -0
  147. package/dist/node/signals/graph.js +817 -0
  148. package/dist/node/signals/handle-protocol.js +11 -0
  149. package/dist/node/signals/index.js +87 -0
  150. package/dist/node/signals/native-read-client.js +319 -0
  151. package/dist/node/signals/native-read-collector.js +132 -0
  152. package/dist/node/signals/native-read-events.js +45 -0
  153. package/dist/node/signals/native-read-inspection.js +20 -0
  154. package/dist/node/signals/native-read-retry.js +30 -0
  155. package/dist/node/signals/native-read-seeds.js +243 -0
  156. package/dist/node/signals/native-read-server.js +99 -0
  157. package/dist/node/signals/owner-context.js +88 -0
  158. package/dist/node/signals/query-attempt-observer.js +42 -0
  159. package/dist/node/signals/query-facade.js +41 -0
  160. package/dist/node/signals/read-protocol.js +125 -0
  161. package/dist/node/signals/requests.js +716 -0
  162. package/dist/node/signals/scalar-computations.js +57 -0
  163. package/dist/node/signals/scope-streams.js +147 -0
  164. package/dist/node/signals/server.js +22 -0
  165. package/dist/node/signals/transition-action.js +555 -0
  166. package/dist/node/signals/transition-candidate.js +101 -0
  167. package/dist/node/signals/transition-coordinator.js +255 -0
  168. package/dist/node/signals/transition-state.js +82 -0
  169. package/dist/node/signals/types.js +20 -0
  170. package/dist/node/static/index.js +10 -0
  171. package/dist/node/stream-protocol.js +114 -0
  172. package/dist/node/streamed-signals-protocol.js +130 -0
  173. package/dist/node/style-values.js +96 -0
  174. package/dist/node/sub-slot.js +35 -0
  175. package/dist/node/testing.js +14 -0
  176. package/dist/node/trusted-html.js +6 -0
  177. package/dist/node/tsrx-iterable.js +5 -0
  178. package/dist/node/tsrx-spread.js +10 -0
  179. package/dist/node/universal-core.js +10010 -0
  180. package/dist/node/universal-dom-boundary.js +237 -0
  181. package/dist/node/universal-native.js +28 -0
  182. package/dist/node/universal.js +17 -0
  183. package/dist/node/version.js +4 -0
  184. package/dist/runtime.d.ts +18 -0
  185. package/dist/runtime.js +13 -2
  186. package/dist/runtime.server.d.ts +7 -0
  187. package/dist/runtime.server.js +4 -0
  188. package/dist/signals/control-binding.js +127 -120
  189. package/dist/signals/derived-facade.js +9 -11
  190. package/dist/signals/document-owner.js +13 -9
  191. package/dist/signals/facade.js +95 -103
  192. package/dist/signals/graph.js +144 -117
  193. package/dist/signals/native-read-client.js +79 -42
  194. package/dist/signals/owner-context.js +20 -10
  195. package/dist/signals/query-attempt-observer.js +9 -10
  196. package/dist/signals/query-facade.js +9 -19
  197. package/dist/signals/scalar-computations.js +7 -12
  198. package/dist/signals/transition-action.js +190 -133
  199. package/dist/signals/transition-candidate.js +30 -20
  200. package/dist/version.js +1 -1
  201. package/package.json +62 -1
@@ -28,23 +28,31 @@ __export(dom_binding_handoff_exports, {
28
28
  releaseBindingHandoff: () => releaseBindingHandoff
29
29
  });
30
30
  module.exports = __toCommonJS(dom_binding_handoff_exports);
31
- var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
32
31
  var import_control_handoff = require("./signals/control-handoff.cjs");
32
+ const __octaneDev = process.env.NODE_ENV !== "production";
33
+ function __octaneNoArgError(code) {
34
+ return "Minified Octane error #" + code + "; visit https://octanejs.dev/errors/" + code + " for the full message or use a development build for full errors and additional helpful warnings.";
35
+ }
33
36
  const events = /* @__PURE__ */ new WeakMap();
34
37
  const delivered = /* @__PURE__ */ new WeakMap();
35
38
  function registerBindingEvent(node, type) {
36
39
  let counts = events.get(node);
37
- if (counts === void 0) events.set(node, counts = /* @__PURE__ */ new Map());
40
+ if (counts === void 0)
41
+ events.set(node, counts = /* @__PURE__ */ new Map());
38
42
  counts.set(type, (counts.get(type) ?? 0) + 1);
39
43
  return () => {
40
44
  const count = counts.get(type) - 1;
41
- if (count === 0) counts.delete(type);
42
- else counts.set(type, count);
43
- if (counts.size === 0) events.delete(node);
45
+ if (count === 0)
46
+ counts.delete(type);
47
+ else
48
+ counts.set(type, count);
49
+ if (counts.size === 0)
50
+ events.delete(node);
44
51
  };
45
52
  }
46
53
  function claimBindingHandoff(lease, owner) {
47
- if (!lease.active() || lease.owner !== void 0) throw new Error((0, import_error_codes_client_generated.formatClientError)(277));
54
+ if (!lease.active() || lease.owner !== void 0)
55
+ throw new Error(__octaneDev ? "A DOM binding hydration lease must be active and have only one root owner." : __octaneNoArgError(277));
48
56
  lease.owner = owner;
49
57
  }
50
58
  function releaseBindingHandoff(lease) {
@@ -52,7 +60,8 @@ function releaseBindingHandoff(lease) {
52
60
  }
53
61
  function hasBindingHandoffEvent(event) {
54
62
  for (const node of event.composedPath()) {
55
- if (events.get(node)?.has(event.type)) return true;
63
+ if (events.get(node)?.has(event.type))
64
+ return true;
56
65
  }
57
66
  return false;
58
67
  }
@@ -61,10 +70,13 @@ function markBindingEvent(event, node, capture) {
61
70
  if (nodes === void 0) {
62
71
  delivered.set(event, nodes = /* @__PURE__ */ new Map());
63
72
  const cleanup = () => {
64
- if (delivered.get(event) === nodes) delivered.delete(event);
73
+ if (delivered.get(event) === nodes)
74
+ delivered.delete(event);
65
75
  };
66
- if (event.isTrusted) setTimeout(cleanup, 0);
67
- else queueMicrotask(cleanup);
76
+ if (event.isTrusted)
77
+ setTimeout(cleanup, 0);
78
+ else
79
+ queueMicrotask(cleanup);
68
80
  }
69
81
  nodes.set(node, (nodes.get(node) ?? 0) | (capture ? 2 : 1));
70
82
  }
@@ -72,9 +84,12 @@ function consumeBindingEvent(event, node, capture) {
72
84
  const nodes = delivered.get(event);
73
85
  const flags = nodes?.get(node) ?? 0;
74
86
  const bit = capture ? 2 : 1;
75
- if ((flags & bit) === 0) return false;
76
- if ((flags & ~bit) === 0) nodes.delete(node);
77
- else nodes.set(node, flags & ~bit);
87
+ if ((flags & bit) === 0)
88
+ return false;
89
+ if ((flags & ~bit) === 0)
90
+ nodes.delete(node);
91
+ else
92
+ nodes.set(node, flags & ~bit);
78
93
  return true;
79
94
  }
80
95
  function beginBindingEvent(event) {
@@ -27,8 +27,11 @@ __export(dom_binding_protocol_exports, {
27
27
  parseBindingMarker: () => parseBindingMarker
28
28
  });
29
29
  module.exports = __toCommonJS(dom_binding_protocol_exports);
30
- var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
31
30
  var import_hydration_markers = require("./hydration-markers.cjs");
31
+ const __octaneDev = process.env.NODE_ENV !== "production";
32
+ function __octaneNoArgError(code) {
33
+ return "Minified Octane error #" + code + "; visit https://octanejs.dev/errors/" + code + " for the full message or use a development build for full errors and additional helpful warnings.";
34
+ }
32
35
  const BINDING_OPEN_PREFIX = import_hydration_markers.HYDRATION_START + "b;";
33
36
  const BINDING_RECEIPT = ";b;";
34
37
  const BINDING_FOR_EMPTY_PREFIX = import_hydration_markers.HYDRATION_FOR_EMPTY + BINDING_RECEIPT;
@@ -43,25 +46,28 @@ function bindingRootMarker(id) {
43
46
  function encodeBindingKey(key) {
44
47
  if (typeof key === "string")
45
48
  return "s:" + JSON.stringify(key).replace(/-/g, "\\u002d").replace(/</g, "\\u003c");
46
- if (typeof key === "number" && Number.isFinite(key)) return "n:" + String(key);
47
- throw new TypeError((0, import_error_codes_client_generated.formatClientError)(306));
49
+ if (typeof key === "number" && Number.isFinite(key))
50
+ return "n:" + String(key);
51
+ throw new TypeError(__octaneDev ? "A DOM presentation key must be a string or finite number." : __octaneNoArgError(306));
48
52
  }
49
53
  function decodeBindingKey(encoded) {
50
54
  let key;
51
55
  try {
52
56
  key = JSON.parse(encoded.slice(2));
53
57
  } catch {
54
- throw new TypeError((0, import_error_codes_client_generated.formatClientError)(307));
58
+ throw new TypeError(__octaneDev ? "A DOM presentation key has invalid serialized identity." : __octaneNoArgError(307));
55
59
  }
56
60
  if (encoded.startsWith("s:") && typeof key === "string" || encoded.startsWith("n:") && typeof key === "number" && Number.isFinite(key)) {
57
- if (encodeBindingKey(key) === encoded) return key;
61
+ if (encodeBindingKey(key) === encoded)
62
+ return key;
58
63
  }
59
- throw new TypeError((0, import_error_codes_client_generated.formatClientError)(307));
64
+ throw new TypeError(__octaneDev ? "A DOM presentation key has invalid serialized identity." : __octaneNoArgError(307));
60
65
  }
61
66
  function parseBindingMarker(data) {
62
67
  if (data.startsWith(BINDING_FOR_EMPTY_PREFIX) || data.startsWith(BINDING_FOR_ITEMS_PREFIX)) {
63
68
  const separator = data.indexOf(";", BINDING_FOR_ID_START);
64
- if (separator <= BINDING_FOR_ID_START || separator === data.length - 1) return null;
69
+ if (separator <= BINDING_FOR_ID_START || separator === data.length - 1)
70
+ return null;
65
71
  return {
66
72
  id: data.slice(BINDING_FOR_ID_START, separator),
67
73
  site: data.slice(separator + 1),
@@ -69,20 +75,27 @@ function parseBindingMarker(data) {
69
75
  arm: data.charCodeAt(import_hydration_markers.HYDRATION_FOR_ARM_INDEX) - 48
70
76
  };
71
77
  }
72
- if (!data.startsWith(BINDING_OPEN_PREFIX)) return null;
78
+ if (!data.startsWith(BINDING_OPEN_PREFIX))
79
+ return null;
73
80
  const idEnd = data.indexOf(";", BINDING_ID_START);
74
- if (idEnd <= BINDING_ID_START || idEnd === data.length - 1) return null;
81
+ if (idEnd <= BINDING_ID_START || idEnd === data.length - 1)
82
+ return null;
75
83
  const id = data.slice(BINDING_ID_START, idEnd);
76
84
  if (data.slice(idEnd + 1) === BINDING_ROOT_SITE)
77
85
  return { id, site: BINDING_ROOT_SITE, kind: "root" };
78
86
  const siteEnd = data.indexOf(";", idEnd + 1);
79
- if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1) return null;
87
+ if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
88
+ return null;
80
89
  const site = data.slice(idEnd + 1, siteEnd);
81
90
  const kind = data.slice(siteEnd + 1);
82
- if (kind === "t") return { id, site, kind: "text" };
83
- if (kind === "v") return { id, site, kind: "view" };
84
- if (kind === "s") return { id, site, kind: "slot" };
85
- if (kind === "o") return { id, site, kind: "opaque" };
91
+ if (kind === "t")
92
+ return { id, site, kind: "text" };
93
+ if (kind === "v")
94
+ return { id, site, kind: "view" };
95
+ if (kind === "s")
96
+ return { id, site, kind: "slot" };
97
+ if (kind === "o")
98
+ return { id, site, kind: "opaque" };
86
99
  if (kind.startsWith("k;")) {
87
100
  const key = kind.slice(2);
88
101
  try {
@@ -94,21 +107,26 @@ function parseBindingMarker(data) {
94
107
  }
95
108
  if (/^(?:-1|0|[1-9]\d*)$/.test(kind)) {
96
109
  const arm = Number(kind);
97
- if (Number.isSafeInteger(arm)) return { id, site, kind: "if", arm };
110
+ if (Number.isSafeInteger(arm))
111
+ return { id, site, kind: "if", arm };
98
112
  }
99
113
  return null;
100
114
  }
101
115
  function isBindingOpenComment(data) {
102
116
  const list = data.startsWith(BINDING_FOR_EMPTY_PREFIX) || data.startsWith(BINDING_FOR_ITEMS_PREFIX);
103
- if (!list && !data.startsWith(BINDING_OPEN_PREFIX)) return false;
117
+ if (!list && !data.startsWith(BINDING_OPEN_PREFIX))
118
+ return false;
104
119
  const idStart = list ? BINDING_FOR_ID_START : BINDING_ID_START;
105
120
  const idEnd = data.indexOf(";", idStart);
106
- if (idEnd <= idStart || idEnd === data.length - 1) return false;
107
- if (list) return data.indexOf(";", idEnd + 1) === -1;
121
+ if (idEnd <= idStart || idEnd === data.length - 1)
122
+ return false;
123
+ if (list)
124
+ return data.indexOf(";", idEnd + 1) === -1;
108
125
  if (data.length - idEnd === BINDING_ROOT_SUFFIX.length && data.endsWith(BINDING_ROOT_SUFFIX))
109
126
  return true;
110
127
  const siteEnd = data.indexOf(";", idEnd + 1);
111
- if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1) return false;
128
+ if (siteEnd <= idEnd + 1 || siteEnd === data.length - 1)
129
+ return false;
112
130
  const tail = siteEnd + 1;
113
131
  if (data.length === tail + 1) {
114
132
  const code = data.charCodeAt(tail);
@@ -116,11 +134,14 @@ function isBindingOpenComment(data) {
116
134
  }
117
135
  if (data.charCodeAt(tail) === 107 && data.charCodeAt(tail + 1) === 59)
118
136
  return (data.charCodeAt(tail + 2) === 115 || data.charCodeAt(tail + 2) === 110) && data.charCodeAt(tail + 3) === 58 && data.length > tail + 4;
119
- if (data.length === tail + 2 && data.endsWith("-1")) return true;
120
- if (data.charCodeAt(tail) < 49 || data.charCodeAt(tail) > 57) return false;
137
+ if (data.length === tail + 2 && data.endsWith("-1"))
138
+ return true;
139
+ if (data.charCodeAt(tail) < 49 || data.charCodeAt(tail) > 57)
140
+ return false;
121
141
  for (let index = tail + 1; index < data.length; index++) {
122
142
  const code = data.charCodeAt(index);
123
- if (code < 48 || code > 57) return false;
143
+ if (code < 48 || code > 57)
144
+ return false;
124
145
  }
125
146
  return true;
126
147
  }
@@ -23,11 +23,14 @@ __export(dom_binding_styles_exports, {
23
23
  __prepareBindingSources: () => __prepareBindingSources
24
24
  });
25
25
  module.exports = __toCommonJS(dom_binding_styles_exports);
26
- var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
27
26
  var import_style_values = require("./style-values.cjs");
28
27
  var import_dom_bindings = require("./dom-bindings.cjs");
29
28
  var import_owner_context = require("./signals/owner-context.cjs");
30
29
  var import_read_protocol = require("./signals/read-protocol.cjs");
30
+ const __octaneDev = process.env.NODE_ENV !== "production";
31
+ function __octaneNoArgError(code) {
32
+ return "Minified Octane error #" + code + "; visit https://octanejs.dev/errors/" + code + " for the full message or use a development build for full errors and additional helpful warnings.";
33
+ }
31
34
  function __prepareBindingSources(reads, subscriptions, notify, active, run) {
32
35
  const previous = new Map(subscriptions);
33
36
  const acquired = /* @__PURE__ */ new Map();
@@ -36,49 +39,58 @@ function __prepareBindingSources(reads, subscriptions, notify, active, run) {
36
39
  let invalid = false;
37
40
  try {
38
41
  for (const source of reads.keys()) {
39
- if (previous.has(source)) continue;
42
+ if (previous.has(source))
43
+ continue;
40
44
  let live = true;
41
- const stop = run(
42
- () => source.subscribe(
43
- (0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
44
- if (!live || retired || !active()) return;
45
- if (!accepted) invalid = true;
46
- else notify();
47
- })
48
- )
49
- );
45
+ const stop = run(() => source.subscribe((0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
46
+ if (!live || retired || !active())
47
+ return;
48
+ if (!accepted)
49
+ invalid = true;
50
+ else
51
+ notify();
52
+ })));
50
53
  acquired.set(source, () => {
51
54
  live = false;
52
55
  stop();
53
56
  });
54
57
  }
55
58
  } catch (error) {
56
- for (const stop of acquired.values()) stop();
59
+ for (const stop of acquired.values())
60
+ stop();
57
61
  throw error;
58
62
  }
59
63
  return {
60
64
  validate: () => !retired && !invalid && active() && subscriptions.size === previous.size && [...previous].every(([source, stop]) => subscriptions.get(source) === stop) && [...reads].every(([source, version]) => source.getVersion() === version),
61
65
  commit() {
62
- if (accepted || retired || !active()) return;
66
+ if (accepted || retired || !active())
67
+ return;
63
68
  accepted = true;
64
- for (const [source, stop] of acquired) subscriptions.set(source, stop);
69
+ for (const [source, stop] of acquired)
70
+ subscriptions.set(source, stop);
65
71
  for (const [source, stop] of previous) {
66
- if (reads.has(source)) continue;
72
+ if (reads.has(source))
73
+ continue;
67
74
  subscriptions.delete(source);
68
75
  stop();
69
76
  }
70
77
  },
71
78
  discard() {
72
- if (accepted || retired) return;
79
+ if (accepted || retired)
80
+ return;
73
81
  retired = true;
74
- for (const stop of acquired.values()) stop();
82
+ for (const stop of acquired.values())
83
+ stop();
75
84
  }
76
85
  };
77
86
  }
78
87
  function __normalizeBindingStyle(value) {
79
- if (value == null || value === false || value === "") return null;
80
- if (typeof value === "string") return value;
81
- if (typeof value !== "object") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(311));
88
+ if (value == null || value === false || value === "")
89
+ return null;
90
+ if (typeof value === "string")
91
+ return value;
92
+ if (typeof value !== "object")
93
+ throw new TypeError(__octaneDev ? "A whole-style DOM binding requires a style object, CSS text or null." : __octaneNoArgError(311));
82
94
  const result = /* @__PURE__ */ Object.create(null);
83
95
  for (const name in value) {
84
96
  const property = value[name];
@@ -111,11 +123,10 @@ function __createBindingStyles() {
111
123
  };
112
124
  previous = snapshotDOM();
113
125
  const get = () => {
114
- if (disposed) return null;
126
+ if (disposed)
127
+ return null;
115
128
  const reads = /* @__PURE__ */ new Map();
116
- const previousObserver = (0, import_read_protocol.setNativeReadObserver)(
117
- (source, version) => reads.set(source, version)
118
- );
129
+ const previousObserver = (0, import_read_protocol.setNativeReadObserver)((source, version) => reads.set(source, version));
119
130
  const guard = (0, import_read_protocol.beginNativeWriteGuard)();
120
131
  let value;
121
132
  try {
@@ -125,35 +136,39 @@ function __createBindingStyles() {
125
136
  (0, import_read_protocol.setNativeReadObserver)(previousObserver);
126
137
  }
127
138
  for (const [source, stop] of subscriptions) {
128
- if (reads.has(source)) continue;
139
+ if (reads.has(source))
140
+ continue;
129
141
  subscriptions.delete(source);
130
142
  stop();
131
143
  }
132
144
  for (const [source, version] of reads) {
133
- if (disposed) break;
145
+ if (disposed)
146
+ break;
134
147
  if (!subscriptions.has(source)) {
135
148
  let active = true;
136
- const stop = run(
137
- () => source.subscribe(
138
- (0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
139
- if (active && !disposed) notify();
140
- })
141
- )
142
- );
143
- if (typeof stop !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(312));
149
+ const stop = run(() => source.subscribe((0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => {
150
+ if (active && !disposed)
151
+ notify();
152
+ })));
153
+ if (typeof stop !== "function")
154
+ throw new TypeError(__octaneDev ? "A DOM style subscription must return cleanup." : __octaneNoArgError(312));
144
155
  const disposeSource = () => {
145
156
  active = false;
146
157
  stop();
147
158
  };
148
- if (disposed) disposeSource();
149
- else subscriptions.set(source, disposeSource);
159
+ if (disposed)
160
+ disposeSource();
161
+ else
162
+ subscriptions.set(source, disposeSource);
150
163
  }
151
- if (!disposed && source.getVersion() !== version) notify();
164
+ if (!disposed && source.getVersion() !== version)
165
+ notify();
152
166
  }
153
167
  return value;
154
168
  };
155
169
  const writeProperty = (name, value) => {
156
- if (disposed) return;
170
+ if (disposed)
171
+ return;
157
172
  name = (0, import_style_values.hyphenateStyleName)(name);
158
173
  const operation = [0, "styleProperty", name];
159
174
  if (restoreStyles) {
@@ -169,17 +184,18 @@ function __createBindingStyles() {
169
184
  (0, import_dom_bindings.__writeBinding)(node, operation, value);
170
185
  };
171
186
  const restore = () => {
172
- if (!restorations) return;
173
- const owned = [...restorations].filter(
174
- (name) => style.getPropertyValue(name) === expected.style.getPropertyValue(name) && style.getPropertyPriority(name) === expected.style.getPropertyPriority(name)
175
- );
187
+ if (!restorations)
188
+ return;
189
+ const owned = [...restorations].filter((name) => style.getPropertyValue(name) === expected.style.getPropertyValue(name) && style.getPropertyPriority(name) === expected.style.getPropertyPriority(name));
176
190
  let failed = false;
177
191
  let failure;
178
192
  for (const name of owned) {
179
193
  try {
180
194
  const value = baseline.style.getPropertyValue(name);
181
- if (value === "") style.removeProperty(name);
182
- else style.setProperty(name, value, baseline.style.getPropertyPriority(name));
195
+ if (value === "")
196
+ style.removeProperty(name);
197
+ else
198
+ style.setProperty(name, value, baseline.style.getPropertyPriority(name));
183
199
  } catch (error) {
184
200
  if (!failed) {
185
201
  failed = true;
@@ -187,14 +203,16 @@ function __createBindingStyles() {
187
203
  }
188
204
  }
189
205
  }
190
- if (failed) throw failure;
206
+ if (failed)
207
+ throw failure;
191
208
  };
192
209
  return {
193
210
  get,
194
211
  preview(value) {
195
212
  const reads = /* @__PURE__ */ new Map();
196
213
  const previousObserver = (0, import_read_protocol.setNativeReadObserver)((source, version) => {
197
- if (!reads.has(source)) reads.set(source, version);
214
+ if (!reads.has(source))
215
+ reads.set(source, version);
198
216
  });
199
217
  const guard = (0, import_read_protocol.beginNativeWriteGuard)();
200
218
  let projected;
@@ -204,13 +222,7 @@ function __createBindingStyles() {
204
222
  (0, import_read_protocol.endNativeWriteGuard)(guard);
205
223
  (0, import_read_protocol.setNativeReadObserver)(previousObserver);
206
224
  }
207
- const prepared = __prepareBindingSources(
208
- reads,
209
- subscriptions,
210
- notify,
211
- () => !disposed,
212
- run
213
- );
225
+ const prepared = __prepareBindingSources(reads, subscriptions, notify, () => !disposed, run);
214
226
  return {
215
227
  value: projected,
216
228
  validate: prepared.validate,
@@ -226,7 +238,8 @@ function __createBindingStyles() {
226
238
  return get();
227
239
  },
228
240
  write(value) {
229
- if (disposed) return;
241
+ if (disposed)
242
+ return;
230
243
  let next = value;
231
244
  let old = typeof previous === "string" ? snapshotDOM() : previous;
232
245
  const writeAll = firstWrite || typeof previous === "string" || typeof value === "string";
@@ -256,7 +269,8 @@ function __createBindingStyles() {
256
269
  }
257
270
  },
258
271
  dispose(preservePresentation) {
259
- if (disposed) return;
272
+ if (disposed)
273
+ return;
260
274
  disposed = true;
261
275
  raw = previous = null;
262
276
  let failed = false;
@@ -277,7 +291,8 @@ function __createBindingStyles() {
277
291
  subscriptions.clear();
278
292
  restorations?.clear();
279
293
  probe = baseline = expected = void 0;
280
- if (failed) throw failure;
294
+ if (failed)
295
+ throw failure;
281
296
  }
282
297
  };
283
298
  }