@qwik.dev/core 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 (132) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.wasm.cjs +27 -27
  5. package/bindings/qwik.wasm.mjs +27 -27
  6. package/bindings/qwik.win32-x64-msvc.node +0 -0
  7. package/bindings/qwik_wasm_bg.wasm +0 -0
  8. package/dist/backpatch/index.cjs +6 -0
  9. package/dist/backpatch/index.d.ts +2 -0
  10. package/dist/backpatch/index.mjs +5 -0
  11. package/dist/{prefetch → backpatch}/package.json +2 -2
  12. package/dist/backpatch-executor.debug.js +34 -0
  13. package/dist/backpatch-executor.js +1 -0
  14. package/dist/build/index.cjs +3 -3
  15. package/dist/build/index.d.ts +22 -22
  16. package/dist/build/package.json +1 -1
  17. package/dist/cli.cjs +3035 -767
  18. package/dist/core-internal.d.ts +4622 -4153
  19. package/dist/core.cjs +7327 -6169
  20. package/dist/core.cjs.map +1 -1
  21. package/dist/core.min.mjs +1 -1
  22. package/dist/core.mjs +7294 -6163
  23. package/dist/core.mjs.map +1 -1
  24. package/dist/core.prod.cjs +3209 -2612
  25. package/dist/core.prod.mjs +3932 -3294
  26. package/dist/insights/index.qwik.cjs +1 -4142
  27. package/dist/insights/index.qwik.mjs +63 -4133
  28. package/dist/insights/vite/index.cjs +1 -82
  29. package/dist/insights/vite/index.mjs +65 -37
  30. package/dist/insights/vite.d.ts +22 -0
  31. package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
  32. package/dist/loader/index.cjs +2 -2
  33. package/dist/loader/index.mjs +2 -2
  34. package/dist/loader/package.json +1 -1
  35. package/dist/optimizer.cjs +201 -3817
  36. package/dist/optimizer.d.ts +754 -707
  37. package/dist/optimizer.mjs +2605 -3628
  38. package/dist/preloader.cjs +266 -0
  39. package/dist/preloader.mjs +195 -0
  40. package/dist/qwikloader.debug.js +228 -222
  41. package/dist/qwikloader.js +1 -3
  42. package/dist/server.cjs +915 -621
  43. package/dist/server.d.ts +519 -402
  44. package/dist/server.mjs +900 -615
  45. package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.mts +1 -1
  46. package/dist/starters/adapters/aws-lambda/package.json +1 -1
  47. package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
  48. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -8
  49. package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.mts +1 -1
  50. package/dist/starters/adapters/azure-swa/package.json +1 -1
  51. package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
  52. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -4
  53. package/dist/starters/adapters/bun/adapters/bun/vite.config.mts +2 -2
  54. package/dist/starters/adapters/bun/package.json +1 -1
  55. package/dist/starters/adapters/bun/src/entry.bun.ts +3 -4
  56. package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.mts +1 -1
  57. package/dist/starters/adapters/cloud-run/package.json +1 -1
  58. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +2 -6
  59. package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.mts +1 -1
  60. package/dist/starters/adapters/cloudflare-pages/package.json +1 -1
  61. package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
  62. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -4
  63. package/dist/starters/adapters/deno/adapters/deno/vite.config.mts +1 -1
  64. package/dist/starters/adapters/deno/package.json +1 -1
  65. package/dist/starters/adapters/deno/src/entry.deno.ts +3 -4
  66. package/dist/starters/adapters/express/adapters/express/vite.config.mts +1 -1
  67. package/dist/starters/adapters/express/package.json +1 -1
  68. package/dist/starters/adapters/express/src/entry.express.tsx +6 -5
  69. package/dist/starters/adapters/fastify/adapters/fastify/vite.config.mts +1 -1
  70. package/dist/starters/adapters/fastify/package.json +1 -1
  71. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +3 -2
  72. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +10 -3
  73. package/dist/starters/adapters/firebase/adapters/firebase/vite.config.mts +1 -1
  74. package/dist/starters/adapters/firebase/firebase.json +12 -1
  75. package/dist/starters/adapters/firebase/functions/index.js +2 -3
  76. package/dist/starters/adapters/firebase/package.json +1 -1
  77. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -4
  78. package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.mts +1 -1
  79. package/dist/starters/adapters/netlify-edge/package.json +1 -1
  80. package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
  81. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -4
  82. package/dist/starters/adapters/node-server/adapters/node-server/vite.config.mts +1 -1
  83. package/dist/starters/adapters/node-server/package.json +1 -1
  84. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -4
  85. package/dist/starters/adapters/ssg/README.md +9 -0
  86. package/dist/starters/adapters/{static/adapters/static → ssg/adapters/ssg}/vite.config.mts +2 -2
  87. package/dist/starters/adapters/ssg/package.json +19 -0
  88. package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.mts +1 -1
  89. package/dist/starters/adapters/vercel-edge/package.json +1 -1
  90. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -4
  91. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  92. package/dist/starters/features/auth/package.json +1 -1
  93. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  94. package/dist/starters/features/csr/index.html +23 -0
  95. package/dist/starters/features/csr/package.json +29 -0
  96. package/dist/starters/features/csr/src/root.tsx +15 -0
  97. package/dist/starters/features/csr/vite.config.mts +13 -0
  98. package/dist/starters/features/localize/package.json +3 -3
  99. package/dist/starters/features/localize/src/entry.ssr.tsx +17 -23
  100. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  101. package/dist/starters/features/pandacss/package.json +1 -1
  102. package/dist/starters/features/partytown/package.json +4 -4
  103. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  104. package/dist/starters/features/playwright/playwright-report/index.html +953 -911
  105. package/dist/starters/features/postcss/postcss.config.js +2 -2
  106. package/dist/starters/features/service-worker/package.json +13 -0
  107. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  108. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  109. package/dist/starters/features/tailwind/package.json +4 -3
  110. package/dist/starters/features/tailwind/prettier.config.js +10 -0
  111. package/dist/starters/features/tailwind/src/global.css +1 -1
  112. package/dist/starters/features/tailwind-v3/package.json +1 -1
  113. package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
  114. package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
  115. package/dist/testing/index.cjs +14313 -11732
  116. package/dist/testing/index.d.ts +1112 -141
  117. package/dist/testing/index.mjs +14225 -11661
  118. package/dist/testing/package.json +1 -1
  119. package/package.json +28 -14
  120. package/public.d.ts +5 -0
  121. package/server.d.ts +1 -0
  122. package/dist/insights/index.d.ts +0 -1
  123. package/dist/insights/vite/index.d.ts +0 -1
  124. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  125. package/dist/prefetch/index.cjs +0 -4
  126. package/dist/prefetch/index.d.ts +0 -2
  127. package/dist/prefetch/index.mjs +0 -3
  128. package/dist/qwik-prefetch.debug.js +0 -244
  129. package/dist/qwik-prefetch.js +0 -1
  130. package/dist/starters/adapters/static/README.md +0 -5
  131. package/dist/starters/adapters/static/package.json +0 -19
  132. package/dist/starters/features/tailwind/.prettierrc.js +0 -3
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/testing",
3
- "version": "2.0.0-alpha.9-dev+56ed5bd",
3
+ "version": "2.0.0-beta.10-dev+4669425",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/package.json CHANGED
@@ -1,23 +1,27 @@
1
1
  {
2
2
  "name": "@qwik.dev/core",
3
3
  "description": "An open source framework for building instant loading web apps at any scale, without the extra effort.",
4
- "version": "2.0.0-alpha.9",
4
+ "version": "2.0.0-beta.10",
5
5
  "author": "Qwik Team",
6
6
  "bin": {
7
7
  "qwik": "./qwik-cli.cjs"
8
8
  },
9
9
  "bugs": "https://github.com/QwikDev/qwik/issues",
10
10
  "dependencies": {
11
- "csstype": "^3.1"
11
+ "csstype": "^3.1.3",
12
+ "launch-editor": "^2.11.1",
13
+ "rollup": ">= ^4.44.0"
12
14
  },
13
15
  "devDependencies": {
16
+ "@croct/json5-parser": "0.2.0",
17
+ "domino": "2.1.6",
14
18
  "ignore": "5.3.1",
15
- "image-size": "1.1.1",
19
+ "image-size": "1.2.1",
16
20
  "kleur": "4.1.5",
17
- "prettier": "3.4.2",
21
+ "prettier": "3.6.2",
18
22
  "ts-morph": "23.0.0",
19
- "vitest": "3.0.8",
20
- "@qwik.dev/core": "2.0.0-alpha.9",
23
+ "vitest": "3.2.4",
24
+ "@qwik.dev/core": "2.0.0-beta.10",
21
25
  "@qwik.dev/dom": "2.1.19"
22
26
  },
23
27
  "engines": {
@@ -103,12 +107,12 @@
103
107
  "require": "./dist/loader/index.cjs"
104
108
  },
105
109
  "./insights": {
106
- "types": "./dist/insights/index.d.ts",
110
+ "types": "./dist/insights.d.ts",
107
111
  "import": "./dist/insights/index.qwik.mjs",
108
112
  "require": "./dist/insights/index.qwik.cjs"
109
113
  },
110
114
  "./insights/vite": {
111
- "types": "./dist/insights/vite/index.d.ts",
115
+ "types": "./dist/insights/vite.d.ts",
112
116
  "import": "./dist/insights/vite/index.mjs",
113
117
  "require": "./dist/insights/vite/index.cjs"
114
118
  },
@@ -119,6 +123,10 @@
119
123
  "import": "./dist/optimizer.mjs",
120
124
  "require": "./dist/optimizer.cjs"
121
125
  },
126
+ "./preloader": {
127
+ "import": "./dist/preloader.mjs",
128
+ "require": "./dist/preloader.cjs"
129
+ },
122
130
  "./server.cjs": "./dist/server.cjs",
123
131
  "./server.mjs": "./dist/server.mjs",
124
132
  "./server": {
@@ -133,8 +141,8 @@
133
141
  },
134
142
  "./qwikloader.js": "./dist/qwikloader.js",
135
143
  "./qwikloader.debug.js": "./dist/qwikloader.debug.js",
136
- "./qwik-prefetch.js": "./dist/qwik-prefetch.js",
137
- "./qwik-prefetch.debug.js": "./dist/qwik-prefetch.debug.js",
144
+ "./backpatch-executor.js": "./dist/backpatch-executor.js",
145
+ "./backpatch-executor.debug.js": "./dist/backpatch-executor.debug.js",
138
146
  "./package.json": "./package.json"
139
147
  },
140
148
  "exports_annotation": "We use the build for the optimizer because esbuild doesn't like the html?raw imports in the server plugin and it's only used in the vite configs",
@@ -157,10 +165,15 @@
157
165
  ],
158
166
  "homepage": "https://qwik.dev/",
159
167
  "keywords": [
160
- "Builder.io",
168
+ "Automatic Optimization",
161
169
  "framework",
162
170
  "generator",
171
+ "javascript streaming",
172
+ "lazy execution",
173
+ "performance",
163
174
  "prerender",
175
+ "resumability",
176
+ "resumable",
164
177
  "server-side-render",
165
178
  "ssg",
166
179
  "ssr",
@@ -172,9 +185,9 @@
172
185
  "license": "MIT",
173
186
  "main": "./src/index.ts",
174
187
  "peerDependencies": {
175
- "prettier": "*",
176
- "vite": "^5",
177
- "vitest": "^2"
188
+ "prettier": "3.6.2",
189
+ "vite": ">=5 <8",
190
+ "vitest": ">=2 <4"
178
191
  },
179
192
  "peerDependenciesMeta": {
180
193
  "vitest": {
@@ -192,6 +205,7 @@
192
205
  "url": "https://github.com/QwikDev/qwik.git",
193
206
  "directory": "packages/qwik"
194
207
  },
208
+ "sideEffects": false,
195
209
  "type": "module",
196
210
  "types": "./public.d.ts",
197
211
  "scripts": {
package/public.d.ts CHANGED
@@ -6,6 +6,7 @@ export {
6
6
  ComputedSignal,
7
7
  ContextId,
8
8
  createComputed$,
9
+ createAsyncComputed$,
9
10
  createSerializer$,
10
11
  createContextId,
11
12
  createSignal,
@@ -43,6 +44,7 @@ export {
43
44
  QwikSVGElements,
44
45
  QwikJSX as JSX,
45
46
  QwikJSX,
47
+ QwikVisibleEvent,
46
48
  ReadonlySignal,
47
49
  render,
48
50
  RenderOnce,
@@ -56,6 +58,7 @@ export {
56
58
  TaskCtx,
57
59
  // TODO do we really want to export this?
58
60
  untrack,
61
+ useAsyncComputed$,
59
62
  useComputed$,
60
63
  useConstant,
61
64
  useContext,
@@ -78,4 +81,6 @@ export {
78
81
  version,
79
82
  withLocale,
80
83
  SVGAttributes,
84
+ HTMLElementAttrs,
85
+ SVGProps,
81
86
  } from './dist/core-internal';
package/server.d.ts CHANGED
@@ -2,6 +2,7 @@ export {
2
2
  getQwikLoaderScript,
3
3
  getQwikPrefetchWorkerScript,
4
4
  setServerPlatform,
5
+ PreloaderOptions,
5
6
  Render,
6
7
  RenderOptions,
7
8
  RenderResult,
@@ -1 +0,0 @@
1
- export * from './insights';
@@ -1 +0,0 @@
1
- export * from './insights-plugin';
@@ -1,10 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- /**
3
- * @beta
4
- * @experimental
5
- */
6
- export declare function qwikInsights(qwikInsightsOpts: {
7
- publicApiKey: string;
8
- baseUrl?: string;
9
- outDir?: string;
10
- }): Promise<PluginOption>;
@@ -1,4 +0,0 @@
1
- const QWIK_PREFETCH = "(()=>{const t=Number.MAX_SAFE_INTEGER>>>1;function n(n,i){const[o,s]=c(i),a=n.t.find((t=>o===t.i));if(a)return n.o(\"intercepting\",i.pathname),e(n,a,[s],t).then((()=>function(t,n){const e=t.u.find((t=>t.l.pathname===n.pathname));return e?e.$.then((t=>t.clone())):(t.o(\"CACHE HIT\",n.pathname),t.h(n))}(n,i)))}async function e(n,e,o,c){const a=new Map;o.forEach((t=>s(e,a,t,c))),await Promise.all(Array.from(a.entries()).map((([i,o])=>async function(n,e,i){let o=n.u.find((t=>t.l.pathname===e.pathname));const s=i>=t?\"direct\":\"prefetch\";if(o){const t=o.p?\"fetching\":\"waiting\";o.m<i?(n.o(\"queue update priority\",t,e.pathname),o.m=i):n.o(\"already in queue\",s,t,e.pathname)}else await n.h(e)||(n.o(\"enqueue\",s,e.pathname),o={m:i,l:e,v:null,$:null,p:!1},o.$=new Promise((t=>o.v=t)),n.u.push(o));return o}(n,new URL(e.i+i,n.l.origin),o)))),i(n)}function i(n){n.u.sort(o);let e=0;for(const o of n.u)if(o.p)e++;else if(n.C()&&(e<n.T||o.m>=t)){o.p=!0,e++;const s=o.m>=t?\"FETCH (CACHE MISS)\":\"FETCH\";n.o(s,o.l.pathname),n.H(o.l).then((async t=>{o.v(t),200===t.status&&(n.o(\"CACHED\",o.l.pathname),await n.R(o.l,t.clone()))})).finally((()=>{n.o(\"FETCH DONE\",o.l.pathname),n.u.splice(n.u.indexOf(o),1),i(n)}))}}function o(t,n){return n.m-t.m}function s(t,n,e,i,o=!0){if(!n.has(e)){if(n.set(e,i),!t.U){let n,e;t.U=new Map;for(let i=0;i<t.L.length;i++){const o=t.L[i];if(\"string\"==typeof o)n={S:[],A:[]},e=!0,t.U.set(o,n);else if(-1===o)e=!1;else{const i=t.L[o];e?n.S.push(i):n.A.push(i)}}}const c=t.U.get(e);if(!c)return n;for(const e of c.S)s(t,n,e,i);if(o){i--;for(const e of c.A)s(t,n,e,i,!1)}}return n}function c(t){const n=new URL(t).pathname,e=n.lastIndexOf(\"/\");return[n.substring(0,e+1),n.substring(e+1)]}const a=(...t)=>{console.log(\"⚙️ Prefetch SW:\",...t)};async function r(t,n,e,i){const o=t.t.findIndex((t=>t.i===n));if(-1!==o&&t.t.splice(o,1),t.o(\"adding base:\",n),t.t.push({i:n,L:e,U:void 0}),i){const i=new Set(e.filter((t=>\"string\"==typeof t))),o=await t.C();if(o)for(const e of await o.keys()){const[s,a]=c(new URL(e.url)),r=[];s!==n||i.has(a)||(t.o(\"deleting\",e.url),r.push(o.delete(e))),await Promise.all(r)}}}function u(t,n,i){let o=t.t.find((t=>t.L.includes(i[0].replace(\"./\",\"\"))));o||(o=t.t.find((t=>n===t.i))),o?e(t,o,i,0):console.error(`Base path not found: ${n}, ignoring prefetch.`)}function f(t){if(!t.N&&t.B.length){const e=t.B.shift();t.N=(async(t,e)=>{const i=e[0];t.o(\"received message:\",i,e[1],e.slice(2)),\"graph\"===i?await r(t,e[1],e.slice(2),!0):\"graph-url\"===i?await async function(t,e,i){await r(t,e,[],!1);const o=await n(t,new URL(e+i,t.l.origin));if(o&&200===o.status){const n=await o.json();n.push(i),await r(t,e,n,!0)}}(t,e[1],e[2]):\"prefetch\"===i?await u(t,e[1],e.slice(2)):\"prefetch-all\"===i?await function(t,n){const e=t.t.find((t=>n===t.i));e?u(t,n,e.L.filter((t=>\"string\"==typeof t))):console.error(`Base path not found: ${n}, ignoring prefetch.`)}(t,e[1]):\"ping\"===i?a(\"ping\"):\"verbose\"===i?(t.o=a)(\"mode: verbose\"):console.error(\"UNKNOWN MESSAGE:\",e)})(t,e).then((()=>{t.N=null,f(t)}))}}class l{constructor(t,n,e=4,i=null,o=null,s=[],c=[],a=[]){this.H=t,this.l=n,this.T=e,this.F=i,this.N=o,this.u=s,this.t=c,this.B=a}C(){return this.F}async R(t,n){const e=await this.C();return null==e?void 0:e.put(t,n)}async h(t){const n=await this.C();return null==n?void 0:n.match(t)}o(){}}(t=>{const e=(i=t.fetch.bind(t),o=new URL(t.location.href),new l(i,o));var i,o;e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open(\"QwikBundles\")),t.addEventListener(\"fetch\",(t=>{const i=t.request;if(\"GET\"===i.method){const o=n(e,new URL(i.url));o&&t.respondWith(o)}})),t.addEventListener(\"message\",(t=>{e.B.push(t.data),f(e)})),t.addEventListener(\"install\",(()=>{t.skipWaiting()})),t.addEventListener(\"activate\",(n=>{e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open(\"QwikBundles\")),n.waitUntil(t.clients.claim())}))})(globalThis)})();";
2
- const QWIK_PREFETCH_DEBUG = "(() => {\n const DIRECT_PRIORITY = Number.MAX_SAFE_INTEGER >>> 1;\n function directFetch(swState, url) {\n const [basePath, filename] = parseBaseFilename(url);\n const base = swState.$bases$.find((base2 => basePath === base2.$path$));\n if (base) {\n swState.$log$(\"intercepting\", url.pathname);\n return enqueueFileAndDependencies(swState, base, [ filename ], DIRECT_PRIORITY).then((() => function(swState, url) {\n const currentRequestTask = swState.$queue$.find((task => task.$url$.pathname === url.pathname));\n if (currentRequestTask) {\n return currentRequestTask.$response$.then((response => response.clone()));\n }\n swState.$log$(\"CACHE HIT\", url.pathname);\n return swState.$match$(url);\n }(swState, url)));\n }\n }\n async function enqueueFileAndDependencies(swState, base, filenames, priority) {\n const fetchMap = new Map;\n filenames.forEach((filename => addDependencies(base, fetchMap, filename, priority)));\n await Promise.all(Array.from(fetchMap.entries()).map((([filename, prio]) => async function(swState, url, priority) {\n let task = swState.$queue$.find((task2 => task2.$url$.pathname === url.pathname));\n const mode = priority >= DIRECT_PRIORITY ? \"direct\" : \"prefetch\";\n if (task) {\n const state = task.$isFetching$ ? \"fetching\" : \"waiting\";\n if (task.$priority$ < priority) {\n swState.$log$(\"queue update priority\", state, url.pathname);\n task.$priority$ = priority;\n } else {\n swState.$log$(\"already in queue\", mode, state, url.pathname);\n }\n } else {\n if (!await swState.$match$(url)) {\n swState.$log$(\"enqueue\", mode, url.pathname);\n task = {\n $priority$: priority,\n $url$: url,\n $resolveResponse$: null,\n $response$: null,\n $isFetching$: !1\n };\n task.$response$ = new Promise((resolve => task.$resolveResponse$ = resolve));\n swState.$queue$.push(task);\n }\n }\n return task;\n }(swState, new URL(base.$path$ + filename, swState.$url$.origin), prio))));\n taskTick(swState);\n }\n function taskTick(swState) {\n swState.$queue$.sort(byFetchOrder);\n let outstandingRequests = 0;\n for (const task of swState.$queue$) {\n if (task.$isFetching$) {\n outstandingRequests++;\n } else if (swState.$getCache$() && (outstandingRequests < swState.$maxPrefetchRequests$ || task.$priority$ >= DIRECT_PRIORITY)) {\n task.$isFetching$ = !0;\n outstandingRequests++;\n const action = task.$priority$ >= DIRECT_PRIORITY ? \"FETCH (CACHE MISS)\" : \"FETCH\";\n swState.$log$(action, task.$url$.pathname);\n swState.$fetch$(task.$url$).then((async response => {\n task.$resolveResponse$(response);\n if (200 === response.status) {\n swState.$log$(\"CACHED\", task.$url$.pathname);\n await swState.$put$(task.$url$, response.clone());\n }\n })).finally((() => {\n swState.$log$(\"FETCH DONE\", task.$url$.pathname);\n swState.$queue$.splice(swState.$queue$.indexOf(task), 1);\n taskTick(swState);\n }));\n }\n }\n }\n function byFetchOrder(a, b) {\n return b.$priority$ - a.$priority$;\n }\n function addDependencies(base, fetchMap, filename, priority, addIndirect = !0) {\n if (!fetchMap.has(filename)) {\n fetchMap.set(filename, priority);\n if (!base.$processed$) {\n base.$processed$ = new Map;\n let current, isDirect;\n for (let i = 0; i < base.$graph$.length; i++) {\n const item = base.$graph$[i];\n if (\"string\" == typeof item) {\n current = {\n $direct$: [],\n $indirect$: []\n };\n isDirect = !0;\n base.$processed$.set(item, current);\n } else if (-1 === item) {\n isDirect = !1;\n } else {\n const depName = base.$graph$[item];\n isDirect ? current.$direct$.push(depName) : current.$indirect$.push(depName);\n }\n }\n }\n const deps = base.$processed$.get(filename);\n if (!deps) {\n return fetchMap;\n }\n for (const dependentFilename of deps.$direct$) {\n addDependencies(base, fetchMap, dependentFilename, priority);\n }\n if (addIndirect) {\n priority--;\n for (const dependentFilename of deps.$indirect$) {\n addDependencies(base, fetchMap, dependentFilename, priority, !1);\n }\n }\n }\n return fetchMap;\n }\n function parseBaseFilename(url) {\n const pathname = new URL(url).pathname;\n const slashIndex = pathname.lastIndexOf(\"/\");\n return [ pathname.substring(0, slashIndex + 1), pathname.substring(slashIndex + 1) ];\n }\n const log = (...args) => {\n console.log(\"⚙️ Prefetch SW:\", ...args);\n };\n const processMessage = async (state, msg) => {\n const type = msg[0];\n state.$log$(\"received message:\", type, msg[1], msg.slice(2));\n \"graph\" === type ? await processBundleGraph(state, msg[1], msg.slice(2), !0) : \"graph-url\" === type ? await async function(swState, base, graphPath) {\n await processBundleGraph(swState, base, [], !1);\n const response = await directFetch(swState, new URL(base + graphPath, swState.$url$.origin));\n if (response && 200 === response.status) {\n const graph = await response.json();\n graph.push(graphPath);\n await processBundleGraph(swState, base, graph, !0);\n }\n }(state, msg[1], msg[2]) : \"prefetch\" === type ? await processPrefetch(state, msg[1], msg.slice(2)) : \"prefetch-all\" === type ? await function(swState, basePath) {\n const base = swState.$bases$.find((base2 => basePath === base2.$path$));\n base ? processPrefetch(swState, basePath, base.$graph$.filter((item => \"string\" == typeof item))) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);\n }(state, msg[1]) : \"ping\" === type ? log(\"ping\") : \"verbose\" === type ? (state.$log$ = log)(\"mode: verbose\") : console.error(\"UNKNOWN MESSAGE:\", msg);\n };\n async function processBundleGraph(swState, base, graph, cleanup) {\n const existingBaseIndex = swState.$bases$.findIndex((b => b.$path$ === base));\n -1 !== existingBaseIndex && swState.$bases$.splice(existingBaseIndex, 1);\n swState.$log$(\"adding base:\", base);\n swState.$bases$.push({\n $path$: base,\n $graph$: graph,\n $processed$: void 0\n });\n if (cleanup) {\n const bundles = new Set(graph.filter((item => \"string\" == typeof item)));\n const cache = await swState.$getCache$();\n if (cache) {\n for (const request of await cache.keys()) {\n const [cacheBase, filename] = parseBaseFilename(new URL(request.url));\n const promises = [];\n if (cacheBase === base && !bundles.has(filename)) {\n swState.$log$(\"deleting\", request.url);\n promises.push(cache.delete(request));\n }\n await Promise.all(promises);\n }\n }\n }\n }\n function processPrefetch(swState, basePath, bundles) {\n let base = swState.$bases$.find((base2 => base2.$graph$.includes(bundles[0].replace(\"./\", \"\"))));\n base || (base = swState.$bases$.find((base2 => basePath === base2.$path$)));\n base ? enqueueFileAndDependencies(swState, base, bundles, 0) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);\n }\n function drainMsgQueue(swState) {\n if (!swState.$msgQueuePromise$ && swState.$msgQueue$.length) {\n const top = swState.$msgQueue$.shift();\n swState.$msgQueuePromise$ = processMessage(swState, top).then((() => {\n swState.$msgQueuePromise$ = null;\n drainMsgQueue(swState);\n }));\n }\n }\n class SWStateImpl {\n constructor($fetch$, $url$, $maxPrefetchRequests$ = 4, $cache$ = null, $msgQueuePromise$ = null, $queue$ = [], $bases$ = [], $msgQueue$ = []) {\n this.$fetch$ = $fetch$;\n this.$url$ = $url$;\n this.$maxPrefetchRequests$ = $maxPrefetchRequests$;\n this.$cache$ = $cache$;\n this.$msgQueuePromise$ = $msgQueuePromise$;\n this.$queue$ = $queue$;\n this.$bases$ = $bases$;\n this.$msgQueue$ = $msgQueue$;\n }\n $getCache$() {\n return this.$cache$;\n }\n async $put$(request, response) {\n const cache = await this.$getCache$();\n return null == cache ? void 0 : cache.put(request, response);\n }\n async $match$(request) {\n const cache = await this.$getCache$();\n return null == cache ? void 0 : cache.match(request);\n }\n $log$() {}\n }\n (swScope => {\n const swState = ((fetch, url) => new SWStateImpl(fetch, url))(swScope.fetch.bind(swScope), new URL(swScope.location.href));\n swState.$getCache$ = () => {\n if (swState.$cache$) {\n return swState.$cache$;\n }\n clearTimeout(undefined);\n setTimeout((() => {\n swState.$cache$ = null;\n }), 5e3);\n return swScope.caches.open(\"QwikBundles\");\n };\n swScope.addEventListener(\"fetch\", (ev => {\n const request = ev.request;\n if (\"GET\" === request.method) {\n const response = directFetch(swState, new URL(request.url));\n response && ev.respondWith(response);\n }\n }));\n swScope.addEventListener(\"message\", (ev => {\n swState.$msgQueue$.push(ev.data);\n drainMsgQueue(swState);\n }));\n swScope.addEventListener(\"install\", (() => {\n swScope.skipWaiting();\n }));\n swScope.addEventListener(\"activate\", (event => {\n swState.$getCache$ = () => {\n if (swState.$cache$) {\n return swState.$cache$;\n }\n clearTimeout(undefined);\n setTimeout((() => {\n swState.$cache$ = null;\n }), 5e3);\n return swScope.caches.open(\"QwikBundles\");\n };\n event.waitUntil(swScope.clients.claim());\n }));\n })(globalThis);\n})();";
3
- exports.QWIK_PREFETCH = QWIK_PREFETCH;
4
- exports.QWIK_PREFETCH_DEBUG = QWIK_PREFETCH_DEBUG;
@@ -1,2 +0,0 @@
1
- export declare const QWIK_PREFETCH: string;
2
- export declare const QWIK_PREFETCH_DEBUG: string;
@@ -1,3 +0,0 @@
1
- const QWIK_PREFETCH = "(()=>{const t=Number.MAX_SAFE_INTEGER>>>1;function n(n,i){const[o,s]=c(i),a=n.t.find((t=>o===t.i));if(a)return n.o(\"intercepting\",i.pathname),e(n,a,[s],t).then((()=>function(t,n){const e=t.u.find((t=>t.l.pathname===n.pathname));return e?e.$.then((t=>t.clone())):(t.o(\"CACHE HIT\",n.pathname),t.h(n))}(n,i)))}async function e(n,e,o,c){const a=new Map;o.forEach((t=>s(e,a,t,c))),await Promise.all(Array.from(a.entries()).map((([i,o])=>async function(n,e,i){let o=n.u.find((t=>t.l.pathname===e.pathname));const s=i>=t?\"direct\":\"prefetch\";if(o){const t=o.p?\"fetching\":\"waiting\";o.m<i?(n.o(\"queue update priority\",t,e.pathname),o.m=i):n.o(\"already in queue\",s,t,e.pathname)}else await n.h(e)||(n.o(\"enqueue\",s,e.pathname),o={m:i,l:e,v:null,$:null,p:!1},o.$=new Promise((t=>o.v=t)),n.u.push(o));return o}(n,new URL(e.i+i,n.l.origin),o)))),i(n)}function i(n){n.u.sort(o);let e=0;for(const o of n.u)if(o.p)e++;else if(n.C()&&(e<n.T||o.m>=t)){o.p=!0,e++;const s=o.m>=t?\"FETCH (CACHE MISS)\":\"FETCH\";n.o(s,o.l.pathname),n.H(o.l).then((async t=>{o.v(t),200===t.status&&(n.o(\"CACHED\",o.l.pathname),await n.R(o.l,t.clone()))})).finally((()=>{n.o(\"FETCH DONE\",o.l.pathname),n.u.splice(n.u.indexOf(o),1),i(n)}))}}function o(t,n){return n.m-t.m}function s(t,n,e,i,o=!0){if(!n.has(e)){if(n.set(e,i),!t.U){let n,e;t.U=new Map;for(let i=0;i<t.L.length;i++){const o=t.L[i];if(\"string\"==typeof o)n={S:[],A:[]},e=!0,t.U.set(o,n);else if(-1===o)e=!1;else{const i=t.L[o];e?n.S.push(i):n.A.push(i)}}}const c=t.U.get(e);if(!c)return n;for(const e of c.S)s(t,n,e,i);if(o){i--;for(const e of c.A)s(t,n,e,i,!1)}}return n}function c(t){const n=new URL(t).pathname,e=n.lastIndexOf(\"/\");return[n.substring(0,e+1),n.substring(e+1)]}const a=(...t)=>{console.log(\"⚙️ Prefetch SW:\",...t)};async function r(t,n,e,i){const o=t.t.findIndex((t=>t.i===n));if(-1!==o&&t.t.splice(o,1),t.o(\"adding base:\",n),t.t.push({i:n,L:e,U:void 0}),i){const i=new Set(e.filter((t=>\"string\"==typeof t))),o=await t.C();if(o)for(const e of await o.keys()){const[s,a]=c(new URL(e.url)),r=[];s!==n||i.has(a)||(t.o(\"deleting\",e.url),r.push(o.delete(e))),await Promise.all(r)}}}function u(t,n,i){let o=t.t.find((t=>t.L.includes(i[0].replace(\"./\",\"\"))));o||(o=t.t.find((t=>n===t.i))),o?e(t,o,i,0):console.error(`Base path not found: ${n}, ignoring prefetch.`)}function f(t){if(!t.N&&t.B.length){const e=t.B.shift();t.N=(async(t,e)=>{const i=e[0];t.o(\"received message:\",i,e[1],e.slice(2)),\"graph\"===i?await r(t,e[1],e.slice(2),!0):\"graph-url\"===i?await async function(t,e,i){await r(t,e,[],!1);const o=await n(t,new URL(e+i,t.l.origin));if(o&&200===o.status){const n=await o.json();n.push(i),await r(t,e,n,!0)}}(t,e[1],e[2]):\"prefetch\"===i?await u(t,e[1],e.slice(2)):\"prefetch-all\"===i?await function(t,n){const e=t.t.find((t=>n===t.i));e?u(t,n,e.L.filter((t=>\"string\"==typeof t))):console.error(`Base path not found: ${n}, ignoring prefetch.`)}(t,e[1]):\"ping\"===i?a(\"ping\"):\"verbose\"===i?(t.o=a)(\"mode: verbose\"):console.error(\"UNKNOWN MESSAGE:\",e)})(t,e).then((()=>{t.N=null,f(t)}))}}class l{constructor(t,n,e=4,i=null,o=null,s=[],c=[],a=[]){this.H=t,this.l=n,this.T=e,this.F=i,this.N=o,this.u=s,this.t=c,this.B=a}C(){return this.F}async R(t,n){const e=await this.C();return null==e?void 0:e.put(t,n)}async h(t){const n=await this.C();return null==n?void 0:n.match(t)}o(){}}(t=>{const e=(i=t.fetch.bind(t),o=new URL(t.location.href),new l(i,o));var i,o;e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open(\"QwikBundles\")),t.addEventListener(\"fetch\",(t=>{const i=t.request;if(\"GET\"===i.method){const o=n(e,new URL(i.url));o&&t.respondWith(o)}})),t.addEventListener(\"message\",(t=>{e.B.push(t.data),f(e)})),t.addEventListener(\"install\",(()=>{t.skipWaiting()})),t.addEventListener(\"activate\",(n=>{e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open(\"QwikBundles\")),n.waitUntil(t.clients.claim())}))})(globalThis)})();";
2
- const QWIK_PREFETCH_DEBUG = "(() => {\n const DIRECT_PRIORITY = Number.MAX_SAFE_INTEGER >>> 1;\n function directFetch(swState, url) {\n const [basePath, filename] = parseBaseFilename(url);\n const base = swState.$bases$.find((base2 => basePath === base2.$path$));\n if (base) {\n swState.$log$(\"intercepting\", url.pathname);\n return enqueueFileAndDependencies(swState, base, [ filename ], DIRECT_PRIORITY).then((() => function(swState, url) {\n const currentRequestTask = swState.$queue$.find((task => task.$url$.pathname === url.pathname));\n if (currentRequestTask) {\n return currentRequestTask.$response$.then((response => response.clone()));\n }\n swState.$log$(\"CACHE HIT\", url.pathname);\n return swState.$match$(url);\n }(swState, url)));\n }\n }\n async function enqueueFileAndDependencies(swState, base, filenames, priority) {\n const fetchMap = new Map;\n filenames.forEach((filename => addDependencies(base, fetchMap, filename, priority)));\n await Promise.all(Array.from(fetchMap.entries()).map((([filename, prio]) => async function(swState, url, priority) {\n let task = swState.$queue$.find((task2 => task2.$url$.pathname === url.pathname));\n const mode = priority >= DIRECT_PRIORITY ? \"direct\" : \"prefetch\";\n if (task) {\n const state = task.$isFetching$ ? \"fetching\" : \"waiting\";\n if (task.$priority$ < priority) {\n swState.$log$(\"queue update priority\", state, url.pathname);\n task.$priority$ = priority;\n } else {\n swState.$log$(\"already in queue\", mode, state, url.pathname);\n }\n } else {\n if (!await swState.$match$(url)) {\n swState.$log$(\"enqueue\", mode, url.pathname);\n task = {\n $priority$: priority,\n $url$: url,\n $resolveResponse$: null,\n $response$: null,\n $isFetching$: !1\n };\n task.$response$ = new Promise((resolve => task.$resolveResponse$ = resolve));\n swState.$queue$.push(task);\n }\n }\n return task;\n }(swState, new URL(base.$path$ + filename, swState.$url$.origin), prio))));\n taskTick(swState);\n }\n function taskTick(swState) {\n swState.$queue$.sort(byFetchOrder);\n let outstandingRequests = 0;\n for (const task of swState.$queue$) {\n if (task.$isFetching$) {\n outstandingRequests++;\n } else if (swState.$getCache$() && (outstandingRequests < swState.$maxPrefetchRequests$ || task.$priority$ >= DIRECT_PRIORITY)) {\n task.$isFetching$ = !0;\n outstandingRequests++;\n const action = task.$priority$ >= DIRECT_PRIORITY ? \"FETCH (CACHE MISS)\" : \"FETCH\";\n swState.$log$(action, task.$url$.pathname);\n swState.$fetch$(task.$url$).then((async response => {\n task.$resolveResponse$(response);\n if (200 === response.status) {\n swState.$log$(\"CACHED\", task.$url$.pathname);\n await swState.$put$(task.$url$, response.clone());\n }\n })).finally((() => {\n swState.$log$(\"FETCH DONE\", task.$url$.pathname);\n swState.$queue$.splice(swState.$queue$.indexOf(task), 1);\n taskTick(swState);\n }));\n }\n }\n }\n function byFetchOrder(a, b) {\n return b.$priority$ - a.$priority$;\n }\n function addDependencies(base, fetchMap, filename, priority, addIndirect = !0) {\n if (!fetchMap.has(filename)) {\n fetchMap.set(filename, priority);\n if (!base.$processed$) {\n base.$processed$ = new Map;\n let current, isDirect;\n for (let i = 0; i < base.$graph$.length; i++) {\n const item = base.$graph$[i];\n if (\"string\" == typeof item) {\n current = {\n $direct$: [],\n $indirect$: []\n };\n isDirect = !0;\n base.$processed$.set(item, current);\n } else if (-1 === item) {\n isDirect = !1;\n } else {\n const depName = base.$graph$[item];\n isDirect ? current.$direct$.push(depName) : current.$indirect$.push(depName);\n }\n }\n }\n const deps = base.$processed$.get(filename);\n if (!deps) {\n return fetchMap;\n }\n for (const dependentFilename of deps.$direct$) {\n addDependencies(base, fetchMap, dependentFilename, priority);\n }\n if (addIndirect) {\n priority--;\n for (const dependentFilename of deps.$indirect$) {\n addDependencies(base, fetchMap, dependentFilename, priority, !1);\n }\n }\n }\n return fetchMap;\n }\n function parseBaseFilename(url) {\n const pathname = new URL(url).pathname;\n const slashIndex = pathname.lastIndexOf(\"/\");\n return [ pathname.substring(0, slashIndex + 1), pathname.substring(slashIndex + 1) ];\n }\n const log = (...args) => {\n console.log(\"⚙️ Prefetch SW:\", ...args);\n };\n const processMessage = async (state, msg) => {\n const type = msg[0];\n state.$log$(\"received message:\", type, msg[1], msg.slice(2));\n \"graph\" === type ? await processBundleGraph(state, msg[1], msg.slice(2), !0) : \"graph-url\" === type ? await async function(swState, base, graphPath) {\n await processBundleGraph(swState, base, [], !1);\n const response = await directFetch(swState, new URL(base + graphPath, swState.$url$.origin));\n if (response && 200 === response.status) {\n const graph = await response.json();\n graph.push(graphPath);\n await processBundleGraph(swState, base, graph, !0);\n }\n }(state, msg[1], msg[2]) : \"prefetch\" === type ? await processPrefetch(state, msg[1], msg.slice(2)) : \"prefetch-all\" === type ? await function(swState, basePath) {\n const base = swState.$bases$.find((base2 => basePath === base2.$path$));\n base ? processPrefetch(swState, basePath, base.$graph$.filter((item => \"string\" == typeof item))) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);\n }(state, msg[1]) : \"ping\" === type ? log(\"ping\") : \"verbose\" === type ? (state.$log$ = log)(\"mode: verbose\") : console.error(\"UNKNOWN MESSAGE:\", msg);\n };\n async function processBundleGraph(swState, base, graph, cleanup) {\n const existingBaseIndex = swState.$bases$.findIndex((b => b.$path$ === base));\n -1 !== existingBaseIndex && swState.$bases$.splice(existingBaseIndex, 1);\n swState.$log$(\"adding base:\", base);\n swState.$bases$.push({\n $path$: base,\n $graph$: graph,\n $processed$: void 0\n });\n if (cleanup) {\n const bundles = new Set(graph.filter((item => \"string\" == typeof item)));\n const cache = await swState.$getCache$();\n if (cache) {\n for (const request of await cache.keys()) {\n const [cacheBase, filename] = parseBaseFilename(new URL(request.url));\n const promises = [];\n if (cacheBase === base && !bundles.has(filename)) {\n swState.$log$(\"deleting\", request.url);\n promises.push(cache.delete(request));\n }\n await Promise.all(promises);\n }\n }\n }\n }\n function processPrefetch(swState, basePath, bundles) {\n let base = swState.$bases$.find((base2 => base2.$graph$.includes(bundles[0].replace(\"./\", \"\"))));\n base || (base = swState.$bases$.find((base2 => basePath === base2.$path$)));\n base ? enqueueFileAndDependencies(swState, base, bundles, 0) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);\n }\n function drainMsgQueue(swState) {\n if (!swState.$msgQueuePromise$ && swState.$msgQueue$.length) {\n const top = swState.$msgQueue$.shift();\n swState.$msgQueuePromise$ = processMessage(swState, top).then((() => {\n swState.$msgQueuePromise$ = null;\n drainMsgQueue(swState);\n }));\n }\n }\n class SWStateImpl {\n constructor($fetch$, $url$, $maxPrefetchRequests$ = 4, $cache$ = null, $msgQueuePromise$ = null, $queue$ = [], $bases$ = [], $msgQueue$ = []) {\n this.$fetch$ = $fetch$;\n this.$url$ = $url$;\n this.$maxPrefetchRequests$ = $maxPrefetchRequests$;\n this.$cache$ = $cache$;\n this.$msgQueuePromise$ = $msgQueuePromise$;\n this.$queue$ = $queue$;\n this.$bases$ = $bases$;\n this.$msgQueue$ = $msgQueue$;\n }\n $getCache$() {\n return this.$cache$;\n }\n async $put$(request, response) {\n const cache = await this.$getCache$();\n return null == cache ? void 0 : cache.put(request, response);\n }\n async $match$(request) {\n const cache = await this.$getCache$();\n return null == cache ? void 0 : cache.match(request);\n }\n $log$() {}\n }\n (swScope => {\n const swState = ((fetch, url) => new SWStateImpl(fetch, url))(swScope.fetch.bind(swScope), new URL(swScope.location.href));\n swState.$getCache$ = () => {\n if (swState.$cache$) {\n return swState.$cache$;\n }\n clearTimeout(undefined);\n setTimeout((() => {\n swState.$cache$ = null;\n }), 5e3);\n return swScope.caches.open(\"QwikBundles\");\n };\n swScope.addEventListener(\"fetch\", (ev => {\n const request = ev.request;\n if (\"GET\" === request.method) {\n const response = directFetch(swState, new URL(request.url));\n response && ev.respondWith(response);\n }\n }));\n swScope.addEventListener(\"message\", (ev => {\n swState.$msgQueue$.push(ev.data);\n drainMsgQueue(swState);\n }));\n swScope.addEventListener(\"install\", (() => {\n swScope.skipWaiting();\n }));\n swScope.addEventListener(\"activate\", (event => {\n swState.$getCache$ = () => {\n if (swState.$cache$) {\n return swState.$cache$;\n }\n clearTimeout(undefined);\n setTimeout((() => {\n swState.$cache$ = null;\n }), 5e3);\n return swScope.caches.open(\"QwikBundles\");\n };\n event.waitUntil(swScope.clients.claim());\n }));\n })(globalThis);\n})();";
3
- export { QWIK_PREFETCH, QWIK_PREFETCH_DEBUG };
@@ -1,244 +0,0 @@
1
- (() => {
2
- const DIRECT_PRIORITY = Number.MAX_SAFE_INTEGER >>> 1;
3
- function directFetch(swState, url) {
4
- const [basePath, filename] = parseBaseFilename(url);
5
- const base = swState.$bases$.find((base2 => basePath === base2.$path$));
6
- if (base) {
7
- swState.$log$("intercepting", url.pathname);
8
- return enqueueFileAndDependencies(swState, base, [ filename ], DIRECT_PRIORITY).then((() => function(swState, url) {
9
- const currentRequestTask = swState.$queue$.find((task => task.$url$.pathname === url.pathname));
10
- if (currentRequestTask) {
11
- return currentRequestTask.$response$.then((response => response.clone()));
12
- }
13
- swState.$log$("CACHE HIT", url.pathname);
14
- return swState.$match$(url);
15
- }(swState, url)));
16
- }
17
- }
18
- async function enqueueFileAndDependencies(swState, base, filenames, priority) {
19
- const fetchMap = new Map;
20
- filenames.forEach((filename => addDependencies(base, fetchMap, filename, priority)));
21
- await Promise.all(Array.from(fetchMap.entries()).map((([filename, prio]) => async function(swState, url, priority) {
22
- let task = swState.$queue$.find((task2 => task2.$url$.pathname === url.pathname));
23
- const mode = priority >= DIRECT_PRIORITY ? "direct" : "prefetch";
24
- if (task) {
25
- const state = task.$isFetching$ ? "fetching" : "waiting";
26
- if (task.$priority$ < priority) {
27
- swState.$log$("queue update priority", state, url.pathname);
28
- task.$priority$ = priority;
29
- } else {
30
- swState.$log$("already in queue", mode, state, url.pathname);
31
- }
32
- } else {
33
- if (!await swState.$match$(url)) {
34
- swState.$log$("enqueue", mode, url.pathname);
35
- task = {
36
- $priority$: priority,
37
- $url$: url,
38
- $resolveResponse$: null,
39
- $response$: null,
40
- $isFetching$: !1
41
- };
42
- task.$response$ = new Promise((resolve => task.$resolveResponse$ = resolve));
43
- swState.$queue$.push(task);
44
- }
45
- }
46
- return task;
47
- }(swState, new URL(base.$path$ + filename, swState.$url$.origin), prio))));
48
- taskTick(swState);
49
- }
50
- function taskTick(swState) {
51
- swState.$queue$.sort(byFetchOrder);
52
- let outstandingRequests = 0;
53
- for (const task of swState.$queue$) {
54
- if (task.$isFetching$) {
55
- outstandingRequests++;
56
- } else if (swState.$getCache$() && (outstandingRequests < swState.$maxPrefetchRequests$ || task.$priority$ >= DIRECT_PRIORITY)) {
57
- task.$isFetching$ = !0;
58
- outstandingRequests++;
59
- const action = task.$priority$ >= DIRECT_PRIORITY ? "FETCH (CACHE MISS)" : "FETCH";
60
- swState.$log$(action, task.$url$.pathname);
61
- swState.$fetch$(task.$url$).then((async response => {
62
- task.$resolveResponse$(response);
63
- if (200 === response.status) {
64
- swState.$log$("CACHED", task.$url$.pathname);
65
- await swState.$put$(task.$url$, response.clone());
66
- }
67
- })).finally((() => {
68
- swState.$log$("FETCH DONE", task.$url$.pathname);
69
- swState.$queue$.splice(swState.$queue$.indexOf(task), 1);
70
- taskTick(swState);
71
- }));
72
- }
73
- }
74
- }
75
- function byFetchOrder(a, b) {
76
- return b.$priority$ - a.$priority$;
77
- }
78
- function addDependencies(base, fetchMap, filename, priority, addIndirect = !0) {
79
- if (!fetchMap.has(filename)) {
80
- fetchMap.set(filename, priority);
81
- if (!base.$processed$) {
82
- base.$processed$ = new Map;
83
- let current, isDirect;
84
- for (let i = 0; i < base.$graph$.length; i++) {
85
- const item = base.$graph$[i];
86
- if ("string" == typeof item) {
87
- current = {
88
- $direct$: [],
89
- $indirect$: []
90
- };
91
- isDirect = !0;
92
- base.$processed$.set(item, current);
93
- } else if (-1 === item) {
94
- isDirect = !1;
95
- } else {
96
- const depName = base.$graph$[item];
97
- isDirect ? current.$direct$.push(depName) : current.$indirect$.push(depName);
98
- }
99
- }
100
- }
101
- const deps = base.$processed$.get(filename);
102
- if (!deps) {
103
- return fetchMap;
104
- }
105
- for (const dependentFilename of deps.$direct$) {
106
- addDependencies(base, fetchMap, dependentFilename, priority);
107
- }
108
- if (addIndirect) {
109
- priority--;
110
- for (const dependentFilename of deps.$indirect$) {
111
- addDependencies(base, fetchMap, dependentFilename, priority, !1);
112
- }
113
- }
114
- }
115
- return fetchMap;
116
- }
117
- function parseBaseFilename(url) {
118
- const pathname = new URL(url).pathname;
119
- const slashIndex = pathname.lastIndexOf("/");
120
- return [ pathname.substring(0, slashIndex + 1), pathname.substring(slashIndex + 1) ];
121
- }
122
- const log = (...args) => {
123
- console.log("⚙️ Prefetch SW:", ...args);
124
- };
125
- const processMessage = async (state, msg) => {
126
- const type = msg[0];
127
- state.$log$("received message:", type, msg[1], msg.slice(2));
128
- "graph" === type ? await processBundleGraph(state, msg[1], msg.slice(2), !0) : "graph-url" === type ? await async function(swState, base, graphPath) {
129
- await processBundleGraph(swState, base, [], !1);
130
- const response = await directFetch(swState, new URL(base + graphPath, swState.$url$.origin));
131
- if (response && 200 === response.status) {
132
- const graph = await response.json();
133
- graph.push(graphPath);
134
- await processBundleGraph(swState, base, graph, !0);
135
- }
136
- }(state, msg[1], msg[2]) : "prefetch" === type ? await processPrefetch(state, msg[1], msg.slice(2)) : "prefetch-all" === type ? await function(swState, basePath) {
137
- const base = swState.$bases$.find((base2 => basePath === base2.$path$));
138
- base ? processPrefetch(swState, basePath, base.$graph$.filter((item => "string" == typeof item))) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);
139
- }(state, msg[1]) : "ping" === type ? log("ping") : "verbose" === type ? (state.$log$ = log)("mode: verbose") : console.error("UNKNOWN MESSAGE:", msg);
140
- };
141
- async function processBundleGraph(swState, base, graph, cleanup) {
142
- const existingBaseIndex = swState.$bases$.findIndex((b => b.$path$ === base));
143
- -1 !== existingBaseIndex && swState.$bases$.splice(existingBaseIndex, 1);
144
- swState.$log$("adding base:", base);
145
- swState.$bases$.push({
146
- $path$: base,
147
- $graph$: graph,
148
- $processed$: void 0
149
- });
150
- if (cleanup) {
151
- const bundles = new Set(graph.filter((item => "string" == typeof item)));
152
- const cache = await swState.$getCache$();
153
- if (cache) {
154
- for (const request of await cache.keys()) {
155
- const [cacheBase, filename] = parseBaseFilename(new URL(request.url));
156
- const promises = [];
157
- if (cacheBase === base && !bundles.has(filename)) {
158
- swState.$log$("deleting", request.url);
159
- promises.push(cache.delete(request));
160
- }
161
- await Promise.all(promises);
162
- }
163
- }
164
- }
165
- }
166
- function processPrefetch(swState, basePath, bundles) {
167
- let base = swState.$bases$.find((base2 => base2.$graph$.includes(bundles[0].replace("./", ""))));
168
- base || (base = swState.$bases$.find((base2 => basePath === base2.$path$)));
169
- base ? enqueueFileAndDependencies(swState, base, bundles, 0) : console.error(`Base path not found: ${basePath}, ignoring prefetch.`);
170
- }
171
- function drainMsgQueue(swState) {
172
- if (!swState.$msgQueuePromise$ && swState.$msgQueue$.length) {
173
- const top = swState.$msgQueue$.shift();
174
- swState.$msgQueuePromise$ = processMessage(swState, top).then((() => {
175
- swState.$msgQueuePromise$ = null;
176
- drainMsgQueue(swState);
177
- }));
178
- }
179
- }
180
- class SWStateImpl {
181
- constructor($fetch$, $url$, $maxPrefetchRequests$ = 4, $cache$ = null, $msgQueuePromise$ = null, $queue$ = [], $bases$ = [], $msgQueue$ = []) {
182
- this.$fetch$ = $fetch$;
183
- this.$url$ = $url$;
184
- this.$maxPrefetchRequests$ = $maxPrefetchRequests$;
185
- this.$cache$ = $cache$;
186
- this.$msgQueuePromise$ = $msgQueuePromise$;
187
- this.$queue$ = $queue$;
188
- this.$bases$ = $bases$;
189
- this.$msgQueue$ = $msgQueue$;
190
- }
191
- $getCache$() {
192
- return this.$cache$;
193
- }
194
- async $put$(request, response) {
195
- const cache = await this.$getCache$();
196
- return null == cache ? void 0 : cache.put(request, response);
197
- }
198
- async $match$(request) {
199
- const cache = await this.$getCache$();
200
- return null == cache ? void 0 : cache.match(request);
201
- }
202
- $log$() {}
203
- }
204
- (swScope => {
205
- const swState = ((fetch, url) => new SWStateImpl(fetch, url))(swScope.fetch.bind(swScope), new URL(swScope.location.href));
206
- swState.$getCache$ = () => {
207
- if (swState.$cache$) {
208
- return swState.$cache$;
209
- }
210
- clearTimeout(undefined);
211
- setTimeout((() => {
212
- swState.$cache$ = null;
213
- }), 5e3);
214
- return swScope.caches.open("QwikBundles");
215
- };
216
- swScope.addEventListener("fetch", (ev => {
217
- const request = ev.request;
218
- if ("GET" === request.method) {
219
- const response = directFetch(swState, new URL(request.url));
220
- response && ev.respondWith(response);
221
- }
222
- }));
223
- swScope.addEventListener("message", (ev => {
224
- swState.$msgQueue$.push(ev.data);
225
- drainMsgQueue(swState);
226
- }));
227
- swScope.addEventListener("install", (() => {
228
- swScope.skipWaiting();
229
- }));
230
- swScope.addEventListener("activate", (event => {
231
- swState.$getCache$ = () => {
232
- if (swState.$cache$) {
233
- return swState.$cache$;
234
- }
235
- clearTimeout(undefined);
236
- setTimeout((() => {
237
- swState.$cache$ = null;
238
- }), 5e3);
239
- return swScope.caches.open("QwikBundles");
240
- };
241
- event.waitUntil(swScope.clients.claim());
242
- }));
243
- })(globalThis);
244
- })();
@@ -1 +0,0 @@
1
- (()=>{const t=Number.MAX_SAFE_INTEGER>>>1;function n(n,i){const[o,s]=c(i),a=n.t.find((t=>o===t.i));if(a)return n.o("intercepting",i.pathname),e(n,a,[s],t).then((()=>function(t,n){const e=t.u.find((t=>t.l.pathname===n.pathname));return e?e.$.then((t=>t.clone())):(t.o("CACHE HIT",n.pathname),t.h(n))}(n,i)))}async function e(n,e,o,c){const a=new Map;o.forEach((t=>s(e,a,t,c))),await Promise.all(Array.from(a.entries()).map((([i,o])=>async function(n,e,i){let o=n.u.find((t=>t.l.pathname===e.pathname));const s=i>=t?"direct":"prefetch";if(o){const t=o.p?"fetching":"waiting";o.m<i?(n.o("queue update priority",t,e.pathname),o.m=i):n.o("already in queue",s,t,e.pathname)}else await n.h(e)||(n.o("enqueue",s,e.pathname),o={m:i,l:e,v:null,$:null,p:!1},o.$=new Promise((t=>o.v=t)),n.u.push(o));return o}(n,new URL(e.i+i,n.l.origin),o)))),i(n)}function i(n){n.u.sort(o);let e=0;for(const o of n.u)if(o.p)e++;else if(n.C()&&(e<n.T||o.m>=t)){o.p=!0,e++;const s=o.m>=t?"FETCH (CACHE MISS)":"FETCH";n.o(s,o.l.pathname),n.H(o.l).then((async t=>{o.v(t),200===t.status&&(n.o("CACHED",o.l.pathname),await n.R(o.l,t.clone()))})).finally((()=>{n.o("FETCH DONE",o.l.pathname),n.u.splice(n.u.indexOf(o),1),i(n)}))}}function o(t,n){return n.m-t.m}function s(t,n,e,i,o=!0){if(!n.has(e)){if(n.set(e,i),!t.U){let n,e;t.U=new Map;for(let i=0;i<t.L.length;i++){const o=t.L[i];if("string"==typeof o)n={S:[],A:[]},e=!0,t.U.set(o,n);else if(-1===o)e=!1;else{const i=t.L[o];e?n.S.push(i):n.A.push(i)}}}const c=t.U.get(e);if(!c)return n;for(const e of c.S)s(t,n,e,i);if(o){i--;for(const e of c.A)s(t,n,e,i,!1)}}return n}function c(t){const n=new URL(t).pathname,e=n.lastIndexOf("/");return[n.substring(0,e+1),n.substring(e+1)]}const a=(...t)=>{console.log("⚙️ Prefetch SW:",...t)};async function r(t,n,e,i){const o=t.t.findIndex((t=>t.i===n));if(-1!==o&&t.t.splice(o,1),t.o("adding base:",n),t.t.push({i:n,L:e,U:void 0}),i){const i=new Set(e.filter((t=>"string"==typeof t))),o=await t.C();if(o)for(const e of await o.keys()){const[s,a]=c(new URL(e.url)),r=[];s!==n||i.has(a)||(t.o("deleting",e.url),r.push(o.delete(e))),await Promise.all(r)}}}function u(t,n,i){let o=t.t.find((t=>t.L.includes(i[0].replace("./",""))));o||(o=t.t.find((t=>n===t.i))),o?e(t,o,i,0):console.error(`Base path not found: ${n}, ignoring prefetch.`)}function f(t){if(!t.N&&t.B.length){const e=t.B.shift();t.N=(async(t,e)=>{const i=e[0];t.o("received message:",i,e[1],e.slice(2)),"graph"===i?await r(t,e[1],e.slice(2),!0):"graph-url"===i?await async function(t,e,i){await r(t,e,[],!1);const o=await n(t,new URL(e+i,t.l.origin));if(o&&200===o.status){const n=await o.json();n.push(i),await r(t,e,n,!0)}}(t,e[1],e[2]):"prefetch"===i?await u(t,e[1],e.slice(2)):"prefetch-all"===i?await function(t,n){const e=t.t.find((t=>n===t.i));e?u(t,n,e.L.filter((t=>"string"==typeof t))):console.error(`Base path not found: ${n}, ignoring prefetch.`)}(t,e[1]):"ping"===i?a("ping"):"verbose"===i?(t.o=a)("mode: verbose"):console.error("UNKNOWN MESSAGE:",e)})(t,e).then((()=>{t.N=null,f(t)}))}}class l{constructor(t,n,e=4,i=null,o=null,s=[],c=[],a=[]){this.H=t,this.l=n,this.T=e,this.F=i,this.N=o,this.u=s,this.t=c,this.B=a}C(){return this.F}async R(t,n){const e=await this.C();return null==e?void 0:e.put(t,n)}async h(t){const n=await this.C();return null==n?void 0:n.match(t)}o(){}}(t=>{const e=(i=t.fetch.bind(t),o=new URL(t.location.href),new l(i,o));var i,o;e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open("QwikBundles")),t.addEventListener("fetch",(t=>{const i=t.request;if("GET"===i.method){const o=n(e,new URL(i.url));o&&t.respondWith(o)}})),t.addEventListener("message",(t=>{e.B.push(t.data),f(e)})),t.addEventListener("install",(()=>{t.skipWaiting()})),t.addEventListener("activate",(n=>{e.C=()=>e.F?e.F:(clearTimeout(void 0),setTimeout((()=>{e.F=null}),5e3),t.caches.open("QwikBundles")),n.waitUntil(t.clients.claim())}))})(globalThis)})();
@@ -1,5 +0,0 @@
1
- ## Static Site Generator (Node.js)
2
-
3
- ```shell
4
- npm run build.server
5
- ```
@@ -1,19 +0,0 @@
1
- {
2
- "description": "Static Site Generator",
3
- "scripts": {
4
- "build.server": "vite build -c adapters/static/vite.config.mts"
5
- },
6
- "__qwik__": {
7
- "priority": 10,
8
- "displayName": "Adapter: Static site (.html files)",
9
- "docs": [
10
- "https://qwik.dev/docs/guides/static-site-generation/"
11
- ],
12
- "nextSteps": {
13
- "lines": [
14
- "You have to change the 'origin' url under staticAdapter",
15
- "inside './adapters/static/vite.config.mts'"
16
- ]
17
- }
18
- }
19
- }
@@ -1,3 +0,0 @@
1
- export default {
2
- plugins: ['prettier-plugin-tailwindcss'],
3
- }