@dvirus-js/utils 0.0.6 → 0.0.13
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 +60 -0
- package/index.js +693 -493
- package/lib/get-empty-keys.d.ts +29 -0
- package/lib/getProp.d.ts +10 -0
- package/lib/html-text-parser/api.d.ts +62 -0
- package/lib/html-text-parser/constant.d.ts +0 -1
- package/lib/html-text-parser/dom-renderer.d.ts +17 -0
- package/lib/html-text-parser/grouping.d.ts +2 -0
- package/lib/html-text-parser/index.d.ts +2 -2
- package/lib/html-text-parser/parsing.d.ts +26 -0
- package/lib/html-text-parser/segment.d.ts +2 -0
- package/lib/html-text-parser/stylesheet.d.ts +21 -0
- package/lib/html-text-parser/tag-regex.d.ts +3 -0
- package/lib/html-text-parser/tags.d.ts +43 -0
- package/lib/html-text-parser/types.d.ts +37 -19
- package/lib/http.d.ts +149 -8
- package/lib/tryCatch.d.ts +1 -1
- package/package.json +1 -1
- package/lib/html-text-parser/html-text-parser.d.ts +0 -70
- package/lib/html-text-parser/methods.d.ts +0 -51
package/index.js
CHANGED
|
@@ -1,62 +1,130 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function V(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 ue(e, t) {
|
|
5
|
+
const r = V(e);
|
|
6
|
+
switch (t) {
|
|
7
7
|
case "lowercase":
|
|
8
|
-
return
|
|
8
|
+
return r.toLowerCase();
|
|
9
9
|
case "UPPERCASE":
|
|
10
|
-
return
|
|
10
|
+
return r.toUpperCase();
|
|
11
11
|
case "Title Case":
|
|
12
|
-
return
|
|
12
|
+
return r.split(" ").map(
|
|
13
13
|
(n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()
|
|
14
14
|
).join(" ");
|
|
15
15
|
case "kebab-case":
|
|
16
|
-
return
|
|
16
|
+
return r.replace(/\s+/g, "-");
|
|
17
17
|
case "snake_case":
|
|
18
|
-
return
|
|
18
|
+
return r.replace(/\s+/g, "_");
|
|
19
19
|
case "camelCase": {
|
|
20
|
-
const n =
|
|
20
|
+
const n = r.split(" ");
|
|
21
21
|
return n.length === 0 ? "" : n[0]?.toLowerCase() + n.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
|
|
26
|
+
return r.split(" ").map(
|
|
27
27
|
(n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()
|
|
28
28
|
).join("");
|
|
29
29
|
case "dot.case":
|
|
30
|
-
return
|
|
30
|
+
return r.replace(/\s+/g, ".");
|
|
31
31
|
case "path/case":
|
|
32
|
-
return
|
|
32
|
+
return r.replace(/\s+/g, "/");
|
|
33
33
|
case "Sentence case":
|
|
34
|
-
return
|
|
34
|
+
return r.replace(/(^\s*\w|[.!?]\s*\w)/g, (n) => n.toUpperCase()).replace(/\bi\b/g, "I");
|
|
35
35
|
case "Header-Case":
|
|
36
|
-
return
|
|
36
|
+
return r.split(" ").map(
|
|
37
37
|
(n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()
|
|
38
38
|
).join("-");
|
|
39
39
|
case "reverse":
|
|
40
|
-
return
|
|
40
|
+
return r.split("").reverse().join("");
|
|
41
41
|
default:
|
|
42
|
-
throw new Error(`Unsupported case type: ${
|
|
42
|
+
throw new Error(`Unsupported case type: ${t}`);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
async function
|
|
45
|
+
async function de(e) {
|
|
46
46
|
try {
|
|
47
|
-
return [await
|
|
48
|
-
} catch (
|
|
49
|
-
return [null,
|
|
47
|
+
return [await (typeof e == "function" ? e() : e), null];
|
|
48
|
+
} catch (t) {
|
|
49
|
+
return [null, t];
|
|
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 (t) {
|
|
56
|
+
return [null, t];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
let b = "";
|
|
60
|
+
const U = {
|
|
61
|
+
100: "Continue",
|
|
62
|
+
101: "Switching Protocols",
|
|
63
|
+
102: "Processing",
|
|
64
|
+
103: "Early Hints",
|
|
65
|
+
200: "OK",
|
|
66
|
+
201: "Created",
|
|
67
|
+
202: "Accepted",
|
|
68
|
+
203: "Non-Authoritative Information",
|
|
69
|
+
204: "No Content",
|
|
70
|
+
205: "Reset Content",
|
|
71
|
+
206: "Partial Content",
|
|
72
|
+
207: "Multi-Status",
|
|
73
|
+
208: "Already Reported",
|
|
74
|
+
226: "IM Used",
|
|
75
|
+
300: "Multiple Choices",
|
|
76
|
+
301: "Moved Permanently",
|
|
77
|
+
302: "Found",
|
|
78
|
+
303: "See Other",
|
|
79
|
+
304: "Not Modified",
|
|
80
|
+
305: "Use Proxy",
|
|
81
|
+
307: "Temporary Redirect",
|
|
82
|
+
308: "Permanent Redirect",
|
|
83
|
+
400: "Bad Request",
|
|
84
|
+
401: "Unauthorized",
|
|
85
|
+
402: "Payment Required",
|
|
86
|
+
403: "Forbidden",
|
|
87
|
+
404: "Not Found",
|
|
88
|
+
405: "Method Not Allowed",
|
|
89
|
+
406: "Not Acceptable",
|
|
90
|
+
407: "Proxy Authentication Required",
|
|
91
|
+
408: "Request Timeout",
|
|
92
|
+
409: "Conflict",
|
|
93
|
+
410: "Gone",
|
|
94
|
+
411: "Length Required",
|
|
95
|
+
412: "Precondition Failed",
|
|
96
|
+
413: "Payload Too Large",
|
|
97
|
+
414: "URI Too Long",
|
|
98
|
+
415: "Unsupported Media Type",
|
|
99
|
+
416: "Range Not Satisfiable",
|
|
100
|
+
417: "Expectation Failed",
|
|
101
|
+
418: "I'm a teapot",
|
|
102
|
+
421: "Misdirected Request",
|
|
103
|
+
422: "Unprocessable Entity",
|
|
104
|
+
423: "Locked",
|
|
105
|
+
424: "Failed Dependency",
|
|
106
|
+
425: "Too Early",
|
|
107
|
+
426: "Upgrade Required",
|
|
108
|
+
428: "Precondition Required",
|
|
109
|
+
429: "Too Many Requests",
|
|
110
|
+
431: "Request Header Fields Too Large",
|
|
111
|
+
451: "Unavailable For Legal Reasons",
|
|
112
|
+
500: "Internal Server Error",
|
|
113
|
+
501: "Not Implemented",
|
|
114
|
+
502: "Bad Gateway",
|
|
115
|
+
503: "Service Unavailable",
|
|
116
|
+
504: "Gateway Timeout",
|
|
117
|
+
505: "HTTP Version Not Supported",
|
|
118
|
+
506: "Variant Also Negotiates",
|
|
119
|
+
507: "Insufficient Storage",
|
|
120
|
+
508: "Loop Detected",
|
|
121
|
+
510: "Not Extended",
|
|
122
|
+
511: "Network Authentication Required"
|
|
123
|
+
}, fe = {
|
|
124
|
+
setBaseUrl: (e) => {
|
|
125
|
+
b = e;
|
|
126
|
+
},
|
|
127
|
+
CodeNames: U,
|
|
60
128
|
/**
|
|
61
129
|
* Makes a GET request to the specified URL.
|
|
62
130
|
*
|
|
@@ -65,9 +133,11 @@ const ee = {
|
|
|
65
133
|
* @returns {Promise<any>} The response data.
|
|
66
134
|
* @throws {Error} If the response is not ok.
|
|
67
135
|
*/
|
|
68
|
-
get: async function(
|
|
69
|
-
|
|
70
|
-
|
|
136
|
+
get: async function(e, t) {
|
|
137
|
+
return await w(
|
|
138
|
+
() => fetch(b + e, t),
|
|
139
|
+
t
|
|
140
|
+
);
|
|
71
141
|
},
|
|
72
142
|
/**
|
|
73
143
|
* Makes a POST request to the specified URL with the given data.
|
|
@@ -79,39 +149,41 @@ const ee = {
|
|
|
79
149
|
* @returns {Promise<R>} The response data.
|
|
80
150
|
* @throws {Error} If the response is not ok.
|
|
81
151
|
*/
|
|
82
|
-
post: async function(t, r
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
152
|
+
post: async function(e, t, r) {
|
|
153
|
+
return await w(
|
|
154
|
+
() => fetch(b + e, {
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: {
|
|
157
|
+
"Content-Type": "application/json",
|
|
158
|
+
...r?.headers
|
|
159
|
+
},
|
|
160
|
+
body: JSON.stringify(t),
|
|
161
|
+
...r
|
|
162
|
+
}),
|
|
163
|
+
r
|
|
164
|
+
);
|
|
93
165
|
},
|
|
94
166
|
/**
|
|
95
|
-
* Makes a DELETE request to the specified URL
|
|
167
|
+
* Makes a DELETE request to the specified URL.
|
|
96
168
|
*
|
|
97
169
|
* @template R
|
|
98
170
|
* @param {string} url - The URL to send the DELETE request to.
|
|
99
|
-
* @param {string} id - The ID to send in the request body.
|
|
100
171
|
* @param {RequestInit} [options] - Optional request options.
|
|
101
172
|
* @returns {Promise<R>} The response data.
|
|
102
173
|
* @throws {Error} If the response is not ok.
|
|
103
174
|
*/
|
|
104
|
-
delete: async function(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
175
|
+
delete: async function(e, t) {
|
|
176
|
+
return await w(
|
|
177
|
+
() => fetch(b + e, {
|
|
178
|
+
method: "DELETE",
|
|
179
|
+
headers: {
|
|
180
|
+
"Content-Type": "application/json",
|
|
181
|
+
...t?.headers
|
|
182
|
+
},
|
|
183
|
+
...t
|
|
184
|
+
}),
|
|
185
|
+
t
|
|
186
|
+
);
|
|
115
187
|
},
|
|
116
188
|
/**
|
|
117
189
|
* Makes a PATCH request to the specified URL with the given data.
|
|
@@ -123,17 +195,19 @@ const ee = {
|
|
|
123
195
|
* @returns {Promise<R>} The response data.
|
|
124
196
|
* @throws {Error} If the response is not ok.
|
|
125
197
|
*/
|
|
126
|
-
patch: async function(t, r
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
198
|
+
patch: async function(e, t, r) {
|
|
199
|
+
return await w(
|
|
200
|
+
() => fetch(b + e, {
|
|
201
|
+
method: "PATCH",
|
|
202
|
+
headers: {
|
|
203
|
+
"Content-Type": "application/json",
|
|
204
|
+
...r?.headers
|
|
205
|
+
},
|
|
206
|
+
body: JSON.stringify(t),
|
|
207
|
+
...r
|
|
208
|
+
}),
|
|
209
|
+
r
|
|
210
|
+
);
|
|
137
211
|
},
|
|
138
212
|
/**
|
|
139
213
|
* Makes a PUT request to the specified URL with the given data.
|
|
@@ -145,52 +219,95 @@ const ee = {
|
|
|
145
219
|
* @returns {Promise<R>} The response data.
|
|
146
220
|
* @throws {Error} If the response is not ok.
|
|
147
221
|
*/
|
|
148
|
-
put: async function(t, r
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
222
|
+
put: async function(e, t, r) {
|
|
223
|
+
return await w(
|
|
224
|
+
() => fetch(b + e, {
|
|
225
|
+
method: "PUT",
|
|
226
|
+
headers: {
|
|
227
|
+
"Content-Type": "application/json",
|
|
228
|
+
...r?.headers
|
|
229
|
+
},
|
|
230
|
+
body: JSON.stringify(t),
|
|
231
|
+
...r
|
|
232
|
+
}),
|
|
233
|
+
r
|
|
234
|
+
);
|
|
159
235
|
}
|
|
160
236
|
};
|
|
161
|
-
async function
|
|
162
|
-
|
|
163
|
-
|
|
237
|
+
async function w(e, t) {
|
|
238
|
+
try {
|
|
239
|
+
const r = await e();
|
|
240
|
+
if (!r.ok) {
|
|
241
|
+
const n = await r.text(), [o, s] = E(() => JSON.parse(n));
|
|
242
|
+
throw Object.assign(r, {
|
|
243
|
+
data: s ? n : o,
|
|
244
|
+
name: `HTTP_${r.status}`,
|
|
245
|
+
message: r.statusText || U[r.status] || `HTTP_${r.status}`
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return t?.parse === "JSON" ? Object.assign(r, {
|
|
249
|
+
data: await r.json()
|
|
250
|
+
}) : t?.parse === "TEXT" ? Object.assign(r, {
|
|
251
|
+
data: await r.text()
|
|
252
|
+
}) : t?.parse === "BLOB" ? Object.assign(r, {
|
|
253
|
+
data: await r.blob()
|
|
254
|
+
}) : t?.parse === "ARRAYBUFFER" ? Object.assign(r, {
|
|
255
|
+
data: await r.arrayBuffer()
|
|
256
|
+
}) : Object.assign(r, {
|
|
257
|
+
data: await r.json()
|
|
258
|
+
});
|
|
259
|
+
} catch (r) {
|
|
260
|
+
if (J(r)) throw r;
|
|
261
|
+
const n = {
|
|
262
|
+
data: r,
|
|
263
|
+
ok: !1,
|
|
264
|
+
status: 0,
|
|
265
|
+
statusText: "NETWORK_ERROR",
|
|
266
|
+
type: "error",
|
|
267
|
+
name: "NetworkError",
|
|
268
|
+
message: r instanceof Error ? r.message : String(r),
|
|
269
|
+
headers: new Headers(),
|
|
270
|
+
url: "",
|
|
271
|
+
redirected: !1,
|
|
272
|
+
clone: () => n,
|
|
273
|
+
bodyUsed: !1,
|
|
274
|
+
formData: () => Promise.resolve(new FormData())
|
|
275
|
+
};
|
|
276
|
+
throw n;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function J(e) {
|
|
280
|
+
return e !== null && typeof e == "object" && "data" in e && "body" in e;
|
|
164
281
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
const s =
|
|
169
|
-
s && (
|
|
170
|
-
}),
|
|
282
|
+
function he(e, t) {
|
|
283
|
+
const r = {};
|
|
284
|
+
return e?.forEach((n, o) => {
|
|
285
|
+
const s = t(n, o, e)?.toString();
|
|
286
|
+
s && (r[s] ??= [], r[s].push(n));
|
|
287
|
+
}), r;
|
|
171
288
|
}
|
|
172
|
-
async function
|
|
173
|
-
return await new Promise((
|
|
289
|
+
async function ge(e) {
|
|
290
|
+
return await new Promise((t) => setTimeout(t, e));
|
|
174
291
|
}
|
|
175
|
-
function
|
|
176
|
-
return
|
|
292
|
+
function pe(e, t, r) {
|
|
293
|
+
return t < e ? e : t > r ? r : t;
|
|
177
294
|
}
|
|
178
|
-
function
|
|
295
|
+
function me(e, t, r) {
|
|
179
296
|
let n;
|
|
180
|
-
return
|
|
181
|
-
clearTimeout(n),
|
|
182
|
-
|
|
183
|
-
},
|
|
297
|
+
return r?.isLoadingFn?.(!1), Object.assign((...s) => {
|
|
298
|
+
clearTimeout(n), r?.isLoadingFn?.(!0), n = setTimeout(() => {
|
|
299
|
+
r?.isLoadingFn?.(!1), e(...s);
|
|
300
|
+
}, t);
|
|
184
301
|
}, {
|
|
185
302
|
cancel() {
|
|
186
|
-
clearTimeout(n),
|
|
303
|
+
clearTimeout(n), r?.isLoadingFn?.(!1);
|
|
187
304
|
}
|
|
188
305
|
});
|
|
189
306
|
}
|
|
190
|
-
function
|
|
191
|
-
if (!
|
|
307
|
+
function Z(e, t) {
|
|
308
|
+
if (!t || typeof t != "string" || typeof e != "object" || e === null)
|
|
192
309
|
return;
|
|
193
|
-
const
|
|
310
|
+
const r = t.split(".");
|
|
194
311
|
function n(o, s) {
|
|
195
312
|
if (!s || typeof s != "object")
|
|
196
313
|
return;
|
|
@@ -198,7 +315,27 @@ function oe(t, r) {
|
|
|
198
315
|
if (a in s)
|
|
199
316
|
return o.length === 1 ? s[a] : n(o.slice(1), s[a]);
|
|
200
317
|
}
|
|
201
|
-
return n(
|
|
318
|
+
return n(r, e);
|
|
319
|
+
}
|
|
320
|
+
function K(e, t, r) {
|
|
321
|
+
let n = e;
|
|
322
|
+
for (let o = 0; o < t.length; o++) {
|
|
323
|
+
const s = t[o] ?? "";
|
|
324
|
+
o === t.length - 1 ? n[s] = r : ((!n[s] || typeof n[s] != "object") && (n[s] = {}), n = n[s]);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function ye(e, t) {
|
|
328
|
+
const r = {};
|
|
329
|
+
if (!e || typeof e != "object")
|
|
330
|
+
return r;
|
|
331
|
+
for (const n of t) {
|
|
332
|
+
const o = Z(e, n);
|
|
333
|
+
if (o !== void 0) {
|
|
334
|
+
const s = n.split(".");
|
|
335
|
+
K(r, s, o);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return r;
|
|
202
339
|
}
|
|
203
340
|
class m {
|
|
204
341
|
#e = null;
|
|
@@ -208,24 +345,24 @@ class m {
|
|
|
208
345
|
* @param {T} val - The success value.
|
|
209
346
|
* @returns {Result<T, never>} A Result instance representing a success.
|
|
210
347
|
*/
|
|
211
|
-
static ok(
|
|
212
|
-
return new m(
|
|
348
|
+
static ok(t) {
|
|
349
|
+
return new m(t, null);
|
|
213
350
|
}
|
|
214
351
|
/**
|
|
215
352
|
* Creates a failed result.
|
|
216
353
|
* @param {E | string} err - The error value or message.
|
|
217
354
|
* @returns {Result<never, E>} A Result instance representing a failure.
|
|
218
355
|
*/
|
|
219
|
-
static err(
|
|
220
|
-
return typeof
|
|
356
|
+
static err(t) {
|
|
357
|
+
return typeof t == "string" ? new m(null, new Error(t)) : new m(null, t);
|
|
221
358
|
}
|
|
222
359
|
/**
|
|
223
360
|
* Wraps a promise in a Result.
|
|
224
361
|
* @param {Promise<T>} promise - The promise to wrap.
|
|
225
362
|
* @returns {Promise<Result<T, E>>} A promise that resolves to a Result.
|
|
226
363
|
*/
|
|
227
|
-
static async promise(
|
|
228
|
-
return
|
|
364
|
+
static async promise(t) {
|
|
365
|
+
return t.then((r) => m.ok(r)).catch((r) => m.err(r));
|
|
229
366
|
}
|
|
230
367
|
/**
|
|
231
368
|
* Wraps a function call in a Result.
|
|
@@ -233,9 +370,9 @@ class m {
|
|
|
233
370
|
* @param {...any[]} args - The arguments to pass to the function.
|
|
234
371
|
* @returns {Result<T, E>} A Result instance representing the function call result.
|
|
235
372
|
*/
|
|
236
|
-
static func(
|
|
373
|
+
static func(t, ...r) {
|
|
237
374
|
try {
|
|
238
|
-
const n =
|
|
375
|
+
const n = t(...r);
|
|
239
376
|
return m.ok(n);
|
|
240
377
|
} catch (n) {
|
|
241
378
|
return m.err(n);
|
|
@@ -246,16 +383,16 @@ class m {
|
|
|
246
383
|
* @param {E | null} err - The error value.
|
|
247
384
|
* @throws {Error} If both ok and err are provided or neither is provided.
|
|
248
385
|
*/
|
|
249
|
-
constructor(
|
|
250
|
-
if (
|
|
386
|
+
constructor(t, r) {
|
|
387
|
+
if (t == null && r == null)
|
|
251
388
|
throw new Error(
|
|
252
389
|
"Result must be initialized with either an ok or an err value"
|
|
253
390
|
);
|
|
254
|
-
if (
|
|
391
|
+
if (t != null && r != null)
|
|
255
392
|
throw new Error(
|
|
256
393
|
"Result can't be initialized with both an ok and an err value"
|
|
257
394
|
);
|
|
258
|
-
|
|
395
|
+
t != null ? this.#e = t : this.#t = r;
|
|
259
396
|
}
|
|
260
397
|
/**
|
|
261
398
|
* Gets the success value, throwing an error if the result is a failure.
|
|
@@ -280,8 +417,8 @@ class m {
|
|
|
280
417
|
* @param {T} defaultValue - The default value to return if the result is a failure.
|
|
281
418
|
* @returns {T} The success value or the default value.
|
|
282
419
|
*/
|
|
283
|
-
unwrapOr(
|
|
284
|
-
return this.isOk() ? this.#e :
|
|
420
|
+
unwrapOr(t) {
|
|
421
|
+
return this.isOk() ? this.#e : t;
|
|
285
422
|
}
|
|
286
423
|
/**
|
|
287
424
|
* Gets the success value, throwing a custom error message if the result is a failure.
|
|
@@ -289,15 +426,15 @@ class m {
|
|
|
289
426
|
* @returns {T} The success value.
|
|
290
427
|
* @throws {Error} If the result is a failure.
|
|
291
428
|
*/
|
|
292
|
-
expect(
|
|
429
|
+
expect(t) {
|
|
293
430
|
if (this.isOk())
|
|
294
431
|
return this.#e;
|
|
295
432
|
if (this.isErr()) {
|
|
296
|
-
const
|
|
297
|
-
throw new Error(
|
|
298
|
-
` +
|
|
433
|
+
const r = this.#t;
|
|
434
|
+
throw new Error(t + `:
|
|
435
|
+
` + r.message);
|
|
299
436
|
}
|
|
300
|
-
throw new Error(
|
|
437
|
+
throw new Error(t);
|
|
301
438
|
}
|
|
302
439
|
/**
|
|
303
440
|
* Checks if the result is a success.
|
|
@@ -321,209 +458,209 @@ class m {
|
|
|
321
458
|
return this.#t;
|
|
322
459
|
}
|
|
323
460
|
}
|
|
324
|
-
function
|
|
325
|
-
return
|
|
461
|
+
function be(e, t = []) {
|
|
462
|
+
return e == null ? t : Array.isArray(e) ? e : [e];
|
|
326
463
|
}
|
|
327
|
-
const z = /* @__PURE__ */ Symbol("SIGNAL"),
|
|
328
|
-
const
|
|
464
|
+
const z = /* @__PURE__ */ Symbol("SIGNAL"), we = (e) => typeof e == "function" && z in e, g = [], Se = (e) => {
|
|
465
|
+
const t = g.splice(0, g.length);
|
|
329
466
|
try {
|
|
330
|
-
return
|
|
467
|
+
return e();
|
|
331
468
|
} finally {
|
|
332
|
-
|
|
469
|
+
g.push(...t);
|
|
333
470
|
}
|
|
334
|
-
},
|
|
335
|
-
const
|
|
471
|
+
}, R = (e, t) => {
|
|
472
|
+
const r = /* @__PURE__ */ new Set();
|
|
336
473
|
let n = 0;
|
|
337
474
|
const o = () => {
|
|
338
|
-
const l =
|
|
339
|
-
l && (
|
|
340
|
-
|
|
475
|
+
const l = g[g.length - 1];
|
|
476
|
+
l && (r.add(l.setDirty), l.addSource(() => {
|
|
477
|
+
r.delete(l.setDirty);
|
|
341
478
|
}));
|
|
342
479
|
}, s = (l) => {
|
|
343
|
-
for (const
|
|
480
|
+
for (const h of Array.from(r)) h(l);
|
|
344
481
|
}, a = () => n > 0;
|
|
345
|
-
return { read: Object.assign(() => (o(),
|
|
482
|
+
return { read: Object.assign(() => (o(), e()), {
|
|
346
483
|
[z]: !0,
|
|
347
|
-
subscribe: (l) => (
|
|
348
|
-
|
|
484
|
+
subscribe: (l) => (r.add(l), n++, t?.(), () => {
|
|
485
|
+
r.delete(l), n--;
|
|
349
486
|
})
|
|
350
487
|
}), notify: s, hasSubscribers: a };
|
|
351
|
-
}, S = (
|
|
352
|
-
let
|
|
353
|
-
const { read:
|
|
354
|
-
return Object.assign(
|
|
488
|
+
}, S = (e) => {
|
|
489
|
+
let t = e;
|
|
490
|
+
const { read: r, notify: n } = R(() => t);
|
|
491
|
+
return Object.assign(r, {
|
|
355
492
|
set: (o) => {
|
|
356
|
-
|
|
493
|
+
t !== o && (t = o, n(o));
|
|
357
494
|
},
|
|
358
495
|
update: (o) => {
|
|
359
|
-
const s = o(
|
|
360
|
-
|
|
496
|
+
const s = o(t);
|
|
497
|
+
t !== s && (t = s, n(s));
|
|
361
498
|
},
|
|
362
|
-
asReadonly: () =>
|
|
499
|
+
asReadonly: () => r
|
|
363
500
|
});
|
|
364
|
-
}, k = (
|
|
365
|
-
const
|
|
366
|
-
let
|
|
501
|
+
}, k = (e) => {
|
|
502
|
+
const t = /* @__PURE__ */ new Set();
|
|
503
|
+
let r = !1, n = null, o = !1;
|
|
367
504
|
const s = () => {
|
|
368
|
-
if (o = !1,
|
|
369
|
-
n && (n(), n = null),
|
|
505
|
+
if (o = !1, r) return;
|
|
506
|
+
n && (n(), n = null), t.forEach((i) => i()), t.clear();
|
|
370
507
|
const a = (i) => {
|
|
371
508
|
n = i;
|
|
372
509
|
};
|
|
373
|
-
|
|
510
|
+
g.push({
|
|
374
511
|
setDirty: () => {
|
|
375
|
-
!
|
|
512
|
+
!r && !o && (o = !0, queueMicrotask(s));
|
|
376
513
|
},
|
|
377
|
-
addSource: (i) =>
|
|
378
|
-
}),
|
|
514
|
+
addSource: (i) => t.add(i)
|
|
515
|
+
}), e(a), g.pop();
|
|
379
516
|
};
|
|
380
517
|
return s(), {
|
|
381
518
|
destroy() {
|
|
382
|
-
|
|
519
|
+
r = !0, n && (n(), n = null), t.forEach((a) => a()), t.clear();
|
|
383
520
|
}
|
|
384
521
|
};
|
|
385
|
-
},
|
|
386
|
-
const
|
|
387
|
-
let
|
|
522
|
+
}, j = (e) => {
|
|
523
|
+
const t = /* @__PURE__ */ new Set();
|
|
524
|
+
let r, n = !0, o = () => {
|
|
388
525
|
};
|
|
389
526
|
const s = () => {
|
|
390
|
-
|
|
527
|
+
t.forEach((c) => c()), t.clear(), g.push({
|
|
391
528
|
setDirty: () => {
|
|
392
529
|
if (n) return;
|
|
393
530
|
n = !0;
|
|
394
|
-
const c =
|
|
395
|
-
s(),
|
|
531
|
+
const c = r;
|
|
532
|
+
s(), r !== c && o(r);
|
|
396
533
|
},
|
|
397
|
-
addSource: (c) =>
|
|
398
|
-
}),
|
|
399
|
-
}, { read: a, notify: i } =
|
|
400
|
-
() => (n && s(),
|
|
534
|
+
addSource: (c) => t.add(c)
|
|
535
|
+
}), r = e(), n = !1, g.pop();
|
|
536
|
+
}, { read: a, notify: i } = R(
|
|
537
|
+
() => (n && s(), r),
|
|
401
538
|
() => {
|
|
402
539
|
n && s();
|
|
403
540
|
}
|
|
404
541
|
);
|
|
405
542
|
return o = i, a;
|
|
406
543
|
};
|
|
407
|
-
function
|
|
408
|
-
const
|
|
544
|
+
function Te(e) {
|
|
545
|
+
const t = typeof e == "function", r = t ? void 0 : e.source, n = t ? e : e.computation, o = /* @__PURE__ */ new Set();
|
|
409
546
|
let s, a = !0, i = !1, c, l = () => {
|
|
410
547
|
};
|
|
411
|
-
const
|
|
412
|
-
if (o.forEach((u) => u()), o.clear(),
|
|
548
|
+
const h = () => {
|
|
549
|
+
if (o.forEach((u) => u()), o.clear(), g.push({
|
|
413
550
|
setDirty: () => {
|
|
414
551
|
if (a) return;
|
|
415
552
|
a = !0, i = !1;
|
|
416
553
|
const u = s;
|
|
417
|
-
|
|
554
|
+
h(), s !== u && l(s);
|
|
418
555
|
},
|
|
419
556
|
addSource: (u) => o.add(u)
|
|
420
|
-
}),
|
|
557
|
+
}), t)
|
|
421
558
|
s = n();
|
|
422
559
|
else {
|
|
423
|
-
const u =
|
|
560
|
+
const u = r?.();
|
|
424
561
|
s = n(u, c), c = { source: u, value: s };
|
|
425
562
|
}
|
|
426
|
-
a = !1,
|
|
427
|
-
}, { read: v, notify:
|
|
428
|
-
() => (a && !i &&
|
|
563
|
+
a = !1, g.pop();
|
|
564
|
+
}, { read: v, notify: f } = R(
|
|
565
|
+
() => (a && !i && h(), s),
|
|
429
566
|
() => {
|
|
430
|
-
a && !i &&
|
|
567
|
+
a && !i && h();
|
|
431
568
|
}
|
|
432
569
|
);
|
|
433
|
-
l =
|
|
434
|
-
const
|
|
570
|
+
l = f;
|
|
571
|
+
const y = Object.assign(v, {
|
|
435
572
|
set: (u) => {
|
|
436
|
-
s !== u && (s = u, i = !0, a = !1,
|
|
573
|
+
s !== u && (s = u, i = !0, a = !1, f(u));
|
|
437
574
|
},
|
|
438
575
|
update: (u) => {
|
|
439
|
-
a && !i &&
|
|
576
|
+
a && !i && h(), y.set(u(s));
|
|
440
577
|
},
|
|
441
578
|
asReadonly: () => v
|
|
442
579
|
});
|
|
443
|
-
return
|
|
444
|
-
}
|
|
445
|
-
class
|
|
446
|
-
constructor(
|
|
447
|
-
const
|
|
448
|
-
${
|
|
449
|
-
super(`Cannot read resource value while in error state${
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
throw new
|
|
456
|
-
return
|
|
457
|
-
}), i = (
|
|
458
|
-
|
|
459
|
-
}, c = (
|
|
460
|
-
|
|
461
|
-
}, l = "params" in
|
|
462
|
-
if ("stream" in
|
|
463
|
-
const
|
|
580
|
+
return y;
|
|
581
|
+
}
|
|
582
|
+
class X extends Error {
|
|
583
|
+
constructor(t) {
|
|
584
|
+
const r = t instanceof Error ? `:
|
|
585
|
+
${t.message}` : "";
|
|
586
|
+
super(`Cannot read resource value while in error state${r}`, { cause: t }), this.name = "ResourceErrorState";
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function $e(e) {
|
|
590
|
+
const t = S(void 0), r = S("idle"), n = S(void 0), o = j(() => r() === "loading"), s = S(0), a = j(() => {
|
|
591
|
+
if (r() === "error")
|
|
592
|
+
throw new X(n());
|
|
593
|
+
return t();
|
|
594
|
+
}), i = (f) => {
|
|
595
|
+
t.set(f), n.set(void 0), r.set("resolved");
|
|
596
|
+
}, c = (f) => {
|
|
597
|
+
t.update(f), n.set(void 0), r.set("resolved");
|
|
598
|
+
}, l = "params" in e;
|
|
599
|
+
if ("stream" in e) {
|
|
600
|
+
const f = S(void 0), y = k((p) => {
|
|
464
601
|
s();
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
params:
|
|
471
|
-
abortSignal:
|
|
602
|
+
const d = new AbortController();
|
|
603
|
+
p(() => d.abort());
|
|
604
|
+
const H = l ? e.params() : void 0;
|
|
605
|
+
r.set("loading"), n.set(void 0);
|
|
606
|
+
const P = e.stream, G = P(l ? {
|
|
607
|
+
params: H,
|
|
608
|
+
abortSignal: d.signal
|
|
472
609
|
} : {
|
|
473
|
-
abortSignal:
|
|
610
|
+
abortSignal: d.signal
|
|
474
611
|
});
|
|
475
|
-
|
|
612
|
+
f.set(G);
|
|
476
613
|
}), u = k(() => {
|
|
477
|
-
const
|
|
478
|
-
if (!
|
|
479
|
-
const
|
|
480
|
-
|
|
614
|
+
const p = f();
|
|
615
|
+
if (!p) return;
|
|
616
|
+
const d = p();
|
|
617
|
+
d && ("error" in d && d.error !== void 0 ? (n.set(d.error), r.set("error")) : "value" in d && (t.set(d.value), r.set("resolved")));
|
|
481
618
|
});
|
|
482
619
|
return {
|
|
483
620
|
value: a,
|
|
484
|
-
status:
|
|
621
|
+
status: r,
|
|
485
622
|
error: n,
|
|
486
623
|
isLoading: o,
|
|
487
624
|
set: i,
|
|
488
625
|
update: c,
|
|
489
626
|
reload: () => {
|
|
490
|
-
s.update((
|
|
627
|
+
s.update((p) => p + 1);
|
|
491
628
|
},
|
|
492
629
|
destroy: () => {
|
|
493
|
-
|
|
630
|
+
y.destroy(), u.destroy();
|
|
494
631
|
}
|
|
495
632
|
};
|
|
496
633
|
}
|
|
497
|
-
const v = k((
|
|
634
|
+
const v = k((f) => {
|
|
498
635
|
s();
|
|
499
|
-
const
|
|
500
|
-
|
|
636
|
+
const y = l ? e.params() : void 0;
|
|
637
|
+
r.set("loading"), n.set(void 0);
|
|
501
638
|
const u = new AbortController();
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
(
|
|
506
|
-
u.signal.aborted || (
|
|
639
|
+
f(() => u.abort());
|
|
640
|
+
const p = l ? { params: y, abortSignal: u.signal } : { abortSignal: u.signal };
|
|
641
|
+
e.loader(p).then(
|
|
642
|
+
(d) => {
|
|
643
|
+
u.signal.aborted || (t.set(d), r.set("resolved"));
|
|
507
644
|
},
|
|
508
|
-
(
|
|
509
|
-
u.signal.aborted || (n.set(
|
|
645
|
+
(d) => {
|
|
646
|
+
u.signal.aborted || (n.set(d), r.set("error"));
|
|
510
647
|
}
|
|
511
648
|
);
|
|
512
649
|
});
|
|
513
650
|
return {
|
|
514
651
|
value: a,
|
|
515
|
-
status:
|
|
652
|
+
status: r,
|
|
516
653
|
error: n,
|
|
517
654
|
isLoading: o,
|
|
518
655
|
set: i,
|
|
519
656
|
update: c,
|
|
520
657
|
reload: () => {
|
|
521
|
-
s.update((
|
|
658
|
+
s.update((f) => f + 1);
|
|
522
659
|
},
|
|
523
660
|
destroy: () => v.destroy()
|
|
524
661
|
};
|
|
525
662
|
}
|
|
526
|
-
const
|
|
663
|
+
const L = /* @__PURE__ */ new Map([
|
|
527
664
|
["b", "b"],
|
|
528
665
|
["i", "i"],
|
|
529
666
|
["u", "u"],
|
|
@@ -560,325 +697,388 @@ const x = /* @__PURE__ */ new Map([
|
|
|
560
697
|
"h5",
|
|
561
698
|
"h6"
|
|
562
699
|
]);
|
|
563
|
-
let
|
|
564
|
-
function
|
|
565
|
-
return
|
|
700
|
+
let x = "rtp-";
|
|
701
|
+
function C() {
|
|
702
|
+
return x;
|
|
566
703
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
704
|
+
function Y(e) {
|
|
705
|
+
x = e;
|
|
569
706
|
}
|
|
570
|
-
const
|
|
707
|
+
const $ = /* @__PURE__ */ new Map([
|
|
571
708
|
["br", "br"],
|
|
572
709
|
["hr", "hr"]
|
|
573
|
-
])
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
[
|
|
590
|
-
"sup",
|
|
591
|
-
/* @__PURE__ */ new Map([
|
|
592
|
-
["vertical-align", "super"],
|
|
593
|
-
["font-size", "smaller"]
|
|
594
|
-
])
|
|
595
|
-
],
|
|
596
|
-
[
|
|
597
|
-
"h1",
|
|
598
|
-
/* @__PURE__ */ new Map([
|
|
599
|
-
["font-size", "2em"],
|
|
600
|
-
["font-weight", "bold"]
|
|
601
|
-
])
|
|
602
|
-
],
|
|
603
|
-
[
|
|
604
|
-
"h2",
|
|
605
|
-
/* @__PURE__ */ new Map([
|
|
606
|
-
["font-size", "1.5em"],
|
|
607
|
-
["font-weight", "bold"]
|
|
608
|
-
])
|
|
609
|
-
],
|
|
610
|
-
[
|
|
611
|
-
"h3",
|
|
612
|
-
/* @__PURE__ */ new Map([
|
|
613
|
-
["font-size", "1.17em"],
|
|
614
|
-
["font-weight", "bold"]
|
|
615
|
-
])
|
|
616
|
-
],
|
|
617
|
-
[
|
|
618
|
-
"h4",
|
|
619
|
-
/* @__PURE__ */ new Map([
|
|
620
|
-
["font-size", "1em"],
|
|
621
|
-
["font-weight", "bold"]
|
|
622
|
-
])
|
|
623
|
-
],
|
|
624
|
-
[
|
|
625
|
-
"h5",
|
|
626
|
-
/* @__PURE__ */ new Map([
|
|
627
|
-
["font-size", "0.83em"],
|
|
628
|
-
["font-weight", "bold"]
|
|
629
|
-
])
|
|
630
|
-
],
|
|
631
|
-
[
|
|
632
|
-
"h6",
|
|
633
|
-
/* @__PURE__ */ new Map([
|
|
634
|
-
["font-size", "0.67em"],
|
|
635
|
-
["font-weight", "bold"]
|
|
636
|
-
])
|
|
637
|
-
],
|
|
638
|
-
["code", /* @__PURE__ */ new Map([["font-family", "monospace"]])],
|
|
639
|
-
["p", /* @__PURE__ */ new Map([["margin-block", "1em"]])],
|
|
640
|
-
["div", /* @__PURE__ */ new Map([["display", "block"]])],
|
|
641
|
-
["ul", /* @__PURE__ */ new Map([["padding-left", "1.5em"]])],
|
|
642
|
-
["ol", /* @__PURE__ */ new Map([["padding-left", "1.5em"]])],
|
|
643
|
-
["li", /* @__PURE__ */ new Map([["margin-block", "0.5em"]])],
|
|
644
|
-
[
|
|
645
|
-
"br",
|
|
646
|
-
/* @__PURE__ */ new Map([
|
|
647
|
-
["display", "block"],
|
|
648
|
-
["height", "1em"]
|
|
649
|
-
])
|
|
650
|
-
],
|
|
651
|
-
[
|
|
652
|
-
"hr",
|
|
653
|
-
/* @__PURE__ */ new Map([
|
|
654
|
-
["display", "block"],
|
|
655
|
-
["border", "0"],
|
|
656
|
-
["border-top", "1px solid #ccc"],
|
|
657
|
-
["border-color", "green"],
|
|
658
|
-
["margin", "1em 0"]
|
|
659
|
-
])
|
|
660
|
-
]
|
|
661
|
-
]), M = (t, r, e, n, o) => {
|
|
662
|
-
const s = t.filter((i) => !T.has(i)), a = t.filter((i) => T.has(i));
|
|
710
|
+
]);
|
|
711
|
+
function W(e) {
|
|
712
|
+
const t = [];
|
|
713
|
+
let r;
|
|
714
|
+
for (const n of e) {
|
|
715
|
+
const o = n.containerTagNames.join(","), s = r?.containerTagNames.join(",");
|
|
716
|
+
o !== s && (r = {
|
|
717
|
+
containerTagNames: n.containerTagNames,
|
|
718
|
+
cssClass: n.containerTagNames.map((a) => `${C()}${a}`).join(" "),
|
|
719
|
+
segments: []
|
|
720
|
+
}, t.push(r)), r.segments.push(n);
|
|
721
|
+
}
|
|
722
|
+
return t;
|
|
723
|
+
}
|
|
724
|
+
const N = (e, t, r, n, o) => {
|
|
725
|
+
const s = e.filter((i) => !T.has(i)), a = e.filter((i) => T.has(i));
|
|
663
726
|
return {
|
|
664
|
-
tagNames:
|
|
665
|
-
tagNamesList:
|
|
666
|
-
text: o ??
|
|
667
|
-
style: s.map(
|
|
668
|
-
(i) => [...w.get(i)?.entries() ?? []].map(([c, l]) => `${c}: ${l}`).join("; ")
|
|
669
|
-
).filter(Boolean).join("; "),
|
|
670
|
-
styleObject: Object.fromEntries(
|
|
671
|
-
s.flatMap((i) => Array.from(w.get(i) ?? []))
|
|
672
|
-
),
|
|
727
|
+
tagNames: e.join(","),
|
|
728
|
+
tagNamesList: e,
|
|
729
|
+
text: o ?? t.slice(r, n),
|
|
673
730
|
containerTagNames: a,
|
|
674
|
-
cssClass: s.map((i) => `${
|
|
731
|
+
cssClass: s.map((i) => `${C()}${i}`).join(" ")
|
|
675
732
|
};
|
|
676
|
-
},
|
|
677
|
-
`<\\/?(${
|
|
733
|
+
}, Q = () => [...L.keys()].join("|"), ee = () => [...$.keys()].join("|"), te = () => new RegExp(
|
|
734
|
+
`<\\/?(${Q()})>|<(${ee()})\\s*/?>`,
|
|
678
735
|
"gi"
|
|
679
736
|
);
|
|
680
|
-
function
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (e.size === 0) continue;
|
|
688
|
-
const n = [...e.entries()].map(([o, s]) => ` ${o}: ${s};`).join(`
|
|
689
|
-
`);
|
|
690
|
-
t.push(`.${N()}${r} {
|
|
691
|
-
${n}
|
|
692
|
-
}`);
|
|
693
|
-
}
|
|
694
|
-
return t.join(`
|
|
695
|
-
`);
|
|
696
|
-
}
|
|
697
|
-
function q() {
|
|
698
|
-
if ("document" in globalThis) {
|
|
699
|
-
const t = R(), r = globalThis, e = r.document.getElementById(
|
|
700
|
-
"html-text-parser-styles"
|
|
737
|
+
function D(e) {
|
|
738
|
+
const t = [], r = /* @__PURE__ */ new Map();
|
|
739
|
+
let n = 0;
|
|
740
|
+
for (const o of e.matchAll(te())) {
|
|
741
|
+
const s = o.index;
|
|
742
|
+
s > n && t.push(
|
|
743
|
+
N([...r.keys()], e, n, s)
|
|
701
744
|
);
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
745
|
+
const a = o[2]?.toLowerCase();
|
|
746
|
+
if (a && $.has(a)) {
|
|
747
|
+
t.push(
|
|
748
|
+
N(
|
|
749
|
+
[...r.keys(), a],
|
|
750
|
+
e,
|
|
751
|
+
n,
|
|
752
|
+
s,
|
|
753
|
+
""
|
|
754
|
+
)
|
|
755
|
+
), n = s + o[0].length;
|
|
756
|
+
continue;
|
|
705
757
|
}
|
|
706
|
-
const
|
|
707
|
-
|
|
758
|
+
const i = o[0][1] === "/", c = L.get(o[1]?.toLowerCase() ?? "") ?? "";
|
|
759
|
+
if (i) {
|
|
760
|
+
const l = (r.get(c) ?? 1) - 1;
|
|
761
|
+
l <= 0 ? r.delete(c) : r.set(c, l);
|
|
762
|
+
} else
|
|
763
|
+
r.set(c, (r.get(c) ?? 0) + 1);
|
|
764
|
+
n = s + o[0].length;
|
|
765
|
+
}
|
|
766
|
+
return n < e.length && t.push(
|
|
767
|
+
N(
|
|
768
|
+
[...r.keys()],
|
|
769
|
+
e,
|
|
770
|
+
n,
|
|
771
|
+
e.length
|
|
772
|
+
)
|
|
773
|
+
), t;
|
|
774
|
+
}
|
|
775
|
+
function F(e) {
|
|
776
|
+
return W(e);
|
|
777
|
+
}
|
|
778
|
+
function A(e, t) {
|
|
779
|
+
e.className = `${C()}${t}`;
|
|
780
|
+
}
|
|
781
|
+
function re(e, t, r) {
|
|
782
|
+
const n = t.tagNamesList.filter((i) => !T.has(i)), o = n.filter((i) => $.has(i)), s = n.filter((i) => !$.has(i));
|
|
783
|
+
let a = e;
|
|
784
|
+
for (const i of s) {
|
|
785
|
+
const c = r.createElement(i);
|
|
786
|
+
A(c, i), a.appendChild(c), a = c;
|
|
787
|
+
}
|
|
788
|
+
if (t.text) {
|
|
789
|
+
a.appendChild(r.createTextNode(t.text));
|
|
708
790
|
return;
|
|
709
791
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
792
|
+
for (const i of o) {
|
|
793
|
+
const c = r.createElement(i);
|
|
794
|
+
A(c, i), a.appendChild(c);
|
|
795
|
+
}
|
|
713
796
|
}
|
|
714
|
-
function
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
)
|
|
730
|
-
segments: []
|
|
731
|
-
}, r.push(e)), e.segments.push(n);
|
|
797
|
+
function ne(e, t, r) {
|
|
798
|
+
const n = [];
|
|
799
|
+
for (const o of t) {
|
|
800
|
+
const s = o.containerTagNames;
|
|
801
|
+
let a = 0;
|
|
802
|
+
for (; a < n.length && a < s.length && n[a]?.tag === s[a]; )
|
|
803
|
+
a++;
|
|
804
|
+
n.length = a;
|
|
805
|
+
let i = n[n.length - 1]?.node ?? e;
|
|
806
|
+
for (const l of s.slice(a)) {
|
|
807
|
+
const h = r.createElement(l);
|
|
808
|
+
A(h, l), i.appendChild(h), n.push({ tag: l, node: h }), i = h;
|
|
809
|
+
}
|
|
810
|
+
const c = n[n.length - 1]?.node ?? e;
|
|
811
|
+
for (const l of o.segments)
|
|
812
|
+
re(c, l, r);
|
|
732
813
|
}
|
|
733
|
-
return r;
|
|
734
814
|
}
|
|
735
|
-
function
|
|
815
|
+
function se(e, t) {
|
|
736
816
|
if (!("document" in globalThis)) {
|
|
737
|
-
console.warn(
|
|
738
|
-
"[html-text-parser] Cannot append segments: document is not available."
|
|
739
|
-
);
|
|
817
|
+
console.warn("[html-text-parser] appendToDom: document is not available.");
|
|
740
818
|
return;
|
|
741
819
|
}
|
|
742
|
-
if (!
|
|
820
|
+
if (!e || !("appendChild" in e)) {
|
|
743
821
|
console.warn(
|
|
744
|
-
"[html-text-parser]
|
|
822
|
+
"[html-text-parser] appendToDom: element does not support appendChild."
|
|
745
823
|
);
|
|
746
824
|
return;
|
|
747
825
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
826
|
+
const r = globalThis.document, n = F(D(t));
|
|
827
|
+
ne(e, n, r);
|
|
828
|
+
}
|
|
829
|
+
const O = "html-text-parser-styles", I = {};
|
|
830
|
+
function M(e) {
|
|
831
|
+
const t = I;
|
|
832
|
+
return `
|
|
833
|
+
/* rtp = reach text parser */
|
|
834
|
+
|
|
835
|
+
.${e}b {
|
|
836
|
+
font-weight: bold;
|
|
837
|
+
${t.b ?? ""}
|
|
758
838
|
}
|
|
759
|
-
|
|
760
|
-
|
|
839
|
+
|
|
840
|
+
.${e}i {
|
|
841
|
+
font-style: italic;
|
|
842
|
+
${t.i ?? ""}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.${e}u {
|
|
846
|
+
text-decoration: underline;
|
|
847
|
+
${t.u ?? ""}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
.${e}s {
|
|
851
|
+
text-decoration: line-through;
|
|
852
|
+
${t.s ?? ""}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
.${e}mark {
|
|
856
|
+
background-color: yellow;
|
|
857
|
+
${t.mark ?? ""}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
.${e}small {
|
|
861
|
+
font-size: smaller;
|
|
862
|
+
${t.small ?? ""}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.${e}sup {
|
|
866
|
+
vertical-align: super;
|
|
867
|
+
font-size: smaller;
|
|
868
|
+
${t.sup ?? ""}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.${e}sub {
|
|
872
|
+
vertical-align: sub;
|
|
873
|
+
font-size: smaller;
|
|
874
|
+
${t.sub ?? ""}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.${e}h1 {
|
|
878
|
+
font-size: 2em;
|
|
879
|
+
font-weight: bold;
|
|
880
|
+
display: block;
|
|
881
|
+
${t.h1 ?? ""}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.${e}h2 {
|
|
885
|
+
font-size: 1.5em;
|
|
886
|
+
font-weight: bold;
|
|
887
|
+
display: block;
|
|
888
|
+
${t.h2 ?? ""}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.${e}h3 {
|
|
892
|
+
font-size: 1.17em;
|
|
893
|
+
font-weight: bold;
|
|
894
|
+
display: block;
|
|
895
|
+
${t.h3 ?? ""}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
.${e}h4 {
|
|
899
|
+
font-size: 1em;
|
|
900
|
+
font-weight: bold;
|
|
901
|
+
display: block;
|
|
902
|
+
${t.h4 ?? ""}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.${e}h5 {
|
|
906
|
+
font-size: 0.83em;
|
|
907
|
+
font-weight: bold;
|
|
908
|
+
display: block;
|
|
909
|
+
${t.h5 ?? ""}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
.${e}h6 {
|
|
913
|
+
font-size: 0.67em;
|
|
914
|
+
font-weight: bold;
|
|
915
|
+
display: block;
|
|
916
|
+
${t.h6 ?? ""}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.${e}code {
|
|
920
|
+
font-family: monospace;
|
|
921
|
+
${t.code ?? ""}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.${e}span {
|
|
925
|
+
${t.span ?? ""}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
.${e}p {
|
|
929
|
+
margin-block: 1em;
|
|
930
|
+
display: block;
|
|
931
|
+
${t.p ?? ""}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.${e}div {
|
|
935
|
+
display: block;
|
|
936
|
+
${t.div ?? ""}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
.${e}ul {
|
|
940
|
+
padding-left: 1.5em;
|
|
941
|
+
list-style: disc;
|
|
942
|
+
display: block;
|
|
943
|
+
${t.ul ?? ""}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
.${e}ol {
|
|
947
|
+
padding-left: 1.5em;
|
|
948
|
+
list-style: decimal;
|
|
949
|
+
display: block;
|
|
950
|
+
${t.ol ?? ""}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.${e}li {
|
|
954
|
+
margin-block: 0.5em;
|
|
955
|
+
display: list-item;
|
|
956
|
+
${t.li ?? ""}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.${e}br {
|
|
960
|
+
${t.br ?? ""}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.${e}hr {
|
|
964
|
+
${t.hr ?? ""}
|
|
965
|
+
}
|
|
966
|
+
`;
|
|
761
967
|
}
|
|
762
|
-
function
|
|
763
|
-
return
|
|
968
|
+
function oe() {
|
|
969
|
+
return M(C());
|
|
764
970
|
}
|
|
765
|
-
function
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
const s = o.index;
|
|
770
|
-
s > n && r.push(
|
|
771
|
-
M([...e.keys()], t, n, s)
|
|
971
|
+
function B() {
|
|
972
|
+
if (!("document" in globalThis)) {
|
|
973
|
+
console.warn(
|
|
974
|
+
"[html-text-parser] Cannot inject stylesheet: document is not available."
|
|
772
975
|
);
|
|
773
|
-
|
|
774
|
-
if (a && j.has(a)) {
|
|
775
|
-
r.push(
|
|
776
|
-
M(
|
|
777
|
-
[...e.keys(), a],
|
|
778
|
-
t,
|
|
779
|
-
n,
|
|
780
|
-
s,
|
|
781
|
-
""
|
|
782
|
-
)
|
|
783
|
-
), n = s + o[0].length;
|
|
784
|
-
continue;
|
|
785
|
-
}
|
|
786
|
-
const i = o[0][1] === "/", c = x.get(o[1]?.toLowerCase() ?? "") ?? "";
|
|
787
|
-
if (i) {
|
|
788
|
-
const l = (e.get(c) ?? 1) - 1;
|
|
789
|
-
l <= 0 ? e.delete(c) : e.set(c, l);
|
|
790
|
-
} else
|
|
791
|
-
e.set(c, (e.get(c) ?? 0) + 1);
|
|
792
|
-
n = s + o[0].length;
|
|
976
|
+
return;
|
|
793
977
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
978
|
+
const e = globalThis, t = e.document.getElementById(O), r = M(C());
|
|
979
|
+
if (t) {
|
|
980
|
+
t.textContent = r;
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
const n = e.document.createElement("style");
|
|
984
|
+
n.setAttribute("id", O), n.textContent = r, e.document.head.appendChild(n);
|
|
985
|
+
}
|
|
986
|
+
function ae(e) {
|
|
987
|
+
Object.assign(
|
|
988
|
+
I,
|
|
989
|
+
Object.fromEntries(
|
|
990
|
+
Object.entries(e).map(([t, r]) => [
|
|
991
|
+
t,
|
|
992
|
+
r.replace(/;/g, " !important;")
|
|
993
|
+
])
|
|
800
994
|
)
|
|
801
|
-
),
|
|
995
|
+
), "document" in globalThis && B();
|
|
802
996
|
}
|
|
803
|
-
function
|
|
804
|
-
if (Array.isArray(
|
|
805
|
-
|
|
806
|
-
B(e);
|
|
807
|
-
});
|
|
997
|
+
function _(e) {
|
|
998
|
+
if (Array.isArray(e)) {
|
|
999
|
+
e.forEach((r) => _(r));
|
|
808
1000
|
return;
|
|
809
1001
|
}
|
|
810
|
-
const
|
|
811
|
-
|
|
1002
|
+
const t = e.tagName ?? e.tag;
|
|
1003
|
+
L.set(e.tag, t);
|
|
812
1004
|
}
|
|
813
|
-
function
|
|
814
|
-
if (Array.isArray(
|
|
815
|
-
|
|
816
|
-
U(e);
|
|
817
|
-
});
|
|
1005
|
+
function q(e) {
|
|
1006
|
+
if (Array.isArray(e)) {
|
|
1007
|
+
e.forEach((r) => q(r));
|
|
818
1008
|
return;
|
|
819
1009
|
}
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1010
|
+
const t = e.tagName ?? e.tag;
|
|
1011
|
+
$.set(e.tag, t);
|
|
1012
|
+
}
|
|
1013
|
+
function ie(e) {
|
|
1014
|
+
T.add(e);
|
|
1015
|
+
}
|
|
1016
|
+
function ce(e) {
|
|
1017
|
+
T.delete(e);
|
|
1018
|
+
}
|
|
1019
|
+
const Ce = {
|
|
1020
|
+
appendToDom: se,
|
|
1021
|
+
parseSegments: D,
|
|
1022
|
+
groupSegments: F,
|
|
1023
|
+
setTag: _,
|
|
1024
|
+
setSelfClosingTag: q,
|
|
1025
|
+
setBlockTag: ie,
|
|
1026
|
+
removeBlockTag: ce,
|
|
1027
|
+
setCssClassPrefix: Y,
|
|
1028
|
+
getStylesheet: oe,
|
|
1029
|
+
generateStylesheet: B,
|
|
1030
|
+
overrideStyles: ae
|
|
1031
|
+
};
|
|
1032
|
+
function le(e, t, r) {
|
|
833
1033
|
function n(o) {
|
|
834
|
-
const [s, a] = E(() =>
|
|
835
|
-
if (a) throw new Error(`Error transforming value for ${
|
|
836
|
-
if (!
|
|
1034
|
+
const [s, a] = E(() => r ? r(o) : o);
|
|
1035
|
+
if (a) throw new Error(`Error transforming value for ${e}: ${a.message}`);
|
|
1036
|
+
if (!t(s)) throw new Error(`"${o}" is not a valid ${e}`);
|
|
837
1037
|
return s;
|
|
838
1038
|
}
|
|
839
1039
|
return n.from = (o) => {
|
|
840
|
-
const [s, a] = E(() =>
|
|
1040
|
+
const [s, a] = E(() => r ? r(o) : o);
|
|
841
1041
|
if (!a)
|
|
842
|
-
return
|
|
1042
|
+
return t(s) ? s : void 0;
|
|
843
1043
|
}, n.is = (o) => {
|
|
844
|
-
const s = E(() =>
|
|
845
|
-
return
|
|
1044
|
+
const s = E(() => r ? r(o) : o)[0] ?? o;
|
|
1045
|
+
return t(s);
|
|
846
1046
|
}, n;
|
|
847
1047
|
}
|
|
848
|
-
const
|
|
1048
|
+
const ve = le(
|
|
849
1049
|
"NumericString",
|
|
850
|
-
(
|
|
1050
|
+
(e) => (
|
|
851
1051
|
// checks that a given value is:
|
|
852
1052
|
// - a number, and the number is neither positive Infinity, negative Infinity, nor NaN.
|
|
853
|
-
typeof
|
|
1053
|
+
typeof e == "string" && e.trim() !== "" && Number.isFinite(Number(e))
|
|
854
1054
|
),
|
|
855
|
-
(
|
|
1055
|
+
(e) => String(e)
|
|
856
1056
|
);
|
|
857
1057
|
export {
|
|
858
|
-
fe as
|
|
1058
|
+
fe as Http,
|
|
1059
|
+
U as HttpCodeNames,
|
|
1060
|
+
ve as NumericString,
|
|
859
1061
|
m as Result,
|
|
860
1062
|
z as SIGNAL,
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
1063
|
+
pe as clamp,
|
|
1064
|
+
j as computed,
|
|
1065
|
+
ue as convertCase,
|
|
1066
|
+
le as createBrand,
|
|
1067
|
+
me as debounce,
|
|
1068
|
+
ge as delay,
|
|
867
1069
|
k as effect,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
B as setRichTextTag,
|
|
878
|
-
U as setSelfClosingTag,
|
|
1070
|
+
Z as getProp,
|
|
1071
|
+
he as groupBy,
|
|
1072
|
+
Ce as htmlTextParser,
|
|
1073
|
+
we as isSignal,
|
|
1074
|
+
Te as linkedSignal,
|
|
1075
|
+
V as normalizeString,
|
|
1076
|
+
ye as pickPaths,
|
|
1077
|
+
$e as resource,
|
|
1078
|
+
K as setDeepValue,
|
|
879
1079
|
S as signal,
|
|
880
|
-
|
|
1080
|
+
be as toArray,
|
|
881
1081
|
E as tryCatch,
|
|
882
|
-
|
|
883
|
-
|
|
1082
|
+
de as tryCatchAsync,
|
|
1083
|
+
Se as untracked
|
|
884
1084
|
};
|