@qwik.dev/router 2.0.0-alpha.9 → 2.0.0-beta.10

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 (159) hide show
  1. package/README.md +1 -1
  2. package/adapters/static/vite.d.ts +1 -1
  3. package/lib/adapters/azure-swa/vite/index-BqUeglYs.cjs +1 -0
  4. package/lib/adapters/azure-swa/vite/index-CBIchDYq.js +651 -0
  5. package/lib/adapters/azure-swa/vite/index-ClHGw5z1.js +6 -0
  6. package/lib/adapters/azure-swa/vite/index-CrwlB95_.js +22 -0
  7. package/lib/adapters/azure-swa/vite/index-DTIOTwZo.cjs +11 -0
  8. package/lib/adapters/azure-swa/vite/index-vQuPcef3.cjs +1 -0
  9. package/lib/adapters/azure-swa/vite/index.cjs +5 -96
  10. package/lib/adapters/azure-swa/vite/index.d.ts +13 -13
  11. package/lib/adapters/azure-swa/vite/index.mjs +201 -26
  12. package/lib/adapters/bun-server/vite/index-BqUeglYs.cjs +1 -0
  13. package/lib/adapters/bun-server/vite/index-CBIchDYq.js +651 -0
  14. package/lib/adapters/bun-server/vite/index-ClHGw5z1.js +6 -0
  15. package/lib/adapters/bun-server/vite/index-CrwlB95_.js +22 -0
  16. package/lib/adapters/bun-server/vite/index-DTIOTwZo.cjs +11 -0
  17. package/lib/adapters/bun-server/vite/index-vQuPcef3.cjs +1 -0
  18. package/lib/adapters/bun-server/vite/index.cjs +5 -50
  19. package/lib/adapters/bun-server/vite/index.d.ts +14 -14
  20. package/lib/adapters/bun-server/vite/index.mjs +196 -12
  21. package/lib/adapters/cloud-run/vite/index-BqUeglYs.cjs +1 -0
  22. package/lib/adapters/cloud-run/vite/index-CBIchDYq.js +651 -0
  23. package/lib/adapters/cloud-run/vite/index-ClHGw5z1.js +6 -0
  24. package/lib/adapters/cloud-run/vite/index-CrwlB95_.js +22 -0
  25. package/lib/adapters/cloud-run/vite/index-DTIOTwZo.cjs +11 -0
  26. package/lib/adapters/cloud-run/vite/index-vQuPcef3.cjs +1 -0
  27. package/lib/adapters/cloud-run/vite/index.cjs +5 -47
  28. package/lib/adapters/cloud-run/vite/index.d.ts +13 -13
  29. package/lib/adapters/cloud-run/vite/index.mjs +195 -11
  30. package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +5 -0
  31. package/lib/adapters/cloudflare-pages/vite/index-C455V8_A.cjs +1 -0
  32. package/lib/adapters/cloudflare-pages/vite/index-ClHGw5z1.js +6 -0
  33. package/lib/adapters/cloudflare-pages/vite/index-D3HITboM.js +645 -0
  34. package/lib/adapters/cloudflare-pages/vite/index-DKcVHRBy.cjs +11 -0
  35. package/lib/adapters/cloudflare-pages/vite/index-DwovcBp3.js +22 -0
  36. package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +250 -0
  37. package/lib/adapters/cloudflare-pages/vite/index-vQuPcef3.cjs +1 -0
  38. package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -115
  39. package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -27
  40. package/lib/adapters/cloudflare-pages/vite/index.mjs +4 -78
  41. package/lib/adapters/deno-server/vite/index-BqUeglYs.cjs +1 -0
  42. package/lib/adapters/deno-server/vite/index-CBIchDYq.js +651 -0
  43. package/lib/adapters/deno-server/vite/index-ClHGw5z1.js +6 -0
  44. package/lib/adapters/deno-server/vite/index-CrwlB95_.js +22 -0
  45. package/lib/adapters/deno-server/vite/index-DTIOTwZo.cjs +11 -0
  46. package/lib/adapters/deno-server/vite/index-vQuPcef3.cjs +1 -0
  47. package/lib/adapters/deno-server/vite/index.cjs +5 -62
  48. package/lib/adapters/deno-server/vite/index.d.ts +14 -14
  49. package/lib/adapters/deno-server/vite/index.mjs +198 -14
  50. package/lib/adapters/netlify-edge/vite/index-BqUeglYs.cjs +1 -0
  51. package/lib/adapters/netlify-edge/vite/index-CBIchDYq.js +651 -0
  52. package/lib/adapters/netlify-edge/vite/index-ClHGw5z1.js +6 -0
  53. package/lib/adapters/netlify-edge/vite/index-CrwlB95_.js +22 -0
  54. package/lib/adapters/netlify-edge/vite/index-DTIOTwZo.cjs +11 -0
  55. package/lib/adapters/netlify-edge/vite/index-vQuPcef3.cjs +1 -0
  56. package/lib/adapters/netlify-edge/vite/index.cjs +6 -129
  57. package/lib/adapters/netlify-edge/vite/index.d.ts +44 -44
  58. package/lib/adapters/netlify-edge/vite/index.mjs +240 -60
  59. package/lib/adapters/node-server/vite/index-BqUeglYs.cjs +1 -0
  60. package/lib/adapters/node-server/vite/index-CBIchDYq.js +651 -0
  61. package/lib/adapters/node-server/vite/index-ClHGw5z1.js +6 -0
  62. package/lib/adapters/node-server/vite/index-CrwlB95_.js +22 -0
  63. package/lib/adapters/node-server/vite/index-DTIOTwZo.cjs +11 -0
  64. package/lib/adapters/node-server/vite/index-vQuPcef3.cjs +1 -0
  65. package/lib/adapters/node-server/vite/index.cjs +5 -50
  66. package/lib/adapters/node-server/vite/index.d.ts +14 -14
  67. package/lib/adapters/node-server/vite/index.mjs +196 -12
  68. package/lib/adapters/shared/vite/index-BqUeglYs.cjs +1 -0
  69. package/lib/adapters/shared/vite/index-CBIchDYq.js +651 -0
  70. package/lib/adapters/shared/vite/index-ClHGw5z1.js +6 -0
  71. package/lib/adapters/shared/vite/index-CrwlB95_.js +22 -0
  72. package/lib/adapters/shared/vite/index-DTIOTwZo.cjs +11 -0
  73. package/lib/adapters/shared/vite/index-vQuPcef3.cjs +1 -0
  74. package/lib/adapters/shared/vite/index.cjs +5 -371
  75. package/lib/adapters/shared/vite/index.d.ts +108 -114
  76. package/lib/adapters/shared/vite/index.mjs +158 -288
  77. package/lib/adapters/ssg/vite/index-BqUeglYs.cjs +1 -0
  78. package/lib/adapters/ssg/vite/index-CBIchDYq.js +651 -0
  79. package/lib/adapters/ssg/vite/index-ClHGw5z1.js +6 -0
  80. package/lib/adapters/ssg/vite/index-CrwlB95_.js +22 -0
  81. package/lib/adapters/ssg/vite/index-DTIOTwZo.cjs +11 -0
  82. package/lib/adapters/ssg/vite/index-vQuPcef3.cjs +1 -0
  83. package/lib/adapters/ssg/vite/index.cjs +5 -0
  84. package/lib/adapters/ssg/vite/index.d.ts +13 -0
  85. package/lib/adapters/ssg/vite/index.mjs +201 -0
  86. package/lib/adapters/vercel-edge/vite/index-BqUeglYs.cjs +1 -0
  87. package/lib/adapters/vercel-edge/vite/index-CBIchDYq.js +651 -0
  88. package/lib/adapters/vercel-edge/vite/index-ClHGw5z1.js +6 -0
  89. package/lib/adapters/vercel-edge/vite/index-CrwlB95_.js +22 -0
  90. package/lib/adapters/vercel-edge/vite/index-DTIOTwZo.cjs +11 -0
  91. package/lib/adapters/vercel-edge/vite/index-vQuPcef3.cjs +1 -0
  92. package/lib/adapters/vercel-edge/vite/index.cjs +5 -118
  93. package/lib/adapters/vercel-edge/vite/index.d.ts +45 -45
  94. package/lib/adapters/vercel-edge/vite/index.mjs +230 -51
  95. package/lib/index.d.ts +1000 -810
  96. package/lib/index.qwik.cjs +438 -203
  97. package/lib/index.qwik.mjs +440 -205
  98. package/lib/middleware/aws-lambda/index.cjs +1 -0
  99. package/lib/middleware/aws-lambda/index.d.ts +49 -48
  100. package/lib/middleware/aws-lambda/index.mjs +27 -41
  101. package/lib/middleware/azure-swa/index.cjs +1 -0
  102. package/lib/middleware/azure-swa/index.d.ts +28 -28
  103. package/lib/middleware/azure-swa/index.mjs +46 -269
  104. package/lib/middleware/bun/index.cjs +1 -0
  105. package/lib/middleware/bun/index.d.ts +35 -35
  106. package/lib/middleware/bun/index.mjs +68 -120
  107. package/lib/middleware/cloudflare-pages/index.cjs +1 -0
  108. package/lib/middleware/cloudflare-pages/index.d.ts +35 -35
  109. package/lib/middleware/cloudflare-pages/index.mjs +48 -80
  110. package/lib/middleware/deno/index.cjs +1 -0
  111. package/lib/middleware/deno/index.d.ts +47 -47
  112. package/lib/middleware/deno/index.mjs +63 -110
  113. package/lib/middleware/firebase/index.cjs +1 -0
  114. package/lib/middleware/firebase/index.d.ts +26 -26
  115. package/lib/middleware/firebase/index.mjs +16 -28
  116. package/lib/middleware/netlify-edge/index.cjs +1 -0
  117. package/lib/middleware/netlify-edge/index.d.ts +27 -27
  118. package/lib/middleware/netlify-edge/index.mjs +36 -64
  119. package/lib/middleware/node/index.cjs +1 -314
  120. package/lib/middleware/node/index.d.ts +64 -64
  121. package/lib/middleware/node/index.mjs +116 -198
  122. package/lib/middleware/request-handler/index.cjs +11 -1538
  123. package/lib/middleware/request-handler/index.d.ts +711 -676
  124. package/lib/middleware/request-handler/index.mjs +895 -1281
  125. package/lib/middleware/vercel-edge/index.cjs +1 -0
  126. package/lib/middleware/vercel-edge/index.d.ts +26 -26
  127. package/lib/middleware/vercel-edge/index.mjs +47 -82
  128. package/lib/modules.d.ts +4 -12
  129. package/lib/service-worker.cjs +1 -267
  130. package/lib/service-worker.d.ts +15 -4
  131. package/lib/service-worker.mjs +3 -263
  132. package/lib/ssg/deno.cjs +1 -0
  133. package/lib/ssg/deno.mjs +6 -0
  134. package/lib/ssg/index-CBIchDYq.js +651 -0
  135. package/lib/ssg/index-ClHGw5z1.js +6 -0
  136. package/lib/ssg/index-DTIOTwZo.cjs +11 -0
  137. package/lib/ssg/index-vQuPcef3.cjs +1 -0
  138. package/lib/ssg/index.cjs +1 -0
  139. package/lib/{static → ssg}/index.d.ts +96 -96
  140. package/lib/ssg/index.mjs +22 -0
  141. package/lib/ssg/node.cjs +11 -0
  142. package/lib/ssg/node.mjs +651 -0
  143. package/lib/vite/index.cjs +29 -27484
  144. package/lib/vite/index.d.ts +170 -154
  145. package/lib/vite/index.mjs +1422 -27288
  146. package/modules.d.ts +4 -12
  147. package/package.json +51 -40
  148. package/ssg.d.ts +2 -0
  149. package/static.d.ts +1 -1
  150. package/lib/adapters/static/vite/index.cjs +0 -361
  151. package/lib/adapters/static/vite/index.d.ts +0 -10
  152. package/lib/adapters/static/vite/index.mjs +0 -324
  153. package/lib/static/deno.mjs +0 -8
  154. package/lib/static/index.cjs +0 -67
  155. package/lib/static/index.mjs +0 -48
  156. package/lib/static/node.cjs +0 -1124
  157. package/lib/static/node.mjs +0 -1086
  158. package/middleware/request-handler/generated/not-found-paths.ts +0 -7
  159. package/middleware/request-handler/generated/static-paths.ts +0 -35
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("node:fs"),q=require("node:path"),X=require("node:os"),_=require("node:worker_threads"),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 j(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}function A(e){return re(q.normalize(e))}function re(e){const t=/^\\\\\?\\/.test(e),s=/[^\u0000-\u0080]+/.test(e);return t||s||(e=e.replace(/\\/g,"/"),e.endsWith("/")&&(e=e.slice(0,e.length-1))),e}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};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 se(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,$,p,W)=>{if(n.ok=u>=200&&u<300,!n.ok)return ie;n.contentType=(v.get("Content-Type")||"").toLowerCase();const h=n.contentType.includes("text/html"),w=o.pathname.endsWith("/404.html"),T=e.getRouteFilePath(o.pathname,h);w?n.resourceType="404":h&&(n.resourceType="page");const b=h?t.emitHtml!==!1:!0,m=h&&t.emitData!==!1;return new Z.WritableStream({async start(){try{(b||m)&&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(m){const d=W.sharedMap.get(U.RequestEvShareQData);if(d&&!w){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 F=await Y._serialize([d]);R.write(F),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 oe={closed:Promise.resolve(void 0),ready:Promise.resolve(void 0),desiredSize:0,async close(){},async abort(){},async write(){},releaseLock(){}},ie={get locked(){return!1},set locked(e){},async abort(){},async close(){},getWriter(){return oe}};async function ae(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(!q.isAbsolute(o))throw new Error(`"outDir" must be an absolute file path, received: ${o}`);o=A(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"),q.isAbsolute(l)||(l=q.resolve(o,l)));const g=await se(e),P=p=>{if(p===0){const m={activeTasks:0,totalTasks:0,render:async M=>{m.activeTasks++,m.totalTasks++;const a=await g(M);return m.activeTasks--,a},terminate:async()=>{}};return m}let W=null;const h=new Map;let w;typeof __filename=="string"?w=__filename:w=typeof document>"u"?require("url").pathToFileURL(__filename).href:N&&N.tagName.toUpperCase()==="SCRIPT"&&N.src||new URL("index-DTIOTwZo.cjs",document.baseURI).href,typeof w=="string"&&w.startsWith("file://")&&(w=new URL(w));const T=new _.Worker(w,{workerData:t}),b={activeTasks:0,totalTasks:0,render:m=>new Promise((M,a)=>{try{b.activeTasks++,b.totalTasks++,h.set(m.pathname,M),T.postMessage(m)}catch(d){b.activeTasks--,h.delete(m.pathname),a(d)}}),terminate:async()=>{h.clear();const m={type:"close"};await new Promise(M=>{W=M,T.postMessage(m)}),await T.terminate()}};return T.on("message",m=>{switch(m.type){case"render":{const M=h.get(m.pathname);M&&(h.delete(m.pathname),b.activeTasks--,M(m));break}case"close":{W&&(W(),W=null);break}}}),T.on("error",m=>{console.error("worker error",m)}),T.on("exit",m=>{m!==1&&console.error(`worker exit ${m}`)}),b},y=()=>s.sort(ce)[0],f=()=>y().activeTasks<c,u=async p=>{const h=await y().render(p);if(l&&h.ok&&h.resourceType==="page"&&(r.push(`<url><loc>${h.url}</loc></url>`),r.length>50)){i&&await i;const w=r.join(`
2
+ `)+`
3
+ `;r.length=0,i=E.promises.appendFile(l,w)}return h},v=async()=>{const p=[];l&&(i&&await i,r.push("</urlset>"),p.push(E.promises.appendFile(l,r.join(`
4
+ `))),r.length=0);for(const W of s)try{p.push(W.terminate())}catch(h){console.error(h)}s.length=0,await Promise.all(p)};l&&(await B(l),await E.promises.writeFile(l,`<?xml version="1.0" encoding="UTF-8"?>
5
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
6
+ `));for(let p=0;p<n;p++)s.push(P(p));return{hasAvailableWorker:f,render:u,close:v}}function ce(e,t){return e.activeTasks<t.activeTasks?-1:e.activeTasks>t.activeTasks?1:e.totalTasks<t.totalTasks?-1:1}async function le(e){_.parentPort?.on("message",async t=>{_.parentPort?.postMessage(await e(t))})}async function Q(e){const t=f=>E.createWriteStream(f,{flags:"w"}),i=()=>{const f=process.hrtime();return()=>{const u=process.hrtime(f);return(u[0]*1e9+u[1])*1e-6}},o=async()=>({debug:e.log==="debug"?console.debug.bind(console):()=>{},error:console.error.bind(console),info:console.info.bind(console)}),n=A(e.outDir),l=(e.basePathname||"/").length,y={createMainProcess:null,createWorkerProcess:le,createLogger:o,getOptions:()=>e,ensureDir:B,createWriteStream:t,createTimer:i,access:ue,getRouteFilePath:(f,u)=>(f=f.slice(l),u?f.endsWith(".html")||(f.endsWith("/")?f+="index.html":f+="/index.html"):f.endsWith("/")&&(f=f.slice(0,-1)),q.join(n,f)),getDataFilePath:f=>(f=f.slice(l),f.endsWith("/")?f+="q-data.json":f+="/q-data.json",q.join(n,f)),getEnv:f=>process.env[f],platform:{static:!0,node:process.versions.node}};return y.createMainProcess=()=>ae(y,e),y}const B=async e=>{await E.promises.mkdir(q.dirname(e),{recursive:!0})},ue=async e=>{try{return await E.promises.access(e),!0}catch{return!1}},fe=e=>{const t=e.stack;if(typeof t=="string"){const s=t.split(`
7
+ `).filter(r=>!r.includes("/node_modules/")&&!r.includes("(node:"));for(let r=1;r<s.length;r++){const i=s[r].replace("file:///","/");if(/^\s+at/.test(i)){const o=i.indexOf("/"),n=i.lastIndexOf(")",o);if(o>0){const l=i.slice(o,n).split(":"),g=G(l[l.length-1]),P=G(l[l.length-2]);return typeof g=="number"&&typeof P=="number"?(l.length-=2,{file:l.join(":"),line:P,column:g}):typeof g=="number"?(l.length-=1,{file:l.join(":"),line:g,column:void 0}):{file:l.join(":"),line:void 0,column:void 0}}}}}},G=e=>{try{return parseInt(e,10)}catch{return}},V=/\r?\n/,z=2;function de(e,t){if(typeof t=="number")return t;if(t.lo!=null)return t.lo;const s=e.split(V),{line:r,column:i}=t;let o=0;for(let n=0;n<r-1&&n<s.length;n++)o+=s[n].length+1;return o+i}function me(e,t=0,s){t=de(e,t),s=s||t;const r=e.split(V);let i=0;const o=[];for(let n=0;n<r.length;n++)if(i+=r[n].length+1,i>=t){for(let c=n-z;c<=n+z||s>i;c++){if(c<0||c>=r.length)continue;const l=c+1;o.push(`${l}${" ".repeat(Math.max(3-String(l).length,0))}| ${r[c]}`);const g=r[c].length;if(c===n){const P=Math.max(t-(i-g)+1,0),y=Math.max(1,s>i?g-P:s-t);o.push(" | "+" ".repeat(P)+"^".repeat(y))}else if(c>n){if(s>i){const P=Math.max(Math.min(s-i,g),1);o.push(" | "+"^".repeat(P))}i+=g+1}}break}return o.join(`
8
+ `)}function he(e){if(e instanceof Error){const t=e;let s=t.loc;if(!t.frame&&!t.plugin&&(s||(s=fe(t)),s&&(t.loc=s,s.file))){t.id=A(t.loc.file);try{const r=E.readFileSync(t.loc.file,"utf-8");t.frame=me(r,t.loc)}catch{}}}return e}function ge(e){const t=[];let s=0;for(;s<e.length;){const r=e.indexOf("[",s);if(r!==-1){const i=e.indexOf("]",r),o=e.slice(r+1,i);t.push(o.startsWith("...")?o.substring(3):o),s=i+1}else s=e.length}return t}var K=(e=>(e[e.RouteName=0]="RouteName",e[e.Loaders=1]="Loaders",e[e.OriginalPathname=2]="OriginalPathname",e[e.RouteBundleNames=3]="RouteBundleNames",e))(K||{});async function we(e,t,s){if(t.emit404Pages!==!1){const i=(t.basePathname||"/")+"404.html";if(!s.some(n=>n[K.OriginalPathname]===i)){const n=e.getRouteFilePath(i,!0),c=U.getErrorHtml(404,"Resource Not Found");return await e.ensureDir(n),new Promise(l=>{const g=e.createWriteStream(n);g.write(c),g.end(l)})}}}function pe(e,t,s){const r=I(t),i=I(s);return o=>{if(o.endsWith("404.html"))return!0;e!=="/"&&(o=o.slice(e.length-1));for(const n of i)if(n.test(o))return!1;for(const n of r)if(n.test(o))return!0;return!1}}function I(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(ke):[]}function ke(e){let t;return e==="/"||e==="/*"?t=e:e.endsWith("/*")?t=`${e.substring(0,e.length-2)}(/*)?`:e.endsWith("/")?t=`${e.substring(0,e.length-1)}(/)?`:e.endsWith("*")?t=e:t=`${e}(/)?`,t=`^${t.replace(/\*/g,".*")}$`,new RegExp(t)}async function Pe(e){const t=e.getOptions();ye(t);const s=await e.createMainProcess(),r=await e.createLogger();r.info(`
9
+ `+x.bold(x.green("Starting Qwik Router SSG...")));const i=(await import(C.pathToFileURL(t.qwikRouterConfigModulePath).href)).default,o=[],n=new Set,c=i.routes||[],l=!!i.trailingSlash,g=pe(t.basePathname||"/",t.include,t.exclude);return new Promise((P,y)=>{try{const f=e.createTimer(),u={duration:0,rendered:0,errors:0,staticPaths:[]};let v=!1,$=!1;const p=async()=>{const a=s.close();if(await we(e,t,c),u.duration=f(),u.errors===0){r.info(`
10
+ ${x.green("SSG results")}`),u.rendered>0&&r.info(`- Generated: ${x.dim(`${u.rendered} page${u.rendered===1?"":"s"}`)}`),r.info(`- Duration: ${x.dim(j(u.duration))}`);const d=u.rendered+u.errors;d>0&&r.info(`- Average: ${x.dim(j(u.duration/d)+" per page")}`),r.info("")}a.then(()=>{setTimeout(()=>P(u))}).catch(y)},W=()=>{for(;!v&&s.hasAvailableWorker()&&o.length>0;){const a=o.shift();a&&T(a)}!v&&$&&o.length===0&&n.size===0&&(v=!0,p())};let h=!1;const w=()=>{h||(h=!0,setTimeout(()=>{h=!1,W()}))},T=async a=>{try{n.add(a.pathname);const d=await s.render({type:"render",...a});if(n.delete(a.pathname),d.error){const k=new Error(d.error.message);k.stack=d.error.stack,r.error(`
11
+ ${x.bold(x.red(`!!! ${d.pathname}: Error during SSG`))}`),r.error(x.red(k.message)),r.error(` Pathname: ${x.magenta(a.pathname)}`),Object.assign(he(k),{plugin:"qwik-ssg"}),r.error(ee.buildErrorMessage(k)),u.errors++}if(d.filePath!=null){u.rendered++,u.staticPaths.push(d.pathname);const k=t.rootDir??t.outDir,R=q.relative(k,d.filePath),F=R.lastIndexOf("/");r.info(`${x.dim(R.slice(0,F+1))}${R.slice(F+1)}`)}w()}catch(d){v=!0,y(d)}},b=(a,d)=>{if(a){if(a=new URL(a,"https://qwik.dev").pathname,a!==t.basePathname)if(l){if(!a.endsWith("/")){const k=a.split("/");k[k.length-1].includes(".")||(a+="/")}}else a.endsWith("/")&&(a=a.slice(0,a.length-1));g(a)&&!o.some(k=>k.pathname===a)&&(o.push({pathname:a,params:d}),w())}},m=async a=>{const[d,k,R]=a,F=await Promise.all(k.map(O=>O())),S=F[F.length-1],L=ge(d);if(S&&(S.default||S.onRequest||S.onGet))if(Array.isArray(L)&&L.length>0){if(typeof S.onStaticGenerate=="function"&&L.length>0){const O=await S.onStaticGenerate({env:{get(D){return e.getEnv(D)}}});if(Array.isArray(O.params))for(const D of O.params){const J=te(R,L,D);b(J,D)}}}else b(R,void 0)};(async()=>{await Promise.all(c.map(m)),$=!0,w()})()}catch(f){y(f)}})}function ye(e){if(!e.qwikRouterConfigModulePath)if(e.qwikCityPlanModulePath)console.warn("`qwikCityPlanModulePath` is deprecated. Use `qwikRouterConfigModulePath` instead.");else throw new Error('Missing "qwikRouterConfigModulePath" option');if(!e.renderModulePath)throw new Error('Missing "renderModulePath" option');let t=e.origin;if(typeof t!="string"||t.trim().length===0)throw new Error('Missing "origin" option');if(t=t.trim(),!/:\/\//.test(t)||t.startsWith("://"))throw new Error(`"origin" must start with a valid protocol, such as "https://" or "http://", received "${t}"`);try{new URL(t)}catch(s){throw new Error(`Invalid "origin": ${s}`)}}async function Te(e){if(_.isMainThread){const t=await Q(e);return await Pe(t)}throw new Error("generate() cannot be called from a worker thread")}!_.isMainThread&&_.workerData&&(async()=>{const e=await Q(_.workerData);await ne(e)})();exports.generate=Te;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function e(t){console.error("Deno not implemented"),Deno.exit(1)}exports.generate=e;
@@ -1,371 +1,5 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/qwik-router/src/adapters/shared/vite/index.ts
31
- var vite_exports = {};
32
- __export(vite_exports, {
33
- NOT_FOUND_PATHS_ID: () => NOT_FOUND_PATHS_ID,
34
- RESOLVED_NOT_FOUND_PATHS_ID: () => RESOLVED_NOT_FOUND_PATHS_ID,
35
- RESOLVED_STATIC_PATHS_ID: () => RESOLVED_STATIC_PATHS_ID,
36
- STATIC_PATHS_ID: () => STATIC_PATHS_ID,
37
- getParentDir: () => getParentDir,
38
- viteAdapter: () => viteAdapter
39
- });
40
- module.exports = __toCommonJS(vite_exports);
41
- var import_node_fs2 = __toESM(require("node:fs"), 1);
42
- var import_node_path2 = require("node:path");
43
-
44
- // packages/qwik-router/src/adapters/shared/vite/post-build.ts
45
- var import_request_handler = require("../../../middleware/request-handler/index.cjs");
46
- var import_node_fs = __toESM(require("node:fs"), 1);
47
- var import_node_path = require("node:path");
48
- async function postBuild(clientOutDir, pathName, userStaticPaths, format, cleanStatic) {
49
- if (pathName && !pathName.endsWith("/")) {
50
- pathName += "/";
51
- }
52
- const ignorePathnames = /* @__PURE__ */ new Set([pathName + "build/", pathName + "assets/"]);
53
- const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
54
- const notFounds = [];
55
- const loadItem = async (fsDir, fsName, pathname) => {
56
- pathname = normalizeTrailingSlash(pathname);
57
- if (ignorePathnames.has(pathname)) {
58
- return;
59
- }
60
- const fsPath = (0, import_node_path.join)(fsDir, fsName);
61
- if (fsName === "index.html" || fsName === "q-data.json") {
62
- if (!staticPaths.has(pathname) && cleanStatic) {
63
- await import_node_fs.default.promises.unlink(fsPath);
64
- }
65
- return;
66
- }
67
- if (fsName === "404.html") {
68
- const notFoundHtml = await import_node_fs.default.promises.readFile(fsPath, "utf-8");
69
- notFounds.push([pathname, notFoundHtml]);
70
- return;
71
- }
72
- const stat = await import_node_fs.default.promises.stat(fsPath);
73
- if (stat.isDirectory()) {
74
- await loadDir(fsPath, pathname + fsName + "/");
75
- } else if (stat.isFile()) {
76
- staticPaths.add(pathname + fsName);
77
- }
78
- };
79
- const loadDir = async (fsDir, pathname) => {
80
- const itemNames = await import_node_fs.default.promises.readdir(fsDir);
81
- await Promise.all(itemNames.map((i) => loadItem(fsDir, i, pathname)));
82
- };
83
- if (import_node_fs.default.existsSync(clientOutDir)) {
84
- await loadDir(clientOutDir, pathName);
85
- }
86
- const notFoundPathsCode = createNotFoundPathsModule(pathName, notFounds, format);
87
- const staticPathsCode = createStaticPathsModule(pathName, staticPaths, format);
88
- return {
89
- notFoundPathsCode,
90
- staticPathsCode
91
- };
92
- }
93
- function normalizeTrailingSlash(pathname) {
94
- if (!pathname.endsWith("/")) {
95
- return pathname + "/";
96
- }
97
- return pathname;
98
- }
99
- function createNotFoundPathsModule(basePathname, notFounds, format) {
100
- notFounds.sort((a, b) => {
101
- if (a[0].length > b[0].length) {
102
- return -1;
103
- }
104
- if (a[0].length < b[0].length) {
105
- return 1;
106
- }
107
- if (a[0] < b[0]) {
108
- return -1;
109
- }
110
- if (a[0] > b[0]) {
111
- return 1;
112
- }
113
- return 0;
114
- });
115
- if (!notFounds.some((r) => r[0] === basePathname)) {
116
- const html = (0, import_request_handler.getErrorHtml)(404, "Resource Not Found");
117
- notFounds.push([basePathname, html]);
118
- }
119
- const c = [];
120
- c.push(`const notFounds = ${JSON.stringify(notFounds, null, 2)};`);
121
- c.push(`function getNotFound(p) {`);
122
- c.push(` for (const r of notFounds) {`);
123
- c.push(` if (p.startsWith(r[0])) {`);
124
- c.push(` return r[1];`);
125
- c.push(` }`);
126
- c.push(` }`);
127
- c.push(` return "Resource Not Found";`);
128
- c.push(`}`);
129
- if (format === "cjs") {
130
- c.push("exports.getNotFound = getNotFound;");
131
- } else {
132
- c.push("export { getNotFound };");
133
- }
134
- return c.join("\n");
135
- }
136
- function createStaticPathsModule(basePathname, staticPaths, format) {
137
- const assetsPath = basePathname + "assets/";
138
- const baseBuildPath = basePathname + "build/";
139
- const c = [];
140
- c.push(
141
- `const staticPaths = new Set(${JSON.stringify(
142
- Array.from(new Set(staticPaths)).sort()
143
- )});`
144
- );
145
- c.push(`function isStaticPath(method, url) {`);
146
- c.push(` if (method.toUpperCase() !== 'GET') {`);
147
- c.push(` return false;`);
148
- c.push(` }`);
149
- c.push(` const p = url.pathname;`);
150
- c.push(` if (p.startsWith(${JSON.stringify(baseBuildPath)})) {`);
151
- c.push(` return true;`);
152
- c.push(` }`);
153
- c.push(` if (p.startsWith(${JSON.stringify(assetsPath)})) {`);
154
- c.push(` return true;`);
155
- c.push(` }`);
156
- c.push(` if (staticPaths.has(p)) {`);
157
- c.push(` return true;`);
158
- c.push(` }`);
159
- c.push(` if (p.endsWith('/q-data.json')) {`);
160
- c.push(` const pWithoutQdata = p.replace(/\\/q-data.json$/, '');`);
161
- c.push(` if (staticPaths.has(pWithoutQdata + '/')) {`);
162
- c.push(` return true;`);
163
- c.push(` }`);
164
- c.push(` if (staticPaths.has(pWithoutQdata)) {`);
165
- c.push(` return true;`);
166
- c.push(` }`);
167
- c.push(` }`);
168
- c.push(` return false;`);
169
- c.push(`}`);
170
- if (format === "cjs") {
171
- c.push("exports.isStaticPath = isStaticPath;");
172
- } else {
173
- c.push("export { isStaticPath };");
174
- }
175
- return c.join("\n");
176
- }
177
-
178
- // packages/qwik-router/src/adapters/shared/vite/index.ts
179
- function viteAdapter(opts) {
180
- let qwikRouterPlugin = null;
181
- let qwikVitePlugin = null;
182
- let serverOutDir = null;
183
- let renderModulePath = null;
184
- let qwikRouterConfigModulePath = null;
185
- let isSsrBuild = false;
186
- let format = "esm";
187
- const outputEntries = [];
188
- const plugin = {
189
- name: `vite-plugin-qwik-router-${opts.name}`,
190
- enforce: "post",
191
- apply: "build",
192
- config(config) {
193
- if (typeof opts.config === "function") {
194
- config = opts.config(config);
195
- }
196
- config.define = {
197
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "production"),
198
- ...config.define
199
- };
200
- return config;
201
- },
202
- configResolved(config) {
203
- var _a, _b, _c, _d;
204
- isSsrBuild = !!config.build.ssr;
205
- if (isSsrBuild) {
206
- qwikRouterPlugin = config.plugins.find(
207
- (p) => p.name === "vite-plugin-qwik-router"
208
- );
209
- if (!qwikRouterPlugin) {
210
- throw new Error("Missing vite-plugin-qwik-router");
211
- }
212
- qwikVitePlugin = config.plugins.find(
213
- (p) => p.name === "vite-plugin-qwik"
214
- );
215
- if (!qwikVitePlugin) {
216
- throw new Error("Missing vite-plugin-qwik");
217
- }
218
- serverOutDir = config.build.outDir;
219
- if (((_a = config.build) == null ? void 0 : _a.ssr) !== true) {
220
- throw new Error(
221
- `"build.ssr" must be set to "true" in order to use the "${opts.name}" adapter.`
222
- );
223
- }
224
- if (!((_c = (_b = config.build) == null ? void 0 : _b.rollupOptions) == null ? void 0 : _c.input)) {
225
- throw new Error(
226
- `"build.rollupOptions.input" must be set in order to use the "${opts.name}" adapter.`
227
- );
228
- }
229
- if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
230
- format = "cjs";
231
- }
232
- }
233
- },
234
- generateBundle(_, bundles) {
235
- if (isSsrBuild) {
236
- outputEntries.length = 0;
237
- for (const fileName in bundles) {
238
- const chunk = bundles[fileName];
239
- if (chunk.type === "chunk" && chunk.isEntry) {
240
- outputEntries.push(fileName);
241
- if (chunk.name === "entry.ssr") {
242
- renderModulePath = (0, import_node_path2.join)(serverOutDir, fileName);
243
- } else if (chunk.name === "@qwik-router-config") {
244
- qwikRouterConfigModulePath = (0, import_node_path2.join)(serverOutDir, fileName);
245
- }
246
- }
247
- }
248
- if (!renderModulePath) {
249
- throw new Error(
250
- 'Unable to find "entry.ssr" entry point. Did you forget to add it to "build.rollupOptions.input"?'
251
- );
252
- }
253
- if (!qwikRouterConfigModulePath) {
254
- throw new Error(
255
- 'Unable to find "@qwik-router-config" entry point. Did you forget to add it to "build.rollupOptions.input"?'
256
- );
257
- }
258
- }
259
- },
260
- closeBundle: {
261
- sequential: true,
262
- async handler() {
263
- var _a;
264
- if (isSsrBuild && opts.ssg !== null && serverOutDir && (qwikRouterPlugin == null ? void 0 : qwikRouterPlugin.api) && (qwikVitePlugin == null ? void 0 : qwikVitePlugin.api)) {
265
- const staticPaths = opts.staticPaths || [];
266
- const routes = qwikRouterPlugin.api.getRoutes();
267
- const basePathname = qwikRouterPlugin.api.getBasePathname();
268
- const clientOutDir = qwikVitePlugin.api.getClientOutDir();
269
- const clientPublicOutDir = qwikVitePlugin.api.getClientPublicOutDir();
270
- const assetsDir = qwikVitePlugin.api.getAssetsDir();
271
- const rootDir = qwikVitePlugin.api.getRootDir() ?? void 0;
272
- if (renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
273
- let ssgOrigin = ((_a = opts.ssg) == null ? void 0 : _a.origin) ?? opts.origin;
274
- if (!ssgOrigin) {
275
- ssgOrigin = `https://yoursite.qwik.dev`;
276
- }
277
- if (ssgOrigin.length > 0 && !/:\/\//.test(ssgOrigin)) {
278
- ssgOrigin = `https://${ssgOrigin}`;
279
- }
280
- if (ssgOrigin.startsWith("//")) {
281
- ssgOrigin = `https:${ssgOrigin}`;
282
- }
283
- try {
284
- ssgOrigin = new URL(ssgOrigin).origin;
285
- } catch (e) {
286
- this.warn(
287
- `Invalid "origin" option: "${ssgOrigin}". Using default origin: "https://yoursite.qwik.dev"`
288
- );
289
- ssgOrigin = `https://yoursite.qwik.dev`;
290
- }
291
- const staticGenerate = await import("../../../static/index.cjs");
292
- const generateOpts = {
293
- maxWorkers: opts.maxWorkers,
294
- basePathname,
295
- outDir: clientPublicOutDir,
296
- rootDir,
297
- ...opts.ssg,
298
- origin: ssgOrigin,
299
- renderModulePath,
300
- qwikRouterConfigModulePath
301
- };
302
- const staticGenerateResult = await staticGenerate.generate(generateOpts);
303
- if (staticGenerateResult.errors > 0) {
304
- const err = new Error(
305
- `Error while running SSG from "${opts.name}" adapter. At least one path failed to render.`
306
- );
307
- err.stack = void 0;
308
- this.error(err);
309
- }
310
- staticPaths.push(...staticGenerateResult.staticPaths);
311
- const { staticPathsCode, notFoundPathsCode } = await postBuild(
312
- clientPublicOutDir,
313
- assetsDir ? (0, import_node_path2.join)(basePathname, assetsDir) : basePathname,
314
- staticPaths,
315
- format,
316
- !!opts.cleanStaticGenerated
317
- );
318
- await Promise.all([
319
- import_node_fs2.default.promises.writeFile((0, import_node_path2.join)(serverOutDir, RESOLVED_STATIC_PATHS_ID), staticPathsCode),
320
- import_node_fs2.default.promises.writeFile(
321
- (0, import_node_path2.join)(serverOutDir, RESOLVED_NOT_FOUND_PATHS_ID),
322
- notFoundPathsCode
323
- )
324
- ]);
325
- if (typeof opts.generate === "function") {
326
- await opts.generate({
327
- outputEntries,
328
- serverOutDir,
329
- clientOutDir,
330
- clientPublicOutDir,
331
- basePathname,
332
- routes,
333
- assetsDir,
334
- warn: (message) => this.warn(message),
335
- error: (message) => this.error(message)
336
- });
337
- }
338
- }
339
- }
340
- }
341
- }
342
- };
343
- return plugin;
344
- }
345
- function getParentDir(startDir, dirName) {
346
- const root = (0, import_node_path2.resolve)("/");
347
- let dir = startDir;
348
- for (let i = 0; i < 20; i++) {
349
- dir = (0, import_node_path2.dirname)(dir);
350
- if ((0, import_node_path2.basename)(dir) === dirName) {
351
- return dir;
352
- }
353
- if (dir === root) {
354
- break;
355
- }
356
- }
357
- throw new Error(`Unable to find "${dirName}" directory from "${startDir}"`);
358
- }
359
- var STATIC_PATHS_ID = "@qwik-router-static-paths";
360
- var RESOLVED_STATIC_PATHS_ID = `${STATIC_PATHS_ID}.js`;
361
- var NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths";
362
- var RESOLVED_NOT_FOUND_PATHS_ID = `${NOT_FOUND_PATHS_ID}.js`;
363
- // Annotate the CommonJS export names for ESM import in node:
364
- 0 && (module.exports = {
365
- NOT_FOUND_PATHS_ID,
366
- RESOLVED_NOT_FOUND_PATHS_ID,
367
- RESOLVED_STATIC_PATHS_ID,
368
- STATIC_PATHS_ID,
369
- getParentDir,
370
- viteAdapter
371
- });
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("node:path"),v=require("@qwik.dev/router/middleware/request-handler"),y=require("node:fs");async function D(e,s,t,r,f){t&&!t.endsWith("/")&&(t+="/");const p=new Set([t+"/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/",t+"/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/"]),o=new Set(r.map(P)),g=[],w=async(a,l,u)=>{if(u=P(u),p.has(u))return;const m=h.join(a,l);if(l==="index.html"||l==="q-data.json"){!o.has(u)&&f&&await y.promises.unlink(m);return}if(l==="404.html"){const _=await y.promises.readFile(m,"utf-8");g.push([u,_]);return}const n=await y.promises.stat(m);n.isDirectory()?await i(m,u+l+"/"):n.isFile()&&o.add(u+l)},i=async(a,l)=>{const u=await y.promises.readdir(a);await Promise.all(u.map(m=>w(a,m,l)))};y.existsSync(e)&&await i(e,t);const d=b(t,g),c=O(o);await R(c,d,s)}function P(e){return e.endsWith("/")?e:e+"/"}function b(e,s){if(s.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),!s.some(t=>t[0]===e)){const t=v.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 R=async(e,s,t)=>{const r=new Set,f=async o=>{const g=await y.promises.readFile(o,"utf-8");let w=!1;const i=g.replace(/(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,(d,c,a)=>(w=!0,a==="STATIC_PATHS"?e:s));w&&await y.promises.writeFile(o,i)},p=async o=>{const g=await y.promises.readdir(o,{withFileTypes:!0});for(const w of g)if(w.isDirectory())await p(h.join(o,w.name));else if(w.name.endsWith("js")){const i=f(h.join(o,w.name)).finally(()=>{r.delete(i)});r.add(i)}};await p(t),await Promise.all(r)};function T(e){let s=null,t=null,r=null,f=null,p=null,o=!1;const g=[];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(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(r=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){g.length=0;for(const c in d){const a=d[c];a.type==="chunk"&&a.isEntry&&(g.push(c),a.name==="entry.ssr"?f=h.join(r,c):a.name==="@qwik-router-config"&&(p=h.join(r,c)))}}},closeBundle:{sequential:!0,async handler(){if(o&&r&&s?.api&&t?.api){const i=e.staticPaths||[],d=s.api.getRoutes(),c=s.api.getBasePathname(),a=t.api.getClientOutDir(),l=t.api.getClientPublicOutDir(),u=t.api.getAssetsDir(),m=t.api.getRootDir()??void 0;if(e.ssg!==null&&f&&p&&a&&l){let n=e.ssg?.origin??e.origin;n||(n="https://yoursite.qwik.dev"),n.length>0&&!/:\/\//.test(n)&&(n=`https://${n}`),n.startsWith("//")&&(n=`https:${n}`);try{n=new URL(n).origin}catch{this.warn(`Invalid "origin" option: "${n}". Using default origin: "https://yoursite.qwik.dev"`),n="https://yoursite.qwik.dev"}const _=await Promise.resolve().then(()=>require("./index-BqUeglYs.cjs")),q={maxWorkers:e.maxWorkers,basePathname:c,outDir:l,rootDir:m,...e.ssg,origin:n,renderModulePath:f,qwikRouterConfigModulePath:p},k=await _.generate(q);if(k.errors>0){const S=new Error(`Error while running SSG from "${e.name}" adapter. At least one path failed to render.`);S.stack=void 0,this.error(S)}i.push(...k.staticPaths)}await D(l,r,u?h.join(c,u):c,i,!!e.cleanStaticGenerated),typeof e.generate=="function"&&await e.generate({outputEntries:g,serverOutDir:r,clientOutDir:a,clientPublicOutDir:l,basePathname:c,routes:d,assetsDir:u,warn:n=>this.warn(n),error:n=>this.error(n)}),this.warn(`
2
+ ==============================================
3
+ Note: Make sure that you are serving the built files with proper cache headers.
4
+ See https://qwik.dev/docs/deployments/#cache-headers for more information.
5
+ ==============================================`),e.ssg!==null&&setTimeout(()=>{process.exit(0)},5e3).unref()}}}}}function E(e,s){const t=h.resolve("/");let r=e;for(let f=0;f<20;f++){if(r=h.dirname(r),h.basename(r)===s)return r;if(r===t)break}throw new Error(`Unable to find "${s}" directory from "${e}"`)}exports.getParentDir=E;exports.viteAdapter=T;
@@ -1,114 +1,108 @@
1
- import type { Plugin as Plugin_2 } from 'vite';
2
- import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
3
- import type { UserConfig } from 'vite';
4
-
5
- /** @public */
6
- export declare interface AdapterSSGOptions extends Omit<StaticGenerateRenderOptions, 'outDir' | 'origin'> {
7
- /** Defines routes that should be static generated. Accepts wildcard behavior. */
8
- include: string[];
9
- /**
10
- * Defines routes that should not be static generated. Accepts wildcard behavior. `exclude` always
11
- * take priority over `include`.
12
- */
13
- exclude?: string[];
14
- /**
15
- * The URL `origin`, which is a combination of the scheme (protocol) and hostname (domain). For
16
- * example, `https://qwik.dev` has the protocol `https://` and domain `qwik.dev`. However, the
17
- * `origin` does not include a `pathname`.
18
- *
19
- * The `origin` is used to provide a full URL during Static Site Generation (SSG), and to simulate
20
- * a complete URL rather than just the `pathname`. For example, in order to render a correct
21
- * canonical tag URL or URLs within the `sitemap.xml`, the `origin` must be provided too.
22
- *
23
- * If the site also starts with a pathname other than `/`, please use the `basePathname` option in
24
- * the Qwik Router config options.
25
- */
26
- origin?: string;
27
- }
28
-
29
- declare interface BuildLayout {
30
- filePath: string;
31
- dirPath: string;
32
- id: string;
33
- layoutType: 'top' | 'nested';
34
- layoutName: string;
35
- }
36
-
37
- declare interface BuildRoute extends ParsedPathname {
38
- /** Unique id built from its relative file system path */
39
- id: string;
40
- /** Local file system path */
41
- filePath: string;
42
- ext: string;
43
- /** URL Pathname */
44
- pathname: string;
45
- layouts: BuildLayout[];
46
- }
47
-
48
- /** @public */
49
- export declare function getParentDir(startDir: string, dirName: string): string;
50
-
51
- /** @public */
52
- export declare const NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths";
53
-
54
- declare interface ParsedPathname {
55
- routeName: string;
56
- pattern: RegExp;
57
- paramNames: string[];
58
- segments: PathnameSegment[];
59
- }
60
-
61
- declare type PathnameSegment = PathnameSegmentPart[];
62
-
63
- declare interface PathnameSegmentPart {
64
- content: string;
65
- dynamic: boolean;
66
- rest: boolean;
67
- }
68
-
69
- /** @public */
70
- export declare const RESOLVED_NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths.js";
71
-
72
- /** @public */
73
- export declare const RESOLVED_STATIC_PATHS_ID = "@qwik-router-static-paths.js";
74
-
75
- /** @public */
76
- export declare interface ServerAdapterOptions {
77
- /**
78
- * Options the adapter should use when running Static Site Generation (SSG). Defaults the `filter`
79
- * to "auto" which will attempt to automatically decides if a page can be statically generated and
80
- * does not have dynamic data, or if it the page should instead be rendered on the server (SSR).
81
- * Setting to `null` will prevent any pages from being statically generated.
82
- */
83
- ssg?: AdapterSSGOptions | null;
84
- }
85
-
86
- /** @public */
87
- export declare const STATIC_PATHS_ID = "@qwik-router-static-paths";
88
-
89
- /** @public */
90
- export declare function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<never>;
91
-
92
- /** @public */
93
- declare interface ViteAdapterPluginOptions {
94
- name: string;
95
- origin: string;
96
- staticPaths?: string[];
97
- ssg?: AdapterSSGOptions | null;
98
- cleanStaticGenerated?: boolean;
99
- maxWorkers?: number;
100
- config?: (config: UserConfig) => UserConfig;
101
- generate?: (generateOpts: {
102
- outputEntries: string[];
103
- clientOutDir: string;
104
- clientPublicOutDir: string;
105
- serverOutDir: string;
106
- basePathname: string;
107
- routes: BuildRoute[];
108
- assetsDir?: string;
109
- warn: (message: string) => void;
110
- error: (message: string) => void;
111
- }) => Promise<void>;
112
- }
113
-
114
- export { }
1
+ import type { Plugin as Plugin_2 } from 'vite';
2
+ import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
3
+ import type { UserConfig } from 'vite';
4
+
5
+ /** @public */
6
+ export declare interface AdapterSSGOptions extends Omit<SsgRenderOptions, 'outDir' | 'origin'> {
7
+ /** Defines routes that should be static generated. Accepts wildcard behavior. */
8
+ include: string[];
9
+ /**
10
+ * Defines routes that should not be static generated. Accepts wildcard behavior. `exclude` always
11
+ * take priority over `include`.
12
+ */
13
+ exclude?: string[];
14
+ /**
15
+ * The URL `origin`, which is a combination of the scheme (protocol) and hostname (domain). For
16
+ * example, `https://qwik.dev` has the protocol `https://` and domain `qwik.dev`. However, the
17
+ * `origin` does not include a `pathname`.
18
+ *
19
+ * The `origin` is used to provide a full URL during Static Site Generation (SSG), and to simulate
20
+ * a complete URL rather than just the `pathname`. For example, in order to render a correct
21
+ * canonical tag URL or URLs within the `sitemap.xml`, the `origin` must be provided too.
22
+ *
23
+ * If the site also starts with a pathname other than `/`, please use the `basePathname` option in
24
+ * the Qwik Router config options.
25
+ */
26
+ origin?: string;
27
+ }
28
+
29
+ declare interface BuildLayout {
30
+ filePath: string;
31
+ dirPath: string;
32
+ id: string;
33
+ layoutType: 'top' | 'nested';
34
+ layoutName: string;
35
+ }
36
+
37
+ declare interface BuildRoute extends ParsedPathname {
38
+ /** Unique id built from its relative file system path */
39
+ id: string;
40
+ /** Local file system path */
41
+ filePath: string;
42
+ ext: string;
43
+ /** URL Pathname */
44
+ pathname: string;
45
+ layouts: BuildLayout[];
46
+ }
47
+
48
+ /** @public */
49
+ export declare function getParentDir(startDir: string, dirName: string): string;
50
+
51
+ declare interface ParsedPathname {
52
+ routeName: string;
53
+ pattern: RegExp;
54
+ paramNames: string[];
55
+ segments: PathnameSegment[];
56
+ }
57
+
58
+ declare type PathnameSegment = PathnameSegmentPart[];
59
+
60
+ declare interface PathnameSegmentPart {
61
+ content: string;
62
+ dynamic: boolean;
63
+ rest: boolean;
64
+ }
65
+
66
+ /** @public */
67
+ export declare interface ServerAdapterOptions {
68
+ /**
69
+ * Options the adapter should use when running Static Site Generation (SSG). Defaults the `filter`
70
+ * to "auto" which will attempt to automatically decides if a page can be statically generated and
71
+ * does not have dynamic data, or if it the page should instead be rendered on the server (SSR).
72
+ * Setting to `null` will prevent any pages from being statically generated.
73
+ */
74
+ ssg?: AdapterSSGOptions | null;
75
+ }
76
+
77
+ /**
78
+ * Implements the SSG after the build is complete. Also provides a `generate(...)` callback that is
79
+ * called after the SSG is complete, which allows for custom post-processing of the complete build
80
+ * results.
81
+ *
82
+ * @public
83
+ */
84
+ export declare function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<never>;
85
+
86
+ /** @public */
87
+ declare interface ViteAdapterPluginOptions {
88
+ name: string;
89
+ origin: string;
90
+ staticPaths?: string[];
91
+ ssg?: AdapterSSGOptions | null;
92
+ cleanStaticGenerated?: boolean;
93
+ maxWorkers?: number;
94
+ config?: (config: UserConfig) => UserConfig;
95
+ generate?: (generateOpts: {
96
+ outputEntries: string[];
97
+ clientOutDir: string;
98
+ clientPublicOutDir: string;
99
+ serverOutDir: string;
100
+ basePathname: string;
101
+ routes: BuildRoute[];
102
+ assetsDir?: string;
103
+ warn: (message: string) => void;
104
+ error: (message: string) => void;
105
+ }) => Promise<void>;
106
+ }
107
+
108
+ export { }