@ember-data/store 4.6.1 → 4.6.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.
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { assert, warn } from '@ember/debug';
|
|
5
5
|
import { DEBUG } from '@glimmer/env';
|
|
6
6
|
|
|
7
|
+
import { getOwnConfig, macroCondition } from '@embroider/macros';
|
|
8
|
+
|
|
7
9
|
import type { ExistingResourceObject, ResourceIdentifierObject } from '@ember-data/types/q/ember-data-json-api';
|
|
8
10
|
import type {
|
|
9
11
|
ForgetMethod,
|
|
@@ -22,6 +24,7 @@ import coerceId from './coerce-id';
|
|
|
22
24
|
import { DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET } from './identifer-debug-consts';
|
|
23
25
|
import normalizeModelName from './normalize-model-name';
|
|
24
26
|
import isNonEmptyString from './utils/is-non-empty-string';
|
|
27
|
+
import installPolyfill from './utils/uuid-polyfill';
|
|
25
28
|
import WeakCache from './weak-cache';
|
|
26
29
|
|
|
27
30
|
const IDENTIFIERS = new WeakSet();
|
|
@@ -33,6 +36,10 @@ export function isStableIdentifier(identifier: Object): identifier is StableReco
|
|
|
33
36
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
34
37
|
const _crypto: Crypto = isFastBoot ? (FastBoot.require('crypto') as Crypto) : window.crypto;
|
|
35
38
|
|
|
39
|
+
if (macroCondition(getOwnConfig<{ polyfillUUID: boolean }>().polyfillUUID)) {
|
|
40
|
+
installPolyfill();
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
function uuidv4(): string {
|
|
37
44
|
return _crypto.randomUUID();
|
|
38
45
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module @ember-data/store
|
|
3
|
+
*/
|
|
4
|
+
interface FastbootCrypto {
|
|
5
|
+
randomFillSync(v: Uint8Array): Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function installPolyfill() {
|
|
9
|
+
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
10
|
+
const CRYPTO: Crypto = isFastBoot ? (FastBoot.require('crypto') as Crypto) : window.crypto;
|
|
11
|
+
|
|
12
|
+
if (!CRYPTO.randomUUID) {
|
|
13
|
+
// we might be able to optimize this by requesting more bytes than we need at a time
|
|
14
|
+
const rng = function (): Uint8Array {
|
|
15
|
+
// WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
|
|
16
|
+
let rnds8 = new Uint8Array(16);
|
|
17
|
+
|
|
18
|
+
if (!CRYPTO.getRandomValues && !isFastBoot) {
|
|
19
|
+
throw new Error(`Unable to generate bytes for UUID`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return CRYPTO.getRandomValues
|
|
23
|
+
? CRYPTO.getRandomValues(rnds8)
|
|
24
|
+
: (CRYPTO as unknown as FastbootCrypto).randomFillSync(rnds8);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
29
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
30
|
+
*/
|
|
31
|
+
const byteToHex: string[] = [];
|
|
32
|
+
for (let i = 0; i < 256; ++i) {
|
|
33
|
+
byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const bytesToUuid = function (buf: Uint8Array) {
|
|
37
|
+
let bth = byteToHex;
|
|
38
|
+
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
|
39
|
+
return [
|
|
40
|
+
bth[buf[0]],
|
|
41
|
+
bth[buf[1]],
|
|
42
|
+
bth[buf[2]],
|
|
43
|
+
bth[buf[3]],
|
|
44
|
+
'-',
|
|
45
|
+
bth[buf[4]],
|
|
46
|
+
bth[buf[5]],
|
|
47
|
+
'-',
|
|
48
|
+
bth[buf[6]],
|
|
49
|
+
bth[buf[7]],
|
|
50
|
+
'-',
|
|
51
|
+
bth[buf[8]],
|
|
52
|
+
bth[buf[9]],
|
|
53
|
+
'-',
|
|
54
|
+
bth[buf[10]],
|
|
55
|
+
bth[buf[11]],
|
|
56
|
+
bth[buf[12]],
|
|
57
|
+
bth[buf[13]],
|
|
58
|
+
bth[buf[14]],
|
|
59
|
+
bth[buf[15]],
|
|
60
|
+
].join('');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
CRYPTO.randomUUID = function uuidv4(): string {
|
|
64
|
+
let rnds = rng();
|
|
65
|
+
|
|
66
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
67
|
+
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
68
|
+
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
69
|
+
|
|
70
|
+
return bytesToUuid(rnds);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
4
4
|
"description": "The default blueprint for ember-cli addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"start": "ember serve"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ember-data/canary-features": "4.6.
|
|
21
|
-
"@ember-data/private-build-infra": "4.6.
|
|
20
|
+
"@ember-data/canary-features": "4.6.2",
|
|
21
|
+
"@ember-data/private-build-infra": "4.6.2",
|
|
22
22
|
"@ember/string": "^3.0.0",
|
|
23
23
|
"@embroider/macros": "^1.8.3",
|
|
24
24
|
"@glimmer/tracking": "^1.1.2",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"ember-cli-typescript": "^5.1.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@ember-data/unpublished-test-infra": "4.6.
|
|
32
|
+
"@ember-data/unpublished-test-infra": "4.6.2",
|
|
33
33
|
"@ember/optional-features": "^2.0.0",
|
|
34
34
|
"@ember/test-helpers": "~2.7.0",
|
|
35
35
|
"@types/ember": "^4.0.0",
|