@local-logic/types 0.1.4 → 0.1.6
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/dist/index.d.ts +2 -2
- package/dist/index.js +194 -187
- package/dist/index.umd.cjs +2 -2
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { SDKPropsMappings, SDKProps } from
|
|
2
|
-
export { ChannelEvents } from
|
|
1
|
+
export type { SDKPropsMappings, SDKProps } from '@local-logic/sdks-app';
|
|
2
|
+
export { ChannelEvents } from '@local-logic/channel';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,193 +1,200 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
1
|
+
var j = /* @__PURE__ */ ((_) => (_.GET_STATE = "get-state", _.GET_STATE_RESPONSE = "get-state-response", _.SET_STATE = "set-state", _.ON_CHANGE = "on-change", _.RESIZE = "resize", _))(j || {});
|
|
2
|
+
function A(_) {
|
|
3
3
|
return _ && _.__esModule && Object.prototype.hasOwnProperty.call(_, "default") ? _.default : _;
|
|
4
4
|
}
|
|
5
|
-
var C = { exports: {} }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
s && (a = a.sort(() => Math.random() - 0.5)), this.dict = a, this.dictLength = this.dict.length, this.setCounter(0);
|
|
88
|
-
}), i(this, "seq", () => this.sequentialUUID()), i(this, "sequentialUUID", () => {
|
|
89
|
-
let t, s, a = "";
|
|
90
|
-
t = this.counter;
|
|
91
|
-
do
|
|
92
|
-
s = t % this.dictLength, t = Math.trunc(t / this.dictLength), a += this.dict[s];
|
|
93
|
-
while (t !== 0);
|
|
94
|
-
return this.counter += 1, a;
|
|
95
|
-
}), i(this, "rnd", (t = this.uuidLength || g) => this.randomUUID(t)), i(this, "randomUUID", (t = this.uuidLength || g) => {
|
|
96
|
-
let s, a, h;
|
|
97
|
-
if (t === null || typeof t > "u" || t < 1)
|
|
98
|
-
throw new Error("Invalid UUID Length Provided");
|
|
99
|
-
for (s = "", h = 0; h < t; h += 1)
|
|
100
|
-
a = parseInt(
|
|
101
|
-
(Math.random() * this.dictLength).toFixed(0),
|
|
102
|
-
10
|
|
103
|
-
) % this.dictLength, s += this.dict[a];
|
|
104
|
-
return s;
|
|
105
|
-
}), i(this, "fmt", (t, s) => this.formattedUUID(t, s)), i(this, "formattedUUID", (t, s) => {
|
|
106
|
-
const a = {
|
|
107
|
-
$r: this.randomUUID,
|
|
108
|
-
$s: this.sequentialUUID,
|
|
109
|
-
$t: this.stamp
|
|
110
|
-
};
|
|
111
|
-
return t.replace(
|
|
112
|
-
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
113
|
-
(h) => {
|
|
114
|
-
const o = h.slice(0, 2), l = parseInt(h.slice(2), 10);
|
|
115
|
-
return o === "$s" ? a[o]().padStart(l, "0") : o === "$t" && s ? a[o](l, s) : a[o](l);
|
|
5
|
+
var C = { exports: {} }, $;
|
|
6
|
+
function F() {
|
|
7
|
+
return $ || ($ = 1, function(_) {
|
|
8
|
+
var m = (() => {
|
|
9
|
+
var c = Object.defineProperty, E = Object.getOwnPropertyDescriptor, L = Object.getOwnPropertyNames, I = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable, b = (n, e, h) => e in n ? c(n, e, { enumerable: !0, configurable: !0, writable: !0, value: h }) : n[e] = h, D = (n, e) => {
|
|
10
|
+
for (var h in e || (e = {}))
|
|
11
|
+
y.call(e, h) && b(n, h, e[h]);
|
|
12
|
+
if (I)
|
|
13
|
+
for (var h of I(e))
|
|
14
|
+
S.call(e, h) && b(n, h, e[h]);
|
|
15
|
+
return n;
|
|
16
|
+
}, M = (n, e) => {
|
|
17
|
+
for (var h in e)
|
|
18
|
+
c(n, h, { get: e[h], enumerable: !0 });
|
|
19
|
+
}, O = (n, e, h, f) => {
|
|
20
|
+
if (e && typeof e == "object" || typeof e == "function")
|
|
21
|
+
for (let d of L(e))
|
|
22
|
+
!y.call(n, d) && d !== h && c(n, d, { get: () => e[d], enumerable: !(f = E(e, d)) || f.enumerable });
|
|
23
|
+
return n;
|
|
24
|
+
}, B = (n) => O(c({}, "__esModule", { value: !0 }), n), i = (n, e, h) => (b(n, typeof e != "symbol" ? e + "" : e, h), h), x = {};
|
|
25
|
+
M(x, {
|
|
26
|
+
DEFAULT_OPTIONS: () => v,
|
|
27
|
+
DEFAULT_UUID_LENGTH: () => g,
|
|
28
|
+
default: () => P
|
|
29
|
+
});
|
|
30
|
+
var q = "5.2.0", g = 6, v = {
|
|
31
|
+
dictionary: "alphanum",
|
|
32
|
+
shuffle: !0,
|
|
33
|
+
debug: !1,
|
|
34
|
+
length: g,
|
|
35
|
+
counter: 0
|
|
36
|
+
}, w = class {
|
|
37
|
+
constructor(n = {}) {
|
|
38
|
+
i(this, "counter"), i(this, "debug"), i(this, "dict"), i(this, "version"), i(this, "dictIndex", 0), i(this, "dictRange", []), i(this, "lowerBound", 0), i(this, "upperBound", 0), i(this, "dictLength", 0), i(this, "uuidLength"), i(this, "_digit_first_ascii", 48), i(this, "_digit_last_ascii", 58), i(this, "_alpha_lower_first_ascii", 97), i(this, "_alpha_lower_last_ascii", 123), i(this, "_hex_last_ascii", 103), i(this, "_alpha_upper_first_ascii", 65), i(this, "_alpha_upper_last_ascii", 91), i(this, "_number_dict_ranges", {
|
|
39
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii]
|
|
40
|
+
}), i(this, "_alpha_dict_ranges", {
|
|
41
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
42
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
43
|
+
}), i(this, "_alpha_lower_dict_ranges", {
|
|
44
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
45
|
+
}), i(this, "_alpha_upper_dict_ranges", {
|
|
46
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
47
|
+
}), i(this, "_alphanum_dict_ranges", {
|
|
48
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
49
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
50
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
51
|
+
}), i(this, "_alphanum_lower_dict_ranges", {
|
|
52
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
53
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
54
|
+
}), i(this, "_alphanum_upper_dict_ranges", {
|
|
55
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
56
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
57
|
+
}), i(this, "_hex_dict_ranges", {
|
|
58
|
+
decDigits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
59
|
+
alphaDigits: [this._alpha_lower_first_ascii, this._hex_last_ascii]
|
|
60
|
+
}), i(this, "_dict_ranges", {
|
|
61
|
+
_number_dict_ranges: this._number_dict_ranges,
|
|
62
|
+
_alpha_dict_ranges: this._alpha_dict_ranges,
|
|
63
|
+
_alpha_lower_dict_ranges: this._alpha_lower_dict_ranges,
|
|
64
|
+
_alpha_upper_dict_ranges: this._alpha_upper_dict_ranges,
|
|
65
|
+
_alphanum_dict_ranges: this._alphanum_dict_ranges,
|
|
66
|
+
_alphanum_lower_dict_ranges: this._alphanum_lower_dict_ranges,
|
|
67
|
+
_alphanum_upper_dict_ranges: this._alphanum_upper_dict_ranges,
|
|
68
|
+
_hex_dict_ranges: this._hex_dict_ranges
|
|
69
|
+
}), i(this, "log", (...t) => {
|
|
70
|
+
const s = [...t];
|
|
71
|
+
if (s[0] = `[short-unique-id] ${t[0]}`, this.debug === !0 && typeof console < "u" && console !== null)
|
|
72
|
+
return console.log(...s);
|
|
73
|
+
}), i(this, "_normalizeDictionary", (t, s) => {
|
|
74
|
+
let a;
|
|
75
|
+
if (t && Array.isArray(t) && t.length > 1)
|
|
76
|
+
a = t;
|
|
77
|
+
else {
|
|
78
|
+
a = [];
|
|
79
|
+
let r;
|
|
80
|
+
this.dictIndex = r = 0;
|
|
81
|
+
const o = `_${t}_dict_ranges`, l = this._dict_ranges[o];
|
|
82
|
+
Object.keys(l).forEach((u) => {
|
|
83
|
+
const U = u;
|
|
84
|
+
for (this.dictRange = l[U], this.lowerBound = this.dictRange[0], this.upperBound = this.dictRange[1], this.dictIndex = r = this.lowerBound; this.lowerBound <= this.upperBound ? r < this.upperBound : r > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? r += 1 : r -= 1)
|
|
85
|
+
a.push(String.fromCharCode(this.dictIndex));
|
|
86
|
+
});
|
|
116
87
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
[
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
88
|
+
return s && (a = a.sort(() => Math.random() - 0.5)), a;
|
|
89
|
+
}), i(this, "setDictionary", (t, s) => {
|
|
90
|
+
this.dict = this._normalizeDictionary(t, s), this.dictLength = this.dict.length, this.setCounter(0);
|
|
91
|
+
}), i(this, "seq", () => this.sequentialUUID()), i(this, "sequentialUUID", () => {
|
|
92
|
+
let t, s, a = "";
|
|
93
|
+
t = this.counter;
|
|
94
|
+
do
|
|
95
|
+
s = t % this.dictLength, t = Math.trunc(t / this.dictLength), a += this.dict[s];
|
|
96
|
+
while (t !== 0);
|
|
97
|
+
return this.counter += 1, a;
|
|
98
|
+
}), i(this, "rnd", (t = this.uuidLength || g) => this.randomUUID(t)), i(this, "randomUUID", (t = this.uuidLength || g) => {
|
|
99
|
+
let s, a, r;
|
|
100
|
+
if (t === null || typeof t > "u" || t < 1)
|
|
101
|
+
throw new Error("Invalid UUID Length Provided");
|
|
102
|
+
for (s = "", r = 0; r < t; r += 1)
|
|
103
|
+
a = parseInt(
|
|
104
|
+
(Math.random() * this.dictLength).toFixed(0),
|
|
105
|
+
10
|
|
106
|
+
) % this.dictLength, s += this.dict[a];
|
|
107
|
+
return s;
|
|
108
|
+
}), i(this, "fmt", (t, s) => this.formattedUUID(t, s)), i(this, "formattedUUID", (t, s) => {
|
|
109
|
+
const a = {
|
|
110
|
+
$r: this.randomUUID,
|
|
111
|
+
$s: this.sequentialUUID,
|
|
112
|
+
$t: this.stamp
|
|
113
|
+
};
|
|
114
|
+
return t.replace(
|
|
115
|
+
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
116
|
+
(r) => {
|
|
117
|
+
const o = r.slice(0, 2), l = parseInt(r.slice(2), 10);
|
|
118
|
+
return o === "$s" ? a[o]().padStart(l, "0") : o === "$t" && s ? a[o](l, s) : a[o](l);
|
|
119
|
+
}
|
|
140
120
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
121
|
+
}), i(this, "availableUUIDs", (t = this.uuidLength) => parseFloat(
|
|
122
|
+
Math.pow([...new Set(this.dict)].length, t).toFixed(0)
|
|
123
|
+
)), i(this, "approxMaxBeforeCollision", (t = this.availableUUIDs(this.uuidLength)) => parseFloat(
|
|
124
|
+
Math.sqrt(Math.PI / 2 * t).toFixed(20)
|
|
125
|
+
)), i(this, "collisionProbability", (t = this.availableUUIDs(this.uuidLength), s = this.uuidLength) => parseFloat(
|
|
126
|
+
(this.approxMaxBeforeCollision(t) / this.availableUUIDs(s)).toFixed(20)
|
|
127
|
+
)), i(this, "uniqueness", (t = this.availableUUIDs(this.uuidLength)) => {
|
|
128
|
+
const s = parseFloat(
|
|
129
|
+
(1 - this.approxMaxBeforeCollision(t) / t).toFixed(20)
|
|
130
|
+
);
|
|
131
|
+
return s > 1 ? 1 : s < 0 ? 0 : s;
|
|
132
|
+
}), i(this, "getVersion", () => this.version), i(this, "stamp", (t, s) => {
|
|
133
|
+
const a = Math.floor(+(s || /* @__PURE__ */ new Date()) / 1e3).toString(16);
|
|
134
|
+
if (typeof t == "number" && t === 0)
|
|
135
|
+
return a;
|
|
136
|
+
if (typeof t != "number" || t < 10)
|
|
137
|
+
throw new Error(
|
|
138
|
+
[
|
|
139
|
+
"Param finalLength must be a number greater than or equal to 10,",
|
|
140
|
+
"or 0 if you want the raw hexadecimal timestamp"
|
|
141
|
+
].join(`
|
|
142
|
+
`)
|
|
143
|
+
);
|
|
144
|
+
const r = t - 9, o = Math.round(Math.random() * (r > 15 ? 15 : r)), l = this.randomUUID(r);
|
|
145
|
+
return `${l.substring(0, o)}${a}${l.substring(o)}${o.toString(16)}`;
|
|
146
|
+
}), i(this, "parseStamp", (t, s) => {
|
|
147
|
+
if (s && !/t0|t[1-9]\d{1,}/.test(s))
|
|
148
|
+
throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");
|
|
149
|
+
const a = s ? s.replace(
|
|
150
|
+
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
151
|
+
(o) => {
|
|
152
|
+
const l = {
|
|
153
|
+
$r: (p) => [...Array(p)].map(() => "r").join(""),
|
|
154
|
+
$s: (p) => [...Array(p)].map(() => "s").join(""),
|
|
155
|
+
$t: (p) => [...Array(p)].map(() => "t").join("")
|
|
156
|
+
}, u = o.slice(0, 2), U = parseInt(o.slice(2), 10);
|
|
157
|
+
return l[u](U);
|
|
158
|
+
}
|
|
159
|
+
).replace(
|
|
160
|
+
/^(.*?)(t{8,})(.*)$/g,
|
|
161
|
+
(o, l, u) => t.substring(l.length, l.length + u.length)
|
|
162
|
+
) : t;
|
|
163
|
+
if (a.length === 8)
|
|
164
|
+
return new Date(parseInt(a, 16) * 1e3);
|
|
165
|
+
if (a.length < 10)
|
|
166
|
+
throw new Error("Stamp length invalid");
|
|
167
|
+
const r = parseInt(a.substring(a.length - 1), 16);
|
|
168
|
+
return new Date(parseInt(a.substring(r, r + 8), 16) * 1e3);
|
|
169
|
+
}), i(this, "setCounter", (t) => {
|
|
170
|
+
this.counter = t;
|
|
171
|
+
}), i(this, "validate", (t, s) => {
|
|
172
|
+
const a = s ? this._normalizeDictionary(s) : this.dict;
|
|
173
|
+
return t.split("").every((r) => a.includes(r));
|
|
174
|
+
});
|
|
175
|
+
const e = D(D({}, v), n);
|
|
176
|
+
this.counter = 0, this.debug = !1, this.dict = [], this.version = q;
|
|
177
|
+
const {
|
|
178
|
+
dictionary: h,
|
|
179
|
+
shuffle: f,
|
|
180
|
+
length: d,
|
|
181
|
+
counter: T
|
|
182
|
+
} = e;
|
|
183
|
+
return this.uuidLength = d, this.setDictionary(h, f), this.setCounter(T), this.debug = e.debug, this.log(this.dict), this.log(
|
|
184
|
+
`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
|
|
185
|
+
), this.log = this.log.bind(this), this.setDictionary = this.setDictionary.bind(this), this.setCounter = this.setCounter.bind(this), this.seq = this.seq.bind(this), this.sequentialUUID = this.sequentialUUID.bind(this), this.rnd = this.rnd.bind(this), this.randomUUID = this.randomUUID.bind(this), this.fmt = this.fmt.bind(this), this.formattedUUID = this.formattedUUID.bind(this), this.availableUUIDs = this.availableUUIDs.bind(this), this.approxMaxBeforeCollision = this.approxMaxBeforeCollision.bind(this), this.collisionProbability = this.collisionProbability.bind(this), this.uniqueness = this.uniqueness.bind(this), this.getVersion = this.getVersion.bind(this), this.stamp = this.stamp.bind(this), this.parseStamp = this.parseStamp.bind(this), this;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
i(w, "default", w);
|
|
189
|
+
var P = w;
|
|
190
|
+
return B(x);
|
|
191
|
+
})();
|
|
192
|
+
_.exports = m.default, typeof window < "u" && (m = m.default);
|
|
193
|
+
}(C)), C.exports;
|
|
194
|
+
}
|
|
195
|
+
var N = F();
|
|
196
|
+
const R = /* @__PURE__ */ A(N);
|
|
197
|
+
new R({ length: 10 });
|
|
191
198
|
export {
|
|
192
|
-
|
|
199
|
+
j as ChannelEvents
|
|
193
200
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(p
|
|
2
|
-
`));const
|
|
1
|
+
(function(u,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(u=typeof globalThis<"u"?globalThis:u||self,p(u.LL_Types={}))})(this,function(u){"use strict";var p=(_=>(_.GET_STATE="get-state",_.GET_STATE_RESPONSE="get-state-response",_.SET_STATE="set-state",_.ON_CHANGE="on-change",_.RESIZE="resize",_))(p||{});function S(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var D={exports:{}},x;function M(){return x||(x=1,function(_){var w=(()=>{var f=Object.defineProperty,B=Object.getOwnPropertyDescriptor,j=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,U=(h,e,n)=>e in h?f(h,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):h[e]=n,L=(h,e)=>{for(var n in e||(e={}))C.call(e,n)&&U(h,n,e[n]);if(v)for(var n of v(e))P.call(e,n)&&U(h,n,e[n]);return h},q=(h,e)=>{for(var n in e)f(h,n,{get:e[n],enumerable:!0})},A=(h,e,n,b)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of j(e))!C.call(h,d)&&d!==n&&f(h,d,{get:()=>e[d],enumerable:!(b=B(e,d))||b.enumerable});return h},F=h=>A(f({},"__esModule",{value:!0}),h),i=(h,e,n)=>(U(h,typeof e!="symbol"?e+"":e,n),n),$={};q($,{DEFAULT_OPTIONS:()=>E,DEFAULT_UUID_LENGTH:()=>m,default:()=>R});var N="5.2.0",m=6,E={dictionary:"alphanum",shuffle:!0,debug:!1,length:m,counter:0},y=class{constructor(h={}){i(this,"counter"),i(this,"debug"),i(this,"dict"),i(this,"version"),i(this,"dictIndex",0),i(this,"dictRange",[]),i(this,"lowerBound",0),i(this,"upperBound",0),i(this,"dictLength",0),i(this,"uuidLength"),i(this,"_digit_first_ascii",48),i(this,"_digit_last_ascii",58),i(this,"_alpha_lower_first_ascii",97),i(this,"_alpha_lower_last_ascii",123),i(this,"_hex_last_ascii",103),i(this,"_alpha_upper_first_ascii",65),i(this,"_alpha_upper_last_ascii",91),i(this,"_number_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii]}),i(this,"_alpha_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alpha_lower_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alpha_upper_dict_ranges",{upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_lower_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alphanum_upper_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_hex_dict_ranges",{decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]}),i(this,"_dict_ranges",{_number_dict_ranges:this._number_dict_ranges,_alpha_dict_ranges:this._alpha_dict_ranges,_alpha_lower_dict_ranges:this._alpha_lower_dict_ranges,_alpha_upper_dict_ranges:this._alpha_upper_dict_ranges,_alphanum_dict_ranges:this._alphanum_dict_ranges,_alphanum_lower_dict_ranges:this._alphanum_lower_dict_ranges,_alphanum_upper_dict_ranges:this._alphanum_upper_dict_ranges,_hex_dict_ranges:this._hex_dict_ranges}),i(this,"log",(...t)=>{const s=[...t];if(s[0]=`[short-unique-id] ${t[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...s)}),i(this,"_normalizeDictionary",(t,s)=>{let a;if(t&&Array.isArray(t)&&t.length>1)a=t;else{a=[];let r;this.dictIndex=r=0;const o=`_${t}_dict_ranges`,l=this._dict_ranges[o];Object.keys(l).forEach(c=>{const I=c;for(this.dictRange=l[I],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=r=this.lowerBound;this.lowerBound<=this.upperBound?r<this.upperBound:r>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?r+=1:r-=1)a.push(String.fromCharCode(this.dictIndex))})}return s&&(a=a.sort(()=>Math.random()-.5)),a}),i(this,"setDictionary",(t,s)=>{this.dict=this._normalizeDictionary(t,s),this.dictLength=this.dict.length,this.setCounter(0)}),i(this,"seq",()=>this.sequentialUUID()),i(this,"sequentialUUID",()=>{let t,s,a="";t=this.counter;do s=t%this.dictLength,t=Math.trunc(t/this.dictLength),a+=this.dict[s];while(t!==0);return this.counter+=1,a}),i(this,"rnd",(t=this.uuidLength||m)=>this.randomUUID(t)),i(this,"randomUUID",(t=this.uuidLength||m)=>{let s,a,r;if(t===null||typeof t>"u"||t<1)throw new Error("Invalid UUID Length Provided");for(s="",r=0;r<t;r+=1)a=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,s+=this.dict[a];return s}),i(this,"fmt",(t,s)=>this.formattedUUID(t,s)),i(this,"formattedUUID",(t,s)=>{const a={$r:this.randomUUID,$s:this.sequentialUUID,$t:this.stamp};return t.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,r=>{const o=r.slice(0,2),l=parseInt(r.slice(2),10);return o==="$s"?a[o]().padStart(l,"0"):o==="$t"&&s?a[o](l,s):a[o](l)})}),i(this,"availableUUIDs",(t=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,t).toFixed(0))),i(this,"approxMaxBeforeCollision",(t=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*t).toFixed(20))),i(this,"collisionProbability",(t=this.availableUUIDs(this.uuidLength),s=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(t)/this.availableUUIDs(s)).toFixed(20))),i(this,"uniqueness",(t=this.availableUUIDs(this.uuidLength))=>{const s=parseFloat((1-this.approxMaxBeforeCollision(t)/t).toFixed(20));return s>1?1:s<0?0:s}),i(this,"getVersion",()=>this.version),i(this,"stamp",(t,s)=>{const a=Math.floor(+(s||new Date)/1e3).toString(16);if(typeof t=="number"&&t===0)return a;if(typeof t!="number"||t<10)throw new Error(["Param finalLength must be a number greater than or equal to 10,","or 0 if you want the raw hexadecimal timestamp"].join(`
|
|
2
|
+
`));const r=t-9,o=Math.round(Math.random()*(r>15?15:r)),l=this.randomUUID(r);return`${l.substring(0,o)}${a}${l.substring(o)}${o.toString(16)}`}),i(this,"parseStamp",(t,s)=>{if(s&&!/t0|t[1-9]\d{1,}/.test(s))throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");const a=s?s.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,o=>{const l={$r:g=>[...Array(g)].map(()=>"r").join(""),$s:g=>[...Array(g)].map(()=>"s").join(""),$t:g=>[...Array(g)].map(()=>"t").join("")},c=o.slice(0,2),I=parseInt(o.slice(2),10);return l[c](I)}).replace(/^(.*?)(t{8,})(.*)$/g,(o,l,c)=>t.substring(l.length,l.length+c.length)):t;if(a.length===8)return new Date(parseInt(a,16)*1e3);if(a.length<10)throw new Error("Stamp length invalid");const r=parseInt(a.substring(a.length-1),16);return new Date(parseInt(a.substring(r,r+8),16)*1e3)}),i(this,"setCounter",t=>{this.counter=t}),i(this,"validate",(t,s)=>{const a=s?this._normalizeDictionary(s):this.dict;return t.split("").every(r=>a.includes(r))});const e=L(L({},E),h);this.counter=0,this.debug=!1,this.dict=[],this.version=N;const{dictionary:n,shuffle:b,length:d,counter:z}=e;return this.uuidLength=d,this.setDictionary(n,b),this.setCounter(z),this.debug=e.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`),this.log=this.log.bind(this),this.setDictionary=this.setDictionary.bind(this),this.setCounter=this.setCounter.bind(this),this.seq=this.seq.bind(this),this.sequentialUUID=this.sequentialUUID.bind(this),this.rnd=this.rnd.bind(this),this.randomUUID=this.randomUUID.bind(this),this.fmt=this.fmt.bind(this),this.formattedUUID=this.formattedUUID.bind(this),this.availableUUIDs=this.availableUUIDs.bind(this),this.approxMaxBeforeCollision=this.approxMaxBeforeCollision.bind(this),this.collisionProbability=this.collisionProbability.bind(this),this.uniqueness=this.uniqueness.bind(this),this.getVersion=this.getVersion.bind(this),this.stamp=this.stamp.bind(this),this.parseStamp=this.parseStamp.bind(this),this}};i(y,"default",y);var R=y;return F($)})();_.exports=w.default,typeof window<"u"&&(w=w.default)}(D)),D.exports}var O=M();const T=S(O);new T({length:10}),u.ChannelEvents=p,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@local-logic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"author": "Local Logic",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "vite",
|
|
16
16
|
"build": "vite build",
|
|
17
|
+
"build:staging": "vite build --mode=staging",
|
|
17
18
|
"lint": "TIMING=1 eslint --ext .js,.jsx,.ts,.tsx .",
|
|
18
19
|
"check-types": "tsc --project ./tsconfig.json --noEmit",
|
|
19
20
|
"prepublishOnly": "yarn run build",
|
|
@@ -22,16 +23,15 @@
|
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@local-logic/channel": "*",
|
|
24
25
|
"@local-logic/client": "*",
|
|
25
|
-
"@local-logic/elements-react": "*",
|
|
26
26
|
"@local-logic/eslint-config": "*",
|
|
27
27
|
"@local-logic/sdks-app": "*",
|
|
28
|
-
"eslint": "^8.
|
|
29
|
-
"prettier": "^3.
|
|
28
|
+
"eslint": "^8.57.1",
|
|
29
|
+
"prettier": "^3.3.3",
|
|
30
30
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
31
31
|
"tsconfig": "*",
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"vite": "^
|
|
34
|
-
"vite-plugin-dts": "^3.
|
|
35
|
-
"vitest": "^
|
|
32
|
+
"typescript": "^5.6.3",
|
|
33
|
+
"vite": "^6.0.9",
|
|
34
|
+
"vite-plugin-dts": "^4.3.0",
|
|
35
|
+
"vitest": "^2.1.9"
|
|
36
36
|
}
|
|
37
37
|
}
|