gemi 0.1.0 → 0.1.2
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/bin/gemi +0 -0
- package/bin/gemi.ts +3 -0
- package/dist/client/Form.d.ts +5 -0
- package/dist/client/Form.d.ts.map +1 -0
- package/{client/index.ts → dist/client/index.d.ts} +1 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +38 -0
- package/dist/client/useRouter.d.ts +2 -0
- package/dist/client/useRouter.d.ts.map +1 -0
- package/dist/dev.js +1195 -0
- package/dist/http/ApiRouter.d.ts +3 -0
- package/dist/http/ApiRouter.d.ts.map +1 -0
- package/dist/http/Controller.d.ts +3 -0
- package/dist/http/Controller.d.ts.map +1 -0
- package/dist/http/ViewRouter.d.ts +3 -0
- package/dist/http/ViewRouter.d.ts.map +1 -0
- package/{http/index.ts → dist/http/index.d.ts} +1 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +33 -0
- package/dist/server/Server.d.ts +10 -0
- package/dist/server/Server.d.ts.map +1 -0
- package/dist/server/dev.d.ts +3 -0
- package/dist/server/dev.d.ts.map +1 -0
- package/{server/index.ts → dist/server/index.d.ts} +1 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +1195 -0
- package/package.json +15 -7
- package/.eslintrc.js +0 -10
- package/client/Form.tsx +0 -9
- package/client/useRouter.ts +0 -1
- package/http/ApiRouter.ts +0 -1
- package/http/Controller.ts +0 -1
- package/http/ViewRouter.ts +0 -1
- package/server/Server.ts +0 -42
- package/server/dev.ts +0 -176
- package/tsconfig.json +0 -10
- package/tsconfig.lint.json +0 -8
|
@@ -0,0 +1,1195 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
13
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
14
|
+
}) : x)(function(x) {
|
|
15
|
+
if (typeof require !== "undefined")
|
|
16
|
+
return require.apply(this, arguments);
|
|
17
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/urlpattern-polyfill/dist/urlpattern.js
|
|
21
|
+
var Re, v, D2, S, X, Z, k, F, J, Q, Ee, W, N, te, re, ne, se, ie, ae, oe, ce, _2, y2, le, fe, z2, j, K, he, ue, de, pe, ge, b2, w, C2, Oe, ke, R2, be, Pe, M, x, B, q2, ee, H, G, E2, me;
|
|
22
|
+
var init_urlpattern = __esm(() => {
|
|
23
|
+
Re = function(e, t) {
|
|
24
|
+
return (t ? /^[\x00-\xFF]*$/ : /^[\x00-\x7F]*$/).test(e);
|
|
25
|
+
};
|
|
26
|
+
v = function(e, t = false) {
|
|
27
|
+
let r = [], n = 0;
|
|
28
|
+
for (;n < e.length; ) {
|
|
29
|
+
let o = e[n], c = function(l) {
|
|
30
|
+
if (!t)
|
|
31
|
+
throw new TypeError(l);
|
|
32
|
+
r.push({ type: "INVALID_CHAR", index: n, value: e[n++] });
|
|
33
|
+
};
|
|
34
|
+
if (o === "*") {
|
|
35
|
+
r.push({ type: "ASTERISK", index: n, value: e[n++] });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (o === "+" || o === "?") {
|
|
39
|
+
r.push({ type: "OTHER_MODIFIER", index: n, value: e[n++] });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (o === "\\") {
|
|
43
|
+
r.push({ type: "ESCAPED_CHAR", index: n++, value: e[n++] });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (o === "{") {
|
|
47
|
+
r.push({ type: "OPEN", index: n, value: e[n++] });
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (o === "}") {
|
|
51
|
+
r.push({ type: "CLOSE", index: n, value: e[n++] });
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (o === ":") {
|
|
55
|
+
let l = "", s = n + 1;
|
|
56
|
+
for (;s < e.length; ) {
|
|
57
|
+
let i = e.substr(s, 1);
|
|
58
|
+
if (s === n + 1 && be.test(i) || s !== n + 1 && Pe.test(i)) {
|
|
59
|
+
l += e[s++];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (!l) {
|
|
65
|
+
c(`Missing parameter name at ${n}`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
r.push({ type: "NAME", index: n, value: l }), n = s;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (o === "(") {
|
|
72
|
+
let l = 1, s = "", i = n + 1, a = false;
|
|
73
|
+
if (e[i] === "?") {
|
|
74
|
+
c(`Pattern cannot start with "?" at ${i}`);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
for (;i < e.length; ) {
|
|
78
|
+
if (!Re(e[i], false)) {
|
|
79
|
+
c(`Invalid character '${e[i]}' at ${i}.`), a = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (e[i] === "\\") {
|
|
83
|
+
s += e[i++] + e[i++];
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (e[i] === ")") {
|
|
87
|
+
if (l--, l === 0) {
|
|
88
|
+
i++;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
} else if (e[i] === "(" && (l++, e[i + 1] !== "?")) {
|
|
92
|
+
c(`Capturing groups are not allowed at ${i}`), a = true;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
s += e[i++];
|
|
96
|
+
}
|
|
97
|
+
if (a)
|
|
98
|
+
continue;
|
|
99
|
+
if (l) {
|
|
100
|
+
c(`Unbalanced pattern at ${n}`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!s) {
|
|
104
|
+
c(`Missing pattern at ${n}`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
r.push({ type: "REGEX", index: n, value: s }), n = i;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
r.push({ type: "CHAR", index: n, value: e[n++] });
|
|
111
|
+
}
|
|
112
|
+
return r.push({ type: "END", index: n, value: "" }), r;
|
|
113
|
+
};
|
|
114
|
+
D2 = function(e, t = {}) {
|
|
115
|
+
let r = v(e);
|
|
116
|
+
t.delimiter ??= "/#?", t.prefixes ??= "./";
|
|
117
|
+
let n = `[^${S(t.delimiter)}]+?`, o = [], c = 0, l = 0, s = "", i = new Set, a = (h2) => {
|
|
118
|
+
if (l < r.length && r[l].type === h2)
|
|
119
|
+
return r[l++].value;
|
|
120
|
+
}, f = () => a("OTHER_MODIFIER") ?? a("ASTERISK"), d = (h2) => {
|
|
121
|
+
let u = a(h2);
|
|
122
|
+
if (u !== undefined)
|
|
123
|
+
return u;
|
|
124
|
+
let { type: p, index: A2 } = r[l];
|
|
125
|
+
throw new TypeError(`Unexpected ${p} at ${A2}, expected ${h2}`);
|
|
126
|
+
}, T2 = () => {
|
|
127
|
+
let h2 = "", u;
|
|
128
|
+
for (;u = a("CHAR") ?? a("ESCAPED_CHAR"); )
|
|
129
|
+
h2 += u;
|
|
130
|
+
return h2;
|
|
131
|
+
}, Se = (h2) => h2, L2 = t.encodePart || Se, I = "", U = (h2) => {
|
|
132
|
+
I += h2;
|
|
133
|
+
}, $ = () => {
|
|
134
|
+
I.length && (o.push(new R2(3, "", "", L2(I), "", 3)), I = "");
|
|
135
|
+
}, V = (h2, u, p, A2, Y) => {
|
|
136
|
+
let g = 3;
|
|
137
|
+
switch (Y) {
|
|
138
|
+
case "?":
|
|
139
|
+
g = 1;
|
|
140
|
+
break;
|
|
141
|
+
case "*":
|
|
142
|
+
g = 0;
|
|
143
|
+
break;
|
|
144
|
+
case "+":
|
|
145
|
+
g = 2;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
if (!u && !p && g === 3) {
|
|
149
|
+
U(h2);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if ($(), !u && !p) {
|
|
153
|
+
if (!h2)
|
|
154
|
+
return;
|
|
155
|
+
o.push(new R2(3, "", "", L2(h2), "", g));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let m2;
|
|
159
|
+
p ? p === "*" ? m2 = M : m2 = p : m2 = n;
|
|
160
|
+
let O = 2;
|
|
161
|
+
m2 === n ? (O = 1, m2 = "") : m2 === M && (O = 0, m2 = "");
|
|
162
|
+
let P;
|
|
163
|
+
if (u ? P = u : p && (P = c++), i.has(P))
|
|
164
|
+
throw new TypeError(`Duplicate name '${P}'.`);
|
|
165
|
+
i.add(P), o.push(new R2(O, P, L2(h2), m2, L2(A2), g));
|
|
166
|
+
};
|
|
167
|
+
for (;l < r.length; ) {
|
|
168
|
+
let h2 = a("CHAR"), u = a("NAME"), p = a("REGEX");
|
|
169
|
+
if (!u && !p && (p = a("ASTERISK")), u || p) {
|
|
170
|
+
let g = h2 ?? "";
|
|
171
|
+
t.prefixes.indexOf(g) === -1 && (U(g), g = ""), $();
|
|
172
|
+
let m2 = f();
|
|
173
|
+
V(g, u, p, "", m2);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
let A2 = h2 ?? a("ESCAPED_CHAR");
|
|
177
|
+
if (A2) {
|
|
178
|
+
U(A2);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (a("OPEN")) {
|
|
182
|
+
let g = T2(), m2 = a("NAME"), O = a("REGEX");
|
|
183
|
+
!m2 && !O && (O = a("ASTERISK"));
|
|
184
|
+
let P = T2();
|
|
185
|
+
d("CLOSE");
|
|
186
|
+
let xe = f();
|
|
187
|
+
V(g, m2, O, P, xe);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
$(), d("END");
|
|
191
|
+
}
|
|
192
|
+
return o;
|
|
193
|
+
};
|
|
194
|
+
S = function(e) {
|
|
195
|
+
return e.replace(/([.+*?^${}()[\]|/\\])/g, "\\$1");
|
|
196
|
+
};
|
|
197
|
+
X = function(e) {
|
|
198
|
+
return e && e.ignoreCase ? "ui" : "u";
|
|
199
|
+
};
|
|
200
|
+
Z = function(e, t, r) {
|
|
201
|
+
return F(D2(e, r), t, r);
|
|
202
|
+
};
|
|
203
|
+
k = function(e) {
|
|
204
|
+
switch (e) {
|
|
205
|
+
case 0:
|
|
206
|
+
return "*";
|
|
207
|
+
case 1:
|
|
208
|
+
return "?";
|
|
209
|
+
case 2:
|
|
210
|
+
return "+";
|
|
211
|
+
case 3:
|
|
212
|
+
return "";
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
F = function(e, t, r = {}) {
|
|
216
|
+
r.delimiter ??= "/#?", r.prefixes ??= "./", r.sensitive ??= false, r.strict ??= false, r.end ??= true, r.start ??= true, r.endsWith = "";
|
|
217
|
+
let n = r.start ? "^" : "";
|
|
218
|
+
for (let s of e) {
|
|
219
|
+
if (s.type === 3) {
|
|
220
|
+
s.modifier === 3 ? n += S(s.value) : n += `(?:${S(s.value)})${k(s.modifier)}`;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
t && t.push(s.name);
|
|
224
|
+
let i = `[^${S(r.delimiter)}]+?`, a = s.value;
|
|
225
|
+
if (s.type === 1 ? a = i : s.type === 0 && (a = M), !s.prefix.length && !s.suffix.length) {
|
|
226
|
+
s.modifier === 3 || s.modifier === 1 ? n += `(${a})${k(s.modifier)}` : n += `((?:${a})${k(s.modifier)})`;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (s.modifier === 3 || s.modifier === 1) {
|
|
230
|
+
n += `(?:${S(s.prefix)}(${a})${S(s.suffix)})`, n += k(s.modifier);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
n += `(?:${S(s.prefix)}`, n += `((?:${a})(?:`, n += S(s.suffix), n += S(s.prefix), n += `(?:${a}))*)${S(s.suffix)})`, s.modifier === 0 && (n += "?");
|
|
234
|
+
}
|
|
235
|
+
let o = `[${S(r.endsWith)}]|\$`, c = `[${S(r.delimiter)}]`;
|
|
236
|
+
if (r.end)
|
|
237
|
+
return r.strict || (n += `${c}?`), r.endsWith.length ? n += `(?=${o})` : n += "$", new RegExp(n, X(r));
|
|
238
|
+
r.strict || (n += `(?:${c}(?=${o}))?`);
|
|
239
|
+
let l = false;
|
|
240
|
+
if (e.length) {
|
|
241
|
+
let s = e[e.length - 1];
|
|
242
|
+
s.type === 3 && s.modifier === 3 && (l = r.delimiter.indexOf(s) > -1);
|
|
243
|
+
}
|
|
244
|
+
return l || (n += `(?=${c}|${o})`), new RegExp(n, X(r));
|
|
245
|
+
};
|
|
246
|
+
J = function(e, t) {
|
|
247
|
+
return e.length ? e[0] === "/" ? true : !t || e.length < 2 ? false : (e[0] == "\\" || e[0] == "{") && e[1] == "/" : false;
|
|
248
|
+
};
|
|
249
|
+
Q = function(e, t) {
|
|
250
|
+
return e.startsWith(t) ? e.substring(t.length, e.length) : e;
|
|
251
|
+
};
|
|
252
|
+
Ee = function(e, t) {
|
|
253
|
+
return e.endsWith(t) ? e.substr(0, e.length - t.length) : e;
|
|
254
|
+
};
|
|
255
|
+
W = function(e) {
|
|
256
|
+
return !e || e.length < 2 ? false : e[0] === "[" || (e[0] === "\\" || e[0] === "{") && e[1] === "[";
|
|
257
|
+
};
|
|
258
|
+
N = function(e) {
|
|
259
|
+
if (!e)
|
|
260
|
+
return true;
|
|
261
|
+
for (let t of ee)
|
|
262
|
+
if (e.test(t))
|
|
263
|
+
return true;
|
|
264
|
+
return false;
|
|
265
|
+
};
|
|
266
|
+
te = function(e, t) {
|
|
267
|
+
if (e = Q(e, "#"), t || e === "")
|
|
268
|
+
return e;
|
|
269
|
+
let r = new URL("https://example.com");
|
|
270
|
+
return r.hash = e, r.hash ? r.hash.substring(1, r.hash.length) : "";
|
|
271
|
+
};
|
|
272
|
+
re = function(e, t) {
|
|
273
|
+
if (e = Q(e, "?"), t || e === "")
|
|
274
|
+
return e;
|
|
275
|
+
let r = new URL("https://example.com");
|
|
276
|
+
return r.search = e, r.search ? r.search.substring(1, r.search.length) : "";
|
|
277
|
+
};
|
|
278
|
+
ne = function(e, t) {
|
|
279
|
+
return t || e === "" ? e : W(e) ? j(e) : z2(e);
|
|
280
|
+
};
|
|
281
|
+
se = function(e, t) {
|
|
282
|
+
if (t || e === "")
|
|
283
|
+
return e;
|
|
284
|
+
let r = new URL("https://example.com");
|
|
285
|
+
return r.password = e, r.password;
|
|
286
|
+
};
|
|
287
|
+
ie = function(e, t) {
|
|
288
|
+
if (t || e === "")
|
|
289
|
+
return e;
|
|
290
|
+
let r = new URL("https://example.com");
|
|
291
|
+
return r.username = e, r.username;
|
|
292
|
+
};
|
|
293
|
+
ae = function(e, t, r) {
|
|
294
|
+
if (r || e === "")
|
|
295
|
+
return e;
|
|
296
|
+
if (t && !ee.includes(t))
|
|
297
|
+
return new URL(`${t}:${e}`).pathname;
|
|
298
|
+
let n = e[0] == "/";
|
|
299
|
+
return e = new URL(n ? e : "/-" + e, "https://example.com").pathname, n || (e = e.substring(2, e.length)), e;
|
|
300
|
+
};
|
|
301
|
+
oe = function(e, t, r) {
|
|
302
|
+
return _2(t) === e && (e = ""), r || e === "" ? e : K(e);
|
|
303
|
+
};
|
|
304
|
+
ce = function(e, t) {
|
|
305
|
+
return e = Ee(e, ":"), t || e === "" ? e : y2(e);
|
|
306
|
+
};
|
|
307
|
+
_2 = function(e) {
|
|
308
|
+
switch (e) {
|
|
309
|
+
case "ws":
|
|
310
|
+
case "http":
|
|
311
|
+
return "80";
|
|
312
|
+
case "wws":
|
|
313
|
+
case "https":
|
|
314
|
+
return "443";
|
|
315
|
+
case "ftp":
|
|
316
|
+
return "21";
|
|
317
|
+
default:
|
|
318
|
+
return "";
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
y2 = function(e) {
|
|
322
|
+
if (e === "")
|
|
323
|
+
return e;
|
|
324
|
+
if (/^[-+.A-Za-z0-9]*$/.test(e))
|
|
325
|
+
return e.toLowerCase();
|
|
326
|
+
throw new TypeError(`Invalid protocol '${e}'.`);
|
|
327
|
+
};
|
|
328
|
+
le = function(e) {
|
|
329
|
+
if (e === "")
|
|
330
|
+
return e;
|
|
331
|
+
let t = new URL("https://example.com");
|
|
332
|
+
return t.username = e, t.username;
|
|
333
|
+
};
|
|
334
|
+
fe = function(e) {
|
|
335
|
+
if (e === "")
|
|
336
|
+
return e;
|
|
337
|
+
let t = new URL("https://example.com");
|
|
338
|
+
return t.password = e, t.password;
|
|
339
|
+
};
|
|
340
|
+
z2 = function(e) {
|
|
341
|
+
if (e === "")
|
|
342
|
+
return e;
|
|
343
|
+
if (/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))
|
|
344
|
+
throw new TypeError(`Invalid hostname '${e}'`);
|
|
345
|
+
let t = new URL("https://example.com");
|
|
346
|
+
return t.hostname = e, t.hostname;
|
|
347
|
+
};
|
|
348
|
+
j = function(e) {
|
|
349
|
+
if (e === "")
|
|
350
|
+
return e;
|
|
351
|
+
if (/[^0-9a-fA-F[\]:]/g.test(e))
|
|
352
|
+
throw new TypeError(`Invalid IPv6 hostname '${e}'`);
|
|
353
|
+
return e.toLowerCase();
|
|
354
|
+
};
|
|
355
|
+
K = function(e) {
|
|
356
|
+
if (e === "" || /^[0-9]*$/.test(e) && parseInt(e) <= 65535)
|
|
357
|
+
return e;
|
|
358
|
+
throw new TypeError(`Invalid port '${e}'.`);
|
|
359
|
+
};
|
|
360
|
+
he = function(e) {
|
|
361
|
+
if (e === "")
|
|
362
|
+
return e;
|
|
363
|
+
let t = new URL("https://example.com");
|
|
364
|
+
return t.pathname = e[0] !== "/" ? "/-" + e : e, e[0] !== "/" ? t.pathname.substring(2, t.pathname.length) : t.pathname;
|
|
365
|
+
};
|
|
366
|
+
ue = function(e) {
|
|
367
|
+
return e === "" ? e : new URL(`data:${e}`).pathname;
|
|
368
|
+
};
|
|
369
|
+
de = function(e) {
|
|
370
|
+
if (e === "")
|
|
371
|
+
return e;
|
|
372
|
+
let t = new URL("https://example.com");
|
|
373
|
+
return t.search = e, t.search.substring(1, t.search.length);
|
|
374
|
+
};
|
|
375
|
+
pe = function(e) {
|
|
376
|
+
if (e === "")
|
|
377
|
+
return e;
|
|
378
|
+
let t = new URL("https://example.com");
|
|
379
|
+
return t.hash = e, t.hash.substring(1, t.hash.length);
|
|
380
|
+
};
|
|
381
|
+
ge = function(e, t) {
|
|
382
|
+
if (typeof e != "string")
|
|
383
|
+
throw new TypeError("parameter 1 is not of type 'string'.");
|
|
384
|
+
let r = new URL(e, t);
|
|
385
|
+
return { protocol: r.protocol.substring(0, r.protocol.length - 1), username: r.username, password: r.password, hostname: r.hostname, port: r.port, pathname: r.pathname, search: r.search !== "" ? r.search.substring(1, r.search.length) : undefined, hash: r.hash !== "" ? r.hash.substring(1, r.hash.length) : undefined };
|
|
386
|
+
};
|
|
387
|
+
b2 = function(e, t) {
|
|
388
|
+
return t ? C2(e) : e;
|
|
389
|
+
};
|
|
390
|
+
w = function(e, t, r) {
|
|
391
|
+
let n;
|
|
392
|
+
if (typeof t.baseURL == "string")
|
|
393
|
+
try {
|
|
394
|
+
n = new URL(t.baseURL), t.protocol === undefined && (e.protocol = b2(n.protocol.substring(0, n.protocol.length - 1), r)), !r && t.protocol === undefined && t.hostname === undefined && t.port === undefined && t.username === undefined && (e.username = b2(n.username, r)), !r && t.protocol === undefined && t.hostname === undefined && t.port === undefined && t.username === undefined && t.password === undefined && (e.password = b2(n.password, r)), t.protocol === undefined && t.hostname === undefined && (e.hostname = b2(n.hostname, r)), t.protocol === undefined && t.hostname === undefined && t.port === undefined && (e.port = b2(n.port, r)), t.protocol === undefined && t.hostname === undefined && t.port === undefined && t.pathname === undefined && (e.pathname = b2(n.pathname, r)), t.protocol === undefined && t.hostname === undefined && t.port === undefined && t.pathname === undefined && t.search === undefined && (e.search = b2(n.search.substring(1, n.search.length), r)), t.protocol === undefined && t.hostname === undefined && t.port === undefined && t.pathname === undefined && t.search === undefined && t.hash === undefined && (e.hash = b2(n.hash.substring(1, n.hash.length), r));
|
|
395
|
+
} catch {
|
|
396
|
+
throw new TypeError(`invalid baseURL '${t.baseURL}'.`);
|
|
397
|
+
}
|
|
398
|
+
if (typeof t.protocol == "string" && (e.protocol = ce(t.protocol, r)), typeof t.username == "string" && (e.username = ie(t.username, r)), typeof t.password == "string" && (e.password = se(t.password, r)), typeof t.hostname == "string" && (e.hostname = ne(t.hostname, r)), typeof t.port == "string" && (e.port = oe(t.port, e.protocol, r)), typeof t.pathname == "string") {
|
|
399
|
+
if (e.pathname = t.pathname, n && !J(e.pathname, r)) {
|
|
400
|
+
let o = n.pathname.lastIndexOf("/");
|
|
401
|
+
o >= 0 && (e.pathname = b2(n.pathname.substring(0, o + 1), r) + e.pathname);
|
|
402
|
+
}
|
|
403
|
+
e.pathname = ae(e.pathname, e.protocol, r);
|
|
404
|
+
}
|
|
405
|
+
return typeof t.search == "string" && (e.search = re(t.search, r)), typeof t.hash == "string" && (e.hash = te(t.hash, r)), e;
|
|
406
|
+
};
|
|
407
|
+
C2 = function(e) {
|
|
408
|
+
return e.replace(/([+*?:{}()\\])/g, "\\$1");
|
|
409
|
+
};
|
|
410
|
+
Oe = function(e) {
|
|
411
|
+
return e.replace(/([.+*?^${}()[\]|/\\])/g, "\\$1");
|
|
412
|
+
};
|
|
413
|
+
ke = function(e, t) {
|
|
414
|
+
t.delimiter ??= "/#?", t.prefixes ??= "./", t.sensitive ??= false, t.strict ??= false, t.end ??= true, t.start ??= true, t.endsWith = "";
|
|
415
|
+
let r = ".*", n = `[^${Oe(t.delimiter)}]+?`, o = /[$_\u200C\u200D\p{ID_Continue}]/u, c = "";
|
|
416
|
+
for (let l = 0;l < e.length; ++l) {
|
|
417
|
+
let s = e[l];
|
|
418
|
+
if (s.type === 3) {
|
|
419
|
+
if (s.modifier === 3) {
|
|
420
|
+
c += C2(s.value);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
c += `{${C2(s.value)}}${k(s.modifier)}`;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
let i = s.hasCustomName(), a = !!s.suffix.length || !!s.prefix.length && (s.prefix.length !== 1 || !t.prefixes.includes(s.prefix)), f = l > 0 ? e[l - 1] : null, d = l < e.length - 1 ? e[l + 1] : null;
|
|
427
|
+
if (!a && i && s.type === 1 && s.modifier === 3 && d && !d.prefix.length && !d.suffix.length)
|
|
428
|
+
if (d.type === 3) {
|
|
429
|
+
let T2 = d.value.length > 0 ? d.value[0] : "";
|
|
430
|
+
a = o.test(T2);
|
|
431
|
+
} else
|
|
432
|
+
a = !d.hasCustomName();
|
|
433
|
+
if (!a && !s.prefix.length && f && f.type === 3) {
|
|
434
|
+
let T2 = f.value[f.value.length - 1];
|
|
435
|
+
a = t.prefixes.includes(T2);
|
|
436
|
+
}
|
|
437
|
+
a && (c += "{"), c += C2(s.prefix), i && (c += `:${s.name}`), s.type === 2 ? c += `(${s.value})` : s.type === 1 ? i || (c += `(${n})`) : s.type === 0 && (!i && (!f || f.type === 3 || f.modifier !== 3 || a || s.prefix !== "") ? c += "*" : c += `(${r})`), s.type === 1 && i && s.suffix.length && o.test(s.suffix[0]) && (c += "\\"), c += C2(s.suffix), a && (c += "}"), s.modifier !== 3 && (c += k(s.modifier));
|
|
438
|
+
}
|
|
439
|
+
return c;
|
|
440
|
+
};
|
|
441
|
+
R2 = class {
|
|
442
|
+
type = 3;
|
|
443
|
+
name = "";
|
|
444
|
+
prefix = "";
|
|
445
|
+
value = "";
|
|
446
|
+
suffix = "";
|
|
447
|
+
modifier = 3;
|
|
448
|
+
constructor(t, r, n, o, c, l) {
|
|
449
|
+
this.type = t, this.name = r, this.prefix = n, this.value = o, this.suffix = c, this.modifier = l;
|
|
450
|
+
}
|
|
451
|
+
hasCustomName() {
|
|
452
|
+
return this.name !== "" && typeof this.name != "number";
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
be = /[$_\p{ID_Start}]/u;
|
|
456
|
+
Pe = /[$_\u200C\u200D\p{ID_Continue}]/u;
|
|
457
|
+
M = ".*";
|
|
458
|
+
x = { delimiter: "", prefixes: "", sensitive: true, strict: true };
|
|
459
|
+
B = { delimiter: ".", prefixes: "", sensitive: true, strict: true };
|
|
460
|
+
q2 = { delimiter: "/", prefixes: "/", sensitive: true, strict: true };
|
|
461
|
+
ee = ["ftp", "file", "http", "https", "ws", "wss"];
|
|
462
|
+
H = class {
|
|
463
|
+
#i;
|
|
464
|
+
#n = [];
|
|
465
|
+
#t = {};
|
|
466
|
+
#e = 0;
|
|
467
|
+
#s = 1;
|
|
468
|
+
#l = 0;
|
|
469
|
+
#o = 0;
|
|
470
|
+
#d = 0;
|
|
471
|
+
#p = 0;
|
|
472
|
+
#g = false;
|
|
473
|
+
constructor(t) {
|
|
474
|
+
this.#i = t;
|
|
475
|
+
}
|
|
476
|
+
get result() {
|
|
477
|
+
return this.#t;
|
|
478
|
+
}
|
|
479
|
+
parse() {
|
|
480
|
+
for (this.#n = v(this.#i, true);this.#e < this.#n.length; this.#e += this.#s) {
|
|
481
|
+
if (this.#s = 1, this.#n[this.#e].type === "END") {
|
|
482
|
+
if (this.#o === 0) {
|
|
483
|
+
this.#b(), this.#f() ? this.#r(9, 1) : this.#h() ? this.#r(8, 1) : this.#r(7, 0);
|
|
484
|
+
continue;
|
|
485
|
+
} else if (this.#o === 2) {
|
|
486
|
+
this.#u(5);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
this.#r(10, 0);
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
if (this.#d > 0)
|
|
493
|
+
if (this.#A())
|
|
494
|
+
this.#d -= 1;
|
|
495
|
+
else
|
|
496
|
+
continue;
|
|
497
|
+
if (this.#T()) {
|
|
498
|
+
this.#d += 1;
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
switch (this.#o) {
|
|
502
|
+
case 0:
|
|
503
|
+
this.#P() && this.#u(1);
|
|
504
|
+
break;
|
|
505
|
+
case 1:
|
|
506
|
+
if (this.#P()) {
|
|
507
|
+
this.#C();
|
|
508
|
+
let t = 7, r = 1;
|
|
509
|
+
this.#E() ? (t = 2, r = 3) : this.#g && (t = 2), this.#r(t, r);
|
|
510
|
+
}
|
|
511
|
+
break;
|
|
512
|
+
case 2:
|
|
513
|
+
this.#S() ? this.#u(3) : (this.#x() || this.#h() || this.#f()) && this.#u(5);
|
|
514
|
+
break;
|
|
515
|
+
case 3:
|
|
516
|
+
this.#O() ? this.#r(4, 1) : this.#S() && this.#r(5, 1);
|
|
517
|
+
break;
|
|
518
|
+
case 4:
|
|
519
|
+
this.#S() && this.#r(5, 1);
|
|
520
|
+
break;
|
|
521
|
+
case 5:
|
|
522
|
+
this.#y() ? this.#p += 1 : this.#w() && (this.#p -= 1), this.#k() && !this.#p ? this.#r(6, 1) : this.#x() ? this.#r(7, 0) : this.#h() ? this.#r(8, 1) : this.#f() && this.#r(9, 1);
|
|
523
|
+
break;
|
|
524
|
+
case 6:
|
|
525
|
+
this.#x() ? this.#r(7, 0) : this.#h() ? this.#r(8, 1) : this.#f() && this.#r(9, 1);
|
|
526
|
+
break;
|
|
527
|
+
case 7:
|
|
528
|
+
this.#h() ? this.#r(8, 1) : this.#f() && this.#r(9, 1);
|
|
529
|
+
break;
|
|
530
|
+
case 8:
|
|
531
|
+
this.#f() && this.#r(9, 1);
|
|
532
|
+
break;
|
|
533
|
+
case 9:
|
|
534
|
+
break;
|
|
535
|
+
case 10:
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
this.#t.hostname !== undefined && this.#t.port === undefined && (this.#t.port = "");
|
|
540
|
+
}
|
|
541
|
+
#r(t, r) {
|
|
542
|
+
switch (this.#o) {
|
|
543
|
+
case 0:
|
|
544
|
+
break;
|
|
545
|
+
case 1:
|
|
546
|
+
this.#t.protocol = this.#c();
|
|
547
|
+
break;
|
|
548
|
+
case 2:
|
|
549
|
+
break;
|
|
550
|
+
case 3:
|
|
551
|
+
this.#t.username = this.#c();
|
|
552
|
+
break;
|
|
553
|
+
case 4:
|
|
554
|
+
this.#t.password = this.#c();
|
|
555
|
+
break;
|
|
556
|
+
case 5:
|
|
557
|
+
this.#t.hostname = this.#c();
|
|
558
|
+
break;
|
|
559
|
+
case 6:
|
|
560
|
+
this.#t.port = this.#c();
|
|
561
|
+
break;
|
|
562
|
+
case 7:
|
|
563
|
+
this.#t.pathname = this.#c();
|
|
564
|
+
break;
|
|
565
|
+
case 8:
|
|
566
|
+
this.#t.search = this.#c();
|
|
567
|
+
break;
|
|
568
|
+
case 9:
|
|
569
|
+
this.#t.hash = this.#c();
|
|
570
|
+
break;
|
|
571
|
+
case 10:
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
this.#o !== 0 && t !== 10 && ([1, 2, 3, 4].includes(this.#o) && [6, 7, 8, 9].includes(t) && (this.#t.hostname ??= ""), [1, 2, 3, 4, 5, 6].includes(this.#o) && [8, 9].includes(t) && (this.#t.pathname ??= this.#g ? "/" : ""), [1, 2, 3, 4, 5, 6, 7].includes(this.#o) && t === 9 && (this.#t.search ??= "")), this.#R(t, r);
|
|
575
|
+
}
|
|
576
|
+
#R(t, r) {
|
|
577
|
+
this.#o = t, this.#l = this.#e + r, this.#e += r, this.#s = 0;
|
|
578
|
+
}
|
|
579
|
+
#b() {
|
|
580
|
+
this.#e = this.#l, this.#s = 0;
|
|
581
|
+
}
|
|
582
|
+
#u(t) {
|
|
583
|
+
this.#b(), this.#o = t;
|
|
584
|
+
}
|
|
585
|
+
#m(t) {
|
|
586
|
+
return t < 0 && (t = this.#n.length - t), t < this.#n.length ? this.#n[t] : this.#n[this.#n.length - 1];
|
|
587
|
+
}
|
|
588
|
+
#a(t, r) {
|
|
589
|
+
let n = this.#m(t);
|
|
590
|
+
return n.value === r && (n.type === "CHAR" || n.type === "ESCAPED_CHAR" || n.type === "INVALID_CHAR");
|
|
591
|
+
}
|
|
592
|
+
#P() {
|
|
593
|
+
return this.#a(this.#e, ":");
|
|
594
|
+
}
|
|
595
|
+
#E() {
|
|
596
|
+
return this.#a(this.#e + 1, "/") && this.#a(this.#e + 2, "/");
|
|
597
|
+
}
|
|
598
|
+
#S() {
|
|
599
|
+
return this.#a(this.#e, "@");
|
|
600
|
+
}
|
|
601
|
+
#O() {
|
|
602
|
+
return this.#a(this.#e, ":");
|
|
603
|
+
}
|
|
604
|
+
#k() {
|
|
605
|
+
return this.#a(this.#e, ":");
|
|
606
|
+
}
|
|
607
|
+
#x() {
|
|
608
|
+
return this.#a(this.#e, "/");
|
|
609
|
+
}
|
|
610
|
+
#h() {
|
|
611
|
+
if (this.#a(this.#e, "?"))
|
|
612
|
+
return true;
|
|
613
|
+
if (this.#n[this.#e].value !== "?")
|
|
614
|
+
return false;
|
|
615
|
+
let t = this.#m(this.#e - 1);
|
|
616
|
+
return t.type !== "NAME" && t.type !== "REGEX" && t.type !== "CLOSE" && t.type !== "ASTERISK";
|
|
617
|
+
}
|
|
618
|
+
#f() {
|
|
619
|
+
return this.#a(this.#e, "#");
|
|
620
|
+
}
|
|
621
|
+
#T() {
|
|
622
|
+
return this.#n[this.#e].type == "OPEN";
|
|
623
|
+
}
|
|
624
|
+
#A() {
|
|
625
|
+
return this.#n[this.#e].type == "CLOSE";
|
|
626
|
+
}
|
|
627
|
+
#y() {
|
|
628
|
+
return this.#a(this.#e, "[");
|
|
629
|
+
}
|
|
630
|
+
#w() {
|
|
631
|
+
return this.#a(this.#e, "]");
|
|
632
|
+
}
|
|
633
|
+
#c() {
|
|
634
|
+
let t = this.#n[this.#e], r = this.#m(this.#l).index;
|
|
635
|
+
return this.#i.substring(r, t.index);
|
|
636
|
+
}
|
|
637
|
+
#C() {
|
|
638
|
+
let t = {};
|
|
639
|
+
Object.assign(t, x), t.encodePart = y2;
|
|
640
|
+
let r = Z(this.#c(), undefined, t);
|
|
641
|
+
this.#g = N(r);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
G = ["protocol", "username", "password", "hostname", "port", "pathname", "search", "hash"];
|
|
645
|
+
E2 = "*";
|
|
646
|
+
me = class {
|
|
647
|
+
#i;
|
|
648
|
+
#n = {};
|
|
649
|
+
#t = {};
|
|
650
|
+
#e = {};
|
|
651
|
+
#s = {};
|
|
652
|
+
#l = false;
|
|
653
|
+
constructor(t = {}, r, n) {
|
|
654
|
+
try {
|
|
655
|
+
let o;
|
|
656
|
+
if (typeof r == "string" ? o = r : n = r, typeof t == "string") {
|
|
657
|
+
let i = new H(t);
|
|
658
|
+
if (i.parse(), t = i.result, o === undefined && typeof t.protocol != "string")
|
|
659
|
+
throw new TypeError("A base URL must be provided for a relative constructor string.");
|
|
660
|
+
t.baseURL = o;
|
|
661
|
+
} else {
|
|
662
|
+
if (!t || typeof t != "object")
|
|
663
|
+
throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");
|
|
664
|
+
if (o)
|
|
665
|
+
throw new TypeError("parameter 1 is not of type 'string'.");
|
|
666
|
+
}
|
|
667
|
+
typeof n > "u" && (n = { ignoreCase: false });
|
|
668
|
+
let c = { ignoreCase: n.ignoreCase === true }, l = { pathname: E2, protocol: E2, username: E2, password: E2, hostname: E2, port: E2, search: E2, hash: E2 };
|
|
669
|
+
this.#i = w(l, t, true), _2(this.#i.protocol) === this.#i.port && (this.#i.port = "");
|
|
670
|
+
let s;
|
|
671
|
+
for (s of G) {
|
|
672
|
+
if (!(s in this.#i))
|
|
673
|
+
continue;
|
|
674
|
+
let i = {}, a = this.#i[s];
|
|
675
|
+
switch (this.#t[s] = [], s) {
|
|
676
|
+
case "protocol":
|
|
677
|
+
Object.assign(i, x), i.encodePart = y2;
|
|
678
|
+
break;
|
|
679
|
+
case "username":
|
|
680
|
+
Object.assign(i, x), i.encodePart = le;
|
|
681
|
+
break;
|
|
682
|
+
case "password":
|
|
683
|
+
Object.assign(i, x), i.encodePart = fe;
|
|
684
|
+
break;
|
|
685
|
+
case "hostname":
|
|
686
|
+
Object.assign(i, B), W(a) ? i.encodePart = j : i.encodePart = z2;
|
|
687
|
+
break;
|
|
688
|
+
case "port":
|
|
689
|
+
Object.assign(i, x), i.encodePart = K;
|
|
690
|
+
break;
|
|
691
|
+
case "pathname":
|
|
692
|
+
N(this.#n.protocol) ? (Object.assign(i, q2, c), i.encodePart = he) : (Object.assign(i, x, c), i.encodePart = ue);
|
|
693
|
+
break;
|
|
694
|
+
case "search":
|
|
695
|
+
Object.assign(i, x, c), i.encodePart = de;
|
|
696
|
+
break;
|
|
697
|
+
case "hash":
|
|
698
|
+
Object.assign(i, x, c), i.encodePart = pe;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
try {
|
|
702
|
+
this.#s[s] = D2(a, i), this.#n[s] = F(this.#s[s], this.#t[s], i), this.#e[s] = ke(this.#s[s], i), this.#l = this.#l || this.#s[s].some((f) => f.type === 2);
|
|
703
|
+
} catch {
|
|
704
|
+
throw new TypeError(`invalid ${s} pattern '${this.#i[s]}'.`);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
} catch (o) {
|
|
708
|
+
throw new TypeError(`Failed to construct 'URLPattern': ${o.message}`);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
test(t = {}, r) {
|
|
712
|
+
let n = { pathname: "", protocol: "", username: "", password: "", hostname: "", port: "", search: "", hash: "" };
|
|
713
|
+
if (typeof t != "string" && r)
|
|
714
|
+
throw new TypeError("parameter 1 is not of type 'string'.");
|
|
715
|
+
if (typeof t > "u")
|
|
716
|
+
return false;
|
|
717
|
+
try {
|
|
718
|
+
typeof t == "object" ? n = w(n, t, false) : n = w(n, ge(t, r), false);
|
|
719
|
+
} catch {
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
let o;
|
|
723
|
+
for (o of G)
|
|
724
|
+
if (!this.#n[o].exec(n[o]))
|
|
725
|
+
return false;
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
exec(t = {}, r) {
|
|
729
|
+
let n = { pathname: "", protocol: "", username: "", password: "", hostname: "", port: "", search: "", hash: "" };
|
|
730
|
+
if (typeof t != "string" && r)
|
|
731
|
+
throw new TypeError("parameter 1 is not of type 'string'.");
|
|
732
|
+
if (typeof t > "u")
|
|
733
|
+
return;
|
|
734
|
+
try {
|
|
735
|
+
typeof t == "object" ? n = w(n, t, false) : n = w(n, ge(t, r), false);
|
|
736
|
+
} catch {
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
let o = {};
|
|
740
|
+
r ? o.inputs = [t, r] : o.inputs = [t];
|
|
741
|
+
let c;
|
|
742
|
+
for (c of G) {
|
|
743
|
+
let l = this.#n[c].exec(n[c]);
|
|
744
|
+
if (!l)
|
|
745
|
+
return null;
|
|
746
|
+
let s = {};
|
|
747
|
+
for (let [i, a] of this.#t[c].entries())
|
|
748
|
+
if (typeof a == "string" || typeof a == "number") {
|
|
749
|
+
let f = l[i + 1];
|
|
750
|
+
s[a] = f;
|
|
751
|
+
}
|
|
752
|
+
o[c] = { input: n[c] ?? "", groups: s };
|
|
753
|
+
}
|
|
754
|
+
return o;
|
|
755
|
+
}
|
|
756
|
+
static compareComponent(t, r, n) {
|
|
757
|
+
let o = (i, a) => {
|
|
758
|
+
for (let f of ["type", "modifier", "prefix", "value", "suffix"]) {
|
|
759
|
+
if (i[f] < a[f])
|
|
760
|
+
return -1;
|
|
761
|
+
if (i[f] === a[f])
|
|
762
|
+
continue;
|
|
763
|
+
return 1;
|
|
764
|
+
}
|
|
765
|
+
return 0;
|
|
766
|
+
}, c = new R2(3, "", "", "", "", 3), l = new R2(0, "", "", "", "", 3), s = (i, a) => {
|
|
767
|
+
let f = 0;
|
|
768
|
+
for (;f < Math.min(i.length, a.length); ++f) {
|
|
769
|
+
let d = o(i[f], a[f]);
|
|
770
|
+
if (d)
|
|
771
|
+
return d;
|
|
772
|
+
}
|
|
773
|
+
return i.length === a.length ? 0 : o(i[f] ?? c, a[f] ?? c);
|
|
774
|
+
};
|
|
775
|
+
return !r.#e[t] && !n.#e[t] ? 0 : r.#e[t] && !n.#e[t] ? s(r.#s[t], [l]) : !r.#e[t] && n.#e[t] ? s([l], n.#s[t]) : s(r.#s[t], n.#s[t]);
|
|
776
|
+
}
|
|
777
|
+
get protocol() {
|
|
778
|
+
return this.#e.protocol;
|
|
779
|
+
}
|
|
780
|
+
get username() {
|
|
781
|
+
return this.#e.username;
|
|
782
|
+
}
|
|
783
|
+
get password() {
|
|
784
|
+
return this.#e.password;
|
|
785
|
+
}
|
|
786
|
+
get hostname() {
|
|
787
|
+
return this.#e.hostname;
|
|
788
|
+
}
|
|
789
|
+
get port() {
|
|
790
|
+
return this.#e.port;
|
|
791
|
+
}
|
|
792
|
+
get pathname() {
|
|
793
|
+
return this.#e.pathname;
|
|
794
|
+
}
|
|
795
|
+
get search() {
|
|
796
|
+
return this.#e.search;
|
|
797
|
+
}
|
|
798
|
+
get hash() {
|
|
799
|
+
return this.#e.hash;
|
|
800
|
+
}
|
|
801
|
+
get hasRegExpGroups() {
|
|
802
|
+
return this.#l;
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
// ../../node_modules/urlpattern-polyfill/index.js
|
|
808
|
+
var exports_urlpattern_polyfill = {};
|
|
809
|
+
__export(exports_urlpattern_polyfill, {
|
|
810
|
+
URLPattern: () => {
|
|
811
|
+
{
|
|
812
|
+
return me;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
var init_urlpattern_polyfill = __esm(() => {
|
|
817
|
+
init_urlpattern();
|
|
818
|
+
if (!globalThis.URLPattern) {
|
|
819
|
+
globalThis.URLPattern = me;
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
// server/dev.ts
|
|
824
|
+
import"react";
|
|
825
|
+
|
|
826
|
+
// node:path
|
|
827
|
+
var L = Object.create;
|
|
828
|
+
var b = Object.defineProperty;
|
|
829
|
+
var z = Object.getOwnPropertyDescriptor;
|
|
830
|
+
var D = Object.getOwnPropertyNames;
|
|
831
|
+
var T = Object.getPrototypeOf;
|
|
832
|
+
var R = Object.prototype.hasOwnProperty;
|
|
833
|
+
var _ = (f, e) => () => (e || f((e = { exports: {} }).exports, e), e.exports);
|
|
834
|
+
var E = (f, e) => {
|
|
835
|
+
for (var r in e)
|
|
836
|
+
b(f, r, { get: e[r], enumerable: true });
|
|
837
|
+
};
|
|
838
|
+
var C = (f, e, r, l) => {
|
|
839
|
+
if (e && typeof e == "object" || typeof e == "function")
|
|
840
|
+
for (let i of D(e))
|
|
841
|
+
!R.call(f, i) && i !== r && b(f, i, { get: () => e[i], enumerable: !(l = z(e, i)) || l.enumerable });
|
|
842
|
+
return f;
|
|
843
|
+
};
|
|
844
|
+
var A = (f, e, r) => (C(f, e, "default"), r && C(r, e, "default"));
|
|
845
|
+
var y = (f, e, r) => (r = f != null ? L(T(f)) : {}, C(e || !f || !f.__esModule ? b(r, "default", { value: f, enumerable: true }) : r, f));
|
|
846
|
+
var h = _((F, S) => {
|
|
847
|
+
function c(f) {
|
|
848
|
+
if (typeof f != "string")
|
|
849
|
+
throw new TypeError("Path must be a string. Received " + JSON.stringify(f));
|
|
850
|
+
}
|
|
851
|
+
function w(f, e) {
|
|
852
|
+
for (var r = "", l = 0, i = -1, s = 0, n, t = 0;t <= f.length; ++t) {
|
|
853
|
+
if (t < f.length)
|
|
854
|
+
n = f.charCodeAt(t);
|
|
855
|
+
else {
|
|
856
|
+
if (n === 47)
|
|
857
|
+
break;
|
|
858
|
+
n = 47;
|
|
859
|
+
}
|
|
860
|
+
if (n === 47) {
|
|
861
|
+
if (!(i === t - 1 || s === 1))
|
|
862
|
+
if (i !== t - 1 && s === 2) {
|
|
863
|
+
if (r.length < 2 || l !== 2 || r.charCodeAt(r.length - 1) !== 46 || r.charCodeAt(r.length - 2) !== 46) {
|
|
864
|
+
if (r.length > 2) {
|
|
865
|
+
var a = r.lastIndexOf("/");
|
|
866
|
+
if (a !== r.length - 1) {
|
|
867
|
+
a === -1 ? (r = "", l = 0) : (r = r.slice(0, a), l = r.length - 1 - r.lastIndexOf("/")), i = t, s = 0;
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
} else if (r.length === 2 || r.length === 1) {
|
|
871
|
+
r = "", l = 0, i = t, s = 0;
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
e && (r.length > 0 ? r += "/.." : r = "..", l = 2);
|
|
876
|
+
} else
|
|
877
|
+
r.length > 0 ? r += "/" + f.slice(i + 1, t) : r = f.slice(i + 1, t), l = t - i - 1;
|
|
878
|
+
i = t, s = 0;
|
|
879
|
+
} else
|
|
880
|
+
n === 46 && s !== -1 ? ++s : s = -1;
|
|
881
|
+
}
|
|
882
|
+
return r;
|
|
883
|
+
}
|
|
884
|
+
function J(f, e) {
|
|
885
|
+
var r = e.dir || e.root, l = e.base || (e.name || "") + (e.ext || "");
|
|
886
|
+
return r ? r === e.root ? r + l : r + f + l : l;
|
|
887
|
+
}
|
|
888
|
+
var g = { resolve: function() {
|
|
889
|
+
for (var e = "", r = false, l, i = arguments.length - 1;i >= -1 && !r; i--) {
|
|
890
|
+
var s;
|
|
891
|
+
i >= 0 ? s = arguments[i] : (l === undefined && (l = process.cwd()), s = l), c(s), s.length !== 0 && (e = s + "/" + e, r = s.charCodeAt(0) === 47);
|
|
892
|
+
}
|
|
893
|
+
return e = w(e, !r), r ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
|
|
894
|
+
}, normalize: function(e) {
|
|
895
|
+
if (c(e), e.length === 0)
|
|
896
|
+
return ".";
|
|
897
|
+
var r = e.charCodeAt(0) === 47, l = e.charCodeAt(e.length - 1) === 47;
|
|
898
|
+
return e = w(e, !r), e.length === 0 && !r && (e = "."), e.length > 0 && l && (e += "/"), r ? "/" + e : e;
|
|
899
|
+
}, isAbsolute: function(e) {
|
|
900
|
+
return c(e), e.length > 0 && e.charCodeAt(0) === 47;
|
|
901
|
+
}, join: function() {
|
|
902
|
+
if (arguments.length === 0)
|
|
903
|
+
return ".";
|
|
904
|
+
for (var e, r = 0;r < arguments.length; ++r) {
|
|
905
|
+
var l = arguments[r];
|
|
906
|
+
c(l), l.length > 0 && (e === undefined ? e = l : e += "/" + l);
|
|
907
|
+
}
|
|
908
|
+
return e === undefined ? "." : g.normalize(e);
|
|
909
|
+
}, relative: function(e, r) {
|
|
910
|
+
if (c(e), c(r), e === r || (e = g.resolve(e), r = g.resolve(r), e === r))
|
|
911
|
+
return "";
|
|
912
|
+
for (var l = 1;l < e.length && e.charCodeAt(l) === 47; ++l)
|
|
913
|
+
;
|
|
914
|
+
for (var i = e.length, s = i - l, n = 1;n < r.length && r.charCodeAt(n) === 47; ++n)
|
|
915
|
+
;
|
|
916
|
+
for (var t = r.length, a = t - n, v = s < a ? s : a, u = -1, o = 0;o <= v; ++o) {
|
|
917
|
+
if (o === v) {
|
|
918
|
+
if (a > v) {
|
|
919
|
+
if (r.charCodeAt(n + o) === 47)
|
|
920
|
+
return r.slice(n + o + 1);
|
|
921
|
+
if (o === 0)
|
|
922
|
+
return r.slice(n + o);
|
|
923
|
+
} else
|
|
924
|
+
s > v && (e.charCodeAt(l + o) === 47 ? u = o : o === 0 && (u = 0));
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
var k = e.charCodeAt(l + o), P = r.charCodeAt(n + o);
|
|
928
|
+
if (k !== P)
|
|
929
|
+
break;
|
|
930
|
+
k === 47 && (u = o);
|
|
931
|
+
}
|
|
932
|
+
var d = "";
|
|
933
|
+
for (o = l + u + 1;o <= i; ++o)
|
|
934
|
+
(o === i || e.charCodeAt(o) === 47) && (d.length === 0 ? d += ".." : d += "/..");
|
|
935
|
+
return d.length > 0 ? d + r.slice(n + u) : (n += u, r.charCodeAt(n) === 47 && ++n, r.slice(n));
|
|
936
|
+
}, _makeLong: function(e) {
|
|
937
|
+
return e;
|
|
938
|
+
}, dirname: function(e) {
|
|
939
|
+
if (c(e), e.length === 0)
|
|
940
|
+
return ".";
|
|
941
|
+
for (var r = e.charCodeAt(0), l = r === 47, i = -1, s = true, n = e.length - 1;n >= 1; --n)
|
|
942
|
+
if (r = e.charCodeAt(n), r === 47) {
|
|
943
|
+
if (!s) {
|
|
944
|
+
i = n;
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
} else
|
|
948
|
+
s = false;
|
|
949
|
+
return i === -1 ? l ? "/" : "." : l && i === 1 ? "//" : e.slice(0, i);
|
|
950
|
+
}, basename: function(e, r) {
|
|
951
|
+
if (r !== undefined && typeof r != "string")
|
|
952
|
+
throw new TypeError('"ext" argument must be a string');
|
|
953
|
+
c(e);
|
|
954
|
+
var l = 0, i = -1, s = true, n;
|
|
955
|
+
if (r !== undefined && r.length > 0 && r.length <= e.length) {
|
|
956
|
+
if (r.length === e.length && r === e)
|
|
957
|
+
return "";
|
|
958
|
+
var t = r.length - 1, a = -1;
|
|
959
|
+
for (n = e.length - 1;n >= 0; --n) {
|
|
960
|
+
var v = e.charCodeAt(n);
|
|
961
|
+
if (v === 47) {
|
|
962
|
+
if (!s) {
|
|
963
|
+
l = n + 1;
|
|
964
|
+
break;
|
|
965
|
+
}
|
|
966
|
+
} else
|
|
967
|
+
a === -1 && (s = false, a = n + 1), t >= 0 && (v === r.charCodeAt(t) ? --t === -1 && (i = n) : (t = -1, i = a));
|
|
968
|
+
}
|
|
969
|
+
return l === i ? i = a : i === -1 && (i = e.length), e.slice(l, i);
|
|
970
|
+
} else {
|
|
971
|
+
for (n = e.length - 1;n >= 0; --n)
|
|
972
|
+
if (e.charCodeAt(n) === 47) {
|
|
973
|
+
if (!s) {
|
|
974
|
+
l = n + 1;
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
} else
|
|
978
|
+
i === -1 && (s = false, i = n + 1);
|
|
979
|
+
return i === -1 ? "" : e.slice(l, i);
|
|
980
|
+
}
|
|
981
|
+
}, extname: function(e) {
|
|
982
|
+
c(e);
|
|
983
|
+
for (var r = -1, l = 0, i = -1, s = true, n = 0, t = e.length - 1;t >= 0; --t) {
|
|
984
|
+
var a = e.charCodeAt(t);
|
|
985
|
+
if (a === 47) {
|
|
986
|
+
if (!s) {
|
|
987
|
+
l = t + 1;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
continue;
|
|
991
|
+
}
|
|
992
|
+
i === -1 && (s = false, i = t + 1), a === 46 ? r === -1 ? r = t : n !== 1 && (n = 1) : r !== -1 && (n = -1);
|
|
993
|
+
}
|
|
994
|
+
return r === -1 || i === -1 || n === 0 || n === 1 && r === i - 1 && r === l + 1 ? "" : e.slice(r, i);
|
|
995
|
+
}, format: function(e) {
|
|
996
|
+
if (e === null || typeof e != "object")
|
|
997
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
|
|
998
|
+
return J("/", e);
|
|
999
|
+
}, parse: function(e) {
|
|
1000
|
+
c(e);
|
|
1001
|
+
var r = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
1002
|
+
if (e.length === 0)
|
|
1003
|
+
return r;
|
|
1004
|
+
var l = e.charCodeAt(0), i = l === 47, s;
|
|
1005
|
+
i ? (r.root = "/", s = 1) : s = 0;
|
|
1006
|
+
for (var n = -1, t = 0, a = -1, v = true, u = e.length - 1, o = 0;u >= s; --u) {
|
|
1007
|
+
if (l = e.charCodeAt(u), l === 47) {
|
|
1008
|
+
if (!v) {
|
|
1009
|
+
t = u + 1;
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
a === -1 && (v = false, a = u + 1), l === 46 ? n === -1 ? n = u : o !== 1 && (o = 1) : n !== -1 && (o = -1);
|
|
1015
|
+
}
|
|
1016
|
+
return n === -1 || a === -1 || o === 0 || o === 1 && n === a - 1 && n === t + 1 ? a !== -1 && (t === 0 && i ? r.base = r.name = e.slice(1, a) : r.base = r.name = e.slice(t, a)) : (t === 0 && i ? (r.name = e.slice(1, n), r.base = e.slice(1, a)) : (r.name = e.slice(t, n), r.base = e.slice(t, a)), r.ext = e.slice(n, a)), t > 0 ? r.dir = e.slice(0, t - 1) : i && (r.dir = "/"), r;
|
|
1017
|
+
}, sep: "/", delimiter: ":", win32: null, posix: null };
|
|
1018
|
+
g.posix = g;
|
|
1019
|
+
S.exports = g;
|
|
1020
|
+
});
|
|
1021
|
+
var m = {};
|
|
1022
|
+
E(m, { default: () => q });
|
|
1023
|
+
A(m, y(h()));
|
|
1024
|
+
var q = y(h());
|
|
1025
|
+
|
|
1026
|
+
// server/Server.ts
|
|
1027
|
+
class Server {
|
|
1028
|
+
urlPattern;
|
|
1029
|
+
requestHandlers = new Map;
|
|
1030
|
+
constructor(urlPattern) {
|
|
1031
|
+
this.urlPattern = urlPattern;
|
|
1032
|
+
}
|
|
1033
|
+
use(pattern, ...requestHandlers) {
|
|
1034
|
+
const requestHandler = requestHandlers.reverse().reduce((acc, handler) => {
|
|
1035
|
+
return (req) => handler(req, () => acc(req, () => new Response("404")));
|
|
1036
|
+
}, () => new Response("404", { status: 404 }));
|
|
1037
|
+
this.requestHandlers.set(pattern, requestHandler);
|
|
1038
|
+
}
|
|
1039
|
+
fetch(req) {
|
|
1040
|
+
const { pathname } = new URL(req.url);
|
|
1041
|
+
const handlerCandidates = [];
|
|
1042
|
+
for (const [p, rh] of this.requestHandlers.entries()) {
|
|
1043
|
+
const pattern = new this.urlPattern({ pathname: p });
|
|
1044
|
+
if (pattern.test({ pathname })) {
|
|
1045
|
+
handlerCandidates.push([p, rh]);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
const [, handler] = handlerCandidates.sort(([pa], [pb]) => pb.length - pa.length)[0];
|
|
1049
|
+
if (handler) {
|
|
1050
|
+
return handler(req, () => new Response("404"));
|
|
1051
|
+
} else {
|
|
1052
|
+
return new Response("404 not found", { status: 404 });
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// server/dev.ts
|
|
1058
|
+
import {createElement} from "react";
|
|
1059
|
+
import {renderToReadableStream} from "react-dom/server.browser";
|
|
1060
|
+
async function startDevServer() {
|
|
1061
|
+
console.log("Starting server...");
|
|
1062
|
+
const root = process.cwd();
|
|
1063
|
+
const { URLPattern } = await Promise.resolve().then(() => (init_urlpattern_polyfill(), exports_urlpattern_polyfill));
|
|
1064
|
+
const server2 = new Server(URLPattern);
|
|
1065
|
+
const vite = await (await import("vite")).createServer({
|
|
1066
|
+
root,
|
|
1067
|
+
logLevel: "error",
|
|
1068
|
+
server: {
|
|
1069
|
+
watch: {
|
|
1070
|
+
usePolling: true,
|
|
1071
|
+
interval: 100
|
|
1072
|
+
},
|
|
1073
|
+
hmr: {
|
|
1074
|
+
clientPort: 5174
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
appType: "custom",
|
|
1078
|
+
resolve: {
|
|
1079
|
+
alias: {
|
|
1080
|
+
"@/app": appDir,
|
|
1081
|
+
"@/framework": frameworkDir
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
const { app } = await vite.ssrLoadModule(q.join(rootDir, "app/bootstrap.ts"));
|
|
1086
|
+
vite.watcher.on("change", async (filePath) => {
|
|
1087
|
+
if (filePath.includes("/app/views")) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
const m2 = await vite.moduleGraph.getModuleByUrl(filePath, true);
|
|
1091
|
+
if (m2) {
|
|
1092
|
+
await vite.reloadModule(m2);
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
server2.use("*", async (req, next) => {
|
|
1096
|
+
const { pathname } = new URL(req.url);
|
|
1097
|
+
const res = await fetch(`http://localhost:5174/${pathname}`);
|
|
1098
|
+
if (res.ok) {
|
|
1099
|
+
return res;
|
|
1100
|
+
} else {
|
|
1101
|
+
return await next();
|
|
1102
|
+
}
|
|
1103
|
+
}, async (req) => {
|
|
1104
|
+
const styles = [];
|
|
1105
|
+
for (const [file, modules] of vite.moduleGraph.fileToModulesMap) {
|
|
1106
|
+
for (const mod of modules) {
|
|
1107
|
+
if (mod.file && mod.file.includes(".css") && !mod.file.includes("app.css")) {
|
|
1108
|
+
const { default: css } = await vite.ssrLoadModule(file);
|
|
1109
|
+
const currentFiles = styles.map((s) => s.file);
|
|
1110
|
+
if (currentFiles.includes(mod.file)) {
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
styles.push({
|
|
1114
|
+
file: mod.file,
|
|
1115
|
+
css
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
const result = await app.handleRequest(req);
|
|
1121
|
+
if (result.kind === "viewError") {
|
|
1122
|
+
const { kind, ...payload } = result;
|
|
1123
|
+
return new Response(null, {
|
|
1124
|
+
...payload
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
if (result.kind === "apiError") {
|
|
1128
|
+
const { kind, data, ...payload } = result;
|
|
1129
|
+
return new Response(JSON.stringify(data), {
|
|
1130
|
+
...payload
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
if (!result) {
|
|
1134
|
+
return new Response("Not found", { status: 404 });
|
|
1135
|
+
}
|
|
1136
|
+
const { default: Root } = await vite.ssrLoadModule("framework/Root.tsx");
|
|
1137
|
+
if (result.kind === "viewData") {
|
|
1138
|
+
const { data, headers, head } = result;
|
|
1139
|
+
return new Response(JSON.stringify({
|
|
1140
|
+
data,
|
|
1141
|
+
head
|
|
1142
|
+
}), {
|
|
1143
|
+
headers: {
|
|
1144
|
+
...headers,
|
|
1145
|
+
"Content-Type": "application/json"
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
if (result.kind === "view") {
|
|
1150
|
+
const { data, headers, head, status = 200 } = result;
|
|
1151
|
+
const stream = await renderToReadableStream(createElement(Root, { data, styles: [], head }), {
|
|
1152
|
+
bootstrapScriptContent: `window.__GEMI_DATA__ = ${JSON.stringify(data)};`,
|
|
1153
|
+
bootstrapModules: [
|
|
1154
|
+
"/framework/refresh.js",
|
|
1155
|
+
"/framework/main.tsx",
|
|
1156
|
+
"http://localhost:5173/@vite/client"
|
|
1157
|
+
]
|
|
1158
|
+
});
|
|
1159
|
+
return new Response(stream, {
|
|
1160
|
+
status,
|
|
1161
|
+
headers: { ...headers, "Content-Type": "text/html" }
|
|
1162
|
+
});
|
|
1163
|
+
} else if (result.kind === "api") {
|
|
1164
|
+
const { data, headers, status } = result;
|
|
1165
|
+
return new Response(JSON.stringify(data), {
|
|
1166
|
+
status,
|
|
1167
|
+
headers: {
|
|
1168
|
+
"Content-Type": "application/json",
|
|
1169
|
+
...headers
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
} else if (result.kind === "api_404") {
|
|
1173
|
+
return new Response("Not found", { status: 404 });
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
await vite.listen(5174);
|
|
1177
|
+
process.env.ROOT_DIR = rootDir;
|
|
1178
|
+
process.env.APP_DIR = appDir;
|
|
1179
|
+
Bun.serve({
|
|
1180
|
+
fetch: (req, s) => {
|
|
1181
|
+
if (s.upgrade(req)) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
return server2.fetch.call(server2, req);
|
|
1185
|
+
},
|
|
1186
|
+
port: process.env.PORT || 5173,
|
|
1187
|
+
websocket: app.websocket
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
var rootDir = process.cwd();
|
|
1191
|
+
var appDir = q.join(rootDir, "app");
|
|
1192
|
+
var frameworkDir = q.join(rootDir, "framework");
|
|
1193
|
+
export {
|
|
1194
|
+
startDevServer
|
|
1195
|
+
};
|