@warp-drive-mirror/react 5.9.0-alpha.21 → 5.9.0-alpha.22

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 (45) hide show
  1. package/dist/index.d.ts +180 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +215 -256
  4. package/dist/index.js.map +1 -0
  5. package/dist/install.d.ts +21 -0
  6. package/dist/install.d.ts.map +1 -0
  7. package/dist/install.js +88 -107
  8. package/dist/install.js.map +1 -0
  9. package/dist/reactive-context-DNq02nr1.js +122 -0
  10. package/dist/reactive-context-DNq02nr1.js.map +1 -0
  11. package/dist/unpkg/dev/index.js +259 -304
  12. package/dist/unpkg/dev/index.js.map +1 -0
  13. package/dist/unpkg/dev/install.js +80 -105
  14. package/dist/unpkg/dev/install.js.map +1 -0
  15. package/dist/unpkg/dev/reactive-context-ir4_7OCl.js +218 -0
  16. package/dist/unpkg/dev/reactive-context-ir4_7OCl.js.map +1 -0
  17. package/dist/unpkg/dev-deprecated/index.js +259 -304
  18. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  19. package/dist/unpkg/dev-deprecated/install.js +80 -105
  20. package/dist/unpkg/dev-deprecated/install.js.map +1 -0
  21. package/dist/unpkg/dev-deprecated/reactive-context-CBrZV0cR.js +218 -0
  22. package/dist/unpkg/dev-deprecated/reactive-context-CBrZV0cR.js.map +1 -0
  23. package/dist/unpkg/prod/index.js +198 -231
  24. package/dist/unpkg/prod/index.js.map +1 -0
  25. package/dist/unpkg/prod/install.js +54 -61
  26. package/dist/unpkg/prod/install.js.map +1 -0
  27. package/dist/unpkg/prod/reactive-context-CvfXAZqb.js +92 -0
  28. package/dist/unpkg/prod/reactive-context-CvfXAZqb.js.map +1 -0
  29. package/dist/unpkg/prod-deprecated/index.js +198 -231
  30. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  31. package/dist/unpkg/prod-deprecated/install.js +54 -61
  32. package/dist/unpkg/prod-deprecated/install.js.map +1 -0
  33. package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js +92 -0
  34. package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js.map +1 -0
  35. package/package.json +15 -17
  36. package/declarations/-private/reactive-context.d.ts +0 -21
  37. package/declarations/-private/request.d.ts +0 -148
  38. package/declarations/-private/store-provider.d.ts +0 -19
  39. package/declarations/index.d.ts +0 -7
  40. package/declarations/install.d.ts +0 -17
  41. package/dist/reactive-context-ClTRYXie.js +0 -154
  42. package/dist/unpkg/dev/reactive-context-4Y50NyRg.js +0 -306
  43. package/dist/unpkg/dev-deprecated/reactive-context-D54NwOLZ.js +0 -306
  44. package/dist/unpkg/prod/reactive-context-DKimDkR3.js +0 -110
  45. package/dist/unpkg/prod-deprecated/reactive-context-DKimDkR3.js +0 -110
@@ -1,154 +0,0 @@
1
- import { Signal } from 'signal-polyfill';
2
- import { createContext, useMemo, useSyncExternalStore } from 'react';
3
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
- import { jsx } from 'react/jsx-runtime';
5
- let nextFlush = null;
6
- let watchers = [];
7
- let watcherId = 0;
8
- function clearWatcher(state) {
9
- state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));
10
- }
11
- function flush(state) {
12
- state.pending = false;
13
- if (state.destroyed) {
14
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
15
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
16
- console.log(`[WarpDrive] Detected Watcher Destroyed During Notify Flush, clearing signals`);
17
- }
18
- }
19
- state.snapshot = null;
20
- clearWatcher(state);
21
- return;
22
- }
23
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
24
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
25
- console.log(`[WarpDrive] Notifying React That WatcherContext:${state.watcherId} Has Updated`);
26
- console.log("all signals", new Set(Signal.subtle.introspectSources(state.watcher)));
27
- console.log("dirty signals", new Set(state.watcher.getPending()));
28
- }
29
- }
30
-
31
- // any time signals have changed, we notify React that our store has updated
32
- state.snapshot = {
33
- watcher: state.watcher
34
- };
35
- if (state.notifyReact) state.notifyReact();
36
-
37
- // tell the Watcher to start watching for changes again
38
- // by signaling that notifications have been flushed.
39
- state.watcher.watch();
40
- }
41
- function _createWatcher() {
42
- const id = watcherId++;
43
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
44
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
45
- console.log(`[WarpDrive] Creating a WatcherContext:${id}`);
46
- }
47
- }
48
- const state = {
49
- watcherId: id,
50
- pending: false,
51
- destroyed: false,
52
- notifyReact: null,
53
- watcher: null,
54
- // the extra wrapper returned here ensures that the context value for the watcher
55
- // changes causing a re-render when the watcher is updated.
56
- snapshot: null
57
- };
58
- state.watcher = new Signal.subtle.Watcher((...args) => {
59
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
60
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
61
- console.log(`watcher ${state.watcherId} notified`, args, state.watcher);
62
- }
63
- }
64
- if (!state.pending && !state.destroyed) {
65
- watchers.push(state);
66
- state.pending = true;
67
- if (!nextFlush) {
68
- nextFlush = new Promise(resolve => {
69
- queueMicrotask(() => {
70
- queueMicrotask(() => {
71
- queueMicrotask(() => {
72
- watchers.forEach(flush);
73
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
74
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
75
- console.log("Flushed watcher:", watchers.map(w => w.watcherId));
76
- }
77
- }
78
- watchers = [];
79
- nextFlush = null;
80
- resolve();
81
- });
82
- });
83
- });
84
- });
85
- }
86
- } else if (state.destroyed) {
87
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
88
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
89
- console.log(`[WarpDrive] Detected Watcher Destroyed During Notify, clearing signals`);
90
- }
91
- }
92
- // if we are destroyed, we clear the watcher signals
93
- // so that it does not continue to watch for changes.
94
- state.snapshot = null;
95
- clearWatcher(state);
96
- }
97
- });
98
-
99
- // The watcher won't begin watching until we call `watcher.watch()`
100
- state.watcher.watch();
101
- state.snapshot = {
102
- watcher: state.watcher
103
- };
104
- return state;
105
- }
106
- function useWatcher() {
107
- const state = useMemo(_createWatcher, []);
108
- return useSyncExternalStore(notifyChanged => {
109
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
110
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
111
- console.log(`[WarpDrive] Subscribing to Watcher`);
112
- }
113
- }
114
- state.destroyed = false;
115
- state.notifyReact = notifyChanged;
116
-
117
- // The watcher won't begin watching until we call `watcher.watch()`
118
- state.watcher.watch();
119
- return () => {
120
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
121
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
122
- console.log(`[WarpDrive] Deactivating Watcher Subscription`);
123
- }
124
- }
125
- state.destroyed = true;
126
- state.notifyReact = null;
127
- };
128
- }, () => state.snapshot);
129
- }
130
-
131
- /**
132
- * @category Contexts
133
- */
134
- const WatcherContext = /*#__PURE__*/createContext(null);
135
-
136
- /**
137
- *
138
- * @category Components
139
- */
140
- function ReactiveContext({
141
- children
142
- }) {
143
- const watcher = useWatcher();
144
- /**
145
- * Unlike other frameworks, React does not have a built-in way to provide
146
- * a context value other than by rendering an extra component.
147
- *
148
- */
149
- return /*#__PURE__*/jsx(WatcherContext, {
150
- value: watcher,
151
- children: children
152
- });
153
- }
154
- export { ReactiveContext as R, WatcherContext as W };
@@ -1,306 +0,0 @@
1
- import { Signal } from 'signal-polyfill';
2
- import { createContext, useMemo, useSyncExternalStore } from 'react';
3
- import { jsxDEV } from 'react/jsx-dev-runtime';
4
-
5
- /*
6
- These are the runtime implementations for the javascript macros that have
7
- runtime implementations.
8
-
9
- Not every macro has a runtime implementation, some only make sense in the
10
- build and always run there.
11
-
12
- Even when we have runtime implementations, we are still careful to emit static
13
- errors during the build wherever possible, and runtime errors when necessary,
14
- so that you're not surprised when you switch from runtime-mode to compile-time
15
- mode.
16
- */
17
-
18
- // This is here as a compile target for `getConfig` and `getOwnConfig` when
19
- // we're in runtime mode. This is not public API to call from your own code.
20
- function config(packageRoot) {
21
- return runtimeConfig.packages[packageRoot];
22
- }
23
- function getGlobalConfig() {
24
- return runtimeConfig.global;
25
- }
26
-
27
- // Welcome intrepid developer!
28
- //
29
- // While this data is "global", this is a private variable.
30
- //
31
- // do not build features based off of its contents,
32
- // or assume it will have the same name in future releases.
33
- const runtimeConfig = globalThis.__embroider_macros__runtime_config__ ||= {};
34
- runtimeConfig.packages ||= {};
35
- runtimeConfig.global ||= {};
36
-
37
- // In the off chance there are duplicate copies of @embroider/macros in the dep graph
38
- // (due to the package manager messing up)
39
- // Let's try to merge them together via the above global well known variable
40
- const localConfig = initializeRuntimeMacrosConfig();
41
- Object.assign(runtimeConfig.packages, localConfig.packages);
42
- Object.assign(runtimeConfig.global, localConfig.global);
43
-
44
- // this exists to be targeted by our babel plugin
45
- function initializeRuntimeMacrosConfig() {
46
- return {
47
- "packages": {},
48
- "global": {
49
- "@embroider/macros": {
50
- "isTesting": false
51
- },
52
- "WarpDrive": {
53
- "debug": {
54
- "DEBUG_RELATIONSHIP_NOTIFICATIONS": false,
55
- "LOG_CACHE": false,
56
- "LOG_CACHE_POLICY": false,
57
- "LOG_GRAPH": false,
58
- "LOG_IDENTIFIERS": false,
59
- "LOG_INSTANCE_CACHE": false,
60
- "LOG_METRIC_COUNTS": false,
61
- "LOG_MUTATIONS": false,
62
- "LOG_NOTIFICATIONS": false,
63
- "LOG_OPERATIONS": false,
64
- "LOG_PAYLOADS": false,
65
- "LOG_REACT_SIGNAL_INTEGRATION": false,
66
- "LOG_REQUESTS": false,
67
- "LOG_REQUEST_STATUS": false,
68
- "__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS": false
69
- },
70
- "polyfillUUID": false,
71
- "includeDataAdapter": true,
72
- "compatWith": "99.0",
73
- "deprecations": {
74
- "DEPRECATE_CATCH_ALL": false,
75
- "DEPRECATE_COMPUTED_CHAINS": false,
76
- "DEPRECATE_EMBER_INFLECTOR": false,
77
- "DEPRECATE_LEGACY_IMPORTS": false,
78
- "DEPRECATE_MANY_ARRAY_DUPLICATES": false,
79
- "DEPRECATE_NON_STRICT_ID": false,
80
- "DEPRECATE_NON_STRICT_TYPES": false,
81
- "DEPRECATE_NON_UNIQUE_PAYLOADS": false,
82
- "DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE": false,
83
- "DEPRECATE_STORE_EXTENDS_EMBER_OBJECT": false,
84
- "DEPRECATE_TRACKING_PACKAGE": false,
85
- "DISABLE_7X_DEPRECATIONS": false,
86
- "ENABLE_LEGACY_REQUEST_METHODS": false,
87
- "ENABLE_LEGACY_SCHEMA_SERVICE": false
88
- },
89
- "features": {
90
- "ENFORCE_STRICT_RESOURCE_FINALIZATION": false,
91
- "JSON_API_CACHE_VALIDATION_ERRORS": false,
92
- "SAMPLE_FEATURE_FLAG": null
93
- },
94
- "activeLogging": {
95
- "DEBUG_RELATIONSHIP_NOTIFICATIONS": true,
96
- "LOG_CACHE": true,
97
- "LOG_CACHE_POLICY": true,
98
- "LOG_GRAPH": true,
99
- "LOG_IDENTIFIERS": true,
100
- "LOG_INSTANCE_CACHE": true,
101
- "LOG_METRIC_COUNTS": true,
102
- "LOG_MUTATIONS": true,
103
- "LOG_NOTIFICATIONS": true,
104
- "LOG_OPERATIONS": true,
105
- "LOG_PAYLOADS": true,
106
- "LOG_REACT_SIGNAL_INTEGRATION": true,
107
- "LOG_REQUESTS": true,
108
- "LOG_REQUEST_STATUS": true,
109
- "__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS": true
110
- },
111
- "env": {
112
- "TESTING": true,
113
- "PRODUCTION": false,
114
- "DEBUG": true,
115
- "IS_RECORDING": false,
116
- "IS_CI": true,
117
- "SHOULD_RECORD": false
118
- }
119
- }
120
- }
121
- };
122
- }
123
- function updaterMethods() {
124
- return {
125
- config,
126
- getGlobalConfig,
127
- setConfig(packageRoot, value) {
128
- runtimeConfig.packages[packageRoot] = value;
129
- },
130
- setGlobalConfig(key, value) {
131
- runtimeConfig.global[key] = value;
132
- }
133
- };
134
- }
135
-
136
- // this is how runtime config can get injected at boot. I'm not sure yet if this
137
- // should be public API, but we certainly need it internally to set things like
138
- // the global fastboot.isRunning.
139
- //
140
- // consumers of this API push a function onto
141
- // window._embroider_macros_runtime_config. The function is given four methods
142
- // which allow it to read and write the per-package and global configs. The
143
- // reason for allowing both read & write is that merging strategies are up to
144
- // each consumers -- read first, then merge, then write.
145
- //
146
- // For an example user of this API, see where we generate
147
- // embroider_macros_fastboot_init.js' in @embroider/core.
148
- let updaters = typeof window !== 'undefined' ? window._embroider_macros_runtime_config : undefined;
149
- if (updaters) {
150
- let methods = updaterMethods();
151
- for (let updater of updaters) {
152
- updater(methods);
153
- }
154
- }
155
- var _jsxFileName = "/home/runner/work/warp-drive/warp-drive/warp-drive-packages/react/src/-private/reactive-context.tsx";
156
- let nextFlush = null;
157
- let watchers = [];
158
- let watcherId = 0;
159
- function clearWatcher(state) {
160
- state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));
161
- }
162
- function flush(state) {
163
- state.pending = false;
164
- if (state.destroyed) {
165
- {
166
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
167
- console.log(`[WarpDrive] Detected Watcher Destroyed During Notify Flush, clearing signals`);
168
- }
169
- }
170
- state.snapshot = null;
171
- clearWatcher(state);
172
- return;
173
- }
174
- {
175
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
176
- console.log(`[WarpDrive] Notifying React That WatcherContext:${state.watcherId} Has Updated`);
177
- console.log("all signals", new Set(Signal.subtle.introspectSources(state.watcher)));
178
- console.log("dirty signals", new Set(state.watcher.getPending()));
179
- }
180
- } // any time signals have changed, we notify React that our store has updated
181
- state.snapshot = {
182
- watcher: state.watcher
183
- };
184
- if (state.notifyReact) state.notifyReact();
185
-
186
- // tell the Watcher to start watching for changes again
187
- // by signaling that notifications have been flushed.
188
- state.watcher.watch();
189
- }
190
- function _createWatcher() {
191
- const id = watcherId++;
192
- {
193
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
194
- console.log(`[WarpDrive] Creating a WatcherContext:${id}`);
195
- }
196
- }
197
- const state = {
198
- watcherId: id,
199
- pending: false,
200
- destroyed: false,
201
- notifyReact: null,
202
- watcher: null,
203
- // the extra wrapper returned here ensures that the context value for the watcher
204
- // changes causing a re-render when the watcher is updated.
205
- snapshot: null
206
- };
207
- state.watcher = new Signal.subtle.Watcher((...args) => {
208
- {
209
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
210
- console.log(`watcher ${state.watcherId} notified`, args, state.watcher);
211
- }
212
- }
213
- if (!state.pending && !state.destroyed) {
214
- watchers.push(state);
215
- state.pending = true;
216
- if (!nextFlush) {
217
- nextFlush = new Promise(resolve => {
218
- queueMicrotask(() => {
219
- queueMicrotask(() => {
220
- queueMicrotask(() => {
221
- watchers.forEach(flush);
222
- {
223
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
224
- console.log("Flushed watcher:", watchers.map(w => w.watcherId));
225
- }
226
- }
227
- watchers = [];
228
- nextFlush = null;
229
- resolve();
230
- });
231
- });
232
- });
233
- });
234
- }
235
- } else if (state.destroyed) {
236
- {
237
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
238
- console.log(`[WarpDrive] Detected Watcher Destroyed During Notify, clearing signals`);
239
- }
240
- } // if we are destroyed, we clear the watcher signals
241
- // so that it does not continue to watch for changes.
242
- state.snapshot = null;
243
- clearWatcher(state);
244
- }
245
- });
246
-
247
- // The watcher won't begin watching until we call `watcher.watch()`
248
- state.watcher.watch();
249
- state.snapshot = {
250
- watcher: state.watcher
251
- };
252
- return state;
253
- }
254
- function useWatcher() {
255
- const state = useMemo(_createWatcher, []);
256
- return useSyncExternalStore(notifyChanged => {
257
- {
258
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
259
- console.log(`[WarpDrive] Subscribing to Watcher`);
260
- }
261
- }
262
- state.destroyed = false;
263
- state.notifyReact = notifyChanged;
264
-
265
- // The watcher won't begin watching until we call `watcher.watch()`
266
- state.watcher.watch();
267
- return () => {
268
- {
269
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
270
- console.log(`[WarpDrive] Deactivating Watcher Subscription`);
271
- }
272
- }
273
- state.destroyed = true;
274
- state.notifyReact = null;
275
- };
276
- }, () => state.snapshot);
277
- }
278
-
279
- /**
280
- * @category Contexts
281
- */
282
- const WatcherContext = /*#__PURE__*/createContext(null);
283
-
284
- /**
285
- *
286
- * @category Components
287
- */
288
- function ReactiveContext({
289
- children
290
- }) {
291
- const watcher = useWatcher();
292
- /**
293
- * Unlike other frameworks, React does not have a built-in way to provide
294
- * a context value other than by rendering an extra component.
295
- *
296
- */
297
- return /*#__PURE__*/jsxDEV(WatcherContext, {
298
- value: watcher,
299
- children: children
300
- }, void 0, false, {
301
- fileName: _jsxFileName,
302
- lineNumber: 164,
303
- columnNumber: 10
304
- }, this);
305
- }
306
- export { ReactiveContext as R, WatcherContext as W, getGlobalConfig as g };