@prozilla-os/dev-tools 1.1.14 → 1.2.0

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.
@@ -0,0 +1,673 @@
1
+ import { resolve as h, basename as A, dirname as w } from "node:path";
2
+ import T from "@vitejs/plugin-react-swc";
3
+ import Z from "vite-plugin-dts";
4
+ import W from "vite-plugin-css-injected-by-js";
5
+ import G from "magic-string";
6
+ import { readFileSync as S, mkdirSync as K, writeFileSync as b, readdirSync as Q } from "node:fs";
7
+ import { createRequire as F } from "node:module";
8
+ import { isObject as k } from "@prozilla-os/shared/utils";
9
+ import { Logger as ee } from "@prozilla-os/shared";
10
+ const N = new ee();
11
+ function C(e) {
12
+ return e.replace(/\r\n/g, `
13
+ `);
14
+ }
15
+ function te(e) {
16
+ const { imageUrls: t, appsConfig: r, baseUrl: s } = e, n = /* @__PURE__ */ new Date(), o = n.getFullYear(), i = n.getMonth() + 1, a = n.getDate(), c = i >= 10 ? i.toString() : "0" + i, l = a >= 10 ? a.toString() : "0" + a, f = `${o}-${c}-${l}`, p = t.map(
17
+ (d) => `
18
+ <image:image>
19
+ <image:loc>${s.slice(0, -1) + d}</image:loc>
20
+ </image:image>`
21
+ ), m = r.apps.map(
22
+ ({ id: d }) => `
23
+ <url>
24
+ <loc>${s + d}</loc>
25
+ <lastmod>${f}</lastmod>
26
+ </url>`
27
+ ), u = `
28
+ <?xml version="1.0" encoding="UTF-8"?>
29
+ <!DOCTYPE xml>
30
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
31
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
32
+ <url>
33
+ <loc>${s}</loc>
34
+ <lastmod>${f}</lastmod>
35
+ ${p.join("")}
36
+ </url>
37
+ ${m.join("")}
38
+ </urlset>`;
39
+ return C(u.trim());
40
+ }
41
+ function ne(e) {
42
+ const { baseUrl: t } = e;
43
+ return C(`# https://www.robotstxt.org/robotstxt.html
44
+ User-agent: *
45
+ Disallow:
46
+ Sitemap: ${t}sitemap.xml`);
47
+ }
48
+ function se(e) {
49
+ return e.domain;
50
+ }
51
+ function re(e, t) {
52
+ const { baseUrl: r } = t, s = new RegExp('(?<=")https?:\\/\\/[a-z0-9-]+(\\.)([a-zA-Z0-9-]+(\\.))*[a-z]{2,3}\\/(?=.*")', "gi");
53
+ e = e.replaceAll(s, r);
54
+ const n = /<!--.*?-->/g;
55
+ e = e.replaceAll(n, "");
56
+ const o = /^\s*$\n/gm;
57
+ return e = e.replaceAll(o, ""), C(e);
58
+ }
59
+ function oe(e, t) {
60
+ e.emitFile({
61
+ type: "asset",
62
+ fileName: "404.html",
63
+ source: t
64
+ });
65
+ }
66
+ function ie(e, t, r) {
67
+ const { appsConfig: s, favicon: n, siteName: o, siteTagLine: i, baseUrl: a } = r;
68
+ for (const c of s.apps) {
69
+ const l = c.id, f = c.name, p = c.description ?? i, m = c.iconUrl ?? n;
70
+ if (l === "index") {
71
+ N.error(`Invalid app ID found: ${l}`);
72
+ return;
73
+ }
74
+ let u = t;
75
+ const d = new RegExp('(?<=(<title>|<meta property="og:title" content="|<meta name="twitter:title" content="))(([a-zA-Z|-]|\\s)+)(?=(<\\/title>|"\\/?>))', "g");
76
+ u = u.replaceAll(d, `${f} | ${o}`);
77
+ const g = new RegExp('(?<=(<meta name="description" content="|<meta property="og:description" content="|<meta name="twitter:description" content="))(([a-zA-Z-.]|\\s)+)(?=("\\/?>))', "g");
78
+ u = u.replaceAll(g, p);
79
+ const _ = new RegExp('(?<=(<link rel="canonical" href="|<meta name="twitter:url" content="|<meta property="og:url" content="))(http(s)?:\\/\\/[a-zA-Z-.]+\\/)(?=("\\/?>))', "g");
80
+ u = u.replaceAll(_, a + l);
81
+ const y = new RegExp('(?<=<link [^>]*rel="(apple-touch-)?icon" [^>]*href=")[^"]+(?="[^>]*>)', "g");
82
+ u = u.replaceAll(y, `${m}?x=${Math.round(Date.now() / 36e5)}`);
83
+ const E = /(<!-- FAQ -->.*?)?<script type="application\/ld\+json">.*?<\/script>/gs;
84
+ u = u.replaceAll(E, ""), e.emitFile({
85
+ type: "asset",
86
+ fileName: `${l}.html`,
87
+ source: u
88
+ });
89
+ }
90
+ }
91
+ function ce(e, t, { appsConfig: r, favicon: s, siteName: n, siteTagLine: o, domain: i, imageUrls: a = [] }) {
92
+ try {
93
+ N.pending("Staging build...");
94
+ const c = `https://${i}/`, l = {
95
+ sitemapXml: "sitemap.xml",
96
+ robotsTxt: "robots.txt",
97
+ indexHtml: "index.html",
98
+ cname: "CNAME"
99
+ }, f = [
100
+ [l.sitemapXml, te],
101
+ [l.robotsTxt, ne],
102
+ [l.cname, se]
103
+ ], p = {
104
+ appsConfig: r,
105
+ favicon: s,
106
+ siteName: n,
107
+ siteTagLine: o,
108
+ domain: i,
109
+ baseUrl: c,
110
+ imageUrls: a,
111
+ paths: l
112
+ };
113
+ if (f.forEach(([m, u]) => {
114
+ e.emitFile({
115
+ type: "asset",
116
+ fileName: m,
117
+ source: u(p)
118
+ });
119
+ }), t != null) {
120
+ const m = re(t, p);
121
+ e.emitFile({
122
+ type: "asset",
123
+ fileName: "index.html",
124
+ source: m
125
+ }), oe(e, m), ie(e, m, p);
126
+ }
127
+ N.success("Staging complete");
128
+ } catch (c) {
129
+ N.error(c).error("Staging failed"), process.exit(1);
130
+ }
131
+ }
132
+ function ae(e) {
133
+ let t = null;
134
+ return {
135
+ name: "vite-plugin-stage-site",
136
+ transformIndexHtml(r) {
137
+ t = r;
138
+ },
139
+ generateBundle() {
140
+ ce(this, t, e);
141
+ }
142
+ };
143
+ }
144
+ function le({ entryPath: e, appClass: t = "App" }) {
145
+ return {
146
+ name: "vite-plugin-app-metadata",
147
+ apply: "build",
148
+ transform(r, s) {
149
+ if (!s.includes(e)) return null;
150
+ const n = process.cwd(), o = h(n, "package.json");
151
+ let i = null;
152
+ try {
153
+ const E = S(o, "utf-8");
154
+ i = JSON.parse(E);
155
+ } catch (E) {
156
+ this.error(E);
157
+ }
158
+ if (i === null) return null;
159
+ const { name: a, version: c, homepage: l } = i;
160
+ let { author: f = "Unknown" } = i;
161
+ typeof f == "string" ? f = f.replace(/<[^>]*>|\([^)]*\)/g, "").trim() : f = f.name;
162
+ const p = new RegExp(`const\\s+(\\w+)\\s*=\\s*new\\s+${t}(?:<[\\w\\s,]+>)?\\s*\\(([^;]*)\\)\\s*(\\.[\\w]+\\([^)]*\\)\\s*)*;`), m = r.match(p);
163
+ if (m == null || m.index == null)
164
+ return this.error("No App instance found in the entry file.");
165
+ const u = m[1], d = [`name: "${a}"`, `version: "${c}"`, `author: "${f}"`];
166
+ l && d.push(`website: "${l}"`);
167
+ const g = `
168
+ ${u}.setMetadata({ ${d.join(", ")} });
169
+ `, _ = m.index + m[0].length, y = new G(r);
170
+ return y.appendLeft(_, g), {
171
+ code: y.toString(),
172
+ map: y.generateMap({ hires: !0 })
173
+ };
174
+ }
175
+ };
176
+ }
177
+ const M = "@prozilla-os/", U = /* @__PURE__ */ new Set(["react", "react-dom", "react/jsx-runtime"]);
178
+ function R(e) {
179
+ try {
180
+ const t = S(h(e, "package.json"), "utf-8"), r = JSON.parse(t);
181
+ if (!k(r))
182
+ return null;
183
+ const s = {};
184
+ return j(r.dependencies) && (s.dependencies = r.dependencies), j(r.peerDependencies) && (s.peerDependencies = r.peerDependencies), s.exports = r.exports, s.module = typeof r.module == "string" ? r.module : void 0, s.main = typeof r.main == "string" ? r.main : void 0, s;
185
+ } catch {
186
+ return null;
187
+ }
188
+ }
189
+ function j(e) {
190
+ return k(e) && Object.values(e).every((t) => typeof t == "string");
191
+ }
192
+ function $(e) {
193
+ return [
194
+ ...Object.keys(e.dependencies ?? {}),
195
+ ...Object.keys(e.peerDependencies ?? {})
196
+ ];
197
+ }
198
+ function ue(e) {
199
+ const t = R(e);
200
+ if (t == null)
201
+ return [];
202
+ const r = $(t), s = new Set(U);
203
+ for (const n of r)
204
+ n.startsWith(M) && s.add(n);
205
+ return Array.from(s);
206
+ }
207
+ function Qe(e) {
208
+ const {
209
+ entryPath: t,
210
+ appClass: r,
211
+ tsconfigPath: s = "tsconfig.build.json",
212
+ sharedPackages: n,
213
+ externalPatterns: o = []
214
+ } = e;
215
+ return [
216
+ le({ entryPath: t, appClass: r }),
217
+ T(),
218
+ W(),
219
+ Z({
220
+ outDir: "dist",
221
+ rollupTypes: !0,
222
+ strictOutput: !0,
223
+ pathsToAliases: !1,
224
+ tsconfigPath: s
225
+ }),
226
+ {
227
+ name: "prozilla-os-app",
228
+ config(i) {
229
+ const a = i.root ?? process.cwd(), c = h(a, t), l = n ?? ue(a);
230
+ return {
231
+ build: {
232
+ lib: {
233
+ entry: c,
234
+ formats: ["es"]
235
+ },
236
+ rollupOptions: {
237
+ external: [
238
+ ...l,
239
+ ...o
240
+ ],
241
+ output: {
242
+ assetFileNames: "assets/[name][extname]",
243
+ chunkFileNames: "chunks/[name]-[hash].js",
244
+ entryFileNames: "[name].js"
245
+ }
246
+ },
247
+ sourcemap: !0
248
+ }
249
+ };
250
+ }
251
+ }
252
+ ];
253
+ }
254
+ const L = "/__shim/", pe = "/__shared/", x = "assets", H = "__shim", me = "/node_modules/.vite/deps/", fe = "IMPORT_MAP_PLACEHOLDER_", de = "script", he = "importmap", ge = /^\/__shim\/(.+)\.js$/, _e = /^\/__shared\/(.+)\.js$/, J = /["']((\.\.?\/)[^"']+)["']/g, ye = '"production"', Ee = '"development"', z = /process\.env\.NODE_ENV/g, Pe = "/node_modules/", Se = /* @__PURE__ */ new Map([
255
+ ["react", { chunkName: "react", isCommonJS: !0 }],
256
+ ["react/jsx-runtime", { chunkName: "react-jsx-runtime", isCommonJS: !0 }],
257
+ ["react-dom", { chunkName: "react-dom", isCommonJS: !0 }]
258
+ ]), ke = ["module", "import", "default"], Ne = 3, Re = /* @__PURE__ */ new Set(["__esModule", "default"]);
259
+ function Ae(e = {}) {
260
+ const { sharedPackages: t, devImports: r = {} } = e;
261
+ let s = !1, n = "";
262
+ const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = [], c = t ?? [], l = {
263
+ shimEntries: O(c),
264
+ chunkPatterns: I(c),
265
+ nonChunkEntries: D(c)
266
+ }, f = {};
267
+ return {
268
+ name: "import-map",
269
+ configResolved(p) {
270
+ if (s = p.command === "serve", n = p.root, t != null)
271
+ return;
272
+ const m = He(n);
273
+ c.length = 0, c.push(...m), l.shimEntries = O(c), l.chunkPatterns = I(c), l.nonChunkEntries = D(c);
274
+ },
275
+ config(p, m) {
276
+ const u = Ue(p.build?.rollupOptions?.output), d = p.optimizeDeps?.include ?? [], g = u.map((_) => ({
277
+ ..._,
278
+ manualChunks: (y, E) => {
279
+ if (typeof _.manualChunks == "function") {
280
+ const P = _.manualChunks(y, E);
281
+ if (P)
282
+ return P;
283
+ }
284
+ return Me(y, l.chunkPatterns);
285
+ }
286
+ }));
287
+ return {
288
+ optimizeDeps: {
289
+ include: [.../* @__PURE__ */ new Set([
290
+ ...d,
291
+ ...l.shimEntries.map((_) => _.specifier)
292
+ ])]
293
+ },
294
+ build: {
295
+ rollupOptions: {
296
+ output: g
297
+ }
298
+ }
299
+ };
300
+ },
301
+ async configureServer(p) {
302
+ await Oe(p, l.nonChunkEntries, i, n), p.middlewares.use((m, u, d) => {
303
+ ze(
304
+ m,
305
+ u,
306
+ n,
307
+ l.nonChunkEntries,
308
+ p
309
+ ).then((g) => {
310
+ g || Je(
311
+ m,
312
+ u,
313
+ d,
314
+ n,
315
+ l.shimEntries,
316
+ f
317
+ );
318
+ }).catch(() => {
319
+ d();
320
+ });
321
+ });
322
+ },
323
+ transformIndexHtml() {
324
+ return [
325
+ ve(s ? $e(r, l, i) : Ce(c))
326
+ ];
327
+ },
328
+ generateBundle(p, m) {
329
+ a.length = 0, Ie(c, m, o), De(c, o, l.shimEntries, n, p.dir, a, f);
330
+ for (const u of c) {
331
+ if (u.chunkName)
332
+ continue;
333
+ const d = q(u.specifier, n), g = Te(d);
334
+ for (const P of g.filePaths)
335
+ P !== d && this.emitFile({
336
+ type: "asset",
337
+ name: A(P),
338
+ source: g.codeByPath.get(P)
339
+ });
340
+ const _ = this.emitFile({
341
+ type: "asset",
342
+ name: g.entryAssetName,
343
+ source: g.codeByPath.get(d)
344
+ }), E = "/" + this.getFileName(_).replace(/\\/g, "/");
345
+ o.set(u.specifier, E);
346
+ }
347
+ },
348
+ writeBundle(p) {
349
+ if (s || !p.dir)
350
+ return;
351
+ je(a, p.dir);
352
+ const m = we(c, o, l.shimEntries);
353
+ xe(p.dir, m);
354
+ }
355
+ };
356
+ }
357
+ function $e(e, t, r) {
358
+ const s = { ...e };
359
+ for (const n of t.shimEntries)
360
+ s[n.specifier] = `${L}${n.urlName}.js`;
361
+ for (const n of t.nonChunkEntries) {
362
+ const o = r.get(n.specifier);
363
+ s[n.specifier] = o ?? `${pe}${n.urlName}.js`;
364
+ }
365
+ return s;
366
+ }
367
+ function Ce(e) {
368
+ const t = {};
369
+ for (const r of e)
370
+ t[r.specifier] = B(r.specifier);
371
+ return t;
372
+ }
373
+ function ve(e) {
374
+ return {
375
+ tag: de,
376
+ attrs: { type: he },
377
+ children: JSON.stringify({ imports: e })
378
+ };
379
+ }
380
+ function we(e, t, r) {
381
+ const s = {};
382
+ for (const n of e) {
383
+ const o = t.get(n.specifier);
384
+ if (o)
385
+ if (n.isCommonJS) {
386
+ const i = r.find((a) => a.specifier === n.specifier);
387
+ i && (s[n.specifier] = `${L}${i.urlName}.js`);
388
+ } else
389
+ s[n.specifier] = o;
390
+ }
391
+ return s;
392
+ }
393
+ function je(e, t) {
394
+ const r = h(t, H);
395
+ K(r, { recursive: !0 });
396
+ for (const s of e)
397
+ b(s.path, s.code);
398
+ }
399
+ function xe(e, t) {
400
+ if (!Object.keys(t).length)
401
+ return;
402
+ let r;
403
+ try {
404
+ r = Q(e).filter((n) => n.endsWith(".html")).map((n) => h(e, n));
405
+ } catch {
406
+ return;
407
+ }
408
+ if (r.length)
409
+ for (const s of r) {
410
+ let n;
411
+ try {
412
+ n = S(s, "utf-8");
413
+ } catch {
414
+ continue;
415
+ }
416
+ for (const [o, i] of Object.entries(t))
417
+ n = n.split(B(o)).join(i);
418
+ b(s, n);
419
+ }
420
+ }
421
+ async function Oe(e, t, r, s) {
422
+ for (const n of t)
423
+ try {
424
+ const o = await e.pluginContainer.resolveId(n.specifier, void 0);
425
+ o?.id != null && r.set(n.specifier, X(o.id, s));
426
+ } catch {
427
+ }
428
+ }
429
+ function Ie(e, t, r) {
430
+ for (const s of e)
431
+ if (s.chunkName != null)
432
+ for (const n of Object.values(t)) {
433
+ if (n.type !== "chunk" || n.name !== s.chunkName)
434
+ continue;
435
+ const i = "/" + n.fileName.split("\\").join("/");
436
+ r.set(s.specifier, i);
437
+ break;
438
+ }
439
+ }
440
+ function De(e, t, r, s, n, o, i) {
441
+ for (const a of e) {
442
+ if (!a.isCommonJS || !a.chunkName)
443
+ continue;
444
+ const c = t.get(a.specifier);
445
+ if (!c)
446
+ continue;
447
+ const l = r.find((m) => m.specifier === a.specifier);
448
+ if (!l)
449
+ continue;
450
+ const f = Y(l.specifier, s, i);
451
+ if (!f.length)
452
+ continue;
453
+ const p = n ?? "dist";
454
+ o.push({
455
+ path: h(p, H, `${l.urlName}.js`),
456
+ code: Fe(c, f)
457
+ });
458
+ }
459
+ }
460
+ function Te(e) {
461
+ const t = S(e, "utf-8").replace(z, ye), r = v(A(e, ".js")) + ".js", s = `/${x}/${r}`, n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
462
+ n.set(e, s), o.set(e, t);
463
+ const i = [e], a = /* @__PURE__ */ new Set([e]);
464
+ for (; i.length; ) {
465
+ const c = i.shift();
466
+ if (!c)
467
+ break;
468
+ const l = w(c), f = o.get(c);
469
+ if (!f)
470
+ continue;
471
+ let p;
472
+ for (; (p = J.exec(f)) !== null; ) {
473
+ const m = p[1], u = h(l, m);
474
+ if (!a.has(u)) {
475
+ a.add(u);
476
+ try {
477
+ const d = S(u, "utf-8");
478
+ o.set(u, d), n.set(u, `/${x}/${A(u)}`), i.push(u);
479
+ } catch {
480
+ }
481
+ }
482
+ }
483
+ }
484
+ for (const [c, l] of o)
485
+ o.set(c, be(l, w(c), n));
486
+ return {
487
+ entryAssetName: r,
488
+ filePaths: Array.from(o.keys()),
489
+ codeByPath: o
490
+ };
491
+ }
492
+ function be(e, t, r) {
493
+ return e.replace(J, (s, n) => {
494
+ const o = h(t, n), i = r.get(o);
495
+ return i != null ? `"${i}"` : s;
496
+ });
497
+ }
498
+ function Fe(e, t) {
499
+ return [
500
+ `import * as __raw from "${e}";`,
501
+ "const __mod = __raw.default ?? Object.values(__raw)[0] ?? __raw;",
502
+ `const { ${t.join(", ")} } = __mod;`,
503
+ `export { ${t.join(", ")} };`,
504
+ "export default __mod;"
505
+ ].join(`
506
+ `);
507
+ }
508
+ function Me(e, t) {
509
+ for (const { chunkName: r, pattern: s, subpath: n } of t)
510
+ if (s.test(e) && (!n || e.includes(n)))
511
+ return r;
512
+ return null;
513
+ }
514
+ function Ue(e) {
515
+ return e ? Array.isArray(e) ? e : [e] : [{}];
516
+ }
517
+ function v(e) {
518
+ return e.replace(/^@/, "").replace(/[^a-zA-Z0-9]/g, "_");
519
+ }
520
+ function Le(e) {
521
+ return e.replace(/^@/, "").replace(/\//g, "_");
522
+ }
523
+ function X(e, t) {
524
+ const r = e.replace(/\\/g, "/"), s = t.replace(/\\/g, "/") + "/";
525
+ return r.startsWith(s) ? "/" + r.slice(s.length) : "/@fs/" + r;
526
+ }
527
+ function B(e) {
528
+ const t = e.replace(/[^a-zA-Z0-9]/g, "_");
529
+ return `__${fe}${t}__`;
530
+ }
531
+ function O(e) {
532
+ return e.filter((t) => t.isCommonJS).map((t) => ({
533
+ urlName: v(t.specifier),
534
+ specifier: t.specifier
535
+ }));
536
+ }
537
+ function I(e) {
538
+ return e.filter(({ chunkName: t }) => t != null).sort((t, r) => r.specifier.length - t.specifier.length).map(({ specifier: t, chunkName: r }) => {
539
+ const s = t.includes("/"), n = s ? t.split("/")[0] : t, o = s ? t.slice(n.length + 1) : void 0, i = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
540
+ return {
541
+ chunkName: r,
542
+ subpath: o,
543
+ pattern: new RegExp(`${Pe}${i}(?=[/.])`)
544
+ };
545
+ });
546
+ }
547
+ function D(e) {
548
+ return e.filter(({ chunkName: t }) => t == null).map(({ specifier: t }) => ({
549
+ urlName: v(t),
550
+ specifier: t
551
+ }));
552
+ }
553
+ function He(e) {
554
+ const t = R(e);
555
+ if (!t)
556
+ return [];
557
+ const r = $(t), s = new Set(U);
558
+ for (const n of r) {
559
+ if (!n.startsWith(M))
560
+ continue;
561
+ s.add(n);
562
+ const o = R(h(e, "node_modules", n));
563
+ if (o)
564
+ for (const i of $(o))
565
+ s.add(i);
566
+ }
567
+ return Array.from(s).map((n) => {
568
+ const o = Se.get(n);
569
+ return o != null ? { specifier: n, ...o } : { specifier: n };
570
+ });
571
+ }
572
+ function V(e, t = 0) {
573
+ if (t > Ne)
574
+ return null;
575
+ for (const r of ke) {
576
+ const s = e[r];
577
+ if (typeof s == "string")
578
+ return s;
579
+ if (k(s)) {
580
+ const n = V(s, t + 1);
581
+ if (n != null)
582
+ return n;
583
+ }
584
+ }
585
+ return null;
586
+ }
587
+ function q(e, t) {
588
+ const r = F(h(t, "package.json")), s = h(r.resolve(`${e}/package.json`), ".."), n = R(s);
589
+ if (!n)
590
+ return h(s, "index.js");
591
+ const o = n.exports;
592
+ if (k(o)) {
593
+ const i = o["."];
594
+ if (k(i)) {
595
+ const a = V(i);
596
+ if (a != null)
597
+ return h(s, a);
598
+ }
599
+ }
600
+ return n.module != null ? h(s, n.module) : h(s, n.main ?? "index.js");
601
+ }
602
+ function Y(e, t, r) {
603
+ const s = r[e];
604
+ if (s != null)
605
+ return s;
606
+ try {
607
+ const o = F(h(t))(e), i = k(o) ? Object.keys(o).filter((a) => !Re.has(a)) : [];
608
+ return r[e] = i, i;
609
+ } catch {
610
+ return r[e] = [], [];
611
+ }
612
+ }
613
+ function Je(e, t, r, s, n, o) {
614
+ const i = e.url?.match(ge);
615
+ if (!i) {
616
+ r();
617
+ return;
618
+ }
619
+ const a = n.find((p) => p.urlName === i[1]);
620
+ if (!a) {
621
+ r();
622
+ return;
623
+ }
624
+ const c = Y(a.specifier, s, o);
625
+ if (!c.length) {
626
+ r();
627
+ return;
628
+ }
629
+ const f = [
630
+ `import __mod from "${`${me}${Le(a.specifier)}.js`}";`,
631
+ `const { ${c.join(", ")} } = __mod;`,
632
+ `export { ${c.join(", ")} };`,
633
+ "export default __mod;"
634
+ ].join(`
635
+ `);
636
+ t.setHeader("Content-Type", "application/javascript"), t.end(f);
637
+ }
638
+ async function ze(e, t, r, s, n) {
639
+ const o = e.url?.match(_e);
640
+ if (!o)
641
+ return !1;
642
+ const i = s.find((a) => a.urlName === o[1]);
643
+ if (!i)
644
+ return !1;
645
+ try {
646
+ const a = q(i.specifier, r);
647
+ if (n) {
648
+ const l = X(a, r), f = await n.transformRequest(l);
649
+ if (f)
650
+ return t.setHeader("Content-Type", "application/javascript"), t.end(f.code), !0;
651
+ }
652
+ const c = S(a, "utf-8").replace(z, Ee);
653
+ return t.setHeader("Content-Type", "application/javascript"), t.end(c), !0;
654
+ } catch {
655
+ return !1;
656
+ }
657
+ }
658
+ function et(e) {
659
+ const { sharedPackages: t, devImports: r, ...s } = e;
660
+ return [
661
+ T(),
662
+ Ae({ sharedPackages: t, devImports: r }),
663
+ ae(s)
664
+ ];
665
+ }
666
+ export {
667
+ le as a,
668
+ Qe as b,
669
+ ae as c,
670
+ Ae as i,
671
+ et as s
672
+ };
673
+ //# sourceMappingURL=site-DHHrF1BY.js.map