@ember-data/store 4.11.1 → 4.11.2
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/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@module @ember-data/store
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { addTransactionCB } from '@ember-data/tracking/-private';
|
|
5
5
|
import type { CollectionResourceDocument } from '@ember-data/types/q/ember-data-json-api';
|
|
6
6
|
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';
|
|
7
7
|
import type { Dict } from '@ember-data/types/q/utils';
|
|
@@ -10,6 +10,8 @@ import IdentifierArray, {
|
|
|
10
10
|
Collection,
|
|
11
11
|
CollectionCreateOptions,
|
|
12
12
|
IDENTIFIER_ARRAY_TAG,
|
|
13
|
+
NOTIFY,
|
|
14
|
+
notifyArray,
|
|
13
15
|
SOURCE,
|
|
14
16
|
} from '../record-arrays/identifier-array';
|
|
15
17
|
import type Store from '../store-service';
|
|
@@ -175,9 +177,9 @@ class RecordArrayManager {
|
|
|
175
177
|
let tag = array[IDENTIFIER_ARRAY_TAG];
|
|
176
178
|
if (!tag.shouldReset) {
|
|
177
179
|
tag.shouldReset = true;
|
|
178
|
-
|
|
179
|
-
} else if (delta > 0 && tag.t) {
|
|
180
|
-
|
|
180
|
+
addTransactionCB(array[NOTIFY]);
|
|
181
|
+
} else if (delta > 0 && !tag.t) {
|
|
182
|
+
addTransactionCB(array[NOTIFY]);
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
|
|
@@ -244,7 +246,8 @@ class RecordArrayManager {
|
|
|
244
246
|
const old = source.slice();
|
|
245
247
|
source.length = 0;
|
|
246
248
|
fastPush(source, identifiers);
|
|
247
|
-
|
|
249
|
+
|
|
250
|
+
notifyArray(array);
|
|
248
251
|
array.meta = payload.meta || null;
|
|
249
252
|
array.links = payload.links || null;
|
|
250
253
|
array.isLoaded = true;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@module @ember-data/store
|
|
3
3
|
*/
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
import { tagForProperty } from '@ember/-internals/metal';
|
|
4
6
|
import { assert, deprecate } from '@ember/debug';
|
|
5
7
|
import { get, set } from '@ember/object';
|
|
6
8
|
import { dependentKeyCompat } from '@ember/object/compat';
|
|
7
9
|
import { compare } from '@ember/utils';
|
|
8
10
|
import { DEBUG } from '@glimmer/env';
|
|
9
11
|
import { tracked } from '@glimmer/tracking';
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
import { dirtyTag } from '@glimmer/validator';
|
|
10
14
|
import Ember from 'ember';
|
|
11
15
|
|
|
12
16
|
import {
|
|
13
17
|
DEPRECATE_A_USAGE,
|
|
14
18
|
DEPRECATE_ARRAY_LIKE,
|
|
19
|
+
DEPRECATE_COMPUTED_CHAINS,
|
|
15
20
|
DEPRECATE_PROMISE_PROXIES,
|
|
16
21
|
DEPRECATE_SNAPSHOT_MODEL_CLASS_ACCESS,
|
|
17
22
|
} from '@ember-data/private-build-infra/deprecations';
|
|
@@ -63,6 +68,18 @@ function isArraySetter(prop: KeyType): boolean {
|
|
|
63
68
|
export const IDENTIFIER_ARRAY_TAG = Symbol('#tag');
|
|
64
69
|
export const SOURCE = Symbol('#source');
|
|
65
70
|
export const MUTATE = Symbol('#update');
|
|
71
|
+
export const NOTIFY = Symbol('#notify');
|
|
72
|
+
|
|
73
|
+
export function notifyArray(arr: IdentifierArray) {
|
|
74
|
+
arr[IDENTIFIER_ARRAY_TAG].ref = null;
|
|
75
|
+
|
|
76
|
+
if (DEPRECATE_COMPUTED_CHAINS) {
|
|
77
|
+
// eslint-disable-next-line
|
|
78
|
+
dirtyTag(tagForProperty(arr, 'length'));
|
|
79
|
+
// eslint-disable-next-line
|
|
80
|
+
dirtyTag(tagForProperty(arr, '[]'));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
66
83
|
|
|
67
84
|
function convertToInt(prop: KeyType): number | null {
|
|
68
85
|
if (typeof prop === 'symbol') return null;
|
|
@@ -76,8 +93,16 @@ function convertToInt(prop: KeyType): number | null {
|
|
|
76
93
|
|
|
77
94
|
class Tag {
|
|
78
95
|
@tracked ref = null;
|
|
79
|
-
shouldReset: boolean
|
|
80
|
-
|
|
96
|
+
declare shouldReset: boolean;
|
|
97
|
+
/*
|
|
98
|
+
* whether this was part of a transaction when last mutated
|
|
99
|
+
*/
|
|
100
|
+
declare t: boolean;
|
|
101
|
+
|
|
102
|
+
constructor() {
|
|
103
|
+
this.shouldReset = false;
|
|
104
|
+
this.t = false;
|
|
105
|
+
}
|
|
81
106
|
}
|
|
82
107
|
|
|
83
108
|
type ProxiedMethod = (...args: unknown[]) => unknown;
|
|
@@ -127,11 +152,9 @@ interface PrivateState {
|
|
|
127
152
|
@class RecordArray
|
|
128
153
|
@public
|
|
129
154
|
*/
|
|
130
|
-
|
|
131
|
-
interface IdentifierArray {
|
|
155
|
+
interface IdentifierArray extends Omit<Array<RecordInstance>, '[]'> {
|
|
132
156
|
[MUTATE]?(prop: string, args: unknown[], result?: unknown): void;
|
|
133
157
|
}
|
|
134
|
-
interface IdentifierArray extends Array<RecordInstance> {}
|
|
135
158
|
class IdentifierArray {
|
|
136
159
|
declare DEPRECATED_CLASS_NAME: string;
|
|
137
160
|
/**
|
|
@@ -155,6 +178,9 @@ class IdentifierArray {
|
|
|
155
178
|
|
|
156
179
|
[IDENTIFIER_ARRAY_TAG] = new Tag();
|
|
157
180
|
[SOURCE]: StableRecordIdentifier[];
|
|
181
|
+
[NOTIFY]() {
|
|
182
|
+
notifyArray(this);
|
|
183
|
+
}
|
|
158
184
|
|
|
159
185
|
declare links: Links | PaginationLinks | null;
|
|
160
186
|
declare meta: Dict<unknown> | null;
|
|
@@ -183,7 +209,7 @@ class IdentifierArray {
|
|
|
183
209
|
// changing the reference breaks the Proxy
|
|
184
210
|
// this[SOURCE] = [];
|
|
185
211
|
this[SOURCE].length = 0;
|
|
186
|
-
this[
|
|
212
|
+
this[NOTIFY]();
|
|
187
213
|
this.isDestroyed = true;
|
|
188
214
|
}
|
|
189
215
|
|
|
@@ -196,6 +222,14 @@ class IdentifierArray {
|
|
|
196
222
|
this[SOURCE].length = value;
|
|
197
223
|
}
|
|
198
224
|
|
|
225
|
+
// here to support computed chains
|
|
226
|
+
// and {{#each}}
|
|
227
|
+
get '[]'() {
|
|
228
|
+
if (DEPRECATE_COMPUTED_CHAINS) {
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
199
233
|
constructor(options: IdentifierArrayCreateOptions) {
|
|
200
234
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
201
235
|
let self = this;
|
|
@@ -296,6 +330,10 @@ class IdentifierArray {
|
|
|
296
330
|
}
|
|
297
331
|
}
|
|
298
332
|
|
|
333
|
+
if (prop === NOTIFY || prop === IDENTIFIER_ARRAY_TAG || prop === SOURCE) {
|
|
334
|
+
return self[prop];
|
|
335
|
+
}
|
|
336
|
+
|
|
299
337
|
let fn = boundFns.get(prop);
|
|
300
338
|
if (fn) return fn;
|
|
301
339
|
|
|
@@ -403,6 +441,8 @@ class IdentifierArray {
|
|
|
403
441
|
};
|
|
404
442
|
}
|
|
405
443
|
|
|
444
|
+
this[NOTIFY] = this[NOTIFY].bind(proxy);
|
|
445
|
+
|
|
406
446
|
return proxy;
|
|
407
447
|
}
|
|
408
448
|
|
|
@@ -544,7 +584,7 @@ export class Collection extends IdentifierArray {
|
|
|
544
584
|
Collection.prototype.query = null;
|
|
545
585
|
|
|
546
586
|
// Ensure instanceof works correctly
|
|
547
|
-
//
|
|
587
|
+
//Object.setPrototypeOf(IdentifierArray.prototype, Array.prototype);
|
|
548
588
|
|
|
549
589
|
if (DEPRECATE_ARRAY_LIKE) {
|
|
550
590
|
IdentifierArray.prototype.DEPRECATED_CLASS_NAME = 'RecordArray';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"description": "The core of EmberData. Provides the Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"directories": {},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@ember-data/model": "4.11.
|
|
18
|
-
"@ember-data/record-data": "4.11.
|
|
19
|
-
"@ember-data/tracking": "4.11.
|
|
17
|
+
"@ember-data/model": "4.11.2",
|
|
18
|
+
"@ember-data/record-data": "4.11.2",
|
|
19
|
+
"@ember-data/tracking": "4.11.2",
|
|
20
20
|
"@ember/string": "^3.0.1",
|
|
21
21
|
"@glimmer/tracking": "^1.1.2"
|
|
22
22
|
},
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ember-data/canary-features": "4.11.
|
|
41
|
-
"@ember-data/private-build-infra": "4.11.
|
|
40
|
+
"@ember-data/canary-features": "4.11.2",
|
|
41
|
+
"@ember-data/private-build-infra": "4.11.2",
|
|
42
42
|
"@embroider/macros": "^1.10.0",
|
|
43
43
|
"ember-auto-import": "^2.4.3",
|
|
44
44
|
"ember-cached-decorator-polyfill": "^1.0.1",
|