@unicom-cloud/utils 0.1.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/case-name/index.js +23 -0
- package/class-name/index.js +9 -0
- package/clipboard-copy/index.js +41 -0
- package/constant/address.js +5304 -0
- package/constant/chineseCharacters.js +4 -0
- package/constant/constellations.js +17 -0
- package/constant/domain.js +268 -0
- package/constant/identity.js +18 -0
- package/constant/index.js +6 -0
- package/constant/keyboardCode.js +105 -0
- package/constant/licensePlate.js +42 -0
- package/constant/name.js +666 -0
- package/constant/platform.js +20 -0
- package/constant/protocol.js +18 -0
- package/constant/ui.js +17 -0
- package/cookie/index.js +33 -0
- package/cookie/src/index.js +116 -0
- package/decimal/decimal.js +1070 -0
- package/decimal/index.js +5 -0
- package/event-emitter/index.js +57 -0
- package/file/fileToURL.js +26 -0
- package/file/index.js +6 -0
- package/file/saveAs.js +35 -0
- package/filesize/index.js +8 -0
- package/filesize/src/constants.js +71 -0
- package/filesize/src/filesize.js +88 -0
- package/index.js +47 -0
- package/invariant/index.js +21 -0
- package/is/index.js +137 -0
- package/math/index.js +34 -0
- package/md5/index.js +65 -0
- package/mock/MockWebSocket.js +117 -0
- package/mock/MockXMLHttpRequest.js +94 -0
- package/mock/index.js +8 -0
- package/normalize-wheel/ExecutionEnvironment.js +11 -0
- package/normalize-wheel/UserAgent_DEPRECATED.js +146 -0
- package/normalize-wheel/index.js +13 -0
- package/normalize-wheel/isEventSupported.js +33 -0
- package/nzh/cn.js +7 -0
- package/nzh/hk.js +7 -0
- package/nzh/index.js +4 -0
- package/nzh/nzh.js +22 -0
- package/nzh/src/autoGet.js +25 -0
- package/nzh/src/index.js +93 -0
- package/nzh/src/langs/cn_b.js +12 -0
- package/nzh/src/langs/cn_s.js +9 -0
- package/nzh/src/langs/hk_b.js +12 -0
- package/nzh/src/langs/hk_s.js +9 -0
- package/nzh/src/utils.js +71 -0
- package/objectKeysSort.js +7 -0
- package/package.json +1 -0
- package/random/address.js +32 -0
- package/random/constellation.js +8 -0
- package/random/image.js +20 -0
- package/random/index.js +63 -0
- package/random/licensePlate.js +12 -0
- package/random/name.js +25 -0
- package/random/number.js +15 -0
- package/random/text.js +117 -0
- package/random/time.js +8 -0
- package/random/web.js +37 -0
- package/screenfull/index.js +119 -0
- package/tree/index.js +87 -0
- package/turbo-stream/index.js +6 -0
- package/turbo-stream/src/decode.js +284 -0
- package/turbo-stream/src/encode.js +363 -0
- package/turbo-stream/src/shared.js +287 -0
- package/url-toolkit/index.js +8 -0
- package/url-toolkit/src/url-toolkit.js +74 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var Y = (i) => {
|
|
3
|
+
throw TypeError(i);
|
|
4
|
+
};
|
|
5
|
+
var O = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
6
|
+
var R = (i, t, e) => O(i, typeof t != "symbol" ? t + "" : t, e), N = (i, t, e) => t.has(i) || Y("Cannot " + e);
|
|
7
|
+
var s = (i, t, e) => (N(i, t, "read from private field"), e ? e.call(i) : t.get(i)), r = (i, t, e) => t.has(i) ? Y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), o = (i, t, e, n) => (N(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), x = (i, t, e) => (N(i, t, "access private method"), e);
|
|
8
|
+
const C = "A", g = "*", v = "J", j = "j", q = "b", V = "K", W = "V", k = "D", H = "E", J = "!", K = "false", Q = "k", X = "H", Z = "h", $ = "F", ee = "I", te = "L", se = "G", ie = "O", ne = "M", re = "NaN", oe = "i", ae = "z", ce = "null", he = "P", Re = "$", de = "R", _e = "<redacted>", Te = "@", ue = "r", Se = "S", fe = ":", ye = "s", Ae = "true", pe = "l", le = "g", Ee = "o", we = "C", Ie = "u", Ne = "U";
|
|
9
|
+
let b = !0;
|
|
10
|
+
try {
|
|
11
|
+
new File([], "");
|
|
12
|
+
} catch {
|
|
13
|
+
b = !1;
|
|
14
|
+
}
|
|
15
|
+
var l, w, M;
|
|
16
|
+
class be {
|
|
17
|
+
constructor() {
|
|
18
|
+
r(this, w);
|
|
19
|
+
R(this, "p", 0);
|
|
20
|
+
r(this, l, []);
|
|
21
|
+
}
|
|
22
|
+
add() {
|
|
23
|
+
this.p++;
|
|
24
|
+
}
|
|
25
|
+
done() {
|
|
26
|
+
if (--this.p === 0) {
|
|
27
|
+
let t;
|
|
28
|
+
for (; (t = s(this, l).shift()) !== void 0; )
|
|
29
|
+
t();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
wait() {
|
|
33
|
+
return new Promise(x(this, w, M).bind(this));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
l = new WeakMap(), w = new WeakSet(), M = function(t) {
|
|
37
|
+
this.p === 0 ? t() : s(this, l).push(t);
|
|
38
|
+
};
|
|
39
|
+
class B {
|
|
40
|
+
constructor() {
|
|
41
|
+
R(this, "promise");
|
|
42
|
+
R(this, "resolve");
|
|
43
|
+
R(this, "reject");
|
|
44
|
+
this.promise = new Promise((t, e) => {
|
|
45
|
+
this.resolve = t, this.reject = e;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var E, d;
|
|
50
|
+
class z {
|
|
51
|
+
constructor() {
|
|
52
|
+
R(this, "iterable");
|
|
53
|
+
r(this, E, new B());
|
|
54
|
+
r(this, d, s(this, E));
|
|
55
|
+
this.iterable = (async function* () {
|
|
56
|
+
let t = s(this, E);
|
|
57
|
+
for (; ; ) {
|
|
58
|
+
const e = await t.promise;
|
|
59
|
+
if (e.done)
|
|
60
|
+
return;
|
|
61
|
+
yield e.value, t = e.next;
|
|
62
|
+
}
|
|
63
|
+
}).bind(this)();
|
|
64
|
+
}
|
|
65
|
+
resolve() {
|
|
66
|
+
s(this, d).resolve({ done: !0 });
|
|
67
|
+
}
|
|
68
|
+
reject(t) {
|
|
69
|
+
s(this, d).promise.catch(() => {
|
|
70
|
+
}), s(this, d).reject(t);
|
|
71
|
+
}
|
|
72
|
+
yield(t) {
|
|
73
|
+
const e = new B();
|
|
74
|
+
s(this, d).resolve({
|
|
75
|
+
done: !1,
|
|
76
|
+
value: t,
|
|
77
|
+
next: e
|
|
78
|
+
}), o(this, d, e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
E = new WeakMap(), d = new WeakMap();
|
|
82
|
+
class Le extends z {
|
|
83
|
+
constructor() {
|
|
84
|
+
super(...arguments);
|
|
85
|
+
R(this, "readable", new ReadableStream({
|
|
86
|
+
start: async (e) => {
|
|
87
|
+
try {
|
|
88
|
+
for await (const n of this.iterable)
|
|
89
|
+
e.enqueue(n);
|
|
90
|
+
e.close();
|
|
91
|
+
} catch (n) {
|
|
92
|
+
e.error(n);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
var _, T, a;
|
|
99
|
+
const L = class L extends Blob {
|
|
100
|
+
constructor(e, n, h, I) {
|
|
101
|
+
super();
|
|
102
|
+
R(this, "promise");
|
|
103
|
+
r(this, _);
|
|
104
|
+
r(this, T);
|
|
105
|
+
r(this, a, {});
|
|
106
|
+
if (typeof e < "u") {
|
|
107
|
+
this.promise = e.promise;
|
|
108
|
+
let y = s(e, a).start ?? 0;
|
|
109
|
+
typeof n < "u" && (y += n), s(this, a).start = y;
|
|
110
|
+
let A = s(e, a).end;
|
|
111
|
+
typeof h < "u" && (A = (s(e, a).start ?? 0) + h), s(this, a).end = A, o(this, T, I ?? (e == null ? void 0 : e.type)), o(this, _, (A ?? e.size) - y);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
get size() {
|
|
115
|
+
if (typeof s(this, _) > "u")
|
|
116
|
+
throw new Error("Size is not set");
|
|
117
|
+
return s(this, _);
|
|
118
|
+
}
|
|
119
|
+
set size(e) {
|
|
120
|
+
o(this, _, e);
|
|
121
|
+
}
|
|
122
|
+
get type() {
|
|
123
|
+
if (typeof s(this, T) > "u")
|
|
124
|
+
throw new Error("Type is not set");
|
|
125
|
+
return s(this, T);
|
|
126
|
+
}
|
|
127
|
+
set type(e) {
|
|
128
|
+
o(this, T, e);
|
|
129
|
+
}
|
|
130
|
+
async arrayBuffer() {
|
|
131
|
+
if (!this.promise)
|
|
132
|
+
throw new Error("Promise is not set");
|
|
133
|
+
const e = await this.promise;
|
|
134
|
+
return s(this, a) ? e.slice(
|
|
135
|
+
s(this, a).start,
|
|
136
|
+
s(this, a).end
|
|
137
|
+
) : e;
|
|
138
|
+
}
|
|
139
|
+
bytes() {
|
|
140
|
+
return this.arrayBuffer().then((e) => new Uint8Array(e));
|
|
141
|
+
}
|
|
142
|
+
slice(e, n, h) {
|
|
143
|
+
return new L(this, e, n, h);
|
|
144
|
+
}
|
|
145
|
+
stream() {
|
|
146
|
+
return new ReadableStream({
|
|
147
|
+
start: async (e) => {
|
|
148
|
+
try {
|
|
149
|
+
e.enqueue(await this.bytes()), e.close();
|
|
150
|
+
} catch (n) {
|
|
151
|
+
e.error(n);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
text() {
|
|
157
|
+
return this.bytes().then((e) => new TextDecoder().decode(e));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
_ = new WeakMap(), T = new WeakMap(), a = new WeakMap();
|
|
161
|
+
let F = L;
|
|
162
|
+
const m = b ? File : Blob;
|
|
163
|
+
var p, u, S, f, c;
|
|
164
|
+
const U = class U extends m {
|
|
165
|
+
constructor(e, n, h, I) {
|
|
166
|
+
var t = (...Ye) => (super(...Ye), R(this, "promise"), r(this, p), r(this, u), r(this, S), r(this, f), r(this, c, {}), this);
|
|
167
|
+
if (b ? t([], "") : t([]), typeof e < "u") {
|
|
168
|
+
this.promise = e.promise;
|
|
169
|
+
let y = s(e, c).start ?? 0;
|
|
170
|
+
typeof n < "u" && (y += n), s(this, c).start = y;
|
|
171
|
+
let A = s(e, c).end;
|
|
172
|
+
typeof h < "u" && (A = (s(e, c).start ?? 0) + h), s(this, c).end = A, o(this, u, I ?? (e == null ? void 0 : e.type)), o(this, S, e.name), o(this, f, e.lastModified);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get name() {
|
|
176
|
+
if (typeof s(this, S) > "u")
|
|
177
|
+
throw new Error("Name is not set");
|
|
178
|
+
return s(this, S);
|
|
179
|
+
}
|
|
180
|
+
set name(e) {
|
|
181
|
+
o(this, S, e);
|
|
182
|
+
}
|
|
183
|
+
get lastModified() {
|
|
184
|
+
if (typeof s(this, f) > "u")
|
|
185
|
+
throw new Error("Last modified is not set");
|
|
186
|
+
return s(this, f);
|
|
187
|
+
}
|
|
188
|
+
set lastModified(e) {
|
|
189
|
+
o(this, f, e);
|
|
190
|
+
}
|
|
191
|
+
get size() {
|
|
192
|
+
if (typeof s(this, p) > "u")
|
|
193
|
+
throw new Error("Size is not set");
|
|
194
|
+
return s(this, p);
|
|
195
|
+
}
|
|
196
|
+
set size(e) {
|
|
197
|
+
o(this, p, e);
|
|
198
|
+
}
|
|
199
|
+
get type() {
|
|
200
|
+
if (typeof s(this, u) > "u")
|
|
201
|
+
throw new Error("Type is not set");
|
|
202
|
+
return s(this, u);
|
|
203
|
+
}
|
|
204
|
+
set type(e) {
|
|
205
|
+
o(this, u, e);
|
|
206
|
+
}
|
|
207
|
+
async arrayBuffer() {
|
|
208
|
+
if (!this.promise)
|
|
209
|
+
throw new Error("Promise is not set");
|
|
210
|
+
const e = await this.promise;
|
|
211
|
+
return s(this, c) ? e.slice(
|
|
212
|
+
s(this, c).start,
|
|
213
|
+
s(this, c).end
|
|
214
|
+
) : e;
|
|
215
|
+
}
|
|
216
|
+
bytes() {
|
|
217
|
+
return this.arrayBuffer().then((e) => new Uint8Array(e));
|
|
218
|
+
}
|
|
219
|
+
slice(e, n, h) {
|
|
220
|
+
return new U(this, e, n, h);
|
|
221
|
+
}
|
|
222
|
+
stream() {
|
|
223
|
+
return new ReadableStream({
|
|
224
|
+
start: async (e) => {
|
|
225
|
+
try {
|
|
226
|
+
e.enqueue(await this.bytes()), e.close();
|
|
227
|
+
} catch (n) {
|
|
228
|
+
e.error(n);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
text() {
|
|
234
|
+
return this.bytes().then((e) => new TextDecoder().decode(e));
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
p = new WeakMap(), u = new WeakMap(), S = new WeakMap(), f = new WeakMap(), c = new WeakMap();
|
|
238
|
+
let D = U;
|
|
239
|
+
export {
|
|
240
|
+
B as Deferred,
|
|
241
|
+
z as DeferredAsyncIterable,
|
|
242
|
+
Le as DeferredReadableStream,
|
|
243
|
+
C as STR_ARRAY_BUFFER,
|
|
244
|
+
g as STR_ASYNC_ITERABLE,
|
|
245
|
+
q as STR_BIGINT,
|
|
246
|
+
v as STR_BIG_INT_64_ARRAY,
|
|
247
|
+
j as STR_BIG_UINT_64_ARRAY,
|
|
248
|
+
V as STR_BLOB,
|
|
249
|
+
W as STR_DATA_VIEW,
|
|
250
|
+
k as STR_DATE,
|
|
251
|
+
H as STR_ERROR,
|
|
252
|
+
J as STR_FAILURE,
|
|
253
|
+
K as STR_FALSE,
|
|
254
|
+
Q as STR_FILE,
|
|
255
|
+
X as STR_FLOAT_32_ARRAY,
|
|
256
|
+
Z as STR_FLOAT_64_ARRAY,
|
|
257
|
+
$ as STR_FORM_DATA,
|
|
258
|
+
ee as STR_INFINITY,
|
|
259
|
+
te as STR_INT_16_ARRAY,
|
|
260
|
+
se as STR_INT_32_ARRAY,
|
|
261
|
+
ie as STR_INT_8_ARRAY,
|
|
262
|
+
ne as STR_MAP,
|
|
263
|
+
oe as STR_NEGATIVE_INFINITY,
|
|
264
|
+
ae as STR_NEGATIVE_ZERO,
|
|
265
|
+
ce as STR_NULL,
|
|
266
|
+
re as STR_NaN,
|
|
267
|
+
he as STR_PLUGIN,
|
|
268
|
+
Re as STR_PROMISE,
|
|
269
|
+
de as STR_READABLE_STREAM,
|
|
270
|
+
_e as STR_REDACTED,
|
|
271
|
+
Te as STR_REFERENCE_SYMBOL,
|
|
272
|
+
ue as STR_REGEXP,
|
|
273
|
+
Se as STR_SET,
|
|
274
|
+
fe as STR_SUCCESS,
|
|
275
|
+
ye as STR_SYMBOL,
|
|
276
|
+
Ae as STR_TRUE,
|
|
277
|
+
pe as STR_UINT_16_ARRAY,
|
|
278
|
+
le as STR_UINT_32_ARRAY,
|
|
279
|
+
Ee as STR_UINT_8_ARRAY,
|
|
280
|
+
we as STR_UINT_8_ARRAY_CLAMPED,
|
|
281
|
+
Ie as STR_UNDEFINED,
|
|
282
|
+
Ne as STR_URL,
|
|
283
|
+
b as SUPPORTS_FILE,
|
|
284
|
+
F as TurboBlob,
|
|
285
|
+
D as TurboFile,
|
|
286
|
+
be as WaitGroup
|
|
287
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const l = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, p = /^(?=([^\/?#]*))\1([^]*)$/, f = /(?:\/|^)\.(?=\/)/g, m = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;
|
|
2
|
+
function E(r, a, s) {
|
|
3
|
+
if (s = s || {}, r = r.trim(), a = a.trim(), !a) {
|
|
4
|
+
if (!s.alwaysNormalize)
|
|
5
|
+
return r;
|
|
6
|
+
const n = c(r);
|
|
7
|
+
if (!n)
|
|
8
|
+
throw new Error("Error trying to parse base URL.");
|
|
9
|
+
return n.path = i(n.path), h(n);
|
|
10
|
+
}
|
|
11
|
+
const t = c(a);
|
|
12
|
+
if (!t)
|
|
13
|
+
throw new Error("Error trying to parse relative URL.");
|
|
14
|
+
if (t.scheme)
|
|
15
|
+
return s.alwaysNormalize ? (t.path = i(t.path), h(t)) : a;
|
|
16
|
+
const e = c(r);
|
|
17
|
+
if (!e)
|
|
18
|
+
throw new Error("Error trying to parse base URL.");
|
|
19
|
+
if (!e.netLoc && e.path && e.path[0] !== "/") {
|
|
20
|
+
const n = p.exec(e.path);
|
|
21
|
+
e.netLoc = n[1], e.path = n[2];
|
|
22
|
+
}
|
|
23
|
+
e.netLoc && !e.path && (e.path = "/");
|
|
24
|
+
const o = {
|
|
25
|
+
// 2c) Otherwise, the embedded URL inherits the scheme of
|
|
26
|
+
// the base URL.
|
|
27
|
+
scheme: e.scheme,
|
|
28
|
+
netLoc: t.netLoc,
|
|
29
|
+
path: null,
|
|
30
|
+
params: t.params,
|
|
31
|
+
query: t.query,
|
|
32
|
+
fragment: t.fragment
|
|
33
|
+
};
|
|
34
|
+
if (!t.netLoc && (o.netLoc = e.netLoc, t.path[0] !== "/"))
|
|
35
|
+
if (!t.path)
|
|
36
|
+
o.path = e.path, t.params || (o.params = e.params, t.query || (o.query = e.query));
|
|
37
|
+
else {
|
|
38
|
+
const n = e.path, u = n.substring(0, n.lastIndexOf("/") + 1) + t.path;
|
|
39
|
+
o.path = i(u);
|
|
40
|
+
}
|
|
41
|
+
return o.path === null && (o.path = s.alwaysNormalize ? i(t.path) : t.path), h(o);
|
|
42
|
+
}
|
|
43
|
+
function c(r) {
|
|
44
|
+
const a = l.exec(r);
|
|
45
|
+
return a ? {
|
|
46
|
+
scheme: a[1] || "",
|
|
47
|
+
netLoc: a[2] || "",
|
|
48
|
+
path: a[3] || "",
|
|
49
|
+
params: a[4] || "",
|
|
50
|
+
query: a[5] || "",
|
|
51
|
+
fragment: a[6] || ""
|
|
52
|
+
} : null;
|
|
53
|
+
}
|
|
54
|
+
function i(r) {
|
|
55
|
+
for (r = r.split("").reverse().join("").replace(f, ""); r.length !== (r = r.replace(m, "")).length; )
|
|
56
|
+
;
|
|
57
|
+
return r.split("").reverse().join("");
|
|
58
|
+
}
|
|
59
|
+
function h(r) {
|
|
60
|
+
return r.scheme + r.netLoc + r.path + r.params + r.query + r.fragment;
|
|
61
|
+
}
|
|
62
|
+
const y = {
|
|
63
|
+
buildAbsoluteURL: E,
|
|
64
|
+
parseURL: c,
|
|
65
|
+
normalizePath: i,
|
|
66
|
+
buildURLFromParts: h
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
E as buildAbsoluteURL,
|
|
70
|
+
h as buildURLFromParts,
|
|
71
|
+
y as default,
|
|
72
|
+
i as normalizePath,
|
|
73
|
+
c as parseURL
|
|
74
|
+
};
|