@serwist/turbopack 9.5.7 → 9.5.9

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 (43) hide show
  1. package/dist/chunks/index.schema-RVDaKxz4.js +189 -0
  2. package/dist/chunks/index.schema-RVDaKxz4.js.map +1 -0
  3. package/dist/index.d.mts +96 -0
  4. package/dist/index.d.mts.map +1 -0
  5. package/dist/index.mjs +166 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/index.react.d.mts +42 -0
  8. package/dist/index.react.d.mts.map +1 -0
  9. package/dist/index.react.mjs +136 -0
  10. package/dist/index.react.mjs.map +1 -0
  11. package/dist/index.schema.d.mts +311 -0
  12. package/dist/index.schema.d.mts.map +1 -0
  13. package/dist/index.schema.mjs +2 -0
  14. package/dist/index.worker.d.mts +18 -0
  15. package/dist/index.worker.d.mts.map +1 -0
  16. package/dist/index.worker.mjs +227 -0
  17. package/dist/index.worker.mjs.map +1 -0
  18. package/package.json +34 -32
  19. package/dist/chunks/index.schema.js +0 -185
  20. package/dist/index.d.ts +0 -22
  21. package/dist/index.d.ts.map +0 -1
  22. package/dist/index.js +0 -190
  23. package/dist/index.react.d.ts +0 -25
  24. package/dist/index.react.d.ts.map +0 -1
  25. package/dist/index.react.js +0 -88
  26. package/dist/index.schema.d.ts +0 -301
  27. package/dist/index.schema.d.ts.map +0 -1
  28. package/dist/index.schema.js +0 -8
  29. package/dist/index.worker.d.ts +0 -14
  30. package/dist/index.worker.d.ts.map +0 -1
  31. package/dist/index.worker.js +0 -261
  32. package/dist/lib/constants.d.ts +0 -2
  33. package/dist/lib/constants.d.ts.map +0 -1
  34. package/dist/lib/context.d.ts +0 -7
  35. package/dist/lib/context.d.ts.map +0 -1
  36. package/dist/lib/index.d.ts +0 -3
  37. package/dist/lib/index.d.ts.map +0 -1
  38. package/dist/lib/logger.d.ts +0 -8
  39. package/dist/lib/logger.d.ts.map +0 -1
  40. package/dist/lib/utils.d.ts +0 -3
  41. package/dist/lib/utils.d.ts.map +0 -1
  42. package/dist/types.d.ts +0 -72
  43. package/dist/types.d.ts.map +0 -1
@@ -0,0 +1,227 @@
1
+ import { CacheFirst, ExpirationPlugin, NetworkFirst, NetworkOnly, RangeRequestsPlugin, StaleWhileRevalidate } from "serwist";
2
+ //#region src/index.worker.ts
3
+ const PAGES_CACHE_NAME = {
4
+ rscPrefetch: "pages-rsc-prefetch",
5
+ rsc: "pages-rsc",
6
+ html: "pages"
7
+ };
8
+ /**
9
+ * The default, recommended list of caching strategies for applications
10
+ * built with Next.js.
11
+ *
12
+ * @see https://serwist.pages.dev/docs/next/worker-exports#default-cache
13
+ */
14
+ const defaultCache = process.env.NODE_ENV !== "production" ? [{
15
+ matcher: /.*/i,
16
+ handler: new NetworkOnly()
17
+ }] : [
18
+ {
19
+ matcher: /^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,
20
+ handler: new CacheFirst({
21
+ cacheName: "google-fonts-webfonts",
22
+ plugins: [new ExpirationPlugin({
23
+ maxEntries: 4,
24
+ maxAgeSeconds: 365 * 24 * 60 * 60,
25
+ maxAgeFrom: "last-used"
26
+ })]
27
+ })
28
+ },
29
+ {
30
+ matcher: /^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,
31
+ handler: new StaleWhileRevalidate({
32
+ cacheName: "google-fonts-stylesheets",
33
+ plugins: [new ExpirationPlugin({
34
+ maxEntries: 4,
35
+ maxAgeSeconds: 10080 * 60,
36
+ maxAgeFrom: "last-used"
37
+ })]
38
+ })
39
+ },
40
+ {
41
+ matcher: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,
42
+ handler: new StaleWhileRevalidate({
43
+ cacheName: "static-font-assets",
44
+ plugins: [new ExpirationPlugin({
45
+ maxEntries: 4,
46
+ maxAgeSeconds: 10080 * 60,
47
+ maxAgeFrom: "last-used"
48
+ })]
49
+ })
50
+ },
51
+ {
52
+ matcher: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,
53
+ handler: new StaleWhileRevalidate({
54
+ cacheName: "static-image-assets",
55
+ plugins: [new ExpirationPlugin({
56
+ maxEntries: 64,
57
+ maxAgeSeconds: 720 * 60 * 60,
58
+ maxAgeFrom: "last-used"
59
+ })]
60
+ })
61
+ },
62
+ {
63
+ matcher: /\/_next\/static.+\.js$/i,
64
+ handler: new CacheFirst({
65
+ cacheName: "next-static-js-assets",
66
+ plugins: [new ExpirationPlugin({
67
+ maxEntries: 64,
68
+ maxAgeSeconds: 1440 * 60,
69
+ maxAgeFrom: "last-used"
70
+ })]
71
+ })
72
+ },
73
+ {
74
+ matcher: /\/_next\/image\?url=.+$/i,
75
+ handler: new StaleWhileRevalidate({
76
+ cacheName: "next-image",
77
+ plugins: [new ExpirationPlugin({
78
+ maxEntries: 64,
79
+ maxAgeSeconds: 1440 * 60,
80
+ maxAgeFrom: "last-used"
81
+ })]
82
+ })
83
+ },
84
+ {
85
+ matcher: /\.(?:mp3|wav|ogg)$/i,
86
+ handler: new CacheFirst({
87
+ cacheName: "static-audio-assets",
88
+ plugins: [new ExpirationPlugin({
89
+ maxEntries: 32,
90
+ maxAgeSeconds: 1440 * 60,
91
+ maxAgeFrom: "last-used"
92
+ }), new RangeRequestsPlugin()]
93
+ })
94
+ },
95
+ {
96
+ matcher: /\.(?:mp4|webm)$/i,
97
+ handler: new CacheFirst({
98
+ cacheName: "static-video-assets",
99
+ plugins: [new ExpirationPlugin({
100
+ maxEntries: 32,
101
+ maxAgeSeconds: 1440 * 60,
102
+ maxAgeFrom: "last-used"
103
+ }), new RangeRequestsPlugin()]
104
+ })
105
+ },
106
+ {
107
+ matcher: /\.(?:js)$/i,
108
+ handler: new StaleWhileRevalidate({
109
+ cacheName: "static-js-assets",
110
+ plugins: [new ExpirationPlugin({
111
+ maxEntries: 48,
112
+ maxAgeSeconds: 1440 * 60,
113
+ maxAgeFrom: "last-used"
114
+ })]
115
+ })
116
+ },
117
+ {
118
+ matcher: /\.(?:css|less)$/i,
119
+ handler: new StaleWhileRevalidate({
120
+ cacheName: "static-style-assets",
121
+ plugins: [new ExpirationPlugin({
122
+ maxEntries: 32,
123
+ maxAgeSeconds: 1440 * 60,
124
+ maxAgeFrom: "last-used"
125
+ })]
126
+ })
127
+ },
128
+ {
129
+ matcher: /\/_next\/data\/.+\/.+\.json$/i,
130
+ handler: new NetworkFirst({
131
+ cacheName: "next-data",
132
+ plugins: [new ExpirationPlugin({
133
+ maxEntries: 32,
134
+ maxAgeSeconds: 1440 * 60,
135
+ maxAgeFrom: "last-used"
136
+ })]
137
+ })
138
+ },
139
+ {
140
+ matcher: /\.(?:json|xml|csv)$/i,
141
+ handler: new NetworkFirst({
142
+ cacheName: "static-data-assets",
143
+ plugins: [new ExpirationPlugin({
144
+ maxEntries: 32,
145
+ maxAgeSeconds: 1440 * 60,
146
+ maxAgeFrom: "last-used"
147
+ })]
148
+ })
149
+ },
150
+ {
151
+ matcher: /\/api\/auth\/.*/,
152
+ handler: new NetworkOnly({ networkTimeoutSeconds: 10 })
153
+ },
154
+ {
155
+ matcher: ({ sameOrigin, url: { pathname } }) => sameOrigin && pathname.startsWith("/api/"),
156
+ method: "GET",
157
+ handler: new NetworkFirst({
158
+ cacheName: "apis",
159
+ plugins: [new ExpirationPlugin({
160
+ maxEntries: 16,
161
+ maxAgeSeconds: 1440 * 60,
162
+ maxAgeFrom: "last-used"
163
+ })],
164
+ networkTimeoutSeconds: 10
165
+ })
166
+ },
167
+ {
168
+ matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get("RSC") === "1" && request.headers.get("Next-Router-Prefetch") === "1" && sameOrigin && !pathname.startsWith("/api/"),
169
+ handler: new NetworkFirst({
170
+ cacheName: PAGES_CACHE_NAME.rscPrefetch,
171
+ plugins: [new ExpirationPlugin({
172
+ maxEntries: 32,
173
+ maxAgeSeconds: 1440 * 60
174
+ })]
175
+ })
176
+ },
177
+ {
178
+ matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get("RSC") === "1" && sameOrigin && !pathname.startsWith("/api/"),
179
+ handler: new NetworkFirst({
180
+ cacheName: PAGES_CACHE_NAME.rsc,
181
+ plugins: [new ExpirationPlugin({
182
+ maxEntries: 32,
183
+ maxAgeSeconds: 1440 * 60
184
+ })]
185
+ })
186
+ },
187
+ {
188
+ matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get("Content-Type")?.includes("text/html") && sameOrigin && !pathname.startsWith("/api/"),
189
+ handler: new NetworkFirst({
190
+ cacheName: PAGES_CACHE_NAME.html,
191
+ plugins: [new ExpirationPlugin({
192
+ maxEntries: 32,
193
+ maxAgeSeconds: 1440 * 60
194
+ })]
195
+ })
196
+ },
197
+ {
198
+ matcher: ({ url: { pathname }, sameOrigin }) => sameOrigin && !pathname.startsWith("/api/"),
199
+ handler: new NetworkFirst({
200
+ cacheName: "others",
201
+ plugins: [new ExpirationPlugin({
202
+ maxEntries: 32,
203
+ maxAgeSeconds: 1440 * 60
204
+ })]
205
+ })
206
+ },
207
+ {
208
+ matcher: ({ sameOrigin }) => !sameOrigin,
209
+ handler: new NetworkFirst({
210
+ cacheName: "cross-origin",
211
+ plugins: [new ExpirationPlugin({
212
+ maxEntries: 32,
213
+ maxAgeSeconds: 3600
214
+ })],
215
+ networkTimeoutSeconds: 10
216
+ })
217
+ },
218
+ {
219
+ matcher: /.*/i,
220
+ method: "GET",
221
+ handler: new NetworkOnly()
222
+ }
223
+ ];
224
+ //#endregion
225
+ export { PAGES_CACHE_NAME, defaultCache };
226
+
227
+ //# sourceMappingURL=index.worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.worker.mjs","names":["RuntimeCaching","CacheFirst","ExpirationPlugin","NetworkFirst","NetworkOnly","RangeRequestsPlugin","StaleWhileRevalidate","PAGES_CACHE_NAME","rscPrefetch","rsc","html","const","defaultCache","process","env","NODE_ENV","matcher","handler","cacheName","plugins","maxEntries","maxAgeSeconds","maxAgeFrom","networkTimeoutSeconds","sameOrigin","url","pathname","startsWith","method","request","headers","get","includes"],"sources":["../src/index.worker.ts"],"sourcesContent":["import type { RuntimeCaching } from \"serwist\";\nimport { CacheFirst, ExpirationPlugin, NetworkFirst, NetworkOnly, RangeRequestsPlugin, StaleWhileRevalidate } from \"serwist\";\n\nexport const PAGES_CACHE_NAME = {\n rscPrefetch: \"pages-rsc-prefetch\",\n rsc: \"pages-rsc\",\n html: \"pages\",\n} as const;\n\n/**\n * The default, recommended list of caching strategies for applications\n * built with Next.js.\n *\n * @see https://serwist.pages.dev/docs/next/worker-exports#default-cache\n */\nexport const defaultCache: RuntimeCaching[] =\n process.env.NODE_ENV !== \"production\"\n ? [\n {\n matcher: /.*/i,\n handler: new NetworkOnly(),\n },\n ]\n : [\n {\n matcher: /^https:\\/\\/fonts\\.(?:gstatic)\\.com\\/.*/i,\n handler: new CacheFirst({\n cacheName: \"google-fonts-webfonts\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /^https:\\/\\/fonts\\.(?:googleapis)\\.com\\/.*/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"google-fonts-stylesheets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-font-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-image-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/static.+\\.js$/i,\n handler: new CacheFirst({\n cacheName: \"next-static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/image\\?url=.+$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"next-image\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp3|wav|ogg)$/i,\n handler: new CacheFirst({\n cacheName: \"static-audio-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp4|webm)$/i,\n handler: new CacheFirst({\n cacheName: \"static-video-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:js)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 48,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:css|less)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-style-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/data\\/.+\\/.+\\.json$/i,\n handler: new NetworkFirst({\n cacheName: \"next-data\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:json|xml|csv)$/i,\n handler: new NetworkFirst({\n cacheName: \"static-data-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n // Exclude /api/auth/* to fix auth callback\n // https://github.com/serwist/serwist/discussions/28\n matcher: /\\/api\\/auth\\/.*/,\n handler: new NetworkOnly({\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ sameOrigin, url: { pathname } }) => sameOrigin && pathname.startsWith(\"/api/\"),\n method: \"GET\",\n handler: new NetworkFirst({\n cacheName: \"apis\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 16,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"RSC\") === \"1\" && request.headers.get(\"Next-Router-Prefetch\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rscPrefetch,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get(\"RSC\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rsc,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"Content-Type\")?.includes(\"text/html\") && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.html,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ url: { pathname }, sameOrigin }) => sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: \"others\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ sameOrigin }) => !sameOrigin,\n handler: new NetworkFirst({\n cacheName: \"cross-origin\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 60 * 60, // 1 hour\n }),\n ],\n networkTimeoutSeconds: 10,\n }),\n },\n {\n matcher: /.*/i,\n method: \"GET\",\n handler: new NetworkOnly(),\n },\n ];\n"],"mappings":";;AAGA,MAAaO,mBAAmB;CAC9BC,aAAa;CACbC,KAAK;CACLC,MAAM;CACP;;;;;;;AAQD,MAAaE,eACXC,QAAQC,IAAIC,aAAa,eACrB,CACE;CACEC,SAAS;CACTC,SAAS,IAAIb,aAAY;CAC1B,CACF,GACD;CACE;EACEY,SAAS;EACTC,SAAS,IAAIhB,WAAW;GACtBiB,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,MAAM,KAAK,KAAK;IAC/BC,YAAY;IACb,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEN,SAAS;EACTC,SAAS,IAAIX,qBAAqB;GAChCY,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,QAAc;IAC7BC,YAAY;IACb,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEN,SA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AiBK,QAAQC,QAAQC,IAAI,MAAM,KAAK,OAAOP,cAAc,CAACE,SAASC,WAAW,QAAQ;EAC1IV,SAAS,IAAId,aAAa;GACxBe,WAAWX,iBAAiBE;GAC5BU,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,OAAU;IAC1B,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEL,UAAU,EAAEa,SAASJ,KAAK,EAAEC,YAAYF,iBACtCK,QAAQC,QAAQC,IAAI,eAAe,EAAEC,SAAS,YAAY,IAAIR,cAAc,CAACE,SAASC,WAAW,QAAQ;EAC3GV,SAAS,IAAId,aAAa;GACxBe,WAAWX,iBAAiBG;GAC5BS,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,OAAU;IAC1B,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEL,UAAU,EAAES,KAAK,EAAEC,YAAYF,iBAAiBA,cAAc,CAACE,SAASC,WAAW,QAAQ;EAC3FV,SAAS,IAAId,aAAa;GACxBe,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,OAAU;IAC1B,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEL,UAAU,EAAEQ,iBAAiB,CAACA;EAC9BP,SAAS,IAAId,aAAa;GACxBe,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe;IAChB,CAAC,CACH;GACDE,uBAAuB;GACxB,CAAA;EACF;CACD;EACEP,SAAS;EACTY,QAAQ;EACRX,SAAS,IAAIb,aAAY;EAC1B;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/turbopack",
3
- "version": "9.5.7",
3
+ "version": "9.5.9",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "A module that integrates Serwist into your Next.js / Turbopack application.",
@@ -31,64 +31,66 @@
31
31
  "repository": "https://github.com/serwist/serwist",
32
32
  "bugs": "https://github.com/serwist/serwist/issues",
33
33
  "homepage": "https://serwist.pages.dev",
34
- "main": "./dist/index.js",
35
- "types": "./dist/index.d.ts",
34
+ "main": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
36
36
  "typesVersions": {
37
37
  "*": {
38
38
  "react": [
39
- "./dist/index.react.d.ts"
39
+ "./dist/index.react.d.mts"
40
40
  ],
41
41
  "worker": [
42
- "./dist/index.worker.d.ts"
42
+ "./dist/index.worker.d.mts"
43
43
  ],
44
44
  "schema": [
45
- "./dist/index.schema.d.ts"
45
+ "./dist/index.schema.d.mts"
46
46
  ]
47
47
  }
48
48
  },
49
49
  "exports": {
50
50
  ".": {
51
- "types": "./dist/index.d.ts",
52
- "default": "./dist/index.js"
51
+ "types": "./dist/index.d.mts",
52
+ "default": "./dist/index.mjs"
53
53
  },
54
54
  "./react": {
55
- "types": "./dist/index.react.d.ts",
56
- "default": "./dist/index.react.js"
55
+ "types": "./dist/index.react.d.mts",
56
+ "default": "./dist/index.react.mjs"
57
57
  },
58
58
  "./worker": {
59
- "types": "./dist/index.worker.d.ts",
60
- "default": "./dist/index.worker.js"
59
+ "types": "./dist/index.worker.d.mts",
60
+ "default": "./dist/index.worker.mjs"
61
61
  },
62
62
  "./schema": {
63
- "types": "./dist/index.schema.d.ts",
64
- "default": "./dist/index.schema.js"
63
+ "types": "./dist/index.schema.d.mts",
64
+ "default": "./dist/index.schema.mjs"
65
65
  },
66
66
  "./package.json": "./package.json"
67
67
  },
68
68
  "dependencies": {
69
- "@swc/core": "1.15.18",
70
- "browserslist": "4.28.1",
69
+ "@swc/core": "1.15.32",
70
+ "browserslist": "4.28.2",
71
71
  "kolorist": "1.8.0",
72
72
  "semver": "7.7.4",
73
73
  "zod": "4.3.6",
74
- "@serwist/utils": "9.5.7",
75
- "@serwist/build": "9.5.7",
76
- "@serwist/window": "9.5.7",
77
- "serwist": "9.5.7"
74
+ "@serwist/utils": "9.5.9",
75
+ "serwist": "9.5.9",
76
+ "@serwist/window": "9.5.9",
77
+ "@serwist/build": "9.5.9"
78
78
  },
79
79
  "devDependencies": {
80
- "@types/node": "25.5.0",
80
+ "@rolldown/plugin-babel": "0.2.3",
81
+ "@types/node": "25.6.0",
81
82
  "@types/react": "19.2.14",
82
83
  "@types/semver": "7.7.1",
83
- "esbuild": "0.27.4",
84
- "esbuild-wasm": "0.27.4",
85
- "next": "16.1.6",
86
- "react": "19.2.4",
87
- "react-dom": "19.2.4",
88
- "rollup": "4.59.0",
89
- "type-fest": "5.4.4",
90
- "typescript": "5.9.3",
91
- "@serwist/configs": "9.5.7"
84
+ "@vitejs/plugin-react": "6.0.1",
85
+ "babel-plugin-react-compiler": "1.0.0",
86
+ "esbuild": "0.28.0",
87
+ "esbuild-wasm": "0.28.0",
88
+ "next": "16.2.4",
89
+ "react": "19.2.5",
90
+ "react-dom": "19.2.5",
91
+ "tsdown": "0.21.10",
92
+ "type-fest": "5.6.0",
93
+ "typescript": "6.0.3"
92
94
  },
93
95
  "peerDependencies": {
94
96
  "esbuild": ">=0.25.0 <1.0.0",
@@ -109,8 +111,8 @@
109
111
  }
110
112
  },
111
113
  "scripts": {
112
- "build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
113
- "dev": "rollup --config rollup.config.js --watch",
114
+ "build": "rimraf dist && NODE_ENV=production tsdown",
115
+ "dev": "tsdown --watch",
114
116
  "lint": "biome lint ./src",
115
117
  "qcheck": "biome check ./src",
116
118
  "typecheck": "tsc"
@@ -1,185 +0,0 @@
1
- import path from 'node:path';
2
- import { injectPartial, globPartial, basePartial, assertType } from '@serwist/build/schema';
3
- import semver from 'semver';
4
- import z from 'zod';
5
- import { createRequire } from 'node:module';
6
- import { green, bold, white, yellow, red } from 'kolorist';
7
- import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from 'next/constants.js';
8
-
9
- const SUPPORTED_ESBUILD_OPTIONS = [
10
- "sourcemap",
11
- "legalComments",
12
- "sourceRoot",
13
- "sourcesContent",
14
- "format",
15
- "globalName",
16
- "target",
17
- "supported",
18
- "define",
19
- "treeShaking",
20
- "minify",
21
- "mangleProps",
22
- "reserveProps",
23
- "mangleQuoted",
24
- "mangleCache",
25
- "drop",
26
- "dropLabels",
27
- "minifyWhitespace",
28
- "minifyIdentifiers",
29
- "minifySyntax",
30
- "lineLimit",
31
- "charset",
32
- "ignoreAnnotations",
33
- "jsx",
34
- "jsxFactory",
35
- "jsxFragment",
36
- "jsxImportSource",
37
- "jsxDev",
38
- "jsxSideEffects",
39
- "pure",
40
- "keepNames",
41
- "absPaths",
42
- "color",
43
- "logLevel",
44
- "logLimit",
45
- "logOverride",
46
- "tsconfigRaw",
47
- "bundle",
48
- "splitting",
49
- "preserveSymlinks",
50
- "external",
51
- "packages",
52
- "alias",
53
- "loader",
54
- "resolveExtensions",
55
- "mainFields",
56
- "conditions",
57
- "allowOverwrite",
58
- "tsconfig",
59
- "outExtension",
60
- "publicPath",
61
- "inject",
62
- "banner",
63
- "footer",
64
- "plugins"
65
- ];
66
-
67
- const require$1 = createRequire(import.meta.url);
68
- const NEXT_VERSION = require$1("next/package.json").version;
69
- const LOGGING_SPACE_PREFIX = semver.gte(NEXT_VERSION, "16.0.0") ? "" : " ";
70
- const prefixedLog = (prefixType, ...message)=>{
71
- let prefix;
72
- let consoleMethod;
73
- switch(prefixType){
74
- case "wait":
75
- prefix = `${white(bold("○"))} (serwist)`;
76
- consoleMethod = "log";
77
- break;
78
- case "error":
79
- prefix = `${red(bold("X"))} (serwist)`;
80
- consoleMethod = "error";
81
- break;
82
- case "warn":
83
- prefix = `${yellow(bold("⚠"))} (serwist)`;
84
- consoleMethod = "warn";
85
- break;
86
- case "info":
87
- prefix = `${white(bold("○"))} (serwist)`;
88
- consoleMethod = "log";
89
- break;
90
- case "event":
91
- prefix = `${green(bold("✓"))} (serwist)`;
92
- consoleMethod = "log";
93
- break;
94
- }
95
- if ((message[0] === "" || message[0] === undefined) && message.length === 1) {
96
- message.shift();
97
- }
98
- if (message.length === 0) {
99
- console[consoleMethod]("");
100
- } else {
101
- console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);
102
- }
103
- };
104
- const wait = (...message)=>prefixedLog("wait", ...message);
105
- const error = (...message)=>prefixedLog("error", ...message);
106
- const warn = (...message)=>prefixedLog("warn", ...message);
107
- const info = (...message)=>prefixedLog("info", ...message);
108
- const event = (...message)=>prefixedLog("event", ...message);
109
-
110
- var logger = /*#__PURE__*/Object.freeze({
111
- __proto__: null,
112
- NEXT_VERSION: NEXT_VERSION,
113
- error: error,
114
- event: event,
115
- info: info,
116
- wait: wait,
117
- warn: warn
118
- });
119
-
120
- const loadNextConfig = async (cwd, isDev)=>{
121
- const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
122
- // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
123
- const nextConfig = await import(/* webpackIgnore: true */ 'next/dist/server/config.js');
124
- const loadConfig = typeof nextConfig.default === "function" ? nextConfig.default : nextConfig.default.default;
125
- return loadConfig(nextPhase, cwd, {
126
- silent: false
127
- });
128
- };
129
- const generateGlobPatterns = (distDir)=>[
130
- `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,
131
- "public/**/*"
132
- ];
133
-
134
- const turboPartial = z.strictObject({
135
- cwd: z.string().prefault(process.cwd()),
136
- nextConfig: z.object({
137
- assetPrefix: z.string().optional(),
138
- basePath: z.string().optional(),
139
- distDir: z.string().optional()
140
- }).optional(),
141
- useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
142
- rebuildOnChange: z.boolean().prefault(true),
143
- esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({})
144
- });
145
- const injectManifestOptions = z.strictObject({
146
- ...basePartial.shape,
147
- ...globPartial.shape,
148
- ...injectPartial.shape,
149
- ...turboPartial.shape,
150
- globPatterns: z.array(z.string()).optional(),
151
- globDirectory: z.string().optional()
152
- }).omit({
153
- disablePrecacheManifest: true
154
- }).transform(async (input)=>{
155
- // webpackIgnore is only supported by Next.js 15 and above, but it is necessary
156
- const nextConfig = semver.gte(NEXT_VERSION, "15.0.0") ? {
157
- ...await loadNextConfig(input.cwd, process.env.NODE_ENV === "development"),
158
- ...input.nextConfig
159
- } : {
160
- distDir: input.nextConfig?.distDir ?? ".next",
161
- basePath: input.nextConfig?.basePath ?? "/",
162
- assetPrefix: input.nextConfig?.assetPrefix ?? input.nextConfig?.basePath ?? ""
163
- };
164
- let distDir = nextConfig.distDir;
165
- if (distDir[0] === "/") distDir = distDir.slice(1);
166
- if (distDir[distDir.length - 1] !== "/") distDir += "/";
167
- return {
168
- ...input,
169
- swSrc: path.isAbsolute(input.swSrc) ? input.swSrc : path.join(input.cwd, input.swSrc),
170
- globPatterns: input.globPatterns ?? generateGlobPatterns(distDir),
171
- globDirectory: input.globDirectory ?? input.cwd,
172
- dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),
173
- nextConfig: {
174
- ...nextConfig,
175
- distDir,
176
- basePath: nextConfig.basePath || "/"
177
- }
178
- };
179
- });
180
- assertType();
181
- assertType();
182
- assertType();
183
- assertType();
184
-
185
- export { injectManifestOptions as i, logger as l, turboPartial as t };
package/dist/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { NextConfig } from "next";
2
- import { NextResponse } from "next/server.js";
3
- import type { InjectManifestOptions } from "./types.js";
4
- /**
5
- * Creates a Route Handler for Serwist files.
6
- * @param options Options for {@linkcode getFileManifestEntries}.
7
- */
8
- export declare const createSerwistRoute: (options: InjectManifestOptions) => {
9
- dynamic: "force-static";
10
- dynamicParams: false;
11
- revalidate: false;
12
- generateStaticParams: () => Promise<{
13
- path: string;
14
- }[]>;
15
- GET: (_: Request, { params }: {
16
- params: Promise<{
17
- path: string;
18
- }>;
19
- }) => Promise<NextResponse<unknown>>;
20
- };
21
- export declare const withSerwist: (nextConfig?: NextConfig) => NextConfig;
22
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,KAAK,EAAE,qBAAqB,EAAiC,MAAM,YAAY,CAAC;AAuCvF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,qBAAqB;;;;;;;aAoGzC,OAAO,cAAc;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;CAmBjF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,aAAY,UAAe,KAAG,UAGxD,CAAC"}