@warp-drive/core 5.7.0-alpha.13 → 5.7.0-alpha.15
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/declarations/graph/-private/-diff.d.ts +8 -8
- package/declarations/graph/-private/-edge-definition.d.ts +2 -2
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +5 -5
- package/declarations/graph/-private/graph.d.ts +15 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +2 -2
- package/declarations/reactive/-private/document.d.ts +6 -16
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/record.d.ts +44 -5
- package/declarations/reactive/-private/schema.d.ts +12 -12
- package/declarations/reactive/-private/symbols.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +2 -2
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +2 -2
- package/declarations/request/-private/types.d.ts +4 -4
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +18 -18
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +21 -19
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
- package/declarations/store/-private/managers/notification-manager.d.ts +21 -25
- package/declarations/store/-private/managers/record-array-manager.d.ts +78 -27
- package/declarations/store/-private/network/request-cache.d.ts +11 -11
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +1 -1
- package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
- package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
- package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
- package/declarations/store/-private/store-service.d.ts +22 -19
- package/declarations/store/-private.d.ts +5 -3
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/schema-service.d.ts +9 -9
- package/declarations/store/deprecated/-private.d.ts +5 -5
- package/declarations/store/deprecated/store.d.ts +8 -9
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -113
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +60 -76
- package/declarations/types/request.d.ts +27 -6
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +1 -1
- package/declarations/types/spec/document.d.ts +6 -6
- package/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
- package/dist/graph/-private.js +129 -129
- package/dist/index.js +6 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +126 -4
- package/dist/{request-state-BWYju5O9.js → request-state-CQ0Q6d1V.js} +4290 -4218
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/store.js +32 -44
- package/dist/{symbols-BoONANuz.js → symbols-sql1_mdx.js} +2 -2
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +27 -0
- package/dist/types/schema/fields.js +2 -0
- package/package.json +3 -3
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { setLogging, getRuntimeConfig } from './types/runtime.js';
|
|
2
|
-
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-
|
|
2
|
+
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-kQXhkeBj.js";
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
4
|
import { w as waitFor } from "./configure-B48bFHOl.js";
|
|
5
5
|
import { peekUniversalTransient, setUniversalTransient } from './types/-private.js';
|
|
6
|
-
export { C as CacheHandler, S as Store, r as recordIdentifierFor,
|
|
6
|
+
export { C as CacheHandler, S as Store, r as recordIdentifierFor, M as setIdentifierForgetMethod, K as setIdentifierGenerationMethod, N as setIdentifierResetMethod, L as setIdentifierUpdateMethod, O as setKeyInfoForResource, s as storeFor } from "./request-state-CQ0Q6d1V.js";
|
|
7
7
|
import '@ember/debug';
|
|
8
8
|
import './utils/string.js';
|
|
9
|
+
import "./symbols-sql1_mdx.js";
|
|
9
10
|
|
|
10
11
|
// Lazily close over fetch to avoid breaking Mirage
|
|
11
12
|
const _fetch = typeof fetch !== 'undefined' ? (...args) => fetch(...args) : typeof FastBoot !== 'undefined' ? (...args) => FastBoot.require('node-fetch')(...args) : () => {
|
|
@@ -60,6 +61,9 @@ const Fetch = {
|
|
|
60
61
|
} else {
|
|
61
62
|
e.statusText = 'Unknown Network Error';
|
|
62
63
|
e.status = 0;
|
|
64
|
+
if (!(e instanceof DOMException)) {
|
|
65
|
+
e.code = 0;
|
|
66
|
+
}
|
|
63
67
|
e.isRequestError = true;
|
|
64
68
|
}
|
|
65
69
|
throw e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as Context } from "../symbols-
|
|
1
|
+
export { C as Context } from "../symbols-sql1_mdx.js";
|
package/dist/reactive.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { F as ReactiveResource, G as isNonIdentityCacheableField, H as getFieldCacheKeyStrict, r as recordIdentifierFor, z as withSignalStore } from "./request-state-CQ0Q6d1V.js";
|
|
2
|
+
export { I as checkout, J as commit } from "./request-state-CQ0Q6d1V.js";
|
|
1
3
|
import { isResourceSchema } from './types/schema/fields.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { a as Checkout } from "./symbols-BoONANuz.js";
|
|
4
|
+
import { D as Destroy, C as Context } from "./symbols-sql1_mdx.js";
|
|
5
|
+
export { a as Checkout } from "./symbols-sql1_mdx.js";
|
|
5
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
7
|
import { warn, deprecate } from '@ember/debug';
|
|
7
8
|
import './index.js';
|
|
@@ -772,4 +773,125 @@ function mergeMap(base, toApply) {
|
|
|
772
773
|
base.set(key, value);
|
|
773
774
|
}
|
|
774
775
|
}
|
|
775
|
-
|
|
776
|
+
const Subscriptions = new WeakMap();
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* `ExpensiveSubscription` is a mechanism for non-reactive
|
|
780
|
+
* frameworks such as `react` to integrate with WarpDrive.
|
|
781
|
+
*
|
|
782
|
+
* This mechanism should never be used by frameworks or libraries
|
|
783
|
+
* that support fine-grained reactivity.
|
|
784
|
+
*
|
|
785
|
+
* ExpensiveSubscription is expensive *because* it doubles the number
|
|
786
|
+
* of notification callbacks required for each resource contained in
|
|
787
|
+
* the request being subscribed to. The more requests in-use, the more
|
|
788
|
+
* this cost adds up.
|
|
789
|
+
*/
|
|
790
|
+
class ExpensiveSubscription {
|
|
791
|
+
constructor(store, request) {
|
|
792
|
+
this._store = store;
|
|
793
|
+
this._request = request;
|
|
794
|
+
this._callbacks = new Set();
|
|
795
|
+
this._resources = new Map();
|
|
796
|
+
this._subscription = store.notifications.subscribe(request, this._notifyRequestChange);
|
|
797
|
+
this._updateResourceCallbacks();
|
|
798
|
+
}
|
|
799
|
+
_updateResourceCallbacks() {
|
|
800
|
+
const request = this._request;
|
|
801
|
+
const store = this._store;
|
|
802
|
+
const {
|
|
803
|
+
notifications
|
|
804
|
+
} = store;
|
|
805
|
+
const req = store.cache.peek(request);
|
|
806
|
+
const resources = this._resources;
|
|
807
|
+
const isInitialSubscription = resources.size === 0;
|
|
808
|
+
if (req && 'data' in req) {
|
|
809
|
+
if (Array.isArray(req.data)) {
|
|
810
|
+
for (const resourceKey of req.data) {
|
|
811
|
+
if (isInitialSubscription || !resources.has(resourceKey)) {
|
|
812
|
+
resources.set(resourceKey, notifications.subscribe(resourceKey, this._scheduleNotify));
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
} else if (req.data) {
|
|
816
|
+
if (isInitialSubscription || !resources.has(req.data)) {
|
|
817
|
+
resources.set(req.data, notifications.subscribe(req.data, this._scheduleNotify));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (req && 'included' in req && Array.isArray(req.included)) {
|
|
822
|
+
for (const resourceKey of req.included) {
|
|
823
|
+
if (isInitialSubscription || !resources.has(resourceKey)) {
|
|
824
|
+
resources.set(resourceKey, notifications.subscribe(resourceKey, this._scheduleNotify));
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
_notifyRequestChange = () => {
|
|
830
|
+
this._updateResourceCallbacks();
|
|
831
|
+
this._scheduleNotify();
|
|
832
|
+
};
|
|
833
|
+
_scheduleNotify = () => {
|
|
834
|
+
this._notify = this._notify || Promise.resolve().then(() => {
|
|
835
|
+
for (const callback of this._callbacks) {
|
|
836
|
+
callback();
|
|
837
|
+
}
|
|
838
|
+
this._notify = null;
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
addWatcher(callback) {
|
|
842
|
+
this._callbacks.add(callback);
|
|
843
|
+
}
|
|
844
|
+
removeWatcher(callback) {
|
|
845
|
+
this._callbacks.delete(callback);
|
|
846
|
+
if (this._callbacks.size === 0) {
|
|
847
|
+
this.destroy();
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
destroy() {
|
|
851
|
+
Subscriptions.delete(this._request);
|
|
852
|
+
const {
|
|
853
|
+
notifications
|
|
854
|
+
} = this._store;
|
|
855
|
+
if (this._subscription) {
|
|
856
|
+
notifications.unsubscribe(this._subscription);
|
|
857
|
+
}
|
|
858
|
+
for (const token of this._resources.values()) {
|
|
859
|
+
notifications.unsubscribe(token);
|
|
860
|
+
}
|
|
861
|
+
this._callbacks.clear();
|
|
862
|
+
this._resources.clear();
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Creates an {@link ExpensiveSubscription} for the {@link RequestKey}
|
|
868
|
+
* if one does not already exist and adds a watcher to it.
|
|
869
|
+
*
|
|
870
|
+
* Returns a cleanup function. This should be called on-mount by a component
|
|
871
|
+
* that wants to subscribe to a request and cleanup should be called on dismount.
|
|
872
|
+
*
|
|
873
|
+
* ::: warning ⚠️ Avoid Using If Your App Supports Fine-grained Reactivity
|
|
874
|
+
* This mechanism should never be used by frameworks or libraries
|
|
875
|
+
* that support fine-grained reactivity.
|
|
876
|
+
* :::
|
|
877
|
+
*
|
|
878
|
+
* `ExpensiveSubscription` is a mechanism for non-reactive
|
|
879
|
+
* frameworks such as `react` to integrate with WarpDrive, for instance
|
|
880
|
+
* by treating a request as an [external store](https://react.dev/reference/react/useSyncExternalStore)
|
|
881
|
+
*
|
|
882
|
+
* `ExpensiveSubscription` is expensive *because* it doubles the number
|
|
883
|
+
* of notification callbacks required for each resource contained in
|
|
884
|
+
* the request being subscribed to. The more requests in-use, the more
|
|
885
|
+
* this cost adds up.
|
|
886
|
+
*/
|
|
887
|
+
function getExpensiveRequestSubscription(store, requestKey, callback) {
|
|
888
|
+
let subscription = Subscriptions.get(requestKey);
|
|
889
|
+
if (!subscription) {
|
|
890
|
+
subscription = new ExpensiveSubscription(store, requestKey);
|
|
891
|
+
}
|
|
892
|
+
subscription.addWatcher(callback);
|
|
893
|
+
return () => {
|
|
894
|
+
subscription.removeWatcher(callback);
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
export { SchemaService, fromIdentity, getExpensiveRequestSubscription, instantiateRecord, registerDerivations, teardownRecord, withDefaults };
|