@ember-data/store 4.12.0-beta.1 → 4.12.0-beta.3
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 { C as AdapterPopulatedRecordArray,
|
|
1
|
+
export { C as AdapterPopulatedRecordArray, j as IDENTIFIER_ARRAY_TAG, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, h as SOURCE, a as Snapshot, l as SnapshotRecordArray, S as Store, _ as _clearCaches, f as coerceId, k as fastPush, i as isStableIdentifier, n as normalizeModelName, g as notifyArray, m as recordDataFor, r as recordIdentifierFor, o as removeRecordDataFor, d as setIdentifierForgetMethod, b as setIdentifierGenerationMethod, e as setIdentifierResetMethod, c as setIdentifierUpdateMethod, s as storeFor } from "./index-bebb407b";
|
|
@@ -6,10 +6,12 @@ import { _backburner } from '@ember/runloop';
|
|
|
6
6
|
import { registerWaiter, unregisterWaiter } from '@ember/test';
|
|
7
7
|
import RSVP, { resolve, Promise as Promise$1, reject } from 'rsvp';
|
|
8
8
|
import { tracked } from '@glimmer/tracking';
|
|
9
|
-
import { subscribe, addToTransaction } from '@ember-data/tracking/-private';
|
|
9
|
+
import { subscribe, addToTransaction, addTransactionCB } from '@ember-data/tracking/-private';
|
|
10
|
+
import { tagForProperty } from '@ember/-internals/metal';
|
|
10
11
|
import { get, set } from '@ember/object';
|
|
11
12
|
import { dependentKeyCompat } from '@ember/object/compat';
|
|
12
13
|
import { compare } from '@ember/utils';
|
|
14
|
+
import { dirtyTag } from '@glimmer/validator';
|
|
13
15
|
import Ember from 'ember';
|
|
14
16
|
import { reads } from '@ember/object/computed';
|
|
15
17
|
import ArrayProxy from '@ember/array/proxy';
|
|
@@ -2802,6 +2804,7 @@ class InstanceCache {
|
|
|
2802
2804
|
getRecord(identifier, properties) {
|
|
2803
2805
|
let record = this.__instances.record.get(identifier);
|
|
2804
2806
|
if (!record) {
|
|
2807
|
+
assert(`Cannot create a new record instance while the store is being destroyed`, !this.store.isDestroying && !this.store.isDestroyed);
|
|
2805
2808
|
const recordData = this.getRecordData(identifier);
|
|
2806
2809
|
record = this.store.instantiateRecord(identifier, properties || {}, this.__recordDataFor, this.store.notifications);
|
|
2807
2810
|
setRecordIdentifier(record, identifier);
|
|
@@ -3179,6 +3182,11 @@ function _isLoading(cache, identifier) {
|
|
|
3179
3182
|
// fulfilled === null &&
|
|
3180
3183
|
req.getPendingRequestsForRecord(identifier).some(req => req.type === 'query');
|
|
3181
3184
|
}
|
|
3185
|
+
function _clearCaches() {
|
|
3186
|
+
RecordCache.clear();
|
|
3187
|
+
StoreMap.clear();
|
|
3188
|
+
RecordDataForIdentifierCache.clear();
|
|
3189
|
+
}
|
|
3182
3190
|
let _modelForMixin;
|
|
3183
3191
|
if (macroCondition(dependencySatisfies("@ember-data/model", "*"))) {
|
|
3184
3192
|
let _found;
|
|
@@ -3452,7 +3460,7 @@ function promiseArray(promise) {
|
|
|
3452
3460
|
return Reflect.get(target, prop, receiver);
|
|
3453
3461
|
}
|
|
3454
3462
|
if (ALLOWABLE_PROPS.includes(prop)) {
|
|
3455
|
-
return
|
|
3463
|
+
return target[prop];
|
|
3456
3464
|
}
|
|
3457
3465
|
if (!ALLOWABLE_METHODS.includes(prop)) {
|
|
3458
3466
|
deprecate(`Accessing ${prop} on this PromiseArray is deprecated. The return type is being changed from PromiseArray to a Promise. The only available methods to access on this promise are .then, .catch and .finally`, false, {
|
|
@@ -3495,7 +3503,7 @@ function promiseObject(promise) {
|
|
|
3495
3503
|
return target.constructor;
|
|
3496
3504
|
}
|
|
3497
3505
|
if (ALLOWABLE_PROPS.includes(prop)) {
|
|
3498
|
-
return
|
|
3506
|
+
return target[prop];
|
|
3499
3507
|
}
|
|
3500
3508
|
if (!ALLOWABLE_METHODS.includes(prop)) {
|
|
3501
3509
|
deprecate(`Accessing ${prop} on this PromiseObject is deprecated. The return type is being changed from PromiseObject to a Promise. The only available methods to access on this promise are .then, .catch and .finally`, false, {
|
|
@@ -3535,6 +3543,16 @@ function isArraySetter(prop) {
|
|
|
3535
3543
|
const IDENTIFIER_ARRAY_TAG = Symbol('#tag');
|
|
3536
3544
|
const SOURCE = Symbol('#source');
|
|
3537
3545
|
const MUTATE = Symbol('#update');
|
|
3546
|
+
const NOTIFY = Symbol('#notify');
|
|
3547
|
+
function notifyArray(arr) {
|
|
3548
|
+
arr[IDENTIFIER_ARRAY_TAG].ref = null;
|
|
3549
|
+
if (macroCondition(getOwnConfig().deprecations.DEPRECATE_COMPUTED_CHAINS)) {
|
|
3550
|
+
// eslint-disable-next-line
|
|
3551
|
+
dirtyTag(tagForProperty(arr, 'length'));
|
|
3552
|
+
// eslint-disable-next-line
|
|
3553
|
+
dirtyTag(tagForProperty(arr, '[]'));
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3538
3556
|
function convertToInt(prop) {
|
|
3539
3557
|
if (typeof prop === 'symbol') return null;
|
|
3540
3558
|
const num = Number(prop);
|
|
@@ -3613,12 +3631,15 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
3613
3631
|
@type Boolean
|
|
3614
3632
|
*/
|
|
3615
3633
|
|
|
3634
|
+
[NOTIFY]() {
|
|
3635
|
+
notifyArray(this);
|
|
3636
|
+
}
|
|
3616
3637
|
destroy() {
|
|
3617
3638
|
this.isDestroying = true;
|
|
3618
3639
|
// changing the reference breaks the Proxy
|
|
3619
3640
|
// this[SOURCE] = [];
|
|
3620
3641
|
this[SOURCE].length = 0;
|
|
3621
|
-
this[
|
|
3642
|
+
this[NOTIFY]();
|
|
3622
3643
|
this.isDestroyed = true;
|
|
3623
3644
|
}
|
|
3624
3645
|
|
|
@@ -3629,6 +3650,14 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
3629
3650
|
set length(value) {
|
|
3630
3651
|
this[SOURCE].length = value;
|
|
3631
3652
|
}
|
|
3653
|
+
|
|
3654
|
+
// here to support computed chains
|
|
3655
|
+
// and {{#each}}
|
|
3656
|
+
get '[]'() {
|
|
3657
|
+
if (macroCondition(getOwnConfig().deprecations.DEPRECATE_COMPUTED_CHAINS)) {
|
|
3658
|
+
return this;
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3632
3661
|
constructor(options) {
|
|
3633
3662
|
_initializerDefineProperty(this, "isUpdating", _descriptor2, this);
|
|
3634
3663
|
this.isLoaded = true;
|
|
@@ -3734,6 +3763,9 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
3734
3763
|
return receiver[receiver.length - 1];
|
|
3735
3764
|
}
|
|
3736
3765
|
}
|
|
3766
|
+
if (prop === NOTIFY || prop === IDENTIFIER_ARRAY_TAG || prop === SOURCE) {
|
|
3767
|
+
return self[prop];
|
|
3768
|
+
}
|
|
3737
3769
|
let fn = boundFns.get(prop);
|
|
3738
3770
|
if (fn) return fn;
|
|
3739
3771
|
let outcome = self[prop];
|
|
@@ -3830,6 +3862,7 @@ let IdentifierArray = (_class3 = class IdentifierArray {
|
|
|
3830
3862
|
assert(`Do not call A() on EmberData RecordArrays`);
|
|
3831
3863
|
};
|
|
3832
3864
|
}
|
|
3865
|
+
this[NOTIFY] = this[NOTIFY].bind(proxy);
|
|
3833
3866
|
return proxy;
|
|
3834
3867
|
}
|
|
3835
3868
|
|
|
@@ -3958,7 +3991,7 @@ class Collection extends IdentifierArray {
|
|
|
3958
3991
|
Collection.prototype.query = null;
|
|
3959
3992
|
|
|
3960
3993
|
// Ensure instanceof works correctly
|
|
3961
|
-
//
|
|
3994
|
+
//Object.setPrototypeOf(IdentifierArray.prototype, Array.prototype);
|
|
3962
3995
|
|
|
3963
3996
|
if (macroCondition(getOwnConfig().deprecations.DEPRECATE_ARRAY_LIKE)) {
|
|
3964
3997
|
IdentifierArray.prototype.DEPRECATED_CLASS_NAME = 'RecordArray';
|
|
@@ -4403,9 +4436,9 @@ class RecordArrayManager {
|
|
|
4403
4436
|
let tag = array[IDENTIFIER_ARRAY_TAG];
|
|
4404
4437
|
if (!tag.shouldReset) {
|
|
4405
4438
|
tag.shouldReset = true;
|
|
4406
|
-
|
|
4407
|
-
} else if (delta > 0 && tag.t) {
|
|
4408
|
-
|
|
4439
|
+
addTransactionCB(array[NOTIFY]);
|
|
4440
|
+
} else if (delta > 0 && !tag.t) {
|
|
4441
|
+
addTransactionCB(array[NOTIFY]);
|
|
4409
4442
|
}
|
|
4410
4443
|
}
|
|
4411
4444
|
_getPendingFor(identifier, includeManaged, isRemove) {
|
|
@@ -4462,7 +4495,7 @@ class RecordArrayManager {
|
|
|
4462
4495
|
const old = source.slice();
|
|
4463
4496
|
source.length = 0;
|
|
4464
4497
|
fastPush(source, identifiers);
|
|
4465
|
-
array
|
|
4498
|
+
notifyArray(array);
|
|
4466
4499
|
array.meta = payload.meta || null;
|
|
4467
4500
|
array.links = payload.links || null;
|
|
4468
4501
|
array.isLoaded = true;
|
|
@@ -7660,4 +7693,4 @@ function normalizeModelName(modelName) {
|
|
|
7660
7693
|
}
|
|
7661
7694
|
assert(`normalizeModelName support has been removed`);
|
|
7662
7695
|
}
|
|
7663
|
-
export { Collection as C, IdentifierArray as I, MUTATE as M, RecordArrayManager as R, Store as S, Snapshot as a, setIdentifierGenerationMethod as b, setIdentifierUpdateMethod as c, setIdentifierForgetMethod as d, setIdentifierResetMethod as e, coerceId as f,
|
|
7696
|
+
export { Collection as C, IdentifierArray as I, MUTATE as M, RecordArrayManager as R, Store as S, _clearCaches as _, Snapshot as a, setIdentifierGenerationMethod as b, setIdentifierUpdateMethod as c, setIdentifierForgetMethod as d, setIdentifierResetMethod as e, coerceId as f, notifyArray as g, SOURCE as h, isStableIdentifier as i, IDENTIFIER_ARRAY_TAG as j, fastPush as k, SnapshotRecordArray as l, recordDataFor as m, normalizeModelName as n, removeRecordDataFor as o, recordIdentifierFor as r, storeFor as s };
|