@local-logic/types 0.1.2 → 0.1.4
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/{src/index.ts → dist/index.d.ts} +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.umd.cjs +2 -0
- package/package.json +12 -9
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -21
- package/CHANGELOG.md +0 -14
- package/lint-staged.config.cjs +0 -4
- package/prettier.config.cjs +0 -2
- package/tsconfig.json +0 -17
- package/vite.config.ts +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var P = /* @__PURE__ */ ((_) => (_.GET_STATE = "get-state", _.GET_STATE_RESPONSE = "get-state-response", _.SET_STATE = "set-state", _.ON_CHANGE = "on-change", _.RESIZE = "resize", _))(P || {});
|
|
2
|
+
function T(_) {
|
|
3
|
+
return _ && _.__esModule && Object.prototype.hasOwnProperty.call(_, "default") ? _.default : _;
|
|
4
|
+
}
|
|
5
|
+
var C = { exports: {} };
|
|
6
|
+
(function(_) {
|
|
7
|
+
var b = (() => {
|
|
8
|
+
var c = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, E = Object.getOwnPropertyNames, I = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable, m = (n, e, r) => e in n ? c(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, D = (n, e) => {
|
|
9
|
+
for (var r in e || (e = {}))
|
|
10
|
+
y.call(e, r) && m(n, r, e[r]);
|
|
11
|
+
if (I)
|
|
12
|
+
for (var r of I(e))
|
|
13
|
+
L.call(e, r) && m(n, r, e[r]);
|
|
14
|
+
return n;
|
|
15
|
+
}, S = (n, e) => {
|
|
16
|
+
for (var r in e)
|
|
17
|
+
c(n, r, { get: e[r], enumerable: !0 });
|
|
18
|
+
}, M = (n, e, r, f) => {
|
|
19
|
+
if (e && typeof e == "object" || typeof e == "function")
|
|
20
|
+
for (let d of E(e))
|
|
21
|
+
!y.call(n, d) && d !== r && c(n, d, { get: () => e[d], enumerable: !(f = $(e, d)) || f.enumerable });
|
|
22
|
+
return n;
|
|
23
|
+
}, O = (n) => M(c({}, "__esModule", { value: !0 }), n), i = (n, e, r) => (m(n, typeof e != "symbol" ? e + "" : e, r), r), x = {};
|
|
24
|
+
S(x, {
|
|
25
|
+
DEFAULT_OPTIONS: () => v,
|
|
26
|
+
DEFAULT_UUID_LENGTH: () => g,
|
|
27
|
+
default: () => q
|
|
28
|
+
});
|
|
29
|
+
var B = "5.0.3", g = 6, v = {
|
|
30
|
+
dictionary: "alphanum",
|
|
31
|
+
shuffle: !0,
|
|
32
|
+
debug: !1,
|
|
33
|
+
length: g,
|
|
34
|
+
counter: 0
|
|
35
|
+
}, w = class {
|
|
36
|
+
constructor(n = {}) {
|
|
37
|
+
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", {
|
|
38
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii]
|
|
39
|
+
}), i(this, "_alpha_dict_ranges", {
|
|
40
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
41
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
42
|
+
}), i(this, "_alpha_lower_dict_ranges", {
|
|
43
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
44
|
+
}), i(this, "_alpha_upper_dict_ranges", {
|
|
45
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
46
|
+
}), i(this, "_alphanum_dict_ranges", {
|
|
47
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
48
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
49
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
50
|
+
}), i(this, "_alphanum_lower_dict_ranges", {
|
|
51
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
52
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
53
|
+
}), i(this, "_alphanum_upper_dict_ranges", {
|
|
54
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
55
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
56
|
+
}), i(this, "_hex_dict_ranges", {
|
|
57
|
+
decDigits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
58
|
+
alphaDigits: [this._alpha_lower_first_ascii, this._hex_last_ascii]
|
|
59
|
+
}), i(this, "_dict_ranges", {
|
|
60
|
+
_number_dict_ranges: this._number_dict_ranges,
|
|
61
|
+
_alpha_dict_ranges: this._alpha_dict_ranges,
|
|
62
|
+
_alpha_lower_dict_ranges: this._alpha_lower_dict_ranges,
|
|
63
|
+
_alpha_upper_dict_ranges: this._alpha_upper_dict_ranges,
|
|
64
|
+
_alphanum_dict_ranges: this._alphanum_dict_ranges,
|
|
65
|
+
_alphanum_lower_dict_ranges: this._alphanum_lower_dict_ranges,
|
|
66
|
+
_alphanum_upper_dict_ranges: this._alphanum_upper_dict_ranges,
|
|
67
|
+
_hex_dict_ranges: this._hex_dict_ranges
|
|
68
|
+
}), i(this, "log", (...t) => {
|
|
69
|
+
const s = [...t];
|
|
70
|
+
if (s[0] = `[short-unique-id] ${t[0]}`, this.debug === !0 && typeof console < "u" && console !== null)
|
|
71
|
+
return console.log(...s);
|
|
72
|
+
}), i(this, "setDictionary", (t, s) => {
|
|
73
|
+
let a;
|
|
74
|
+
if (t && Array.isArray(t) && t.length > 1)
|
|
75
|
+
a = t;
|
|
76
|
+
else {
|
|
77
|
+
a = [];
|
|
78
|
+
let h;
|
|
79
|
+
this.dictIndex = h = 0;
|
|
80
|
+
const o = `_${t}_dict_ranges`, l = this._dict_ranges[o];
|
|
81
|
+
Object.keys(l).forEach((p) => {
|
|
82
|
+
const U = p;
|
|
83
|
+
for (this.dictRange = l[U], this.lowerBound = this.dictRange[0], this.upperBound = this.dictRange[1], this.dictIndex = h = this.lowerBound; this.lowerBound <= this.upperBound ? h < this.upperBound : h > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? h += 1 : h -= 1)
|
|
84
|
+
a.push(String.fromCharCode(this.dictIndex));
|
|
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);
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}), i(this, "availableUUIDs", (t = this.uuidLength) => parseFloat(
|
|
119
|
+
Math.pow([...new Set(this.dict)].length, t).toFixed(0)
|
|
120
|
+
)), i(this, "approxMaxBeforeCollision", (t = this.availableUUIDs(this.uuidLength)) => parseFloat(
|
|
121
|
+
Math.sqrt(Math.PI / 2 * t).toFixed(20)
|
|
122
|
+
)), i(this, "collisionProbability", (t = this.availableUUIDs(this.uuidLength), s = this.uuidLength) => parseFloat(
|
|
123
|
+
(this.approxMaxBeforeCollision(t) / this.availableUUIDs(s)).toFixed(20)
|
|
124
|
+
)), i(this, "uniqueness", (t = this.availableUUIDs(this.uuidLength)) => {
|
|
125
|
+
const s = parseFloat(
|
|
126
|
+
(1 - this.approxMaxBeforeCollision(t) / t).toFixed(20)
|
|
127
|
+
);
|
|
128
|
+
return s > 1 ? 1 : s < 0 ? 0 : s;
|
|
129
|
+
}), i(this, "getVersion", () => this.version), i(this, "stamp", (t, s) => {
|
|
130
|
+
const a = Math.floor(+(s || /* @__PURE__ */ new Date()) / 1e3).toString(16);
|
|
131
|
+
if (typeof t == "number" && t === 0)
|
|
132
|
+
return a;
|
|
133
|
+
if (typeof t != "number" || t < 10)
|
|
134
|
+
throw new Error(
|
|
135
|
+
[
|
|
136
|
+
"Param finalLength must be a number greater than or equal to 10,",
|
|
137
|
+
"or 0 if you want the raw hexadecimal timestamp"
|
|
138
|
+
].join(`
|
|
139
|
+
`)
|
|
140
|
+
);
|
|
141
|
+
const h = t - 9, o = Math.round(Math.random() * (h > 15 ? 15 : h)), l = this.randomUUID(h);
|
|
142
|
+
return `${l.substring(0, o)}${a}${l.substring(o)}${o.toString(16)}`;
|
|
143
|
+
}), i(this, "parseStamp", (t, s) => {
|
|
144
|
+
if (s && !/t0|t[1-9]\d{1,}/.test(s))
|
|
145
|
+
throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");
|
|
146
|
+
const a = s ? s.replace(
|
|
147
|
+
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
148
|
+
(o) => {
|
|
149
|
+
const l = {
|
|
150
|
+
$r: (u) => [...Array(u)].map(() => "r").join(""),
|
|
151
|
+
$s: (u) => [...Array(u)].map(() => "s").join(""),
|
|
152
|
+
$t: (u) => [...Array(u)].map(() => "t").join("")
|
|
153
|
+
}, p = o.slice(0, 2), U = parseInt(o.slice(2), 10);
|
|
154
|
+
return l[p](U);
|
|
155
|
+
}
|
|
156
|
+
).replace(
|
|
157
|
+
/^(.*?)(t{8,})(.*)$/g,
|
|
158
|
+
(o, l, p) => t.substring(l.length, l.length + p.length)
|
|
159
|
+
) : t;
|
|
160
|
+
if (a.length === 8)
|
|
161
|
+
return new Date(parseInt(a, 16) * 1e3);
|
|
162
|
+
if (a.length < 10)
|
|
163
|
+
throw new Error("Stamp length invalid");
|
|
164
|
+
const h = parseInt(a.substring(a.length - 1), 16);
|
|
165
|
+
return new Date(parseInt(a.substring(h, h + 8), 16) * 1e3);
|
|
166
|
+
}), i(this, "setCounter", (t) => {
|
|
167
|
+
this.counter = t;
|
|
168
|
+
});
|
|
169
|
+
const e = D(D({}, v), n);
|
|
170
|
+
this.counter = 0, this.debug = !1, this.dict = [], this.version = B;
|
|
171
|
+
const {
|
|
172
|
+
dictionary: r,
|
|
173
|
+
shuffle: f,
|
|
174
|
+
length: d,
|
|
175
|
+
counter: j
|
|
176
|
+
} = e;
|
|
177
|
+
return this.uuidLength = d, this.setDictionary(r, f), this.setCounter(j), this.debug = e.debug, this.log(this.dict), this.log(
|
|
178
|
+
`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
|
|
179
|
+
), 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;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
i(w, "default", w);
|
|
183
|
+
var q = w;
|
|
184
|
+
return O(x);
|
|
185
|
+
})();
|
|
186
|
+
_.exports = b.default, typeof window < "u" && (b = b.default);
|
|
187
|
+
})(C);
|
|
188
|
+
var A = C.exports;
|
|
189
|
+
const F = /* @__PURE__ */ T(A);
|
|
190
|
+
new F({ length: 10 });
|
|
191
|
+
export {
|
|
192
|
+
P as ChannelEvents
|
|
193
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p.LL_Types={}))})(this,function(p){"use strict";var u=(_=>(_.GET_STATE="get-state",_.GET_STATE_RESPONSE="get-state-response",_.SET_STATE="set-state",_.ON_CHANGE="on-change",_.RESIZE="resize",_))(u||{});function E(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var D={exports:{}};(function(_){var w=(()=>{var f=Object.defineProperty,O=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,U=(n,e,r)=>e in n?f(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,C=(n,e)=>{for(var r in e||(e={}))v.call(e,r)&&U(n,r,e[r]);if(x)for(var r of x(e))B.call(e,r)&&U(n,r,e[r]);return n},j=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},q=(n,e,r,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of T(e))!v.call(n,d)&&d!==r&&f(n,d,{get:()=>e[d],enumerable:!(m=O(e,d))||m.enumerable});return n},P=n=>q(f({},"__esModule",{value:!0}),n),i=(n,e,r)=>(U(n,typeof e!="symbol"?e+"":e,r),r),L={};j(L,{DEFAULT_OPTIONS:()=>$,DEFAULT_UUID_LENGTH:()=>b,default:()=>F});var A="5.0.3",b=6,$={dictionary:"alphanum",shuffle:!0,debug:!1,length:b,counter:0},y=class{constructor(n={}){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,"setDictionary",(t,s)=>{let a;if(t&&Array.isArray(t)&&t.length>1)a=t;else{a=[];let h;this.dictIndex=h=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=h=this.lowerBound;this.lowerBound<=this.upperBound?h<this.upperBound:h>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?h+=1:h-=1)a.push(String.fromCharCode(this.dictIndex))})}s&&(a=a.sort(()=>Math.random()-.5)),this.dict=a,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||b)=>this.randomUUID(t)),i(this,"randomUUID",(t=this.uuidLength||b)=>{let s,a,h;if(t===null||typeof t>"u"||t<1)throw new Error("Invalid UUID Length Provided");for(s="",h=0;h<t;h+=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,h=>{const o=h.slice(0,2),l=parseInt(h.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 h=t-9,o=Math.round(Math.random()*(h>15?15:h)),l=this.randomUUID(h);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 h=parseInt(a.substring(a.length-1),16);return new Date(parseInt(a.substring(h,h+8),16)*1e3)}),i(this,"setCounter",t=>{this.counter=t});const e=C(C({},$),n);this.counter=0,this.debug=!1,this.dict=[],this.version=A;const{dictionary:r,shuffle:m,length:d,counter:R}=e;return this.uuidLength=d,this.setDictionary(r,m),this.setCounter(R),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 F=y;return P(L)})();_.exports=w.default,typeof window<"u"&&(w=w.default)})(D);var S=D.exports;const M=E(S);new M({length:10}),p.ChannelEvents=u,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@local-logic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"author": "Local Logic",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
8
9
|
"license": "ISC",
|
|
9
10
|
"main": "./dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist/**/*"
|
|
13
|
+
],
|
|
10
14
|
"scripts": {
|
|
11
15
|
"dev": "vite",
|
|
12
16
|
"build": "vite build",
|
|
@@ -20,15 +24,14 @@
|
|
|
20
24
|
"@local-logic/client": "*",
|
|
21
25
|
"@local-logic/elements-react": "*",
|
|
22
26
|
"@local-logic/eslint-config": "*",
|
|
23
|
-
"@local-logic/lat-client": "*",
|
|
24
27
|
"@local-logic/sdks-app": "*",
|
|
25
|
-
"eslint": "^8.
|
|
26
|
-
"prettier": "^3.1.
|
|
27
|
-
"rollup-plugin-visualizer": "^5.
|
|
28
|
+
"eslint": "^8.56.0",
|
|
29
|
+
"prettier": "^3.1.1",
|
|
30
|
+
"rollup-plugin-visualizer": "^5.12.0",
|
|
28
31
|
"tsconfig": "*",
|
|
29
|
-
"typescript": "^5.
|
|
30
|
-
"vite": "^
|
|
31
|
-
"vite-plugin-dts": "^3.
|
|
32
|
-
"vitest": "^
|
|
32
|
+
"typescript": "^5.3.3",
|
|
33
|
+
"vite": "^5.0.11",
|
|
34
|
+
"vite-plugin-dts": "^3.7.0",
|
|
35
|
+
"vitest": "^1.1.3"
|
|
33
36
|
}
|
|
34
37
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
"@local-logic/eslint-config/base",
|
|
4
|
-
],
|
|
5
|
-
settings: {
|
|
6
|
-
"import/resolver": {
|
|
7
|
-
typescript: {},
|
|
8
|
-
node: {
|
|
9
|
-
extensions: [".ts"],
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
overrides: [
|
|
14
|
-
{
|
|
15
|
-
files: ["**/*.ts"],
|
|
16
|
-
rules: {
|
|
17
|
-
"import/extensions": "off"
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
]
|
|
21
|
-
};
|
package/CHANGELOG.md
DELETED
package/lint-staged.config.cjs
DELETED
package/prettier.config.cjs
DELETED
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "tsconfig/react-library.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"declarationMap": true
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"./src/**/*",
|
|
10
|
-
"global.d.ts"
|
|
11
|
-
],
|
|
12
|
-
"exclude": [
|
|
13
|
-
"dist",
|
|
14
|
-
"build",
|
|
15
|
-
"node_modules"
|
|
16
|
-
]
|
|
17
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { visualizer } from "rollup-plugin-visualizer";
|
|
3
|
-
import { defineConfig, PluginOption } from "vite";
|
|
4
|
-
import dts from "vite-plugin-dts";
|
|
5
|
-
|
|
6
|
-
// https://vitejs.dev/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
build: {
|
|
9
|
-
lib: {
|
|
10
|
-
entry: {
|
|
11
|
-
index: path.resolve(__dirname, "src/index.ts"),
|
|
12
|
-
},
|
|
13
|
-
name: "LL_Types",
|
|
14
|
-
},
|
|
15
|
-
/**
|
|
16
|
-
* This option will only minify the UMD output. Package users can still see
|
|
17
|
-
* the unminified "index.es.js" output.
|
|
18
|
-
*/
|
|
19
|
-
minify: true,
|
|
20
|
-
},
|
|
21
|
-
resolve: {
|
|
22
|
-
alias: {
|
|
23
|
-
"~": path.resolve(__dirname, "./src"),
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
plugins: [
|
|
27
|
-
/**
|
|
28
|
-
* Generate typings
|
|
29
|
-
*/
|
|
30
|
-
dts({
|
|
31
|
-
insertTypesEntry: true,
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
// This option MUST come last. Note that build size WILL NOT represent build
|
|
35
|
-
// size in client app because it is not minified (client app should handle
|
|
36
|
-
// minification).
|
|
37
|
-
visualizer({ brotliSize: true, open: !!process.env.STATS }) as PluginOption,
|
|
38
|
-
],
|
|
39
|
-
});
|