@ember-data/store 5.4.0-alpha.3 → 5.4.0-alpha.4
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/addon/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as AdapterPopulatedRecordArray, C as CacheHandler, h as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, g as SOURCE, S as Store, m as StoreMap, _ as _clearCaches, e as coerceId, j as fastPush, i as isStableIdentifier, n as notifyArray, p as peekCache, r as recordIdentifierFor, k as removeRecordDataFor, o as setCacheFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, l as setRecordIdentifier, s as storeFor } from "./store-service-
|
|
1
|
+
export { f as AdapterPopulatedRecordArray, C as CacheHandler, h as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, g as SOURCE, S as Store, m as StoreMap, _ as _clearCaches, e as coerceId, j as fastPush, i as isStableIdentifier, n as notifyArray, p as peekCache, r as recordIdentifierFor, k as removeRecordDataFor, o as setCacheFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, l as setRecordIdentifier, s as storeFor } from "./store-service-aa7f91c0";
|
package/addon/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheHandler, S as default, r as recordIdentifierFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./store-service-
|
|
1
|
+
export { C as CacheHandler, S as default, r as recordIdentifierFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./store-service-aa7f91c0";
|
|
@@ -396,6 +396,10 @@ function ensureStringId(id) {
|
|
|
396
396
|
// provided for additional debuggability
|
|
397
397
|
const DEBUG_CLIENT_ORIGINATED = Symbol('record-originated-on-client');
|
|
398
398
|
const DEBUG_IDENTIFIER_BUCKET = Symbol('identifier-bucket');
|
|
399
|
+
const DEBUG_STALE_CACHE_OWNER = Symbol('warpDriveStaleCache');
|
|
400
|
+
|
|
401
|
+
// also present in production
|
|
402
|
+
const CACHE_OWNER = Symbol('warpDriveCache');
|
|
399
403
|
function normalizeModelName(type) {
|
|
400
404
|
if (macroCondition(getOwnConfig().deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
401
405
|
const result = dasherize(type);
|
|
@@ -476,7 +480,7 @@ function hasType(resource) {
|
|
|
476
480
|
const IDENTIFIERS = new Set();
|
|
477
481
|
const DOCUMENTS = new Set();
|
|
478
482
|
function isStableIdentifier(identifier) {
|
|
479
|
-
return IDENTIFIERS.has(identifier);
|
|
483
|
+
return identifier[CACHE_OWNER] !== undefined || IDENTIFIERS.has(identifier);
|
|
480
484
|
}
|
|
481
485
|
function isDocumentIdentifier(identifier) {
|
|
482
486
|
return DOCUMENTS.has(identifier);
|
|
@@ -519,6 +523,7 @@ function setIdentifierResetMethod(method) {
|
|
|
519
523
|
// Map<type, Map<id, lid>>
|
|
520
524
|
|
|
521
525
|
const NEW_IDENTIFIERS = new Map();
|
|
526
|
+
let IDENTIFIER_CACHE_ID = 0;
|
|
522
527
|
function updateTypeIdMapping(typeMap, identifier, id) {
|
|
523
528
|
let idMap = typeMap.get(identifier.type);
|
|
524
529
|
if (!idMap) {
|
|
@@ -601,6 +606,7 @@ class IdentifierCache {
|
|
|
601
606
|
this._merge = defaultMergeMethod;
|
|
602
607
|
this._keyInfoForResource = defaultKeyInfoMethod;
|
|
603
608
|
this._isDefaultConfig = !configuredGenerationMethod;
|
|
609
|
+
this._id = IDENTIFIER_CACHE_ID++;
|
|
604
610
|
this._cache = {
|
|
605
611
|
resources: new Map(),
|
|
606
612
|
resourcesByType: Object.create(null),
|
|
@@ -676,11 +682,13 @@ class IdentifierCache {
|
|
|
676
682
|
// if we still don't have an identifier, time to generate one
|
|
677
683
|
if (shouldGenerate === 2) {
|
|
678
684
|
resource.lid = lid;
|
|
685
|
+
resource[CACHE_OWNER] = this._id;
|
|
679
686
|
identifier = /*#__NOINLINE__*/makeStableRecordIdentifier(resource, 'record', false);
|
|
680
687
|
} else {
|
|
681
688
|
// we lie a bit here as a memory optimization
|
|
682
689
|
const keyInfo = this._keyInfoForResource(resource, null);
|
|
683
690
|
keyInfo.lid = lid;
|
|
691
|
+
keyInfo[CACHE_OWNER] = this._id;
|
|
684
692
|
identifier = /*#__NOINLINE__*/makeStableRecordIdentifier(keyInfo, 'record', false);
|
|
685
693
|
}
|
|
686
694
|
addResourceToCache(this._cache, identifier);
|
|
@@ -767,7 +775,8 @@ class IdentifierCache {
|
|
|
767
775
|
let identifier = /*#__NOINLINE__*/makeStableRecordIdentifier({
|
|
768
776
|
id: data.id || null,
|
|
769
777
|
type: data.type,
|
|
770
|
-
lid: newLid
|
|
778
|
+
lid: newLid,
|
|
779
|
+
[CACHE_OWNER]: this._id
|
|
771
780
|
}, 'record', true);
|
|
772
781
|
|
|
773
782
|
// populate our unique table
|
|
@@ -899,6 +908,10 @@ class IdentifierCache {
|
|
|
899
908
|
}
|
|
900
909
|
this._cache.resources.delete(identifier.lid);
|
|
901
910
|
typeSet.lid.delete(identifier.lid);
|
|
911
|
+
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
912
|
+
identifier[DEBUG_STALE_CACHE_OWNER] = identifier[CACHE_OWNER];
|
|
913
|
+
}
|
|
914
|
+
identifier[CACHE_OWNER] = undefined;
|
|
902
915
|
IDENTIFIERS.delete(identifier);
|
|
903
916
|
this._forget(identifier, 'record');
|
|
904
917
|
if (macroCondition(getOwnConfig().debug.LOG_IDENTIFIERS)) {
|
|
@@ -929,6 +942,19 @@ function makeStableRecordIdentifier(recordIdentifier, bucket, clientOriginated)
|
|
|
929
942
|
get type() {
|
|
930
943
|
return recordIdentifier.type;
|
|
931
944
|
},
|
|
945
|
+
get [CACHE_OWNER]() {
|
|
946
|
+
return recordIdentifier[CACHE_OWNER];
|
|
947
|
+
},
|
|
948
|
+
set [CACHE_OWNER](value) {
|
|
949
|
+
recordIdentifier[CACHE_OWNER] = value;
|
|
950
|
+
},
|
|
951
|
+
get [DEBUG_STALE_CACHE_OWNER]() {
|
|
952
|
+
return recordIdentifier[DEBUG_STALE_CACHE_OWNER];
|
|
953
|
+
},
|
|
954
|
+
set [DEBUG_STALE_CACHE_OWNER](value) {
|
|
955
|
+
recordIdentifier[DEBUG_STALE_CACHE_OWNER] = value;
|
|
956
|
+
},
|
|
957
|
+
// @ts-expect-error debug only
|
|
932
958
|
toString() {
|
|
933
959
|
const {
|
|
934
960
|
type,
|
|
@@ -2818,7 +2844,7 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
2818
2844
|
}
|
|
2819
2845
|
this.isUpdating = true;
|
|
2820
2846
|
let updatingPromise = this._update();
|
|
2821
|
-
updatingPromise.finally(() => {
|
|
2847
|
+
void updatingPromise.finally(() => {
|
|
2822
2848
|
this._updatingPromise = null;
|
|
2823
2849
|
if (this.isDestroying || this.isDestroyed) {
|
|
2824
2850
|
return;
|