@ember-data/store 4.12.2 → 4.12.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, j as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, h as SOURCE, S as Store, _ as _clearCaches, e as coerceId, k as fastPush, i as isStableIdentifier, n as normalizeModelName, g as notifyArray, p as peekCache, r as recordIdentifierFor, l as removeRecordDataFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./index-
|
|
1
|
+
export { f as AdapterPopulatedRecordArray, C as CacheHandler, j as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, h as SOURCE, S as Store, _ as _clearCaches, e as coerceId, k as fastPush, i as isStableIdentifier, n as normalizeModelName, g as notifyArray, p as peekCache, r as recordIdentifierFor, l as removeRecordDataFor, c as setIdentifierForgetMethod, a as setIdentifierGenerationMethod, d as setIdentifierResetMethod, b as setIdentifierUpdateMethod, s as storeFor } from "./index-7883b099";
|
|
@@ -3493,7 +3493,7 @@ class ShimModelClass {
|
|
|
3493
3493
|
});
|
|
3494
3494
|
Object.keys(attrDefs).forEach(key => {
|
|
3495
3495
|
if (attrDefs[key].type) {
|
|
3496
|
-
callback.call(binding, key, attrDefs[key]
|
|
3496
|
+
callback.call(binding, key, attrDefs[key]?.type ?? null);
|
|
3497
3497
|
}
|
|
3498
3498
|
});
|
|
3499
3499
|
}
|
|
@@ -3972,13 +3972,13 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
3972
3972
|
@type Store
|
|
3973
3973
|
*/
|
|
3974
3974
|
|
|
3975
|
-
destroy() {
|
|
3976
|
-
this.isDestroying =
|
|
3975
|
+
destroy(clear) {
|
|
3976
|
+
this.isDestroying = !clear;
|
|
3977
3977
|
// changing the reference breaks the Proxy
|
|
3978
3978
|
// this[SOURCE] = [];
|
|
3979
3979
|
this[SOURCE].length = 0;
|
|
3980
3980
|
this[NOTIFY]();
|
|
3981
|
-
this.isDestroyed =
|
|
3981
|
+
this.isDestroyed = !clear;
|
|
3982
3982
|
}
|
|
3983
3983
|
|
|
3984
3984
|
// length must be on self for proxied methods to work properly
|
|
@@ -4324,8 +4324,8 @@ class Collection extends IdentifierArray {
|
|
|
4324
4324
|
}
|
|
4325
4325
|
return promise;
|
|
4326
4326
|
}
|
|
4327
|
-
destroy() {
|
|
4328
|
-
super.destroy();
|
|
4327
|
+
destroy(clear) {
|
|
4328
|
+
super.destroy(clear);
|
|
4329
4329
|
this._manager._managed.delete(this);
|
|
4330
4330
|
this._manager._pending.delete(this);
|
|
4331
4331
|
}
|
|
@@ -4711,10 +4711,14 @@ class RecordArrayManager {
|
|
|
4711
4711
|
this._staged = new Map();
|
|
4712
4712
|
this._keyedArrays = new Map();
|
|
4713
4713
|
this._identifiers = new Map();
|
|
4714
|
+
this._set = new Map();
|
|
4715
|
+
this._visibilitySet = new Map();
|
|
4714
4716
|
this._subscription = this.store.notifications.subscribe('resource', (identifier, type) => {
|
|
4715
4717
|
if (type === 'added') {
|
|
4718
|
+
this._visibilitySet.set(identifier, true);
|
|
4716
4719
|
this.identifierAdded(identifier);
|
|
4717
4720
|
} else if (type === 'removed') {
|
|
4721
|
+
this._visibilitySet.set(identifier, false);
|
|
4718
4722
|
this.identifierRemoved(identifier);
|
|
4719
4723
|
} else if (type === 'state') {
|
|
4720
4724
|
this.identifierChanged(identifier);
|
|
@@ -4726,7 +4730,7 @@ class RecordArrayManager {
|
|
|
4726
4730
|
if (!pending || this.isDestroying || this.isDestroyed) {
|
|
4727
4731
|
return;
|
|
4728
4732
|
}
|
|
4729
|
-
sync(array, pending);
|
|
4733
|
+
sync(array, pending, this._set.get(array));
|
|
4730
4734
|
this._pending.delete(array);
|
|
4731
4735
|
}
|
|
4732
4736
|
|
|
@@ -4759,6 +4763,7 @@ class RecordArrayManager {
|
|
|
4759
4763
|
manager: this
|
|
4760
4764
|
});
|
|
4761
4765
|
this._live.set(type, array);
|
|
4766
|
+
this._set.set(array, new Set(identifiers));
|
|
4762
4767
|
}
|
|
4763
4768
|
return array;
|
|
4764
4769
|
}
|
|
@@ -4776,6 +4781,7 @@ class RecordArrayManager {
|
|
|
4776
4781
|
};
|
|
4777
4782
|
let array = new Collection(options);
|
|
4778
4783
|
this._managed.add(array);
|
|
4784
|
+
this._set.set(array, new Set(options.identifiers || []));
|
|
4779
4785
|
if (config.identifiers) {
|
|
4780
4786
|
associate(this._identifiers, array, config.identifiers);
|
|
4781
4787
|
}
|
|
@@ -4847,6 +4853,7 @@ class RecordArrayManager {
|
|
|
4847
4853
|
const old = source.slice();
|
|
4848
4854
|
source.length = 0;
|
|
4849
4855
|
fastPush(source, identifiers);
|
|
4856
|
+
this._set.set(array, new Set(identifiers));
|
|
4850
4857
|
notifyArray(array);
|
|
4851
4858
|
array.meta = payload.meta || null;
|
|
4852
4859
|
array.links = payload.links || null;
|
|
@@ -4884,21 +4891,30 @@ class RecordArrayManager {
|
|
|
4884
4891
|
}
|
|
4885
4892
|
identifierChanged(identifier) {
|
|
4886
4893
|
let newState = this.store._instanceCache.recordIsLoaded(identifier, true);
|
|
4894
|
+
|
|
4895
|
+
// if the change matches the most recent direct added/removed
|
|
4896
|
+
// state, then we can ignore it
|
|
4897
|
+
if (this._visibilitySet.get(identifier) === newState) {
|
|
4898
|
+
return;
|
|
4899
|
+
}
|
|
4887
4900
|
if (newState) {
|
|
4888
4901
|
this.identifierAdded(identifier);
|
|
4889
4902
|
} else {
|
|
4890
4903
|
this.identifierRemoved(identifier);
|
|
4891
4904
|
}
|
|
4892
4905
|
}
|
|
4893
|
-
clear() {
|
|
4894
|
-
this._live.forEach(array => array.destroy());
|
|
4895
|
-
this._managed.forEach(array => array.destroy());
|
|
4906
|
+
clear(isClear = true) {
|
|
4907
|
+
this._live.forEach(array => array.destroy(isClear));
|
|
4908
|
+
this._managed.forEach(array => array.destroy(isClear));
|
|
4896
4909
|
this._managed.clear();
|
|
4897
4910
|
this._identifiers.clear();
|
|
4911
|
+
this._pending.clear();
|
|
4912
|
+
this._set.forEach(set => set.clear());
|
|
4913
|
+
this._visibilitySet.clear();
|
|
4898
4914
|
}
|
|
4899
4915
|
destroy() {
|
|
4900
4916
|
this.isDestroying = true;
|
|
4901
|
-
this.clear();
|
|
4917
|
+
this.clear(false);
|
|
4902
4918
|
this._live.clear();
|
|
4903
4919
|
this.isDestroyed = true;
|
|
4904
4920
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -4927,20 +4943,22 @@ function disassociateIdentifier(ArraysCache, array, identifier) {
|
|
|
4927
4943
|
cache.delete(array);
|
|
4928
4944
|
}
|
|
4929
4945
|
}
|
|
4930
|
-
function sync(array, changes) {
|
|
4946
|
+
function sync(array, changes, arraySet) {
|
|
4931
4947
|
let state = array[SOURCE];
|
|
4932
4948
|
const adds = [];
|
|
4933
4949
|
const removes = [];
|
|
4934
4950
|
changes.forEach((value, key) => {
|
|
4935
4951
|
if (value === 'add') {
|
|
4936
4952
|
// likely we want to keep a Set along-side
|
|
4937
|
-
if (
|
|
4953
|
+
if (arraySet.has(key)) {
|
|
4938
4954
|
return;
|
|
4939
4955
|
}
|
|
4940
4956
|
adds.push(key);
|
|
4957
|
+
arraySet.add(key);
|
|
4941
4958
|
} else {
|
|
4942
|
-
if (
|
|
4959
|
+
if (arraySet.has(key)) {
|
|
4943
4960
|
removes.push(key);
|
|
4961
|
+
arraySet.delete(key);
|
|
4944
4962
|
}
|
|
4945
4963
|
}
|
|
4946
4964
|
});
|
|
@@ -4954,6 +4972,7 @@ function sync(array, changes) {
|
|
|
4954
4972
|
const index = state.indexOf(i);
|
|
4955
4973
|
if (index !== -1) {
|
|
4956
4974
|
state.splice(index, 1);
|
|
4975
|
+
arraySet.delete(i);
|
|
4957
4976
|
}
|
|
4958
4977
|
});
|
|
4959
4978
|
}
|
|
@@ -5337,17 +5356,34 @@ class Store extends EmberObject {
|
|
|
5337
5356
|
_run(cb) {
|
|
5338
5357
|
assert(`EmberData should never encounter a nested run`, !this._cbs);
|
|
5339
5358
|
const _cbs = this._cbs = {};
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5359
|
+
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
5360
|
+
try {
|
|
5361
|
+
cb();
|
|
5362
|
+
if (_cbs.coalesce) {
|
|
5363
|
+
_cbs.coalesce();
|
|
5364
|
+
}
|
|
5365
|
+
if (_cbs.sync) {
|
|
5366
|
+
_cbs.sync();
|
|
5367
|
+
}
|
|
5368
|
+
if (_cbs.notify) {
|
|
5369
|
+
_cbs.notify();
|
|
5370
|
+
}
|
|
5371
|
+
} finally {
|
|
5372
|
+
this._cbs = null;
|
|
5373
|
+
}
|
|
5374
|
+
} else {
|
|
5375
|
+
cb();
|
|
5376
|
+
if (_cbs.coalesce) {
|
|
5377
|
+
_cbs.coalesce();
|
|
5378
|
+
}
|
|
5379
|
+
if (_cbs.sync) {
|
|
5380
|
+
_cbs.sync();
|
|
5381
|
+
}
|
|
5382
|
+
if (_cbs.notify) {
|
|
5383
|
+
_cbs.notify();
|
|
5384
|
+
}
|
|
5385
|
+
this._cbs = null;
|
|
5349
5386
|
}
|
|
5350
|
-
this._cbs = null;
|
|
5351
5387
|
}
|
|
5352
5388
|
_join(cb) {
|
|
5353
5389
|
if (this._cbs) {
|
|
@@ -5488,7 +5524,9 @@ class Store extends EmberObject {
|
|
|
5488
5524
|
|
|
5489
5525
|
// ensure that `getOwner(this)` works inside a model instance
|
|
5490
5526
|
setOwner(createOptions, getOwner(this));
|
|
5491
|
-
|
|
5527
|
+
const factory = getModelFactory(this, this._modelFactoryCache, modelName);
|
|
5528
|
+
assert(`No model was found for '${modelName}'`, factory);
|
|
5529
|
+
return factory.class.create(createOptions);
|
|
5492
5530
|
}
|
|
5493
5531
|
assert(`You must implement the store's instantiateRecord hook for your custom model class.`);
|
|
5494
5532
|
}
|
|
@@ -5677,7 +5715,7 @@ class Store extends EmberObject {
|
|
|
5677
5715
|
let maybeFactory = getModelFactory(this, this._modelFactoryCache, normalizedModelName);
|
|
5678
5716
|
|
|
5679
5717
|
// for factorFor factory/class split
|
|
5680
|
-
|
|
5718
|
+
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
5681
5719
|
if (!klass || !klass.isModel || this._forceShim) {
|
|
5682
5720
|
assert(`No model was found for '${modelName}' and no schema handles the type`, this.getSchemaDefinitionService().doesTypeExist(modelName));
|
|
5683
5721
|
return getShimClass(this, modelName);
|