@dvirus-js/utils 0.0.16 → 0.0.18
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/CHANGELOG.md +14 -0
- package/index.d.ts +1 -0
- package/index.js +213 -197
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.0.17 (2026-06-12)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **signals:** split signal-form into secondary entry point subpath ([16b14f9](https://github.com/Dvirus97/dvirus-js/commit/16b14f9))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Dvir Cohen
|
|
10
|
+
|
|
11
|
+
## 0.0.16 (2026-05-31)
|
|
12
|
+
|
|
13
|
+
This was a version bump only for utils to align it with other projects, there were no code changes.
|
|
14
|
+
|
|
1
15
|
## 0.0.15 (2026-05-31)
|
|
2
16
|
|
|
3
17
|
### 🩹 Fixes
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -2,42 +2,42 @@ function V(e) {
|
|
|
2
2
|
return e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim();
|
|
3
3
|
}
|
|
4
4
|
function ue(e, t) {
|
|
5
|
-
const
|
|
5
|
+
const n = V(e);
|
|
6
6
|
switch (t) {
|
|
7
7
|
case "lowercase":
|
|
8
|
-
return
|
|
8
|
+
return n.toLowerCase();
|
|
9
9
|
case "UPPERCASE":
|
|
10
|
-
return
|
|
10
|
+
return n.toUpperCase();
|
|
11
11
|
case "Title Case":
|
|
12
|
-
return
|
|
13
|
-
(
|
|
12
|
+
return n.split(" ").map(
|
|
13
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
14
14
|
).join(" ");
|
|
15
15
|
case "kebab-case":
|
|
16
|
-
return
|
|
16
|
+
return n.replace(/\s+/g, "-");
|
|
17
17
|
case "snake_case":
|
|
18
|
-
return
|
|
18
|
+
return n.replace(/\s+/g, "_");
|
|
19
19
|
case "camelCase": {
|
|
20
|
-
const
|
|
21
|
-
return
|
|
20
|
+
const r = n.split(" ");
|
|
21
|
+
return r.length === 0 ? "" : r[0]?.toLowerCase() + r.slice(1).map(
|
|
22
22
|
(o) => o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()
|
|
23
23
|
).join("");
|
|
24
24
|
}
|
|
25
25
|
case "PascalCase":
|
|
26
|
-
return
|
|
27
|
-
(
|
|
26
|
+
return n.split(" ").map(
|
|
27
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
28
28
|
).join("");
|
|
29
29
|
case "dot.case":
|
|
30
|
-
return
|
|
30
|
+
return n.replace(/\s+/g, ".");
|
|
31
31
|
case "path/case":
|
|
32
|
-
return
|
|
32
|
+
return n.replace(/\s+/g, "/");
|
|
33
33
|
case "Sentence case":
|
|
34
|
-
return
|
|
34
|
+
return n.replace(/(^\s*\w|[.!?]\s*\w)/g, (r) => r.toUpperCase()).replace(/\bi\b/g, "I");
|
|
35
35
|
case "Header-Case":
|
|
36
|
-
return
|
|
37
|
-
(
|
|
36
|
+
return n.split(" ").map(
|
|
37
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
38
38
|
).join("-");
|
|
39
39
|
case "reverse":
|
|
40
|
-
return
|
|
40
|
+
return n.split("").reverse().join("");
|
|
41
41
|
default:
|
|
42
42
|
throw new Error(`Unsupported case type: ${t}`);
|
|
43
43
|
}
|
|
@@ -149,18 +149,18 @@ const U = {
|
|
|
149
149
|
* @returns {Promise<R>} The response data.
|
|
150
150
|
* @throws {Error} If the response is not ok.
|
|
151
151
|
*/
|
|
152
|
-
post: async function(e, t,
|
|
152
|
+
post: async function(e, t, n) {
|
|
153
153
|
return await w(
|
|
154
154
|
() => fetch(b + e, {
|
|
155
155
|
method: "POST",
|
|
156
156
|
headers: {
|
|
157
157
|
"Content-Type": "application/json",
|
|
158
|
-
...
|
|
158
|
+
...n?.headers
|
|
159
159
|
},
|
|
160
160
|
body: JSON.stringify(t),
|
|
161
|
-
...
|
|
161
|
+
...n
|
|
162
162
|
}),
|
|
163
|
-
|
|
163
|
+
n
|
|
164
164
|
);
|
|
165
165
|
},
|
|
166
166
|
/**
|
|
@@ -195,18 +195,18 @@ const U = {
|
|
|
195
195
|
* @returns {Promise<R>} The response data.
|
|
196
196
|
* @throws {Error} If the response is not ok.
|
|
197
197
|
*/
|
|
198
|
-
patch: async function(e, t,
|
|
198
|
+
patch: async function(e, t, n) {
|
|
199
199
|
return await w(
|
|
200
200
|
() => fetch(b + e, {
|
|
201
201
|
method: "PATCH",
|
|
202
202
|
headers: {
|
|
203
203
|
"Content-Type": "application/json",
|
|
204
|
-
...
|
|
204
|
+
...n?.headers
|
|
205
205
|
},
|
|
206
206
|
body: JSON.stringify(t),
|
|
207
|
-
...
|
|
207
|
+
...n
|
|
208
208
|
}),
|
|
209
|
-
|
|
209
|
+
n
|
|
210
210
|
);
|
|
211
211
|
},
|
|
212
212
|
/**
|
|
@@ -219,123 +219,123 @@ const U = {
|
|
|
219
219
|
* @returns {Promise<R>} The response data.
|
|
220
220
|
* @throws {Error} If the response is not ok.
|
|
221
221
|
*/
|
|
222
|
-
put: async function(e, t,
|
|
222
|
+
put: async function(e, t, n) {
|
|
223
223
|
return await w(
|
|
224
224
|
() => fetch(b + e, {
|
|
225
225
|
method: "PUT",
|
|
226
226
|
headers: {
|
|
227
227
|
"Content-Type": "application/json",
|
|
228
|
-
...
|
|
228
|
+
...n?.headers
|
|
229
229
|
},
|
|
230
230
|
body: JSON.stringify(t),
|
|
231
|
-
...
|
|
231
|
+
...n
|
|
232
232
|
}),
|
|
233
|
-
|
|
233
|
+
n
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
async function w(e, t) {
|
|
238
238
|
try {
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
241
|
-
const
|
|
242
|
-
throw Object.assign(
|
|
243
|
-
data: s ?
|
|
244
|
-
name: `HTTP_${
|
|
245
|
-
message:
|
|
239
|
+
const n = await e();
|
|
240
|
+
if (!n.ok) {
|
|
241
|
+
const r = await n.text(), [o, s] = E(() => JSON.parse(r));
|
|
242
|
+
throw Object.assign(n, {
|
|
243
|
+
data: s ? r : o,
|
|
244
|
+
name: `HTTP_${n.status}`,
|
|
245
|
+
message: n.statusText || U[n.status] || `HTTP_${n.status}`
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
|
-
return t?.parse === "JSON" ? Object.assign(
|
|
249
|
-
data: await
|
|
250
|
-
}) : t?.parse === "TEXT" ? Object.assign(
|
|
251
|
-
data: await
|
|
252
|
-
}) : t?.parse === "BLOB" ? Object.assign(
|
|
253
|
-
data: await
|
|
254
|
-
}) : t?.parse === "ARRAYBUFFER" ? Object.assign(
|
|
255
|
-
data: await
|
|
256
|
-
}) : Object.assign(
|
|
257
|
-
data: await
|
|
248
|
+
return t?.parse === "JSON" ? Object.assign(n, {
|
|
249
|
+
data: await n.json()
|
|
250
|
+
}) : t?.parse === "TEXT" ? Object.assign(n, {
|
|
251
|
+
data: await n.text()
|
|
252
|
+
}) : t?.parse === "BLOB" ? Object.assign(n, {
|
|
253
|
+
data: await n.blob()
|
|
254
|
+
}) : t?.parse === "ARRAYBUFFER" ? Object.assign(n, {
|
|
255
|
+
data: await n.arrayBuffer()
|
|
256
|
+
}) : Object.assign(n, {
|
|
257
|
+
data: await n.json()
|
|
258
258
|
});
|
|
259
|
-
} catch (
|
|
260
|
-
if (J(
|
|
261
|
-
const
|
|
262
|
-
data:
|
|
259
|
+
} catch (n) {
|
|
260
|
+
if (J(n)) throw n;
|
|
261
|
+
const r = {
|
|
262
|
+
data: n,
|
|
263
263
|
ok: !1,
|
|
264
264
|
status: 0,
|
|
265
265
|
statusText: "NETWORK_ERROR",
|
|
266
266
|
type: "error",
|
|
267
267
|
name: "NetworkError",
|
|
268
|
-
message:
|
|
268
|
+
message: n instanceof Error ? n.message : String(n),
|
|
269
269
|
headers: new Headers(),
|
|
270
270
|
url: "",
|
|
271
271
|
redirected: !1,
|
|
272
|
-
clone: () =>
|
|
272
|
+
clone: () => r,
|
|
273
273
|
bodyUsed: !1,
|
|
274
274
|
formData: () => Promise.resolve(new FormData())
|
|
275
275
|
};
|
|
276
|
-
throw
|
|
276
|
+
throw r;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
function J(e) {
|
|
280
280
|
return e !== null && typeof e == "object" && "data" in e && "body" in e;
|
|
281
281
|
}
|
|
282
282
|
function he(e, t) {
|
|
283
|
-
const
|
|
284
|
-
return e?.forEach((
|
|
285
|
-
const s = t(
|
|
286
|
-
s && (
|
|
287
|
-
}),
|
|
283
|
+
const n = {};
|
|
284
|
+
return e?.forEach((r, o) => {
|
|
285
|
+
const s = t(r, o, e)?.toString();
|
|
286
|
+
s && (n[s] ??= [], n[s].push(r));
|
|
287
|
+
}), n;
|
|
288
288
|
}
|
|
289
289
|
async function ge(e) {
|
|
290
290
|
return await new Promise((t) => setTimeout(t, e));
|
|
291
291
|
}
|
|
292
|
-
function pe(e, t,
|
|
293
|
-
return t < e ? e : t >
|
|
292
|
+
function pe(e, t, n) {
|
|
293
|
+
return t < e ? e : t > n ? n : t;
|
|
294
294
|
}
|
|
295
|
-
function me(e, t,
|
|
296
|
-
let
|
|
297
|
-
return
|
|
298
|
-
clearTimeout(
|
|
299
|
-
|
|
295
|
+
function me(e, t, n) {
|
|
296
|
+
let r;
|
|
297
|
+
return n?.isLoadingFn?.(!1), Object.assign((...s) => {
|
|
298
|
+
clearTimeout(r), n?.isLoadingFn?.(!0), r = setTimeout(() => {
|
|
299
|
+
n?.isLoadingFn?.(!1), e(...s);
|
|
300
300
|
}, t);
|
|
301
301
|
}, {
|
|
302
302
|
cancel() {
|
|
303
|
-
clearTimeout(
|
|
303
|
+
clearTimeout(r), n?.isLoadingFn?.(!1);
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function K(e, t) {
|
|
308
308
|
if (!t || typeof t != "string" || typeof e != "object" || e === null)
|
|
309
309
|
return;
|
|
310
|
-
const
|
|
311
|
-
function
|
|
310
|
+
const n = t.split(".");
|
|
311
|
+
function r(o, s) {
|
|
312
312
|
if (!s || typeof s != "object")
|
|
313
313
|
return;
|
|
314
314
|
const a = o[0];
|
|
315
315
|
if (a in s)
|
|
316
|
-
return o.length === 1 ? s[a] :
|
|
316
|
+
return o.length === 1 ? s[a] : r(o.slice(1), s[a]);
|
|
317
317
|
}
|
|
318
|
-
return n
|
|
318
|
+
return r(n, e);
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
let
|
|
320
|
+
function Z(e, t, n) {
|
|
321
|
+
let r = e;
|
|
322
322
|
for (let o = 0; o < t.length; o++) {
|
|
323
323
|
const s = t[o] ?? "";
|
|
324
|
-
o === t.length - 1 ?
|
|
324
|
+
o === t.length - 1 ? r[s] = n : ((!r[s] || typeof r[s] != "object") && (r[s] = {}), r = r[s]);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
function ye(e, t) {
|
|
328
|
-
const
|
|
328
|
+
const n = {};
|
|
329
329
|
if (!e || typeof e != "object")
|
|
330
|
-
return
|
|
331
|
-
for (const
|
|
332
|
-
const o =
|
|
330
|
+
return n;
|
|
331
|
+
for (const r of t) {
|
|
332
|
+
const o = K(e, r);
|
|
333
333
|
if (o !== void 0) {
|
|
334
|
-
const s =
|
|
335
|
-
|
|
334
|
+
const s = r.split(".");
|
|
335
|
+
Z(n, s, o);
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
return
|
|
338
|
+
return n;
|
|
339
339
|
}
|
|
340
340
|
class m {
|
|
341
341
|
#e = null;
|
|
@@ -362,7 +362,7 @@ class m {
|
|
|
362
362
|
* @returns {Promise<Result<T, E>>} A promise that resolves to a Result.
|
|
363
363
|
*/
|
|
364
364
|
static async promise(t) {
|
|
365
|
-
return t.then((
|
|
365
|
+
return t.then((n) => m.ok(n)).catch((n) => m.err(n));
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Wraps a function call in a Result.
|
|
@@ -370,12 +370,12 @@ class m {
|
|
|
370
370
|
* @param {...any[]} args - The arguments to pass to the function.
|
|
371
371
|
* @returns {Result<T, E>} A Result instance representing the function call result.
|
|
372
372
|
*/
|
|
373
|
-
static func(t, ...
|
|
373
|
+
static func(t, ...n) {
|
|
374
374
|
try {
|
|
375
|
-
const
|
|
376
|
-
return m.ok(
|
|
377
|
-
} catch (
|
|
378
|
-
return m.err(
|
|
375
|
+
const r = t(...n);
|
|
376
|
+
return m.ok(r);
|
|
377
|
+
} catch (r) {
|
|
378
|
+
return m.err(r);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
/**
|
|
@@ -383,16 +383,16 @@ class m {
|
|
|
383
383
|
* @param {E | null} err - The error value.
|
|
384
384
|
* @throws {Error} If both ok and err are provided or neither is provided.
|
|
385
385
|
*/
|
|
386
|
-
constructor(t,
|
|
387
|
-
if (t == null &&
|
|
386
|
+
constructor(t, n) {
|
|
387
|
+
if (t == null && n == null)
|
|
388
388
|
throw new Error(
|
|
389
389
|
"Result must be initialized with either an ok or an err value"
|
|
390
390
|
);
|
|
391
|
-
if (t != null &&
|
|
391
|
+
if (t != null && n != null)
|
|
392
392
|
throw new Error(
|
|
393
393
|
"Result can't be initialized with both an ok and an err value"
|
|
394
394
|
);
|
|
395
|
-
t != null ? this.#e = t : this.#t =
|
|
395
|
+
t != null ? this.#e = t : this.#t = n;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
398
|
* Gets the success value, throwing an error if the result is a failure.
|
|
@@ -430,9 +430,9 @@ class m {
|
|
|
430
430
|
if (this.isOk())
|
|
431
431
|
return this.#e;
|
|
432
432
|
if (this.isErr()) {
|
|
433
|
-
const
|
|
433
|
+
const n = this.#t;
|
|
434
434
|
throw new Error(t + `:
|
|
435
|
-
` +
|
|
435
|
+
` + n.message);
|
|
436
436
|
}
|
|
437
437
|
throw new Error(t);
|
|
438
438
|
}
|
|
@@ -469,80 +469,80 @@ const z = /* @__PURE__ */ Symbol("SIGNAL"), we = (e) => typeof e == "function" &
|
|
|
469
469
|
g.push(...t);
|
|
470
470
|
}
|
|
471
471
|
}, R = (e, t) => {
|
|
472
|
-
const
|
|
473
|
-
let
|
|
472
|
+
const n = /* @__PURE__ */ new Set();
|
|
473
|
+
let r = 0;
|
|
474
474
|
const o = () => {
|
|
475
475
|
const l = g[g.length - 1];
|
|
476
|
-
l && (
|
|
477
|
-
|
|
476
|
+
l && (n.add(l.setDirty), l.addSource(() => {
|
|
477
|
+
n.delete(l.setDirty);
|
|
478
478
|
}));
|
|
479
479
|
}, s = (l) => {
|
|
480
|
-
for (const h of Array.from(
|
|
481
|
-
}, a = () =>
|
|
480
|
+
for (const h of Array.from(n)) h(l);
|
|
481
|
+
}, a = () => r > 0;
|
|
482
482
|
return { read: Object.assign(() => (o(), e()), {
|
|
483
483
|
[z]: !0,
|
|
484
|
-
subscribe: (l) => (
|
|
485
|
-
|
|
484
|
+
subscribe: (l) => (n.add(l), r++, t?.(), () => {
|
|
485
|
+
n.delete(l), r--;
|
|
486
486
|
})
|
|
487
487
|
}), notify: s, hasSubscribers: a };
|
|
488
488
|
}, S = (e) => {
|
|
489
489
|
let t = e;
|
|
490
|
-
const { read:
|
|
491
|
-
return Object.assign(
|
|
490
|
+
const { read: n, notify: r } = R(() => t);
|
|
491
|
+
return Object.assign(n, {
|
|
492
492
|
set: (o) => {
|
|
493
|
-
t !== o && (t = o,
|
|
493
|
+
t !== o && (t = o, r(o));
|
|
494
494
|
},
|
|
495
495
|
update: (o) => {
|
|
496
496
|
const s = o(t);
|
|
497
|
-
t !== s && (t = s,
|
|
497
|
+
t !== s && (t = s, r(s));
|
|
498
498
|
},
|
|
499
|
-
asReadonly: () =>
|
|
499
|
+
asReadonly: () => n
|
|
500
500
|
});
|
|
501
501
|
}, k = (e) => {
|
|
502
502
|
const t = /* @__PURE__ */ new Set();
|
|
503
|
-
let
|
|
503
|
+
let n = !1, r = null, o = !1;
|
|
504
504
|
const s = () => {
|
|
505
|
-
if (o = !1,
|
|
506
|
-
|
|
505
|
+
if (o = !1, n) return;
|
|
506
|
+
r && (r(), r = null), t.forEach((i) => i()), t.clear();
|
|
507
507
|
const a = (i) => {
|
|
508
|
-
|
|
508
|
+
r = i;
|
|
509
509
|
};
|
|
510
510
|
g.push({
|
|
511
511
|
setDirty: () => {
|
|
512
|
-
!
|
|
512
|
+
!n && !o && (o = !0, queueMicrotask(s));
|
|
513
513
|
},
|
|
514
514
|
addSource: (i) => t.add(i)
|
|
515
515
|
}), e(a), g.pop();
|
|
516
516
|
};
|
|
517
517
|
return s(), {
|
|
518
518
|
destroy() {
|
|
519
|
-
|
|
519
|
+
n = !0, r && (r(), r = null), t.forEach((a) => a()), t.clear();
|
|
520
520
|
}
|
|
521
521
|
};
|
|
522
522
|
}, j = (e) => {
|
|
523
523
|
const t = /* @__PURE__ */ new Set();
|
|
524
|
-
let
|
|
524
|
+
let n, r = !0, o = () => {
|
|
525
525
|
};
|
|
526
526
|
const s = () => {
|
|
527
527
|
t.forEach((c) => c()), t.clear(), g.push({
|
|
528
528
|
setDirty: () => {
|
|
529
|
-
if (
|
|
530
|
-
|
|
531
|
-
const c =
|
|
532
|
-
s(),
|
|
529
|
+
if (r) return;
|
|
530
|
+
r = !0;
|
|
531
|
+
const c = n;
|
|
532
|
+
s(), n !== c && o(n);
|
|
533
533
|
},
|
|
534
534
|
addSource: (c) => t.add(c)
|
|
535
|
-
}),
|
|
535
|
+
}), n = e(), r = !1, g.pop();
|
|
536
536
|
}, { read: a, notify: i } = R(
|
|
537
|
-
() => (
|
|
537
|
+
() => (r && s(), n),
|
|
538
538
|
() => {
|
|
539
|
-
|
|
539
|
+
r && s();
|
|
540
540
|
}
|
|
541
541
|
);
|
|
542
542
|
return o = i, a;
|
|
543
543
|
};
|
|
544
544
|
function Te(e) {
|
|
545
|
-
const t = typeof e == "function",
|
|
545
|
+
const t = typeof e == "function", n = t ? void 0 : e.source, r = t ? e : e.computation, o = /* @__PURE__ */ new Set();
|
|
546
546
|
let s, a = !0, i = !1, c, l = () => {
|
|
547
547
|
};
|
|
548
548
|
const h = () => {
|
|
@@ -555,10 +555,10 @@ function Te(e) {
|
|
|
555
555
|
},
|
|
556
556
|
addSource: (u) => o.add(u)
|
|
557
557
|
}), t)
|
|
558
|
-
s =
|
|
558
|
+
s = r();
|
|
559
559
|
else {
|
|
560
|
-
const u =
|
|
561
|
-
s =
|
|
560
|
+
const u = n?.();
|
|
561
|
+
s = r(u, c), c = { source: u, value: s };
|
|
562
562
|
}
|
|
563
563
|
a = !1, g.pop();
|
|
564
564
|
}, { read: v, notify: f } = R(
|
|
@@ -581,20 +581,20 @@ function Te(e) {
|
|
|
581
581
|
}
|
|
582
582
|
class X extends Error {
|
|
583
583
|
constructor(t) {
|
|
584
|
-
const
|
|
584
|
+
const n = t instanceof Error ? `:
|
|
585
585
|
${t.message}` : "";
|
|
586
|
-
super(`Cannot read resource value while in error state${
|
|
586
|
+
super(`Cannot read resource value while in error state${n}`, { cause: t }), this.name = "ResourceErrorState";
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
function $e(e) {
|
|
590
|
-
const t = S(void 0),
|
|
591
|
-
if (
|
|
592
|
-
throw new X(
|
|
590
|
+
const t = S(void 0), n = S("idle"), r = S(void 0), o = j(() => n() === "loading"), s = S(0), a = j(() => {
|
|
591
|
+
if (n() === "error")
|
|
592
|
+
throw new X(r());
|
|
593
593
|
return t();
|
|
594
594
|
}), i = (f) => {
|
|
595
|
-
t.set(f),
|
|
595
|
+
t.set(f), r.set(void 0), n.set("resolved");
|
|
596
596
|
}, c = (f) => {
|
|
597
|
-
t.update(f),
|
|
597
|
+
t.update(f), r.set(void 0), n.set("resolved");
|
|
598
598
|
}, l = "params" in e;
|
|
599
599
|
if ("stream" in e) {
|
|
600
600
|
const f = S(void 0), y = k((p) => {
|
|
@@ -602,7 +602,7 @@ function $e(e) {
|
|
|
602
602
|
const d = new AbortController();
|
|
603
603
|
p(() => d.abort());
|
|
604
604
|
const H = l ? e.params() : void 0;
|
|
605
|
-
|
|
605
|
+
n.set("loading"), r.set(void 0);
|
|
606
606
|
const P = e.stream, G = P(l ? {
|
|
607
607
|
params: H,
|
|
608
608
|
abortSignal: d.signal
|
|
@@ -614,12 +614,12 @@ function $e(e) {
|
|
|
614
614
|
const p = f();
|
|
615
615
|
if (!p) return;
|
|
616
616
|
const d = p();
|
|
617
|
-
d && ("error" in d && d.error !== void 0 ? (
|
|
617
|
+
d && ("error" in d && d.error !== void 0 ? (r.set(d.error), n.set("error")) : "value" in d && (t.set(d.value), n.set("resolved")));
|
|
618
618
|
});
|
|
619
619
|
return {
|
|
620
620
|
value: a,
|
|
621
|
-
status:
|
|
622
|
-
error:
|
|
621
|
+
status: n,
|
|
622
|
+
error: r,
|
|
623
623
|
isLoading: o,
|
|
624
624
|
set: i,
|
|
625
625
|
update: c,
|
|
@@ -634,23 +634,23 @@ function $e(e) {
|
|
|
634
634
|
const v = k((f) => {
|
|
635
635
|
s();
|
|
636
636
|
const y = l ? e.params() : void 0;
|
|
637
|
-
|
|
637
|
+
n.set("loading"), r.set(void 0);
|
|
638
638
|
const u = new AbortController();
|
|
639
639
|
f(() => u.abort());
|
|
640
640
|
const p = l ? { params: y, abortSignal: u.signal } : { abortSignal: u.signal };
|
|
641
641
|
e.loader(p).then(
|
|
642
642
|
(d) => {
|
|
643
|
-
u.signal.aborted || (t.set(d),
|
|
643
|
+
u.signal.aborted || (t.set(d), n.set("resolved"));
|
|
644
644
|
},
|
|
645
645
|
(d) => {
|
|
646
|
-
u.signal.aborted || (
|
|
646
|
+
u.signal.aborted || (r.set(d), n.set("error"));
|
|
647
647
|
}
|
|
648
648
|
);
|
|
649
649
|
});
|
|
650
650
|
return {
|
|
651
651
|
value: a,
|
|
652
|
-
status:
|
|
653
|
-
error:
|
|
652
|
+
status: n,
|
|
653
|
+
error: r,
|
|
654
654
|
isLoading: o,
|
|
655
655
|
set: i,
|
|
656
656
|
update: c,
|
|
@@ -710,23 +710,23 @@ const $ = /* @__PURE__ */ new Map([
|
|
|
710
710
|
]);
|
|
711
711
|
function W(e) {
|
|
712
712
|
const t = [];
|
|
713
|
-
let
|
|
714
|
-
for (const
|
|
715
|
-
const o =
|
|
716
|
-
o !== s && (
|
|
717
|
-
containerTagNames:
|
|
718
|
-
cssClass:
|
|
713
|
+
let n;
|
|
714
|
+
for (const r of e) {
|
|
715
|
+
const o = r.containerTagNames.join(","), s = n?.containerTagNames.join(",");
|
|
716
|
+
o !== s && (n = {
|
|
717
|
+
containerTagNames: r.containerTagNames,
|
|
718
|
+
cssClass: r.containerTagNames.map((a) => `${C()}${a}`).join(" "),
|
|
719
719
|
segments: []
|
|
720
|
-
}, t.push(
|
|
720
|
+
}, t.push(n)), n.segments.push(r);
|
|
721
721
|
}
|
|
722
722
|
return t;
|
|
723
723
|
}
|
|
724
|
-
const N = (e, t,
|
|
724
|
+
const N = (e, t, n, r, o) => {
|
|
725
725
|
const s = e.filter((i) => !T.has(i)), a = e.filter((i) => T.has(i));
|
|
726
726
|
return {
|
|
727
727
|
tagNames: e.join(","),
|
|
728
728
|
tagNamesList: e,
|
|
729
|
-
text: o ?? t.slice(
|
|
729
|
+
text: o ?? t.slice(n, r),
|
|
730
730
|
containerTagNames: a,
|
|
731
731
|
cssClass: s.map((i) => `${C()}${i}`).join(" ")
|
|
732
732
|
};
|
|
@@ -735,39 +735,39 @@ const N = (e, t, r, n, o) => {
|
|
|
735
735
|
"gi"
|
|
736
736
|
);
|
|
737
737
|
function D(e) {
|
|
738
|
-
const t = [],
|
|
739
|
-
let
|
|
738
|
+
const t = [], n = /* @__PURE__ */ new Map();
|
|
739
|
+
let r = 0;
|
|
740
740
|
for (const o of e.matchAll(te())) {
|
|
741
741
|
const s = o.index;
|
|
742
|
-
s >
|
|
743
|
-
N([...
|
|
742
|
+
s > r && t.push(
|
|
743
|
+
N([...n.keys()], e, r, s)
|
|
744
744
|
);
|
|
745
745
|
const a = o[2]?.toLowerCase();
|
|
746
746
|
if (a && $.has(a)) {
|
|
747
747
|
t.push(
|
|
748
748
|
N(
|
|
749
|
-
[...
|
|
749
|
+
[...n.keys(), a],
|
|
750
750
|
e,
|
|
751
|
-
|
|
751
|
+
r,
|
|
752
752
|
s,
|
|
753
753
|
""
|
|
754
754
|
)
|
|
755
|
-
),
|
|
755
|
+
), r = s + o[0].length;
|
|
756
756
|
continue;
|
|
757
757
|
}
|
|
758
758
|
const i = o[0][1] === "/", c = L.get(o[1]?.toLowerCase() ?? "") ?? "";
|
|
759
759
|
if (i) {
|
|
760
|
-
const l = (
|
|
761
|
-
l <= 0 ?
|
|
760
|
+
const l = (n.get(c) ?? 1) - 1;
|
|
761
|
+
l <= 0 ? n.delete(c) : n.set(c, l);
|
|
762
762
|
} else
|
|
763
|
-
|
|
764
|
-
|
|
763
|
+
n.set(c, (n.get(c) ?? 0) + 1);
|
|
764
|
+
r = s + o[0].length;
|
|
765
765
|
}
|
|
766
|
-
return
|
|
766
|
+
return r < e.length && t.push(
|
|
767
767
|
N(
|
|
768
|
-
[...
|
|
768
|
+
[...n.keys()],
|
|
769
769
|
e,
|
|
770
|
-
|
|
770
|
+
r,
|
|
771
771
|
e.length
|
|
772
772
|
)
|
|
773
773
|
), t;
|
|
@@ -778,38 +778,38 @@ function F(e) {
|
|
|
778
778
|
function A(e, t) {
|
|
779
779
|
e.className = `${C()}${t}`;
|
|
780
780
|
}
|
|
781
|
-
function
|
|
782
|
-
const
|
|
781
|
+
function ne(e, t, n) {
|
|
782
|
+
const r = t.tagNamesList.filter((i) => !T.has(i)), o = r.filter((i) => $.has(i)), s = r.filter((i) => !$.has(i));
|
|
783
783
|
let a = e;
|
|
784
784
|
for (const i of s) {
|
|
785
|
-
const c =
|
|
785
|
+
const c = n.createElement(i);
|
|
786
786
|
A(c, i), a.appendChild(c), a = c;
|
|
787
787
|
}
|
|
788
788
|
if (t.text) {
|
|
789
|
-
a.appendChild(
|
|
789
|
+
a.appendChild(n.createTextNode(t.text));
|
|
790
790
|
return;
|
|
791
791
|
}
|
|
792
792
|
for (const i of o) {
|
|
793
|
-
const c =
|
|
793
|
+
const c = n.createElement(i);
|
|
794
794
|
A(c, i), a.appendChild(c);
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
|
-
function
|
|
798
|
-
const
|
|
797
|
+
function re(e, t, n) {
|
|
798
|
+
const r = [];
|
|
799
799
|
for (const o of t) {
|
|
800
800
|
const s = o.containerTagNames;
|
|
801
801
|
let a = 0;
|
|
802
|
-
for (; a <
|
|
802
|
+
for (; a < r.length && a < s.length && r[a]?.tag === s[a]; )
|
|
803
803
|
a++;
|
|
804
|
-
|
|
805
|
-
let i =
|
|
804
|
+
r.length = a;
|
|
805
|
+
let i = r[r.length - 1]?.node ?? e;
|
|
806
806
|
for (const l of s.slice(a)) {
|
|
807
|
-
const h =
|
|
808
|
-
A(h, l), i.appendChild(h),
|
|
807
|
+
const h = n.createElement(l);
|
|
808
|
+
A(h, l), i.appendChild(h), r.push({ tag: l, node: h }), i = h;
|
|
809
809
|
}
|
|
810
|
-
const c =
|
|
810
|
+
const c = r[r.length - 1]?.node ?? e;
|
|
811
811
|
for (const l of o.segments)
|
|
812
|
-
|
|
812
|
+
ne(c, l, n);
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
function se(e, t) {
|
|
@@ -823,8 +823,8 @@ function se(e, t) {
|
|
|
823
823
|
);
|
|
824
824
|
return;
|
|
825
825
|
}
|
|
826
|
-
const
|
|
827
|
-
|
|
826
|
+
const n = globalThis.document, r = F(D(t));
|
|
827
|
+
re(e, r, n);
|
|
828
828
|
}
|
|
829
829
|
const O = "html-text-parser-styles", I = {};
|
|
830
830
|
function M(e) {
|
|
@@ -975,28 +975,28 @@ function B() {
|
|
|
975
975
|
);
|
|
976
976
|
return;
|
|
977
977
|
}
|
|
978
|
-
const e = globalThis, t = e.document.getElementById(O),
|
|
978
|
+
const e = globalThis, t = e.document.getElementById(O), n = M(C());
|
|
979
979
|
if (t) {
|
|
980
|
-
t.textContent =
|
|
980
|
+
t.textContent = n;
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
-
const
|
|
984
|
-
|
|
983
|
+
const r = e.document.createElement("style");
|
|
984
|
+
r.setAttribute("id", O), r.textContent = n, e.document.head.appendChild(r);
|
|
985
985
|
}
|
|
986
986
|
function ae(e) {
|
|
987
987
|
Object.assign(
|
|
988
988
|
I,
|
|
989
989
|
Object.fromEntries(
|
|
990
|
-
Object.entries(e).map(([t,
|
|
990
|
+
Object.entries(e).map(([t, n]) => [
|
|
991
991
|
t,
|
|
992
|
-
|
|
992
|
+
n.replace(/;/g, " !important;")
|
|
993
993
|
])
|
|
994
994
|
)
|
|
995
995
|
), "document" in globalThis && B();
|
|
996
996
|
}
|
|
997
997
|
function _(e) {
|
|
998
998
|
if (Array.isArray(e)) {
|
|
999
|
-
e.forEach((
|
|
999
|
+
e.forEach((n) => _(n));
|
|
1000
1000
|
return;
|
|
1001
1001
|
}
|
|
1002
1002
|
const t = e.tagName ?? e.tag;
|
|
@@ -1004,7 +1004,7 @@ function _(e) {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
function q(e) {
|
|
1006
1006
|
if (Array.isArray(e)) {
|
|
1007
|
-
e.forEach((
|
|
1007
|
+
e.forEach((n) => q(n));
|
|
1008
1008
|
return;
|
|
1009
1009
|
}
|
|
1010
1010
|
const t = e.tagName ?? e.tag;
|
|
@@ -1029,21 +1029,21 @@ const Ce = {
|
|
|
1029
1029
|
generateStylesheet: B,
|
|
1030
1030
|
overrideStyles: ae
|
|
1031
1031
|
};
|
|
1032
|
-
function le(e, t,
|
|
1033
|
-
function
|
|
1034
|
-
const [s, a] = E(() =>
|
|
1032
|
+
function le(e, t, n) {
|
|
1033
|
+
function r(o) {
|
|
1034
|
+
const [s, a] = E(() => n ? n(o) : o);
|
|
1035
1035
|
if (a) throw new Error(`Error transforming value for ${e}: ${a.message}`);
|
|
1036
1036
|
if (!t(s)) throw new Error(`"${o}" is not a valid ${e}`);
|
|
1037
1037
|
return s;
|
|
1038
1038
|
}
|
|
1039
|
-
return
|
|
1040
|
-
const [s, a] = E(() =>
|
|
1039
|
+
return r.from = (o) => {
|
|
1040
|
+
const [s, a] = E(() => n ? n(o) : o);
|
|
1041
1041
|
if (!a)
|
|
1042
1042
|
return t(s) ? s : void 0;
|
|
1043
|
-
},
|
|
1044
|
-
const s = E(() =>
|
|
1043
|
+
}, r.is = (o) => {
|
|
1044
|
+
const s = E(() => n ? n(o) : o)[0] ?? o;
|
|
1045
1045
|
return t(s);
|
|
1046
|
-
},
|
|
1046
|
+
}, r;
|
|
1047
1047
|
}
|
|
1048
1048
|
const ve = le(
|
|
1049
1049
|
"NumericString",
|
|
@@ -1054,6 +1054,20 @@ const ve = le(
|
|
|
1054
1054
|
),
|
|
1055
1055
|
(e) => String(e)
|
|
1056
1056
|
);
|
|
1057
|
+
function Ee(e) {
|
|
1058
|
+
return Object.keys(e).filter((t) => {
|
|
1059
|
+
const n = e[t];
|
|
1060
|
+
return n === "" || n === null || n === void 0;
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
function ke(e) {
|
|
1064
|
+
if (e.length === 0) return "";
|
|
1065
|
+
if (e.length === 1) {
|
|
1066
|
+
const [t] = e;
|
|
1067
|
+
return t || "";
|
|
1068
|
+
}
|
|
1069
|
+
return e.slice(0, -1).join(", ") + " and " + e[e.length - 1];
|
|
1070
|
+
}
|
|
1057
1071
|
export {
|
|
1058
1072
|
fe as Http,
|
|
1059
1073
|
U as HttpCodeNames,
|
|
@@ -1067,15 +1081,17 @@ export {
|
|
|
1067
1081
|
me as debounce,
|
|
1068
1082
|
ge as delay,
|
|
1069
1083
|
k as effect,
|
|
1070
|
-
|
|
1084
|
+
Ee as getEmptyKeys,
|
|
1085
|
+
K as getProp,
|
|
1071
1086
|
he as groupBy,
|
|
1072
1087
|
Ce as htmlTextParser,
|
|
1073
1088
|
we as isSignal,
|
|
1089
|
+
ke as joinToSentence,
|
|
1074
1090
|
Te as linkedSignal,
|
|
1075
1091
|
V as normalizeString,
|
|
1076
1092
|
ye as pickPaths,
|
|
1077
1093
|
$e as resource,
|
|
1078
|
-
|
|
1094
|
+
Z as setDeepValue,
|
|
1079
1095
|
S as signal,
|
|
1080
1096
|
be as toArray,
|
|
1081
1097
|
E as tryCatch,
|