@dvirus-js/utils 0.0.4 → 0.0.7
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 +24 -0
- package/index.js +433 -365
- package/lib/getProp.d.ts +10 -0
- package/lib/http.d.ts +11 -0
- package/lib/tryCatch.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 0.0.6 (2026-05-20)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- update utils index exports ([7919620](https://github.com/Dvirus97/dvirus-js/commit/7919620))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Dvir Cohen
|
|
10
|
+
|
|
11
|
+
## 0.0.5 (2026-05-20)
|
|
12
|
+
|
|
13
|
+
This was a version bump only for utils to align it with other projects, there were no code changes.
|
|
14
|
+
|
|
15
|
+
## 0.0.4 (2026-05-19)
|
|
16
|
+
|
|
17
|
+
### 🩹 Fixes
|
|
18
|
+
|
|
19
|
+
- minor formatting updates ([3dbc3e6](https://github.com/Dvirus97/dvirus-js/commit/3dbc3e6))
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- Dvir Cohen
|
|
24
|
+
|
|
1
25
|
## 0.0.3 (2026-05-19)
|
|
2
26
|
|
|
3
27
|
### 🩹 Fixes
|
package/index.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function I(e) {
|
|
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
|
-
function
|
|
5
|
-
const
|
|
6
|
-
switch (
|
|
4
|
+
function re(e, n) {
|
|
5
|
+
const t = I(e);
|
|
6
|
+
switch (n) {
|
|
7
7
|
case "lowercase":
|
|
8
|
-
return
|
|
8
|
+
return t.toLowerCase();
|
|
9
9
|
case "UPPERCASE":
|
|
10
|
-
return
|
|
10
|
+
return t.toUpperCase();
|
|
11
11
|
case "Title Case":
|
|
12
|
-
return
|
|
13
|
-
(
|
|
12
|
+
return t.split(" ").map(
|
|
13
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
14
14
|
).join(" ");
|
|
15
15
|
case "kebab-case":
|
|
16
|
-
return
|
|
16
|
+
return t.replace(/\s+/g, "-");
|
|
17
17
|
case "snake_case":
|
|
18
|
-
return
|
|
18
|
+
return t.replace(/\s+/g, "_");
|
|
19
19
|
case "camelCase": {
|
|
20
|
-
const
|
|
21
|
-
return
|
|
20
|
+
const r = t.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 t.split(" ").map(
|
|
27
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
28
28
|
).join("");
|
|
29
29
|
case "dot.case":
|
|
30
|
-
return
|
|
30
|
+
return t.replace(/\s+/g, ".");
|
|
31
31
|
case "path/case":
|
|
32
|
-
return
|
|
32
|
+
return t.replace(/\s+/g, "/");
|
|
33
33
|
case "Sentence case":
|
|
34
|
-
return
|
|
34
|
+
return t.replace(/(^\s*\w|[.!?]\s*\w)/g, (r) => r.toUpperCase()).replace(/\bi\b/g, "I");
|
|
35
35
|
case "Header-Case":
|
|
36
|
-
return
|
|
37
|
-
(
|
|
36
|
+
return t.split(" ").map(
|
|
37
|
+
(r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()
|
|
38
38
|
).join("-");
|
|
39
39
|
case "reverse":
|
|
40
|
-
return
|
|
40
|
+
return t.split("").reverse().join("");
|
|
41
41
|
default:
|
|
42
|
-
throw new Error(`Unsupported case type: ${
|
|
42
|
+
throw new Error(`Unsupported case type: ${n}`);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
async function
|
|
45
|
+
async function se(e) {
|
|
46
46
|
try {
|
|
47
|
-
return [await
|
|
48
|
-
} catch (
|
|
49
|
-
return [null,
|
|
47
|
+
return [await (typeof e == "function" ? e() : e), null];
|
|
48
|
+
} catch (n) {
|
|
49
|
+
return [null, n];
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function E(
|
|
52
|
+
function E(e) {
|
|
53
53
|
try {
|
|
54
|
-
return [
|
|
55
|
-
} catch (
|
|
56
|
-
return [null,
|
|
54
|
+
return [e(), null];
|
|
55
|
+
} catch (n) {
|
|
56
|
+
return [null, n];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const oe = {
|
|
60
60
|
/**
|
|
61
61
|
* Makes a GET request to the specified URL.
|
|
62
62
|
*
|
|
@@ -65,9 +65,8 @@ const ee = {
|
|
|
65
65
|
* @returns {Promise<any>} The response data.
|
|
66
66
|
* @throws {Error} If the response is not ok.
|
|
67
67
|
*/
|
|
68
|
-
get: async function(
|
|
69
|
-
|
|
70
|
-
return await C(e);
|
|
68
|
+
get: async function(e, n) {
|
|
69
|
+
return await C(() => fetch(e, n), n);
|
|
71
70
|
},
|
|
72
71
|
/**
|
|
73
72
|
* Makes a POST request to the specified URL with the given data.
|
|
@@ -79,17 +78,19 @@ const ee = {
|
|
|
79
78
|
* @returns {Promise<R>} The response data.
|
|
80
79
|
* @throws {Error} If the response is not ok.
|
|
81
80
|
*/
|
|
82
|
-
post: async function(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
post: async function(e, n, t) {
|
|
82
|
+
return await C(
|
|
83
|
+
() => fetch(e, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
...t?.headers
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify(n),
|
|
90
|
+
...t
|
|
91
|
+
}),
|
|
92
|
+
t
|
|
93
|
+
);
|
|
93
94
|
},
|
|
94
95
|
/**
|
|
95
96
|
* Makes a DELETE request to the specified URL with the given ID.
|
|
@@ -101,17 +102,19 @@ const ee = {
|
|
|
101
102
|
* @returns {Promise<R>} The response data.
|
|
102
103
|
* @throws {Error} If the response is not ok.
|
|
103
104
|
*/
|
|
104
|
-
delete: async function(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
delete: async function(e, n, t) {
|
|
106
|
+
return await C(
|
|
107
|
+
() => fetch(e, {
|
|
108
|
+
method: "DELETE",
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
...t?.headers
|
|
112
|
+
},
|
|
113
|
+
body: JSON.stringify({ id: n }),
|
|
114
|
+
...t
|
|
115
|
+
}),
|
|
116
|
+
t
|
|
117
|
+
);
|
|
115
118
|
},
|
|
116
119
|
/**
|
|
117
120
|
* Makes a PATCH request to the specified URL with the given data.
|
|
@@ -123,17 +126,19 @@ const ee = {
|
|
|
123
126
|
* @returns {Promise<R>} The response data.
|
|
124
127
|
* @throws {Error} If the response is not ok.
|
|
125
128
|
*/
|
|
126
|
-
patch: async function(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
patch: async function(e, n, t) {
|
|
130
|
+
return await C(
|
|
131
|
+
() => fetch(e, {
|
|
132
|
+
method: "PATCH",
|
|
133
|
+
headers: {
|
|
134
|
+
"Content-Type": "application/json",
|
|
135
|
+
...t?.headers
|
|
136
|
+
},
|
|
137
|
+
body: JSON.stringify(n),
|
|
138
|
+
...t
|
|
139
|
+
}),
|
|
140
|
+
t
|
|
141
|
+
);
|
|
137
142
|
},
|
|
138
143
|
/**
|
|
139
144
|
* Makes a PUT request to the specified URL with the given data.
|
|
@@ -145,62 +150,123 @@ const ee = {
|
|
|
145
150
|
* @returns {Promise<R>} The response data.
|
|
146
151
|
* @throws {Error} If the response is not ok.
|
|
147
152
|
*/
|
|
148
|
-
put: async function(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
put: async function(e, n, t) {
|
|
154
|
+
return await C(
|
|
155
|
+
() => fetch(e, {
|
|
156
|
+
method: "PUT",
|
|
157
|
+
headers: {
|
|
158
|
+
"Content-Type": "application/json",
|
|
159
|
+
...t?.headers
|
|
160
|
+
},
|
|
161
|
+
body: JSON.stringify(n),
|
|
162
|
+
...t
|
|
163
|
+
}),
|
|
164
|
+
t
|
|
165
|
+
);
|
|
159
166
|
}
|
|
160
167
|
};
|
|
161
|
-
async function C(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
async function C(e, n) {
|
|
169
|
+
try {
|
|
170
|
+
const t = await e();
|
|
171
|
+
if (!t.ok) {
|
|
172
|
+
const r = await t.text().catch(() => "");
|
|
173
|
+
throw Object.assign(
|
|
174
|
+
new Error(`HTTP ${t.status} ${t.statusText}`),
|
|
175
|
+
{
|
|
176
|
+
status: t.status,
|
|
177
|
+
statusText: t.statusText,
|
|
178
|
+
body: r
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return n?.parse === "JSON" ? await t.json() : n?.parse === "TEXT" ? await t.text() : n?.parse === "BLOB" ? await t.blob() : n?.parse === "ARRAYBUFFER" ? await t.arrayBuffer() : await t.json();
|
|
183
|
+
} catch (t) {
|
|
184
|
+
throw H(t) ? t : Object.assign(
|
|
185
|
+
new Error(
|
|
186
|
+
t instanceof Error ? t.message : "Network request failed"
|
|
187
|
+
),
|
|
188
|
+
{
|
|
189
|
+
status: G(t),
|
|
190
|
+
statusText: "NETWORK_ERROR",
|
|
191
|
+
code: V(t),
|
|
192
|
+
isNetworkError: !0,
|
|
193
|
+
cause: t
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function G(e) {
|
|
199
|
+
if (typeof e == "object" && e !== null && "status" in e && typeof e.status == "number")
|
|
200
|
+
return e.status;
|
|
201
|
+
}
|
|
202
|
+
function V(e) {
|
|
203
|
+
if (typeof e == "object" && e !== null && "code" in e && typeof e.code == "string")
|
|
204
|
+
return e.code;
|
|
205
|
+
if (typeof e == "object" && e !== null && "cause" in e && typeof e.cause == "object" && e.cause !== null && "code" in e.cause && typeof e.cause.code == "string")
|
|
206
|
+
return e.cause.code;
|
|
207
|
+
}
|
|
208
|
+
function H(e) {
|
|
209
|
+
return typeof e == "object" && e !== null && "status" in e && typeof e.status == "number";
|
|
210
|
+
}
|
|
211
|
+
function ae(e, n) {
|
|
212
|
+
const t = {};
|
|
213
|
+
return e?.forEach((r, o) => {
|
|
214
|
+
const s = n(r, o, e)?.toString();
|
|
215
|
+
s && (t[s] ??= [], t[s].push(r));
|
|
216
|
+
}), t;
|
|
217
|
+
}
|
|
218
|
+
async function ie(e) {
|
|
219
|
+
return await new Promise((n) => setTimeout(n, e));
|
|
220
|
+
}
|
|
221
|
+
function ce(e, n, t) {
|
|
222
|
+
return n < e ? e : n > t ? t : n;
|
|
223
|
+
}
|
|
224
|
+
function le(e, n, t) {
|
|
225
|
+
let r;
|
|
226
|
+
return t?.isLoadingFn?.(!1), Object.assign((...s) => {
|
|
227
|
+
clearTimeout(r), t?.isLoadingFn?.(!0), r = setTimeout(() => {
|
|
228
|
+
t?.isLoadingFn?.(!1), e(...s);
|
|
229
|
+
}, n);
|
|
184
230
|
}, {
|
|
185
231
|
cancel() {
|
|
186
|
-
clearTimeout(
|
|
232
|
+
clearTimeout(r), t?.isLoadingFn?.(!1);
|
|
187
233
|
}
|
|
188
234
|
});
|
|
189
235
|
}
|
|
190
|
-
function
|
|
191
|
-
if (!
|
|
236
|
+
function J(e, n) {
|
|
237
|
+
if (!n || typeof n != "string" || typeof e != "object" || e === null)
|
|
192
238
|
return;
|
|
193
|
-
const
|
|
194
|
-
function
|
|
239
|
+
const t = n.split(".");
|
|
240
|
+
function r(o, s) {
|
|
195
241
|
if (!s || typeof s != "object")
|
|
196
242
|
return;
|
|
197
243
|
const a = o[0];
|
|
198
244
|
if (a in s)
|
|
199
|
-
return o.length === 1 ? s[a] :
|
|
245
|
+
return o.length === 1 ? s[a] : r(o.slice(1), s[a]);
|
|
200
246
|
}
|
|
201
|
-
return
|
|
247
|
+
return r(t, e);
|
|
202
248
|
}
|
|
203
|
-
|
|
249
|
+
function Z(e, n, t) {
|
|
250
|
+
let r = e;
|
|
251
|
+
for (let o = 0; o < n.length; o++) {
|
|
252
|
+
const s = n[o] ?? "";
|
|
253
|
+
o === n.length - 1 ? r[s] = t : ((!r[s] || typeof r[s] != "object") && (r[s] = {}), r = r[s]);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function ue(e, n) {
|
|
257
|
+
const t = {};
|
|
258
|
+
if (!e || typeof e != "object")
|
|
259
|
+
return t;
|
|
260
|
+
for (const r of n) {
|
|
261
|
+
const o = J(e, r);
|
|
262
|
+
if (o !== void 0) {
|
|
263
|
+
const s = r.split(".");
|
|
264
|
+
Z(t, s, o);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return t;
|
|
268
|
+
}
|
|
269
|
+
class y {
|
|
204
270
|
#e = null;
|
|
205
271
|
#t = null;
|
|
206
272
|
/**
|
|
@@ -208,24 +274,24 @@ class m {
|
|
|
208
274
|
* @param {T} val - The success value.
|
|
209
275
|
* @returns {Result<T, never>} A Result instance representing a success.
|
|
210
276
|
*/
|
|
211
|
-
static ok(
|
|
212
|
-
return new
|
|
277
|
+
static ok(n) {
|
|
278
|
+
return new y(n, null);
|
|
213
279
|
}
|
|
214
280
|
/**
|
|
215
281
|
* Creates a failed result.
|
|
216
282
|
* @param {E | string} err - The error value or message.
|
|
217
283
|
* @returns {Result<never, E>} A Result instance representing a failure.
|
|
218
284
|
*/
|
|
219
|
-
static err(
|
|
220
|
-
return typeof
|
|
285
|
+
static err(n) {
|
|
286
|
+
return typeof n == "string" ? new y(null, new Error(n)) : new y(null, n);
|
|
221
287
|
}
|
|
222
288
|
/**
|
|
223
289
|
* Wraps a promise in a Result.
|
|
224
290
|
* @param {Promise<T>} promise - The promise to wrap.
|
|
225
291
|
* @returns {Promise<Result<T, E>>} A promise that resolves to a Result.
|
|
226
292
|
*/
|
|
227
|
-
static async promise(
|
|
228
|
-
return
|
|
293
|
+
static async promise(n) {
|
|
294
|
+
return n.then((t) => y.ok(t)).catch((t) => y.err(t));
|
|
229
295
|
}
|
|
230
296
|
/**
|
|
231
297
|
* Wraps a function call in a Result.
|
|
@@ -233,12 +299,12 @@ class m {
|
|
|
233
299
|
* @param {...any[]} args - The arguments to pass to the function.
|
|
234
300
|
* @returns {Result<T, E>} A Result instance representing the function call result.
|
|
235
301
|
*/
|
|
236
|
-
static func(
|
|
302
|
+
static func(n, ...t) {
|
|
237
303
|
try {
|
|
238
|
-
const
|
|
239
|
-
return
|
|
240
|
-
} catch (
|
|
241
|
-
return
|
|
304
|
+
const r = n(...t);
|
|
305
|
+
return y.ok(r);
|
|
306
|
+
} catch (r) {
|
|
307
|
+
return y.err(r);
|
|
242
308
|
}
|
|
243
309
|
}
|
|
244
310
|
/**
|
|
@@ -246,16 +312,16 @@ class m {
|
|
|
246
312
|
* @param {E | null} err - The error value.
|
|
247
313
|
* @throws {Error} If both ok and err are provided or neither is provided.
|
|
248
314
|
*/
|
|
249
|
-
constructor(
|
|
250
|
-
if (
|
|
315
|
+
constructor(n, t) {
|
|
316
|
+
if (n == null && t == null)
|
|
251
317
|
throw new Error(
|
|
252
318
|
"Result must be initialized with either an ok or an err value"
|
|
253
319
|
);
|
|
254
|
-
if (
|
|
320
|
+
if (n != null && t != null)
|
|
255
321
|
throw new Error(
|
|
256
322
|
"Result can't be initialized with both an ok and an err value"
|
|
257
323
|
);
|
|
258
|
-
|
|
324
|
+
n != null ? this.#e = n : this.#t = t;
|
|
259
325
|
}
|
|
260
326
|
/**
|
|
261
327
|
* Gets the success value, throwing an error if the result is a failure.
|
|
@@ -280,8 +346,8 @@ class m {
|
|
|
280
346
|
* @param {T} defaultValue - The default value to return if the result is a failure.
|
|
281
347
|
* @returns {T} The success value or the default value.
|
|
282
348
|
*/
|
|
283
|
-
unwrapOr(
|
|
284
|
-
return this.isOk() ? this.#e :
|
|
349
|
+
unwrapOr(n) {
|
|
350
|
+
return this.isOk() ? this.#e : n;
|
|
285
351
|
}
|
|
286
352
|
/**
|
|
287
353
|
* Gets the success value, throwing a custom error message if the result is a failure.
|
|
@@ -289,15 +355,15 @@ class m {
|
|
|
289
355
|
* @returns {T} The success value.
|
|
290
356
|
* @throws {Error} If the result is a failure.
|
|
291
357
|
*/
|
|
292
|
-
expect(
|
|
358
|
+
expect(n) {
|
|
293
359
|
if (this.isOk())
|
|
294
360
|
return this.#e;
|
|
295
361
|
if (this.isErr()) {
|
|
296
|
-
const
|
|
297
|
-
throw new Error(
|
|
298
|
-
` +
|
|
362
|
+
const t = this.#t;
|
|
363
|
+
throw new Error(n + `:
|
|
364
|
+
` + t.message);
|
|
299
365
|
}
|
|
300
|
-
throw new Error(
|
|
366
|
+
throw new Error(n);
|
|
301
367
|
}
|
|
302
368
|
/**
|
|
303
369
|
* Checks if the result is a success.
|
|
@@ -321,168 +387,168 @@ class m {
|
|
|
321
387
|
return this.#t;
|
|
322
388
|
}
|
|
323
389
|
}
|
|
324
|
-
function
|
|
325
|
-
return
|
|
390
|
+
function fe(e, n = []) {
|
|
391
|
+
return e == null ? n : Array.isArray(e) ? e : [e];
|
|
326
392
|
}
|
|
327
|
-
const
|
|
328
|
-
const
|
|
393
|
+
const O = /* @__PURE__ */ Symbol("SIGNAL"), de = (e) => typeof e == "function" && O in e, p = [], pe = (e) => {
|
|
394
|
+
const n = p.splice(0, p.length);
|
|
329
395
|
try {
|
|
330
|
-
return
|
|
396
|
+
return e();
|
|
331
397
|
} finally {
|
|
332
|
-
p.push(...
|
|
398
|
+
p.push(...n);
|
|
333
399
|
}
|
|
334
|
-
},
|
|
335
|
-
const
|
|
336
|
-
let
|
|
400
|
+
}, j = (e, n) => {
|
|
401
|
+
const t = /* @__PURE__ */ new Set();
|
|
402
|
+
let r = 0;
|
|
337
403
|
const o = () => {
|
|
338
404
|
const l = p[p.length - 1];
|
|
339
|
-
l && (
|
|
340
|
-
|
|
405
|
+
l && (t.add(l.setDirty), l.addSource(() => {
|
|
406
|
+
t.delete(l.setDirty);
|
|
341
407
|
}));
|
|
342
408
|
}, s = (l) => {
|
|
343
|
-
for (const
|
|
344
|
-
}, a = () =>
|
|
345
|
-
return { read: Object.assign(() => (o(),
|
|
346
|
-
[
|
|
347
|
-
subscribe: (l) => (
|
|
348
|
-
|
|
409
|
+
for (const m of Array.from(t)) m(l);
|
|
410
|
+
}, a = () => r > 0;
|
|
411
|
+
return { read: Object.assign(() => (o(), e()), {
|
|
412
|
+
[O]: !0,
|
|
413
|
+
subscribe: (l) => (t.add(l), r++, n?.(), () => {
|
|
414
|
+
t.delete(l), r--;
|
|
349
415
|
})
|
|
350
416
|
}), notify: s, hasSubscribers: a };
|
|
351
|
-
}, S = (
|
|
352
|
-
let
|
|
353
|
-
const { read:
|
|
354
|
-
return Object.assign(
|
|
417
|
+
}, S = (e) => {
|
|
418
|
+
let n = e;
|
|
419
|
+
const { read: t, notify: r } = j(() => n);
|
|
420
|
+
return Object.assign(t, {
|
|
355
421
|
set: (o) => {
|
|
356
|
-
|
|
422
|
+
n !== o && (n = o, r(o));
|
|
357
423
|
},
|
|
358
424
|
update: (o) => {
|
|
359
|
-
const s = o(
|
|
360
|
-
|
|
425
|
+
const s = o(n);
|
|
426
|
+
n !== s && (n = s, r(s));
|
|
361
427
|
},
|
|
362
|
-
asReadonly: () =>
|
|
428
|
+
asReadonly: () => t
|
|
363
429
|
});
|
|
364
|
-
}, k = (
|
|
365
|
-
const
|
|
366
|
-
let
|
|
430
|
+
}, k = (e) => {
|
|
431
|
+
const n = /* @__PURE__ */ new Set();
|
|
432
|
+
let t = !1, r = null, o = !1;
|
|
367
433
|
const s = () => {
|
|
368
|
-
if (o = !1,
|
|
369
|
-
|
|
434
|
+
if (o = !1, t) return;
|
|
435
|
+
r && (r(), r = null), n.forEach((i) => i()), n.clear();
|
|
370
436
|
const a = (i) => {
|
|
371
|
-
|
|
437
|
+
r = i;
|
|
372
438
|
};
|
|
373
439
|
p.push({
|
|
374
440
|
setDirty: () => {
|
|
375
|
-
!
|
|
441
|
+
!t && !o && (o = !0, queueMicrotask(s));
|
|
376
442
|
},
|
|
377
|
-
addSource: (i) =>
|
|
378
|
-
}),
|
|
443
|
+
addSource: (i) => n.add(i)
|
|
444
|
+
}), e(a), p.pop();
|
|
379
445
|
};
|
|
380
446
|
return s(), {
|
|
381
447
|
destroy() {
|
|
382
|
-
|
|
448
|
+
t = !0, r && (r(), r = null), n.forEach((a) => a()), n.clear();
|
|
383
449
|
}
|
|
384
450
|
};
|
|
385
|
-
}, L = (
|
|
386
|
-
const
|
|
387
|
-
let
|
|
451
|
+
}, L = (e) => {
|
|
452
|
+
const n = /* @__PURE__ */ new Set();
|
|
453
|
+
let t, r = !0, o = () => {
|
|
388
454
|
};
|
|
389
455
|
const s = () => {
|
|
390
|
-
|
|
456
|
+
n.forEach((c) => c()), n.clear(), p.push({
|
|
391
457
|
setDirty: () => {
|
|
392
|
-
if (
|
|
393
|
-
|
|
394
|
-
const c =
|
|
395
|
-
s(),
|
|
458
|
+
if (r) return;
|
|
459
|
+
r = !0;
|
|
460
|
+
const c = t;
|
|
461
|
+
s(), t !== c && o(t);
|
|
396
462
|
},
|
|
397
|
-
addSource: (c) =>
|
|
398
|
-
}),
|
|
399
|
-
}, { read: a, notify: i } =
|
|
400
|
-
() => (
|
|
463
|
+
addSource: (c) => n.add(c)
|
|
464
|
+
}), t = e(), r = !1, p.pop();
|
|
465
|
+
}, { read: a, notify: i } = j(
|
|
466
|
+
() => (r && s(), t),
|
|
401
467
|
() => {
|
|
402
|
-
|
|
468
|
+
r && s();
|
|
403
469
|
}
|
|
404
470
|
);
|
|
405
471
|
return o = i, a;
|
|
406
472
|
};
|
|
407
|
-
function
|
|
408
|
-
const
|
|
473
|
+
function he(e) {
|
|
474
|
+
const n = typeof e == "function", t = n ? void 0 : e.source, r = n ? e : e.computation, o = /* @__PURE__ */ new Set();
|
|
409
475
|
let s, a = !0, i = !1, c, l = () => {
|
|
410
476
|
};
|
|
411
|
-
const
|
|
477
|
+
const m = () => {
|
|
412
478
|
if (o.forEach((u) => u()), o.clear(), p.push({
|
|
413
479
|
setDirty: () => {
|
|
414
480
|
if (a) return;
|
|
415
481
|
a = !0, i = !1;
|
|
416
482
|
const u = s;
|
|
417
|
-
|
|
483
|
+
m(), s !== u && l(s);
|
|
418
484
|
},
|
|
419
485
|
addSource: (u) => o.add(u)
|
|
420
|
-
}),
|
|
421
|
-
s =
|
|
486
|
+
}), n)
|
|
487
|
+
s = r();
|
|
422
488
|
else {
|
|
423
|
-
const u =
|
|
424
|
-
s =
|
|
489
|
+
const u = t?.();
|
|
490
|
+
s = r(u, c), c = { source: u, value: s };
|
|
425
491
|
}
|
|
426
492
|
a = !1, p.pop();
|
|
427
|
-
}, { read:
|
|
428
|
-
() => (a && !i &&
|
|
493
|
+
}, { read: T, notify: d } = j(
|
|
494
|
+
() => (a && !i && m(), s),
|
|
429
495
|
() => {
|
|
430
|
-
a && !i &&
|
|
496
|
+
a && !i && m();
|
|
431
497
|
}
|
|
432
498
|
);
|
|
433
499
|
l = d;
|
|
434
|
-
const b = Object.assign(
|
|
500
|
+
const b = Object.assign(T, {
|
|
435
501
|
set: (u) => {
|
|
436
502
|
s !== u && (s = u, i = !0, a = !1, d(u));
|
|
437
503
|
},
|
|
438
504
|
update: (u) => {
|
|
439
|
-
a && !i &&
|
|
505
|
+
a && !i && m(), b.set(u(s));
|
|
440
506
|
},
|
|
441
|
-
asReadonly: () =>
|
|
507
|
+
asReadonly: () => T
|
|
442
508
|
});
|
|
443
509
|
return b;
|
|
444
510
|
}
|
|
445
|
-
class
|
|
446
|
-
constructor(
|
|
447
|
-
const
|
|
448
|
-
${
|
|
449
|
-
super(`Cannot read resource value while in error state${
|
|
511
|
+
class q extends Error {
|
|
512
|
+
constructor(n) {
|
|
513
|
+
const t = n instanceof Error ? `:
|
|
514
|
+
${n.message}` : "";
|
|
515
|
+
super(`Cannot read resource value while in error state${t}`, { cause: n }), this.name = "ResourceErrorState";
|
|
450
516
|
}
|
|
451
517
|
}
|
|
452
|
-
function
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
throw new
|
|
456
|
-
return
|
|
518
|
+
function ge(e) {
|
|
519
|
+
const n = S(void 0), t = S("idle"), r = S(void 0), o = L(() => t() === "loading"), s = S(0), a = L(() => {
|
|
520
|
+
if (t() === "error")
|
|
521
|
+
throw new q(r());
|
|
522
|
+
return n();
|
|
457
523
|
}), i = (d) => {
|
|
458
|
-
|
|
524
|
+
n.set(d), r.set(void 0), t.set("resolved");
|
|
459
525
|
}, c = (d) => {
|
|
460
|
-
|
|
461
|
-
}, l = "params" in
|
|
462
|
-
if ("stream" in
|
|
526
|
+
n.update(d), r.set(void 0), t.set("resolved");
|
|
527
|
+
}, l = "params" in e;
|
|
528
|
+
if ("stream" in e) {
|
|
463
529
|
const d = S(void 0), b = k((g) => {
|
|
464
530
|
s();
|
|
465
531
|
const f = new AbortController();
|
|
466
532
|
g(() => f.abort());
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
const $ =
|
|
470
|
-
params:
|
|
533
|
+
const _ = l ? e.params() : void 0;
|
|
534
|
+
t.set("loading"), r.set(void 0);
|
|
535
|
+
const $ = e.stream, F = $(l ? {
|
|
536
|
+
params: _,
|
|
471
537
|
abortSignal: f.signal
|
|
472
538
|
} : {
|
|
473
539
|
abortSignal: f.signal
|
|
474
540
|
});
|
|
475
|
-
d.set(
|
|
541
|
+
d.set(F);
|
|
476
542
|
}), u = k(() => {
|
|
477
543
|
const g = d();
|
|
478
544
|
if (!g) return;
|
|
479
545
|
const f = g();
|
|
480
|
-
f && ("error" in f && f.error !== void 0 ? (
|
|
546
|
+
f && ("error" in f && f.error !== void 0 ? (r.set(f.error), t.set("error")) : "value" in f && (n.set(f.value), t.set("resolved")));
|
|
481
547
|
});
|
|
482
548
|
return {
|
|
483
549
|
value: a,
|
|
484
|
-
status:
|
|
485
|
-
error:
|
|
550
|
+
status: t,
|
|
551
|
+
error: r,
|
|
486
552
|
isLoading: o,
|
|
487
553
|
set: i,
|
|
488
554
|
update: c,
|
|
@@ -494,36 +560,36 @@ function ue(t) {
|
|
|
494
560
|
}
|
|
495
561
|
};
|
|
496
562
|
}
|
|
497
|
-
const
|
|
563
|
+
const T = k((d) => {
|
|
498
564
|
s();
|
|
499
|
-
const b = l ?
|
|
500
|
-
|
|
565
|
+
const b = l ? e.params() : void 0;
|
|
566
|
+
t.set("loading"), r.set(void 0);
|
|
501
567
|
const u = new AbortController();
|
|
502
568
|
d(() => u.abort());
|
|
503
569
|
const g = l ? { params: b, abortSignal: u.signal } : { abortSignal: u.signal };
|
|
504
|
-
|
|
570
|
+
e.loader(g).then(
|
|
505
571
|
(f) => {
|
|
506
|
-
u.signal.aborted || (
|
|
572
|
+
u.signal.aborted || (n.set(f), t.set("resolved"));
|
|
507
573
|
},
|
|
508
574
|
(f) => {
|
|
509
|
-
u.signal.aborted || (
|
|
575
|
+
u.signal.aborted || (r.set(f), t.set("error"));
|
|
510
576
|
}
|
|
511
577
|
);
|
|
512
578
|
});
|
|
513
579
|
return {
|
|
514
580
|
value: a,
|
|
515
|
-
status:
|
|
516
|
-
error:
|
|
581
|
+
status: t,
|
|
582
|
+
error: r,
|
|
517
583
|
isLoading: o,
|
|
518
584
|
set: i,
|
|
519
585
|
update: c,
|
|
520
586
|
reload: () => {
|
|
521
587
|
s.update((d) => d + 1);
|
|
522
588
|
},
|
|
523
|
-
destroy: () =>
|
|
589
|
+
destroy: () => T.destroy()
|
|
524
590
|
};
|
|
525
591
|
}
|
|
526
|
-
const
|
|
592
|
+
const A = /* @__PURE__ */ new Map([
|
|
527
593
|
["b", "b"],
|
|
528
594
|
["i", "i"],
|
|
529
595
|
["u", "u"],
|
|
@@ -547,7 +613,7 @@ const x = /* @__PURE__ */ new Map([
|
|
|
547
613
|
["ul", "ul"],
|
|
548
614
|
["ol", "ol"],
|
|
549
615
|
["li", "li"]
|
|
550
|
-
]),
|
|
616
|
+
]), v = /* @__PURE__ */ new Set([
|
|
551
617
|
"div",
|
|
552
618
|
"p",
|
|
553
619
|
"ul",
|
|
@@ -560,14 +626,14 @@ const x = /* @__PURE__ */ new Map([
|
|
|
560
626
|
"h5",
|
|
561
627
|
"h6"
|
|
562
628
|
]);
|
|
563
|
-
let
|
|
564
|
-
function
|
|
565
|
-
return
|
|
629
|
+
let R = "rtp-";
|
|
630
|
+
function M() {
|
|
631
|
+
return R;
|
|
566
632
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
633
|
+
function X(e) {
|
|
634
|
+
R = e;
|
|
569
635
|
}
|
|
570
|
-
const
|
|
636
|
+
const N = /* @__PURE__ */ new Map([
|
|
571
637
|
["br", "br"],
|
|
572
638
|
["hr", "hr"]
|
|
573
639
|
]), w = /* @__PURE__ */ new Map([
|
|
@@ -658,12 +724,12 @@ const j = /* @__PURE__ */ new Map([
|
|
|
658
724
|
["margin", "1em 0"]
|
|
659
725
|
])
|
|
660
726
|
]
|
|
661
|
-
]),
|
|
662
|
-
const s =
|
|
727
|
+
]), x = (e, n, t, r, o) => {
|
|
728
|
+
const s = e.filter((i) => !v.has(i)), a = e.filter((i) => v.has(i));
|
|
663
729
|
return {
|
|
664
|
-
tagNames:
|
|
665
|
-
tagNamesList:
|
|
666
|
-
text: o ??
|
|
730
|
+
tagNames: e.join(","),
|
|
731
|
+
tagNamesList: e,
|
|
732
|
+
text: o ?? n.slice(t, r),
|
|
667
733
|
style: s.map(
|
|
668
734
|
(i) => [...w.get(i)?.entries() ?? []].map(([c, l]) => `${c}: ${l}`).join("; ")
|
|
669
735
|
).filter(Boolean).join("; "),
|
|
@@ -671,214 +737,216 @@ const j = /* @__PURE__ */ new Map([
|
|
|
671
737
|
s.flatMap((i) => Array.from(w.get(i) ?? []))
|
|
672
738
|
),
|
|
673
739
|
containerTagNames: a,
|
|
674
|
-
cssClass: s.map((i) => `${
|
|
740
|
+
cssClass: s.map((i) => `${M()}${i}`).join(" ")
|
|
675
741
|
};
|
|
676
|
-
},
|
|
677
|
-
`<\\/?(${
|
|
742
|
+
}, K = () => [...A.keys()].join("|"), W = () => [...N.keys()].join("|"), Y = () => new RegExp(
|
|
743
|
+
`<\\/?(${K()})>|<(${W()})\\s*/?>`,
|
|
678
744
|
"gi"
|
|
679
745
|
);
|
|
680
|
-
function
|
|
681
|
-
const
|
|
682
|
-
Object.entries(
|
|
683
|
-
}
|
|
684
|
-
function
|
|
685
|
-
const
|
|
686
|
-
for (const [
|
|
687
|
-
if (
|
|
688
|
-
const
|
|
746
|
+
function z(e, n) {
|
|
747
|
+
const t = w.get(e) ?? /* @__PURE__ */ new Map();
|
|
748
|
+
Object.entries(n).forEach(([r, o]) => t.set(r, o)), w.set(e, t);
|
|
749
|
+
}
|
|
750
|
+
function P() {
|
|
751
|
+
const e = [];
|
|
752
|
+
for (const [n, t] of w) {
|
|
753
|
+
if (t.size === 0) continue;
|
|
754
|
+
const r = [...t.entries()].map(([o, s]) => ` ${o}: ${s};`).join(`
|
|
689
755
|
`);
|
|
690
|
-
|
|
691
|
-
${
|
|
756
|
+
e.push(`.${M()}${n} {
|
|
757
|
+
${r}
|
|
692
758
|
}`);
|
|
693
759
|
}
|
|
694
|
-
return
|
|
760
|
+
return e.join(`
|
|
695
761
|
`);
|
|
696
762
|
}
|
|
697
|
-
function
|
|
763
|
+
function Q() {
|
|
698
764
|
if ("document" in globalThis) {
|
|
699
|
-
const
|
|
765
|
+
const e = P(), n = globalThis, t = n.document.getElementById(
|
|
700
766
|
"html-text-parser-styles"
|
|
701
767
|
);
|
|
702
|
-
if (
|
|
703
|
-
|
|
768
|
+
if (t) {
|
|
769
|
+
t.textContent = e;
|
|
704
770
|
return;
|
|
705
771
|
}
|
|
706
|
-
const
|
|
707
|
-
|
|
772
|
+
const r = n.document.createElement("style");
|
|
773
|
+
r.textContent = e, r.setAttribute("id", "html-text-parser-styles"), n.document.head.appendChild(r);
|
|
708
774
|
return;
|
|
709
775
|
}
|
|
710
776
|
console.warn(
|
|
711
777
|
"[html-text-parser] Cannot inject stylesheet: document is not available."
|
|
712
778
|
);
|
|
713
779
|
}
|
|
714
|
-
function
|
|
715
|
-
const
|
|
716
|
-
let
|
|
717
|
-
for (const
|
|
718
|
-
const o =
|
|
719
|
-
o !== s && (
|
|
720
|
-
containerTagNames:
|
|
721
|
-
cssClass:
|
|
722
|
-
style:
|
|
780
|
+
function ee(e) {
|
|
781
|
+
const n = [];
|
|
782
|
+
let t;
|
|
783
|
+
for (const r of e) {
|
|
784
|
+
const o = r.containerTagNames.join(","), s = t?.containerTagNames.join(",");
|
|
785
|
+
o !== s && (t = {
|
|
786
|
+
containerTagNames: r.containerTagNames,
|
|
787
|
+
cssClass: r.containerTagNames.map((a) => `${M()}${a}`).join(" "),
|
|
788
|
+
style: r.containerTagNames.map(
|
|
723
789
|
(a) => [...w.get(a)?.entries() ?? []].map(([i, c]) => `${i}: ${c}`).join("; ")
|
|
724
790
|
).filter(Boolean).join("; "),
|
|
725
791
|
styleObject: Object.fromEntries(
|
|
726
|
-
|
|
792
|
+
r.containerTagNames.flatMap(
|
|
727
793
|
(a) => Array.from(w.get(a) ?? [])
|
|
728
794
|
)
|
|
729
795
|
),
|
|
730
796
|
segments: []
|
|
731
|
-
},
|
|
797
|
+
}, n.push(t)), t.segments.push(r);
|
|
732
798
|
}
|
|
733
|
-
return
|
|
799
|
+
return n;
|
|
734
800
|
}
|
|
735
|
-
function
|
|
801
|
+
function te(e, n, t) {
|
|
736
802
|
if (!("document" in globalThis)) {
|
|
737
803
|
console.warn(
|
|
738
804
|
"[html-text-parser] Cannot append segments: document is not available."
|
|
739
805
|
);
|
|
740
806
|
return;
|
|
741
807
|
}
|
|
742
|
-
if (!
|
|
808
|
+
if (!e || !("appendChild" in e)) {
|
|
743
809
|
console.warn(
|
|
744
810
|
"[html-text-parser] Cannot append segments: provided element does not support appendChild."
|
|
745
811
|
);
|
|
746
812
|
return;
|
|
747
813
|
}
|
|
748
|
-
|
|
749
|
-
const
|
|
750
|
-
for (const s of
|
|
814
|
+
t = { useClasses: !0, useStyles: !1, ...t };
|
|
815
|
+
const r = e, o = globalThis.document;
|
|
816
|
+
for (const s of n) {
|
|
751
817
|
const a = o.createElement(
|
|
752
818
|
s.containerTagNames[0] || "span"
|
|
753
819
|
);
|
|
754
|
-
|
|
820
|
+
t.useClasses && (a.className = s.cssClass), t.useStyles && a.setAttribute("style", s.style);
|
|
755
821
|
for (const i of s.segments) {
|
|
756
822
|
const c = o.createElement("span");
|
|
757
|
-
c.textContent = i.text,
|
|
823
|
+
c.textContent = i.text, t.useClasses && (c.className = i.cssClass), t.useStyles && c.setAttribute("style", i.style), a.appendChild(c);
|
|
758
824
|
}
|
|
759
|
-
|
|
825
|
+
r.appendChild(a);
|
|
760
826
|
}
|
|
761
827
|
}
|
|
762
|
-
function h(
|
|
763
|
-
return
|
|
828
|
+
function h(e) {
|
|
829
|
+
return ee(B(e));
|
|
764
830
|
}
|
|
765
|
-
function
|
|
766
|
-
const
|
|
767
|
-
let
|
|
768
|
-
for (const o of
|
|
831
|
+
function B(e) {
|
|
832
|
+
const n = [], t = /* @__PURE__ */ new Map();
|
|
833
|
+
let r = 0;
|
|
834
|
+
for (const o of e.matchAll(Y())) {
|
|
769
835
|
const s = o.index;
|
|
770
|
-
s >
|
|
771
|
-
|
|
836
|
+
s > r && n.push(
|
|
837
|
+
x([...t.keys()], e, r, s)
|
|
772
838
|
);
|
|
773
839
|
const a = o[2]?.toLowerCase();
|
|
774
|
-
if (a &&
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
[...
|
|
778
|
-
|
|
779
|
-
|
|
840
|
+
if (a && N.has(a)) {
|
|
841
|
+
n.push(
|
|
842
|
+
x(
|
|
843
|
+
[...t.keys(), a],
|
|
844
|
+
e,
|
|
845
|
+
r,
|
|
780
846
|
s,
|
|
781
847
|
""
|
|
782
848
|
)
|
|
783
|
-
),
|
|
849
|
+
), r = s + o[0].length;
|
|
784
850
|
continue;
|
|
785
851
|
}
|
|
786
|
-
const i = o[0][1] === "/", c =
|
|
852
|
+
const i = o[0][1] === "/", c = A.get(o[1]?.toLowerCase() ?? "") ?? "";
|
|
787
853
|
if (i) {
|
|
788
|
-
const l = (
|
|
789
|
-
l <= 0 ?
|
|
854
|
+
const l = (t.get(c) ?? 1) - 1;
|
|
855
|
+
l <= 0 ? t.delete(c) : t.set(c, l);
|
|
790
856
|
} else
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
return
|
|
795
|
-
|
|
796
|
-
[...
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
857
|
+
t.set(c, (t.get(c) ?? 0) + 1);
|
|
858
|
+
r = s + o[0].length;
|
|
859
|
+
}
|
|
860
|
+
return r < e.length && n.push(
|
|
861
|
+
x(
|
|
862
|
+
[...t.keys()],
|
|
863
|
+
e,
|
|
864
|
+
r,
|
|
865
|
+
e.length
|
|
800
866
|
)
|
|
801
|
-
),
|
|
867
|
+
), n;
|
|
802
868
|
}
|
|
803
|
-
function
|
|
804
|
-
if (Array.isArray(
|
|
805
|
-
|
|
806
|
-
|
|
869
|
+
function U(e) {
|
|
870
|
+
if (Array.isArray(e)) {
|
|
871
|
+
e.forEach((t) => {
|
|
872
|
+
U(t);
|
|
807
873
|
});
|
|
808
874
|
return;
|
|
809
875
|
}
|
|
810
|
-
const
|
|
811
|
-
|
|
876
|
+
const n = e.tagName ?? e.tag;
|
|
877
|
+
A.set(e.tag, n), e.style != null && Object.keys(e.style).length && z(n, e.style);
|
|
812
878
|
}
|
|
813
|
-
function
|
|
814
|
-
if (Array.isArray(
|
|
815
|
-
|
|
816
|
-
|
|
879
|
+
function D(e) {
|
|
880
|
+
if (Array.isArray(e)) {
|
|
881
|
+
e.forEach((t) => {
|
|
882
|
+
D(t);
|
|
817
883
|
});
|
|
818
884
|
return;
|
|
819
885
|
}
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
h.setTag =
|
|
824
|
-
h.setSelfClosingTag =
|
|
825
|
-
h.setBlockTag = (
|
|
826
|
-
h.removeBlockTag = (
|
|
827
|
-
h.setCssClassPrefix =
|
|
828
|
-
h.getStylesheet =
|
|
829
|
-
h.flat =
|
|
830
|
-
h.generateStylesheet =
|
|
831
|
-
h.appendToDom =
|
|
832
|
-
function
|
|
833
|
-
function
|
|
834
|
-
const [s, a] = E(() =>
|
|
835
|
-
if (a) throw new Error(`Error transforming value for ${
|
|
836
|
-
if (!
|
|
886
|
+
const n = e.tagName ?? e.tag;
|
|
887
|
+
N.set(e.tag, n), e.style != null && Object.keys(e.style).length && z(n, e.style);
|
|
888
|
+
}
|
|
889
|
+
h.setTag = U;
|
|
890
|
+
h.setSelfClosingTag = D;
|
|
891
|
+
h.setBlockTag = (e) => v.add(e);
|
|
892
|
+
h.removeBlockTag = (e) => v.delete(e);
|
|
893
|
+
h.setCssClassPrefix = X;
|
|
894
|
+
h.getStylesheet = P;
|
|
895
|
+
h.flat = B;
|
|
896
|
+
h.generateStylesheet = Q;
|
|
897
|
+
h.appendToDom = te;
|
|
898
|
+
function ne(e, n, t) {
|
|
899
|
+
function r(o) {
|
|
900
|
+
const [s, a] = E(() => t ? t(o) : o);
|
|
901
|
+
if (a) throw new Error(`Error transforming value for ${e}: ${a.message}`);
|
|
902
|
+
if (!n(s)) throw new Error(`"${o}" is not a valid ${e}`);
|
|
837
903
|
return s;
|
|
838
904
|
}
|
|
839
|
-
return
|
|
840
|
-
const [s, a] = E(() =>
|
|
905
|
+
return r.from = (o) => {
|
|
906
|
+
const [s, a] = E(() => t ? t(o) : o);
|
|
841
907
|
if (!a)
|
|
842
|
-
return
|
|
843
|
-
},
|
|
844
|
-
const s = E(() =>
|
|
845
|
-
return
|
|
846
|
-
},
|
|
908
|
+
return n(s) ? s : void 0;
|
|
909
|
+
}, r.is = (o) => {
|
|
910
|
+
const s = E(() => t ? t(o) : o)[0] ?? o;
|
|
911
|
+
return n(s);
|
|
912
|
+
}, r;
|
|
847
913
|
}
|
|
848
|
-
const
|
|
914
|
+
const ye = ne(
|
|
849
915
|
"NumericString",
|
|
850
|
-
(
|
|
916
|
+
(e) => (
|
|
851
917
|
// checks that a given value is:
|
|
852
918
|
// - a number, and the number is neither positive Infinity, negative Infinity, nor NaN.
|
|
853
|
-
typeof
|
|
919
|
+
typeof e == "string" && e.trim() !== "" && Number.isFinite(Number(e))
|
|
854
920
|
),
|
|
855
|
-
(
|
|
921
|
+
(e) => String(e)
|
|
856
922
|
);
|
|
857
923
|
export {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
924
|
+
ye as NumericString,
|
|
925
|
+
y as Result,
|
|
926
|
+
O as SIGNAL,
|
|
927
|
+
ce as clamp,
|
|
862
928
|
L as computed,
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
929
|
+
re as convertCase,
|
|
930
|
+
ne as createBrand,
|
|
931
|
+
le as debounce,
|
|
932
|
+
ie as delay,
|
|
867
933
|
k as effect,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
934
|
+
J as getProp,
|
|
935
|
+
ae as groupBy,
|
|
936
|
+
oe as http,
|
|
937
|
+
de as isSignal,
|
|
938
|
+
he as linkedSignal,
|
|
939
|
+
I as normalizeString,
|
|
874
940
|
h as parseRichText,
|
|
875
|
-
|
|
876
|
-
ue as
|
|
877
|
-
|
|
878
|
-
|
|
941
|
+
B as parseRichTextFlat,
|
|
942
|
+
ue as pickPaths,
|
|
943
|
+
ge as resource,
|
|
944
|
+
Z as setDeepValue,
|
|
945
|
+
U as setRichTextTag,
|
|
946
|
+
D as setSelfClosingTag,
|
|
879
947
|
S as signal,
|
|
880
|
-
|
|
948
|
+
fe as toArray,
|
|
881
949
|
E as tryCatch,
|
|
882
|
-
|
|
883
|
-
|
|
950
|
+
se as tryCatchAsync,
|
|
951
|
+
pe as untracked
|
|
884
952
|
};
|
package/lib/getProp.d.ts
CHANGED
|
@@ -15,3 +15,13 @@ export type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}
|
|
|
15
15
|
* @returns {PathValue<T, P>} The value at the given path, or undefined if the path is invalid.
|
|
16
16
|
*/
|
|
17
17
|
export declare function getProp<T, P extends string>(obj: T, path: P): PathValue<T, P>;
|
|
18
|
+
/**
|
|
19
|
+
* Utility to deeply set a value in an object at a given path array.
|
|
20
|
+
* This is a helper function to reconstruct the object structure.
|
|
21
|
+
*/
|
|
22
|
+
export declare function setDeepValue<TObj extends object, TValue = any>(obj: TObj, keysPath: string[], value: TValue): void;
|
|
23
|
+
/**
|
|
24
|
+
* Takes an object and an array of paths, returning a new object
|
|
25
|
+
* that preserves the original nested structure for the requested keys.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pickPaths<T, P extends string>(obj: T, paths: readonly P[]): Partial<T>;
|
package/lib/http.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export type HttpError = Error & {
|
|
2
|
+
status?: number;
|
|
3
|
+
statusText?: string;
|
|
4
|
+
body?: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
isNetworkError?: boolean;
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export interface RequestInit extends globalThis.RequestInit {
|
|
10
|
+
parse?: 'JSON' | 'TEXT' | 'BLOB' | 'ARRAYBUFFER';
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
13
|
* A utility object for making HTTP requests.
|
|
3
14
|
*/
|
package/lib/tryCatch.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type TryResult<T, E = Error> = [T, null] | [null, E];
|
|
|
11
11
|
* @param {Promise<T>} promise - The promise to handle
|
|
12
12
|
* @returns {Promise<TryResult<T, E>>} - A promise that resolves to a tuple with either the result or the error
|
|
13
13
|
*/
|
|
14
|
-
export declare function tryCatchAsync<T, E = Error>(promise: Promise<T>): Promise<TryResult<T, E>>;
|
|
14
|
+
export declare function tryCatchAsync<T, E = Error>(promise: Promise<T> | (() => Promise<T>)): Promise<TryResult<T, E>>;
|
|
15
15
|
/**
|
|
16
16
|
* Main wrapper function to handle promise with try-catch
|
|
17
17
|
* @template T - Type of the successful result
|