octane 0.6.2 → 0.7.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 (200) hide show
  1. package/dist/cjs/constants.cjs +3 -0
  2. package/dist/cjs/dom-binding-handoff.cjs +2 -1
  3. package/dist/cjs/dom-binding-protocol.cjs +4 -3
  4. package/dist/cjs/dom-binding-styles.cjs +3 -2
  5. package/dist/cjs/dom-bindings.cjs +24 -23
  6. package/dist/cjs/error-codes.client.generated.cjs +7 -1
  7. package/dist/cjs/error-codes.server.generated.cjs +27 -1
  8. package/dist/cjs/hydration/event-capture.cjs +2 -1
  9. package/dist/cjs/independent-hydration-protocol.cjs +3 -2
  10. package/dist/cjs/index.cjs +2 -0
  11. package/dist/cjs/runtime.cjs +866 -370
  12. package/dist/cjs/runtime.server.cjs +250 -62
  13. package/dist/cjs/server/index.cjs +2 -0
  14. package/dist/cjs/server/rpc-stream.cjs +19 -12
  15. package/dist/cjs/server/streamed-signals.cjs +18 -1
  16. package/dist/cjs/shared-value-helpers.cjs +24 -2
  17. package/dist/cjs/signals/control-binding.cjs +7 -6
  18. package/dist/cjs/signals/derived-facade.cjs +2 -1
  19. package/dist/cjs/signals/document-owner.cjs +4 -3
  20. package/dist/cjs/signals/facade.cjs +10 -9
  21. package/dist/cjs/signals/graph.cjs +5 -4
  22. package/dist/cjs/signals/native-read-client.cjs +4 -3
  23. package/dist/cjs/signals/owner-context.cjs +4 -3
  24. package/dist/cjs/signals/query-attempt-observer.cjs +2 -1
  25. package/dist/cjs/signals/query-facade.cjs +2 -1
  26. package/dist/cjs/signals/scalar-computations.cjs +2 -1
  27. package/dist/cjs/signals/transition-action.cjs +10 -9
  28. package/dist/cjs/signals/transition-candidate.cjs +2 -1
  29. package/dist/cjs/version.cjs +1 -1
  30. package/dist/compiler/arm-exits.js +151 -0
  31. package/dist/compiler/compile-universal.js +262 -65
  32. package/dist/compiler/compile.js +1929 -306
  33. package/dist/compiler/deferred-snapshots.js +791 -0
  34. package/dist/compiler/strong-mode.js +59 -10
  35. package/dist/constants.d.ts +5 -1
  36. package/dist/constants.js +2 -0
  37. package/dist/error-codes.client.generated.d.ts +1 -0
  38. package/dist/error-codes.client.generated.js +5 -0
  39. package/dist/error-codes.server.generated.d.ts +5 -0
  40. package/dist/error-codes.server.generated.js +25 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/node/aria-diagnostics.js +92 -0
  44. package/dist/node/behavior-form-submissions.js +228 -0
  45. package/dist/node/behavior-root-types.js +0 -0
  46. package/dist/node/behavior-root.js +746 -0
  47. package/dist/node/class-names.js +25 -0
  48. package/dist/node/compatibility.js +10 -0
  49. package/dist/node/component-flags.js +23 -0
  50. package/dist/node/constants.js +115 -0
  51. package/dist/node/context-epoch.js +13 -0
  52. package/dist/node/context-identity.js +46 -0
  53. package/dist/node/css.js +80 -0
  54. package/dist/node/data-encoding.js +134 -0
  55. package/dist/node/devtools-hook.js +229 -0
  56. package/dist/node/dom-binding-claims.js +4 -0
  57. package/dist/node/dom-binding-classes.js +152 -0
  58. package/dist/node/dom-binding-controls.js +6 -0
  59. package/dist/node/dom-binding-handoff.js +77 -0
  60. package/dist/node/dom-binding-program.js +1617 -0
  61. package/dist/node/dom-binding-projections.js +204 -0
  62. package/dist/node/dom-binding-protocol.js +130 -0
  63. package/dist/node/dom-binding-signals.js +135 -0
  64. package/dist/node/dom-binding-styles.js +280 -0
  65. package/dist/node/dom-bindings.js +1087 -0
  66. package/dist/node/dom-focused-move.js +46 -0
  67. package/dist/node/dom-stage.js +878 -0
  68. package/dist/node/dom-tables.js +382 -0
  69. package/dist/node/error-codes.client.generated.js +1071 -0
  70. package/dist/node/error-codes.server.generated.js +761 -0
  71. package/dist/node/error-message.js +27 -0
  72. package/dist/node/event-names.js +15 -0
  73. package/dist/node/form-diagnostics.js +96 -0
  74. package/dist/node/form-submission.js +43 -0
  75. package/dist/node/has-own.js +4 -0
  76. package/dist/node/head-ownership.js +31 -0
  77. package/dist/node/hook-slot-cache.js +91 -0
  78. package/dist/node/host-property-diagnostics.js +189 -0
  79. package/dist/node/html-tree-validation.js +193 -0
  80. package/dist/node/hydration/condition.js +15 -0
  81. package/dist/node/hydration/control-capture.js +237 -0
  82. package/dist/node/hydration/document-lifecycle.js +89 -0
  83. package/dist/node/hydration/event-capture.js +362 -0
  84. package/dist/node/hydration/idle.js +23 -0
  85. package/dist/node/hydration/independent-island.js +317 -0
  86. package/dist/node/hydration/index.js +74 -0
  87. package/dist/node/hydration/interaction-config.js +61 -0
  88. package/dist/node/hydration/interaction.js +35 -0
  89. package/dist/node/hydration/load.js +15 -0
  90. package/dist/node/hydration/media.js +33 -0
  91. package/dist/node/hydration/native-intent.js +68 -0
  92. package/dist/node/hydration/never.js +12 -0
  93. package/dist/node/hydration/stream-delivery.js +345 -0
  94. package/dist/node/hydration/stream-receiver.js +190 -0
  95. package/dist/node/hydration/stream-result-receiver.js +276 -0
  96. package/dist/node/hydration/streamed-signals.js +186 -0
  97. package/dist/node/hydration/types.js +0 -0
  98. package/dist/node/hydration/visible.js +69 -0
  99. package/dist/node/hydration-markers.js +44 -0
  100. package/dist/node/independent-hydration-protocol.js +91 -0
  101. package/dist/node/index.js +463 -0
  102. package/dist/node/internal/client.js +7 -0
  103. package/dist/node/internal/context.js +5 -0
  104. package/dist/node/internal/server.js +5 -0
  105. package/dist/node/internal/signal-read.js +4 -0
  106. package/dist/node/method-dep.js +25 -0
  107. package/dist/node/profiling.js +432 -0
  108. package/dist/node/public-types.js +0 -0
  109. package/dist/node/react/fiber-adapter.js +57 -0
  110. package/dist/node/react/index.js +397 -0
  111. package/dist/node/react/react-compat-envelope.js +78 -0
  112. package/dist/node/react/react-compat-server.js +129 -0
  113. package/dist/node/react/react-compat-shared.js +104 -0
  114. package/dist/node/react/react-compat.js +223 -0
  115. package/dist/node/react/server.js +81 -0
  116. package/dist/node/react/shared.js +75 -0
  117. package/dist/node/renderer-bridge.js +35 -0
  118. package/dist/node/resize-observer.js +105 -0
  119. package/dist/node/resource-hint-diagnostics.js +67 -0
  120. package/dist/node/runtime-tags.js +22 -0
  121. package/dist/node/runtime.js +29364 -0
  122. package/dist/node/runtime.server.js +8200 -0
  123. package/dist/node/sanitize-url.js +34 -0
  124. package/dist/node/server/early-signals.js +54 -0
  125. package/dist/node/server/index.js +338 -0
  126. package/dist/node/server/rpc-batch.js +129 -0
  127. package/dist/node/server/rpc-stream.js +132 -0
  128. package/dist/node/server/rpc.js +48 -0
  129. package/dist/node/server/signal-query-observation.js +134 -0
  130. package/dist/node/server/streamed-region.js +31 -0
  131. package/dist/node/server/streamed-signals.js +574 -0
  132. package/dist/node/server-call.js +75 -0
  133. package/dist/node/server-rpc-batch-client.js +119 -0
  134. package/dist/node/server-rpc-client.js +108 -0
  135. package/dist/node/server-rpc-protocol.js +109 -0
  136. package/dist/node/server-rpc-stream-client.js +98 -0
  137. package/dist/node/shared-value-helpers.js +60 -0
  138. package/dist/node/signals/actions.js +463 -0
  139. package/dist/node/signals/client.js +22 -0
  140. package/dist/node/signals/computations.js +452 -0
  141. package/dist/node/signals/control-binding.js +388 -0
  142. package/dist/node/signals/control-handoff.js +12 -0
  143. package/dist/node/signals/derived-facade.js +25 -0
  144. package/dist/node/signals/document-owner.js +48 -0
  145. package/dist/node/signals/early-values.js +124 -0
  146. package/dist/node/signals/encoding.js +6 -0
  147. package/dist/node/signals/engine.js +668 -0
  148. package/dist/node/signals/errors.js +54 -0
  149. package/dist/node/signals/facade.js +441 -0
  150. package/dist/node/signals/graph.js +817 -0
  151. package/dist/node/signals/handle-protocol.js +11 -0
  152. package/dist/node/signals/index.js +87 -0
  153. package/dist/node/signals/native-read-client.js +319 -0
  154. package/dist/node/signals/native-read-collector.js +132 -0
  155. package/dist/node/signals/native-read-events.js +45 -0
  156. package/dist/node/signals/native-read-inspection.js +20 -0
  157. package/dist/node/signals/native-read-retry.js +30 -0
  158. package/dist/node/signals/native-read-seeds.js +243 -0
  159. package/dist/node/signals/native-read-server.js +99 -0
  160. package/dist/node/signals/owner-context.js +88 -0
  161. package/dist/node/signals/query-attempt-observer.js +42 -0
  162. package/dist/node/signals/query-facade.js +41 -0
  163. package/dist/node/signals/read-protocol.js +125 -0
  164. package/dist/node/signals/requests.js +716 -0
  165. package/dist/node/signals/scalar-computations.js +57 -0
  166. package/dist/node/signals/scope-streams.js +147 -0
  167. package/dist/node/signals/server.js +22 -0
  168. package/dist/node/signals/transition-action.js +555 -0
  169. package/dist/node/signals/transition-candidate.js +101 -0
  170. package/dist/node/signals/transition-coordinator.js +255 -0
  171. package/dist/node/signals/transition-state.js +82 -0
  172. package/dist/node/signals/types.js +20 -0
  173. package/dist/node/static/index.js +10 -0
  174. package/dist/node/stream-protocol.js +114 -0
  175. package/dist/node/streamed-signals-protocol.js +130 -0
  176. package/dist/node/style-values.js +96 -0
  177. package/dist/node/sub-slot.js +35 -0
  178. package/dist/node/testing.js +14 -0
  179. package/dist/node/trusted-html.js +6 -0
  180. package/dist/node/tsrx-iterable.js +5 -0
  181. package/dist/node/tsrx-spread.js +10 -0
  182. package/dist/node/universal-core.js +10138 -0
  183. package/dist/node/universal-dom-boundary.js +237 -0
  184. package/dist/node/universal-native.js +28 -0
  185. package/dist/node/universal.js +17 -0
  186. package/dist/node/version.js +4 -0
  187. package/dist/runtime.d.ts +219 -8
  188. package/dist/runtime.js +714 -220
  189. package/dist/runtime.server.d.ts +33 -2
  190. package/dist/runtime.server.js +217 -29
  191. package/dist/server/index.d.ts +1 -1
  192. package/dist/server/index.js +2 -0
  193. package/dist/server/rpc-stream.js +19 -12
  194. package/dist/server/streamed-signals.js +18 -1
  195. package/dist/shared-value-helpers.d.ts +11 -0
  196. package/dist/shared-value-helpers.js +21 -1
  197. package/dist/universal-core.d.ts +3 -1
  198. package/dist/universal-core.js +178 -50
  199. package/dist/version.js +1 -1
  200. package/package.json +62 -1
@@ -0,0 +1,243 @@
1
+ import { formatClientError } from "../error-codes.client.generated.js";
2
+ import { decodeSignalValue, snapshotSignalValue } from "../data-encoding.js";
3
+ const NATIVE_SIGNAL_SEED_ATTR = "data-octane-native-signals";
4
+ const NATIVE_SIGNAL_FRESH_COMMENT = "oct-native-fresh:";
5
+ function seedEntryKey(entry) {
6
+ return (entry.read ?? "value") + ":" + entry.key;
7
+ }
8
+ function seedEntrySignature(entry) {
9
+ return JSON.stringify(snapshotSignalValue({ ...entry, read: entry.read ?? "value" }));
10
+ }
11
+ const capturedInitialDocumentSignals = /* @__PURE__ */ new WeakMap();
12
+ function captureInitialDocumentSignals(seed, scopeKey) {
13
+ return getInitialDocumentCapture(seed, scopeKey).seed;
14
+ }
15
+ function getInitialDocumentCapture(seed, scopeKey) {
16
+ const previous = capturedInitialDocumentSignals.get(seed);
17
+ if (previous !== void 0) {
18
+ if (scopeKey !== void 0 && previous.seed.scopeKey !== scopeKey)
19
+ throw new Error(formatClientError(170));
20
+ return previous;
21
+ }
22
+ const captured = snapshotSignalValue(seed);
23
+ if (captured === null || typeof captured !== "object" || captured.version !== 1 || typeof captured.scopeKey !== "string" || !captured.scopeKey.trim() || scopeKey !== void 0 && captured.scopeKey !== scopeKey || !Array.isArray(captured.entries))
24
+ throw new Error(formatClientError(170));
25
+ const entries = /* @__PURE__ */ new Map();
26
+ const signatures = /* @__PURE__ */ new Map();
27
+ for (const entry of captured.entries) {
28
+ const read = entry?.read ?? "value";
29
+ if (entry === null || typeof entry !== "object" || typeof entry.key !== "string" || !entry.key.trim() || !["signal", "derived", "async"].includes(entry.kind) || !["value", "latest", "snapshot"].includes(read) || typeof entry.complete !== "boolean" || !Array.isArray(entry.value) || entry.available !== void 0 && (read !== "latest" || typeof entry.available !== "boolean") || entry.refreshing !== void 0 && typeof entry.refreshing !== "boolean" || entry.connection !== void 0 && !["none", "connecting", "open", "closed"].includes(entry.connection) || entries.has(seedEntryKey(entry)))
30
+ throw new Error(formatClientError(171));
31
+ if (entry.available === false) {
32
+ if (entry.complete || entry.request !== void 0 || entry.value.length !== 1 || entry.value[0] !== "undefined")
33
+ throw new Error(formatClientError(172));
34
+ } else if (entry.kind === "async") {
35
+ const request = entry.request;
36
+ if (request === null || typeof request !== "object" || typeof request.queryKey !== "string" || !request.queryKey.trim() || !["promise", "stream"].includes(request.kind) || !Array.isArray(request.argument))
37
+ throw new Error(formatClientError(173));
38
+ decodeSignalValue(request.argument);
39
+ } else if (entry.request !== void 0) {
40
+ throw new Error(formatClientError(174));
41
+ }
42
+ decodeSignalValue(entry.value);
43
+ const key = seedEntryKey(entry);
44
+ entries.set(key, entry);
45
+ signatures.set(key, seedEntrySignature(entry));
46
+ }
47
+ const result = { seed: captured, entries, signatures };
48
+ capturedInitialDocumentSignals.set(captured, result);
49
+ return result;
50
+ }
51
+ function mergeNativeSeedReads(previous, next) {
52
+ const target = previous ?? { reads: /* @__PURE__ */ new Map(), mixed: false };
53
+ if (next.mixed) target.mixed = true;
54
+ for (const [source, version] of next.reads) {
55
+ const prior = target.reads.get(source);
56
+ if (prior === void 0) target.reads.set(source, version);
57
+ else if (prior !== version) target.mixed = true;
58
+ }
59
+ return target;
60
+ }
61
+ function rewindNativeSeedReads(reads, size, mixed) {
62
+ if (reads === null) return;
63
+ let index = 0;
64
+ for (const source of reads.reads.keys()) {
65
+ if (index++ >= size) reads.reads.delete(source);
66
+ }
67
+ reads.mixed = mixed;
68
+ }
69
+ function serializeNativeSeedReads(reads, initialDocumentSignals) {
70
+ if (reads === null) return void 0;
71
+ if (reads.mixed) throw new Error(formatClientError(175));
72
+ const scopes = /* @__PURE__ */ new Map();
73
+ const claims = /* @__PURE__ */ new Map();
74
+ for (const [source, version] of reads.reads) {
75
+ if (source.getVersion() !== version) throw new Error(formatClientError(176));
76
+ const seeds = source.serialize?.(version);
77
+ if (source.getVersion() !== version) throw new Error(formatClientError(177));
78
+ if (seeds === void 0) {
79
+ if (source.serialize !== void 0) throw new Error(formatClientError(178));
80
+ continue;
81
+ }
82
+ for (const { owner, seed } of seeds) {
83
+ const claimant = claims.get(seed.scopeKey);
84
+ if (claimant !== void 0 && claimant !== owner)
85
+ throw new Error(formatClientError(179, seed.scopeKey));
86
+ claims.set(seed.scopeKey, owner);
87
+ let entries = scopes.get(seed.scopeKey);
88
+ if (entries === void 0) scopes.set(seed.scopeKey, entries = /* @__PURE__ */ new Map());
89
+ for (const entry of seed.entries) {
90
+ const channel = entry.read ?? "value";
91
+ const key = channel + ":" + entry.key;
92
+ const previous = entries.get(key);
93
+ if (previous !== void 0 && JSON.stringify(previous) !== JSON.stringify(entry))
94
+ throw new Error(formatClientError(180, seed.scopeKey, entry.key));
95
+ entries.set(key, entry);
96
+ }
97
+ }
98
+ }
99
+ if (scopes.size === 0) return void 0;
100
+ let references;
101
+ let initialDocumentScopeKey;
102
+ if (initialDocumentSignals !== void 0) {
103
+ const initial = getInitialDocumentCapture(initialDocumentSignals);
104
+ initialDocumentScopeKey = initial.seed.scopeKey;
105
+ const documentEntries = scopes.get(initialDocumentScopeKey);
106
+ if (documentEntries !== void 0) {
107
+ for (const [key, entry] of documentEntries) {
108
+ if (initial.signatures.get(key) === seedEntrySignature(entry)) {
109
+ (references ??= []).push({ key: entry.key, read: entry.read ?? "value" });
110
+ documentEntries.delete(key);
111
+ }
112
+ }
113
+ if (references !== void 0 && documentEntries.size === 0)
114
+ scopes.delete(initialDocumentScopeKey);
115
+ }
116
+ }
117
+ const serializedScopes = Array.from(scopes, ([scopeKey, entries]) => ({
118
+ version: 1,
119
+ scopeKey,
120
+ entries: Array.from(entries.values())
121
+ }));
122
+ if (references !== void 0)
123
+ return {
124
+ version: 2,
125
+ scopes: serializedScopes,
126
+ initialDocument: { scopeKey: initialDocumentScopeKey, entries: references }
127
+ };
128
+ return {
129
+ version: 1,
130
+ scopes: serializedScopes
131
+ };
132
+ }
133
+ function parseNativeSignalManifest(raw) {
134
+ return validateNativeSignalManifest(JSON.parse(raw));
135
+ }
136
+ function validateNativeSignalManifest(value) {
137
+ if (value === null || typeof value !== "object" || value.version !== 1 && value.version !== 2 || !Array.isArray(value.scopes))
138
+ throw new Error(formatClientError(181));
139
+ const manifest = value;
140
+ const keys = /* @__PURE__ */ new Set();
141
+ for (const scope of manifest.scopes) {
142
+ if (scope === null || typeof scope !== "object" || scope.version !== 1 || typeof scope.scopeKey !== "string" || scope.scopeKey.length === 0 || !Array.isArray(scope.entries) || keys.has(scope.scopeKey))
143
+ throw new Error(formatClientError(182));
144
+ keys.add(scope.scopeKey);
145
+ }
146
+ if (manifest.version === 2) {
147
+ const document = manifest.initialDocument;
148
+ if (document === null || typeof document !== "object" || typeof document.scopeKey !== "string" || !document.scopeKey.trim() || !Array.isArray(document.entries) || document.entries.length === 0)
149
+ throw new Error(formatClientError(183));
150
+ const references = /* @__PURE__ */ new Set();
151
+ for (const reference of document.entries) {
152
+ if (reference === null || typeof reference !== "object" || typeof reference.key !== "string" || !reference.key.trim() || !["value", "latest", "snapshot"].includes(reference.read) || references.has(seedEntryKey(reference)))
153
+ throw new Error(formatClientError(184));
154
+ references.add(seedEntryKey(reference));
155
+ }
156
+ }
157
+ return manifest;
158
+ }
159
+ function materializeNativeSignalManifest(manifest, initialDocumentSignals) {
160
+ if (manifest.version === 1) return manifest;
161
+ validateNativeSignalManifest(manifest);
162
+ if (initialDocumentSignals === void 0) throw new Error(formatClientError(185));
163
+ const document = manifest.initialDocument;
164
+ const initial = getInitialDocumentCapture(initialDocumentSignals, document.scopeKey);
165
+ const entries = /* @__PURE__ */ new Map();
166
+ for (const reference of document.entries) {
167
+ const key = seedEntryKey(reference);
168
+ const entry = initial.entries.get(key);
169
+ if (entry === void 0 || entries.has(key)) throw new Error(formatClientError(186));
170
+ entries.set(key, entry);
171
+ }
172
+ for (const scope of manifest.scopes) {
173
+ if (scope.scopeKey !== document.scopeKey) continue;
174
+ for (const entry of scope.entries) {
175
+ const key = seedEntryKey(entry);
176
+ if (entries.has(key)) throw new Error(formatClientError(187));
177
+ entries.set(key, entry);
178
+ }
179
+ }
180
+ return {
181
+ version: 1,
182
+ scopes: [
183
+ ...manifest.scopes.filter((scope) => scope.scopeKey !== document.scopeKey),
184
+ { version: 1, scopeKey: document.scopeKey, entries: Array.from(entries.values()) }
185
+ ]
186
+ };
187
+ }
188
+ function createNativeAdoptionState(manifest, initialDocumentSignals) {
189
+ const materialized = materializeNativeSignalManifest(manifest, initialDocumentSignals);
190
+ const seeds = new Map(materialized.scopes.map((seed) => [seed.scopeKey, seed]));
191
+ const frames = /* @__PURE__ */ new Map();
192
+ const claims = /* @__PURE__ */ new Map();
193
+ let released = false;
194
+ return {
195
+ resolve(owner) {
196
+ if (released) return void 0;
197
+ const seed = seeds.get(owner.scopeKey);
198
+ if (seed === void 0) return void 0;
199
+ const claimant = claims.get(owner.scopeKey);
200
+ if (claimant !== void 0 && claimant !== owner)
201
+ throw new Error(formatClientError(188, owner.scopeKey));
202
+ let frame = frames.get(owner);
203
+ if (frame === void 0) {
204
+ frame = owner.beginAdoption(seed);
205
+ claims.set(owner.scopeKey, owner);
206
+ frames.set(owner, frame);
207
+ }
208
+ return frame;
209
+ },
210
+ release() {
211
+ if (released) return;
212
+ released = true;
213
+ let failure;
214
+ let failed = false;
215
+ try {
216
+ for (const frame of frames.values()) {
217
+ try {
218
+ frame.release();
219
+ } catch (error) {
220
+ if (!failed) failure = error;
221
+ failed = true;
222
+ }
223
+ }
224
+ } finally {
225
+ frames.clear();
226
+ claims.clear();
227
+ seeds.clear();
228
+ }
229
+ if (failed) throw failure;
230
+ }
231
+ };
232
+ }
233
+ export {
234
+ NATIVE_SIGNAL_FRESH_COMMENT,
235
+ NATIVE_SIGNAL_SEED_ATTR,
236
+ captureInitialDocumentSignals,
237
+ createNativeAdoptionState,
238
+ materializeNativeSignalManifest,
239
+ mergeNativeSeedReads,
240
+ parseNativeSignalManifest,
241
+ rewindNativeSeedReads,
242
+ serializeNativeSeedReads
243
+ };
@@ -0,0 +1,99 @@
1
+ import { createNativeReadCollector } from "./native-read-collector.js";
2
+ import {
3
+ mergeNativeSeedReads,
4
+ rewindNativeSeedReads,
5
+ serializeNativeSeedReads
6
+ } from "./native-read-seeds.js";
7
+ function createNativeServerReadDriver(record, recordFailure) {
8
+ const frames = [];
9
+ const passes = [];
10
+ let depth = 0;
11
+ let passDepth = 0;
12
+ let base = 0;
13
+ const collector = createNativeReadCollector((_owner, source, version) => {
14
+ const frame = frames[depth - 1];
15
+ if (frame === void 0) return;
16
+ const reads = frame.reads ??= { reads: /* @__PURE__ */ new Map(), mixed: false };
17
+ const previous = reads.reads.get(source);
18
+ if (previous === void 0) reads.reads.set(source, version);
19
+ else if (previous !== version) reads.mixed = true;
20
+ });
21
+ function append(reads) {
22
+ if (depth === base) record(reads);
23
+ else frames[depth - 1].reads = mergeNativeSeedReads(frames[depth - 1].reads, reads);
24
+ }
25
+ return {
26
+ merge: mergeNativeSeedReads,
27
+ rewindReads: rewindNativeSeedReads,
28
+ serialize: serializeNativeSeedReads,
29
+ isDetached: collector.isDetached,
30
+ pauseLifecycle: () => collector.suspend(true),
31
+ resumeLifecycle: (token) => collector.resume(token, true),
32
+ checkpoint() {
33
+ if (depth === base) return null;
34
+ const frame = frames[depth - 1];
35
+ const reads = frame.reads;
36
+ return { frame, reads, size: reads?.reads.size ?? 0, mixed: reads?.mixed ?? false };
37
+ },
38
+ rewind(checkpoint) {
39
+ checkpoint.frame.reads = checkpoint.reads;
40
+ rewindNativeSeedReads(checkpoint.reads, checkpoint.size, checkpoint.mixed);
41
+ },
42
+ beginPass() {
43
+ const token = passDepth++;
44
+ const pass = passes[token] ??= { base: 0, collectorToken: -1 };
45
+ pass.base = base;
46
+ pass.collectorToken = collector.beginRender();
47
+ base = depth;
48
+ return token;
49
+ },
50
+ endPass(token) {
51
+ const pass = passes[token];
52
+ base = pass.base;
53
+ passDepth = token;
54
+ collector.endRender(pass.collectorToken);
55
+ },
56
+ beginScope(owner) {
57
+ const token = depth++;
58
+ const frame = frames[token] ??= { collectorToken: -1, reads: null };
59
+ frame.reads = null;
60
+ frame.collectorToken = collector.beginScope(owner);
61
+ return token;
62
+ },
63
+ endScope(token, completed) {
64
+ const frame = frames[token];
65
+ const reads = frame.reads;
66
+ frame.reads = null;
67
+ depth = token;
68
+ try {
69
+ if (completed && reads !== null) append(reads);
70
+ else if (!completed && reads !== null) recordFailure();
71
+ } finally {
72
+ collector.endScope(frame.collectorToken);
73
+ }
74
+ },
75
+ /** A renderer boundary may emit its successful body in a later segment. */
76
+ beginCapture() {
77
+ const token = depth++;
78
+ const frame = frames[token] ??= { collectorToken: -1, reads: null };
79
+ frame.collectorToken = -1;
80
+ frame.reads = null;
81
+ return token;
82
+ },
83
+ finishCapture(token, merge) {
84
+ const frame = frames[token];
85
+ const reads = frame.reads;
86
+ frame.reads = null;
87
+ depth = token;
88
+ if (merge && reads !== null) append(reads);
89
+ return reads;
90
+ },
91
+ append,
92
+ beginWitness: collector.beginWitness,
93
+ finishWitness: collector.finishWitness,
94
+ replay: collector.replay
95
+ };
96
+ }
97
+ export {
98
+ createNativeServerReadDriver
99
+ };
@@ -0,0 +1,88 @@
1
+ const __octaneDev = process.env.NODE_ENV !== "production";
2
+ function __octaneNoArgError(code) {
3
+ 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.";
4
+ }
5
+ let installedEnvironment;
6
+ let synchronousOwner = null;
7
+ let defaultOwner;
8
+ let retireOwner;
9
+ function installSignalOwnerEnvironment(environment) {
10
+ if (!environment || typeof environment.current !== "function" || typeof environment.run !== "function" || typeof environment.capture !== "function") {
11
+ throw new TypeError(__octaneDev ? "A signal owner environment requires current, run, and capture." : __octaneNoArgError(189));
12
+ }
13
+ const previous = installedEnvironment;
14
+ installedEnvironment = environment;
15
+ return () => {
16
+ if (installedEnvironment === environment)
17
+ installedEnvironment = previous;
18
+ };
19
+ }
20
+ function currentSignalOwner() {
21
+ if (installedEnvironment !== void 0)
22
+ return installedEnvironment.current() ?? synchronousOwner;
23
+ return synchronousOwner ?? defaultOwner?.() ?? null;
24
+ }
25
+ function currentExplicitSignalOwner() {
26
+ return installedEnvironment?.current() ?? synchronousOwner;
27
+ }
28
+ function installDefaultSignalOwner(current) {
29
+ if (typeof current !== "function")
30
+ throw new TypeError(__octaneDev ? "A default signal owner requires a provider." : __octaneNoArgError(190));
31
+ const previous = defaultOwner;
32
+ defaultOwner = current;
33
+ return () => {
34
+ if (defaultOwner === current)
35
+ defaultOwner = previous;
36
+ };
37
+ }
38
+ function runWithSignalOwner(owner, callback) {
39
+ if (typeof callback !== "function")
40
+ throw new TypeError(__octaneDev ? "A signal owner callback is required." : __octaneNoArgError(191));
41
+ if (installedEnvironment)
42
+ return installedEnvironment.run(owner, callback);
43
+ const previous = synchronousOwner;
44
+ synchronousOwner = owner;
45
+ try {
46
+ return callback();
47
+ } finally {
48
+ synchronousOwner = previous;
49
+ }
50
+ }
51
+ function enterSynchronousSignalOwner(owner) {
52
+ if (installedEnvironment !== void 0)
53
+ return void 0;
54
+ const previous = synchronousOwner;
55
+ synchronousOwner = owner;
56
+ return previous;
57
+ }
58
+ function restoreSynchronousSignalOwner(previous) {
59
+ synchronousOwner = previous;
60
+ }
61
+ function captureSignalOwner(owner) {
62
+ return installedEnvironment?.capture(owner) ?? ((callback) => runWithSignalOwner(owner, callback));
63
+ }
64
+ function retireSignalOwnerIdentity(owner) {
65
+ retireOwner?.(owner);
66
+ }
67
+ function installSignalOwnerRetirement(retire) {
68
+ const previous = retireOwner;
69
+ retireOwner = retire;
70
+ return () => {
71
+ if (retireOwner === retire)
72
+ retireOwner = previous;
73
+ };
74
+ }
75
+ export {
76
+ installedEnvironment as activeSignalOwnerEnvironment,
77
+ synchronousOwner as activeSynchronousSignalOwner,
78
+ captureSignalOwner,
79
+ currentExplicitSignalOwner,
80
+ currentSignalOwner,
81
+ enterSynchronousSignalOwner,
82
+ installDefaultSignalOwner,
83
+ installSignalOwnerEnvironment,
84
+ installSignalOwnerRetirement,
85
+ restoreSynchronousSignalOwner,
86
+ retireSignalOwnerIdentity,
87
+ runWithSignalOwner
88
+ };
@@ -0,0 +1,42 @@
1
+ const __octaneDev = process.env.NODE_ENV !== "production";
2
+ function __octaneNoArgError(code) {
3
+ 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.";
4
+ }
5
+ let CURRENT_OBSERVER;
6
+ function runWithServerSignalQueryAttemptObserver(owner, observe, createObservations, callback) {
7
+ const previous = CURRENT_OBSERVER;
8
+ CURRENT_OBSERVER = { owner, observe, createObservations };
9
+ try {
10
+ return callback();
11
+ } finally {
12
+ CURRENT_OBSERVER = previous;
13
+ }
14
+ }
15
+ function serverSignalQueryAttemptObserver(scopeKey) {
16
+ const context = CURRENT_OBSERVER;
17
+ if (context === void 0)
18
+ return;
19
+ const ownerKey = context.owner.documentOwner.scopeKey;
20
+ if (scopeKey !== ownerKey && scopeKey !== `${ownerKey}:instance:${context.owner.instanceKey}`) {
21
+ return;
22
+ }
23
+ if (typeof context.createObservations !== "function") {
24
+ throw new TypeError(__octaneDev ? "A server signal query observer requires an observation factory." : __octaneNoArgError(192));
25
+ }
26
+ return context;
27
+ }
28
+ function hasServerSignalQueryAttemptObserver(scopeKey) {
29
+ return serverSignalQueryAttemptObserver(scopeKey) !== void 0;
30
+ }
31
+ function captureCurrentServerSignalQueryAttemptObserver(scopeKey) {
32
+ const context = serverSignalQueryAttemptObserver(scopeKey);
33
+ if (context === void 0)
34
+ return;
35
+ return (callback) => runWithServerSignalQueryAttemptObserver(context.owner, context.observe, context.createObservations, callback);
36
+ }
37
+ export {
38
+ captureCurrentServerSignalQueryAttemptObserver,
39
+ hasServerSignalQueryAttemptObserver,
40
+ runWithServerSignalQueryAttemptObserver,
41
+ serverSignalQueryAttemptObserver
42
+ };
@@ -0,0 +1,41 @@
1
+ const __octaneDev = process.env.NODE_ENV !== "production";
2
+ import { createResourceCellWith } from "./engine.js";
3
+ import { Descriptor, descriptorKey, signalOptionsKey } from "./facade.js";
4
+ import { runWithSignalOwner } from "./owner-context.js";
5
+ import { initializeResource, query as createQueryRequest } from "./requests.js";
6
+ import { skip } from "./types.js";
7
+ function __octaneNoArgError(code) {
8
+ 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.";
9
+ }
10
+ class QueryDescriptor extends Descriptor {
11
+ refetch() {
12
+ this.resolve().retry();
13
+ }
14
+ reset() {
15
+ this.resolve().retry({ pending: true });
16
+ }
17
+ retry(options) {
18
+ this.resolve().retry(options);
19
+ }
20
+ }
21
+ function __queryAt(site, select, load, options) {
22
+ if (typeof select !== "function" || typeof load !== "function") {
23
+ throw new TypeError(__octaneDev ? "query$ requires selector and loader functions." : __octaneNoArgError(193));
24
+ }
25
+ const explicit = signalOptionsKey(options);
26
+ site ??= explicit;
27
+ const authoredKey = descriptorKey(site, explicit);
28
+ const key = explicit !== void 0 && (site?.startsWith("g:") || site?.startsWith("i:")) ? site.slice(0, 2) + authoredKey : authoredKey;
29
+ const request = createQueryRequest(key, load, options);
30
+ return new QueryDescriptor(key, "async", (owner) => createResourceCellWith(owner, key, () => {
31
+ const selection = runWithSignalOwner(owner, select);
32
+ return selection === skip ? skip : request(selection);
33
+ }, initializeResource), site);
34
+ }
35
+ function query$(select, load, options) {
36
+ return __queryAt(void 0, select, load, options);
37
+ }
38
+ export {
39
+ __queryAt,
40
+ query$
41
+ };
@@ -0,0 +1,125 @@
1
+ import { formatClientError } from "../error-codes.client.generated.js";
2
+ const SIGNAL_DEPENDENT_NODE = /* @__PURE__ */ Symbol("octane.signalDependent");
3
+ const NATIVE_TRANSITION_CONSUMER = /* @__PURE__ */ Symbol("octane.transitionConsumer");
4
+ function forwardNativeTransitionConsumer(notify, wrapped) {
5
+ const consumer = notify[NATIVE_TRANSITION_CONSUMER];
6
+ if (consumer) wrapped[NATIVE_TRANSITION_CONSUMER] = consumer;
7
+ return wrapped;
8
+ }
9
+ let nativeActionResolver;
10
+ let nativeCandidateResolver;
11
+ function registerNativeActionResolver(resolver) {
12
+ nativeActionResolver = resolver;
13
+ }
14
+ function getNativeCandidate() {
15
+ return nativeCandidateResolver === void 0 ? nativeActionResolver?.() : nativeCandidateResolver?.();
16
+ }
17
+ function setNativeCandidateResolver(resolver) {
18
+ const previous = nativeCandidateResolver;
19
+ nativeCandidateResolver = resolver;
20
+ return previous;
21
+ }
22
+ let nativeReadObserver = null;
23
+ let nativeWriteGuarded = false;
24
+ const NATIVE_DOM_VALUE = /* @__PURE__ */ Symbol("octane.nativeDomValue");
25
+ function readNativeDomValue(value) {
26
+ return value !== null && typeof value === "object" && NATIVE_DOM_VALUE in value ? value[NATIVE_DOM_VALUE]() : value;
27
+ }
28
+ function readNativeDomStyle(value) {
29
+ value = readNativeDomValue(value);
30
+ if (value === null || typeof value !== "object") return value;
31
+ const result = /* @__PURE__ */ Object.create(null);
32
+ for (const name in value) result[name] = readNativeDomValue(value[name]);
33
+ return result;
34
+ }
35
+ function readNativeDomProps(props) {
36
+ return "style" in props ? { ...props, style: readNativeDomStyle(props.style) } : props;
37
+ }
38
+ let nativeAdoptionResolver = null;
39
+ class NativeAdoptionMiss extends Error {
40
+ scopeKey;
41
+ nodeKey;
42
+ read;
43
+ constructor(scopeKey, nodeKey, read = "value") {
44
+ super(formatClientError(194, read, scopeKey, nodeKey));
45
+ this.name = "NativeAdoptionMiss";
46
+ this.scopeKey = scopeKey;
47
+ this.nodeKey = nodeKey;
48
+ this.read = read;
49
+ }
50
+ }
51
+ function getNativeAdoptionResolver() {
52
+ return nativeAdoptionResolver;
53
+ }
54
+ function setNativeAdoptionResolver(resolver) {
55
+ const previous = nativeAdoptionResolver;
56
+ nativeAdoptionResolver = resolver;
57
+ return previous;
58
+ }
59
+ let nativeBatchHooks = null;
60
+ function registerNativeBatchHooks(hooks) {
61
+ nativeBatchHooks = hooks;
62
+ }
63
+ function beginNativeBatch() {
64
+ const hooks = nativeBatchHooks;
65
+ hooks?.startBatch();
66
+ return hooks;
67
+ }
68
+ function endNativeBatch(hooks) {
69
+ hooks?.endBatch();
70
+ }
71
+ function runNativeBatch(callback) {
72
+ const hooks = beginNativeBatch();
73
+ try {
74
+ return callback();
75
+ } finally {
76
+ endNativeBatch(hooks);
77
+ }
78
+ }
79
+ function reportNativeRead(source, version) {
80
+ nativeReadObserver?.(source, version);
81
+ }
82
+ function getNativeReadObserver() {
83
+ return nativeReadObserver;
84
+ }
85
+ function setNativeReadObserver(observer) {
86
+ const previous = nativeReadObserver;
87
+ nativeReadObserver = observer;
88
+ return previous;
89
+ }
90
+ function beginNativeWriteGuard() {
91
+ const previous = nativeWriteGuarded;
92
+ nativeWriteGuarded = true;
93
+ return previous;
94
+ }
95
+ function endNativeWriteGuard(previous) {
96
+ nativeWriteGuarded = previous;
97
+ }
98
+ function isNativeWriteGuarded() {
99
+ return nativeWriteGuarded;
100
+ }
101
+ export {
102
+ NATIVE_DOM_VALUE,
103
+ NATIVE_TRANSITION_CONSUMER,
104
+ NativeAdoptionMiss,
105
+ SIGNAL_DEPENDENT_NODE,
106
+ beginNativeBatch,
107
+ beginNativeWriteGuard,
108
+ endNativeBatch,
109
+ endNativeWriteGuard,
110
+ forwardNativeTransitionConsumer,
111
+ getNativeAdoptionResolver,
112
+ getNativeCandidate,
113
+ getNativeReadObserver,
114
+ isNativeWriteGuarded,
115
+ readNativeDomProps,
116
+ readNativeDomStyle,
117
+ readNativeDomValue,
118
+ registerNativeActionResolver,
119
+ registerNativeBatchHooks,
120
+ reportNativeRead,
121
+ runNativeBatch,
122
+ setNativeAdoptionResolver,
123
+ setNativeCandidateResolver,
124
+ setNativeReadObserver
125
+ };