@octane-xplat/patches 0.0.1 → 0.9.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.
- package/LICENSE +21 -0
- package/README.md +8 -1
- package/package.json +16 -10
- package/patches/@nativescript-community__octane@0.2.4.patch +25 -0
- package/patches/@nativescript-community__vite-octane@0.2.1.patch +41 -0
- package/patches/@nativescript__core@9.1.2.patch +1415 -0
- package/patches/@nativescript__core@9.1.3-next.2.patch +428 -0
- package/patches/@nativescript__types@9.0.0.patch +93 -0
- package/patches/@nativescript__vite@8.0.13.patch +233 -0
- package/patches/@nativescript__vite@8.0.17.patch +220 -0
- package/patches/@octanejs__tiptap@0.0.51.patch +78 -0
- package/patches/@tsrx__typescript-plugin@0.4.11.patch +11 -0
- package/patches/css@3.0.0.patch +52 -0
- package/patches/linkifyjs@4.3.3.patch +73 -0
- package/patches/octane@0.6.3.patch +1307 -0
- package/index.d.ts +0 -1
- package/index.js +0 -2
|
@@ -0,0 +1,1307 @@
|
|
|
1
|
+
diff --git a/dist/cjs/runtime.cjs b/dist/cjs/runtime.cjs
|
|
2
|
+
index 6f4f11cafea50ca0de062aace3426df371a44867..dc96ffaa91081ca81f904de35ed5db9a024daa96 100644
|
|
3
|
+
--- a/dist/cjs/runtime.cjs
|
|
4
|
+
+++ b/dist/cjs/runtime.cjs
|
|
5
|
+
@@ -354,6 +354,7 @@ var import_stream_protocol = require("./stream-protocol.cjs");
|
|
6
|
+
var import_renderer_bridge = require("./renderer-bridge.cjs");
|
|
7
|
+
var import_context_identity = require("./context-identity.cjs");
|
|
8
|
+
var import_native_read_client = require("./signals/native-read-client.cjs");
|
|
9
|
+
+var import_local_hook = require("./signals/local-hook.cjs");
|
|
10
|
+
var import_native_read_collector = require("./signals/native-read-collector.cjs");
|
|
11
|
+
var import_native_read_retry = require("./signals/native-read-retry.cjs");
|
|
12
|
+
var import_transition_state = require("./signals/transition-state.cjs");
|
|
13
|
+
@@ -7604,6 +7605,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
|
|
14
|
+
}
|
|
15
|
+
return cell.nativeValue;
|
|
16
|
+
}
|
|
17
|
+
+(0, import_local_hook.registerLocalSignalHook)(() => CURRENT_SCOPE === null ? null : nativeLocalHook);
|
|
18
|
+
function useState(initial, slot) {
|
|
19
|
+
const s = readStateHook(initial, slot, arguments.length === 1);
|
|
20
|
+
return [s.value, s.setter];
|
|
21
|
+
diff --git a/dist/cjs/signals/client.cjs b/dist/cjs/signals/client.cjs
|
|
22
|
+
index 28e28444192dee7af64351cfe02d5dde96658832..af40518defca21eb88707eb76bb6fe10c1d266e7 100644
|
|
23
|
+
--- a/dist/cjs/signals/client.cjs
|
|
24
|
+
+++ b/dist/cjs/signals/client.cjs
|
|
25
|
+
@@ -23,13 +23,13 @@ __export(client_exports, {
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(client_exports);
|
|
28
|
+
__reExport(client_exports, require("./index.cjs"), module.exports);
|
|
29
|
+
-var import_runtime = require("../runtime.cjs");
|
|
30
|
+
var import_engine = require("./engine.cjs");
|
|
31
|
+
+var import_local_hook = require("./local-hook.cjs");
|
|
32
|
+
function disposeLocalSignal(cell) {
|
|
33
|
+
cell.scope.dispose();
|
|
34
|
+
}
|
|
35
|
+
function useSignal$(initial, slot) {
|
|
36
|
+
- const cell = (0, import_runtime.nativeLocalHook)(
|
|
37
|
+
+ const cell = (0, import_local_hook.localSignalHook)(
|
|
38
|
+
"useSignal$",
|
|
39
|
+
() => {
|
|
40
|
+
const value = typeof initial === "function" ? initial() : initial;
|
|
41
|
+
diff --git a/dist/cjs/signals/document-owner.cjs b/dist/cjs/signals/document-owner.cjs
|
|
42
|
+
index ea6b3040bcc3d1fe0c600894af33fece59711d4b..56a74394b0e40f0ca1dc9b1afb1b44e5a695994f 100644
|
|
43
|
+
--- a/dist/cjs/signals/document-owner.cjs
|
|
44
|
+
+++ b/dist/cjs/signals/document-owner.cjs
|
|
45
|
+
@@ -54,7 +54,9 @@ function enableSignalDocument(abi = 1) {
|
|
46
|
+
if (defaultInstalled)
|
|
47
|
+
return;
|
|
48
|
+
defaultInstalled = true;
|
|
49
|
+
- (0, import_owner_context.installDefaultSignalOwner)(() => typeof document === "undefined" ? null : documentSignalOwner(document));
|
|
50
|
+
+ if (typeof document === "undefined")
|
|
51
|
+
+ return;
|
|
52
|
+
+ (0, import_owner_context.installDefaultSignalOwner)(() => documentSignalOwner(document));
|
|
53
|
+
}
|
|
54
|
+
function installStreamedSignalOwnerActivator(activate) {
|
|
55
|
+
if (streamedSignalOwnerActivator !== void 0) {
|
|
56
|
+
diff --git a/dist/cjs/signals/facade.cjs b/dist/cjs/signals/facade.cjs
|
|
57
|
+
index 9da71c1a774d4764d6e34df12211a08ae2817d5c..02db86c39e23717e0fedb83eb7faf62e4cca7780 100644
|
|
58
|
+
--- a/dist/cjs/signals/facade.cjs
|
|
59
|
+
+++ b/dist/cjs/signals/facade.cjs
|
|
60
|
+
@@ -283,6 +283,8 @@ class Descriptor {
|
|
61
|
+
this.kind = kind;
|
|
62
|
+
this.create = create;
|
|
63
|
+
this.site = site;
|
|
64
|
+
+ // Instance declarations stay with their component across child templates and events.
|
|
65
|
+
+ this.instanceOwner = site?.startsWith("i:") ? (0, import_owner_context.currentSignalOwner)() : null;
|
|
66
|
+
}
|
|
67
|
+
key;
|
|
68
|
+
kind;
|
|
69
|
+
@@ -292,7 +294,7 @@ class Descriptor {
|
|
70
|
+
cells = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
[import_types.SIGNAL_OWNER_RESOLVE](owner) {
|
|
72
|
+
requireSite(this.site);
|
|
73
|
+
- return this.resolvedCell(resolveDescriptorOwner(this.site, owner));
|
|
74
|
+
+ return this.resolvedCell(resolveDescriptorOwner(this.site, this.instanceOwner ?? owner));
|
|
75
|
+
}
|
|
76
|
+
resolvedCell(target) {
|
|
77
|
+
let cell = this.cells.get(target);
|
|
78
|
+
@@ -303,7 +305,7 @@ class Descriptor {
|
|
79
|
+
return cell;
|
|
80
|
+
}
|
|
81
|
+
resolve() {
|
|
82
|
+
- const token = requireOwner();
|
|
83
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
84
|
+
const owner = resolveDescriptorOwner(this.site, token);
|
|
85
|
+
requireSite(this.site);
|
|
86
|
+
return this.resolvedCell(owner);
|
|
87
|
+
@@ -334,7 +336,7 @@ class Descriptor {
|
|
88
|
+
return this.resolve().snapshot();
|
|
89
|
+
}
|
|
90
|
+
subscribe(notify) {
|
|
91
|
+
- const token = requireOwner();
|
|
92
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
93
|
+
const scope = resolveDescriptorOwner(this.site, token);
|
|
94
|
+
const run = (0, import_owner_context.captureSignalOwner)(token);
|
|
95
|
+
return this[import_types.SIGNAL_OWNER_RESOLVE](scope).subscribe((0, import_read_protocol.forwardNativeTransitionConsumer)(notify, () => run(notify)));
|
|
96
|
+
diff --git a/dist/cjs/signals/index.cjs b/dist/cjs/signals/index.cjs
|
|
97
|
+
index 865afcf87d84f0cc319d65145b246c9c033927aa..08dd675a49a50c1621e5d3c5a26ca22f8cdbb31d 100644
|
|
98
|
+
--- a/dist/cjs/signals/index.cjs
|
|
99
|
+
+++ b/dist/cjs/signals/index.cjs
|
|
100
|
+
@@ -34,6 +34,7 @@ __export(signals_exports, {
|
|
101
|
+
__derivedAt: () => import_derived_facade.__derivedAt,
|
|
102
|
+
__derivedScalarAt: () => import_facade.__derivedScalarAt,
|
|
103
|
+
__enableSignalDocument: () => import_document_owner.enableSignalDocument,
|
|
104
|
+
+ __enableUniversalSignalDocument: () => import_universal_owner.enableUniversalSignalDocument,
|
|
105
|
+
__queryAt: () => import_query_facade.__queryAt,
|
|
106
|
+
__signalAt: () => import_facade.__signalAt,
|
|
107
|
+
__startSignalReads: () => import_facade.__startSignalReads,
|
|
108
|
+
@@ -65,6 +66,7 @@ module.exports = __toCommonJS(signals_exports);
|
|
109
|
+
var import_engine = require("./engine.cjs");
|
|
110
|
+
var import_control_binding = require("./control-binding.cjs");
|
|
111
|
+
var import_document_owner = require("./document-owner.cjs");
|
|
112
|
+
+var import_universal_owner = require("./universal-owner.cjs");
|
|
113
|
+
var import_requests = require("./requests.cjs");
|
|
114
|
+
var import_actions = require("./actions.cjs");
|
|
115
|
+
var import_derived_facade = require("./derived-facade.cjs");
|
|
116
|
+
@@ -92,6 +94,7 @@ var import_types = require("./types.cjs");
|
|
117
|
+
__derivedAt,
|
|
118
|
+
__derivedScalarAt,
|
|
119
|
+
__enableSignalDocument,
|
|
120
|
+
+ __enableUniversalSignalDocument,
|
|
121
|
+
__queryAt,
|
|
122
|
+
__signalAt,
|
|
123
|
+
__startSignalReads,
|
|
124
|
+
diff --git a/dist/cjs/signals/local-hook.cjs b/dist/cjs/signals/local-hook.cjs
|
|
125
|
+
new file mode 100644
|
|
126
|
+
index 0000000000000000000000000000000000000000..4858595ce50e97284f18daa94c3b5ce6ab041dd4
|
|
127
|
+
--- /dev/null
|
|
128
|
+
+++ b/dist/cjs/signals/local-hook.cjs
|
|
129
|
+
@@ -0,0 +1,44 @@
|
|
130
|
+
+"use strict";
|
|
131
|
+
+var __defProp = Object.defineProperty;
|
|
132
|
+
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
133
|
+
+var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
134
|
+
+var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
135
|
+
+var __export = (target, all) => {
|
|
136
|
+
+ for (var name in all)
|
|
137
|
+
+ __defProp(target, name, { get: all[name], enumerable: true });
|
|
138
|
+
+};
|
|
139
|
+
+var __copyProps = (to, from, except, desc) => {
|
|
140
|
+
+ if (from && typeof from === "object" || typeof from === "function") {
|
|
141
|
+
+ for (let key of __getOwnPropNames(from))
|
|
142
|
+
+ if (!__hasOwnProp.call(to, key) && key !== except)
|
|
143
|
+
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
144
|
+
+ }
|
|
145
|
+
+ return to;
|
|
146
|
+
+};
|
|
147
|
+
+var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
148
|
+
+var local_hook_exports = {};
|
|
149
|
+
+__export(local_hook_exports, {
|
|
150
|
+
+ localSignalHook: () => localSignalHook,
|
|
151
|
+
+ registerLocalSignalHook: () => registerLocalSignalHook
|
|
152
|
+
+});
|
|
153
|
+
+module.exports = __toCommonJS(local_hook_exports);
|
|
154
|
+
+const probes = [];
|
|
155
|
+
+function registerLocalSignalHook(probe) {
|
|
156
|
+
+ probes.push(probe);
|
|
157
|
+
+ return () => {
|
|
158
|
+
+ const index = probes.indexOf(probe);
|
|
159
|
+
+ if (index !== -1) probes.splice(index, 1);
|
|
160
|
+
+ };
|
|
161
|
+
+}
|
|
162
|
+
+function localSignalHook(name, initialize, dispose, slot) {
|
|
163
|
+
+ for (let index = probes.length - 1; index >= 0; index--) {
|
|
164
|
+
+ const hook = probes[index]();
|
|
165
|
+
+ if (hook !== null) return hook(name, initialize, dispose, slot);
|
|
166
|
+
+ }
|
|
167
|
+
+ throw new Error(`${name} requires an active Octane component render.`);
|
|
168
|
+
+}
|
|
169
|
+
+// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
+0 && (module.exports = {
|
|
171
|
+
+ localSignalHook,
|
|
172
|
+
+ registerLocalSignalHook
|
|
173
|
+
+});
|
|
174
|
+
diff --git a/dist/cjs/signals/universal-owner.cjs b/dist/cjs/signals/universal-owner.cjs
|
|
175
|
+
new file mode 100644
|
|
176
|
+
index 0000000000000000000000000000000000000000..00c323a8bd4453d566dbd002ab1222f03def2760
|
|
177
|
+
--- /dev/null
|
|
178
|
+
+++ b/dist/cjs/signals/universal-owner.cjs
|
|
179
|
+
@@ -0,0 +1,46 @@
|
|
180
|
+
+"use strict";
|
|
181
|
+
+var __defProp = Object.defineProperty;
|
|
182
|
+
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
183
|
+
+var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
184
|
+
+var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
185
|
+
+var __export = (target, all) => {
|
|
186
|
+
+ for (var name in all)
|
|
187
|
+
+ __defProp(target, name, { get: all[name], enumerable: true });
|
|
188
|
+
+};
|
|
189
|
+
+var __copyProps = (to, from, except, desc) => {
|
|
190
|
+
+ if (from && typeof from === "object" || typeof from === "function") {
|
|
191
|
+
+ for (let key of __getOwnPropNames(from))
|
|
192
|
+
+ if (!__hasOwnProp.call(to, key) && key !== except)
|
|
193
|
+
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
194
|
+
+ }
|
|
195
|
+
+ return to;
|
|
196
|
+
+};
|
|
197
|
+
+var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
198
|
+
+var universal_owner_exports = {};
|
|
199
|
+
+__export(universal_owner_exports, {
|
|
200
|
+
+ enableUniversalSignalDocument: () => enableUniversalSignalDocument,
|
|
201
|
+
+ installUniversalSignalDocumentProvider: () => installUniversalSignalDocumentProvider,
|
|
202
|
+
+ universalSignalDocument: () => universalSignalDocument
|
|
203
|
+
+});
|
|
204
|
+
+module.exports = __toCommonJS(universal_owner_exports);
|
|
205
|
+
+var import_owner_context = require("./owner-context.cjs");
|
|
206
|
+
+let universalOwner;
|
|
207
|
+
+let provider;
|
|
208
|
+
+function installUniversalSignalDocumentProvider(next) {
|
|
209
|
+
+ provider = next;
|
|
210
|
+
+}
|
|
211
|
+
+function universalSignalDocument() {
|
|
212
|
+
+ return provider?.() ?? (universalOwner ??= Object.freeze({ scopeKey: "octane:universal" }));
|
|
213
|
+
+}
|
|
214
|
+
+function enableUniversalSignalDocument(abi = 1) {
|
|
215
|
+
+ if (abi !== 1) {
|
|
216
|
+
+ throw new TypeError("Unsupported universal signal owner ABI.");
|
|
217
|
+
+ }
|
|
218
|
+
+ (0, import_owner_context.installDefaultSignalOwner)(universalSignalDocument);
|
|
219
|
+
+}
|
|
220
|
+
+// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
+0 && (module.exports = {
|
|
222
|
+
+ enableUniversalSignalDocument,
|
|
223
|
+
+ installUniversalSignalDocumentProvider,
|
|
224
|
+
+ universalSignalDocument
|
|
225
|
+
+});
|
|
226
|
+
diff --git a/dist/compiler/compile-universal.js b/dist/compiler/compile-universal.js
|
|
227
|
+
index fb05864726848fec0e680cc06de3cfe88f9930de..e1ae8e2314f2cc61a7a6cbd38ae0fadea8aa08bf 100644
|
|
228
|
+
--- a/dist/compiler/compile-universal.js
|
|
229
|
+
+++ b/dist/compiler/compile-universal.js
|
|
230
|
+
@@ -2658,6 +2658,15 @@ function hasOwnTemplateReturn(fn) {
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function componentRender(fn, state, force = false) {
|
|
234
|
+
+ // Functions that are never invoked as components stay ordinary functions,
|
|
235
|
+
+ // so an async/generator helper only fails once it is actually compiled as
|
|
236
|
+
+ // one (the `@{ … }` form, a JSX-shaped return, or component usage).
|
|
237
|
+
+ const component =
|
|
238
|
+
+ fn.body?.type === 'JSXCodeBlock' ||
|
|
239
|
+
+ (fn.body?.type !== 'BlockStatement'
|
|
240
|
+
+ ? force || isTemplateNode(fn.body)
|
|
241
|
+
+ : force || hasOwnTemplateReturn(fn) || state.componentNames.has(functionName(fn)));
|
|
242
|
+
+ if (!component) return null;
|
|
243
|
+
if (fn.async || fn.generator) {
|
|
244
|
+
throw universalError(
|
|
245
|
+
state.filename,
|
|
246
|
+
@@ -2672,11 +2681,8 @@ function componentRender(fn, state, force = false) {
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (fn.body?.type !== 'BlockStatement') {
|
|
250
|
+
- if (!force && !isTemplateNode(fn.body)) return null;
|
|
251
|
+
return { setup: [], render: isTemplateNode(fn.body) ? fn.body : null, expression: fn.body };
|
|
252
|
+
}
|
|
253
|
+
- if (!force && !hasOwnTemplateReturn(fn) && !state.componentNames.has(functionName(fn)))
|
|
254
|
+
- return null;
|
|
255
|
+
return { setup: fn.body.body ?? [], render: null };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
diff --git a/dist/compiler/compile.js b/dist/compiler/compile.js
|
|
259
|
+
index cdf5a08e96946bf06dd417dcfb87373e4be5f305..64a357159586e45774ff864f4478b204bb0dd7ab 100644
|
|
260
|
+
--- a/dist/compiler/compile.js
|
|
261
|
+
+++ b/dist/compiler/compile.js
|
|
262
|
+
@@ -2275,7 +2275,7 @@ function classifyViewTransitionOwnership(astBody, production, ownComponents) {
|
|
263
|
+
|
|
264
|
+
function hookRuntimeModulesForCompile(options, universalUnits = []) {
|
|
265
|
+
const modules = new Set(options?.__hookRuntimeModules || []);
|
|
266
|
+
- if (options?.nativeReads === true) {
|
|
267
|
+
+ if (options?.nativeReads === true || options?.__universalSignalReads === true) {
|
|
268
|
+
modules.add('octane/signals/client');
|
|
269
|
+
modules.add('octane/signals/server');
|
|
270
|
+
}
|
|
271
|
+
@@ -10112,6 +10112,11 @@ function compileInternal(
|
|
272
|
+
universalRuntime: undefined,
|
|
273
|
+
rendererBoundaries: undefined,
|
|
274
|
+
rendererRegistry: undefined,
|
|
275
|
+
+ // Universal owners observe reads at render time; the inner
|
|
276
|
+
+ // compile must not emit the DOM native-read runtime helpers,
|
|
277
|
+
+ // but signal hook classification still applies.
|
|
278
|
+
+ nativeReads: false,
|
|
279
|
+
+ __universalSignalReads: options.nativeReads === true,
|
|
280
|
+
__hookRuntimeModules: [...(options?.__hookRuntimeModules || []), renderer.module],
|
|
281
|
+
__runtimeImportRoutes: [
|
|
282
|
+
...(options?.__runtimeImportRoutes ?? []),
|
|
283
|
+
@@ -10360,6 +10365,10 @@ function compileInternal(
|
|
284
|
+
autoMemo: autoMemoEnabled,
|
|
285
|
+
strongMemo: strongMemoEnabled,
|
|
286
|
+
nativeReads: options?.nativeReads === true,
|
|
287
|
+
+ // Universal renders observe signal reads at runtime through the owner
|
|
288
|
+
+ // environment; hook classification still needs to know the module imports
|
|
289
|
+
+ // the signals runtime even though no DOM native-read helpers are emitted.
|
|
290
|
+
+ signalReads: options?.nativeReads === true || options?.__universalSignalReads === true,
|
|
291
|
+
nativeModuleStyles: options?.nativeReads === true && hasModuleStyleMaps(ast.body),
|
|
292
|
+
// A split Hydrate query module is invoked as the existing server-rendered
|
|
293
|
+
// boundary body. Its sole component child must therefore keep the server's
|
|
294
|
+
@@ -11805,6 +11814,10 @@ function compileServer(
|
|
295
|
+
compilerNameSuffixes: null,
|
|
296
|
+
mode: 'server',
|
|
297
|
+
nativeReads: options?.nativeReads === true,
|
|
298
|
+
+ // Universal renders observe signal reads at runtime through the owner
|
|
299
|
+
+ // environment; hook classification still needs to know the module imports
|
|
300
|
+
+ // the signals runtime even though no DOM native-read helpers are emitted.
|
|
301
|
+
+ signalReads: options?.nativeReads === true || options?.__universalSignalReads === true,
|
|
302
|
+
nativeModuleStyles: options?.nativeReads === true && hasModuleStyleMaps(ast.body),
|
|
303
|
+
hmr: false, // SSR never hot-swaps in place; client/server production slot shapes stay aligned
|
|
304
|
+
dev: !!(options && options.dev),
|
|
305
|
+
@@ -18960,7 +18973,7 @@ function slotKeyedHookName(n, ctx) {
|
|
306
|
+
ctx.foreignImportLocals?.has(local) === true;
|
|
307
|
+
if (
|
|
308
|
+
imported !== undefined &&
|
|
309
|
+
- (HOOK_NAMES.has(imported) || (ctx.nativeReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
310
|
+
+ (HOOK_NAMES.has(imported) || (ctx.signalReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
311
|
+
)
|
|
312
|
+
return imported;
|
|
313
|
+
if (!shadowsImport && HOOK_NAMES.has(local)) return local;
|
|
314
|
+
@@ -18970,7 +18983,7 @@ function slotKeyedHookName(n, ctx) {
|
|
315
|
+
const imported = n._octaneImportedHook ?? n._octaneHookRuntimeImportedHook;
|
|
316
|
+
if (
|
|
317
|
+
imported !== undefined &&
|
|
318
|
+
- (HOOK_NAMES.has(imported) || (ctx.nativeReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
319
|
+
+ (HOOK_NAMES.has(imported) || (ctx.signalReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
320
|
+
) {
|
|
321
|
+
return imported;
|
|
322
|
+
}
|
|
323
|
+
@@ -19817,7 +19830,7 @@ function rewriteHookCalls(node, ctx, componentName, localRoot = false) {
|
|
324
|
+
// enforced by rejectHookInJsLoop.
|
|
325
|
+
const isBuiltin =
|
|
326
|
+
(HOOK_NAMES.has(name) ||
|
|
327
|
+
- (ctx.nativeReads &&
|
|
328
|
+
+ (ctx.signalReads &&
|
|
329
|
+
hookRuntimeImportedName !== undefined &&
|
|
330
|
+
NATIVE_SIGNAL_HOOK_NAMES.has(name))) &&
|
|
331
|
+
(generated ||
|
|
332
|
+
@@ -19946,7 +19959,7 @@ function rewriteHookCalls(node, ctx, componentName, localRoot = false) {
|
|
333
|
+
) {
|
|
334
|
+
const name = n._octaneImportedHook ?? n._octaneHookRuntimeImportedHook;
|
|
335
|
+
const isBuiltin =
|
|
336
|
+
- HOOK_NAMES.has(name) || (ctx.nativeReads && NATIVE_SIGNAL_HOOK_NAMES.has(name));
|
|
337
|
+
+ HOOK_NAMES.has(name) || (ctx.signalReads && NATIVE_SIGNAL_HOOK_NAMES.has(name));
|
|
338
|
+
const isServerUse = name === 'use' && ctx.mode === 'server';
|
|
339
|
+
if (isBuiltin || isServerUse) {
|
|
340
|
+
if (isBuiltin) {
|
|
341
|
+
diff --git a/dist/compiler/native-read-diagnostics.js b/dist/compiler/native-read-diagnostics.js
|
|
342
|
+
index 3ec74f384e5b34a8032c96646e9ba3faeee50e75..0816e98d66d5082d8d3bb337073c2123e6032c4c 100644
|
|
343
|
+
--- a/dist/compiler/native-read-diagnostics.js
|
|
344
|
+
+++ b/dist/compiler/native-read-diagnostics.js
|
|
345
|
+
@@ -87,9 +87,12 @@ export function assertNativeReadOptions(options) {
|
|
346
|
+
if (
|
|
347
|
+
options?.nativeReads === true &&
|
|
348
|
+
options.renderer?.target != null &&
|
|
349
|
+
- options.renderer.target !== 'dom'
|
|
350
|
+
+ options.renderer.target !== 'dom' &&
|
|
351
|
+
+ options.renderer.target !== 'universal'
|
|
352
|
+
) {
|
|
353
|
+
- throw new Error('Octane native signal reads support only the DOM client and server.');
|
|
354
|
+
+ throw new Error(
|
|
355
|
+
+ 'Octane native signal reads support only the DOM client, DOM server, and universal renderers.',
|
|
356
|
+
+ );
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
@@ -108,11 +111,11 @@ export function analyzeNativeReadDiagnostics(ast, source, filename, options = {}
|
|
361
|
+
filename,
|
|
362
|
+
rendererBoundaries: options.rendererBoundaries,
|
|
363
|
+
});
|
|
364
|
+
- const unsupported = boundaries.find(
|
|
365
|
+
- (boundary) =>
|
|
366
|
+
- boundary.childRenderer !== 'dom' &&
|
|
367
|
+
- options.rendererRegistry?.[boundary.childRenderer]?.target !== 'dom',
|
|
368
|
+
- );
|
|
369
|
+
+ const unsupported = boundaries.find((boundary) => {
|
|
370
|
+
+ if (boundary.childRenderer === 'dom') return false;
|
|
371
|
+
+ const target = options.rendererRegistry?.[boundary.childRenderer]?.target;
|
|
372
|
+
+ return target !== 'dom' && target !== 'universal';
|
|
373
|
+
+ });
|
|
374
|
+
if (unsupported)
|
|
375
|
+
return [
|
|
376
|
+
nativeReadDiagnostic(
|
|
377
|
+
diff --git a/dist/compiler/slot-hooks.js b/dist/compiler/slot-hooks.js
|
|
378
|
+
index 7b2f867538a166ebaf3d1a8aa6e7d910e3b0da12..2c1d36c9edb32c483a5e7ed736e51b0ca12cde30 100644
|
|
379
|
+
--- a/dist/compiler/slot-hooks.js
|
|
380
|
+
+++ b/dist/compiler/slot-hooks.js
|
|
381
|
+
@@ -1182,12 +1182,12 @@ function walk(node, owner, st) {
|
|
382
|
+
}
|
|
383
|
+
const imported =
|
|
384
|
+
node._octaneImportedHook ??
|
|
385
|
+
- (st.nativeReads ? node._octaneHookRuntimeImportedHook : undefined);
|
|
386
|
+
+ (st.signalReads ? node._octaneHookRuntimeImportedHook : undefined);
|
|
387
|
+
collectStateGetterEdit(node, imported, st);
|
|
388
|
+
if (
|
|
389
|
+
!st.manualSlots &&
|
|
390
|
+
imported &&
|
|
391
|
+
- (HOOK_NAMES.has(imported) || (st.nativeReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
392
|
+
+ (HOOK_NAMES.has(imported) || (st.signalReads && NATIVE_SIGNAL_HOOK_NAMES.has(imported)))
|
|
393
|
+
) {
|
|
394
|
+
const local =
|
|
395
|
+
node.callee?.type === 'Identifier'
|
|
396
|
+
@@ -1398,7 +1398,11 @@ export function slotHooks(source, id, options) {
|
|
397
|
+
HOOK_NAMES.has(name),
|
|
398
|
+
);
|
|
399
|
+
const manualProviders = options?.manualSlots ? findManualHookProviders(ast) : new Map();
|
|
400
|
+
- const nativeReadActivation = options?.nativeReads === true && importsNativeRenderer(ast);
|
|
401
|
+
+ // Universal renderers observe reads at render time; the DOM collection
|
|
402
|
+
+ // driver and its activation helper only apply to dom targets.
|
|
403
|
+
+ const universalTarget = options?.renderer?.target === 'universal';
|
|
404
|
+
+ const nativeReadActivation =
|
|
405
|
+
+ options?.nativeReads === true && !universalTarget && importsNativeRenderer(ast);
|
|
406
|
+
const signalLowering = signalDeclarationSourceEdits(ast, id, source);
|
|
407
|
+
const pureCalls = collectPureFactoryCalls(
|
|
408
|
+
ast,
|
|
409
|
+
@@ -1487,7 +1491,8 @@ export function slotHooks(source, id, options) {
|
|
410
|
+
]),
|
|
411
|
+
),
|
|
412
|
+
manualSlots: options?.manualSlots === true,
|
|
413
|
+
- nativeReads: options?.nativeReads === true,
|
|
414
|
+
+ nativeReads: options?.nativeReads === true && !universalTarget,
|
|
415
|
+
+ signalReads: options?.nativeReads === true,
|
|
416
|
+
locals: importInfo.locals,
|
|
417
|
+
source,
|
|
418
|
+
inferred,
|
|
419
|
+
@@ -1590,7 +1595,9 @@ export function slotHooks(source, id, options) {
|
|
420
|
+
? 'enableServerSignalBindings'
|
|
421
|
+
: nativeReadActivation
|
|
422
|
+
? 'enableSignalBindings'
|
|
423
|
+
- : '__enableSignalDocument';
|
|
424
|
+
+ : universalTarget
|
|
425
|
+
+ ? '__enableUniversalSignalDocument'
|
|
426
|
+
+ : '__enableSignalDocument';
|
|
427
|
+
const local = allocSlotName(st, `_$${imported}`);
|
|
428
|
+
let specifiers = signalHelperImports.get(request);
|
|
429
|
+
if (specifiers === undefined) signalHelperImports.set(request, (specifiers = []));
|
|
430
|
+
diff --git a/dist/node/runtime.js b/dist/node/runtime.js
|
|
431
|
+
index 21d10d95b6094ee07693a8b0757ca381d706b86e..2a0b4204dbcc6a0a749fcdbecfe93241d73dd768 100644
|
|
432
|
+
--- a/dist/node/runtime.js
|
|
433
|
+
+++ b/dist/node/runtime.js
|
|
434
|
+
@@ -162,6 +162,7 @@ import {
|
|
435
|
+
import { isRendererContext, registerClientRendererBridge } from "./renderer-bridge.js";
|
|
436
|
+
import { defineRemovedContextMembers, registerContext } from "./context-identity.js";
|
|
437
|
+
import { createNativeReadDriver } from "./signals/native-read-client.js";
|
|
438
|
+
+import { registerLocalSignalHook } from "./signals/local-hook.js";
|
|
439
|
+
import {
|
|
440
|
+
validateNativeReadWitness
|
|
441
|
+
} from "./signals/native-read-collector.js";
|
|
442
|
+
@@ -7456,6 +7457,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
|
|
443
|
+
}
|
|
444
|
+
return cell.nativeValue;
|
|
445
|
+
}
|
|
446
|
+
+registerLocalSignalHook(() => CURRENT_SCOPE === null ? null : nativeLocalHook);
|
|
447
|
+
function useState(initial, slot) {
|
|
448
|
+
const s = readStateHook(initial, slot, arguments.length === 1);
|
|
449
|
+
return [s.value, s.setter];
|
|
450
|
+
diff --git a/dist/node/signals/client.js b/dist/node/signals/client.js
|
|
451
|
+
index 21a39c3ce9a28d2095e276fd647fd795e939a0bf..3f85700b57cbc3084c2df776ab3e6b5365f091a8 100644
|
|
452
|
+
--- a/dist/node/signals/client.js
|
|
453
|
+
+++ b/dist/node/signals/client.js
|
|
454
|
+
@@ -1,11 +1,11 @@
|
|
455
|
+
export * from "./index.js";
|
|
456
|
+
-import { nativeLocalHook } from "../runtime.js";
|
|
457
|
+
import { createLocalScope } from "./engine.js";
|
|
458
|
+
+import { localSignalHook } from "./local-hook.js";
|
|
459
|
+
function disposeLocalSignal(cell) {
|
|
460
|
+
cell.scope.dispose();
|
|
461
|
+
}
|
|
462
|
+
function useSignal$(initial, slot) {
|
|
463
|
+
- const cell = nativeLocalHook(
|
|
464
|
+
+ const cell = localSignalHook(
|
|
465
|
+
"useSignal$",
|
|
466
|
+
() => {
|
|
467
|
+
const value = typeof initial === "function" ? initial() : initial;
|
|
468
|
+
diff --git a/dist/node/signals/document-owner.js b/dist/node/signals/document-owner.js
|
|
469
|
+
index 0decc9286f8d06e78dd15eaa16d0cc53cac44220..59a94863274839675c48880bf37018fddd00ec11 100644
|
|
470
|
+
--- a/dist/node/signals/document-owner.js
|
|
471
|
+
+++ b/dist/node/signals/document-owner.js
|
|
472
|
+
@@ -27,7 +27,9 @@ function enableSignalDocument(abi = 1) {
|
|
473
|
+
if (defaultInstalled)
|
|
474
|
+
return;
|
|
475
|
+
defaultInstalled = true;
|
|
476
|
+
- installDefaultSignalOwner(() => typeof document === "undefined" ? null : documentSignalOwner(document));
|
|
477
|
+
+ if (typeof document === "undefined")
|
|
478
|
+
+ return;
|
|
479
|
+
+ installDefaultSignalOwner(() => documentSignalOwner(document));
|
|
480
|
+
}
|
|
481
|
+
function installStreamedSignalOwnerActivator(activate) {
|
|
482
|
+
if (streamedSignalOwnerActivator !== void 0) {
|
|
483
|
+
diff --git a/dist/node/signals/facade.js b/dist/node/signals/facade.js
|
|
484
|
+
index 86c0233dad7013c6516912656e0e1b304351c1cb..594e697b59f19e95821ed09313835842a7afe33e 100644
|
|
485
|
+
--- a/dist/node/signals/facade.js
|
|
486
|
+
+++ b/dist/node/signals/facade.js
|
|
487
|
+
@@ -241,6 +241,8 @@ class Descriptor {
|
|
488
|
+
this.kind = kind;
|
|
489
|
+
this.create = create;
|
|
490
|
+
this.site = site;
|
|
491
|
+
+ // Instance declarations stay with their component across child templates and events.
|
|
492
|
+
+ this.instanceOwner = site?.startsWith("i:") ? currentSignalOwner() : null;
|
|
493
|
+
}
|
|
494
|
+
key;
|
|
495
|
+
kind;
|
|
496
|
+
@@ -250,7 +252,7 @@ class Descriptor {
|
|
497
|
+
cells = /* @__PURE__ */ new WeakMap();
|
|
498
|
+
[SIGNAL_OWNER_RESOLVE](owner) {
|
|
499
|
+
requireSite(this.site);
|
|
500
|
+
- return this.resolvedCell(resolveDescriptorOwner(this.site, owner));
|
|
501
|
+
+ return this.resolvedCell(resolveDescriptorOwner(this.site, this.instanceOwner ?? owner));
|
|
502
|
+
}
|
|
503
|
+
resolvedCell(target) {
|
|
504
|
+
let cell = this.cells.get(target);
|
|
505
|
+
@@ -261,7 +263,7 @@ class Descriptor {
|
|
506
|
+
return cell;
|
|
507
|
+
}
|
|
508
|
+
resolve() {
|
|
509
|
+
- const token = requireOwner();
|
|
510
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
511
|
+
const owner = resolveDescriptorOwner(this.site, token);
|
|
512
|
+
requireSite(this.site);
|
|
513
|
+
return this.resolvedCell(owner);
|
|
514
|
+
@@ -292,7 +294,7 @@ class Descriptor {
|
|
515
|
+
return this.resolve().snapshot();
|
|
516
|
+
}
|
|
517
|
+
subscribe(notify) {
|
|
518
|
+
- const token = requireOwner();
|
|
519
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
520
|
+
const scope = resolveDescriptorOwner(this.site, token);
|
|
521
|
+
const run = captureSignalOwner(token);
|
|
522
|
+
return this[SIGNAL_OWNER_RESOLVE](scope).subscribe(forwardNativeTransitionConsumer(notify, () => run(notify)));
|
|
523
|
+
diff --git a/dist/node/signals/index.js b/dist/node/signals/index.js
|
|
524
|
+
index 8ae19e510a09e8144ae2ab66c0daf293a4a3f8f6..0bf09f5276e9e1a38ef67923b9cc2a441be2ce7f 100644
|
|
525
|
+
--- a/dist/node/signals/index.js
|
|
526
|
+
+++ b/dist/node/signals/index.js
|
|
527
|
+
@@ -1,6 +1,7 @@
|
|
528
|
+
import { createScope } from "./engine.js";
|
|
529
|
+
import { bindSignalControl } from "./control-binding.js";
|
|
530
|
+
import { enableSignalDocument } from "./document-owner.js";
|
|
531
|
+
+import { enableUniversalSignalDocument } from "./universal-owner.js";
|
|
532
|
+
import { createResource, query } from "./requests.js";
|
|
533
|
+
import { ActionUncertainError, action$, isActionUncertain, optimistic$ } from "./actions.js";
|
|
534
|
+
import { __derivedAt, derived$ } from "./derived-facade.js";
|
|
535
|
+
@@ -58,6 +59,7 @@ export {
|
|
536
|
+
__derivedAt,
|
|
537
|
+
__derivedScalarAt,
|
|
538
|
+
enableSignalDocument as __enableSignalDocument,
|
|
539
|
+
+ enableUniversalSignalDocument as __enableUniversalSignalDocument,
|
|
540
|
+
__queryAt,
|
|
541
|
+
__signalAt,
|
|
542
|
+
__startSignalReads,
|
|
543
|
+
diff --git a/dist/node/signals/local-hook.js b/dist/node/signals/local-hook.js
|
|
544
|
+
new file mode 100644
|
|
545
|
+
index 0000000000000000000000000000000000000000..77c63f5e2d931eb8dbd384ae027ee0f09935f9ce
|
|
546
|
+
--- /dev/null
|
|
547
|
+
+++ b/dist/node/signals/local-hook.js
|
|
548
|
+
@@ -0,0 +1,19 @@
|
|
549
|
+
+const probes = [];
|
|
550
|
+
+function registerLocalSignalHook(probe) {
|
|
551
|
+
+ probes.push(probe);
|
|
552
|
+
+ return () => {
|
|
553
|
+
+ const index = probes.indexOf(probe);
|
|
554
|
+
+ if (index !== -1) probes.splice(index, 1);
|
|
555
|
+
+ };
|
|
556
|
+
+}
|
|
557
|
+
+function localSignalHook(name, initialize, dispose, slot) {
|
|
558
|
+
+ for (let index = probes.length - 1; index >= 0; index--) {
|
|
559
|
+
+ const hook = probes[index]();
|
|
560
|
+
+ if (hook !== null) return hook(name, initialize, dispose, slot);
|
|
561
|
+
+ }
|
|
562
|
+
+ throw new Error(`${name} requires an active Octane component render.`);
|
|
563
|
+
+}
|
|
564
|
+
+export {
|
|
565
|
+
+ localSignalHook,
|
|
566
|
+
+ registerLocalSignalHook
|
|
567
|
+
+};
|
|
568
|
+
diff --git a/dist/node/signals/universal-owner.js b/dist/node/signals/universal-owner.js
|
|
569
|
+
new file mode 100644
|
|
570
|
+
index 0000000000000000000000000000000000000000..ff5eb43e8f0ddcadbcf8e861f42788b389b4d99b
|
|
571
|
+
--- /dev/null
|
|
572
|
+
+++ b/dist/node/signals/universal-owner.js
|
|
573
|
+
@@ -0,0 +1,20 @@
|
|
574
|
+
+import { installDefaultSignalOwner } from "./owner-context.js";
|
|
575
|
+
+let universalOwner;
|
|
576
|
+
+let provider;
|
|
577
|
+
+function installUniversalSignalDocumentProvider(next) {
|
|
578
|
+
+ provider = next;
|
|
579
|
+
+}
|
|
580
|
+
+function universalSignalDocument() {
|
|
581
|
+
+ return provider?.() ?? (universalOwner ??= Object.freeze({ scopeKey: "octane:universal" }));
|
|
582
|
+
+}
|
|
583
|
+
+function enableUniversalSignalDocument(abi = 1) {
|
|
584
|
+
+ if (abi !== 1) {
|
|
585
|
+
+ throw new TypeError("Unsupported universal signal owner ABI.");
|
|
586
|
+
+ }
|
|
587
|
+
+ installDefaultSignalOwner(universalSignalDocument);
|
|
588
|
+
+}
|
|
589
|
+
+export {
|
|
590
|
+
+ enableUniversalSignalDocument,
|
|
591
|
+
+ installUniversalSignalDocumentProvider,
|
|
592
|
+
+ universalSignalDocument
|
|
593
|
+
+};
|
|
594
|
+
diff --git a/dist/node/universal-core.js b/dist/node/universal-core.js
|
|
595
|
+
index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac19c65808c 100644
|
|
596
|
+
--- a/dist/node/universal-core.js
|
|
597
|
+
+++ b/dist/node/universal-core.js
|
|
598
|
+
@@ -17,6 +17,14 @@ import {
|
|
599
|
+
} from "./profiling.js";
|
|
600
|
+
import { getRendererHostFlusher } from "./renderer-bridge.js";
|
|
601
|
+
import { resolveLazyDefaultProps } from "./shared-value-helpers.js";
|
|
602
|
+
+import { universalSignalDocument } from "./signals/universal-owner.js";
|
|
603
|
+
+import { registerLocalSignalHook } from "./signals/local-hook.js";
|
|
604
|
+
+import { retireSignalOwnerIdentity, runWithSignalOwner } from "./signals/owner-context.js";
|
|
605
|
+
+import {
|
|
606
|
+
+ beginNativeWriteGuard,
|
|
607
|
+
+ endNativeWriteGuard,
|
|
608
|
+
+ setNativeReadObserver
|
|
609
|
+
+} from "./signals/read-protocol.js";
|
|
610
|
+
import { __methodDep } from "./method-dep.js";
|
|
611
|
+
const UNIVERSAL_PLAN = /* @__PURE__ */ Symbol.for("octane.universal.plan");
|
|
612
|
+
const UNIVERSAL_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.value");
|
|
613
|
+
@@ -842,6 +850,7 @@ function draftOwner(record, parent, replayPath) {
|
|
614
|
+
boundaryThenable: record.boundaryThenable,
|
|
615
|
+
isBoundary: record.isBoundary,
|
|
616
|
+
canHandleSuspense: record.canHandleSuspense,
|
|
617
|
+
+ signalReads: null,
|
|
618
|
+
visibility: parent?.visibility ?? record.visibility,
|
|
619
|
+
contextStable: null
|
|
620
|
+
};
|
|
621
|
+
@@ -1012,6 +1021,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
622
|
+
owner.contextStable = null;
|
|
623
|
+
owner.needsRender = false;
|
|
624
|
+
owner.implicitSlot = 0;
|
|
625
|
+
+ owner.signalReads = NO_SIGNAL_READS;
|
|
626
|
+
const previousOwner = CURRENT_OWNER;
|
|
627
|
+
const previousAttemptOwner = attempt.owner;
|
|
628
|
+
CURRENT_OWNER = owner;
|
|
629
|
+
@@ -1023,13 +1033,18 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
630
|
+
const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && component !== null ? __profileBeginRender(owner.record, component, owner.record.mounted) : null;
|
|
631
|
+
let didThrow = false;
|
|
632
|
+
let thrown;
|
|
633
|
+
+ const signalOwner = universalSignalOwner(owner.record);
|
|
634
|
+
+ const previousReadObserver = setNativeReadObserver(observeUniversalSignalRead);
|
|
635
|
+
+ const writeGuard = beginNativeWriteGuard();
|
|
636
|
+
try {
|
|
637
|
+
- output = build();
|
|
638
|
+
+ output = runWithSignalOwner(signalOwner, build);
|
|
639
|
+
} catch (error) {
|
|
640
|
+
didThrow = true;
|
|
641
|
+
- thrown = error;
|
|
642
|
+
- throw error;
|
|
643
|
+
+ thrown = isThenable(error) ? new UniversalSuspense(error) : error;
|
|
644
|
+
+ throw thrown;
|
|
645
|
+
} finally {
|
|
646
|
+
+ endNativeWriteGuard(writeGuard);
|
|
647
|
+
+ setNativeReadObserver(previousReadObserver);
|
|
648
|
+
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
|
|
649
|
+
__profileEndRender(profileFrame, didThrow, thrown);
|
|
650
|
+
}
|
|
651
|
+
@@ -1196,6 +1211,8 @@ function disposeUncommittedDraft(owner) {
|
|
652
|
+
owner.record.componentProps = null;
|
|
653
|
+
owner.record.range = null;
|
|
654
|
+
owner.record.updates.clear();
|
|
655
|
+
+ disposeUniversalSignalReads(owner.record);
|
|
656
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
657
|
+
for (const hook of owner.hooks.values()) {
|
|
658
|
+
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
659
|
+
}
|
|
660
|
+
@@ -3142,6 +3159,85 @@ function scheduleOwner(owner, slot) {
|
|
661
|
+
}
|
|
662
|
+
owner.root.scheduleOwned(owner);
|
|
663
|
+
}
|
|
664
|
+
+const UNIVERSAL_SIGNAL_OWNERS = /* @__PURE__ */ new WeakMap();
|
|
665
|
+
+function universalSignalOwner(record) {
|
|
666
|
+
+ let owner = UNIVERSAL_SIGNAL_OWNERS.get(record);
|
|
667
|
+
+ if (owner === void 0) {
|
|
668
|
+
+ const documentOwner = universalSignalDocument();
|
|
669
|
+
+ const identity = {
|
|
670
|
+
+ scopeKey: documentOwner.scopeKey,
|
|
671
|
+
+ documentOwner,
|
|
672
|
+
+ // The identity object itself is the opaque per-instance token — the
|
|
673
|
+
+ // same shape DOM scopes use, so identity maps never retain the record.
|
|
674
|
+
+ instanceOwner: null,
|
|
675
|
+
+ instanceKey: `u:${record.id}`
|
|
676
|
+
+ };
|
|
677
|
+
+ identity.instanceOwner = identity;
|
|
678
|
+
+ owner = Object.freeze(identity);
|
|
679
|
+
+ UNIVERSAL_SIGNAL_OWNERS.set(record, owner);
|
|
680
|
+
+ }
|
|
681
|
+
+ return owner;
|
|
682
|
+
+}
|
|
683
|
+
+const NO_SIGNAL_READS = /* @__PURE__ */ new Set();
|
|
684
|
+
+function observeUniversalSignalRead(source) {
|
|
685
|
+
+ const owner = CURRENT_OWNER;
|
|
686
|
+
+ if (owner === null) return;
|
|
687
|
+
+ if (owner.signalReads === NO_SIGNAL_READS) owner.signalReads = /* @__PURE__ */ new Set();
|
|
688
|
+
+ owner.signalReads.add(source);
|
|
689
|
+
+}
|
|
690
|
+
+function commitUniversalSignalReads(record, reads) {
|
|
691
|
+
+ if (reads === null) return;
|
|
692
|
+
+ let subscriptions = record.signalSubscriptions;
|
|
693
|
+
+ if (subscriptions !== void 0) {
|
|
694
|
+
+ for (const [source, unsubscribe] of subscriptions) {
|
|
695
|
+
+ if (!reads.has(source)) {
|
|
696
|
+
+ subscriptions.delete(source);
|
|
697
|
+
+ unsubscribe();
|
|
698
|
+
+ }
|
|
699
|
+
+ }
|
|
700
|
+
+ }
|
|
701
|
+
+ for (const source of reads) {
|
|
702
|
+
+ if (subscriptions?.has(source)) continue;
|
|
703
|
+
+ if (subscriptions === void 0) {
|
|
704
|
+
+ subscriptions = /* @__PURE__ */ new Map();
|
|
705
|
+
+ record.signalSubscriptions = subscriptions;
|
|
706
|
+
+ }
|
|
707
|
+
+ subscriptions.set(
|
|
708
|
+
+ source,
|
|
709
|
+
+ source.subscribe(() => {
|
|
710
|
+
+ if (!record.disposed) scheduleOwner(record);
|
|
711
|
+
+ })
|
|
712
|
+
+ );
|
|
713
|
+
+ }
|
|
714
|
+
+ if (subscriptions !== void 0 && subscriptions.size === 0) {
|
|
715
|
+
+ record.signalSubscriptions = void 0;
|
|
716
|
+
+ }
|
|
717
|
+
+}
|
|
718
|
+
+function disposeUniversalSignalReads(record) {
|
|
719
|
+
+ const subscriptions = record.signalSubscriptions;
|
|
720
|
+
+ if (subscriptions !== void 0) {
|
|
721
|
+
+ record.signalSubscriptions = void 0;
|
|
722
|
+
+ for (const unsubscribe of subscriptions.values()) unsubscribe();
|
|
723
|
+
+ }
|
|
724
|
+
+ const owner = UNIVERSAL_SIGNAL_OWNERS.get(record);
|
|
725
|
+
+ if (owner !== void 0) retireSignalOwnerIdentity(owner);
|
|
726
|
+
+}
|
|
727
|
+
+function disposeUniversalLocalHooks(hooks) {
|
|
728
|
+
+ for (const hook of hooks.values()) {
|
|
729
|
+
+ if (hook.kind === "local") hook.dispose(hook.value);
|
|
730
|
+
+ }
|
|
731
|
+
+}
|
|
732
|
+
+function universalLocalHook(_name, initialize, dispose, slot) {
|
|
733
|
+
+ const owner = currentDraftOwner();
|
|
734
|
+
+ const resolved = resolveHookSlot(slot);
|
|
735
|
+
+ let cell = owner.hooks.get(resolved);
|
|
736
|
+
+ if (cell === void 0) {
|
|
737
|
+
+ cell = { kind: "local", value: initialize(), dispose };
|
|
738
|
+
+ owner.hooks.set(resolved, cell);
|
|
739
|
+
+ }
|
|
740
|
+
+ return cell.value;
|
|
741
|
+
+}
|
|
742
|
+
+registerLocalSignalHook(() => CURRENT_OWNER === null ? null : universalLocalHook);
|
|
743
|
+
function currentDraftOwner() {
|
|
744
|
+
currentAttempt();
|
|
745
|
+
const owner = activateLazyLeafOwner();
|
|
746
|
+
@@ -5520,9 +5616,9 @@ class UniversalRootImpl {
|
|
747
|
+
}
|
|
748
|
+
let result;
|
|
749
|
+
try {
|
|
750
|
+
- result = event.handler(payload);
|
|
751
|
+
+ result = runWithSignalOwner(universalSignalOwner(event.owner), () => event.handler(payload));
|
|
752
|
+
} catch (error) {
|
|
753
|
+
- if (!routeUniversalOwnerError(event.owner, error)) throw error;
|
|
754
|
+
+ if (!routeUniversalOwnerError(event.owner, error) && !reportUniversalUncaughtError(this, error)) throw error;
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
@@ -6096,6 +6192,8 @@ class UniversalRootImpl {
|
|
759
|
+
draft.record.componentProps = null;
|
|
760
|
+
draft.record.range = null;
|
|
761
|
+
draft.record.updates.clear();
|
|
762
|
+
+ disposeUniversalSignalReads(draft.record);
|
|
763
|
+
+ disposeUniversalLocalHooks(draft.hooks);
|
|
764
|
+
for (const hook of draft.hooks.values()) {
|
|
765
|
+
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
766
|
+
}
|
|
767
|
+
@@ -6776,6 +6874,7 @@ class UniversalRootImpl {
|
|
768
|
+
owner.componentProps = draftOwner2.componentProps;
|
|
769
|
+
owner.componentRevision = draftOwner2.componentRevision;
|
|
770
|
+
owner.hooks = draftOwner2.hooks;
|
|
771
|
+
+ commitUniversalSignalReads(owner, draftOwner2.signalReads);
|
|
772
|
+
for (const [slot, applied] of draftOwner2.appliedUpdates) {
|
|
773
|
+
const queue = owner.updates.get(slot);
|
|
774
|
+
if (queue !== applied.queue || applied.lane) continue;
|
|
775
|
+
@@ -6809,6 +6908,7 @@ class UniversalRootImpl {
|
|
776
|
+
record.componentRevision = draft.componentRevision;
|
|
777
|
+
record.parent = draft.parent?.record ?? null;
|
|
778
|
+
record.hooks = draft.hooks;
|
|
779
|
+
+ commitUniversalSignalReads(record, draft.signalReads);
|
|
780
|
+
record.effectOrder = [...draft.seenEffects];
|
|
781
|
+
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
782
|
+
draft.seenEffects[index].previous = null;
|
|
783
|
+
@@ -8455,6 +8555,8 @@ class UniversalRootImpl {
|
|
784
|
+
owner.componentProps = null;
|
|
785
|
+
owner.range = null;
|
|
786
|
+
owner.updates.clear();
|
|
787
|
+
+ disposeUniversalSignalReads(owner);
|
|
788
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
789
|
+
}
|
|
790
|
+
for (const draft of draftOwnersParentFirst) {
|
|
791
|
+
const record = draft.record;
|
|
792
|
+
@@ -8464,6 +8566,7 @@ class UniversalRootImpl {
|
|
793
|
+
record.parent = draft.parent?.record ?? null;
|
|
794
|
+
}
|
|
795
|
+
record.hooks = draft.hooks;
|
|
796
|
+
+ commitUniversalSignalReads(record, draft.signalReads);
|
|
797
|
+
record.effectOrder = [...draft.seenEffects];
|
|
798
|
+
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
799
|
+
draft.seenEffects[index].previous = null;
|
|
800
|
+
@@ -8985,6 +9088,8 @@ class UniversalRootImpl {
|
|
801
|
+
owner.componentProps = null;
|
|
802
|
+
owner.range = null;
|
|
803
|
+
owner.updates.clear();
|
|
804
|
+
+ disposeUniversalSignalReads(owner);
|
|
805
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
806
|
+
}
|
|
807
|
+
const deactivatedRegionCells = /* @__PURE__ */ new Set();
|
|
808
|
+
for (const bridge of regionBridges) {
|
|
809
|
+
diff --git a/dist/node/universal-native.js b/dist/node/universal-native.js
|
|
810
|
+
index 55ac9b640dc8bbfd977bb2cbe0b7993c8ddb425a..3ff9a5750fb59cd91b63299aec3a3e0c030b4579 100644
|
|
811
|
+
--- a/dist/node/universal-native.js
|
|
812
|
+
+++ b/dist/node/universal-native.js
|
|
813
|
+
@@ -6,9 +6,11 @@ import {
|
|
814
|
+
import {
|
|
815
|
+
universalContext
|
|
816
|
+
} from "./universal-core.js";
|
|
817
|
+
+import { enableUniversalSignalDocument } from "./signals/universal-owner.js";
|
|
818
|
+
import { registerRendererContext, renderRendererContextProvider } from "./renderer-bridge.js";
|
|
819
|
+
import { CONTEXT_TAG } from "./runtime-tags.js";
|
|
820
|
+
import { registerContext } from "./context-identity.js";
|
|
821
|
+
+enableUniversalSignalDocument();
|
|
822
|
+
// @__NO_SIDE_EFFECTS__
|
|
823
|
+
function createContext(defaultValue) {
|
|
824
|
+
const context = ((props, scope) => scope === void 0 ? universalContext(context, props.value, props.children) : renderRendererContextProvider(context, props, scope));
|
|
825
|
+
diff --git a/dist/node/universal.js b/dist/node/universal.js
|
|
826
|
+
index 6427a0190c072e7e4629c379e42bedc03669dc6e..8049b7880824de607157091004a46c9d33a23484 100644
|
|
827
|
+
--- a/dist/node/universal.js
|
|
828
|
+
+++ b/dist/node/universal.js
|
|
829
|
+
@@ -8,6 +8,9 @@ import {
|
|
830
|
+
createUniversalHostBoundary,
|
|
831
|
+
registerUniversalHostBridge
|
|
832
|
+
} from "./universal-dom-boundary.js";
|
|
833
|
+
+import { documentSignalOwner } from "./signals/document-owner.js";
|
|
834
|
+
+import { installUniversalSignalDocumentProvider } from "./signals/universal-owner.js";
|
|
835
|
+
+installUniversalSignalDocumentProvider(() => documentSignalOwner(document));
|
|
836
|
+
export {
|
|
837
|
+
createContext,
|
|
838
|
+
createSubSlot,
|
|
839
|
+
diff --git a/dist/runtime.js b/dist/runtime.js
|
|
840
|
+
index ee2a2bdd0e0909921fc43ed073be0fbc7f6ec585..4f9f1b5b7782bc0e42799ddb847d22f617a4885f 100644
|
|
841
|
+
--- a/dist/runtime.js
|
|
842
|
+
+++ b/dist/runtime.js
|
|
843
|
+
@@ -161,6 +161,7 @@ import {
|
|
844
|
+
import { isRendererContext, registerClientRendererBridge } from "./renderer-bridge.js";
|
|
845
|
+
import { defineRemovedContextMembers, registerContext } from "./context-identity.js";
|
|
846
|
+
import { createNativeReadDriver } from "./signals/native-read-client.js";
|
|
847
|
+
+import { registerLocalSignalHook } from "./signals/local-hook.js";
|
|
848
|
+
import {
|
|
849
|
+
validateNativeReadWitness
|
|
850
|
+
} from "./signals/native-read-collector.js";
|
|
851
|
+
@@ -7455,6 +7456,7 @@ function nativeLocalHook(name, initialize, dispose, slot) {
|
|
852
|
+
}
|
|
853
|
+
return cell.nativeValue;
|
|
854
|
+
}
|
|
855
|
+
+registerLocalSignalHook(() => CURRENT_SCOPE === null ? null : nativeLocalHook);
|
|
856
|
+
function useState(initial, slot) {
|
|
857
|
+
const s = readStateHook(initial, slot, arguments.length === 1);
|
|
858
|
+
return [s.value, s.setter];
|
|
859
|
+
diff --git a/dist/signals/client.d.ts b/dist/signals/client.d.ts
|
|
860
|
+
index 6388c2f98517884a13af720687fb81c1f18357be..f9e98624f159cccf02a379d79201751fc07694d8 100644
|
|
861
|
+
--- a/dist/signals/client.d.ts
|
|
862
|
+
+++ b/dist/signals/client.d.ts
|
|
863
|
+
@@ -1,4 +1,4 @@
|
|
864
|
+
-/** Optional component hooks for the native-read DOM compiler mode. */
|
|
865
|
+
+/** Optional component hooks for the native-read compiler mode (DOM and universal). */
|
|
866
|
+
export * from './index.js';
|
|
867
|
+
import type { WritableSignal } from './types.js';
|
|
868
|
+
/** A writable signal owned by this compiler-assigned component hook slot. */
|
|
869
|
+
diff --git a/dist/signals/client.js b/dist/signals/client.js
|
|
870
|
+
index 21a39c3ce9a28d2095e276fd647fd795e939a0bf..3f85700b57cbc3084c2df776ab3e6b5365f091a8 100644
|
|
871
|
+
--- a/dist/signals/client.js
|
|
872
|
+
+++ b/dist/signals/client.js
|
|
873
|
+
@@ -1,11 +1,11 @@
|
|
874
|
+
export * from "./index.js";
|
|
875
|
+
-import { nativeLocalHook } from "../runtime.js";
|
|
876
|
+
import { createLocalScope } from "./engine.js";
|
|
877
|
+
+import { localSignalHook } from "./local-hook.js";
|
|
878
|
+
function disposeLocalSignal(cell) {
|
|
879
|
+
cell.scope.dispose();
|
|
880
|
+
}
|
|
881
|
+
function useSignal$(initial, slot) {
|
|
882
|
+
- const cell = nativeLocalHook(
|
|
883
|
+
+ const cell = localSignalHook(
|
|
884
|
+
"useSignal$",
|
|
885
|
+
() => {
|
|
886
|
+
const value = typeof initial === "function" ? initial() : initial;
|
|
887
|
+
diff --git a/dist/signals/document-owner.js b/dist/signals/document-owner.js
|
|
888
|
+
index cd4e628f79d9fed839c089a89e711d446d2e18a4..078dcd31218022b69086238180e6b236e7d8224f 100644
|
|
889
|
+
--- a/dist/signals/document-owner.js
|
|
890
|
+
+++ b/dist/signals/document-owner.js
|
|
891
|
+
@@ -26,7 +26,9 @@ function enableSignalDocument(abi = 1) {
|
|
892
|
+
if (defaultInstalled)
|
|
893
|
+
return;
|
|
894
|
+
defaultInstalled = true;
|
|
895
|
+
- installDefaultSignalOwner(() => typeof document === "undefined" ? null : documentSignalOwner(document));
|
|
896
|
+
+ if (typeof document === "undefined")
|
|
897
|
+
+ return;
|
|
898
|
+
+ installDefaultSignalOwner(() => documentSignalOwner(document));
|
|
899
|
+
}
|
|
900
|
+
function installStreamedSignalOwnerActivator(activate) {
|
|
901
|
+
if (streamedSignalOwnerActivator !== void 0) {
|
|
902
|
+
diff --git a/dist/signals/facade.js b/dist/signals/facade.js
|
|
903
|
+
index 5ab4b73f2e8276b3ade5f04e8fa647efd76cb830..7b23010b7440b698ac4775b44cf16dc55625654d 100644
|
|
904
|
+
--- a/dist/signals/facade.js
|
|
905
|
+
+++ b/dist/signals/facade.js
|
|
906
|
+
@@ -240,6 +240,8 @@ class Descriptor {
|
|
907
|
+
this.kind = kind;
|
|
908
|
+
this.create = create;
|
|
909
|
+
this.site = site;
|
|
910
|
+
+ // Instance declarations stay with their component across child templates and events.
|
|
911
|
+
+ this.instanceOwner = site?.startsWith("i:") ? currentSignalOwner() : null;
|
|
912
|
+
}
|
|
913
|
+
key;
|
|
914
|
+
kind;
|
|
915
|
+
@@ -249,7 +251,7 @@ class Descriptor {
|
|
916
|
+
cells = /* @__PURE__ */ new WeakMap();
|
|
917
|
+
[SIGNAL_OWNER_RESOLVE](owner) {
|
|
918
|
+
requireSite(this.site);
|
|
919
|
+
- return this.resolvedCell(resolveDescriptorOwner(this.site, owner));
|
|
920
|
+
+ return this.resolvedCell(resolveDescriptorOwner(this.site, this.instanceOwner ?? owner));
|
|
921
|
+
}
|
|
922
|
+
resolvedCell(target) {
|
|
923
|
+
let cell = this.cells.get(target);
|
|
924
|
+
@@ -260,7 +262,7 @@ class Descriptor {
|
|
925
|
+
return cell;
|
|
926
|
+
}
|
|
927
|
+
resolve() {
|
|
928
|
+
- const token = requireOwner();
|
|
929
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
930
|
+
const owner = resolveDescriptorOwner(this.site, token);
|
|
931
|
+
requireSite(this.site);
|
|
932
|
+
return this.resolvedCell(owner);
|
|
933
|
+
@@ -291,7 +293,7 @@ class Descriptor {
|
|
934
|
+
return this.resolve().snapshot();
|
|
935
|
+
}
|
|
936
|
+
subscribe(notify) {
|
|
937
|
+
- const token = requireOwner();
|
|
938
|
+
+ const token = this.instanceOwner ?? requireOwner();
|
|
939
|
+
const scope = resolveDescriptorOwner(this.site, token);
|
|
940
|
+
const run = captureSignalOwner(token);
|
|
941
|
+
return this[SIGNAL_OWNER_RESOLVE](scope).subscribe(forwardNativeTransitionConsumer(notify, () => run(notify)));
|
|
942
|
+
diff --git a/dist/signals/index.d.ts b/dist/signals/index.d.ts
|
|
943
|
+
index 95f32a27af860c358714eeadfbdcbc18bc323d9d..98559855b07e84b61915dba198f357505d584175 100644
|
|
944
|
+
--- a/dist/signals/index.d.ts
|
|
945
|
+
+++ b/dist/signals/index.d.ts
|
|
946
|
+
@@ -3,6 +3,7 @@ export { createScope } from './engine.js';
|
|
947
|
+
export { bindSignalControl } from './control-binding.js';
|
|
948
|
+
export type { SignalControlBinding } from './control-handoff.js';
|
|
949
|
+
export { enableSignalDocument as __enableSignalDocument } from './document-owner.js';
|
|
950
|
+
+export { enableUniversalSignalDocument as __enableUniversalSignalDocument } from './universal-owner.js';
|
|
951
|
+
export { createResource, query } from './requests.js';
|
|
952
|
+
export { ActionUncertainError, action$, isActionUncertain, optimistic$ } from './actions.js';
|
|
953
|
+
export { __derivedAt, derived$ } from './derived-facade.js';
|
|
954
|
+
diff --git a/dist/signals/index.js b/dist/signals/index.js
|
|
955
|
+
index 8ae19e510a09e8144ae2ab66c0daf293a4a3f8f6..0bf09f5276e9e1a38ef67923b9cc2a441be2ce7f 100644
|
|
956
|
+
--- a/dist/signals/index.js
|
|
957
|
+
+++ b/dist/signals/index.js
|
|
958
|
+
@@ -1,6 +1,7 @@
|
|
959
|
+
import { createScope } from "./engine.js";
|
|
960
|
+
import { bindSignalControl } from "./control-binding.js";
|
|
961
|
+
import { enableSignalDocument } from "./document-owner.js";
|
|
962
|
+
+import { enableUniversalSignalDocument } from "./universal-owner.js";
|
|
963
|
+
import { createResource, query } from "./requests.js";
|
|
964
|
+
import { ActionUncertainError, action$, isActionUncertain, optimistic$ } from "./actions.js";
|
|
965
|
+
import { __derivedAt, derived$ } from "./derived-facade.js";
|
|
966
|
+
@@ -58,6 +59,7 @@ export {
|
|
967
|
+
__derivedAt,
|
|
968
|
+
__derivedScalarAt,
|
|
969
|
+
enableSignalDocument as __enableSignalDocument,
|
|
970
|
+
+ enableUniversalSignalDocument as __enableUniversalSignalDocument,
|
|
971
|
+
__queryAt,
|
|
972
|
+
__signalAt,
|
|
973
|
+
__startSignalReads,
|
|
974
|
+
diff --git a/dist/signals/local-hook.d.ts b/dist/signals/local-hook.d.ts
|
|
975
|
+
new file mode 100644
|
|
976
|
+
index 0000000000000000000000000000000000000000..d6c1770fc22b738e0e107b6616f60eaf676d853e
|
|
977
|
+
--- /dev/null
|
|
978
|
+
+++ b/dist/signals/local-hook.d.ts
|
|
979
|
+
@@ -0,0 +1,16 @@
|
|
980
|
+
+/**
|
|
981
|
+
+ * Renderer-provided slots for optional signal hooks.
|
|
982
|
+
+ *
|
|
983
|
+
+ * `useSignal$` allocates a component-local signal cell, but the cell itself
|
|
984
|
+
+ * lives in whichever renderer is currently rendering — DOM hook slots on the
|
|
985
|
+
+ * client/server, universal owner slots under `target: 'universal'` renderers.
|
|
986
|
+
+ * `octane/signals` cannot import either runtime (both import the signal
|
|
987
|
+
+ * engine), so each renderer registers a probe at module evaluation; the probe
|
|
988
|
+
+ * answers only while one of its own owners is executing, which also settles
|
|
989
|
+
+ * nesting (a universal boundary inside a DOM render probes last and wins).
|
|
990
|
+
+ */
|
|
991
|
+
+export type LocalSignalHook = <T>(name: string, initialize: () => T, dispose: (value: T) => void, slot?: symbol | number) => T;
|
|
992
|
+
+/** @internal Renderer runtimes register once, at module evaluation. */
|
|
993
|
+
+export declare function registerLocalSignalHook(probe: () => LocalSignalHook | null): () => void;
|
|
994
|
+
+/** @internal Dispatch to the innermost renderer that currently owns a render. */
|
|
995
|
+
+export declare function localSignalHook<T>(name: string, initialize: () => T, dispose: (value: T) => void, slot?: symbol | number): T;
|
|
996
|
+
diff --git a/dist/signals/local-hook.js b/dist/signals/local-hook.js
|
|
997
|
+
new file mode 100644
|
|
998
|
+
index 0000000000000000000000000000000000000000..77c63f5e2d931eb8dbd384ae027ee0f09935f9ce
|
|
999
|
+
--- /dev/null
|
|
1000
|
+
+++ b/dist/signals/local-hook.js
|
|
1001
|
+
@@ -0,0 +1,19 @@
|
|
1002
|
+
+const probes = [];
|
|
1003
|
+
+function registerLocalSignalHook(probe) {
|
|
1004
|
+
+ probes.push(probe);
|
|
1005
|
+
+ return () => {
|
|
1006
|
+
+ const index = probes.indexOf(probe);
|
|
1007
|
+
+ if (index !== -1) probes.splice(index, 1);
|
|
1008
|
+
+ };
|
|
1009
|
+
+}
|
|
1010
|
+
+function localSignalHook(name, initialize, dispose, slot) {
|
|
1011
|
+
+ for (let index = probes.length - 1; index >= 0; index--) {
|
|
1012
|
+
+ const hook = probes[index]();
|
|
1013
|
+
+ if (hook !== null) return hook(name, initialize, dispose, slot);
|
|
1014
|
+
+ }
|
|
1015
|
+
+ throw new Error(`${name} requires an active Octane component render.`);
|
|
1016
|
+
+}
|
|
1017
|
+
+export {
|
|
1018
|
+
+ localSignalHook,
|
|
1019
|
+
+ registerLocalSignalHook
|
|
1020
|
+
+};
|
|
1021
|
+
diff --git a/dist/signals/universal-owner.d.ts b/dist/signals/universal-owner.d.ts
|
|
1022
|
+
new file mode 100644
|
|
1023
|
+
index 0000000000000000000000000000000000000000..0e57f3a79115c858355f863434c6e3423570067b
|
|
1024
|
+
--- /dev/null
|
|
1025
|
+
+++ b/dist/signals/universal-owner.d.ts
|
|
1026
|
+
@@ -0,0 +1,10 @@
|
|
1027
|
+
+import type { SignalOwner } from './types.js';
|
|
1028
|
+
+/**
|
|
1029
|
+
+ * @internal A DOM runtime aliases the ambient owner so universal-boundary and
|
|
1030
|
+
+ * DOM renders resolve the same document scope.
|
|
1031
|
+
+ */
|
|
1032
|
+
+export declare function installUniversalSignalDocumentProvider(next: () => SignalOwner): void;
|
|
1033
|
+
+/** @internal Process-wide signal document for host-neutral renderers. */
|
|
1034
|
+
+export declare function universalSignalDocument(): SignalOwner;
|
|
1035
|
+
+/** @internal Compiler capability for ambient signal reads under universal renderers. */
|
|
1036
|
+
+export declare function enableUniversalSignalDocument(abi?: number): void;
|
|
1037
|
+
diff --git a/dist/signals/universal-owner.js b/dist/signals/universal-owner.js
|
|
1038
|
+
new file mode 100644
|
|
1039
|
+
index 0000000000000000000000000000000000000000..ff5eb43e8f0ddcadbcf8e861f42788b389b4d99b
|
|
1040
|
+
--- /dev/null
|
|
1041
|
+
+++ b/dist/signals/universal-owner.js
|
|
1042
|
+
@@ -0,0 +1,20 @@
|
|
1043
|
+
+import { installDefaultSignalOwner } from "./owner-context.js";
|
|
1044
|
+
+let universalOwner;
|
|
1045
|
+
+let provider;
|
|
1046
|
+
+function installUniversalSignalDocumentProvider(next) {
|
|
1047
|
+
+ provider = next;
|
|
1048
|
+
+}
|
|
1049
|
+
+function universalSignalDocument() {
|
|
1050
|
+
+ return provider?.() ?? (universalOwner ??= Object.freeze({ scopeKey: "octane:universal" }));
|
|
1051
|
+
+}
|
|
1052
|
+
+function enableUniversalSignalDocument(abi = 1) {
|
|
1053
|
+
+ if (abi !== 1) {
|
|
1054
|
+
+ throw new TypeError("Unsupported universal signal owner ABI.");
|
|
1055
|
+
+ }
|
|
1056
|
+
+ installDefaultSignalOwner(universalSignalDocument);
|
|
1057
|
+
+}
|
|
1058
|
+
+export {
|
|
1059
|
+
+ enableUniversalSignalDocument,
|
|
1060
|
+
+ installUniversalSignalDocumentProvider,
|
|
1061
|
+
+ universalSignalDocument
|
|
1062
|
+
+};
|
|
1063
|
+
diff --git a/dist/universal-core.js b/dist/universal-core.js
|
|
1064
|
+
index 4dbe2f938d039d415b44821bcb3be520172bcada..aaffba80e3f94c909b5eb2f6156baac19c65808c 100644
|
|
1065
|
+
--- a/dist/universal-core.js
|
|
1066
|
+
+++ b/dist/universal-core.js
|
|
1067
|
+
@@ -17,6 +17,14 @@ import {
|
|
1068
|
+
} from "./profiling.js";
|
|
1069
|
+
import { getRendererHostFlusher } from "./renderer-bridge.js";
|
|
1070
|
+
import { resolveLazyDefaultProps } from "./shared-value-helpers.js";
|
|
1071
|
+
+import { universalSignalDocument } from "./signals/universal-owner.js";
|
|
1072
|
+
+import { registerLocalSignalHook } from "./signals/local-hook.js";
|
|
1073
|
+
+import { retireSignalOwnerIdentity, runWithSignalOwner } from "./signals/owner-context.js";
|
|
1074
|
+
+import {
|
|
1075
|
+
+ beginNativeWriteGuard,
|
|
1076
|
+
+ endNativeWriteGuard,
|
|
1077
|
+
+ setNativeReadObserver
|
|
1078
|
+
+} from "./signals/read-protocol.js";
|
|
1079
|
+
import { __methodDep } from "./method-dep.js";
|
|
1080
|
+
const UNIVERSAL_PLAN = /* @__PURE__ */ Symbol.for("octane.universal.plan");
|
|
1081
|
+
const UNIVERSAL_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.value");
|
|
1082
|
+
@@ -842,6 +850,7 @@ function draftOwner(record, parent, replayPath) {
|
|
1083
|
+
boundaryThenable: record.boundaryThenable,
|
|
1084
|
+
isBoundary: record.isBoundary,
|
|
1085
|
+
canHandleSuspense: record.canHandleSuspense,
|
|
1086
|
+
+ signalReads: null,
|
|
1087
|
+
visibility: parent?.visibility ?? record.visibility,
|
|
1088
|
+
contextStable: null
|
|
1089
|
+
};
|
|
1090
|
+
@@ -1012,6 +1021,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
1091
|
+
owner.contextStable = null;
|
|
1092
|
+
owner.needsRender = false;
|
|
1093
|
+
owner.implicitSlot = 0;
|
|
1094
|
+
+ owner.signalReads = NO_SIGNAL_READS;
|
|
1095
|
+
const previousOwner = CURRENT_OWNER;
|
|
1096
|
+
const previousAttemptOwner = attempt.owner;
|
|
1097
|
+
CURRENT_OWNER = owner;
|
|
1098
|
+
@@ -1023,13 +1033,18 @@ function executeOwner(owner, build, initialRenderCount = 0) {
|
|
1099
|
+
const profileFrame = typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__ && component !== null ? __profileBeginRender(owner.record, component, owner.record.mounted) : null;
|
|
1100
|
+
let didThrow = false;
|
|
1101
|
+
let thrown;
|
|
1102
|
+
+ const signalOwner = universalSignalOwner(owner.record);
|
|
1103
|
+
+ const previousReadObserver = setNativeReadObserver(observeUniversalSignalRead);
|
|
1104
|
+
+ const writeGuard = beginNativeWriteGuard();
|
|
1105
|
+
try {
|
|
1106
|
+
- output = build();
|
|
1107
|
+
+ output = runWithSignalOwner(signalOwner, build);
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
didThrow = true;
|
|
1110
|
+
- thrown = error;
|
|
1111
|
+
- throw error;
|
|
1112
|
+
+ thrown = isThenable(error) ? new UniversalSuspense(error) : error;
|
|
1113
|
+
+ throw thrown;
|
|
1114
|
+
} finally {
|
|
1115
|
+
+ endNativeWriteGuard(writeGuard);
|
|
1116
|
+
+ setNativeReadObserver(previousReadObserver);
|
|
1117
|
+
if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
|
|
1118
|
+
__profileEndRender(profileFrame, didThrow, thrown);
|
|
1119
|
+
}
|
|
1120
|
+
@@ -1196,6 +1211,8 @@ function disposeUncommittedDraft(owner) {
|
|
1121
|
+
owner.record.componentProps = null;
|
|
1122
|
+
owner.record.range = null;
|
|
1123
|
+
owner.record.updates.clear();
|
|
1124
|
+
+ disposeUniversalSignalReads(owner.record);
|
|
1125
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
1126
|
+
for (const hook of owner.hooks.values()) {
|
|
1127
|
+
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
1128
|
+
}
|
|
1129
|
+
@@ -3142,6 +3159,85 @@ function scheduleOwner(owner, slot) {
|
|
1130
|
+
}
|
|
1131
|
+
owner.root.scheduleOwned(owner);
|
|
1132
|
+
}
|
|
1133
|
+
+const UNIVERSAL_SIGNAL_OWNERS = /* @__PURE__ */ new WeakMap();
|
|
1134
|
+
+function universalSignalOwner(record) {
|
|
1135
|
+
+ let owner = UNIVERSAL_SIGNAL_OWNERS.get(record);
|
|
1136
|
+
+ if (owner === void 0) {
|
|
1137
|
+
+ const documentOwner = universalSignalDocument();
|
|
1138
|
+
+ const identity = {
|
|
1139
|
+
+ scopeKey: documentOwner.scopeKey,
|
|
1140
|
+
+ documentOwner,
|
|
1141
|
+
+ // The identity object itself is the opaque per-instance token — the
|
|
1142
|
+
+ // same shape DOM scopes use, so identity maps never retain the record.
|
|
1143
|
+
+ instanceOwner: null,
|
|
1144
|
+
+ instanceKey: `u:${record.id}`
|
|
1145
|
+
+ };
|
|
1146
|
+
+ identity.instanceOwner = identity;
|
|
1147
|
+
+ owner = Object.freeze(identity);
|
|
1148
|
+
+ UNIVERSAL_SIGNAL_OWNERS.set(record, owner);
|
|
1149
|
+
+ }
|
|
1150
|
+
+ return owner;
|
|
1151
|
+
+}
|
|
1152
|
+
+const NO_SIGNAL_READS = /* @__PURE__ */ new Set();
|
|
1153
|
+
+function observeUniversalSignalRead(source) {
|
|
1154
|
+
+ const owner = CURRENT_OWNER;
|
|
1155
|
+
+ if (owner === null) return;
|
|
1156
|
+
+ if (owner.signalReads === NO_SIGNAL_READS) owner.signalReads = /* @__PURE__ */ new Set();
|
|
1157
|
+
+ owner.signalReads.add(source);
|
|
1158
|
+
+}
|
|
1159
|
+
+function commitUniversalSignalReads(record, reads) {
|
|
1160
|
+
+ if (reads === null) return;
|
|
1161
|
+
+ let subscriptions = record.signalSubscriptions;
|
|
1162
|
+
+ if (subscriptions !== void 0) {
|
|
1163
|
+
+ for (const [source, unsubscribe] of subscriptions) {
|
|
1164
|
+
+ if (!reads.has(source)) {
|
|
1165
|
+
+ subscriptions.delete(source);
|
|
1166
|
+
+ unsubscribe();
|
|
1167
|
+
+ }
|
|
1168
|
+
+ }
|
|
1169
|
+
+ }
|
|
1170
|
+
+ for (const source of reads) {
|
|
1171
|
+
+ if (subscriptions?.has(source)) continue;
|
|
1172
|
+
+ if (subscriptions === void 0) {
|
|
1173
|
+
+ subscriptions = /* @__PURE__ */ new Map();
|
|
1174
|
+
+ record.signalSubscriptions = subscriptions;
|
|
1175
|
+
+ }
|
|
1176
|
+
+ subscriptions.set(
|
|
1177
|
+
+ source,
|
|
1178
|
+
+ source.subscribe(() => {
|
|
1179
|
+
+ if (!record.disposed) scheduleOwner(record);
|
|
1180
|
+
+ })
|
|
1181
|
+
+ );
|
|
1182
|
+
+ }
|
|
1183
|
+
+ if (subscriptions !== void 0 && subscriptions.size === 0) {
|
|
1184
|
+
+ record.signalSubscriptions = void 0;
|
|
1185
|
+
+ }
|
|
1186
|
+
+}
|
|
1187
|
+
+function disposeUniversalSignalReads(record) {
|
|
1188
|
+
+ const subscriptions = record.signalSubscriptions;
|
|
1189
|
+
+ if (subscriptions !== void 0) {
|
|
1190
|
+
+ record.signalSubscriptions = void 0;
|
|
1191
|
+
+ for (const unsubscribe of subscriptions.values()) unsubscribe();
|
|
1192
|
+
+ }
|
|
1193
|
+
+ const owner = UNIVERSAL_SIGNAL_OWNERS.get(record);
|
|
1194
|
+
+ if (owner !== void 0) retireSignalOwnerIdentity(owner);
|
|
1195
|
+
+}
|
|
1196
|
+
+function disposeUniversalLocalHooks(hooks) {
|
|
1197
|
+
+ for (const hook of hooks.values()) {
|
|
1198
|
+
+ if (hook.kind === "local") hook.dispose(hook.value);
|
|
1199
|
+
+ }
|
|
1200
|
+
+}
|
|
1201
|
+
+function universalLocalHook(_name, initialize, dispose, slot) {
|
|
1202
|
+
+ const owner = currentDraftOwner();
|
|
1203
|
+
+ const resolved = resolveHookSlot(slot);
|
|
1204
|
+
+ let cell = owner.hooks.get(resolved);
|
|
1205
|
+
+ if (cell === void 0) {
|
|
1206
|
+
+ cell = { kind: "local", value: initialize(), dispose };
|
|
1207
|
+
+ owner.hooks.set(resolved, cell);
|
|
1208
|
+
+ }
|
|
1209
|
+
+ return cell.value;
|
|
1210
|
+
+}
|
|
1211
|
+
+registerLocalSignalHook(() => CURRENT_OWNER === null ? null : universalLocalHook);
|
|
1212
|
+
function currentDraftOwner() {
|
|
1213
|
+
currentAttempt();
|
|
1214
|
+
const owner = activateLazyLeafOwner();
|
|
1215
|
+
@@ -5520,9 +5616,9 @@ class UniversalRootImpl {
|
|
1216
|
+
}
|
|
1217
|
+
let result;
|
|
1218
|
+
try {
|
|
1219
|
+
- result = event.handler(payload);
|
|
1220
|
+
+ result = runWithSignalOwner(universalSignalOwner(event.owner), () => event.handler(payload));
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
- if (!routeUniversalOwnerError(event.owner, error)) throw error;
|
|
1223
|
+
+ if (!routeUniversalOwnerError(event.owner, error) && !reportUniversalUncaughtError(this, error)) throw error;
|
|
1224
|
+
}
|
|
1225
|
+
return result;
|
|
1226
|
+
}
|
|
1227
|
+
@@ -6096,6 +6192,8 @@ class UniversalRootImpl {
|
|
1228
|
+
draft.record.componentProps = null;
|
|
1229
|
+
draft.record.range = null;
|
|
1230
|
+
draft.record.updates.clear();
|
|
1231
|
+
+ disposeUniversalSignalReads(draft.record);
|
|
1232
|
+
+ disposeUniversalLocalHooks(draft.hooks);
|
|
1233
|
+
for (const hook of draft.hooks.values()) {
|
|
1234
|
+
if (hook.kind === "effect-event") hook.cell.active = false;
|
|
1235
|
+
}
|
|
1236
|
+
@@ -6776,6 +6874,7 @@ class UniversalRootImpl {
|
|
1237
|
+
owner.componentProps = draftOwner2.componentProps;
|
|
1238
|
+
owner.componentRevision = draftOwner2.componentRevision;
|
|
1239
|
+
owner.hooks = draftOwner2.hooks;
|
|
1240
|
+
+ commitUniversalSignalReads(owner, draftOwner2.signalReads);
|
|
1241
|
+
for (const [slot, applied] of draftOwner2.appliedUpdates) {
|
|
1242
|
+
const queue = owner.updates.get(slot);
|
|
1243
|
+
if (queue !== applied.queue || applied.lane) continue;
|
|
1244
|
+
@@ -6809,6 +6908,7 @@ class UniversalRootImpl {
|
|
1245
|
+
record.componentRevision = draft.componentRevision;
|
|
1246
|
+
record.parent = draft.parent?.record ?? null;
|
|
1247
|
+
record.hooks = draft.hooks;
|
|
1248
|
+
+ commitUniversalSignalReads(record, draft.signalReads);
|
|
1249
|
+
record.effectOrder = [...draft.seenEffects];
|
|
1250
|
+
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
1251
|
+
draft.seenEffects[index].previous = null;
|
|
1252
|
+
@@ -8455,6 +8555,8 @@ class UniversalRootImpl {
|
|
1253
|
+
owner.componentProps = null;
|
|
1254
|
+
owner.range = null;
|
|
1255
|
+
owner.updates.clear();
|
|
1256
|
+
+ disposeUniversalSignalReads(owner);
|
|
1257
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
1258
|
+
}
|
|
1259
|
+
for (const draft of draftOwnersParentFirst) {
|
|
1260
|
+
const record = draft.record;
|
|
1261
|
+
@@ -8464,6 +8566,7 @@ class UniversalRootImpl {
|
|
1262
|
+
record.parent = draft.parent?.record ?? null;
|
|
1263
|
+
}
|
|
1264
|
+
record.hooks = draft.hooks;
|
|
1265
|
+
+ commitUniversalSignalReads(record, draft.signalReads);
|
|
1266
|
+
record.effectOrder = [...draft.seenEffects];
|
|
1267
|
+
for (let index = 0; index < draft.seenEffects.length; index++) {
|
|
1268
|
+
draft.seenEffects[index].previous = null;
|
|
1269
|
+
@@ -8985,6 +9088,8 @@ class UniversalRootImpl {
|
|
1270
|
+
owner.componentProps = null;
|
|
1271
|
+
owner.range = null;
|
|
1272
|
+
owner.updates.clear();
|
|
1273
|
+
+ disposeUniversalSignalReads(owner);
|
|
1274
|
+
+ disposeUniversalLocalHooks(owner.hooks);
|
|
1275
|
+
}
|
|
1276
|
+
const deactivatedRegionCells = /* @__PURE__ */ new Set();
|
|
1277
|
+
for (const bridge of regionBridges) {
|
|
1278
|
+
diff --git a/dist/universal-native.js b/dist/universal-native.js
|
|
1279
|
+
index 55ac9b640dc8bbfd977bb2cbe0b7993c8ddb425a..3ff9a5750fb59cd91b63299aec3a3e0c030b4579 100644
|
|
1280
|
+
--- a/dist/universal-native.js
|
|
1281
|
+
+++ b/dist/universal-native.js
|
|
1282
|
+
@@ -6,9 +6,11 @@ import {
|
|
1283
|
+
import {
|
|
1284
|
+
universalContext
|
|
1285
|
+
} from "./universal-core.js";
|
|
1286
|
+
+import { enableUniversalSignalDocument } from "./signals/universal-owner.js";
|
|
1287
|
+
import { registerRendererContext, renderRendererContextProvider } from "./renderer-bridge.js";
|
|
1288
|
+
import { CONTEXT_TAG } from "./runtime-tags.js";
|
|
1289
|
+
import { registerContext } from "./context-identity.js";
|
|
1290
|
+
+enableUniversalSignalDocument();
|
|
1291
|
+
// @__NO_SIDE_EFFECTS__
|
|
1292
|
+
function createContext(defaultValue) {
|
|
1293
|
+
const context = ((props, scope) => scope === void 0 ? universalContext(context, props.value, props.children) : renderRendererContextProvider(context, props, scope));
|
|
1294
|
+
diff --git a/dist/universal.js b/dist/universal.js
|
|
1295
|
+
index 6427a0190c072e7e4629c379e42bedc03669dc6e..8049b7880824de607157091004a46c9d33a23484 100644
|
|
1296
|
+
--- a/dist/universal.js
|
|
1297
|
+
+++ b/dist/universal.js
|
|
1298
|
+
@@ -8,6 +8,9 @@ import {
|
|
1299
|
+
createUniversalHostBoundary,
|
|
1300
|
+
registerUniversalHostBridge
|
|
1301
|
+
} from "./universal-dom-boundary.js";
|
|
1302
|
+
+import { documentSignalOwner } from "./signals/document-owner.js";
|
|
1303
|
+
+import { installUniversalSignalDocumentProvider } from "./signals/universal-owner.js";
|
|
1304
|
+
+installUniversalSignalDocumentProvider(() => documentSignalOwner(document));
|
|
1305
|
+
export {
|
|
1306
|
+
createContext,
|
|
1307
|
+
createSubSlot,
|