waku 1.0.0-beta.8 → 1.0.0-beta.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.
- package/README.md +2 -1
- package/dist/adapters/cloudflare.js +3 -2
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/client.d.ts +0 -6
- package/dist/client.js +4 -6
- package/dist/client.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.js +1 -0
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/env.d.ts +1 -4
- package/dist/lib/env.js +1 -3
- package/dist/lib/env.js.map +1 -1
- package/dist/lib/global-types.d.ts +0 -1
- package/dist/lib/types.d.ts +2 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils/custom-errors.d.ts +2 -0
- package/dist/lib/utils/custom-errors.js +6 -0
- package/dist/lib/utils/custom-errors.js.map +1 -1
- package/dist/lib/utils/fs-router.js +1 -0
- package/dist/lib/utils/fs-router.js.map +1 -1
- package/dist/lib/utils/redirect.d.ts +1 -0
- package/dist/lib/utils/redirect.js +45 -0
- package/dist/lib/utils/redirect.js.map +1 -0
- package/dist/lib/utils/render.js +3 -0
- package/dist/lib/utils/render.js.map +1 -1
- package/dist/lib/utils/ssr.d.ts +2 -0
- package/dist/lib/utils/ssr.js +62 -1
- package/dist/lib/utils/ssr.js.map +1 -1
- package/dist/lib/vite-entries/entry.browser.js +0 -5
- package/dist/lib/vite-entries/entry.browser.js.map +1 -1
- package/dist/lib/vite-entries/entry.build.js +2 -2
- package/dist/lib/vite-entries/entry.build.js.map +1 -1
- package/dist/lib/vite-entries/entry.server.js +2 -2
- package/dist/lib/vite-entries/entry.server.js.map +1 -1
- package/dist/lib/vite-plugins/build-id.js +2 -1
- package/dist/lib/vite-plugins/build-id.js.map +1 -1
- package/dist/lib/vite-plugins/patch-rsdw.js +7 -13
- package/dist/lib/vite-plugins/patch-rsdw.js.map +1 -1
- package/dist/lib/vite-rsc/handler.js +25 -8
- package/dist/lib/vite-rsc/handler.js.map +1 -1
- package/dist/lib/vite-rsc/ssr.js +11 -9
- package/dist/lib/vite-rsc/ssr.js.map +1 -1
- package/dist/minimal/client-utils/fetch-store.d.ts +5 -3
- package/dist/minimal/client-utils/fetch-store.js.map +1 -1
- package/dist/minimal/client.d.ts +55 -42
- package/dist/minimal/client.js +195 -129
- package/dist/minimal/client.js.map +1 -1
- package/dist/router/client-utils/error-route.d.ts +16 -0
- package/dist/router/client-utils/error-route.js +66 -0
- package/dist/router/client-utils/error-route.js.map +1 -0
- package/dist/router/client-utils/prefetch-cache.d.ts +5 -3
- package/dist/router/client-utils/prefetch-cache.js +68 -42
- package/dist/router/client-utils/prefetch-cache.js.map +1 -1
- package/dist/router/client-utils/route-url.d.ts +11 -0
- package/dist/router/client-utils/route-url.js +43 -0
- package/dist/router/client-utils/route-url.js.map +1 -0
- package/dist/router/client-utils/router-state.d.ts +37 -0
- package/dist/router/client-utils/router-state.js +70 -0
- package/dist/router/client-utils/router-state.js.map +1 -0
- package/dist/router/client-utils/scroll.d.ts +5 -0
- package/dist/router/client-utils/scroll.js +61 -0
- package/dist/router/client-utils/scroll.js.map +1 -0
- package/dist/router/client.d.ts +70 -22
- package/dist/router/client.js +598 -482
- package/dist/router/client.js.map +1 -1
- package/dist/router/create-pages.d.ts +2 -8
- package/dist/router/create-pages.js +8 -14
- package/dist/router/create-pages.js.map +1 -1
- package/dist/router/define-router-utils/build-handler.js +29 -5
- package/dist/router/define-router-utils/build-handler.js.map +1 -1
- package/dist/router/define-router-utils/client-code.d.ts +1 -1
- package/dist/router/define-router-utils/client-code.js.map +1 -1
- package/dist/router/define-router-utils/config-registry.d.ts +3 -3
- package/dist/router/define-router-utils/config-registry.js +1 -2
- package/dist/router/define-router-utils/config-registry.js.map +1 -1
- package/dist/router/define-router-utils/{config-types.d.ts → config.d.ts} +9 -1
- package/dist/router/define-router-utils/{config-serialization.js → config.js} +6 -1
- package/dist/router/define-router-utils/config.js.map +1 -0
- package/dist/router/define-router-utils/element-cache.d.ts +1 -1
- package/dist/router/define-router-utils/element-cache.js +1 -1
- package/dist/router/define-router-utils/element-cache.js.map +1 -1
- package/dist/router/define-router-utils/request-handler.js +76 -19
- package/dist/router/define-router-utils/request-handler.js.map +1 -1
- package/dist/router/define-router-utils/route-entries.d.ts +2 -2
- package/dist/router/define-router-utils/route-entries.js.map +1 -1
- package/dist/router/define-router.d.ts +11 -6
- package/dist/router/define-router.js +22 -7
- package/dist/router/define-router.js.map +1 -1
- package/dist/router/fs-router.d.ts +1 -1
- package/dist/router/isomorphic-utils/path-spec.d.ts +1 -16
- package/dist/router/isomorphic-utils/path-spec.js +17 -16
- package/dist/router/isomorphic-utils/path-spec.js.map +1 -1
- package/package.json +4 -4
- package/dist/router/client-utils/elements-meta.d.ts +0 -6
- package/dist/router/client-utils/elements-meta.js +0 -21
- package/dist/router/client-utils/elements-meta.js.map +0 -1
- package/dist/router/client-utils/navigate.d.ts +0 -45
- package/dist/router/client-utils/navigate.js +0 -112
- package/dist/router/client-utils/navigate.js.map +0 -1
- package/dist/router/define-router-utils/build-metadata.d.ts +0 -5
- package/dist/router/define-router-utils/build-metadata.js +0 -7
- package/dist/router/define-router-utils/build-metadata.js.map +0 -1
- package/dist/router/define-router-utils/config-serialization.d.ts +0 -5
- package/dist/router/define-router-utils/config-serialization.js.map +0 -1
- package/dist/router/define-router-utils/config-types.js +0 -3
- package/dist/router/define-router-utils/config-types.js.map +0 -1
- package/dist/router/define-router-utils/path-spec.d.ts +0 -5
- package/dist/router/define-router-utils/path-spec.js +0 -19
- package/dist/router/define-router-utils/path-spec.js.map +0 -1
- package/dist/router/define-router-utils/task-runner.d.ts +0 -4
- package/dist/router/define-router-utils/task-runner.js +0 -29
- package/dist/router/define-router-utils/task-runner.js.map +0 -1
package/README.md
CHANGED
|
@@ -524,6 +524,7 @@ Group routes are especially powerful for organizing complex applications where d
|
|
|
524
524
|
|
|
525
525
|
The following directories are ignored by the router:
|
|
526
526
|
|
|
527
|
+
- `_actions`
|
|
527
528
|
- `_components`
|
|
528
529
|
- `_hooks`
|
|
529
530
|
|
|
@@ -1117,7 +1118,7 @@ Data mutations can be performed via [server actions](https://react.dev/reference
|
|
|
1117
1118
|
|
|
1118
1119
|
### API endpoints
|
|
1119
1120
|
|
|
1120
|
-
Create API routes by making a new file in the special `./src/pages/_api` directory and exporting one or more functions named after the HTTP methods that you want it to support: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, or `
|
|
1121
|
+
Create API routes by making a new file in the special `./src/pages/_api` directory and exporting one or more functions named after the HTTP methods that you want it to support: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`, or `QUERY`. The name of the file determines the route it will be served from. Each function receives a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object and returns a standard [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
|
|
1121
1122
|
|
|
1122
1123
|
```ts
|
|
1123
1124
|
// ./src/pages/_api/contact.ts
|
|
@@ -33,7 +33,7 @@ function removeGzipEncoding(res) {
|
|
|
33
33
|
}
|
|
34
34
|
return res;
|
|
35
35
|
}
|
|
36
|
-
export default createServerEntryAdapter(({ processRequest, processBuild,
|
|
36
|
+
export default createServerEntryAdapter(({ processRequest, processBuild, unstable_setAllEnv, config, notFoundHtml }, options)=>{
|
|
37
37
|
const { bodyLimit: bodyLimitOptions, middlewareFns = [], middlewareModules = {}, internalPathToBuildStaticFiles = '__waku_internal_build_static_files' } = options || {};
|
|
38
38
|
const app = new Hono();
|
|
39
39
|
app.notFound((c)=>{
|
|
@@ -102,6 +102,7 @@ export default createServerEntryAdapter(({ processRequest, processBuild, setAllE
|
|
|
102
102
|
return res;
|
|
103
103
|
};
|
|
104
104
|
return {
|
|
105
|
+
...options?.handlers,
|
|
105
106
|
fetch: fetchFn,
|
|
106
107
|
build: async (utils)=>{
|
|
107
108
|
const server = await startPreviewServer();
|
|
@@ -137,7 +138,7 @@ export default createServerEntryAdapter(({ processRequest, processBuild, setAllE
|
|
|
137
138
|
defaultExport: {
|
|
138
139
|
...options?.handlers,
|
|
139
140
|
fetch (req, env) {
|
|
140
|
-
|
|
141
|
+
unstable_setAllEnv(env);
|
|
141
142
|
return fetchFn(req);
|
|
142
143
|
}
|
|
143
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/cloudflare.ts"],"sourcesContent":["import type { MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { Hono } from 'hono/tiny';\nimport {\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_startPreviewServer as startPreviewServer,\n} from 'waku/adapter-builders';\nimport {\n unstable_constants as constants,\n unstable_consumeMultiplexedStream as consumeMultiplexedStream,\n unstable_honoMiddleware as honoMiddleware,\n unstable_produceMultiplexedStream as produceMultiplexedStream,\n} from 'waku/internals';\nimport type { BuildOptions } from './cloudflare-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { rscMiddleware, middlewareRunner } = honoMiddleware;\n\nconst DEFAULT_BODY_LIMIT_MAX_SIZE = 100 * 1024 * 1024;\n\nconst DO_NOT_BUNDLE = '';\n\nconst PRUNABLE_KEY_PREFIX = '\\0__prunable__/';\n\nconst emptyStream = () =>\n new ReadableStream<Uint8Array>({\n start(controller) {\n controller.close();\n },\n });\n\nfunction isProductionWorker(req: Request): boolean {\n // This header seems to only be set for production cloudflare workers\n return !!req.headers.get('cf-visitor');\n}\n\nfunction isLoopbackRequest(req: Request): boolean {\n const { hostname } = new URL(req.url);\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '::1' ||\n hostname === '[::1]'\n );\n}\n\nfunction removeGzipEncoding(res: Response): Response {\n const contentType = res.headers.get('content-type');\n if (\n !contentType ||\n contentType.includes('text/html') ||\n contentType.includes('text/plain')\n ) {\n const headers = new Headers(res.headers);\n headers.set('content-encoding', 'Identity');\n return new Response(res.body, {\n status: res.status,\n statusText: res.statusText,\n headers,\n });\n }\n return res;\n}\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, setAllEnv, config, notFoundHtml },\n options?: {\n static?: boolean;\n handlers?: Record<string, unknown>;\n assetsDir?: string;\n bodyLimit?: Parameters<typeof bodyLimit>[0] | false;\n middlewareFns?: ((opts: { app: Hono }) => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n internalPathToBuildStaticFiles?: string;\n },\n ) => {\n const {\n bodyLimit: bodyLimitOptions,\n middlewareFns = [],\n middlewareModules = {},\n internalPathToBuildStaticFiles = '__waku_internal_build_static_files',\n } = options || {};\n const app = new Hono();\n app.notFound((c) => {\n if (notFoundHtml) {\n return c.html(notFoundHtml, 404);\n }\n return c.text('404 Not Found', 404);\n });\n if (bodyLimitOptions !== false) {\n app.use(\n bodyLimit(bodyLimitOptions ?? { maxSize: DEFAULT_BODY_LIMIT_MAX_SIZE }),\n );\n }\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn({ app }));\n }\n app.use(middlewareRunner(middlewareModules as never, { app }));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n srcDir: config.srcDir,\n distDir: config.distDir,\n DIST_PUBLIC,\n serverless: !options?.static,\n };\n\n const buildBody = () =>\n produceMultiplexedStream(async (emitFile) => {\n await processBuild({\n emitFile,\n unstable_registerPrunableFile: (srcPath) =>\n emitFile(PRUNABLE_KEY_PREFIX + srcPath, emptyStream()),\n });\n });\n\n const fetchFn = async (req: Request) => {\n if (\n new URL(req.url).pathname === `/${internalPathToBuildStaticFiles}` &&\n isLoopbackRequest(req) &&\n !isProductionWorker(req)\n ) {\n return new Response(buildBody());\n }\n let cloudflareContext;\n try {\n cloudflareContext = await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'cloudflare:workers'\n );\n } catch {\n // Not in a Cloudflare environment\n }\n let res: Response | Promise<Response>;\n if (cloudflareContext) {\n const { env, waitUntil, passThroughOnException } = cloudflareContext;\n res = app.fetch(req, env, {\n waitUntil,\n passThroughOnException,\n props: undefined,\n });\n } else {\n res = app.fetch(req);\n }\n // Workaround https://github.com/cloudflare/workers-sdk/issues/6577\n if (import.meta.env?.PROD && !isProductionWorker(req)) {\n if ('then' in res) {\n res = res.then((res) => removeGzipEncoding(res));\n } else {\n res = removeGzipEncoding(res);\n }\n }\n return res;\n };\n\n return {\n fetch: fetchFn,\n build: async (utils) => {\n const server = await startPreviewServer();\n // Fallback middleware for the case without @cloudflare/vite-plugin\n server.middlewares.use(async (_req, res, next) => {\n try {\n const { Readable } = await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'node:stream'\n );\n Readable.fromWeb(buildBody() as never).pipe(res);\n } catch (err) {\n next(err);\n }\n });\n const response = await fetch(\n server.baseUrl + internalPathToBuildStaticFiles,\n { headers: { connection: 'close' } },\n );\n await consumeMultiplexedStream(response.body!, async (key, stream) => {\n if (key.startsWith(PRUNABLE_KEY_PREFIX)) {\n utils.unstable_registerPrunableFile(\n key.slice(PRUNABLE_KEY_PREFIX.length),\n );\n return;\n }\n await utils.emitFile(key, stream);\n });\n // https://github.com/nodejs/node/issues/56645\n await new Promise((resolve) => setTimeout(resolve, 100));\n await server.close();\n },\n buildOptions,\n buildEnhancers: ['waku/adapters/cloudflare-build-enhancer'],\n defaultExport: {\n ...options?.handlers,\n fetch(req: Request, env: Record<string, unknown>) {\n setAllEnv(env);\n return fetchFn(req);\n },\n },\n };\n },\n);\n"],"names":["bodyLimit","Hono","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_startPreviewServer","startPreviewServer","unstable_constants","constants","unstable_consumeMultiplexedStream","consumeMultiplexedStream","unstable_honoMiddleware","honoMiddleware","unstable_produceMultiplexedStream","produceMultiplexedStream","DIST_PUBLIC","rscMiddleware","middlewareRunner","DEFAULT_BODY_LIMIT_MAX_SIZE","DO_NOT_BUNDLE","PRUNABLE_KEY_PREFIX","emptyStream","ReadableStream","start","controller","close","isProductionWorker","req","headers","get","isLoopbackRequest","hostname","URL","url","removeGzipEncoding","res","contentType","includes","Headers","set","Response","body","status","statusText","processRequest","processBuild","setAllEnv","config","notFoundHtml","options","bodyLimitOptions","middlewareFns","middlewareModules","internalPathToBuildStaticFiles","app","notFound","c","html","text","use","maxSize","middlewareFn","buildOptions","srcDir","distDir","serverless","static","buildBody","emitFile","unstable_registerPrunableFile","srcPath","fetchFn","pathname","cloudflareContext","env","waitUntil","passThroughOnException","fetch","props","undefined","PROD","then","build","utils","server","middlewares","_req","next","Readable","fromWeb","pipe","err","response","baseUrl","connection","key","stream","startsWith","slice","length","Promise","resolve","setTimeout","buildEnhancers","defaultExport","handlers"],"mappings":"AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,YAAY;AACjC,SACEC,qCAAqCC,wBAAwB,EAC7DC,+BAA+BC,kBAAkB,QAC5C,wBAAwB;AAC/B,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,EACzCC,qCAAqCC,wBAAwB,QACxD,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGP;AACxB,MAAM,EAAEQ,aAAa,EAAEC,gBAAgB,EAAE,GAAGL;AAE5C,MAAMM,8BAA8B,MAAM,OAAO;AAEjD,MAAMC,gBAAgB;AAEtB,MAAMC,sBAAsB;AAE5B,MAAMC,cAAc,IAClB,IAAIC,eAA2B;QAC7BC,OAAMC,UAAU;YACdA,WAAWC,KAAK;QAClB;IACF;AAEF,SAASC,mBAAmBC,GAAY;IACtC,qEAAqE;IACrE,OAAO,CAAC,CAACA,IAAIC,OAAO,CAACC,GAAG,CAAC;AAC3B;AAEA,SAASC,kBAAkBH,GAAY;IACrC,MAAM,EAAEI,QAAQ,EAAE,GAAG,IAAIC,IAAIL,IAAIM,GAAG;IACpC,OACEF,aAAa,eACbA,aAAa,eACbA,aAAa,SACbA,aAAa;AAE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AC9C,EAAE,OAAOwD,KAAK;oBACZJ,KAAKI;gBACP;YACF;YACA,MAAMC,WAAW,MAAMf,MACrBO,OAAOS,OAAO,GAAGxC,gCACjB;gBAAEzB,SAAS;oBAAEkE,YAAY;gBAAQ;YAAE;YAErC,MAAMpF,yBAAyBkF,SAASnD,IAAI,EAAG,OAAOsD,KAAKC;gBACzD,IAAID,IAAIE,UAAU,CAAC7E,sBAAsB;oBACvC+D,MAAMd,6BAA6B,CACjC0B,IAAIG,KAAK,CAAC9E,oBAAoB+E,MAAM;oBAEtC;gBACF;gBACA,MAAMhB,MAAMf,QAAQ,CAAC2B,KAAKC;YAC5B;YACA,8CAA8C;YAC9C,MAAM,IAAII,QAAQ,CAACC,UAAYC,WAAWD,SAAS;YACnD,MAAMjB,OAAO3D,KAAK;QACpB;QACAqC;QACAyC,gBAAgB;YAAC;SAA0C;QAC3DC,eAAe;YACb,GAAGvD,SAASwD,QAAQ;YACpB5B,OAAMlD,GAAY,EAAE+C,GAA4B;gBAC9C5B,UAAU4B;gBACV,OAAOH,QAAQ5C;YACjB;QACF;IACF;AACF,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/cloudflare.ts"],"sourcesContent":["import type { MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { Hono } from 'hono/tiny';\nimport {\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_startPreviewServer as startPreviewServer,\n} from 'waku/adapter-builders';\nimport {\n unstable_constants as constants,\n unstable_consumeMultiplexedStream as consumeMultiplexedStream,\n unstable_honoMiddleware as honoMiddleware,\n unstable_produceMultiplexedStream as produceMultiplexedStream,\n} from 'waku/internals';\nimport type { BuildOptions } from './cloudflare-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { rscMiddleware, middlewareRunner } = honoMiddleware;\n\nconst DEFAULT_BODY_LIMIT_MAX_SIZE = 100 * 1024 * 1024;\n\nconst DO_NOT_BUNDLE = '';\n\nconst PRUNABLE_KEY_PREFIX = '\\0__prunable__/';\n\nconst emptyStream = () =>\n new ReadableStream<Uint8Array>({\n start(controller) {\n controller.close();\n },\n });\n\nfunction isProductionWorker(req: Request): boolean {\n // This header seems to only be set for production cloudflare workers\n return !!req.headers.get('cf-visitor');\n}\n\nfunction isLoopbackRequest(req: Request): boolean {\n const { hostname } = new URL(req.url);\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '::1' ||\n hostname === '[::1]'\n );\n}\n\nfunction removeGzipEncoding(res: Response): Response {\n const contentType = res.headers.get('content-type');\n if (\n !contentType ||\n contentType.includes('text/html') ||\n contentType.includes('text/plain')\n ) {\n const headers = new Headers(res.headers);\n headers.set('content-encoding', 'Identity');\n return new Response(res.body, {\n status: res.status,\n statusText: res.statusText,\n headers,\n });\n }\n return res;\n}\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, unstable_setAllEnv, config, notFoundHtml },\n options?: {\n static?: boolean;\n handlers?: Record<string, unknown>;\n assetsDir?: string;\n bodyLimit?: Parameters<typeof bodyLimit>[0] | false;\n middlewareFns?: ((opts: { app: Hono }) => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n internalPathToBuildStaticFiles?: string;\n },\n ) => {\n const {\n bodyLimit: bodyLimitOptions,\n middlewareFns = [],\n middlewareModules = {},\n internalPathToBuildStaticFiles = '__waku_internal_build_static_files',\n } = options || {};\n const app = new Hono();\n app.notFound((c) => {\n if (notFoundHtml) {\n return c.html(notFoundHtml, 404);\n }\n return c.text('404 Not Found', 404);\n });\n if (bodyLimitOptions !== false) {\n app.use(\n bodyLimit(bodyLimitOptions ?? { maxSize: DEFAULT_BODY_LIMIT_MAX_SIZE }),\n );\n }\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn({ app }));\n }\n app.use(middlewareRunner(middlewareModules as never, { app }));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n srcDir: config.srcDir,\n distDir: config.distDir,\n DIST_PUBLIC,\n serverless: !options?.static,\n };\n\n const buildBody = () =>\n produceMultiplexedStream(async (emitFile) => {\n await processBuild({\n emitFile,\n unstable_registerPrunableFile: (srcPath) =>\n emitFile(PRUNABLE_KEY_PREFIX + srcPath, emptyStream()),\n });\n });\n\n const fetchFn = async (req: Request) => {\n if (\n new URL(req.url).pathname === `/${internalPathToBuildStaticFiles}` &&\n isLoopbackRequest(req) &&\n !isProductionWorker(req)\n ) {\n return new Response(buildBody());\n }\n let cloudflareContext;\n try {\n cloudflareContext = await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'cloudflare:workers'\n );\n } catch {\n // Not in a Cloudflare environment\n }\n let res: Response | Promise<Response>;\n if (cloudflareContext) {\n const { env, waitUntil, passThroughOnException } = cloudflareContext;\n res = app.fetch(req, env, {\n waitUntil,\n passThroughOnException,\n props: undefined,\n });\n } else {\n res = app.fetch(req);\n }\n // Workaround https://github.com/cloudflare/workers-sdk/issues/6577\n if (import.meta.env?.PROD && !isProductionWorker(req)) {\n if ('then' in res) {\n res = res.then((res) => removeGzipEncoding(res));\n } else {\n res = removeGzipEncoding(res);\n }\n }\n return res;\n };\n\n return {\n ...options?.handlers,\n fetch: fetchFn,\n build: async (utils) => {\n const server = await startPreviewServer();\n // Fallback middleware for the case without @cloudflare/vite-plugin\n server.middlewares.use(async (_req, res, next) => {\n try {\n const { Readable } = await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'node:stream'\n );\n Readable.fromWeb(buildBody() as never).pipe(res);\n } catch (err) {\n next(err);\n }\n });\n const response = await fetch(\n server.baseUrl + internalPathToBuildStaticFiles,\n { headers: { connection: 'close' } },\n );\n await consumeMultiplexedStream(response.body!, async (key, stream) => {\n if (key.startsWith(PRUNABLE_KEY_PREFIX)) {\n utils.unstable_registerPrunableFile(\n key.slice(PRUNABLE_KEY_PREFIX.length),\n );\n return;\n }\n await utils.emitFile(key, stream);\n });\n // https://github.com/nodejs/node/issues/56645\n await new Promise((resolve) => setTimeout(resolve, 100));\n await server.close();\n },\n buildOptions,\n buildEnhancers: ['waku/adapters/cloudflare-build-enhancer'],\n defaultExport: {\n ...options?.handlers,\n fetch(req: Request, env: Record<string, unknown>) {\n unstable_setAllEnv(env);\n return fetchFn(req);\n },\n },\n };\n },\n);\n"],"names":["bodyLimit","Hono","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_startPreviewServer","startPreviewServer","unstable_constants","constants","unstable_consumeMultiplexedStream","consumeMultiplexedStream","unstable_honoMiddleware","honoMiddleware","unstable_produceMultiplexedStream","produceMultiplexedStream","DIST_PUBLIC","rscMiddleware","middlewareRunner","DEFAULT_BODY_LIMIT_MAX_SIZE","DO_NOT_BUNDLE","PRUNABLE_KEY_PREFIX","emptyStream","ReadableStream","start","controller","close","isProductionWorker","req","headers","get","isLoopbackRequest","hostname","URL","url","removeGzipEncoding","res","contentType","includes","Headers","set","Response","body","status","statusText","processRequest","processBuild","unstable_setAllEnv","config","notFoundHtml","options","bodyLimitOptions","middlewareFns","middlewareModules","internalPathToBuildStaticFiles","app","notFound","c","html","text","use","maxSize","middlewareFn","buildOptions","srcDir","distDir","serverless","static","buildBody","emitFile","unstable_registerPrunableFile","srcPath","fetchFn","pathname","cloudflareContext","env","waitUntil","passThroughOnException","fetch","props","undefined","PROD","then","handlers","build","utils","server","middlewares","_req","next","Readable","fromWeb","pipe","err","response","baseUrl","connection","key","stream","startsWith","slice","length","Promise","resolve","setTimeout","buildEnhancers","defaultExport"],"mappings":"AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,IAAI,QAAQ,YAAY;AACjC,SACEC,qCAAqCC,wBAAwB,EAC7DC,+BAA+BC,kBAAkB,QAC5C,wBAAwB;AAC/B,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,EACzCC,qCAAqCC,wBAAwB,QACxD,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGP;AACxB,MAAM,EAAEQ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 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Experimental, the name and the behavior might change.
|
|
3
|
-
*/
|
|
4
1
|
export declare const unstable_allowServer: <T>(x: T) => T;
|
|
5
|
-
/**
|
|
6
|
-
* Unsure if this is going to be a public API in the future.
|
|
7
|
-
*/
|
|
8
2
|
export declare const unstable_defaultRootOptions: {
|
|
9
3
|
onCaughtError(error: unknown): void;
|
|
10
4
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getErrorInfo } from './lib/utils/custom-errors.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Unsure if this is going to be a public API in the future.
|
|
7
|
-
*/ export const unstable_defaultRootOptions = {
|
|
2
|
+
// Experimental, the name and the behavior might change.
|
|
3
|
+
export const unstable_allowServer = (x)=>x;
|
|
4
|
+
// Unsure if this is going to be a public API in the future.
|
|
5
|
+
export const unstable_defaultRootOptions = {
|
|
8
6
|
onCaughtError (error) {
|
|
9
7
|
if (getErrorInfo(error)) {
|
|
10
8
|
return;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { getErrorInfo } from './lib/utils/custom-errors.js';\n\n
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { getErrorInfo } from './lib/utils/custom-errors.js';\n\n// Experimental, the name and the behavior might change.\nexport const unstable_allowServer = <T>(x: T) => x;\n\n// Unsure if this is going to be a public API in the future.\nexport const unstable_defaultRootOptions = {\n onCaughtError(error: unknown) {\n if (getErrorInfo(error)) {\n return;\n }\n console.error(error);\n },\n};\n"],"names":["getErrorInfo","unstable_allowServer","x","unstable_defaultRootOptions","onCaughtError","error","console"],"mappings":"AAAA,SAASA,YAAY,QAAQ,+BAA+B;AAE5D,wDAAwD;AACxD,OAAO,MAAMC,uBAAuB,CAAIC,IAASA,EAAE;AAEnD,4DAA4D;AAC5D,OAAO,MAAMC,8BAA8B;IACzCC,eAAcC,KAAc;QAC1B,IAAIL,aAAaK,QAAQ;YACvB;QACF;QACAC,QAAQD,KAAK,CAACA;IAChB;AACF,EAAE"}
|
package/dist/lib/constants.d.ts
CHANGED
package/dist/lib/constants.js
CHANGED
|
@@ -6,6 +6,7 @@ export const EXTENSIONS = [
|
|
|
6
6
|
'.mjs',
|
|
7
7
|
'.cjs'
|
|
8
8
|
];
|
|
9
|
+
export const DEV_BUILD_ID = 'dev'; // truthy on purpose
|
|
9
10
|
export const SRC_CLIENT_ENTRY = 'waku.client';
|
|
10
11
|
export const SRC_SERVER_ENTRY = 'waku.server';
|
|
11
12
|
export const SRC_PAGES = 'pages'; // only for managed mode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/constants.ts"],"sourcesContent":["export const EXTENSIONS = ['.js', '.ts', '.tsx', '.jsx', '.mjs', '.cjs'];\nexport const SRC_CLIENT_ENTRY = 'waku.client';\nexport const SRC_SERVER_ENTRY = 'waku.server';\nexport const SRC_PAGES = 'pages'; // only for managed mode\nexport const SRC_MIDDLEWARE = 'middleware'; // only for managed mode\n\n// Some file and dir names for dist\n// We may change this in the future\nexport const DIST_PUBLIC = 'public';\nexport const DIST_SERVER = 'server';\nexport const BUILD_METADATA_FILE = '__waku_build_metadata.js';\n"],"names":["EXTENSIONS","SRC_CLIENT_ENTRY","SRC_SERVER_ENTRY","SRC_PAGES","SRC_MIDDLEWARE","DIST_PUBLIC","DIST_SERVER","BUILD_METADATA_FILE"],"mappings":"AAAA,OAAO,MAAMA,aAAa;IAAC;IAAO;IAAO;IAAQ;IAAQ;IAAQ;CAAO,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../src/lib/constants.ts"],"sourcesContent":["export const EXTENSIONS = ['.js', '.ts', '.tsx', '.jsx', '.mjs', '.cjs'];\n\nexport const DEV_BUILD_ID = 'dev'; // truthy on purpose\nexport const SRC_CLIENT_ENTRY = 'waku.client';\nexport const SRC_SERVER_ENTRY = 'waku.server';\nexport const SRC_PAGES = 'pages'; // only for managed mode\nexport const SRC_MIDDLEWARE = 'middleware'; // only for managed mode\n\n// Some file and dir names for dist\n// We may change this in the future\nexport const DIST_PUBLIC = 'public';\nexport const DIST_SERVER = 'server';\nexport const BUILD_METADATA_FILE = '__waku_build_metadata.js';\n"],"names":["EXTENSIONS","DEV_BUILD_ID","SRC_CLIENT_ENTRY","SRC_SERVER_ENTRY","SRC_PAGES","SRC_MIDDLEWARE","DIST_PUBLIC","DIST_SERVER","BUILD_METADATA_FILE"],"mappings":"AAAA,OAAO,MAAMA,aAAa;IAAC;IAAO;IAAO;IAAQ;IAAQ;IAAQ;CAAO,CAAC;AAEzE,OAAO,MAAMC,eAAe,MAAM,CAAC,oBAAoB;AACvD,OAAO,MAAMC,mBAAmB,cAAc;AAC9C,OAAO,MAAMC,mBAAmB,cAAc;AAC9C,OAAO,MAAMC,YAAY,QAAQ,CAAC,wBAAwB;AAC1D,OAAO,MAAMC,iBAAiB,aAAa,CAAC,wBAAwB;AAEpE,mCAAmC;AACnC,mCAAmC;AACnC,OAAO,MAAMC,cAAc,SAAS;AACpC,OAAO,MAAMC,cAAc,SAAS;AACpC,OAAO,MAAMC,sBAAsB,2BAA2B"}
|
package/dist/lib/env.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* This is an internal function and not for public use.
|
|
3
|
-
*/
|
|
4
|
-
export declare function setAllEnv(newEnv: Readonly<Record<string, unknown>>): void;
|
|
1
|
+
export declare function unstable_setAllEnv(newEnv: Readonly<Record<string, unknown>>): void;
|
|
5
2
|
export declare function getEnv(key: string): string | undefined;
|
package/dist/lib/env.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// The use of `globalThis` in this file is more or less a hack.
|
|
2
2
|
// It should be revisited with a better solution.
|
|
3
|
-
|
|
4
|
-
* This is an internal function and not for public use.
|
|
5
|
-
*/ export function setAllEnv(newEnv) {
|
|
3
|
+
export function unstable_setAllEnv(newEnv) {
|
|
6
4
|
const env = {};
|
|
7
5
|
for (const [key, value] of Object.entries(newEnv)){
|
|
8
6
|
if (typeof value === 'string') {
|
package/dist/lib/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/env.ts"],"sourcesContent":["// The use of `globalThis` in this file is more or less a hack.\n// It should be revisited with a better solution.\n\
|
|
1
|
+
{"version":3,"sources":["../../src/lib/env.ts"],"sourcesContent":["// The use of `globalThis` in this file is more or less a hack.\n// It should be revisited with a better solution.\n\nexport function unstable_setAllEnv(newEnv: Readonly<Record<string, unknown>>) {\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(newEnv)) {\n if (typeof value === 'string') {\n env[key] = value;\n }\n }\n globalThis.__WAKU_SERVER_ENV__ = env;\n}\n\nexport function getEnv(key: string): string | undefined {\n return globalThis.__WAKU_SERVER_ENV__?.[key];\n}\n"],"names":["unstable_setAllEnv","newEnv","env","key","value","Object","entries","globalThis","__WAKU_SERVER_ENV__","getEnv"],"mappings":"AAAA,+DAA+D;AAC/D,iDAAiD;AAEjD,OAAO,SAASA,mBAAmBC,MAAyC;IAC1E,MAAMC,MAA8B,CAAC;IACrC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,QAAS;QACjD,IAAI,OAAOG,UAAU,UAAU;YAC7BF,GAAG,CAACC,IAAI,GAAGC;QACb;IACF;IACAG,WAAWC,mBAAmB,GAAGN;AACnC;AAEA,OAAO,SAASO,OAAON,GAAW;IAChC,OAAOI,WAAWC,mBAAmB,EAAE,CAACL,IAAI;AAC9C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
declare global {
|
|
2
2
|
var __WAKU_RSC_RELOAD_LISTENERS__: (() => void)[] | undefined;
|
|
3
3
|
var __WAKU_REFETCH_RSC__: (() => void) | undefined;
|
|
4
|
-
var __WAKU_REFETCH_ROUTE__: (() => void) | undefined;
|
|
5
4
|
var __WAKU_START_PREVIEW_SERVER__: (() => Promise<import('./vite-rsc/preview.js').PreviewServer>) | undefined;
|
|
6
5
|
var __WAKU_SERVER_ENV__: Readonly<Record<string, string>> | undefined;
|
|
7
6
|
var __WAKU_INITIAL_RSC__: import('./utils/initial-rsc.js').InitialRscEntry | undefined;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type Elements = Record<string, unknown>;
|
|
|
5
5
|
export type Unstable_RenderRsc = (elements: Elements, options?: {
|
|
6
6
|
value?: unknown;
|
|
7
7
|
etags?: Etags;
|
|
8
|
+
documentLocation?: string;
|
|
8
9
|
unstable_clientModuleCallback?: (ids: string[]) => void;
|
|
9
10
|
}) => Promise<ReadableStream>;
|
|
10
11
|
export type Unstable_RenderHtml = (elementsStream: ReadableStream, html: ReactNode, options: {
|
|
@@ -72,7 +73,7 @@ export type Unstable_CreateServerEntryAdapter = <Options>(fn: (args: {
|
|
|
72
73
|
handlers: Unstable_Handlers;
|
|
73
74
|
processRequest: Unstable_ProcessRequest;
|
|
74
75
|
processBuild: Unstable_ProcessBuild;
|
|
75
|
-
|
|
76
|
+
unstable_setAllEnv: (newEnv: Readonly<Record<string, unknown>>) => void;
|
|
76
77
|
config: Omit<Required<Config>, 'vite'>;
|
|
77
78
|
isBuild: boolean;
|
|
78
79
|
notFoundHtml: string;
|
package/dist/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Config } from '../config.js';\nimport type { Etags } from './utils/etags.js';\n\ntype Elements = Record<string, unknown>;\n\nexport type Unstable_RenderRsc = (\n elements: Elements,\n options?: {\n value?: unknown;\n etags?: Etags;\n unstable_clientModuleCallback?: (ids: string[]) => void;\n },\n) => Promise<ReadableStream>;\n\nexport type Unstable_RenderHtml = (\n elementsStream: ReadableStream,\n html: ReactNode,\n options: {\n rscPath: string;\n formState?: unknown;\n status?: number;\n nonce?: string;\n unstable_extraScriptContent?: string;\n },\n) => Promise<Response>;\n\nexport type Unstable_EmitFile = (\n filePath: string,\n body: ReadableStream,\n) => Promise<void>;\n\nexport type Unstable_HandleRequest = (\n input: (\n | { type: 'rsc'; rscPath: string; rscParams: unknown }\n | {\n type: 'call';\n fn: (...args: unknown[]) => Promise<unknown>;\n args: unknown[];\n }\n | {\n type: 'http';\n tryAction?: () => Promise<\n | { action: true; formState: unknown }\n | { action: false; formData: FormData }\n >;\n }\n ) & {\n pathname: string;\n req: Request;\n etags?: Etags;\n },\n utils: {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n loadBuildMetadata: (key: string) => Promise<string | undefined>;\n },\n) => Promise<ReadableStream | Response | 'fallback' | null | undefined>;\n\nexport type Unstable_HandleBuild = (utils: {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n rscPath2pathname: (rscPath: string) => string;\n saveBuildMetadata: (key: string, value: string) => Promise<void>;\n generateFile: (\n fileName: string,\n body: ReadableStream | string,\n ) => Promise<void>;\n generateDefaultHtml: (fileName: string) => Promise<void>;\n unstable_registerPrunableFile: (srcPath: string) => void;\n}) => Promise<void>;\n\nexport type Unstable_Handlers = {\n handleRequest: Unstable_HandleRequest;\n handleBuild: Unstable_HandleBuild;\n [someOtherProperty: string]: unknown;\n};\n\nexport type Unstable_ServerEntry = {\n fetch: (req: Request, ...args: any[]) => Response | Promise<Response>;\n build: (\n utils: {\n emitFile: Unstable_EmitFile;\n unstable_registerPrunableFile: (srcPath: string) => void;\n },\n ...args: any[]\n ) => Promise<void>;\n buildOptions?: Record<string, unknown>;\n buildEnhancers?: string[]; // enhancer module ids\n defaultExport?: unknown;\n [someOtherProperty: string]: unknown;\n};\n\nexport type Unstable_ProcessRequest = (\n arg: Parameters<Unstable_ServerEntry['fetch']>[0],\n) => Promise<Response | null>;\n\nexport type Unstable_ProcessBuild = (\n arg: Parameters<Unstable_ServerEntry['build']>[0],\n) => Promise<void>;\n\nexport type Unstable_CreateServerEntryAdapter = <Options>(\n fn: (\n args: {\n handlers: Unstable_Handlers;\n processRequest: Unstable_ProcessRequest;\n processBuild: Unstable_ProcessBuild;\n
|
|
1
|
+
{"version":3,"sources":["../../src/lib/types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Config } from '../config.js';\nimport type { Etags } from './utils/etags.js';\n\ntype Elements = Record<string, unknown>;\n\nexport type Unstable_RenderRsc = (\n elements: Elements,\n options?: {\n value?: unknown;\n etags?: Etags;\n documentLocation?: string;\n unstable_clientModuleCallback?: (ids: string[]) => void;\n },\n) => Promise<ReadableStream>;\n\nexport type Unstable_RenderHtml = (\n elementsStream: ReadableStream,\n html: ReactNode,\n options: {\n rscPath: string;\n formState?: unknown;\n status?: number;\n nonce?: string;\n unstable_extraScriptContent?: string;\n },\n) => Promise<Response>;\n\nexport type Unstable_EmitFile = (\n filePath: string,\n body: ReadableStream,\n) => Promise<void>;\n\nexport type Unstable_HandleRequest = (\n input: (\n | { type: 'rsc'; rscPath: string; rscParams: unknown }\n | {\n type: 'call';\n fn: (...args: unknown[]) => Promise<unknown>;\n args: unknown[];\n }\n | {\n type: 'http';\n tryAction?: () => Promise<\n | { action: true; formState: unknown }\n | { action: false; formData: FormData }\n >;\n }\n ) & {\n pathname: string;\n req: Request;\n etags?: Etags;\n },\n utils: {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n loadBuildMetadata: (key: string) => Promise<string | undefined>;\n },\n) => Promise<ReadableStream | Response | 'fallback' | null | undefined>;\n\nexport type Unstable_HandleBuild = (utils: {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n rscPath2pathname: (rscPath: string) => string;\n saveBuildMetadata: (key: string, value: string) => Promise<void>;\n generateFile: (\n fileName: string,\n body: ReadableStream | string,\n ) => Promise<void>;\n generateDefaultHtml: (fileName: string) => Promise<void>;\n unstable_registerPrunableFile: (srcPath: string) => void;\n}) => Promise<void>;\n\nexport type Unstable_Handlers = {\n handleRequest: Unstable_HandleRequest;\n handleBuild: Unstable_HandleBuild;\n [someOtherProperty: string]: unknown;\n};\n\nexport type Unstable_ServerEntry = {\n fetch: (req: Request, ...args: any[]) => Response | Promise<Response>;\n build: (\n utils: {\n emitFile: Unstable_EmitFile;\n unstable_registerPrunableFile: (srcPath: string) => void;\n },\n ...args: any[]\n ) => Promise<void>;\n buildOptions?: Record<string, unknown>;\n buildEnhancers?: string[]; // enhancer module ids\n defaultExport?: unknown;\n [someOtherProperty: string]: unknown;\n};\n\nexport type Unstable_ProcessRequest = (\n arg: Parameters<Unstable_ServerEntry['fetch']>[0],\n) => Promise<Response | null>;\n\nexport type Unstable_ProcessBuild = (\n arg: Parameters<Unstable_ServerEntry['build']>[0],\n) => Promise<void>;\n\nexport type Unstable_CreateServerEntryAdapter = <Options>(\n fn: (\n args: {\n handlers: Unstable_Handlers;\n processRequest: Unstable_ProcessRequest;\n processBuild: Unstable_ProcessBuild;\n unstable_setAllEnv: (newEnv: Readonly<Record<string, unknown>>) => void;\n config: Omit<Required<Config>, 'vite'>;\n isBuild: boolean;\n notFoundHtml: string;\n },\n options?: Options,\n ) => Unstable_ServerEntry,\n) => (handlers: Unstable_Handlers, options?: Options) => Unstable_ServerEntry;\n"],"names":[],"mappings":"AAsGA,WAa8E"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type ErrorInfo = {
|
|
2
2
|
status?: number;
|
|
3
3
|
location?: string;
|
|
4
|
+
unstable_leave?: boolean;
|
|
5
|
+
unstable_networkError?: boolean;
|
|
4
6
|
};
|
|
5
7
|
export declare const createCustomError: (message: string, errorInfo: ErrorInfo) => Error;
|
|
6
8
|
export declare const getErrorInfo: (err: unknown) => ErrorInfo | null;
|
|
@@ -8,6 +8,12 @@ const isErrorInfo = (x)=>{
|
|
|
8
8
|
if ('location' in x && typeof x.location !== 'string') {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
|
+
if ('unstable_leave' in x && typeof x.unstable_leave !== 'boolean') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if ('unstable_networkError' in x && typeof x.unstable_networkError !== 'boolean') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
11
17
|
return true;
|
|
12
18
|
};
|
|
13
19
|
const prefix = '__WAKU_CUSTOM_ERROR__;';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/custom-errors.ts"],"sourcesContent":["type ErrorInfo = {\n status?: number;\n location?: string;\n};\n\nconst isErrorInfo = (x: unknown): x is ErrorInfo => {\n if (typeof x !== 'object' || x === null) {\n return false;\n }\n if ('status' in x && typeof (x as ErrorInfo).status !== 'number') {\n return false;\n }\n if ('location' in x && typeof (x as ErrorInfo).location !== 'string') {\n return false;\n }\n return true;\n};\n\nconst prefix = '__WAKU_CUSTOM_ERROR__;';\n\n// This is an internal API and not for public use\nexport const createCustomError = (message: string, errorInfo: ErrorInfo) => {\n const err = new Error(message);\n (err as { digest?: string }).digest = prefix + JSON.stringify(errorInfo);\n return err;\n};\n\nexport const getErrorInfo = (err: unknown) => {\n const digest = (err as { digest?: string } | undefined)?.digest;\n if (typeof digest !== 'string' || !digest.startsWith(prefix)) {\n return null;\n }\n try {\n const info = JSON.parse(digest.slice(prefix.length));\n if (isErrorInfo(info)) {\n return info;\n }\n } catch {\n // ignore\n }\n return null;\n};\n"],"names":["isErrorInfo","x","status","location","prefix","createCustomError","message","errorInfo","err","Error","digest","JSON","stringify","getErrorInfo","startsWith","info","parse","slice","length"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/custom-errors.ts"],"sourcesContent":["type ErrorInfo = {\n status?: number;\n location?: string;\n unstable_leave?: boolean;\n // set by the client, read by no one in waku: an app decides its own recovery\n unstable_networkError?: boolean;\n};\n\nconst isErrorInfo = (x: unknown): x is ErrorInfo => {\n if (typeof x !== 'object' || x === null) {\n return false;\n }\n if ('status' in x && typeof (x as ErrorInfo).status !== 'number') {\n return false;\n }\n if ('location' in x && typeof (x as ErrorInfo).location !== 'string') {\n return false;\n }\n if (\n 'unstable_leave' in x &&\n typeof (x as ErrorInfo).unstable_leave !== 'boolean'\n ) {\n return false;\n }\n if (\n 'unstable_networkError' in x &&\n typeof (x as ErrorInfo).unstable_networkError !== 'boolean'\n ) {\n return false;\n }\n return true;\n};\n\nconst prefix = '__WAKU_CUSTOM_ERROR__;';\n\n// This is an internal API and not for public use\nexport const createCustomError = (message: string, errorInfo: ErrorInfo) => {\n const err = new Error(message);\n (err as { digest?: string }).digest = prefix + JSON.stringify(errorInfo);\n return err;\n};\n\nexport const getErrorInfo = (err: unknown) => {\n const digest = (err as { digest?: string } | undefined)?.digest;\n if (typeof digest !== 'string' || !digest.startsWith(prefix)) {\n return null;\n }\n try {\n const info = JSON.parse(digest.slice(prefix.length));\n if (isErrorInfo(info)) {\n return info;\n }\n } catch {\n // ignore\n }\n return null;\n};\n"],"names":["isErrorInfo","x","status","location","unstable_leave","unstable_networkError","prefix","createCustomError","message","errorInfo","err","Error","digest","JSON","stringify","getErrorInfo","startsWith","info","parse","slice","length"],"mappings":"AAQA,MAAMA,cAAc,CAACC;IACnB,IAAI,OAAOA,MAAM,YAAYA,MAAM,MAAM;QACvC,OAAO;IACT;IACA,IAAI,YAAYA,KAAK,OAAO,AAACA,EAAgBC,MAAM,KAAK,UAAU;QAChE,OAAO;IACT;IACA,IAAI,cAAcD,KAAK,OAAO,AAACA,EAAgBE,QAAQ,KAAK,UAAU;QACpE,OAAO;IACT;IACA,IACE,oBAAoBF,KACpB,OAAO,AAACA,EAAgBG,cAAc,KAAK,WAC3C;QACA,OAAO;IACT;IACA,IACE,2BAA2BH,KAC3B,OAAO,AAACA,EAAgBI,qBAAqB,KAAK,WAClD;QACA,OAAO;IACT;IACA,OAAO;AACT;AAEA,MAAMC,SAAS;AAEf,iDAAiD;AACjD,OAAO,MAAMC,oBAAoB,CAACC,SAAiBC;IACjD,MAAMC,MAAM,IAAIC,MAAMH;IACrBE,IAA4BE,MAAM,GAAGN,SAASO,KAAKC,SAAS,CAACL;IAC9D,OAAOC;AACT,EAAE;AAEF,OAAO,MAAMK,eAAe,CAACL;IAC3B,MAAME,SAAUF,KAAyCE;IACzD,IAAI,OAAOA,WAAW,YAAY,CAACA,OAAOI,UAAU,CAACV,SAAS;QAC5D,OAAO;IACT;IACA,IAAI;QACF,MAAMW,OAAOJ,KAAKK,KAAK,CAACN,OAAOO,KAAK,CAACb,OAAOc,MAAM;QAClD,IAAIpB,YAAYiB,OAAO;YACrB,OAAOA;QACT;IACF,EAAE,OAAM;IACN,SAAS;IACX;IACA,OAAO;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/fs-router.ts"],"sourcesContent":["const IGNORED_PATH_PARTS = new Set(['_components', '_hooks']);\n\n/** Ignore paths like `_components` and `_hooks` in pages dir */\nexport const isIgnoredPath = (paths: string[]) =>\n paths.some((p) => IGNORED_PATH_PARTS.has(p));\n"],"names":["IGNORED_PATH_PARTS","Set","isIgnoredPath","paths","some","p","has"],"mappings":"AAAA,MAAMA,qBAAqB,IAAIC,IAAI;IAAC;IAAe;CAAS;
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/fs-router.ts"],"sourcesContent":["const IGNORED_PATH_PARTS = new Set(['_actions', '_components', '_hooks']);\n\n/** Ignore paths like `_components` and `_hooks` in pages dir */\nexport const isIgnoredPath = (paths: string[]) =>\n paths.some((p) => IGNORED_PATH_PARTS.has(p));\n"],"names":["IGNORED_PATH_PARTS","Set","isIgnoredPath","paths","some","p","has"],"mappings":"AAAA,MAAMA,qBAAqB,IAAIC,IAAI;IAAC;IAAY;IAAe;CAAS;AAExE,8DAA8D,GAC9D,OAAO,MAAMC,gBAAgB,CAACC,QAC5BA,MAAMC,IAAI,CAAC,CAACC,IAAML,mBAAmBM,GAAG,CAACD,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveRedirectLocation: (location: string, requestUrl: string, basePath: string) => string | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { addBase } from './path.js';
|
|
2
|
+
const hasControlCharacter = (value)=>[
|
|
3
|
+
...value
|
|
4
|
+
].some((char)=>char < ' ' || char === '\u007f');
|
|
5
|
+
const getLocationType = (location)=>{
|
|
6
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(location)) {
|
|
7
|
+
return 'absolute';
|
|
8
|
+
}
|
|
9
|
+
if (location.startsWith('//')) {
|
|
10
|
+
return 'authority';
|
|
11
|
+
}
|
|
12
|
+
return location.startsWith('/') ? 'appPath' : 'relative';
|
|
13
|
+
};
|
|
14
|
+
export const resolveRedirectLocation = (location, requestUrl, basePath)=>{
|
|
15
|
+
// a header strips these, so classify what will actually be sent
|
|
16
|
+
location = location.trim();
|
|
17
|
+
const locationType = getLocationType(location);
|
|
18
|
+
if (locationType === 'relative') {
|
|
19
|
+
return hasControlCharacter(location) ? undefined : location;
|
|
20
|
+
}
|
|
21
|
+
const request = new URL(requestUrl);
|
|
22
|
+
let target;
|
|
23
|
+
try {
|
|
24
|
+
target = new URL(location, request);
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
if (target.protocol !== 'http:' && target.protocol !== 'https:') {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
target.username = '';
|
|
32
|
+
target.password = '';
|
|
33
|
+
const path = target.pathname + target.search + target.hash;
|
|
34
|
+
if (target.host !== request.host) {
|
|
35
|
+
return locationType === 'absolute' ? target.href : '//' + target.host + path;
|
|
36
|
+
}
|
|
37
|
+
// requestUrl takes its scheme from the socket, so http from there is no
|
|
38
|
+
// evidence that the browser is on http
|
|
39
|
+
if (locationType === 'absolute' && target.protocol === 'https:') {
|
|
40
|
+
return target.href;
|
|
41
|
+
}
|
|
42
|
+
return locationType === 'appPath' ? addBase(path, basePath) : path;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/redirect.ts"],"sourcesContent":["import { addBase } from './path.js';\n\nconst hasControlCharacter = (value: string) =>\n [...value].some((char) => char < ' ' || char === '\\u007f');\n\nconst getLocationType = (location: string) => {\n if (/^[a-z][a-z\\d+.-]*:/i.test(location)) {\n return 'absolute' as const;\n }\n if (location.startsWith('//')) {\n return 'authority' as const;\n }\n return location.startsWith('/')\n ? ('appPath' as const)\n : ('relative' as const);\n};\n\nexport const resolveRedirectLocation = (\n location: string,\n requestUrl: string,\n basePath: string,\n): string | undefined => {\n // a header strips these, so classify what will actually be sent\n location = location.trim();\n const locationType = getLocationType(location);\n if (locationType === 'relative') {\n return hasControlCharacter(location) ? undefined : location;\n }\n const request = new URL(requestUrl);\n let target: URL;\n try {\n target = new URL(location, request);\n } catch {\n return undefined;\n }\n if (target.protocol !== 'http:' && target.protocol !== 'https:') {\n return undefined;\n }\n target.username = '';\n target.password = '';\n const path = target.pathname + target.search + target.hash;\n if (target.host !== request.host) {\n return locationType === 'absolute'\n ? target.href\n : '//' + target.host + path;\n }\n // requestUrl takes its scheme from the socket, so http from there is no\n // evidence that the browser is on http\n if (locationType === 'absolute' && target.protocol === 'https:') {\n return target.href;\n }\n return locationType === 'appPath' ? addBase(path, basePath) : path;\n};\n"],"names":["addBase","hasControlCharacter","value","some","char","getLocationType","location","test","startsWith","resolveRedirectLocation","requestUrl","basePath","trim","locationType","undefined","request","URL","target","protocol","username","password","path","pathname","search","hash","host","href"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AAEpC,MAAMC,sBAAsB,CAACC,QAC3B;WAAIA;KAAM,CAACC,IAAI,CAAC,CAACC,OAASA,OAAO,OAAOA,SAAS;AAEnD,MAAMC,kBAAkB,CAACC;IACvB,IAAI,sBAAsBC,IAAI,CAACD,WAAW;QACxC,OAAO;IACT;IACA,IAAIA,SAASE,UAAU,CAAC,OAAO;QAC7B,OAAO;IACT;IACA,OAAOF,SAASE,UAAU,CAAC,OACtB,YACA;AACP;AAEA,OAAO,MAAMC,0BAA0B,CACrCH,UACAI,YACAC;IAEA,gEAAgE;IAChEL,WAAWA,SAASM,IAAI;IACxB,MAAMC,eAAeR,gBAAgBC;IACrC,IAAIO,iBAAiB,YAAY;QAC/B,OAAOZ,oBAAoBK,YAAYQ,YAAYR;IACrD;IACA,MAAMS,UAAU,IAAIC,IAAIN;IACxB,IAAIO;IACJ,IAAI;QACFA,SAAS,IAAID,IAAIV,UAAUS;IAC7B,EAAE,OAAM;QACN,OAAOD;IACT;IACA,IAAIG,OAAOC,QAAQ,KAAK,WAAWD,OAAOC,QAAQ,KAAK,UAAU;QAC/D,OAAOJ;IACT;IACAG,OAAOE,QAAQ,GAAG;IAClBF,OAAOG,QAAQ,GAAG;IAClB,MAAMC,OAAOJ,OAAOK,QAAQ,GAAGL,OAAOM,MAAM,GAAGN,OAAOO,IAAI;IAC1D,IAAIP,OAAOQ,IAAI,KAAKV,QAAQU,IAAI,EAAE;QAChC,OAAOZ,iBAAiB,aACpBI,OAAOS,IAAI,GACX,OAAOT,OAAOQ,IAAI,GAAGJ;IAC3B;IACA,wEAAwE;IACxE,uCAAuC;IACvC,IAAIR,iBAAiB,cAAcI,OAAOC,QAAQ,KAAK,UAAU;QAC/D,OAAOD,OAAOS,IAAI;IACpB;IACA,OAAOb,iBAAiB,YAAYb,QAAQqB,MAAMV,YAAYU;AAChE,EAAE"}
|
package/dist/lib/utils/render.js
CHANGED
|
@@ -26,6 +26,9 @@ export function createRenderUtils(temporaryReferences, renderToReadableStream, l
|
|
|
26
26
|
if (options && 'value' in options) {
|
|
27
27
|
data._value = options.value;
|
|
28
28
|
}
|
|
29
|
+
if (options?.documentLocation) {
|
|
30
|
+
data._location = options.documentLocation;
|
|
31
|
+
}
|
|
29
32
|
if (options?.etags) {
|
|
30
33
|
for (const [slotId, etag] of Object.entries(options.etags)){
|
|
31
34
|
data[ETAG_ID_PREFIX + slotId] = etag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/render.ts"],"sourcesContent":["import type { Unstable_RenderHtml, Unstable_RenderRsc } from '../types.js';\nimport { ETAG_ID_PREFIX } from './etags.js';\nimport { sanitizeLog } from './log.js';\n\nconst validateRscElementIds = (elements: Record<string, unknown>) => {\n for (const id of Object.keys(elements)) {\n if (id.startsWith('_')) {\n throw new Error(\n `RSC element IDs starting with \"_\" are reserved for Waku internals: ${id}`,\n );\n }\n }\n};\n\nexport function createRenderUtils(\n temporaryReferences: unknown,\n renderToReadableStream: (\n data: unknown,\n options?: object,\n extraOptions?: object,\n ) => ReadableStream,\n loadSsrEntryModule: () => Promise<\n typeof import('../vite-entries/entry.ssr.js')\n >,\n buildId: string,\n debugChannel?: { readable?: ReadableStream; writable?: WritableStream },\n debugId?: string,\n): {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n} {\n const onError = (e: unknown) => {\n if (\n e &&\n typeof e === 'object' &&\n 'digest' in e &&\n typeof e.digest === 'string'\n ) {\n return e.digest;\n }\n console.error('Error during rendering:', sanitizeLog(e));\n };\n\n return {\n async renderRsc(elements, options) {\n validateRscElementIds(elements);\n const data: Record<string, unknown> = buildId\n ? { ...elements, _buildId: buildId }\n : { ...elements };\n if (options && 'value' in options) {\n data._value = options.value;\n }\n if (options?.etags) {\n for (const [slotId, etag] of Object.entries(options.etags)) {\n data[ETAG_ID_PREFIX + slotId] = etag;\n }\n }\n return renderToReadableStream(\n data,\n {\n temporaryReferences,\n onError,\n debugChannel,\n },\n {\n onClientReference(metadata: {\n id: string;\n name: string;\n deps: { js: string[]; css: string[] };\n }) {\n options?.unstable_clientModuleCallback?.(metadata.deps.js);\n },\n },\n );\n },\n async renderHtml(elementsStream, html, options) {\n const { INTERNAL_renderHtmlStream: renderHtmlStream } =\n await loadSsrEntryModule();\n\n const rscHtmlStream = renderToReadableStream(html, {\n onError,\n });\n const htmlResult = await renderHtmlStream(elementsStream, rscHtmlStream, {\n rscPath: options.rscPath,\n formState: options.formState as never,\n nonce: options.nonce,\n extraScriptContent: options.unstable_extraScriptContent,\n debugId,\n });\n return new Response(htmlResult.stream, {\n status: htmlResult.status || options.status || 200,\n headers: { 'content-type': 'text/html; charset=utf-8' },\n });\n },\n };\n}\n"],"names":["ETAG_ID_PREFIX","sanitizeLog","validateRscElementIds","elements","id","Object","keys","startsWith","Error","createRenderUtils","temporaryReferences","renderToReadableStream","loadSsrEntryModule","buildId","debugChannel","debugId","onError","e","digest","console","error","renderRsc","options","data","_buildId","_value","value","etags","slotId","etag","entries","onClientReference","metadata","unstable_clientModuleCallback","deps","js","renderHtml","elementsStream","html","INTERNAL_renderHtmlStream","renderHtmlStream","rscHtmlStream","htmlResult","rscPath","formState","nonce","extraScriptContent","unstable_extraScriptContent","Response","stream","status","headers"],"mappings":"AACA,SAASA,cAAc,QAAQ,aAAa;AAC5C,SAASC,WAAW,QAAQ,WAAW;AAEvC,MAAMC,wBAAwB,CAACC;IAC7B,KAAK,MAAMC,MAAMC,OAAOC,IAAI,CAACH,UAAW;QACtC,IAAIC,GAAGG,UAAU,CAAC,MAAM;YACtB,MAAM,IAAIC,MACR,CAAC,mEAAmE,EAAEJ,IAAI;QAE9E;IACF;AACF;AAEA,OAAO,SAASK,kBACdC,mBAA4B,EAC5BC,sBAImB,EACnBC,kBAEC,EACDC,OAAe,EACfC,YAAuE,EACvEC,OAAgB;IAKhB,MAAMC,UAAU,CAACC;QACf,IACEA,KACA,OAAOA,MAAM,YACb,YAAYA,KACZ,OAAOA,EAAEC,MAAM,KAAK,UACpB;YACA,OAAOD,EAAEC,MAAM;QACjB;QACAC,QAAQC,KAAK,CAAC,2BAA2BnB,YAAYgB;IACvD;IAEA,OAAO;QACL,MAAMI,WAAUlB,QAAQ,EAAEmB,OAAO;YAC/BpB,sBAAsBC;YACtB,MAAMoB,OAAgCV,UAClC;gBAAE,GAAGV,QAAQ;gBAAEqB,UAAUX;YAAQ,IACjC;gBAAE,GAAGV,QAAQ;YAAC;YAClB,IAAImB,WAAW,WAAWA,SAAS;gBACjCC,KAAKE,MAAM,GAAGH,QAAQI,KAAK;YAC7B;YACA,IAAIJ,SAASK,OAAO;gBAClB,KAAK,MAAM,CAACC,QAAQC,KAAK,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/render.ts"],"sourcesContent":["import type { Unstable_RenderHtml, Unstable_RenderRsc } from '../types.js';\nimport { ETAG_ID_PREFIX } from './etags.js';\nimport { sanitizeLog } from './log.js';\n\nconst validateRscElementIds = (elements: Record<string, unknown>) => {\n for (const id of Object.keys(elements)) {\n if (id.startsWith('_')) {\n throw new Error(\n `RSC element IDs starting with \"_\" are reserved for Waku internals: ${id}`,\n );\n }\n }\n};\n\nexport function createRenderUtils(\n temporaryReferences: unknown,\n renderToReadableStream: (\n data: unknown,\n options?: object,\n extraOptions?: object,\n ) => ReadableStream,\n loadSsrEntryModule: () => Promise<\n typeof import('../vite-entries/entry.ssr.js')\n >,\n buildId: string,\n debugChannel?: { readable?: ReadableStream; writable?: WritableStream },\n debugId?: string,\n): {\n renderRsc: Unstable_RenderRsc;\n renderHtml: Unstable_RenderHtml;\n} {\n const onError = (e: unknown) => {\n if (\n e &&\n typeof e === 'object' &&\n 'digest' in e &&\n typeof e.digest === 'string'\n ) {\n return e.digest;\n }\n console.error('Error during rendering:', sanitizeLog(e));\n };\n\n return {\n async renderRsc(elements, options) {\n validateRscElementIds(elements);\n const data: Record<string, unknown> = buildId\n ? { ...elements, _buildId: buildId }\n : { ...elements };\n if (options && 'value' in options) {\n data._value = options.value;\n }\n if (options?.documentLocation) {\n data._location = options.documentLocation;\n }\n if (options?.etags) {\n for (const [slotId, etag] of Object.entries(options.etags)) {\n data[ETAG_ID_PREFIX + slotId] = etag;\n }\n }\n return renderToReadableStream(\n data,\n {\n temporaryReferences,\n onError,\n debugChannel,\n },\n {\n onClientReference(metadata: {\n id: string;\n name: string;\n deps: { js: string[]; css: string[] };\n }) {\n options?.unstable_clientModuleCallback?.(metadata.deps.js);\n },\n },\n );\n },\n async renderHtml(elementsStream, html, options) {\n const { INTERNAL_renderHtmlStream: renderHtmlStream } =\n await loadSsrEntryModule();\n\n const rscHtmlStream = renderToReadableStream(html, {\n onError,\n });\n const htmlResult = await renderHtmlStream(elementsStream, rscHtmlStream, {\n rscPath: options.rscPath,\n formState: options.formState as never,\n nonce: options.nonce,\n extraScriptContent: options.unstable_extraScriptContent,\n debugId,\n });\n return new Response(htmlResult.stream, {\n status: htmlResult.status || options.status || 200,\n headers: { 'content-type': 'text/html; charset=utf-8' },\n });\n },\n };\n}\n"],"names":["ETAG_ID_PREFIX","sanitizeLog","validateRscElementIds","elements","id","Object","keys","startsWith","Error","createRenderUtils","temporaryReferences","renderToReadableStream","loadSsrEntryModule","buildId","debugChannel","debugId","onError","e","digest","console","error","renderRsc","options","data","_buildId","_value","value","documentLocation","_location","etags","slotId","etag","entries","onClientReference","metadata","unstable_clientModuleCallback","deps","js","renderHtml","elementsStream","html","INTERNAL_renderHtmlStream","renderHtmlStream","rscHtmlStream","htmlResult","rscPath","formState","nonce","extraScriptContent","unstable_extraScriptContent","Response","stream","status","headers"],"mappings":"AACA,SAASA,cAAc,QAAQ,aAAa;AAC5C,SAASC,WAAW,QAAQ,WAAW;AAEvC,MAAMC,wBAAwB,CAACC;IAC7B,KAAK,MAAMC,MAAMC,OAAOC,IAAI,CAACH,UAAW;QACtC,IAAIC,GAAGG,UAAU,CAAC,MAAM;YACtB,MAAM,IAAIC,MACR,CAAC,mEAAmE,EAAEJ,IAAI;QAE9E;IACF;AACF;AAEA,OAAO,SAASK,kBACdC,mBAA4B,EAC5BC,sBAImB,EACnBC,kBAEC,EACDC,OAAe,EACfC,YAAuE,EACvEC,OAAgB;IAKhB,MAAMC,UAAU,CAACC;QACf,IACEA,KACA,OAAOA,MAAM,YACb,YAAYA,KACZ,OAAOA,EAAEC,MA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BAC/CC,SAAS;oBAAE,gBAAgB;gBAA2B;YACxD;QACF;IACF;AACF"}
|
package/dist/lib/utils/ssr.d.ts
CHANGED
package/dist/lib/utils/ssr.js
CHANGED
|
@@ -1,9 +1,70 @@
|
|
|
1
|
+
import { DEV_BUILD_ID } from '../constants.js';
|
|
1
2
|
import { createInitialRscEntryCode } from './initial-rsc.js';
|
|
3
|
+
function getRecoveryBuildId() {
|
|
4
|
+
const buildId = import.meta.env?.WAKU_BUILD_ID;
|
|
5
|
+
if (!buildId || buildId === DEV_BUILD_ID) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return buildId;
|
|
9
|
+
}
|
|
10
|
+
// https://github.com/wakujs/waku/issues/2238
|
|
11
|
+
// Must run before the bootstrap import. Defer reload until DOMContentLoaded
|
|
12
|
+
// (streaming HTML is unreliable). Persist a build-id marker so a broken build
|
|
13
|
+
// cannot loop forever.
|
|
14
|
+
function getVersionSkewRecoveryCode() {
|
|
15
|
+
const buildId = getRecoveryBuildId();
|
|
16
|
+
if (!buildId) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
return `
|
|
20
|
+
window.addEventListener('vite:preloadError', function (e) {
|
|
21
|
+
var key = 'waku:preload-error-build-id';
|
|
22
|
+
var canRetry = false;
|
|
23
|
+
try {
|
|
24
|
+
canRetry = sessionStorage.getItem(key) !== ${JSON.stringify(buildId)};
|
|
25
|
+
sessionStorage.setItem(key, ${JSON.stringify(buildId)});
|
|
26
|
+
} catch {
|
|
27
|
+
canRetry = false;
|
|
28
|
+
}
|
|
29
|
+
if (!canRetry) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
var reload = function () {
|
|
34
|
+
window.location.reload();
|
|
35
|
+
};
|
|
36
|
+
if (document.readyState === 'loading') {
|
|
37
|
+
document.addEventListener('DOMContentLoaded', reload);
|
|
38
|
+
} else {
|
|
39
|
+
reload();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
// Bare import() does not fire vite:preloadError; mirror __vitePreload so the
|
|
45
|
+
// recovery listener above runs. https://github.com/wakujs/waku/issues/2238
|
|
46
|
+
export function createBootstrapScriptContent(entryUrl) {
|
|
47
|
+
const entryImport = `import(${JSON.stringify(entryUrl)})`;
|
|
48
|
+
if (!getRecoveryBuildId()) {
|
|
49
|
+
return `${entryImport};`;
|
|
50
|
+
}
|
|
51
|
+
return `${entryImport}.catch((err) => {
|
|
52
|
+
var e = new Event('vite:preloadError', { cancelable: true });
|
|
53
|
+
e.payload = err;
|
|
54
|
+
window.dispatchEvent(e);
|
|
55
|
+
if (!e.defaultPrevented) {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
});`;
|
|
59
|
+
}
|
|
2
60
|
export function getBootstrapPreamble(options) {
|
|
3
61
|
return `
|
|
62
|
+
${getVersionSkewRecoveryCode()}
|
|
4
63
|
${options.hydrate ? 'globalThis.__WAKU_HYDRATE__ = true;' : ''}
|
|
64
|
+
${options.initialRsc ? `
|
|
5
65
|
globalThis.__WAKU_INITIAL_RSC__ = ${createInitialRscEntryCode(options.debugId)};
|
|
6
|
-
|
|
66
|
+
` : ''}
|
|
67
|
+
`.split('\n').map((line)=>line.trim()).filter(Boolean).join('\n');
|
|
7
68
|
}
|
|
8
69
|
|
|
9
70
|
//# sourceMappingURL=ssr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/ssr.ts"],"sourcesContent":["import { createInitialRscEntryCode } from './initial-rsc.js';\n\nexport function getBootstrapPreamble(options: {\n hydrate: boolean;\n debugId?: string | undefined;\n}) {\n return `\n ${options.hydrate ? 'globalThis.__WAKU_HYDRATE__ = true;' : ''}\n globalThis.__WAKU_INITIAL_RSC__ = ${createInitialRscEntryCode(\n options.debugId,\n )};\n
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/ssr.ts"],"sourcesContent":["import { DEV_BUILD_ID } from '../constants.js';\nimport { createInitialRscEntryCode } from './initial-rsc.js';\n\nfunction getRecoveryBuildId(): string | undefined {\n const buildId = import.meta.env?.WAKU_BUILD_ID;\n if (!buildId || buildId === DEV_BUILD_ID) {\n return undefined;\n }\n return buildId;\n}\n\n// https://github.com/wakujs/waku/issues/2238\n// Must run before the bootstrap import. Defer reload until DOMContentLoaded\n// (streaming HTML is unreliable). Persist a build-id marker so a broken build\n// cannot loop forever.\nfunction getVersionSkewRecoveryCode(): string {\n const buildId = getRecoveryBuildId();\n if (!buildId) {\n return '';\n }\n return `\n window.addEventListener('vite:preloadError', function (e) {\n var key = 'waku:preload-error-build-id';\n var canRetry = false;\n try {\n canRetry = sessionStorage.getItem(key) !== ${JSON.stringify(buildId)};\n sessionStorage.setItem(key, ${JSON.stringify(buildId)});\n } catch {\n canRetry = false;\n }\n if (!canRetry) {\n return;\n }\n e.preventDefault();\n var reload = function () {\n window.location.reload();\n };\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', reload);\n } else {\n reload();\n }\n });\n `;\n}\n\n// Bare import() does not fire vite:preloadError; mirror __vitePreload so the\n// recovery listener above runs. https://github.com/wakujs/waku/issues/2238\nexport function createBootstrapScriptContent(entryUrl: string): string {\n const entryImport = `import(${JSON.stringify(entryUrl)})`;\n if (!getRecoveryBuildId()) {\n return `${entryImport};`;\n }\n return `${entryImport}.catch((err) => {\n var e = new Event('vite:preloadError', { cancelable: true });\n e.payload = err;\n window.dispatchEvent(e);\n if (!e.defaultPrevented) {\n throw err;\n }\n });`;\n}\n\nexport function getBootstrapPreamble(options: {\n hydrate: boolean;\n initialRsc: boolean;\n debugId?: string | undefined;\n}) {\n return `\n ${getVersionSkewRecoveryCode()}\n ${options.hydrate ? 'globalThis.__WAKU_HYDRATE__ = true;' : ''}\n ${\n options.initialRsc\n ? `\n globalThis.__WAKU_INITIAL_RSC__ = ${createInitialRscEntryCode(\n options.debugId,\n )};\n `\n : ''\n }\n `\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n .join('\\n');\n}\n"],"names":["DEV_BUILD_ID","createInitialRscEntryCode","getRecoveryBuildId","buildId","env","WAKU_BUILD_ID","undefined","getVersionSkewRecoveryCode","JSON","stringify","createBootstrapScriptContent","entryUrl","entryImport","getBootstrapPreamble","options","hydrate","initialRsc","debugId","split","map","line","trim","filter","Boolean","join"],"mappings":"AAAA,SAASA,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,yBAAyB,QAAQ,mBAAmB;AAE7D,SAASC;IACP,MAAMC,UAAU,YAAYC,GAAG,EAAEC;IACjC,IAAI,CAACF,WAAWA,YAAYH,cAAc;QACxC,OAAOM;IACT;IACA,OAAOH;AACT;AAEA,6CAA6C;AAC7C,4EAA4E;AAC5E,8EAA8E;AAC9E,uBAAuB;AACvB,SAASI;IACP,MAAMJ,UAAUD;IAChB,IAAI,CAACC,SAAS;QACZ,OAAO;IACT;IACA,OAAO,CAAC;;;;;mDAKyC,EAAEK,KAAKC,SAAS,CAACN,SAAS;oCACzC,EAAEK,KAAKC,SAAS,CAACN,SAAS;;;;;;;;;;;;;;;;;EAiB5D,CAAC;AACH;AAEA,6EAA6E;AAC7E,2EAA2E;AAC3E,OAAO,SAASO,6BAA6BC,QAAgB;IAC3D,MAAMC,cAAc,CAAC,OAAO,EAAEJ,KAAKC,SAAS,CAACE,UAAU,CAAC,CAAC;IACzD,IAAI,CAACT,sBAAsB;QACzB,OAAO,GAAGU,YAAY,CAAC,CAAC;IAC1B;IACA,OAAO,GAAGA,YAAY;;;;;;;KAOnB,CAAC;AACN;AAEA,OAAO,SAASC,qBAAqBC,OAIpC;IACC,OAAO,CAAC;IACN,EAAEP,6BAA6B;IAC/B,EAAEO,QAAQC,OAAO,GAAG,wCAAwC,GAAG;IAC/D,EACED,QAAQE,UAAU,GACd,CAAC;sCAC2B,EAAEf,0BAClCa,QAAQG,OAAO,EACf;IACF,CAAC,GACK,GACL;EACH,CAAC,CACEC,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,MAAM,CAACC,SACPC,IAAI,CAAC;AACV"}
|
|
@@ -7,11 +7,6 @@ if (import.meta.hot) {
|
|
|
7
7
|
globalThis.__WAKU_RSC_RELOAD_LISTENERS__?.forEach((l)=>l());
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
if (import.meta.env.WAKU_BUILD_ID) {
|
|
11
|
-
window.addEventListener('vite:preloadError', ()=>{
|
|
12
|
-
window.location.reload();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
10
|
import 'virtual:vite-rsc-waku/client-entry';
|
|
16
11
|
|
|
17
12
|
//# sourceMappingURL=entry.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/vite-entries/entry.browser.tsx"],"sourcesContent":["import { setServerCallback } from '@vitejs/plugin-rsc/browser';\nimport { unstable_callServerRsc } from '../../minimal/client.js';\nsetServerCallback(unstable_callServerRsc);\n\nif (import.meta.hot) {\n import.meta.hot.on('rsc:update', (e) => {\n console.log('[rsc:update]', e);\n globalThis.__WAKU_RSC_RELOAD_LISTENERS__?.forEach((l) => l());\n });\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/vite-entries/entry.browser.tsx"],"sourcesContent":["import { setServerCallback } from '@vitejs/plugin-rsc/browser';\nimport { unstable_callServerRsc } from '../../minimal/client.js';\nsetServerCallback(unstable_callServerRsc);\n\nif (import.meta.hot) {\n import.meta.hot.on('rsc:update', (e) => {\n console.log('[rsc:update]', e);\n globalThis.__WAKU_RSC_RELOAD_LISTENERS__?.forEach((l) => l());\n });\n}\n\nimport 'virtual:vite-rsc-waku/client-entry';\n"],"names":["setServerCallback","unstable_callServerRsc","hot","on","e","console","log","globalThis","__WAKU_RSC_RELOAD_LISTENERS__","forEach","l"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,sBAAsB,QAAQ,0BAA0B;AACjED,kBAAkBC;AAElB,IAAI,YAAYC,GAAG,EAAE;IACnB,YAAYA,GAAG,CAACC,EAAE,CAAC,cAAc,CAACC;QAChCC,QAAQC,GAAG,CAAC,gBAAgBF;QAC5BG,WAAWC,6BAA6B,EAAEC,QAAQ,CAACC,IAAMA;IAC3D;AACF;AAEA,OAAO,qCAAqC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import serverEntry from 'virtual:vite-rsc-waku/server-entry';
|
|
2
|
-
import {
|
|
2
|
+
import { unstable_setAllEnv } from '../env.js';
|
|
3
3
|
import { joinPath } from '../utils/path.js';
|
|
4
4
|
const DO_NOT_BUNDLE = '';
|
|
5
5
|
async function resolveModuleId(moduleId, rootDir) {
|
|
@@ -17,7 +17,7 @@ async function resolveModuleId(moduleId, rootDir) {
|
|
|
17
17
|
return pathToFileURL(resolved).href;
|
|
18
18
|
}
|
|
19
19
|
export async function INTERNAL_runBuild({ rootDir, emitFile }) {
|
|
20
|
-
|
|
20
|
+
unstable_setAllEnv(process.env);
|
|
21
21
|
const prunableFiles = new Set();
|
|
22
22
|
let build = serverEntry.build;
|
|
23
23
|
for (const enhancer of serverEntry.buildEnhancers || []){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/vite-entries/entry.build.ts"],"sourcesContent":["import serverEntry from 'virtual:vite-rsc-waku/server-entry';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/vite-entries/entry.build.ts"],"sourcesContent":["import serverEntry from 'virtual:vite-rsc-waku/server-entry';\nimport { unstable_setAllEnv } from '../env.js';\nimport type { Unstable_EmitFile } from '../types.js';\nimport { joinPath } from '../utils/path.js';\n\nconst DO_NOT_BUNDLE = '';\n\nasync function resolveModuleId(moduleId: string, rootDir: string) {\n if (moduleId.startsWith('file://')) {\n return moduleId;\n }\n const { pathToFileURL } = (await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'node:url'\n )) as typeof import('node:url');\n if (moduleId.startsWith('/')) {\n // treat as project-root relative (not filesystem root)\n return pathToFileURL(joinPath(rootDir, moduleId.slice(1))).href;\n }\n const { createRequire } = (await import(\n /* @vite-ignore */ DO_NOT_BUNDLE + 'node:module'\n )) as typeof import('node:module');\n const require = createRequire(joinPath(rootDir, 'DUMMY.js'));\n const resolved = require.resolve(moduleId);\n return pathToFileURL(resolved).href;\n}\n\nexport async function INTERNAL_runBuild({\n rootDir,\n emitFile,\n}: {\n rootDir: string;\n emitFile: Unstable_EmitFile;\n}) {\n unstable_setAllEnv(process.env);\n const prunableFiles = new Set<string>();\n let build = serverEntry.build;\n for (const enhancer of serverEntry.buildEnhancers || []) {\n const moduleId = await resolveModuleId(enhancer, rootDir);\n const mod = await import(moduleId);\n build = await mod.default(build);\n }\n await build(\n {\n emitFile,\n unstable_registerPrunableFile: (srcPath) => {\n prunableFiles.add(srcPath);\n },\n },\n serverEntry.buildOptions || {},\n );\n return { prunableFiles: Array.from(prunableFiles) };\n}\n"],"names":["serverEntry","unstable_setAllEnv","joinPath","DO_NOT_BUNDLE","resolveModuleId","moduleId","rootDir","startsWith","pathToFileURL","slice","href","createRequire","require","resolved","resolve","INTERNAL_runBuild","emitFile","process","env","prunableFiles","Set","build","enhancer","buildEnhancers","mod","default","unstable_registerPrunableFile","srcPath","add","buildOptions","Array","from"],"mappings":"AAAA,OAAOA,iBAAiB,qCAAqC;AAC7D,SAASC,kBAAkB,QAAQ,YAAY;AAE/C,SAASC,QAAQ,QAAQ,mBAAmB;AAE5C,MAAMC,gBAAgB;AAEtB,eAAeC,gBAAgBC,QAAgB,EAAEC,OAAe;IAC9D,IAAID,SAASE,UAAU,CAAC,YAAY;QAClC,OAAOF;IACT;IACA,MAAM,EAAEG,aAAa,EAAE,GAAI,MAAM,MAAM,CACrC,gBAAgB,GAAGL,gBAAgB;IAErC,IAAIE,SAASE,UAAU,CAAC,MAAM;QAC5B,uDAAuD;QACvD,OAAOC,cAAcN,SAASI,SAASD,SAASI,KAAK,CAAC,KAAKC,IAAI;IACjE;IACA,MAAM,EAAEC,aAAa,EAAE,GAAI,MAAM,MAAM,CACrC,gBAAgB,GAAGR,gBAAgB;IAErC,MAAMS,UAAUD,cAAcT,SAASI,SAAS;IAChD,MAAMO,WAAWD,QAAQE,OAAO,CAACT;IACjC,OAAOG,cAAcK,UAAUH,IAAI;AACrC;AAEA,OAAO,eAAeK,kBAAkB,EACtCT,OAAO,EACPU,QAAQ,EAIT;IACCf,mBAAmBgB,QAAQC,GAAG;IAC9B,MAAMC,gBAAgB,IAAIC;IAC1B,IAAIC,QAAQrB,YAAYqB,KAAK;IAC7B,KAAK,MAAMC,YAAYtB,YAAYuB,cAAc,IAAI,EAAE,CAAE;QACvD,MAAMlB,WAAW,MAAMD,gBAAgBkB,UAAUhB;QACjD,MAAMkB,MAAM,MAAM,MAAM,CAACnB;QACzBgB,QAAQ,MAAMG,IAAIC,OAAO,CAACJ;IAC5B;IACA,MAAMA,MACJ;QACEL;QACAU,+BAA+B,CAACC;YAC9BR,cAAcS,GAAG,CAACD;QACpB;IACF,GACA3B,YAAY6B,YAAY,IAAI,CAAC;IAE/B,OAAO;QAAEV,eAAeW,MAAMC,IAAI,CAACZ;IAAe;AACpD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import serverEntry from 'virtual:vite-rsc-waku/server-entry';
|
|
2
|
-
import {
|
|
2
|
+
import { unstable_setAllEnv } from '../env.js';
|
|
3
3
|
export { serverEntry as unstable_serverEntry };
|
|
4
4
|
export async function INTERNAL_runFetch(env, req, ...args) {
|
|
5
|
-
|
|
5
|
+
unstable_setAllEnv(env);
|
|
6
6
|
return serverEntry.fetch(req, ...args);
|
|
7
7
|
}
|
|
8
8
|
export default serverEntry.defaultExport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/vite-entries/entry.server.tsx"],"sourcesContent":["import serverEntry from 'virtual:vite-rsc-waku/server-entry';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/vite-entries/entry.server.tsx"],"sourcesContent":["import serverEntry from 'virtual:vite-rsc-waku/server-entry';\nimport { unstable_setAllEnv } from '../env.js';\n\nexport { serverEntry as unstable_serverEntry };\n\nexport async function INTERNAL_runFetch(\n env: Readonly<Record<string, unknown>>,\n req: Request,\n ...args: any[]\n) {\n unstable_setAllEnv(env);\n return serverEntry.fetch(req, ...args);\n}\n\nexport default serverEntry.defaultExport;\n"],"names":["serverEntry","unstable_setAllEnv","unstable_serverEntry","INTERNAL_runFetch","env","req","args","fetch","defaultExport"],"mappings":"AAAA,OAAOA,iBAAiB,qCAAqC;AAC7D,SAASC,kBAAkB,QAAQ,YAAY;AAE/C,SAASD,eAAeE,oBAAoB,GAAG;AAE/C,OAAO,eAAeC,kBACpBC,GAAsC,EACtCC,GAAY,EACZ,GAAGC,IAAW;IAEdL,mBAAmBG;IACnB,OAAOJ,YAAYO,KAAK,CAACF,QAAQC;AACnC;AAEA,eAAeN,YAAYQ,aAAa,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { DEV_BUILD_ID } from '../constants.js';
|
|
2
3
|
const KEY = 'import.meta.env.WAKU_BUILD_ID';
|
|
3
4
|
export function buildIdPlugin() {
|
|
4
5
|
const buildId = randomBytes(6).toString('base64url');
|
|
@@ -10,7 +11,7 @@ export function buildIdPlugin() {
|
|
|
10
11
|
}
|
|
11
12
|
return {
|
|
12
13
|
define: {
|
|
13
|
-
[KEY]: JSON.stringify(env.command === 'serve' ?
|
|
14
|
+
[KEY]: JSON.stringify(env.command === 'serve' ? DEV_BUILD_ID : buildId)
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/vite-plugins/build-id.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport type { Plugin } from 'vite';\n\nconst KEY = 'import.meta.env.WAKU_BUILD_ID';\n\nexport function buildIdPlugin(): Plugin {\n const buildId = randomBytes(6).toString('base64url');\n return {\n name: 'waku:vite-plugins:build-id',\n config(merged, env) {\n if (merged.define && KEY in merged.define) {\n return;\n }\n return {\n define: {\n [KEY]: JSON.stringify(env.command === 'serve' ?
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/vite-plugins/build-id.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport type { Plugin } from 'vite';\nimport { DEV_BUILD_ID } from '../constants.js';\n\nconst KEY = 'import.meta.env.WAKU_BUILD_ID';\n\nexport function buildIdPlugin(): Plugin {\n const buildId = randomBytes(6).toString('base64url');\n return {\n name: 'waku:vite-plugins:build-id',\n config(merged, env) {\n if (merged.define && KEY in merged.define) {\n return;\n }\n return {\n define: {\n [KEY]: JSON.stringify(\n env.command === 'serve' ? DEV_BUILD_ID : buildId,\n ),\n },\n };\n },\n };\n}\n"],"names":["randomBytes","DEV_BUILD_ID","KEY","buildIdPlugin","buildId","toString","name","config","merged","env","define","JSON","stringify","command"],"mappings":"AAAA,SAASA,WAAW,QAAQ,cAAc;AAE1C,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,MAAMC,MAAM;AAEZ,OAAO,SAASC;IACd,MAAMC,UAAUJ,YAAY,GAAGK,QAAQ,CAAC;IACxC,OAAO;QACLC,MAAM;QACNC,QAAOC,MAAM,EAAEC,GAAG;YAChB,IAAID,OAAOE,MAAM,IAAIR,OAAOM,OAAOE,MAAM,EAAE;gBACzC;YACF;YACA,OAAO;gBACLA,QAAQ;oBACN,CAACR,IAAI,EAAES,KAAKC,SAAS,CACnBH,IAAII,OAAO,KAAK,UAAUZ,eAAeG;gBAE7C;YACF;QACF;IACF;AACF"}
|