@amplitude/analytics-core 2.8.0 → 2.8.1
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/lib/cjs/utils/uuid.d.ts +1 -1
- package/lib/cjs/utils/uuid.d.ts.map +1 -1
- package/lib/cjs/utils/uuid.js +23 -4
- package/lib/cjs/utils/uuid.js.map +1 -1
- package/lib/esm/utils/uuid.d.ts +1 -1
- package/lib/esm/utils/uuid.d.ts.map +1 -1
- package/lib/esm/utils/uuid.js +21 -2
- package/lib/esm/utils/uuid.js.map +1 -1
- package/package.json +2 -2
package/lib/cjs/utils/uuid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source: [jed's gist]{@link https://gist.github.com/982883}.
|
|
2
|
+
* Source: [jed's gist's comment]{@link https://gist.github.com/jed/982883?permalink_comment_id=3223002#gistcomment-3223002}.
|
|
3
3
|
* Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
|
|
4
4
|
* where each x is replaced with a random hexadecimal digit from 0 to f, and
|
|
5
5
|
* y is replaced with a random hexadecimal digit from 8 to b.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+BH,eAAO,MAAM,IAAI,OAAQ,GAAG,KAAG,MAe9B,CAAC"}
|
package/lib/cjs/utils/uuid.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UUID = void 0;
|
|
4
2
|
/**
|
|
5
|
-
* Source: [jed's gist]{@link https://gist.github.com/982883}.
|
|
3
|
+
* Source: [jed's gist's comment]{@link https://gist.github.com/jed/982883?permalink_comment_id=3223002#gistcomment-3223002}.
|
|
6
4
|
* Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
|
|
7
5
|
* where each x is replaced with a random hexadecimal digit from 0 to f, and
|
|
8
6
|
* y is replaced with a random hexadecimal digit from 8 to b.
|
|
9
7
|
* Used to generate UUIDs for deviceIds.
|
|
10
8
|
* @private
|
|
11
9
|
*/
|
|
12
|
-
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.UUID = void 0;
|
|
12
|
+
var tslib_1 = require("tslib");
|
|
13
|
+
var global_scope_1 = require("../global-scope");
|
|
14
|
+
var legacyUUID = function (a) {
|
|
13
15
|
return a // if the placeholder was passed, return
|
|
14
16
|
? // a random number from 0 to 15
|
|
15
17
|
(a ^ // unless b is 8,
|
|
@@ -28,5 +30,22 @@ var UUID = function (a) {
|
|
|
28
30
|
/[018]/g, // zeroes, ones, and eights with
|
|
29
31
|
exports.UUID);
|
|
30
32
|
};
|
|
33
|
+
var hex = tslib_1.__spreadArray([], tslib_1.__read(Array(256).keys()), false).map(function (index) { return index.toString(16).padStart(2, '0'); });
|
|
34
|
+
var UUID = function (a) {
|
|
35
|
+
var _a;
|
|
36
|
+
var globalScope = (0, global_scope_1.getGlobalScope)();
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
if (!((_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.crypto) === null || _a === void 0 ? void 0 : _a.getRandomValues)) {
|
|
39
|
+
// Fallback to legacy UUID generation if crypto is not available
|
|
40
|
+
return legacyUUID(a);
|
|
41
|
+
}
|
|
42
|
+
var r = globalScope.crypto.getRandomValues(new Uint8Array(16));
|
|
43
|
+
r[6] = (r[6] & 0x0f) | 0x40;
|
|
44
|
+
r[8] = (r[8] & 0x3f) | 0x80;
|
|
45
|
+
return tslib_1.__spreadArray([], tslib_1.__read(r.entries()), false).map(function (_a) {
|
|
46
|
+
var _b = tslib_1.__read(_a, 2), index = _b[0], int = _b[1];
|
|
47
|
+
return ([4, 6, 8, 10].includes(index) ? "-".concat(hex[int]) : hex[int]);
|
|
48
|
+
}).join('');
|
|
49
|
+
};
|
|
31
50
|
exports.UUID = UUID;
|
|
32
51
|
//# sourceMappingURL=uuid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;AAEH,gDAAiD;AAEjD,IAAM,UAAU,GAAG,UAAU,CAAO;IAClC,OAAO,CAAC,CAAC,wCAAwC;QAC/C,CAAC,CAAC,+BAA+B;YAC/B,CACE,CAAC,GAAG,iBAAiB;gBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB;oBAChC,EAAE,CAAC,IAAI,uBAAuB;oBAC9B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CACX,CAAC,UAAU;iBACT,QAAQ,CAAC,EAAE,CAAC,CAAC,iBAAiB;QACnC,CAAC,CAAC,sCAAsC;YACtC,CACE,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa;gBAC3B,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU;gBACzB,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU;gBACzB,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,cAAc;gBAC7B,MAAM,CAAC,CAAC,IAAI,CAAC,CACd,CAAC,iBAAiB;iBAChB,OAAO;YACN,YAAY;YACZ,QAAQ,EAAE,gCAAgC;YAC1C,YAAI,CACL,CAAC;AACV,CAAC,CAAC;AAEF,IAAM,GAAG,GAAa,yCAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,UAAE,GAA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* Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,\n * where each x is replaced with a random hexadecimal digit from 0 to f, and\n * y is replaced with a random hexadecimal digit from 8 to b.\n * Used to generate UUIDs for deviceIds.\n * @private\n */\n\nimport { getGlobalScope } from '../global-scope';\n\nconst legacyUUID = function (a?: any): string {\n return a // if the placeholder was passed, return\n ? // a random number from 0 to 15\n (\n a ^ // unless b is 8,\n ((Math.random() * // in which case\n 16) >> // a random number from\n (a / 4))\n ) // 8 to 11\n .toString(16) // in hexadecimal\n : // or otherwise a concatenated string:\n (\n String(1e7) + // 10000000 +\n String(-1e3) + // -1000 +\n String(-4e3) + // -4000 +\n String(-8e3) + // -80000000 +\n String(-1e11)\n ) // -100000000000,\n .replace(\n // replacing\n /[018]/g, // zeroes, ones, and eights with\n UUID, // random hex digits\n );\n};\n\nconst hex: string[] = [...Array(256).keys()].map((index) => index.toString(16).padStart(2, '0'));\n\nexport const UUID = (a?: any): string => {\n const globalScope = getGlobalScope();\n\n /* istanbul ignore next */\n if (!globalScope?.crypto?.getRandomValues) {\n // Fallback to legacy UUID generation if crypto is not available\n return legacyUUID(a);\n }\n\n const r = globalScope.crypto.getRandomValues(new Uint8Array(16));\n\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return [...r.entries()].map(([index, int]) => ([4, 6, 8, 10].includes(index) ? `-${hex[int]}` : hex[int])).join('');\n};\n"]}
|
package/lib/esm/utils/uuid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source: [jed's gist]{@link https://gist.github.com/982883}.
|
|
2
|
+
* Source: [jed's gist's comment]{@link https://gist.github.com/jed/982883?permalink_comment_id=3223002#gistcomment-3223002}.
|
|
3
3
|
* Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
|
|
4
4
|
* where each x is replaced with a random hexadecimal digit from 0 to f, and
|
|
5
5
|
* y is replaced with a random hexadecimal digit from 8 to b.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+BH,eAAO,MAAM,IAAI,OAAQ,GAAG,KAAG,MAe9B,CAAC"}
|
package/lib/esm/utils/uuid.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source: [jed's gist]{@link https://gist.github.com/982883}.
|
|
2
|
+
* Source: [jed's gist's comment]{@link https://gist.github.com/jed/982883?permalink_comment_id=3223002#gistcomment-3223002}.
|
|
3
3
|
* Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
|
|
4
4
|
* where each x is replaced with a random hexadecimal digit from 0 to f, and
|
|
5
5
|
* y is replaced with a random hexadecimal digit from 8 to b.
|
|
6
6
|
* Used to generate UUIDs for deviceIds.
|
|
7
7
|
* @private
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
import { __read, __spreadArray } from "tslib";
|
|
10
|
+
import { getGlobalScope } from '../global-scope';
|
|
11
|
+
var legacyUUID = function (a) {
|
|
10
12
|
return a // if the placeholder was passed, return
|
|
11
13
|
? // a random number from 0 to 15
|
|
12
14
|
(a ^ // unless b is 8,
|
|
@@ -25,4 +27,21 @@ export var UUID = function (a) {
|
|
|
25
27
|
/[018]/g, // zeroes, ones, and eights with
|
|
26
28
|
UUID);
|
|
27
29
|
};
|
|
30
|
+
var hex = __spreadArray([], __read(Array(256).keys()), false).map(function (index) { return index.toString(16).padStart(2, '0'); });
|
|
31
|
+
export var UUID = function (a) {
|
|
32
|
+
var _a;
|
|
33
|
+
var globalScope = getGlobalScope();
|
|
34
|
+
/* istanbul ignore next */
|
|
35
|
+
if (!((_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.crypto) === null || _a === void 0 ? void 0 : _a.getRandomValues)) {
|
|
36
|
+
// Fallback to legacy UUID generation if crypto is not available
|
|
37
|
+
return legacyUUID(a);
|
|
38
|
+
}
|
|
39
|
+
var r = globalScope.crypto.getRandomValues(new Uint8Array(16));
|
|
40
|
+
r[6] = (r[6] & 0x0f) | 0x40;
|
|
41
|
+
r[8] = (r[8] & 0x3f) | 0x80;
|
|
42
|
+
return __spreadArray([], __read(r.entries()), false).map(function (_a) {
|
|
43
|
+
var _b = __read(_a, 2), index = _b[0], int = _b[1];
|
|
44
|
+
return ([4, 6, 8, 10].includes(index) ? "-".concat(hex[int]) : hex[int]);
|
|
45
|
+
}).join('');
|
|
46
|
+
};
|
|
28
47
|
//# sourceMappingURL=uuid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,IAAM,UAAU,GAAG,UAAU,CAAO;IAClC,OAAO,CAAC,CAAC,wCAAwC;QAC/C,CAAC,CAAC,+BAA+B;YAC/B,CACE,CAAC,GAAG,iBAAiB;gBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB;oBAChC,EAAE,CAAC,IAAI,uBAAuB;oBAC9B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CACX,CAAC,UAAU;iBACT,QAAQ,CAAC,EAAE,CAAC,CAAC,iBAAiB;QACnC,CAAC,CAAC,sCAAsC;YACtC,CACE,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa;gBAC3B,MAAM,CAAC,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C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAI,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAA3D,CAA2D,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtH,CAAC,CAAC","sourcesContent":["/**\n * Source: [jed's gist's comment]{@link https://gist.github.com/jed/982883?permalink_comment_id=3223002#gistcomment-3223002}.\n * Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,\n * where each x is replaced with a random hexadecimal digit from 0 to f, and\n * y is replaced with a random hexadecimal digit from 8 to b.\n * Used to generate UUIDs for deviceIds.\n * @private\n */\n\nimport { getGlobalScope } from '../global-scope';\n\nconst legacyUUID = function (a?: any): string {\n return a // if the placeholder was passed, return\n ? // a random number from 0 to 15\n (\n a ^ // unless b is 8,\n ((Math.random() * // in which case\n 16) >> // a random number from\n (a / 4))\n ) // 8 to 11\n .toString(16) // in hexadecimal\n : // or otherwise a concatenated string:\n (\n String(1e7) + // 10000000 +\n String(-1e3) + // -1000 +\n String(-4e3) + // -4000 +\n String(-8e3) + // -80000000 +\n String(-1e11)\n ) // -100000000000,\n .replace(\n // replacing\n /[018]/g, // zeroes, ones, and eights with\n UUID, // random hex digits\n );\n};\n\nconst hex: string[] = [...Array(256).keys()].map((index) => index.toString(16).padStart(2, '0'));\n\nexport const UUID = (a?: any): string => {\n const globalScope = getGlobalScope();\n\n /* istanbul ignore next */\n if (!globalScope?.crypto?.getRandomValues) {\n // Fallback to legacy UUID generation if crypto is not available\n return legacyUUID(a);\n }\n\n const r = globalScope.crypto.getRandomValues(new Uint8Array(16));\n\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return [...r.entries()].map(([index, int]) => ([4, 6, 8, 10].includes(index) ? `-${hex[int]}` : hex[int])).join('');\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-core",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"lib"
|
|
42
42
|
],
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "71161aaa132c2ee9f2d5fc4eedc1ce2ec1e553f5"
|
|
44
44
|
}
|