@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.11

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.
Files changed (36) hide show
  1. package/lib/adapters/azure-swa/vite/index.cjs +2 -2
  2. package/lib/adapters/azure-swa/vite/index.mjs +73 -69
  3. package/lib/adapters/bun-server/vite/index.cjs +2 -2
  4. package/lib/adapters/bun-server/vite/index.mjs +77 -73
  5. package/lib/adapters/cloud-run/vite/index.cjs +2 -2
  6. package/lib/adapters/cloud-run/vite/index.mjs +104 -100
  7. package/lib/adapters/cloudflare-pages/vite/{index-DwovcBp3.js → index-Bg_9YkM5.js} +1 -1
  8. package/lib/adapters/cloudflare-pages/vite/{index-C455V8_A.cjs → index-C1aDmh1S.cjs} +1 -1
  9. package/lib/adapters/cloudflare-pages/vite/index-CHT9Y93A.js +254 -0
  10. package/lib/adapters/cloudflare-pages/vite/{index-DKcVHRBy.cjs → index-Ck7KvpK1.cjs} +1 -1
  11. package/lib/adapters/cloudflare-pages/vite/{index-D3HITboM.js → index-Cp1cjAds.js} +1 -1
  12. package/lib/adapters/cloudflare-pages/vite/index-D9RL9dvJ.cjs +5 -0
  13. package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -1
  14. package/lib/adapters/cloudflare-pages/vite/index.mjs +1 -1
  15. package/lib/adapters/deno-server/vite/index.cjs +2 -2
  16. package/lib/adapters/deno-server/vite/index.mjs +81 -77
  17. package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
  18. package/lib/adapters/netlify-edge/vite/index.mjs +119 -115
  19. package/lib/adapters/node-server/vite/index.cjs +2 -2
  20. package/lib/adapters/node-server/vite/index.mjs +78 -74
  21. package/lib/adapters/shared/vite/index.cjs +2 -2
  22. package/lib/adapters/shared/vite/index.mjs +108 -104
  23. package/lib/adapters/ssg/vite/index.cjs +2 -2
  24. package/lib/adapters/ssg/vite/index.mjs +100 -96
  25. package/lib/adapters/vercel-edge/vite/index.cjs +2 -2
  26. package/lib/adapters/vercel-edge/vite/index.mjs +114 -110
  27. package/lib/index.qwik.cjs +39 -33
  28. package/lib/index.qwik.mjs +39 -33
  29. package/lib/middleware/request-handler/index.cjs +8 -8
  30. package/lib/middleware/request-handler/index.mjs +598 -587
  31. package/lib/vite/index.cjs +17 -17
  32. package/lib/vite/index.d.ts +3 -3
  33. package/lib/vite/index.mjs +242 -230
  34. package/package.json +4 -4
  35. package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
  36. package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
@@ -1,98 +1,98 @@
1
- import y, { existsSync as b } from "node:fs";
2
- import { join as p, resolve as D, dirname as E, basename as q } from "node:path";
1
+ import y, { existsSync as E } from "node:fs";
2
+ import { join as m, resolve as D, dirname as x, basename as q } from "node:path";
3
3
  import { getErrorHtml as R } from "@qwik.dev/router/middleware/request-handler";
4
- async function x(e, s, t, i, a) {
4
+ async function O(e, r, t, i, u) {
5
5
  t && !t.endsWith("/") && (t += "/");
6
- const w = /* @__PURE__ */ new Set([
6
+ const h = /* @__PURE__ */ new Set([
7
7
  t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
8
8
  t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
9
- ]), o = new Set(i.map(S)), f = [], d = async (l, u, c) => {
10
- if (c = S(c), w.has(c))
9
+ ]), o = new Set(i.map(_)), d = [], c = async (a, l, f) => {
10
+ if (f = _(f), h.has(f))
11
11
  return;
12
- const m = p(l, u);
13
- if (u === "index.html" || u === "q-data.json") {
14
- !o.has(c) && a && await y.promises.unlink(m);
12
+ const w = m(a, l);
13
+ if (l === "index.html" || l === "q-data.json") {
14
+ !o.has(f) && u && await y.promises.unlink(w);
15
15
  return;
16
16
  }
17
- if (u === "404.html") {
18
- const k = await y.promises.readFile(m, "utf-8");
19
- f.push([c, k]);
17
+ if (l === "404.html") {
18
+ const s = await y.promises.readFile(w, "utf-8");
19
+ d.push([f, s]);
20
20
  return;
21
21
  }
22
- const n = await y.promises.stat(m);
23
- n.isDirectory() ? await r(m, c + u + "/") : n.isFile() && o.add(c + u);
24
- }, r = async (l, u) => {
25
- const c = await y.promises.readdir(l);
26
- await Promise.all(c.map((m) => d(l, m, u)));
22
+ const k = await y.promises.stat(w);
23
+ k.isDirectory() ? await p(w, f + l + "/") : k.isFile() && o.add(f + l);
24
+ }, p = async (a, l) => {
25
+ const f = await y.promises.readdir(a);
26
+ await Promise.all(f.map((w) => c(a, w, l)));
27
27
  };
28
- y.existsSync(e) && await r(e, t);
29
- const h = O(t, f), g = j(o);
30
- await T(g, h, s);
28
+ y.existsSync(e) && await p(e, t);
29
+ const n = T(t, d), g = j(o);
30
+ await A(g, n, r);
31
31
  }
32
- function S(e) {
32
+ function _(e) {
33
33
  return e.endsWith("/") ? e : e + "/";
34
34
  }
35
- function O(e, s) {
36
- if (s.sort((t, i) => t[0].length > i[0].length ? -1 : t[0].length < i[0].length ? 1 : t[0] < i[0] ? -1 : t[0] > i[0] ? 1 : 0), !s.some((t) => t[0] === e)) {
35
+ function T(e, r) {
36
+ if (r.sort((t, i) => t[0].length > i[0].length ? -1 : t[0].length < i[0].length ? 1 : t[0] < i[0] ? -1 : t[0] > i[0] ? 1 : 0), !r.some((t) => t[0] === e)) {
37
37
  const t = R(404, "Resource Not Found");
38
- s.push([e, t]);
38
+ r.push([e, t]);
39
39
  }
40
- return JSON.stringify(s, null, 2).slice(1, -1);
40
+ return JSON.stringify(r, null, 2).slice(1, -1);
41
41
  }
42
42
  function j(e) {
43
43
  return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
44
44
  }
45
- const T = async (e, s, t) => {
46
- const i = /* @__PURE__ */ new Set(), a = async (o) => {
47
- const f = await y.promises.readFile(o, "utf-8");
48
- let d = !1;
49
- const r = f.replace(
45
+ const A = async (e, r, t) => {
46
+ const i = /* @__PURE__ */ new Set(), u = async (o) => {
47
+ const d = await y.promises.readFile(o, "utf-8");
48
+ let c = !1;
49
+ const p = d.replace(
50
50
  /(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
51
- (h, g, l) => (d = !0, l === "STATIC_PATHS" ? e : s)
51
+ (n, g, a) => (c = !0, a === "STATIC_PATHS" ? e : r)
52
52
  );
53
- d && await y.promises.writeFile(o, r);
54
- }, w = async (o) => {
55
- const f = await y.promises.readdir(o, { withFileTypes: !0 });
56
- for (const d of f)
57
- if (d.isDirectory())
58
- await w(p(o, d.name));
59
- else if (d.name.endsWith("js")) {
60
- const r = a(p(o, d.name)).finally(() => {
61
- i.delete(r);
53
+ c && await y.promises.writeFile(o, p);
54
+ }, h = async (o) => {
55
+ const d = await y.promises.readdir(o, { withFileTypes: !0 });
56
+ for (const c of d)
57
+ if (c.isDirectory())
58
+ await h(m(o, c.name));
59
+ else if (c.name.endsWith("js")) {
60
+ const p = u(m(o, c.name)).finally(() => {
61
+ i.delete(p);
62
62
  });
63
- i.add(r);
63
+ i.add(p);
64
64
  }
65
65
  };
66
- await w(t), await Promise.all(i);
66
+ await h(t), await Promise.all(i);
67
67
  };
68
- function A(e) {
69
- let s = null, t = null, i = null, a = null, w = null, o = !1;
70
- const f = [];
68
+ function F(e) {
69
+ let r = null, t = null, i = null, u = null, h = null, o = !1, d;
70
+ const c = [];
71
71
  return {
72
72
  name: `vite-plugin-qwik-router-ssg-${e.name}`,
73
73
  enforce: "post",
74
74
  apply: "build",
75
- config(r) {
76
- return typeof e.config == "function" && (r = e.config(r)), r.define = {
75
+ config(n) {
76
+ return typeof e.config == "function" && (n = e.config(n)), n.define = {
77
77
  "process.env.NODE_ENV": JSON.stringify("production"),
78
- ...r.define
79
- }, r;
78
+ ...n.define
79
+ }, n;
80
80
  },
81
- configResolved(r) {
82
- if (o = !!r.build.ssr, o) {
83
- if (s = r.plugins.find(
84
- (h) => h.name === "vite-plugin-qwik-router"
85
- ), !s)
81
+ configResolved(n) {
82
+ if (o = !!n.build.ssr, d = n.command, o) {
83
+ if (r = n.plugins.find(
84
+ (g) => g.name === "vite-plugin-qwik-router"
85
+ ), !r)
86
86
  throw new Error("Missing vite-plugin-qwik-router");
87
- if (t = r.plugins.find(
88
- (h) => h.name === "vite-plugin-qwik"
87
+ if (t = n.plugins.find(
88
+ (g) => g.name === "vite-plugin-qwik"
89
89
  ), !t)
90
90
  throw new Error("Missing vite-plugin-qwik");
91
- if (i = r.build.outDir, r.build?.ssr !== !0)
91
+ if (i = n.build.outDir, n.build?.ssr !== !0)
92
92
  throw new Error(
93
93
  `"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`
94
94
  );
95
- if (!r.build?.rollupOptions?.input)
95
+ if (!n.build?.rollupOptions?.input)
96
96
  throw new Error(
97
97
  `"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`
98
98
  );
@@ -100,76 +100,76 @@ function A(e) {
100
100
  },
101
101
  buildStart() {
102
102
  if (o && e.ssg !== null) {
103
- const { srcDir: r } = t.api.getOptions();
104
- this.emitFile({
103
+ const { srcDir: n } = t.api.getOptions();
104
+ d === "build" && i && n && (this.emitFile({
105
105
  id: "@qwik-router-config",
106
106
  type: "chunk",
107
107
  fileName: "@qwik-router-config.js"
108
108
  }), this.emitFile({
109
- id: `${r}/entry.ssr`,
109
+ id: `${n}/entry.ssr`,
110
110
  type: "chunk",
111
111
  fileName: "entry.ssr.js"
112
- });
112
+ }));
113
113
  }
114
114
  },
115
- generateBundle(r, h) {
115
+ generateBundle(n, g) {
116
116
  if (o) {
117
- f.length = 0;
118
- for (const g in h) {
119
- const l = h[g];
120
- l.type === "chunk" && l.isEntry && (f.push(g), l.name === "entry.ssr" ? a = p(i, g) : l.name === "@qwik-router-config" && (w = p(i, g)));
117
+ c.length = 0;
118
+ for (const a in g) {
119
+ const l = g[a];
120
+ l.type === "chunk" && l.isEntry && (c.push(a), l.name === "entry.ssr" ? u = m(i, a) : l.name === "@qwik-router-config" && (h = m(i, a)));
121
121
  }
122
122
  }
123
123
  },
124
124
  closeBundle: {
125
125
  sequential: !0,
126
126
  async handler() {
127
- if (o && i && s?.api && t?.api) {
128
- const r = e.staticPaths || [], h = s.api.getRoutes(), g = s.api.getBasePathname(), l = t.api.getClientOutDir(), u = t.api.getClientPublicOutDir(), c = t.api.getAssetsDir(), m = t.api.getRootDir() ?? void 0;
129
- if (e.ssg !== null && a && w && l && u) {
130
- let n = e.ssg?.origin ?? e.origin;
131
- n || (n = "https://yoursite.qwik.dev"), n.length > 0 && !/:\/\//.test(n) && (n = `https://${n}`), n.startsWith("//") && (n = `https:${n}`);
127
+ if (o && i && r?.api && t?.api) {
128
+ const n = e.staticPaths || [], g = r.api.getRoutes(), a = r.api.getBasePathname(), l = t.api.getClientOutDir(), f = t.api.getClientPublicOutDir(), w = t.api.getAssetsDir(), k = t.api.getRootDir() ?? void 0;
129
+ if (e.ssg !== null && u && h && l && f) {
130
+ let s = e.ssg?.origin ?? e.origin;
131
+ s || (s = "https://yoursite.qwik.dev"), s.length > 0 && !/:\/\//.test(s) && (s = `https://${s}`), s.startsWith("//") && (s = `https:${s}`);
132
132
  try {
133
- n = new URL(n).origin;
133
+ s = new URL(s).origin;
134
134
  } catch {
135
135
  this.warn(
136
- `Invalid "origin" option: "${n}". Using default origin: "https://yoursite.qwik.dev"`
137
- ), n = "https://yoursite.qwik.dev";
136
+ `Invalid "origin" option: "${s}". Using default origin: "https://yoursite.qwik.dev"`
137
+ ), s = "https://yoursite.qwik.dev";
138
138
  }
139
- const k = await import("./index-CrwlB95_.js"), v = {
139
+ const v = await import("./index-CrwlB95_.js"), b = {
140
140
  maxWorkers: e.maxWorkers,
141
- basePathname: g,
142
- outDir: u,
143
- rootDir: m,
141
+ basePathname: a,
142
+ outDir: f,
143
+ rootDir: k,
144
144
  ...e.ssg,
145
- origin: n,
146
- renderModulePath: a,
147
- qwikRouterConfigModulePath: w
148
- }, P = await k.generate(v);
145
+ origin: s,
146
+ renderModulePath: u,
147
+ qwikRouterConfigModulePath: h
148
+ }, P = await v.generate(b);
149
149
  if (P.errors > 0) {
150
- const _ = new Error(
150
+ const S = new Error(
151
151
  `Error while running SSG from "${e.name}" adapter. At least one path failed to render.`
152
152
  );
153
- _.stack = void 0, this.error(_);
153
+ S.stack = void 0, this.error(S);
154
154
  }
155
- r.push(...P.staticPaths);
155
+ n.push(...P.staticPaths);
156
156
  }
157
- await x(
158
- u,
157
+ await O(
158
+ f,
159
159
  i,
160
- c ? p(g, c) : g,
161
- r,
160
+ w ? m(a, w) : a,
161
+ n,
162
162
  !!e.cleanStaticGenerated
163
163
  ), typeof e.generate == "function" && await e.generate({
164
- outputEntries: f,
164
+ outputEntries: c,
165
165
  serverOutDir: i,
166
166
  clientOutDir: l,
167
- clientPublicOutDir: u,
168
- basePathname: g,
169
- routes: h,
170
- assetsDir: c,
171
- warn: (n) => this.warn(n),
172
- error: (n) => this.error(n)
167
+ clientPublicOutDir: f,
168
+ basePathname: a,
169
+ routes: g,
170
+ assetsDir: w,
171
+ warn: (s) => this.warn(s),
172
+ error: (s) => this.error(s)
173
173
  }), this.warn(
174
174
  `
175
175
  ==============================================
@@ -177,6 +177,10 @@ Note: Make sure that you are serving the built files with proper cache headers.
177
177
  See https://qwik.dev/docs/deployments/#cache-headers for more information.
178
178
  ==============================================`
179
179
  ), e.ssg !== null && setTimeout(() => {
180
+ console.warn(
181
+ "SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."
182
+ ), process.exit(0);
183
+ }, 5e3).unref(), e.ssg !== null && setTimeout(() => {
180
184
  process.exit(0);
181
185
  }, 5e3).unref();
182
186
  }
@@ -184,22 +188,22 @@ See https://qwik.dev/docs/deployments/#cache-headers for more information.
184
188
  }
185
189
  };
186
190
  }
187
- function F(e, s) {
191
+ function I(e, r) {
188
192
  const t = D("/");
189
193
  let i = e;
190
- for (let a = 0; a < 20; a++) {
191
- if (i = E(i), q(i) === s)
194
+ for (let u = 0; u < 20; u++) {
195
+ if (i = x(i), q(i) === r)
192
196
  return i;
193
197
  if (i === t)
194
198
  break;
195
199
  }
196
- throw new Error(`Unable to find "${s}" directory from "${e}"`);
200
+ throw new Error(`Unable to find "${r}" directory from "${e}"`);
197
201
  }
198
- function W(e = {}) {
199
- const s = process?.env;
200
- return A({
202
+ function G(e = {}) {
203
+ const r = process?.env;
204
+ return F({
201
205
  name: "netlify-edge",
202
- origin: s?.ORIGIN ?? s?.URL ?? "https://yoursitename.netlify.app",
206
+ origin: r?.ORIGIN ?? r?.URL ?? "https://yoursitename.netlify.app",
203
207
  ssg: e.ssg,
204
208
  staticPaths: e.staticPaths,
205
209
  cleanStaticGenerated: !0,
@@ -229,8 +233,8 @@ function W(e = {}) {
229
233
  },
230
234
  async generate({ serverOutDir: t, basePathname: i }) {
231
235
  if (e.functionRoutes !== !1) {
232
- const a = [];
233
- typeof e.excludedPath == "string" ? a.push(e.excludedPath) : Array.isArray(e.excludedPath) ? a.push(...e.excludedPath) : a.push(
236
+ const u = [];
237
+ typeof e.excludedPath == "string" ? u.push(e.excludedPath) : Array.isArray(e.excludedPath) ? u.push(...e.excludedPath) : u.push(
234
238
  "/build/*",
235
239
  "/favicon.ico",
236
240
  "/robots.txt",
@@ -239,18 +243,18 @@ function W(e = {}) {
239
243
  "/service-worker.js",
240
244
  "/sitemap.xml"
241
245
  );
242
- const w = {
246
+ const h = {
243
247
  functions: [
244
248
  {
245
249
  path: i + "*",
246
250
  function: "entry.netlify-edge",
247
251
  cache: "manual",
248
- excludedPath: a
252
+ excludedPath: u
249
253
  }
250
254
  ],
251
255
  version: 1
252
- }, o = p(t, "entry.netlify-edge.js"), f = p(t, "entry.netlify-edge.mjs");
253
- b(f) && await y.promises.writeFile(
256
+ }, o = m(t, "entry.netlify-edge.js"), d = m(t, "entry.netlify-edge.mjs");
257
+ E(d) && await y.promises.writeFile(
254
258
  o,
255
259
  [
256
260
  "import entry_netlifyEdge from './entry.netlify-edge.mjs';",
@@ -258,15 +262,15 @@ function W(e = {}) {
258
262
  ].join(`
259
263
  `)
260
264
  );
261
- const d = F(t, "edge-functions");
265
+ const c = I(t, "edge-functions");
262
266
  await y.promises.writeFile(
263
- p(d, "manifest.json"),
264
- JSON.stringify(w, null, 2)
267
+ m(c, "manifest.json"),
268
+ JSON.stringify(h, null, 2)
265
269
  );
266
270
  }
267
271
  }
268
272
  });
269
273
  }
270
274
  export {
271
- W as netlifyEdgeAdapter
275
+ G as netlifyEdgeAdapter
272
276
  };
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:path"),P=require("@qwik.dev/router/middleware/request-handler"),p=require("node:fs");async function D(e,n,t,s,m){t&&!t.endsWith("/")&&(t+="/");const h=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(s.map(v)),f=[],g=async(a,l,u)=>{if(u=v(u),h.has(u))return;const w=y.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(u)&&m&&await p.promises.unlink(w);return}if(l==="404.html"){const S=await p.promises.readFile(w,"utf-8");f.push([u,S]);return}const r=await p.promises.stat(w);r.isDirectory()?await i(w,u+l+"/"):r.isFile()&&o.add(u+l)},i=async(a,l)=>{const u=await p.promises.readdir(a);await Promise.all(u.map(w=>g(a,w,l)))};p.existsSync(e)&&await i(e,t);const d=O(t,f),c=R(o);await b(c,d,n)}function v(e){return e.endsWith("/")?e:e+"/"}function O(e,n){if(n.sort((t,s)=>t[0].length>s[0].length?-1:t[0].length<s[0].length?1:t[0]<s[0]?-1:t[0]>s[0]?1:0),!n.some(t=>t[0]===e)){const t=P.getErrorHtml(404,"Resource Not Found");n.push([e,t])}return JSON.stringify(n,null,2).slice(1,-1)}function R(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const b=async(e,n,t)=>{const s=new Set,m=async o=>{const f=await p.promises.readFile(o,"utf-8");let g=!1;const i=f.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(d,c,a)=>(g=!0,a==="STATIC_PATHS"?e:n));g&&await p.promises.writeFile(o,i)},h=async o=>{const f=await p.promises.readdir(o,{withFileTypes:!0});for(const g of f)if(g.isDirectory())await h(y.join(o,g.name));else if(g.name.endsWith("js")){const i=m(y.join(o,g.name)).finally(()=>{s.delete(i)});s.add(i)}};await h(t),await Promise.all(s)};function T(e){let n=null,t=null,s=null,m=null,h=null,o=!1;const f=[];return{name:`vite-plugin-qwik-router-ssg-${e.name}`,enforce:"post",apply:"build",config(i){return typeof e.config=="function"&&(i=e.config(i)),i.define={"process.env.NODE_ENV":JSON.stringify("production"),...i.define},i},configResolved(i){if(o=!!i.build.ssr,o){if(n=i.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!n)throw new Error("Missing vite-plugin-qwik-router");if(t=i.plugins.find(d=>d.name==="vite-plugin-qwik"),!t)throw new Error("Missing vite-plugin-qwik");if(s=i.build.outDir,i.build?.ssr!==!0)throw new Error(`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`);if(!i.build?.rollupOptions?.input)throw new Error(`"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`)}},buildStart(){if(o&&e.ssg!==null){const{srcDir:i}=t.api.getOptions();this.emitFile({id:"@qwik-router-config",type:"chunk",fileName:"@qwik-router-config.js"}),this.emitFile({id:`${i}/entry.ssr`,type:"chunk",fileName:"entry.ssr.js"})}},generateBundle(i,d){if(o){f.length=0;for(const c in d){const a=d[c];a.type==="chunk"&&a.isEntry&&(f.push(c),a.name==="entry.ssr"?m=y.join(s,c):a.name==="@qwik-router-config"&&(h=y.join(s,c)))}}},closeBundle:{sequential:!0,async handler(){if(o&&s&&n?.api&&t?.api){const i=e.staticPaths||[],d=n.api.getRoutes(),c=n.api.getBasePathname(),a=t.api.getClientOutDir(),l=t.api.getClientPublicOutDir(),u=t.api.getAssetsDir(),w=t.api.getRootDir()??void 0;if(e.ssg!==null&&m&&h&&a&&l){let r=e.ssg?.origin??e.origin;r||(r="https://yoursite.qwik.dev"),r.length>0&&!/:\/\//.test(r)&&(r=`https://${r}`),r.startsWith("//")&&(r=`https:${r}`);try{r=new URL(r).origin}catch{this.warn(`Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`),r="https://yoursite.qwik.dev"}const S=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),q={maxWorkers:e.maxWorkers,basePathname:c,outDir:l,rootDir:w,...e.ssg,origin:r,renderModulePath:m,qwikRouterConfigModulePath:h},_=await S.generate(q);if(_.errors>0){const k=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);k.stack=void 0,this.error(k)}i.push(..._.staticPaths)}await D(l,s,u?y.join(c,u):c,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:f,serverOutDir:s,clientOutDir:a,clientPublicOutDir:l,basePathname:c,routes:d,assetsDir:u,warn:r=>this.warn(r),error:r=>this.error(r)}),this.warn(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:path"),D=require("@qwik.dev/router/middleware/request-handler"),p=require("node:fs");async function b(e,s,t,n,m){t&&!t.endsWith("/")&&(t+="/");const h=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(n.map(_)),g=[],c=async(a,l,u)=>{if(u=_(u),h.has(u))return;const f=y.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(u)&&m&&await p.promises.unlink(f);return}if(l==="404.html"){const r=await p.promises.readFile(f,"utf-8");g.push([u,r]);return}const S=await p.promises.stat(f);S.isDirectory()?await w(f,u+l+"/"):S.isFile()&&o.add(u+l)},w=async(a,l)=>{const u=await p.promises.readdir(a);await Promise.all(u.map(f=>c(a,f,l)))};p.existsSync(e)&&await w(e,t);const i=O(t,g),d=R(o);await T(d,i,s)}function _(e){return e.endsWith("/")?e:e+"/"}function O(e,s){if(s.sort((t,n)=>t[0].length>n[0].length?-1:t[0].length<n[0].length?1:t[0]<n[0]?-1:t[0]>n[0]?1:0),!s.some(t=>t[0]===e)){const t=D.getErrorHtml(404,"Resource Not Found");s.push([e,t])}return JSON.stringify(s,null,2).slice(1,-1)}function R(e){return JSON.stringify(Array.from(new Set(e)).sort()).slice(1,-1)}const T=async(e,s,t)=>{const n=new Set,m=async o=>{const g=await p.promises.readFile(o,"utf-8");let c=!1;const w=g.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(i,d,a)=>(c=!0,a==="STATIC_PATHS"?e:s));c&&await p.promises.writeFile(o,w)},h=async o=>{const g=await p.promises.readdir(o,{withFileTypes:!0});for(const c of g)if(c.isDirectory())await h(y.join(o,c.name));else if(c.name.endsWith("js")){const w=m(y.join(o,c.name)).finally(()=>{n.delete(w)});n.add(w)}};await h(t),await Promise.all(n)};function E(e){let s=null,t=null,n=null,m=null,h=null,o=!1,g;const c=[];return{name:`vite-plugin-qwik-router-ssg-${e.name}`,enforce:"post",apply:"build",config(i){return typeof e.config=="function"&&(i=e.config(i)),i.define={"process.env.NODE_ENV":JSON.stringify("production"),...i.define},i},configResolved(i){if(o=!!i.build.ssr,g=i.command,o){if(s=i.plugins.find(d=>d.name==="vite-plugin-qwik-router"),!s)throw new Error("Missing vite-plugin-qwik-router");if(t=i.plugins.find(d=>d.name==="vite-plugin-qwik"),!t)throw new Error("Missing vite-plugin-qwik");if(n=i.build.outDir,i.build?.ssr!==!0)throw new Error(`"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`);if(!i.build?.rollupOptions?.input)throw new Error(`"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`)}},buildStart(){if(o&&e.ssg!==null){const{srcDir:i}=t.api.getOptions();g==="build"&&n&&i&&(this.emitFile({id:"@qwik-router-config",type:"chunk",fileName:"@qwik-router-config.js"}),this.emitFile({id:`${i}/entry.ssr`,type:"chunk",fileName:"entry.ssr.js"}))}},generateBundle(i,d){if(o){c.length=0;for(const a in d){const l=d[a];l.type==="chunk"&&l.isEntry&&(c.push(a),l.name==="entry.ssr"?m=y.join(n,a):l.name==="@qwik-router-config"&&(h=y.join(n,a)))}}},closeBundle:{sequential:!0,async handler(){if(o&&n&&s?.api&&t?.api){const i=e.staticPaths||[],d=s.api.getRoutes(),a=s.api.getBasePathname(),l=t.api.getClientOutDir(),u=t.api.getClientPublicOutDir(),f=t.api.getAssetsDir(),S=t.api.getRootDir()??void 0;if(e.ssg!==null&&m&&h&&l&&u){let r=e.ssg?.origin??e.origin;r||(r="https://yoursite.qwik.dev"),r.length>0&&!/:\/\//.test(r)&&(r=`https://${r}`),r.startsWith("//")&&(r=`https:${r}`);try{r=new URL(r).origin}catch{this.warn(`Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`),r="https://yoursite.qwik.dev"}const q=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),P={maxWorkers:e.maxWorkers,basePathname:a,outDir:u,rootDir:S,...e.ssg,origin:r,renderModulePath:m,qwikRouterConfigModulePath:h},k=await q.generate(P);if(k.errors>0){const v=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);v.stack=void 0,this.error(v)}i.push(...k.staticPaths)}await b(u,n,f?y.join(a,f):a,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:c,serverOutDir:n,clientOutDir:l,clientPublicOutDir:u,basePathname:a,routes:d,assetsDir:f,warn:r=>this.warn(r),error:r=>this.error(r)}),this.warn(`
2
2
  ==============================================
3
3
  Note: Make sure that you are serving the built files with proper cache headers.
4
4
  See https://qwik.dev/docs/deployments/#cache-headers for more information.
5
- ==============================================`),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function A(e={}){const n=process?.env;return T({name:e.name||"node-server",origin:n?.ORIGIN??n?.URL??"https://yoursitename.qwik.dev",ssg:e.ssg,cleanStaticGenerated:!0,config(){return{ssr:{target:"node"},build:{ssr:!0},publicDir:!1}}})}exports.nodeServerAdapter=A;
5
+ ==============================================`),e.ssg!==null&&setTimeout(()=>{console.warn("SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."),process.exit(0)},5e3).unref(),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function A(e={}){const s=process?.env;return E({name:e.name||"node-server",origin:s?.ORIGIN??s?.URL??"https://yoursitename.qwik.dev",ssg:e.ssg,cleanStaticGenerated:!0,config(){return{ssr:{target:"node"},build:{ssr:!0},publicDir:!1}}})}exports.nodeServerAdapter=A;