@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,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("node:path"),v=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(q)),f=[],g=async(a,u,l)=>{if(l=q(l),h.has(l))return;const w=y.join(a,u);if(u==="index.html"||u==="q-data.json"){!o.has(l)&&m&&await p.promises.unlink(w);return}if(u==="404.html"){const S=await p.promises.readFile(w,"utf-8");f.push([l,S]);return}const r=await p.promises.stat(w);r.isDirectory()?await i(w,l+u+"/"):r.isFile()&&o.add(l+u)},i=async(a,u)=>{const l=await p.promises.readdir(a);await Promise.all(l.map(w=>g(a,w,u)))};p.existsSync(e)&&await i(e,t);const d=R(t,f),c=O(o);await b(c,d,n)}function q(e){return e.endsWith("/")?e:e+"/"}function R(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=v.getErrorHtml(404,"Resource Not Found");n.push([e,t])}return JSON.stringify(n,null,2).slice(1,-1)}function O(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(),u=t.api.getClientPublicOutDir(),l=t.api.getAssetsDir(),w=t.api.getRootDir()??void 0;if(e.ssg!==null&&m&&h&&a&&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 S=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),P={maxWorkers:e.maxWorkers,basePathname:c,outDir:u,rootDir:w,...e.ssg,origin:r,renderModulePath:m,qwikRouterConfigModulePath:h},_=await S.generate(P);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(u,s,l?y.join(c,l):c,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:f,serverOutDir:s,clientOutDir:a,clientPublicOutDir:u,basePathname:c,routes:d,assetsDir:l,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 R(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(q)),g=[],c=async(a,l,u)=>{if(u=q(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=b(t,g),d=O(o);await T(d,i,s)}function q(e){return e.endsWith("/")?e:e+"/"}function b(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 O(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 v=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},_=await v.generate(P);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 R(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:"cloud-run",origin:n?.ORIGIN??n?.URL??"https://your-app-name.run.app",ssg:e.ssg,cleanStaticGenerated:!0,config(){return{build:{ssr:!0},publicDir:!1}}})}exports.cloudRunAdapter=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:"cloud-run",origin:s?.ORIGIN??s?.URL??"https://your-app-name.run.app",ssg:e.ssg,cleanStaticGenerated:!0,config(){return{build:{ssr:!0},publicDir:!1}}})}exports.cloudRunAdapter=A;
@@ -1,107 +1,107 @@
1
1
  import { join as y } from "node:path";
2
- import { getErrorHtml as D } from "@qwik.dev/router/middleware/request-handler";
2
+ import { getErrorHtml as q } from "@qwik.dev/router/middleware/request-handler";
3
3
  import p from "node:fs";
4
- async function q(t, n, e, s, m) {
5
- e && !e.endsWith("/") && (e += "/");
6
- const w = /* @__PURE__ */ new Set([
7
- e + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
8
- e + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
9
- ]), o = new Set(s.map(P)), f = [], g = async (a, l, u) => {
10
- if (u = P(u), w.has(u))
4
+ async function R(e, s, t, n, m) {
5
+ t && !t.endsWith("/") && (t += "/");
6
+ const h = /* @__PURE__ */ new Set([
7
+ t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
8
+ t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
9
+ ]), o = new Set(n.map(v)), g = [], c = async (a, l, u) => {
10
+ if (u = v(u), h.has(u))
11
11
  return;
12
- const h = y(a, l);
12
+ const f = y(a, l);
13
13
  if (l === "index.html" || l === "q-data.json") {
14
- !o.has(u) && m && await p.promises.unlink(h);
14
+ !o.has(u) && m && await p.promises.unlink(f);
15
15
  return;
16
16
  }
17
17
  if (l === "404.html") {
18
- const _ = await p.promises.readFile(h, "utf-8");
19
- f.push([u, _]);
18
+ const r = await p.promises.readFile(f, "utf-8");
19
+ g.push([u, r]);
20
20
  return;
21
21
  }
22
- const r = await p.promises.stat(h);
23
- r.isDirectory() ? await i(h, u + l + "/") : r.isFile() && o.add(u + l);
24
- }, i = async (a, l) => {
22
+ const S = await p.promises.stat(f);
23
+ S.isDirectory() ? await w(f, u + l + "/") : S.isFile() && o.add(u + l);
24
+ }, w = async (a, l) => {
25
25
  const u = await p.promises.readdir(a);
26
- await Promise.all(u.map((h) => g(a, h, l)));
26
+ await Promise.all(u.map((f) => c(a, f, l)));
27
27
  };
28
- p.existsSync(t) && await i(t, e);
29
- const d = R(e, f), c = O(o);
30
- await b(c, d, n);
28
+ p.existsSync(e) && await w(e, t);
29
+ const i = O(t, g), d = b(o);
30
+ await T(d, i, s);
31
31
  }
32
- function P(t) {
33
- return t.endsWith("/") ? t : t + "/";
32
+ function v(e) {
33
+ return e.endsWith("/") ? e : e + "/";
34
34
  }
35
- function R(t, n) {
36
- if (n.sort((e, s) => e[0].length > s[0].length ? -1 : e[0].length < s[0].length ? 1 : e[0] < s[0] ? -1 : e[0] > s[0] ? 1 : 0), !n.some((e) => e[0] === t)) {
37
- const e = D(404, "Resource Not Found");
38
- n.push([t, e]);
35
+ function O(e, s) {
36
+ 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)) {
37
+ const t = q(404, "Resource Not Found");
38
+ s.push([e, t]);
39
39
  }
40
- return JSON.stringify(n, null, 2).slice(1, -1);
40
+ return JSON.stringify(s, null, 2).slice(1, -1);
41
41
  }
42
- function O(t) {
43
- return JSON.stringify(Array.from(new Set(t)).sort()).slice(1, -1);
42
+ function b(e) {
43
+ return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
44
44
  }
45
- const b = async (t, n, e) => {
46
- const s = /* @__PURE__ */ new Set(), m = async (o) => {
47
- const f = await p.promises.readFile(o, "utf-8");
48
- let g = !1;
49
- const i = f.replace(
45
+ const T = async (e, s, t) => {
46
+ const n = /* @__PURE__ */ new Set(), m = async (o) => {
47
+ const g = await p.promises.readFile(o, "utf-8");
48
+ let c = !1;
49
+ const w = g.replace(
50
50
  /(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
51
- (d, c, a) => (g = !0, a === "STATIC_PATHS" ? t : n)
51
+ (i, d, a) => (c = !0, a === "STATIC_PATHS" ? e : s)
52
52
  );
53
- g && await p.promises.writeFile(o, i);
54
- }, w = async (o) => {
55
- const f = await p.promises.readdir(o, { withFileTypes: !0 });
56
- for (const g of f)
57
- if (g.isDirectory())
58
- await w(y(o, g.name));
59
- else if (g.name.endsWith("js")) {
60
- const i = m(y(o, g.name)).finally(() => {
61
- s.delete(i);
53
+ c && await p.promises.writeFile(o, w);
54
+ }, h = async (o) => {
55
+ const g = await p.promises.readdir(o, { withFileTypes: !0 });
56
+ for (const c of g)
57
+ if (c.isDirectory())
58
+ await h(y(o, c.name));
59
+ else if (c.name.endsWith("js")) {
60
+ const w = m(y(o, c.name)).finally(() => {
61
+ n.delete(w);
62
62
  });
63
- s.add(i);
63
+ n.add(w);
64
64
  }
65
65
  };
66
- await w(e), await Promise.all(s);
66
+ await h(t), await Promise.all(n);
67
67
  };
68
- function T(t) {
69
- let n = null, e = null, s = null, m = null, w = null, o = !1;
70
- const f = [];
68
+ function E(e) {
69
+ let s = null, t = null, n = null, m = null, h = null, o = !1, g;
70
+ const c = [];
71
71
  return {
72
- name: `vite-plugin-qwik-router-ssg-${t.name}`,
72
+ name: `vite-plugin-qwik-router-ssg-${e.name}`,
73
73
  enforce: "post",
74
74
  apply: "build",
75
75
  config(i) {
76
- return typeof t.config == "function" && (i = t.config(i)), i.define = {
76
+ return typeof e.config == "function" && (i = e.config(i)), i.define = {
77
77
  "process.env.NODE_ENV": JSON.stringify("production"),
78
78
  ...i.define
79
79
  }, i;
80
80
  },
81
81
  configResolved(i) {
82
- if (o = !!i.build.ssr, o) {
83
- if (n = i.plugins.find(
82
+ if (o = !!i.build.ssr, g = i.command, o) {
83
+ if (s = i.plugins.find(
84
84
  (d) => d.name === "vite-plugin-qwik-router"
85
- ), !n)
85
+ ), !s)
86
86
  throw new Error("Missing vite-plugin-qwik-router");
87
- if (e = i.plugins.find(
87
+ if (t = i.plugins.find(
88
88
  (d) => d.name === "vite-plugin-qwik"
89
- ), !e)
89
+ ), !t)
90
90
  throw new Error("Missing vite-plugin-qwik");
91
- if (s = i.build.outDir, i.build?.ssr !== !0)
91
+ if (n = i.build.outDir, i.build?.ssr !== !0)
92
92
  throw new Error(
93
- `"build.ssr" must be set to "true" in order to use the "${t.name}" adapter.`
93
+ `"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`
94
94
  );
95
95
  if (!i.build?.rollupOptions?.input)
96
96
  throw new Error(
97
- `"build.rollupOptions.input" must be set in order to use the "${t.name}" adapter.`
97
+ `"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`
98
98
  );
99
99
  }
100
100
  },
101
101
  buildStart() {
102
- if (o && t.ssg !== null) {
103
- const { srcDir: i } = e.api.getOptions();
104
- this.emitFile({
102
+ if (o && e.ssg !== null) {
103
+ const { srcDir: i } = t.api.getOptions();
104
+ g === "build" && n && i && (this.emitFile({
105
105
  id: "@qwik-router-config",
106
106
  type: "chunk",
107
107
  fileName: "@qwik-router-config.js"
@@ -109,25 +109,25 @@ function T(t) {
109
109
  id: `${i}/entry.ssr`,
110
110
  type: "chunk",
111
111
  fileName: "entry.ssr.js"
112
- });
112
+ }));
113
113
  }
114
114
  },
115
115
  generateBundle(i, d) {
116
116
  if (o) {
117
- f.length = 0;
118
- for (const c in d) {
119
- const a = d[c];
120
- a.type === "chunk" && a.isEntry && (f.push(c), a.name === "entry.ssr" ? m = y(s, c) : a.name === "@qwik-router-config" && (w = y(s, c)));
117
+ c.length = 0;
118
+ for (const a in d) {
119
+ const l = d[a];
120
+ l.type === "chunk" && l.isEntry && (c.push(a), l.name === "entry.ssr" ? m = y(n, a) : l.name === "@qwik-router-config" && (h = y(n, a)));
121
121
  }
122
122
  }
123
123
  },
124
124
  closeBundle: {
125
125
  sequential: !0,
126
126
  async handler() {
127
- if (o && s && n?.api && e?.api) {
128
- const i = t.staticPaths || [], d = n.api.getRoutes(), c = n.api.getBasePathname(), a = e.api.getClientOutDir(), l = e.api.getClientPublicOutDir(), u = e.api.getAssetsDir(), h = e.api.getRootDir() ?? void 0;
129
- if (t.ssg !== null && m && w && a && l) {
130
- let r = t.ssg?.origin ?? t.origin;
127
+ if (o && n && s?.api && t?.api) {
128
+ 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;
129
+ if (e.ssg !== null && m && h && l && u) {
130
+ let r = e.ssg?.origin ?? e.origin;
131
131
  r || (r = "https://yoursite.qwik.dev"), r.length > 0 && !/:\/\//.test(r) && (r = `https://${r}`), r.startsWith("//") && (r = `https:${r}`);
132
132
  try {
133
133
  r = new URL(r).origin;
@@ -136,38 +136,38 @@ function T(t) {
136
136
  `Invalid "origin" option: "${r}". Using default origin: "https://yoursite.qwik.dev"`
137
137
  ), r = "https://yoursite.qwik.dev";
138
138
  }
139
- const _ = await import("./index-CrwlB95_.js"), v = {
140
- maxWorkers: t.maxWorkers,
141
- basePathname: c,
142
- outDir: l,
143
- rootDir: h,
144
- ...t.ssg,
139
+ const P = await import("./index-CrwlB95_.js"), D = {
140
+ maxWorkers: e.maxWorkers,
141
+ basePathname: a,
142
+ outDir: u,
143
+ rootDir: S,
144
+ ...e.ssg,
145
145
  origin: r,
146
146
  renderModulePath: m,
147
- qwikRouterConfigModulePath: w
148
- }, k = await _.generate(v);
147
+ qwikRouterConfigModulePath: h
148
+ }, k = await P.generate(D);
149
149
  if (k.errors > 0) {
150
- const S = new Error(
151
- `Error while running SSG from "${t.name}" adapter. At least one path failed to render.`
150
+ const _ = new Error(
151
+ `Error while running SSG from "${e.name}" adapter. At least one path failed to render.`
152
152
  );
153
- S.stack = void 0, this.error(S);
153
+ _.stack = void 0, this.error(_);
154
154
  }
155
155
  i.push(...k.staticPaths);
156
156
  }
157
- await q(
158
- l,
159
- s,
160
- u ? y(c, u) : c,
157
+ await R(
158
+ u,
159
+ n,
160
+ f ? y(a, f) : a,
161
161
  i,
162
- !!t.cleanStaticGenerated
163
- ), typeof t.generate == "function" && await t.generate({
164
- outputEntries: f,
165
- serverOutDir: s,
166
- clientOutDir: a,
167
- clientPublicOutDir: l,
168
- basePathname: c,
162
+ !!e.cleanStaticGenerated
163
+ ), typeof e.generate == "function" && await e.generate({
164
+ outputEntries: c,
165
+ serverOutDir: n,
166
+ clientOutDir: l,
167
+ clientPublicOutDir: u,
168
+ basePathname: a,
169
169
  routes: d,
170
- assetsDir: u,
170
+ assetsDir: f,
171
171
  warn: (r) => this.warn(r),
172
172
  error: (r) => this.error(r)
173
173
  }), this.warn(
@@ -176,7 +176,11 @@ function T(t) {
176
176
  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
- ), t.ssg !== null && setTimeout(() => {
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,12 +188,12 @@ See https://qwik.dev/docs/deployments/#cache-headers for more information.
184
188
  }
185
189
  };
186
190
  }
187
- function C(t = {}) {
188
- const n = process?.env;
189
- return T({
191
+ function F(e = {}) {
192
+ const s = process?.env;
193
+ return E({
190
194
  name: "cloud-run",
191
- origin: n?.ORIGIN ?? n?.URL ?? "https://your-app-name.run.app",
192
- ssg: t.ssg,
195
+ origin: s?.ORIGIN ?? s?.URL ?? "https://your-app-name.run.app",
196
+ ssg: e.ssg,
193
197
  cleanStaticGenerated: !0,
194
198
  config() {
195
199
  return {
@@ -202,5 +206,5 @@ function C(t = {}) {
202
206
  });
203
207
  }
204
208
  export {
205
- C as cloudRunAdapter
209
+ F as cloudRunAdapter
206
210
  };
@@ -5,7 +5,7 @@ function r() {
5
5
  if (n())
6
6
  return import("./index-ClHGw5z1.js");
7
7
  if (e() || o())
8
- return import("./index-D3HITboM.js");
8
+ return import("./index-Cp1cjAds.js");
9
9
  throw new Error("Unsupported platform");
10
10
  }
11
11
  function n() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function t(r){return await(await o()).generate(r)}function o(){if(e())return Promise.resolve().then(()=>require("./index-vQuPcef3.cjs"));if(n()||s())return Promise.resolve().then(()=>require("./index-DKcVHRBy.cjs"));throw new Error("Unsupported platform")}function e(){return typeof Deno<"u"}function n(){return typeof Bun<"u"}function s(){return!n()&&!e()&&typeof process<"u"&&!!process.versions?.node}exports.generate=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function t(r){return await(await o()).generate(r)}function o(){if(e())return Promise.resolve().then(()=>require("./index-vQuPcef3.cjs"));if(n()||s())return Promise.resolve().then(()=>require("./index-Ck7KvpK1.cjs"));throw new Error("Unsupported platform")}function e(){return typeof Deno<"u"}function n(){return typeof Bun<"u"}function s(){return!n()&&!e()&&typeof process<"u"&&!!process.versions?.node}exports.generate=t;
@@ -0,0 +1,254 @@
1
+ import d from "node:fs";
2
+ import { normalize as b, join as p, relative as E } from "node:path";
3
+ import { getErrorHtml as O } from "@qwik.dev/router/middleware/request-handler";
4
+ function J(e) {
5
+ return v(b(e));
6
+ }
7
+ function v(e) {
8
+ const n = /^\\\\\?\\/.test(e), t = /[^\u0000-\u0080]+/.test(e);
9
+ return n || t || (e = e.replace(/\\/g, "/"), e.endsWith("/") && (e = e.slice(0, e.length - 1))), e;
10
+ }
11
+ async function D(e, n, t, r, g) {
12
+ t && !t.endsWith("/") && (t += "/");
13
+ const h = /* @__PURE__ */ new Set([
14
+ t + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
15
+ t + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
16
+ ]), o = new Set(r.map(P)), w = [], a = async (l, u, c) => {
17
+ if (c = P(c), h.has(c))
18
+ return;
19
+ const m = p(l, u);
20
+ if (u === "index.html" || u === "q-data.json") {
21
+ !o.has(c) && g && await d.promises.unlink(m);
22
+ return;
23
+ }
24
+ if (u === "404.html") {
25
+ const s = await d.promises.readFile(m, "utf-8");
26
+ w.push([c, s]);
27
+ return;
28
+ }
29
+ const k = await d.promises.stat(m);
30
+ k.isDirectory() ? await y(m, c + u + "/") : k.isFile() && o.add(c + u);
31
+ }, y = async (l, u) => {
32
+ const c = await d.promises.readdir(l);
33
+ await Promise.all(c.map((m) => a(l, m, u)));
34
+ };
35
+ d.existsSync(e) && await y(e, t);
36
+ const i = T(t, w), f = x(o);
37
+ await A(f, i, n);
38
+ }
39
+ function P(e) {
40
+ return e.endsWith("/") ? e : e + "/";
41
+ }
42
+ function T(e, n) {
43
+ if (n.sort((t, r) => t[0].length > r[0].length ? -1 : t[0].length < r[0].length ? 1 : t[0] < r[0] ? -1 : t[0] > r[0] ? 1 : 0), !n.some((t) => t[0] === e)) {
44
+ const t = O(404, "Resource Not Found");
45
+ n.push([e, t]);
46
+ }
47
+ return JSON.stringify(n, null, 2).slice(1, -1);
48
+ }
49
+ function x(e) {
50
+ return JSON.stringify(Array.from(new Set(e)).sort()).slice(1, -1);
51
+ }
52
+ const A = async (e, n, t) => {
53
+ const r = /* @__PURE__ */ new Set(), g = async (o) => {
54
+ const w = await d.promises.readFile(o, "utf-8");
55
+ let a = !1;
56
+ const y = w.replace(
57
+ /(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
58
+ (i, f, l) => (a = !0, l === "STATIC_PATHS" ? e : n)
59
+ );
60
+ a && await d.promises.writeFile(o, y);
61
+ }, h = async (o) => {
62
+ const w = await d.promises.readdir(o, { withFileTypes: !0 });
63
+ for (const a of w)
64
+ if (a.isDirectory())
65
+ await h(p(o, a.name));
66
+ else if (a.name.endsWith("js")) {
67
+ const y = g(p(o, a.name)).finally(() => {
68
+ r.delete(y);
69
+ });
70
+ r.add(y);
71
+ }
72
+ };
73
+ await h(t), await Promise.all(r);
74
+ };
75
+ function F(e) {
76
+ let n = null, t = null, r = null, g = null, h = null, o = !1, w;
77
+ const a = [];
78
+ return {
79
+ name: `vite-plugin-qwik-router-ssg-${e.name}`,
80
+ enforce: "post",
81
+ apply: "build",
82
+ config(i) {
83
+ return typeof e.config == "function" && (i = e.config(i)), i.define = {
84
+ "process.env.NODE_ENV": JSON.stringify("production"),
85
+ ...i.define
86
+ }, i;
87
+ },
88
+ configResolved(i) {
89
+ if (o = !!i.build.ssr, w = i.command, o) {
90
+ if (n = i.plugins.find(
91
+ (f) => f.name === "vite-plugin-qwik-router"
92
+ ), !n)
93
+ throw new Error("Missing vite-plugin-qwik-router");
94
+ if (t = i.plugins.find(
95
+ (f) => f.name === "vite-plugin-qwik"
96
+ ), !t)
97
+ throw new Error("Missing vite-plugin-qwik");
98
+ if (r = i.build.outDir, i.build?.ssr !== !0)
99
+ throw new Error(
100
+ `"build.ssr" must be set to "true" in order to use the "${e.name}" adapter.`
101
+ );
102
+ if (!i.build?.rollupOptions?.input)
103
+ throw new Error(
104
+ `"build.rollupOptions.input" must be set in order to use the "${e.name}" adapter.`
105
+ );
106
+ }
107
+ },
108
+ buildStart() {
109
+ if (o && e.ssg !== null) {
110
+ const { srcDir: i } = t.api.getOptions();
111
+ w === "build" && r && i && (this.emitFile({
112
+ id: "@qwik-router-config",
113
+ type: "chunk",
114
+ fileName: "@qwik-router-config.js"
115
+ }), this.emitFile({
116
+ id: `${i}/entry.ssr`,
117
+ type: "chunk",
118
+ fileName: "entry.ssr.js"
119
+ }));
120
+ }
121
+ },
122
+ generateBundle(i, f) {
123
+ if (o) {
124
+ a.length = 0;
125
+ for (const l in f) {
126
+ const u = f[l];
127
+ u.type === "chunk" && u.isEntry && (a.push(l), u.name === "entry.ssr" ? g = p(r, l) : u.name === "@qwik-router-config" && (h = p(r, l)));
128
+ }
129
+ }
130
+ },
131
+ closeBundle: {
132
+ sequential: !0,
133
+ async handler() {
134
+ if (o && r && n?.api && t?.api) {
135
+ const i = e.staticPaths || [], f = n.api.getRoutes(), l = n.api.getBasePathname(), u = t.api.getClientOutDir(), c = t.api.getClientPublicOutDir(), m = t.api.getAssetsDir(), k = t.api.getRootDir() ?? void 0;
136
+ if (e.ssg !== null && g && h && u && c) {
137
+ let s = e.ssg?.origin ?? e.origin;
138
+ s || (s = "https://yoursite.qwik.dev"), s.length > 0 && !/:\/\//.test(s) && (s = `https://${s}`), s.startsWith("//") && (s = `https:${s}`);
139
+ try {
140
+ s = new URL(s).origin;
141
+ } catch {
142
+ this.warn(
143
+ `Invalid "origin" option: "${s}". Using default origin: "https://yoursite.qwik.dev"`
144
+ ), s = "https://yoursite.qwik.dev";
145
+ }
146
+ const R = await import("./index-Bg_9YkM5.js"), q = {
147
+ maxWorkers: e.maxWorkers,
148
+ basePathname: l,
149
+ outDir: c,
150
+ rootDir: k,
151
+ ...e.ssg,
152
+ origin: s,
153
+ renderModulePath: g,
154
+ qwikRouterConfigModulePath: h
155
+ }, S = await R.generate(q);
156
+ if (S.errors > 0) {
157
+ const _ = new Error(
158
+ `Error while running SSG from "${e.name}" adapter. At least one path failed to render.`
159
+ );
160
+ _.stack = void 0, this.error(_);
161
+ }
162
+ i.push(...S.staticPaths);
163
+ }
164
+ await D(
165
+ c,
166
+ r,
167
+ m ? p(l, m) : l,
168
+ i,
169
+ !!e.cleanStaticGenerated
170
+ ), typeof e.generate == "function" && await e.generate({
171
+ outputEntries: a,
172
+ serverOutDir: r,
173
+ clientOutDir: u,
174
+ clientPublicOutDir: c,
175
+ basePathname: l,
176
+ routes: f,
177
+ assetsDir: m,
178
+ warn: (s) => this.warn(s),
179
+ error: (s) => this.error(s)
180
+ }), this.warn(
181
+ `
182
+ ==============================================
183
+ Note: Make sure that you are serving the built files with proper cache headers.
184
+ See https://qwik.dev/docs/deployments/#cache-headers for more information.
185
+ ==============================================`
186
+ ), e.ssg !== null && setTimeout(() => {
187
+ console.warn(
188
+ "SSG seems to be hanging after completion, forcing process to exit. Everything is likely fine."
189
+ ), process.exit(0);
190
+ }, 5e3).unref(), e.ssg !== null && setTimeout(() => {
191
+ process.exit(0);
192
+ }, 5e3).unref();
193
+ }
194
+ }
195
+ }
196
+ };
197
+ }
198
+ function $(e = {}) {
199
+ const n = process?.env;
200
+ return F({
201
+ name: "cloudflare-pages",
202
+ origin: n?.CF_PAGES_URL ?? n?.ORIGIN ?? "https://your.cloudflare.pages.dev",
203
+ ssg: e.ssg,
204
+ staticPaths: e.staticPaths,
205
+ cleanStaticGenerated: !0,
206
+ config() {
207
+ return {
208
+ resolve: {
209
+ conditions: ["webworker", "worker"]
210
+ },
211
+ ssr: {
212
+ target: "webworker",
213
+ noExternal: !0,
214
+ external: ["node:async_hooks"]
215
+ },
216
+ build: {
217
+ ssr: !0,
218
+ rollupOptions: {
219
+ output: {
220
+ format: "es",
221
+ hoistTransitiveImports: !1
222
+ }
223
+ }
224
+ },
225
+ publicDir: !1
226
+ };
227
+ },
228
+ async generate({ clientOutDir: t, serverOutDir: r, basePathname: g, assetsDir: h }) {
229
+ const o = p(t, "_routes.json");
230
+ if (!d.existsSync(o) && e.functionRoutes !== !1) {
231
+ let i = h ? p(g, h) : g;
232
+ i.endsWith("/") || (i += "/");
233
+ const f = {
234
+ version: 1,
235
+ include: [g + "*"],
236
+ exclude: [i + "build/*", i + "assets/*"]
237
+ };
238
+ await d.promises.writeFile(o, JSON.stringify(f, void 0, 2));
239
+ }
240
+ const a = p(t, "_worker.js");
241
+ if (!d.existsSync(a)) {
242
+ const i = E(t, p(r, "entry.cloudflare-pages"));
243
+ await d.promises.writeFile(
244
+ a,
245
+ `import { fetch } from "${v(i)}"; export default { fetch };`
246
+ );
247
+ }
248
+ }
249
+ });
250
+ }
251
+ export {
252
+ $ as c,
253
+ J as n
254
+ };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("node:fs"),E=require("node:path"),X=require("node:os"),_=require("node:worker_threads"),j=require("./index-BIeHg2Cj.cjs"),Y=require("@qwik.dev/core/internal"),U=require("@qwik.dev/router/middleware/request-handler"),Z=require("node:stream/web"),C=require("node:url"),x=require("kleur/colors"),ee=require("vite");var N=typeof document<"u"?document.currentScript:null;function A(e){return e<1?e.toFixed(2)+" ms":e<1e3?e.toFixed(1)+" ms":e<6e4?(e/1e3).toFixed(1)+" s":(e/6e4).toFixed(1)+" m"}function te(e,t,s){let r=e;if(t&&s)for(const i of t){const o=`[${i}]`,n=`[...${i}]`,c=s[i];r=r.replace(n,c),r=r.replace(o,c)}return r}async function re(e){delete globalThis.__qwik;const t=e.getOptions(),s=new Set,r={...t,render:(await import(C.pathToFileURL(t.renderModulePath).href)).default,qwikRouterConfig:(await import(C.pathToFileURL(t.qwikRouterConfigModulePath).href)).default};e.createWorkerProcess(async i=>{switch(i.type){case"render":return new Promise(o=>{H(e,r,i,s,o)});case"close":{const o=Array.from(s);return s.clear(),await Promise.all(o),{type:"close"}}}})}async function ne(e){delete globalThis.__qwik;const t=e.getOptions(),s=new Set,r={...t,render:(await import(C.pathToFileURL(t.renderModulePath).href)).default,qwikRouterConfig:(await import(C.pathToFileURL(t.qwikRouterConfigModulePath).href)).default};return i=>new Promise(o=>{H(e,r,i,s,o)})}async function H(e,t,s,r,i){const o=new URL(s.pathname,t.origin),n={type:"render",pathname:s.pathname,url:o.href,ok:!1,error:null,filePath:null,contentType:null,resourceType:null};try{let c=null,l;const g=new Promise(u=>{l=u}),P=new Request(o),y={mode:"static",locale:void 0,url:o,request:P,env:{get(u){return e.getEnv(u)}},platform:e.platform,getClientConn:()=>({}),getWritableStream:(u,v,$,w,W)=>{if(n.ok=u>=200&&u<300,!n.ok)return oe;n.contentType=(v.get("Content-Type")||"").toLowerCase();const m=n.contentType.includes("text/html"),p=o.pathname.endsWith("/404.html"),T=e.getRouteFilePath(o.pathname,m);p?n.resourceType="404":m&&(n.resourceType="page");const b=m?t.emitHtml!==!1:!0,h=m&&t.emitData!==!1;return new Z.WritableStream({async start(){try{(b||h)&&await e.ensureDir(T),b&&(c=e.createWriteStream(T),c.on("error",a=>{console.error(a),c=null,n.error={message:a.message,stack:a.stack}}))}catch(a){c=null,n.error={message:String(a),stack:a.stack||""}}},write(a){try{c&&c.write(Buffer.from(a.buffer))}catch(d){c=null,n.error={message:String(d),stack:d.stack||""}}},async close(){const a=[];try{if(h){const d=W.sharedMap.get(U.RequestEvShareQData);if(d&&!p){const k=e.getDataFilePath(o.pathname),R=e.createWriteStream(k);R.on("error",S=>{console.error(S),n.error={message:S.message,stack:S.stack}});const q=await Y._serialize([d]);R.write(q),a.push(new Promise(S=>{n.filePath=T,R.end(S)}))}}c&&a.push(new Promise(d=>{n.filePath=T,c.end(d)}).finally(l)),a.length>0&&await Promise.all(a)}catch(d){c=null,n.error={message:String(d),stack:d.stack||""}}}})}},f=U.requestHandler(y,t).then(u=>{if(u!=null)return u.completion.then(v=>c?g.then(()=>v):v)}).then(u=>{u!==void 0&&(u instanceof Error?n.error={message:u.message,stack:u.stack}:n.error={message:String(u),stack:void 0})}).finally(()=>{r.delete(f),i(n)});r.add(f)}catch(c){c instanceof Error?n.error={message:c.message,stack:c.stack}:n.error={message:String(c),stack:void 0},i(n)}}const se={closed:Promise.resolve(void 0),ready:Promise.resolve(void 0),desiredSize:0,async close(){},async abort(){},async write(){},releaseLock(){}},oe={get locked(){return!1},set locked(e){},async abort(){},async close(){},getWriter(){return se}};async function ie(e,t){const s=[],r=[];let i=null;t={...t};let o=t.outDir;if(typeof o!="string")throw new Error('Missing "outDir" option');if(!E.isAbsolute(o))throw new Error(`"outDir" must be an absolute file path, received: ${o}`);o=j.normalizePath(o);let n=X.cpus().length;typeof t.maxWorkers=="number"&&(n=Math.max(1,Math.min(t.maxWorkers,n)));let c=20;typeof t.maxTasksPerWorker=="number"&&(c=Math.max(1,Math.min(t.maxTasksPerWorker,50)));let l=t.sitemapOutFile;l!==null&&(typeof l!="string"&&(l="sitemap.xml"),E.isAbsolute(l)||(l=E.resolve(o,l)));const g=await ne(e),P=w=>{if(w===0){const h={activeTasks:0,totalTasks:0,render:async M=>{h.activeTasks++,h.totalTasks++;const a=await g(M);return h.activeTasks--,a},terminate:async()=>{}};return h}let W=null;const m=new Map;let p;typeof __filename=="string"?p=__filename:p=typeof document>"u"?require("url").pathToFileURL(__filename).href:N&&N.tagName.toUpperCase()==="SCRIPT"&&N.src||new URL("index-DKcVHRBy.cjs",document.baseURI).href,typeof p=="string"&&p.startsWith("file://")&&(p=new URL(p));const T=new _.Worker(p,{workerData:t}),b={activeTasks:0,totalTasks:0,render:h=>new Promise((M,a)=>{try{b.activeTasks++,b.totalTasks++,m.set(h.pathname,M),T.postMessage(h)}catch(d){b.activeTasks--,m.delete(h.pathname),a(d)}}),terminate:async()=>{m.clear();const h={type:"close"};await new Promise(M=>{W=M,T.postMessage(h)}),await T.terminate()}};return T.on("message",h=>{switch(h.type){case"render":{const M=m.get(h.pathname);M&&(m.delete(h.pathname),b.activeTasks--,M(h));break}case"close":{W&&(W(),W=null);break}}}),T.on("error",h=>{console.error("worker error",h)}),T.on("exit",h=>{h!==1&&console.error(`worker exit ${h}`)}),b},y=()=>s.sort(ae)[0],f=()=>y().activeTasks<c,u=async w=>{const m=await y().render(w);if(l&&m.ok&&m.resourceType==="page"&&(r.push(`<url><loc>${m.url}</loc></url>`),r.length>50)){i&&await i;const p=r.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("node:fs"),E=require("node:path"),X=require("node:os"),_=require("node:worker_threads"),j=require("./index-D9RL9dvJ.cjs"),Y=require("@qwik.dev/core/internal"),U=require("@qwik.dev/router/middleware/request-handler"),Z=require("node:stream/web"),C=require("node:url"),x=require("kleur/colors"),ee=require("vite");var N=typeof document<"u"?document.currentScript:null;function A(e){return e<1?e.toFixed(2)+" ms":e<1e3?e.toFixed(1)+" ms":e<6e4?(e/1e3).toFixed(1)+" s":(e/6e4).toFixed(1)+" m"}function te(e,t,s){let r=e;if(t&&s)for(const i of t){const o=`[${i}]`,n=`[...${i}]`,c=s[i];r=r.replace(n,c),r=r.replace(o,c)}return r}async function re(e){delete globalThis.__qwik;const t=e.getOptions(),s=new Set,r={...t,render:(await import(C.pathToFileURL(t.renderModulePath).href)).default,qwikRouterConfig:(await import(C.pathToFileURL(t.qwikRouterConfigModulePath).href)).default};e.createWorkerProcess(async i=>{switch(i.type){case"render":return new Promise(o=>{H(e,r,i,s,o)});case"close":{const o=Array.from(s);return s.clear(),await Promise.all(o),{type:"close"}}}})}async function ne(e){delete globalThis.__qwik;const t=e.getOptions(),s=new Set,r={...t,render:(await import(C.pathToFileURL(t.renderModulePath).href)).default,qwikRouterConfig:(await import(C.pathToFileURL(t.qwikRouterConfigModulePath).href)).default};return i=>new Promise(o=>{H(e,r,i,s,o)})}async function H(e,t,s,r,i){const o=new URL(s.pathname,t.origin),n={type:"render",pathname:s.pathname,url:o.href,ok:!1,error:null,filePath:null,contentType:null,resourceType:null};try{let c=null,l;const g=new Promise(u=>{l=u}),P=new Request(o),y={mode:"static",locale:void 0,url:o,request:P,env:{get(u){return e.getEnv(u)}},platform:e.platform,getClientConn:()=>({}),getWritableStream:(u,v,$,w,W)=>{if(n.ok=u>=200&&u<300,!n.ok)return oe;n.contentType=(v.get("Content-Type")||"").toLowerCase();const m=n.contentType.includes("text/html"),p=o.pathname.endsWith("/404.html"),T=e.getRouteFilePath(o.pathname,m);p?n.resourceType="404":m&&(n.resourceType="page");const b=m?t.emitHtml!==!1:!0,h=m&&t.emitData!==!1;return new Z.WritableStream({async start(){try{(b||h)&&await e.ensureDir(T),b&&(c=e.createWriteStream(T),c.on("error",a=>{console.error(a),c=null,n.error={message:a.message,stack:a.stack}}))}catch(a){c=null,n.error={message:String(a),stack:a.stack||""}}},write(a){try{c&&c.write(Buffer.from(a.buffer))}catch(d){c=null,n.error={message:String(d),stack:d.stack||""}}},async close(){const a=[];try{if(h){const d=W.sharedMap.get(U.RequestEvShareQData);if(d&&!p){const k=e.getDataFilePath(o.pathname),R=e.createWriteStream(k);R.on("error",S=>{console.error(S),n.error={message:S.message,stack:S.stack}});const q=await Y._serialize([d]);R.write(q),a.push(new Promise(S=>{n.filePath=T,R.end(S)}))}}c&&a.push(new Promise(d=>{n.filePath=T,c.end(d)}).finally(l)),a.length>0&&await Promise.all(a)}catch(d){c=null,n.error={message:String(d),stack:d.stack||""}}}})}},f=U.requestHandler(y,t).then(u=>{if(u!=null)return u.completion.then(v=>c?g.then(()=>v):v)}).then(u=>{u!==void 0&&(u instanceof Error?n.error={message:u.message,stack:u.stack}:n.error={message:String(u),stack:void 0})}).finally(()=>{r.delete(f),i(n)});r.add(f)}catch(c){c instanceof Error?n.error={message:c.message,stack:c.stack}:n.error={message:String(c),stack:void 0},i(n)}}const se={closed:Promise.resolve(void 0),ready:Promise.resolve(void 0),desiredSize:0,async close(){},async abort(){},async write(){},releaseLock(){}},oe={get locked(){return!1},set locked(e){},async abort(){},async close(){},getWriter(){return se}};async function ie(e,t){const s=[],r=[];let i=null;t={...t};let o=t.outDir;if(typeof o!="string")throw new Error('Missing "outDir" option');if(!E.isAbsolute(o))throw new Error(`"outDir" must be an absolute file path, received: ${o}`);o=j.normalizePath(o);let n=X.cpus().length;typeof t.maxWorkers=="number"&&(n=Math.max(1,Math.min(t.maxWorkers,n)));let c=20;typeof t.maxTasksPerWorker=="number"&&(c=Math.max(1,Math.min(t.maxTasksPerWorker,50)));let l=t.sitemapOutFile;l!==null&&(typeof l!="string"&&(l="sitemap.xml"),E.isAbsolute(l)||(l=E.resolve(o,l)));const g=await ne(e),P=w=>{if(w===0){const h={activeTasks:0,totalTasks:0,render:async M=>{h.activeTasks++,h.totalTasks++;const a=await g(M);return h.activeTasks--,a},terminate:async()=>{}};return h}let W=null;const m=new Map;let p;typeof __filename=="string"?p=__filename:p=typeof document>"u"?require("url").pathToFileURL(__filename).href:N&&N.tagName.toUpperCase()==="SCRIPT"&&N.src||new URL("index-Ck7KvpK1.cjs",document.baseURI).href,typeof p=="string"&&p.startsWith("file://")&&(p=new URL(p));const T=new _.Worker(p,{workerData:t}),b={activeTasks:0,totalTasks:0,render:h=>new Promise((M,a)=>{try{b.activeTasks++,b.totalTasks++,m.set(h.pathname,M),T.postMessage(h)}catch(d){b.activeTasks--,m.delete(h.pathname),a(d)}}),terminate:async()=>{m.clear();const h={type:"close"};await new Promise(M=>{W=M,T.postMessage(h)}),await T.terminate()}};return T.on("message",h=>{switch(h.type){case"render":{const M=m.get(h.pathname);M&&(m.delete(h.pathname),b.activeTasks--,M(h));break}case"close":{W&&(W(),W=null);break}}}),T.on("error",h=>{console.error("worker error",h)}),T.on("exit",h=>{h!==1&&console.error(`worker exit ${h}`)}),b},y=()=>s.sort(ae)[0],f=()=>y().activeTasks<c,u=async w=>{const m=await y().render(w);if(l&&m.ok&&m.resourceType==="page"&&(r.push(`<url><loc>${m.url}</loc></url>`),r.length>50)){i&&await i;const p=r.join(`
2
2
  `)+`
3
3
  `;r.length=0,i=F.promises.appendFile(l,p)}return m},v=async()=>{const w=[];l&&(i&&await i,r.push("</urlset>"),w.push(F.promises.appendFile(l,r.join(`
4
4
  `))),r.length=0);for(const W of s)try{w.push(W.terminate())}catch(m){console.error(m)}s.length=0,await Promise.all(w)};l&&(await B(l),await F.promises.writeFile(l,`<?xml version="1.0" encoding="UTF-8"?>