@warp-drive/core 5.6.0-alpha.5 → 5.6.0-beta.1

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 (219) hide show
  1. package/README.md +8 -7
  2. package/cjs-dist/addon-shim.cjs +1 -0
  3. package/cjs-dist/cjs-set-config.cjs +1 -0
  4. package/declarations/build-config/babel-macros.d.ts +1 -0
  5. package/declarations/build-config/canary-features.d.ts +1 -0
  6. package/declarations/build-config/debugging.d.ts +1 -0
  7. package/declarations/build-config/deprecations.d.ts +1 -0
  8. package/declarations/build-config/env.d.ts +1 -0
  9. package/declarations/build-config/macros.d.ts +1 -0
  10. package/declarations/build-config.d.ts +1 -0
  11. package/declarations/configure.d.ts +7 -0
  12. package/declarations/graph/-private/-diff.d.ts +32 -0
  13. package/declarations/graph/-private/-edge-definition.d.ts +148 -0
  14. package/declarations/graph/-private/-state.d.ts +96 -0
  15. package/declarations/graph/-private/-utils.d.ts +31 -0
  16. package/declarations/graph/-private/coerce-id.d.ts +10 -0
  17. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +18 -0
  18. package/declarations/graph/-private/edges/collection.d.ts +39 -0
  19. package/declarations/graph/-private/edges/implicit.d.ts +43 -0
  20. package/declarations/graph/-private/edges/resource.d.ts +24 -0
  21. package/declarations/graph/-private/graph.d.ts +90 -0
  22. package/declarations/graph/-private/normalize-link.d.ts +8 -0
  23. package/declarations/graph/-private/operations/add-to-related-records.d.ts +4 -0
  24. package/declarations/graph/-private/operations/merge-identifier.d.ts +3 -0
  25. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +4 -0
  26. package/declarations/graph/-private/operations/replace-related-record.d.ts +3 -0
  27. package/declarations/graph/-private/operations/replace-related-records.d.ts +62 -0
  28. package/declarations/graph/-private/operations/update-relationship.d.ts +13 -0
  29. package/declarations/graph/-private.d.ts +13 -0
  30. package/declarations/index.d.ts +14 -3
  31. package/declarations/reactive/-private/document.d.ts +146 -0
  32. package/declarations/reactive/-private/fields/compute.d.ts +43 -0
  33. package/declarations/reactive/-private/fields/extension.d.ts +8 -0
  34. package/declarations/reactive/-private/fields/managed-array.d.ts +22 -0
  35. package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
  36. package/declarations/reactive/-private/fields/many-array-manager.d.ts +19 -0
  37. package/declarations/reactive/-private/hooks.d.ts +5 -0
  38. package/declarations/reactive/-private/record.d.ts +64 -0
  39. package/declarations/reactive/-private/schema.d.ts +271 -0
  40. package/declarations/reactive/-private/symbols.d.ts +36 -0
  41. package/declarations/reactive/-private.d.ts +1 -0
  42. package/declarations/reactive.d.ts +4 -0
  43. package/declarations/request/-private/context.d.ts +34 -35
  44. package/declarations/request/-private/debug.d.ts +2 -3
  45. package/declarations/request/-private/fetch.d.ts +24 -36
  46. package/declarations/request/-private/future.d.ts +3 -4
  47. package/declarations/request/-private/manager.d.ts +159 -132
  48. package/declarations/request/-private/promise-cache.d.ts +21 -13
  49. package/declarations/request/-private/types.d.ts +124 -123
  50. package/declarations/request/-private/utils.d.ts +8 -9
  51. package/declarations/request.d.ts +5 -433
  52. package/declarations/store/-private/cache-handler/handler.d.ts +62 -0
  53. package/declarations/store/-private/cache-handler/types.d.ts +98 -0
  54. package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
  55. package/declarations/store/-private/caches/cache-utils.d.ts +12 -0
  56. package/declarations/store/-private/caches/identifier-cache.d.ts +304 -0
  57. package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
  58. package/declarations/store/-private/caches/resource-utils.d.ts +9 -0
  59. package/declarations/store/-private/debug/utils.d.ts +6 -0
  60. package/declarations/store/-private/default-cache-policy.d.ts +384 -0
  61. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +159 -0
  62. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  63. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +25 -0
  64. package/declarations/store/-private/managers/cache-manager.d.ts +443 -0
  65. package/declarations/store/-private/managers/notification-manager.d.ts +98 -0
  66. package/declarations/store/-private/managers/record-array-manager.d.ts +97 -0
  67. package/declarations/store/-private/network/request-cache.d.ts +107 -0
  68. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +263 -0
  69. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +176 -0
  70. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +169 -0
  71. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +35 -0
  72. package/declarations/store/-private/new-core-tmp/request-state.d.ts +277 -0
  73. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +261 -0
  74. package/declarations/store/-private/record-arrays/identifier-array.d.ts +147 -0
  75. package/declarations/store/-private/record-arrays/many-array.d.ts +197 -0
  76. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +126 -0
  77. package/declarations/store/-private/store-service.d.ts +1605 -0
  78. package/declarations/store/-private/utils/coerce-id.d.ts +10 -0
  79. package/declarations/store/-private/utils/construct-resource.d.ts +6 -0
  80. package/declarations/store/-private/utils/is-non-empty-string.d.ts +1 -0
  81. package/declarations/store/-private/utils/normalize-model-name.d.ts +1 -0
  82. package/declarations/store/-private/utils/uuid-polyfill.d.ts +1 -0
  83. package/declarations/store/-private.d.ts +31 -0
  84. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +99 -0
  85. package/declarations/store/-types/q/ds-model.d.ts +21 -0
  86. package/declarations/store/-types/q/identifier.d.ts +20 -0
  87. package/declarations/store/-types/q/record-instance.d.ts +23 -0
  88. package/declarations/store/-types/q/schema-service.d.ts +354 -0
  89. package/declarations/store/-types/q/store.d.ts +32 -0
  90. package/declarations/store.d.ts +1 -0
  91. package/declarations/types/-private.d.ts +16 -8
  92. package/declarations/types/cache/aliases.d.ts +11 -1
  93. package/declarations/types/cache/change.d.ts +4 -5
  94. package/declarations/types/cache/mutations.d.ts +51 -28
  95. package/declarations/types/cache/operations.d.ts +60 -47
  96. package/declarations/types/cache/relationship.d.ts +11 -9
  97. package/declarations/types/cache.d.ts +495 -484
  98. package/declarations/types/graph.d.ts +31 -40
  99. package/declarations/types/identifier.d.ts +83 -82
  100. package/declarations/types/json/raw.d.ts +1 -2
  101. package/declarations/types/params.d.ts +4 -5
  102. package/declarations/types/record.d.ts +117 -76
  103. package/declarations/types/request.d.ts +289 -266
  104. package/declarations/types/runtime.d.ts +8 -9
  105. package/declarations/types/schema/concepts.d.ts +19 -13
  106. package/declarations/types/schema/fields.d.ts +1712 -1741
  107. package/declarations/types/schema/fields.type-test.d.ts +0 -1
  108. package/declarations/types/spec/document.d.ts +28 -22
  109. package/declarations/types/spec/error.d.ts +16 -17
  110. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  111. package/declarations/types/symbols.d.ts +74 -75
  112. package/declarations/types/utils.d.ts +5 -5
  113. package/declarations/types.d.ts +10 -7
  114. package/declarations/utils/string.d.ts +48 -0
  115. package/dist/build-config/babel-macros.js +1 -0
  116. package/dist/build-config/canary-features.js +1 -0
  117. package/dist/build-config/debugging.js +1 -0
  118. package/dist/build-config/deprecations.js +1 -0
  119. package/dist/build-config/env.js +1 -0
  120. package/dist/build-config/macros.js +1 -0
  121. package/dist/build-config.js +1 -0
  122. package/dist/configure-B48bFHOl.js +181 -0
  123. package/dist/configure.js +1 -0
  124. package/dist/{context-DE5sFezZ.js → context-COmAnXUQ.js} +2 -2
  125. package/dist/graph/-private.js +3372 -0
  126. package/dist/handler-C2T-IyJK.js +339 -0
  127. package/dist/index.js +37 -104
  128. package/dist/reactive/-private.js +1 -0
  129. package/dist/reactive.js +1988 -0
  130. package/dist/request-state-CjLph1LP.js +8139 -0
  131. package/dist/request.js +1 -1
  132. package/dist/store/-private.js +3 -0
  133. package/dist/store.js +545 -0
  134. package/dist/symbols-SIstXMLI.js +44 -0
  135. package/dist/types/-private.js +3 -3
  136. package/dist/types/record.js +1 -1
  137. package/dist/types/request.js +2 -2
  138. package/dist/types/runtime.js +1 -1
  139. package/dist/types/schema/fields.js +8 -41
  140. package/dist/types/symbols.js +3 -3
  141. package/dist/utils/string.js +92 -0
  142. package/logos/NCC-1701-a-blue.svg +4 -0
  143. package/logos/NCC-1701-a-gold.svg +4 -0
  144. package/logos/NCC-1701-a-gold_100.svg +1 -0
  145. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  146. package/logos/NCC-1701-a.svg +4 -0
  147. package/logos/README.md +4 -0
  148. package/logos/docs-badge.svg +2 -0
  149. package/logos/ember-data-logo-dark.svg +12 -0
  150. package/logos/ember-data-logo-light.svg +12 -0
  151. package/logos/github-header.svg +444 -0
  152. package/logos/social1.png +0 -0
  153. package/logos/social2.png +0 -0
  154. package/logos/warp-drive-logo-dark.svg +4 -0
  155. package/logos/warp-drive-logo-gold.svg +4 -0
  156. package/package.json +11 -8
  157. package/declarations/index.d.ts.map +0 -1
  158. package/declarations/request/-private/context.d.ts.map +0 -1
  159. package/declarations/request/-private/debug.d.ts.map +0 -1
  160. package/declarations/request/-private/fetch.d.ts.map +0 -1
  161. package/declarations/request/-private/future.d.ts.map +0 -1
  162. package/declarations/request/-private/manager.d.ts.map +0 -1
  163. package/declarations/request/-private/promise-cache.d.ts.map +0 -1
  164. package/declarations/request/-private/types.d.ts.map +0 -1
  165. package/declarations/request/-private/utils.d.ts.map +0 -1
  166. package/declarations/request.d.ts.map +0 -1
  167. package/declarations/types/-private.d.ts.map +0 -1
  168. package/declarations/types/cache/aliases.d.ts.map +0 -1
  169. package/declarations/types/cache/change.d.ts.map +0 -1
  170. package/declarations/types/cache/mutations.d.ts.map +0 -1
  171. package/declarations/types/cache/operations.d.ts.map +0 -1
  172. package/declarations/types/cache/relationship.d.ts.map +0 -1
  173. package/declarations/types/cache.d.ts.map +0 -1
  174. package/declarations/types/graph.d.ts.map +0 -1
  175. package/declarations/types/identifier.d.ts.map +0 -1
  176. package/declarations/types/json/raw.d.ts.map +0 -1
  177. package/declarations/types/params.d.ts.map +0 -1
  178. package/declarations/types/record.d.ts.map +0 -1
  179. package/declarations/types/record.type-test.d.ts +0 -2
  180. package/declarations/types/record.type-test.d.ts.map +0 -1
  181. package/declarations/types/request.d.ts.map +0 -1
  182. package/declarations/types/request.type-test.d.ts +0 -2
  183. package/declarations/types/request.type-test.d.ts.map +0 -1
  184. package/declarations/types/runtime.d.ts.map +0 -1
  185. package/declarations/types/schema/concepts.d.ts.map +0 -1
  186. package/declarations/types/schema/fields.d.ts.map +0 -1
  187. package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
  188. package/declarations/types/spec/document.d.ts.map +0 -1
  189. package/declarations/types/spec/error.d.ts.map +0 -1
  190. package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
  191. package/declarations/types/symbols.d.ts.map +0 -1
  192. package/declarations/types/utils.d.ts.map +0 -1
  193. package/declarations/types.d.ts.map +0 -1
  194. package/dist/context-DE5sFezZ.js.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/request.js.map +0 -1
  197. package/dist/types/-private.js.map +0 -1
  198. package/dist/types/cache/aliases.js.map +0 -1
  199. package/dist/types/cache/change.js.map +0 -1
  200. package/dist/types/cache/mutations.js.map +0 -1
  201. package/dist/types/cache/operations.js.map +0 -1
  202. package/dist/types/cache/relationship.js.map +0 -1
  203. package/dist/types/cache.js.map +0 -1
  204. package/dist/types/graph.js.map +0 -1
  205. package/dist/types/identifier.js.map +0 -1
  206. package/dist/types/json/raw.js.map +0 -1
  207. package/dist/types/params.js.map +0 -1
  208. package/dist/types/record.js.map +0 -1
  209. package/dist/types/request.js.map +0 -1
  210. package/dist/types/runtime.js.map +0 -1
  211. package/dist/types/schema/concepts.js.map +0 -1
  212. package/dist/types/schema/fields.js.map +0 -1
  213. package/dist/types/schema/fields.type-test.js.map +0 -1
  214. package/dist/types/spec/document.js.map +0 -1
  215. package/dist/types/spec/error.js.map +0 -1
  216. package/dist/types/spec/json-api-raw.js.map +0 -1
  217. package/dist/types/symbols.js.map +0 -1
  218. package/dist/types/utils.js.map +0 -1
  219. package/dist/types.js.map +0 -1
@@ -0,0 +1,181 @@
1
+ import { getOrSetGlobal, peekTransient, setTransient } from './types/-private.js';
2
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
3
+ const ARRAY_SIGNAL = getOrSetGlobal('#[]', Symbol('#[]'));
4
+ const OBJECT_SIGNAL = getOrSetGlobal('#{}', Symbol('#{}'));
5
+
6
+ /**
7
+ * Requirements:
8
+ *
9
+ * Signal:
10
+ *
11
+ * - signal: a way of creating a reference that we can dirty when we desire to notify
12
+ * - @signal: a way of creating an accessor on an object that subscribes to a signal on access
13
+ * and notifies the signal on set, or of upgrading a descriptor to be such an accessor
14
+ * - defineSignal: a way of creating a signal on an object
15
+ * - notifySignal: a way of notifying the underlying signal that it has been dirtied
16
+ * - peekSignal: a way of inspecting the signal without notifying it
17
+ *
18
+ * - gate: a memoized getter function that re-runs when on access if its signal is dirty
19
+ * conceptually, a gate is a tightly coupled signal and memo
20
+ * - @gate: a way of creating a gate on an object or upgrading a descriptor with a getter
21
+ * to be a gate
22
+ * - defineGate: a way of creating a gate on an object
23
+ * - notifySignal: a way of notifying the signal for a gate that it has been dirtied
24
+ *
25
+ * - memo:
26
+ * - @memo: a way of creating a memoized getter on an object or upgrading a descriptor with a getter
27
+ * to be a memo
28
+ * - defineMemo: a way of creating a memo on an object
29
+ *
30
+ * - signalStore: storage bucket for signals associated to an object
31
+ * - withSignalStore: a way of pre-creating a signal store on an object
32
+ *
33
+ *
34
+ * @internal
35
+ */
36
+
37
+ /**
38
+ * An Opaque type that represents a framework specific or TC39 signal.
39
+ *
40
+ * It may be an array of signals or a single signal.
41
+ *
42
+ * @internal
43
+ */
44
+
45
+ /**
46
+ * The hooks which MUST be configured in order to use reactive arrays,
47
+ * resources and documents with framework specfic signals or TC39 signals.
48
+ *
49
+ * Support for multiple frameworks simultaneously can be done via
50
+ * this abstraction by returning multiple signals from the `createSignal`
51
+ * method, and consuming the correct one via the correct framework via
52
+ * the `consumeSignal` and `notifySignal` methods.
53
+ *
54
+ * Unlike many signals implementations, WarpDrive does not wrap values as
55
+ * signals directly, but instead uses signals to alert the reactive layer
56
+ * to changes in the underlying cache. E.g. a signal is associated to a value,
57
+ * but does not serve as the cache for that value directly. We refer to this as
58
+ * a "gate", the pattern has also been called "side-signals".
59
+ *
60
+ * A no-op implementation is allowed, though it may lead to performance issues
61
+ * in locations that use createMemo as no memoization would be done. This is
62
+ * typically desirable only when integrating with a framework that does its own
63
+ * memoization and does not integrate with any signals-like primitive. For these
64
+ * scenarios you may also be interested in integrating with the {@link NotificationManager}
65
+ * more directly.
66
+ *
67
+ * @public
68
+ */
69
+
70
+ /**
71
+ * Contains information a {@link SignalHooks} implementation may want
72
+ * to use, such as the specialized key used for the signal
73
+ * representing an array's contents / length.
74
+ *
75
+ * ```ts
76
+ * interface HooksOptions {
77
+ * wellknown: {
78
+ * Array: symbol | string;
79
+ * }
80
+ * }
81
+ * ```
82
+ *
83
+ * @public
84
+ */
85
+
86
+ /**
87
+ * Configures the signals implementation to use. Supports multiple
88
+ * implementations simultaneously.
89
+ *
90
+ * See {@link HooksOptions} for the options passed to the provided function
91
+ * when called.
92
+ *
93
+ * See {@link SignalHooks} for the implementation the callback function should
94
+ * return.
95
+ *
96
+ * @public
97
+ * @param buildConfig - a function that takes options and returns a configuration object
98
+ */
99
+ function setupSignals(buildConfig) {
100
+ // We want to assert this but can't because too many package manager
101
+ // and bundler bugs exist that cause this to be called multiple times
102
+ // for what should be a single call.
103
+ // assert(`Cannot override configured signal hooks`, peekTransient('signalHooks') === null);
104
+ const hooks = buildConfig({
105
+ wellknown: {
106
+ Array: ARRAY_SIGNAL
107
+ }
108
+ });
109
+ setTransient('signalHooks', hooks);
110
+ }
111
+
112
+ /**
113
+ * Internal method for consuming the configured `createSignal` hook
114
+ *
115
+ * @internal
116
+ */
117
+ function createSignal(obj, key) {
118
+ const signalHooks = peekTransient('signalHooks');
119
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
120
+ if (!test) {
121
+ throw new Error(`Signal hooks not configured`);
122
+ }
123
+ })(signalHooks) : {};
124
+ return signalHooks.createSignal(obj, key);
125
+ }
126
+
127
+ /**
128
+ * Internal method for consuming the configured `consumeSignal` hook
129
+ *
130
+ * @internal
131
+ */
132
+ function consumeSignal(signal) {
133
+ const signalHooks = peekTransient('signalHooks');
134
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
135
+ if (!test) {
136
+ throw new Error(`Signal hooks not configured`);
137
+ }
138
+ })(signalHooks) : {};
139
+ return signalHooks.consumeSignal(signal);
140
+ }
141
+
142
+ /**
143
+ * Internal method for consuming the configured `notifySignal` hook
144
+ *
145
+ * @internal
146
+ */
147
+ function notifySignal(signal) {
148
+ const signalHooks = peekTransient('signalHooks');
149
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
150
+ if (!test) {
151
+ throw new Error(`Signal hooks not configured`);
152
+ }
153
+ })(signalHooks) : {};
154
+ return signalHooks.notifySignal(signal);
155
+ }
156
+ function createMemo(object, key, fn) {
157
+ const signalHooks = peekTransient('signalHooks');
158
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
159
+ if (!test) {
160
+ throw new Error(`Signal hooks not configured`);
161
+ }
162
+ })(signalHooks) : {};
163
+ return signalHooks.createMemo(object, key, fn);
164
+ }
165
+ function willSyncFlushWatchers() {
166
+ const signalHooks = peekTransient('signalHooks');
167
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
168
+ if (!test) {
169
+ throw new Error(`Signal hooks not configured`);
170
+ }
171
+ })(signalHooks) : {};
172
+ return signalHooks.willSyncFlushWatchers();
173
+ }
174
+ function waitFor(promise) {
175
+ const signalHooks = peekTransient('signalHooks');
176
+ if (signalHooks?.waitFor) {
177
+ return signalHooks.waitFor(promise);
178
+ }
179
+ return promise;
180
+ }
181
+ export { ARRAY_SIGNAL as A, OBJECT_SIGNAL as O, createSignal as a, consumeSignal as b, createMemo as c, willSyncFlushWatchers as d, notifySignal as n, setupSignals as s, waitFor as w };
@@ -0,0 +1 @@
1
+ export { s as setupSignals } from "./configure-B48bFHOl.js";
@@ -1,5 +1,5 @@
1
- import { STRUCTURED, IS_FUTURE, SkipCache } from "./types/request.js";
2
- import { getOrSetGlobal, getOrSetUniversal } from "./types/-private.js";
1
+ import { STRUCTURED, IS_FUTURE, SkipCache } from './types/request.js';
2
+ import { getOrSetGlobal, getOrSetUniversal } from './types/-private.js';
3
3
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
4
  const BODY_TYPES = {
5
5
  type: 'string',