@posthog/browser-common 0.1.0 → 0.2.0
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/README.md +17 -4
- package/dist/config.d.ts +9 -0
- package/dist/config.js +43 -0
- package/dist/config.mjs +9 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +44 -0
- package/dist/constants.mjs +4 -0
- package/dist/utils/array-at-polyfill.d.ts +1 -0
- package/dist/utils/array-at-polyfill.js +16 -0
- package/dist/utils/array-at-polyfill.mjs +11 -0
- package/dist/utils/autocapture-utils.d.ts +23 -0
- package/dist/utils/autocapture-utils.js +479 -0
- package/dist/utils/autocapture-utils.mjs +385 -0
- package/dist/utils/blocked-uas.d.ts +17 -0
- package/dist/utils/blocked-uas.js +54 -0
- package/dist/utils/blocked-uas.mjs +14 -0
- package/dist/utils/cookie-utils.d.ts +1 -0
- package/dist/utils/cookie-utils.js +49 -0
- package/dist/utils/cookie-utils.mjs +15 -0
- package/dist/utils/device-model-utils.d.ts +8 -0
- package/dist/utils/device-model-utils.js +52 -0
- package/dist/utils/device-model-utils.mjs +18 -0
- package/dist/utils/element-utils.d.ts +5 -0
- package/dist/utils/element-utils.js +67 -0
- package/dist/utils/element-utils.mjs +21 -0
- package/dist/utils/elements-chain-utils.d.ts +4 -0
- package/dist/utils/elements-chain-utils.js +79 -0
- package/dist/utils/elements-chain-utils.mjs +36 -0
- package/dist/utils/encode-utils.d.ts +8 -0
- package/dist/utils/encode-utils.js +39 -0
- package/dist/utils/encode-utils.mjs +5 -0
- package/dist/utils/event-utils.d.ts +24 -0
- package/dist/utils/event-utils.js +344 -0
- package/dist/utils/event-utils.mjs +246 -0
- package/dist/utils/general-utils.d.ts +30 -0
- package/dist/utils/general-utils.js +191 -0
- package/dist/utils/general-utils.mjs +118 -0
- package/dist/utils/globals.d.ts +25 -0
- package/dist/utils/globals.js +75 -0
- package/dist/utils/globals.mjs +14 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.js +83 -0
- package/dist/utils/logger.mjs +36 -0
- package/dist/utils/matcher-utils.d.ts +3 -0
- package/dist/utils/matcher-utils.js +63 -0
- package/dist/utils/matcher-utils.mjs +26 -0
- package/dist/utils/property-utils.d.ts +23 -0
- package/dist/utils/property-utils.js +108 -0
- package/dist/utils/property-utils.mjs +65 -0
- package/dist/utils/prototype-utils.d.ts +7 -0
- package/dist/utils/prototype-utils.js +64 -0
- package/dist/utils/prototype-utils.mjs +27 -0
- package/dist/utils/regex-utils.d.ts +2 -0
- package/dist/utils/regex-utils.js +54 -0
- package/dist/utils/regex-utils.mjs +17 -0
- package/dist/utils/request-utils.d.ts +15 -0
- package/dist/utils/request-utils.js +153 -0
- package/dist/utils/request-utils.mjs +95 -0
- package/dist/utils/simple-event-emitter.d.ts +5 -0
- package/dist/utils/simple-event-emitter.js +51 -0
- package/dist/utils/simple-event-emitter.mjs +17 -0
- package/dist/utils/stylesheet-loader.d.ts +7 -0
- package/dist/utils/stylesheet-loader.js +53 -0
- package/dist/utils/stylesheet-loader.mjs +19 -0
- package/dist/utils/type-utils.d.ts +2 -0
- package/dist/utils/type-utils.js +41 -0
- package/dist/utils/type-utils.mjs +4 -0
- package/dist/utils/url-targeting-utils.d.ts +28 -0
- package/dist/utils/url-targeting-utils.js +56 -0
- package/dist/utils/url-targeting-utils.mjs +19 -0
- package/dist/utils/uuidv7.d.ts +43 -0
- package/dist/utils/uuidv7.js +172 -0
- package/dist/utils/uuidv7.js.LICENSE.txt +9 -0
- package/dist/utils/uuidv7.mjs +132 -0
- package/dist/utils/uuidv7.mjs.LICENSE.txt +9 -0
- package/package.json +37 -3
- package/LICENSE +0 -353
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*! For license information please see uuidv7.js.LICENSE.txt */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
uuid7ToTimestampMs: ()=>uuid7ToTimestampMs,
|
|
29
|
+
UUID: ()=>UUID,
|
|
30
|
+
uuidv7: ()=>uuidv7
|
|
31
|
+
});
|
|
32
|
+
const external_globals_js_namespaceObject = require("./globals.js");
|
|
33
|
+
const core_namespaceObject = require("@posthog/core");
|
|
34
|
+
/**
|
|
35
|
+
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
36
|
+
*
|
|
37
|
+
* @license Apache-2.0
|
|
38
|
+
* @copyright 2021-2023 LiosK
|
|
39
|
+
* @packageDocumentation
|
|
40
|
+
*
|
|
41
|
+
* from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
|
|
42
|
+
*/ if (!Math.trunc) Math.trunc = function(v) {
|
|
43
|
+
return v < 0 ? Math.ceil(v) : Math.floor(v);
|
|
44
|
+
};
|
|
45
|
+
if (!Number.isInteger) Number.isInteger = function(value) {
|
|
46
|
+
return (0, core_namespaceObject.isNumber)(value) && isFinite(value) && Math.floor(value) === value;
|
|
47
|
+
};
|
|
48
|
+
class UUID {
|
|
49
|
+
constructor(bytes){
|
|
50
|
+
this.bytes = bytes;
|
|
51
|
+
if (16 !== bytes.length) throw new TypeError('not 128-bit length');
|
|
52
|
+
}
|
|
53
|
+
static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
|
|
54
|
+
if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 0xffffffffffff || randA > 0xfff || randBHi > 0x3fffffff || randBLo > 0xffffffff) throw new RangeError('invalid field value');
|
|
55
|
+
const bytes = new Uint8Array(16);
|
|
56
|
+
bytes[0] = unixTsMs / 2 ** 40;
|
|
57
|
+
bytes[1] = unixTsMs / 2 ** 32;
|
|
58
|
+
bytes[2] = unixTsMs / 2 ** 24;
|
|
59
|
+
bytes[3] = unixTsMs / 2 ** 16;
|
|
60
|
+
bytes[4] = unixTsMs / 256;
|
|
61
|
+
bytes[5] = unixTsMs;
|
|
62
|
+
bytes[6] = 0x70 | randA >>> 8;
|
|
63
|
+
bytes[7] = randA;
|
|
64
|
+
bytes[8] = 0x80 | randBHi >>> 24;
|
|
65
|
+
bytes[9] = randBHi >>> 16;
|
|
66
|
+
bytes[10] = randBHi >>> 8;
|
|
67
|
+
bytes[11] = randBHi;
|
|
68
|
+
bytes[12] = randBLo >>> 24;
|
|
69
|
+
bytes[13] = randBLo >>> 16;
|
|
70
|
+
bytes[14] = randBLo >>> 8;
|
|
71
|
+
bytes[15] = randBLo;
|
|
72
|
+
return new UUID(bytes);
|
|
73
|
+
}
|
|
74
|
+
toString() {
|
|
75
|
+
let text = '';
|
|
76
|
+
for(let i = 0; i < this.bytes.length; i++){
|
|
77
|
+
text = text + (this.bytes[i] >>> 4).toString(16) + (0xf & this.bytes[i]).toString(16);
|
|
78
|
+
if (3 === i || 5 === i || 7 === i || 9 === i) text += '-';
|
|
79
|
+
}
|
|
80
|
+
if (36 !== text.length) throw new Error('Invalid UUIDv7 was generated');
|
|
81
|
+
return text;
|
|
82
|
+
}
|
|
83
|
+
clone() {
|
|
84
|
+
return new UUID(this.bytes.slice(0));
|
|
85
|
+
}
|
|
86
|
+
equals(other) {
|
|
87
|
+
return 0 === this.compareTo(other);
|
|
88
|
+
}
|
|
89
|
+
compareTo(other) {
|
|
90
|
+
for(let i = 0; i < 16; i++){
|
|
91
|
+
const diff = this.bytes[i] - other.bytes[i];
|
|
92
|
+
if (0 !== diff) return Math.sign(diff);
|
|
93
|
+
}
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class V7Generator {
|
|
98
|
+
generate() {
|
|
99
|
+
const value = this.generateOrAbort();
|
|
100
|
+
if (!(0, core_namespaceObject.isUndefined)(value)) return value;
|
|
101
|
+
{
|
|
102
|
+
this._timestamp = 0;
|
|
103
|
+
const valueAfterReset = this.generateOrAbort();
|
|
104
|
+
if ((0, core_namespaceObject.isUndefined)(valueAfterReset)) throw new Error('Could not generate UUID after timestamp reset');
|
|
105
|
+
return valueAfterReset;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
generateOrAbort() {
|
|
109
|
+
const MAX_COUNTER = 0x3ffffffffff;
|
|
110
|
+
const ROLLBACK_ALLOWANCE = 10000;
|
|
111
|
+
const ts = Date.now();
|
|
112
|
+
if (ts > this._timestamp) {
|
|
113
|
+
this._timestamp = ts;
|
|
114
|
+
this._resetCounter();
|
|
115
|
+
} else {
|
|
116
|
+
if (!(ts + ROLLBACK_ALLOWANCE > this._timestamp)) return;
|
|
117
|
+
this._counter++;
|
|
118
|
+
if (this._counter > MAX_COUNTER) {
|
|
119
|
+
this._timestamp++;
|
|
120
|
+
this._resetCounter();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return UUID.fromFieldsV7(this._timestamp, Math.trunc(this._counter / 2 ** 30), this._counter & 2 ** 30 - 1, this._random.nextUint32());
|
|
124
|
+
}
|
|
125
|
+
_resetCounter() {
|
|
126
|
+
this._counter = 0x400 * this._random.nextUint32() + (0x3ff & this._random.nextUint32());
|
|
127
|
+
}
|
|
128
|
+
constructor(){
|
|
129
|
+
this._timestamp = 0;
|
|
130
|
+
this._counter = 0;
|
|
131
|
+
this._random = new DefaultRandom();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
let getRandomValues = (buffer)=>{
|
|
135
|
+
if ('undefined' != typeof UUIDV7_DENY_WEAK_RNG && UUIDV7_DENY_WEAK_RNG) throw new Error('no cryptographically strong RNG available');
|
|
136
|
+
for(let i = 0; i < buffer.length; i++)buffer[i] = 0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random());
|
|
137
|
+
return buffer;
|
|
138
|
+
};
|
|
139
|
+
if (external_globals_js_namespaceObject.window && !(0, core_namespaceObject.isUndefined)(external_globals_js_namespaceObject.window.crypto) && crypto.getRandomValues) getRandomValues = (buffer)=>crypto.getRandomValues(buffer);
|
|
140
|
+
class DefaultRandom {
|
|
141
|
+
nextUint32() {
|
|
142
|
+
if (this._cursor >= this._buffer.length) {
|
|
143
|
+
getRandomValues(this._buffer);
|
|
144
|
+
this._cursor = 0;
|
|
145
|
+
}
|
|
146
|
+
return this._buffer[this._cursor++];
|
|
147
|
+
}
|
|
148
|
+
constructor(){
|
|
149
|
+
this._buffer = new Uint32Array(8);
|
|
150
|
+
this._cursor = 1 / 0;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
let defaultGenerator;
|
|
154
|
+
const uuidv7 = ()=>uuidv7obj().toString();
|
|
155
|
+
const uuidv7obj = ()=>(defaultGenerator || (defaultGenerator = new V7Generator())).generate();
|
|
156
|
+
const uuid7ToTimestampMs = (uuid)=>{
|
|
157
|
+
const hex = uuid.replace(/-/g, '');
|
|
158
|
+
if (32 !== hex.length) throw new Error('Not a valid UUID');
|
|
159
|
+
if ('7' !== hex[12]) throw new Error('Not a UUIDv7');
|
|
160
|
+
return parseInt(hex.substring(0, 12), 16);
|
|
161
|
+
};
|
|
162
|
+
exports.UUID = __webpack_exports__.UUID;
|
|
163
|
+
exports.uuid7ToTimestampMs = __webpack_exports__.uuid7ToTimestampMs;
|
|
164
|
+
exports.uuidv7 = __webpack_exports__.uuidv7;
|
|
165
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
166
|
+
"UUID",
|
|
167
|
+
"uuid7ToTimestampMs",
|
|
168
|
+
"uuidv7"
|
|
169
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
170
|
+
Object.defineProperty(exports, '__esModule', {
|
|
171
|
+
value: true
|
|
172
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
3
|
+
*
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
* @copyright 2021-2023 LiosK
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*
|
|
8
|
+
* from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
|
|
9
|
+
*/
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*! For license information please see uuidv7.mjs.LICENSE.txt */
|
|
2
|
+
import { window as external_globals_mjs_window } from "./globals.mjs";
|
|
3
|
+
import { isNumber, isUndefined } from "@posthog/core";
|
|
4
|
+
/**
|
|
5
|
+
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
6
|
+
*
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
* @copyright 2021-2023 LiosK
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*
|
|
11
|
+
* from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
|
|
12
|
+
*/ if (!Math.trunc) Math.trunc = function(v) {
|
|
13
|
+
return v < 0 ? Math.ceil(v) : Math.floor(v);
|
|
14
|
+
};
|
|
15
|
+
if (!Number.isInteger) Number.isInteger = function(value) {
|
|
16
|
+
return isNumber(value) && isFinite(value) && Math.floor(value) === value;
|
|
17
|
+
};
|
|
18
|
+
class UUID {
|
|
19
|
+
constructor(bytes){
|
|
20
|
+
this.bytes = bytes;
|
|
21
|
+
if (16 !== bytes.length) throw new TypeError('not 128-bit length');
|
|
22
|
+
}
|
|
23
|
+
static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
|
|
24
|
+
if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 0xffffffffffff || randA > 0xfff || randBHi > 0x3fffffff || randBLo > 0xffffffff) throw new RangeError('invalid field value');
|
|
25
|
+
const bytes = new Uint8Array(16);
|
|
26
|
+
bytes[0] = unixTsMs / 2 ** 40;
|
|
27
|
+
bytes[1] = unixTsMs / 2 ** 32;
|
|
28
|
+
bytes[2] = unixTsMs / 2 ** 24;
|
|
29
|
+
bytes[3] = unixTsMs / 2 ** 16;
|
|
30
|
+
bytes[4] = unixTsMs / 256;
|
|
31
|
+
bytes[5] = unixTsMs;
|
|
32
|
+
bytes[6] = 0x70 | randA >>> 8;
|
|
33
|
+
bytes[7] = randA;
|
|
34
|
+
bytes[8] = 0x80 | randBHi >>> 24;
|
|
35
|
+
bytes[9] = randBHi >>> 16;
|
|
36
|
+
bytes[10] = randBHi >>> 8;
|
|
37
|
+
bytes[11] = randBHi;
|
|
38
|
+
bytes[12] = randBLo >>> 24;
|
|
39
|
+
bytes[13] = randBLo >>> 16;
|
|
40
|
+
bytes[14] = randBLo >>> 8;
|
|
41
|
+
bytes[15] = randBLo;
|
|
42
|
+
return new UUID(bytes);
|
|
43
|
+
}
|
|
44
|
+
toString() {
|
|
45
|
+
let text = '';
|
|
46
|
+
for(let i = 0; i < this.bytes.length; i++){
|
|
47
|
+
text = text + (this.bytes[i] >>> 4).toString(16) + (0xf & this.bytes[i]).toString(16);
|
|
48
|
+
if (3 === i || 5 === i || 7 === i || 9 === i) text += '-';
|
|
49
|
+
}
|
|
50
|
+
if (36 !== text.length) throw new Error('Invalid UUIDv7 was generated');
|
|
51
|
+
return text;
|
|
52
|
+
}
|
|
53
|
+
clone() {
|
|
54
|
+
return new UUID(this.bytes.slice(0));
|
|
55
|
+
}
|
|
56
|
+
equals(other) {
|
|
57
|
+
return 0 === this.compareTo(other);
|
|
58
|
+
}
|
|
59
|
+
compareTo(other) {
|
|
60
|
+
for(let i = 0; i < 16; i++){
|
|
61
|
+
const diff = this.bytes[i] - other.bytes[i];
|
|
62
|
+
if (0 !== diff) return Math.sign(diff);
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class V7Generator {
|
|
68
|
+
generate() {
|
|
69
|
+
const value = this.generateOrAbort();
|
|
70
|
+
if (!isUndefined(value)) return value;
|
|
71
|
+
{
|
|
72
|
+
this._timestamp = 0;
|
|
73
|
+
const valueAfterReset = this.generateOrAbort();
|
|
74
|
+
if (isUndefined(valueAfterReset)) throw new Error('Could not generate UUID after timestamp reset');
|
|
75
|
+
return valueAfterReset;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
generateOrAbort() {
|
|
79
|
+
const MAX_COUNTER = 0x3ffffffffff;
|
|
80
|
+
const ROLLBACK_ALLOWANCE = 10000;
|
|
81
|
+
const ts = Date.now();
|
|
82
|
+
if (ts > this._timestamp) {
|
|
83
|
+
this._timestamp = ts;
|
|
84
|
+
this._resetCounter();
|
|
85
|
+
} else {
|
|
86
|
+
if (!(ts + ROLLBACK_ALLOWANCE > this._timestamp)) return;
|
|
87
|
+
this._counter++;
|
|
88
|
+
if (this._counter > MAX_COUNTER) {
|
|
89
|
+
this._timestamp++;
|
|
90
|
+
this._resetCounter();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return UUID.fromFieldsV7(this._timestamp, Math.trunc(this._counter / 2 ** 30), this._counter & 2 ** 30 - 1, this._random.nextUint32());
|
|
94
|
+
}
|
|
95
|
+
_resetCounter() {
|
|
96
|
+
this._counter = 0x400 * this._random.nextUint32() + (0x3ff & this._random.nextUint32());
|
|
97
|
+
}
|
|
98
|
+
constructor(){
|
|
99
|
+
this._timestamp = 0;
|
|
100
|
+
this._counter = 0;
|
|
101
|
+
this._random = new DefaultRandom();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
let getRandomValues = (buffer)=>{
|
|
105
|
+
if ('undefined' != typeof UUIDV7_DENY_WEAK_RNG && UUIDV7_DENY_WEAK_RNG) throw new Error('no cryptographically strong RNG available');
|
|
106
|
+
for(let i = 0; i < buffer.length; i++)buffer[i] = 0x10000 * Math.trunc(0x10000 * Math.random()) + Math.trunc(0x10000 * Math.random());
|
|
107
|
+
return buffer;
|
|
108
|
+
};
|
|
109
|
+
if (external_globals_mjs_window && !isUndefined(external_globals_mjs_window.crypto) && crypto.getRandomValues) getRandomValues = (buffer)=>crypto.getRandomValues(buffer);
|
|
110
|
+
class DefaultRandom {
|
|
111
|
+
nextUint32() {
|
|
112
|
+
if (this._cursor >= this._buffer.length) {
|
|
113
|
+
getRandomValues(this._buffer);
|
|
114
|
+
this._cursor = 0;
|
|
115
|
+
}
|
|
116
|
+
return this._buffer[this._cursor++];
|
|
117
|
+
}
|
|
118
|
+
constructor(){
|
|
119
|
+
this._buffer = new Uint32Array(8);
|
|
120
|
+
this._cursor = 1 / 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
let defaultGenerator;
|
|
124
|
+
const uuidv7 = ()=>uuidv7obj().toString();
|
|
125
|
+
const uuidv7obj = ()=>(defaultGenerator || (defaultGenerator = new V7Generator())).generate();
|
|
126
|
+
const uuid7ToTimestampMs = (uuid)=>{
|
|
127
|
+
const hex = uuid.replace(/-/g, '');
|
|
128
|
+
if (32 !== hex.length) throw new Error('Not a valid UUID');
|
|
129
|
+
if ('7' !== hex[12]) throw new Error('Not a UUIDv7');
|
|
130
|
+
return parseInt(hex.substring(0, 12), 16);
|
|
131
|
+
};
|
|
132
|
+
export { UUID, uuid7ToTimestampMs, uuidv7 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
3
|
+
*
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
* @copyright 2021-2023 LiosK
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*
|
|
8
|
+
* from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
|
|
9
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
"url": "git+https://github.com/PostHog/posthog-js.git",
|
|
9
9
|
"directory": "packages/browser-common"
|
|
10
10
|
},
|
|
11
|
-
"sideEffects":
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"./dist/utils/array-at-polyfill.js",
|
|
13
|
+
"./dist/utils/array-at-polyfill.mjs",
|
|
14
|
+
"./dist/utils/uuidv7.js",
|
|
15
|
+
"./dist/utils/uuidv7.mjs"
|
|
16
|
+
],
|
|
12
17
|
"files": [
|
|
13
18
|
"dist",
|
|
14
19
|
"README.md"
|
|
@@ -16,15 +21,44 @@
|
|
|
16
21
|
"main": "dist/index.js",
|
|
17
22
|
"module": "dist/index.mjs",
|
|
18
23
|
"types": "dist/index.d.ts",
|
|
24
|
+
"typesVersions": {
|
|
25
|
+
"*": {
|
|
26
|
+
"config": [
|
|
27
|
+
"dist/config.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"constants": [
|
|
30
|
+
"dist/constants.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"utils/*": [
|
|
33
|
+
"dist/utils/*.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
19
37
|
"exports": {
|
|
20
38
|
".": {
|
|
21
39
|
"types": "./dist/index.d.ts",
|
|
22
40
|
"require": "./dist/index.js",
|
|
23
41
|
"import": "./dist/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./config": {
|
|
44
|
+
"types": "./dist/config.d.ts",
|
|
45
|
+
"require": "./dist/config.js",
|
|
46
|
+
"import": "./dist/config.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./constants": {
|
|
49
|
+
"types": "./dist/constants.d.ts",
|
|
50
|
+
"require": "./dist/constants.js",
|
|
51
|
+
"import": "./dist/constants.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./utils/*": {
|
|
54
|
+
"types": "./dist/utils/*.d.ts",
|
|
55
|
+
"require": "./dist/utils/*.js",
|
|
56
|
+
"import": "./dist/utils/*.mjs"
|
|
24
57
|
}
|
|
25
58
|
},
|
|
26
59
|
"dependencies": {
|
|
27
|
-
"@posthog/core": "^1.
|
|
60
|
+
"@posthog/core": "^1.44.0",
|
|
61
|
+
"@posthog/types": "^1.397.1"
|
|
28
62
|
},
|
|
29
63
|
"devDependencies": {
|
|
30
64
|
"@rslib/core": "0.10.6",
|