waku 0.27.3 → 0.27.5

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 (82) hide show
  1. package/dist/adapters/aws-lambda-build-enhancer.d.ts +4 -0
  2. package/dist/adapters/{lib/aws-lambda-post-build.js → aws-lambda-build-enhancer.js} +8 -2
  3. package/dist/adapters/aws-lambda-build-enhancer.js.map +1 -0
  4. package/dist/adapters/aws-lambda.d.ts +0 -7
  5. package/dist/adapters/aws-lambda.js +4 -9
  6. package/dist/adapters/aws-lambda.js.map +1 -1
  7. package/dist/adapters/bun-build-enhancer.d.ts +4 -0
  8. package/dist/adapters/{lib/bun-post-build.js → bun-build-enhancer.js} +8 -2
  9. package/dist/adapters/bun-build-enhancer.js.map +1 -0
  10. package/dist/adapters/bun.d.ts +0 -7
  11. package/dist/adapters/bun.js +4 -9
  12. package/dist/adapters/bun.js.map +1 -1
  13. package/dist/adapters/cloudflare-build-enhancer.d.ts +4 -0
  14. package/dist/adapters/{lib/cloudflare-post-build.js → cloudflare-build-enhancer.js} +8 -2
  15. package/dist/adapters/cloudflare-build-enhancer.js.map +1 -0
  16. package/dist/adapters/cloudflare.d.ts +0 -7
  17. package/dist/adapters/cloudflare.js +4 -10
  18. package/dist/adapters/cloudflare.js.map +1 -1
  19. package/dist/adapters/deno-build-enhancer.d.ts +4 -0
  20. package/dist/adapters/{lib/deno-post-build.js → deno-build-enhancer.js} +8 -2
  21. package/dist/adapters/deno-build-enhancer.js.map +1 -0
  22. package/dist/adapters/deno.d.ts +0 -7
  23. package/dist/adapters/deno.js +4 -9
  24. package/dist/adapters/deno.js.map +1 -1
  25. package/dist/adapters/netlify-build-enhancer.d.ts +7 -0
  26. package/dist/adapters/{lib/netlify-post-build.js → netlify-build-enhancer.js} +8 -2
  27. package/dist/adapters/netlify-build-enhancer.js.map +1 -0
  28. package/dist/adapters/netlify.d.ts +0 -7
  29. package/dist/adapters/netlify.js +4 -10
  30. package/dist/adapters/netlify.js.map +1 -1
  31. package/dist/adapters/node-build-enhancer.d.ts +4 -0
  32. package/dist/adapters/{lib/node-post-build.js → node-build-enhancer.js} +8 -2
  33. package/dist/adapters/node-build-enhancer.js.map +1 -0
  34. package/dist/adapters/node.d.ts +0 -7
  35. package/dist/adapters/node.js +4 -9
  36. package/dist/adapters/node.js.map +1 -1
  37. package/dist/adapters/vercel-build-enhancer.d.ts +10 -0
  38. package/dist/adapters/{lib/vercel-post-build.js → vercel-build-enhancer.js} +8 -2
  39. package/dist/adapters/vercel-build-enhancer.js.map +1 -0
  40. package/dist/adapters/vercel.d.ts +0 -7
  41. package/dist/adapters/vercel.js +4 -10
  42. package/dist/adapters/vercel.js.map +1 -1
  43. package/dist/lib/types.d.ts +10 -5
  44. package/dist/lib/types.js.map +1 -1
  45. package/dist/lib/utils/path.js +5 -2
  46. package/dist/lib/utils/path.js.map +1 -1
  47. package/dist/lib/utils/request.d.ts +1 -2
  48. package/dist/lib/utils/request.js +8 -5
  49. package/dist/lib/utils/request.js.map +1 -1
  50. package/dist/lib/vite-entries/entry.build.js +22 -6
  51. package/dist/lib/vite-entries/entry.build.js.map +1 -1
  52. package/dist/lib/vite-plugins/allow-server.js +115 -170
  53. package/dist/lib/vite-plugins/allow-server.js.map +1 -1
  54. package/dist/lib/vite-plugins/fs-router-typegen.js +39 -21
  55. package/dist/lib/vite-plugins/fs-router-typegen.js.map +1 -1
  56. package/dist/lib/vite-rsc/handler.js +1 -1
  57. package/dist/lib/vite-rsc/handler.js.map +1 -1
  58. package/dist/lib/vite-rsc/plugin.js +1 -3
  59. package/dist/lib/vite-rsc/plugin.js.map +1 -1
  60. package/dist/minimal/server.d.ts +6 -2
  61. package/dist/router/create-pages.js +105 -116
  62. package/dist/router/create-pages.js.map +1 -1
  63. package/dist/router/define-router.js +7 -7
  64. package/dist/router/define-router.js.map +1 -1
  65. package/package.json +18 -17
  66. package/dist/adapters/lib/aws-lambda-post-build.d.ts +0 -3
  67. package/dist/adapters/lib/aws-lambda-post-build.js.map +0 -1
  68. package/dist/adapters/lib/bun-post-build.d.ts +0 -3
  69. package/dist/adapters/lib/bun-post-build.js.map +0 -1
  70. package/dist/adapters/lib/cloudflare-post-build.d.ts +0 -3
  71. package/dist/adapters/lib/cloudflare-post-build.js.map +0 -1
  72. package/dist/adapters/lib/deno-post-build.d.ts +0 -3
  73. package/dist/adapters/lib/deno-post-build.js.map +0 -1
  74. package/dist/adapters/lib/netlify-post-build.d.ts +0 -6
  75. package/dist/adapters/lib/netlify-post-build.js.map +0 -1
  76. package/dist/adapters/lib/node-post-build.d.ts +0 -3
  77. package/dist/adapters/lib/node-post-build.js.map +0 -1
  78. package/dist/adapters/lib/vercel-post-build.d.ts +0 -9
  79. package/dist/adapters/lib/vercel-post-build.js.map +0 -1
  80. package/dist/lib/vite-plugins/path-macro.d.ts +0 -2
  81. package/dist/lib/vite-plugins/path-macro.js +0 -54
  82. package/dist/lib/vite-plugins/path-macro.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ };
4
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir }) {
3
+ async function postBuild({ distDir }) {
4
4
  const SERVE_JS = 'serve-aws-lambda.js';
5
5
  const serveCode = `
6
6
  import { INTERNAL_runFetch } from './server/index.js';
@@ -16,5 +16,11 @@ export const handler = handle({
16
16
  type: 'module'
17
17
  }, null, 2));
18
18
  }
19
+ export default async function buildEnhancer(build) {
20
+ return async (emitFile, options)=>{
21
+ await build(emitFile, options);
22
+ await postBuild(options);
23
+ };
24
+ }
19
25
 
20
- //# sourceMappingURL=aws-lambda-post-build.js.map
26
+ //# sourceMappingURL=aws-lambda-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/aws-lambda-build-enhancer.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = { distDir: string };\n\nasync function postBuild({ distDir }: BuildOptions) {\n const SERVE_JS = 'serve-aws-lambda.js';\n const serveCode = `\nimport { INTERNAL_runFetch } from './server/index.js';\n\nconst handle = globalThis.__WAKU_AWS_LAMBDA_HANDLE__;\n\nexport const handler = handle({\n fetch: (req, ...args) => INTERNAL_runFetch(process.env, req, ...args),\n});\n`;\n writeFileSync(path.join(distDir, SERVE_JS), serveCode);\n writeFileSync(\n path.join(distDir, 'package.json'),\n JSON.stringify({ type: 'module' }, null, 2),\n );\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n"],"names":["writeFileSync","path","postBuild","distDir","SERVE_JS","serveCode","join","JSON","stringify","type","buildEnhancer","build","emitFile","options"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,OAAOC,UAAU,YAAY;AAI7B,eAAeC,UAAU,EAAEC,OAAO,EAAgB;IAChD,MAAMC,WAAW;IACjB,MAAMC,YAAY,CAAC;;;;;;;;AAQrB,CAAC;IACCL,cAAcC,KAAKK,IAAI,CAACH,SAASC,WAAWC;IAC5CL,cACEC,KAAKK,IAAI,CAACH,SAAS,iBACnBI,KAAKC,SAAS,CAAC;QAAEC,MAAM;IAAS,GAAG,MAAM;AAE7C;AAEA,eAAe,eAAeC,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMX,UAAUW;IAClB;AACF"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -3,10 +3,6 @@ import { serveStatic } from '@hono/node-server/serve-static';
3
3
  import { Hono } from 'hono';
4
4
  import * as honoAwsLambda from 'hono/aws-lambda';
5
5
  import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
6
- function joinPath(path1, path2) {
7
- const p = path.posix.join(path1, path2);
8
- return p.startsWith('/') ? p : './' + p;
9
- }
10
6
  const { DIST_PUBLIC } = constants;
11
7
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
12
8
  export default createServerEntryAdapter(({ processRequest, processBuild, config, isBuild, notFoundHtml }, options)=>{
@@ -31,17 +27,16 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
31
27
  app.use(rscMiddleware({
32
28
  processRequest
33
29
  }));
34
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/aws-lambda-post-build.js');
35
- const postBuildArg = {
30
+ const buildOptions = {
36
31
  distDir: config.distDir
37
32
  };
38
33
  globalThis.__WAKU_AWS_LAMBDA_HANDLE__ = options?.streaming ? honoAwsLambda.streamHandle : honoAwsLambda.handle;
39
34
  return {
40
35
  fetch: app.fetch,
41
36
  build: processBuild,
42
- postBuild: [
43
- postBuildScript,
44
- postBuildArg
37
+ buildOptions,
38
+ buildEnhancers: [
39
+ 'waku/adapters/aws-lambda-build-enhancer'
45
40
  ]
46
41
  };
47
42
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/aws-lambda.ts"],"sourcesContent":["import path from 'node:path';\nimport { serveStatic } from '@hono/node-server/serve-static';\nimport { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport * as honoAwsLambda from 'hono/aws-lambda';\nimport type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\n\ndeclare global {\n interface ImportMeta {\n glob: ImportGlobFunction;\n readonly __WAKU_ORIGINAL_PATH__: string;\n }\n}\n\nfunction joinPath(path1: string, path2: string) {\n const p = path.posix.join(path1, path2);\n return p.startsWith('/') ? p : './' + p;\n}\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, isBuild, notFoundHtml },\n options?: {\n streaming?: boolean;\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 (isBuild) {\n app.use(serveStatic({ root: path.join(config.distDir, DIST_PUBLIC) }));\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const postBuildScript = joinPath(\n import.meta.__WAKU_ORIGINAL_PATH__,\n '../lib/aws-lambda-post-build.js',\n );\n const postBuildArg: Parameters<\n typeof import('./lib/aws-lambda-post-build.js').default\n >[0] = {\n distDir: config.distDir,\n };\n (globalThis as any).__WAKU_AWS_LAMBDA_HANDLE__ = options?.streaming\n ? honoAwsLambda.streamHandle\n : honoAwsLambda.handle;\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["path","serveStatic","Hono","honoAwsLambda","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","path1","path2","p","posix","join","startsWith","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","isBuild","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","root","distDir","middlewareFn","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","globalThis","__WAKU_AWS_LAMBDA_HANDLE__","streaming","streamHandle","handle","fetch","build","postBuild"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,IAAI,QAAQ,OAAO;AAE5B,YAAYC,mBAAmB,kBAAkB;AAEjD,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AASxB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIb,KAAKc,KAAK,CAACC,IAAI,CAACJ,OAAOC;IACjC,OAAOC,EAAEG,UAAU,CAAC,OAAOH,IAAI,OAAOA;AACxC;AAEA,MAAM,EAAEI,WAAW,EAAE,GAAGZ;AACxB,MAAM,EAAEa,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGX;AAE/D,eAAeF,yBACb,CACE,EAAEc,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAE,EAC/DC;IAMA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAI3B;IAChB2B,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIT,SAAS;QACXK,IAAIK,GAAG,CAACjC,YAAY;YAAEkC,MAAMnC,KAAKe,IAAI,CAACQ,OAAOa,OAAO,EAAEnB;QAAa;IACrE;IACAY,IAAIK,GAAG,CAAChB;IACR,KAAK,MAAMmB,gBAAgBV,cAAe;QACxCE,IAAIK,GAAG,CAACG;IACV;IACAR,IAAIK,GAAG,CAACd,iBAAiBQ;IACzBC,IAAIK,GAAG,CAACf,cAAc;QAAEE;IAAe;IACvC,MAAMiB,kBAAkB5B,SACtB,YAAY6B,sBAAsB,EAClC;IAEF,MAAMC,eAEC;QACLJ,SAASb,OAAOa,OAAO;IACzB;IACCK,WAAmBC,0BAA0B,GAAGhB,SAASiB,YACtDxC,cAAcyC,YAAY,GAC1BzC,cAAc0C,MAAM;IACxB,OAAO;QACLC,OAAOjB,IAAIiB,KAAK;QAChBC,OAAOzB;QACP0B,WAAW;YAACV;YAAiBE;SAAa;IAC5C;AACF,GACA"}
1
+ {"version":3,"sources":["../../src/adapters/aws-lambda.ts"],"sourcesContent":["import path from 'node:path';\nimport { serveStatic } from '@hono/node-server/serve-static';\nimport { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport * as honoAwsLambda from 'hono/aws-lambda';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport type { BuildOptions } from './aws-lambda-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, isBuild, notFoundHtml },\n options?: {\n streaming?: boolean;\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 (isBuild) {\n app.use(serveStatic({ root: path.join(config.distDir, DIST_PUBLIC) }));\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n distDir: config.distDir,\n };\n (globalThis as any).__WAKU_AWS_LAMBDA_HANDLE__ = options?.streaming\n ? honoAwsLambda.streamHandle\n : honoAwsLambda.handle;\n return {\n fetch: app.fetch,\n build: processBuild,\n buildOptions,\n buildEnhancers: ['waku/adapters/aws-lambda-build-enhancer'],\n };\n },\n);\n"],"names":["path","serveStatic","Hono","honoAwsLambda","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","isBuild","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","root","join","distDir","middlewareFn","buildOptions","globalThis","__WAKU_AWS_LAMBDA_HANDLE__","streaming","streamHandle","handle","fetch","build","buildEnhancers"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,IAAI,QAAQ,OAAO;AAE5B,YAAYC,mBAAmB,kBAAkB;AACjD,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGL;AACxB,MAAM,EAAEM,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGJ;AAE/D,eAAeF,yBACb,CACE,EAAEO,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAE,EAC/DC;IAMA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIpB;IAChBoB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIT,SAAS;QACXK,IAAIK,GAAG,CAAC1B,YAAY;YAAE2B,MAAM5B,KAAK6B,IAAI,CAACb,OAAOc,OAAO,EAAEpB;QAAa;IACrE;IACAY,IAAIK,GAAG,CAAChB;IACR,KAAK,MAAMoB,gBAAgBX,cAAe;QACxCE,IAAIK,GAAG,CAACI;IACV;IACAT,IAAIK,GAAG,CAACd,iBAAiBQ;IACzBC,IAAIK,GAAG,CAACf,cAAc;QAAEE;IAAe;IACvC,MAAMkB,eAA6B;QACjCF,SAASd,OAAOc,OAAO;IACzB;IACCG,WAAmBC,0BAA0B,GAAGf,SAASgB,YACtDhC,cAAciC,YAAY,GAC1BjC,cAAckC,MAAM;IACxB,OAAO;QACLC,OAAOhB,IAAIgB,KAAK;QAChBC,OAAOxB;QACPiB;QACAQ,gBAAgB;YAAC;SAA0C;IAC7D;AACF,GACA"}
@@ -0,0 +1,4 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ };
4
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir }) {
3
+ async function postBuild({ distDir }) {
4
4
  const SERVE_JS = 'serve-bun.js';
5
5
  const serveCode = `
6
6
  import { unstable_serverEntry } from './server/index.js';
@@ -11,5 +11,11 @@ Bun.serve({
11
11
  `;
12
12
  writeFileSync(path.resolve(distDir, SERVE_JS), serveCode);
13
13
  }
14
+ export default async function buildEnhancer(build) {
15
+ return async (emitFile, options)=>{
16
+ await build(emitFile, options);
17
+ await postBuild(options);
18
+ };
19
+ }
14
20
 
15
- //# sourceMappingURL=bun-post-build.js.map
21
+ //# sourceMappingURL=bun-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/bun-build-enhancer.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = { distDir: string };\n\nasync function postBuild({ distDir }: BuildOptions) {\n const SERVE_JS = 'serve-bun.js';\n const serveCode = `\nimport { unstable_serverEntry } from './server/index.js';\n\nBun.serve({\n fetch: unstable_serverEntry.fetch,\n});\n`;\n writeFileSync(path.resolve(distDir, SERVE_JS), serveCode);\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n"],"names":["writeFileSync","path","postBuild","distDir","SERVE_JS","serveCode","resolve","buildEnhancer","build","emitFile","options"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,OAAOC,UAAU,YAAY;AAI7B,eAAeC,UAAU,EAAEC,OAAO,EAAgB;IAChD,MAAMC,WAAW;IACjB,MAAMC,YAAY,CAAC;;;;;;AAMrB,CAAC;IACCL,cAAcC,KAAKK,OAAO,CAACH,SAASC,WAAWC;AACjD;AAEA,eAAe,eAAeE,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMR,UAAUQ;IAClB;AACF"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -2,10 +2,6 @@ import path from 'node:path';
2
2
  import { Hono } from 'hono';
3
3
  import { serveStatic } from 'hono/bun';
4
4
  import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
5
- function joinPath(path1, path2) {
6
- const p = path.posix.join(path1, path2);
7
- return p.startsWith('/') ? p : './' + p;
8
- }
9
5
  const { DIST_PUBLIC } = constants;
10
6
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
11
7
  export default createServerEntryAdapter(({ processRequest, processBuild, config, isBuild, notFoundHtml }, options)=>{
@@ -31,16 +27,15 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
31
27
  app.use(rscMiddleware({
32
28
  processRequest
33
29
  }));
34
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/bun-post-build.js');
35
- const postBuildArg = {
30
+ const buildOptions = {
36
31
  distDir: config.distDir
37
32
  };
38
33
  return {
39
34
  fetch: app.fetch,
40
35
  build: processBuild,
41
- postBuild: [
42
- postBuildScript,
43
- postBuildArg
36
+ buildOptions,
37
+ buildEnhancers: [
38
+ 'waku/adapters/bun-build-enhancer'
44
39
  ]
45
40
  };
46
41
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/bun.ts"],"sourcesContent":["import path from 'node:path';\nimport { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport { serveStatic } from 'hono/bun';\nimport type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\n\ndeclare global {\n interface ImportMeta {\n glob: ImportGlobFunction;\n readonly __WAKU_ORIGINAL_PATH__: string;\n }\n}\n\nfunction joinPath(path1: string, path2: string) {\n const p = path.posix.join(path1, path2);\n return p.startsWith('/') ? p : './' + p;\n}\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, isBuild, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 (isBuild) {\n app.use(\n `${config.basePath}*`,\n serveStatic({\n root: path.join(config.distDir, DIST_PUBLIC),\n rewriteRequestPath: (path) => path.slice(config.basePath.length - 1),\n }),\n );\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const postBuildScript = joinPath(\n import.meta.__WAKU_ORIGINAL_PATH__,\n '../lib/bun-post-build.js',\n );\n const postBuildArg: Parameters<\n typeof import('./lib/bun-post-build.js').default\n >[0] = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["path","Hono","serveStatic","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","path1","path2","p","posix","join","startsWith","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","isBuild","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","basePath","root","distDir","rewriteRequestPath","slice","length","middlewareFn","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","fetch","build","postBuild"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC,WAAW,QAAQ,WAAW;AAEvC,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AASxB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIZ,KAAKa,KAAK,CAACC,IAAI,CAACJ,OAAOC;IACjC,OAAOC,EAAEG,UAAU,CAAC,OAAOH,IAAI,OAAOA;AACxC;AAEA,MAAM,EAAEI,WAAW,EAAE,GAAGZ;AACxB,MAAM,EAAEa,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGX;AAE/D,eAAeF,yBACb,CACE,EAAEc,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAE,EAC/DC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAI3B;IAChB2B,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIT,SAAS;QACXK,IAAIK,GAAG,CACL,GAAGX,OAAOY,QAAQ,CAAC,CAAC,CAAC,EACrBhC,YAAY;YACViC,MAAMnC,KAAKc,IAAI,CAACQ,OAAOc,OAAO,EAAEpB;YAChCqB,oBAAoB,CAACrC,OAASA,KAAKsC,KAAK,CAAChB,OAAOY,QAAQ,CAACK,MAAM,GAAG;QACpE;IAEJ;IACAX,IAAIK,GAAG,CAAChB;IACR,KAAK,MAAMuB,gBAAgBd,cAAe;QACxCE,IAAIK,GAAG,CAACO;IACV;IACAZ,IAAIK,GAAG,CAACd,iBAAiBQ;IACzBC,IAAIK,GAAG,CAACf,cAAc;QAAEE;IAAe;IACvC,MAAMqB,kBAAkBhC,SACtB,YAAYiC,sBAAsB,EAClC;IAEF,MAAMC,eAEC;QACLP,SAASd,OAAOc,OAAO;IACzB;IACA,OAAO;QACLQ,OAAOhB,IAAIgB,KAAK;QAChBC,OAAOxB;QACPyB,WAAW;YAACL;YAAiBE;SAAa;IAC5C;AACF,GACA"}
1
+ {"version":3,"sources":["../../src/adapters/bun.ts"],"sourcesContent":["import path from 'node:path';\nimport { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport { serveStatic } from 'hono/bun';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport type { BuildOptions } from './bun-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, isBuild, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 (isBuild) {\n app.use(\n `${config.basePath}*`,\n serveStatic({\n root: path.join(config.distDir, DIST_PUBLIC),\n rewriteRequestPath: (path) => path.slice(config.basePath.length - 1),\n }),\n );\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n buildOptions,\n buildEnhancers: ['waku/adapters/bun-build-enhancer'],\n };\n },\n);\n"],"names":["path","Hono","serveStatic","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","isBuild","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","basePath","root","join","distDir","rewriteRequestPath","slice","length","middlewareFn","buildOptions","fetch","build","buildEnhancers"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC,WAAW,QAAQ,WAAW;AACvC,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGL;AACxB,MAAM,EAAEM,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGJ;AAE/D,eAAeF,yBACb,CACE,EAAEO,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,OAAO,EAAEC,YAAY,EAAE,EAC/DC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIpB;IAChBoB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIT,SAAS;QACXK,IAAIK,GAAG,CACL,GAAGX,OAAOY,QAAQ,CAAC,CAAC,CAAC,EACrBzB,YAAY;YACV0B,MAAM5B,KAAK6B,IAAI,CAACd,OAAOe,OAAO,EAAErB;YAChCsB,oBAAoB,CAAC/B,OAASA,KAAKgC,KAAK,CAACjB,OAAOY,QAAQ,CAACM,MAAM,GAAG;QACpE;IAEJ;IACAZ,IAAIK,GAAG,CAAChB;IACR,KAAK,MAAMwB,gBAAgBf,cAAe;QACxCE,IAAIK,GAAG,CAACQ;IACV;IACAb,IAAIK,GAAG,CAACd,iBAAiBQ;IACzBC,IAAIK,GAAG,CAACf,cAAc;QAAEE;IAAe;IACvC,MAAMsB,eAA6B;QACjCL,SAASf,OAAOe,OAAO;IACzB;IACA,OAAO;QACLM,OAAOf,IAAIe,KAAK;QAChBC,OAAOvB;QACPqB;QACAG,gBAAgB;YAAC;SAAmC;IACtD;AACF,GACA"}
@@ -0,0 +1,4 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ };
4
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir }) {
3
+ async function postBuild({ distDir }) {
4
4
  const mainEntry = path.resolve(path.join(distDir, 'server', 'serve-cloudflare.js'));
5
5
  fs.writeFileSync(mainEntry, `\
6
6
  import { INTERNAL_runFetch } from './index.js';
@@ -33,6 +33,12 @@ export default {
33
33
  `);
34
34
  }
35
35
  }
36
+ export default async function buildEnhancer(build) {
37
+ return async (emitFile, options)=>{
38
+ await build(emitFile, options);
39
+ await postBuild(options);
40
+ };
41
+ }
36
42
  const forceRelativePath = (s)=>s.startsWith('.') ? s : './' + s;
37
43
 
38
- //# sourceMappingURL=cloudflare-post-build.js.map
44
+ //# sourceMappingURL=cloudflare-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/cloudflare-build-enhancer.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = { distDir: string };\n\nasync function postBuild({ distDir }: BuildOptions) {\n const mainEntry = path.resolve(\n path.join(distDir, 'server', 'serve-cloudflare.js'),\n );\n fs.writeFileSync(\n mainEntry,\n `\\\nimport { INTERNAL_runFetch } from './index.js';\n\nexport default {\n fetch: (request, env, ctx) => INTERNAL_runFetch(env, request, env, ctx),\n};\n`,\n );\n\n const wranglerTomlFile = path.resolve('wrangler.toml');\n const wranglerJsonFile = path.resolve('wrangler.json');\n const wranglerJsoncFile = path.resolve('wrangler.jsonc');\n if (\n !fs.existsSync(wranglerTomlFile) &&\n !fs.existsSync(wranglerJsonFile) &&\n !fs.existsSync(wranglerJsoncFile)\n ) {\n fs.writeFileSync(\n wranglerJsoncFile,\n `\\\n{\n \"name\": \"waku-project\",\n \"main\": ${JSON.stringify(forceRelativePath(path.relative(process.cwd(), mainEntry)))},\n // https://developers.cloudflare.com/workers/platform/compatibility-dates\n \"compatibility_date\": \"2024-11-11\",\n // nodejs_als is required for Waku server-side request context\n // It can be removed if only building static pages\n \"compatibility_flags\": [\"nodejs_als\"],\n // https://developers.cloudflare.com/workers/static-assets/binding/\n \"assets\": {\n \"binding\": \"ASSETS\",\n \"directory\": \"./dist/public\",\n \"html_handling\": \"drop-trailing-slash\",\n \"not_found_handling\": \"404-page\"\n }\n}\n`,\n );\n }\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n\nconst forceRelativePath = (s: string) => (s.startsWith('.') ? s : './' + s);\n"],"names":["fs","path","postBuild","distDir","mainEntry","resolve","join","writeFileSync","wranglerTomlFile","wranglerJsonFile","wranglerJsoncFile","existsSync","JSON","stringify","forceRelativePath","relative","process","cwd","buildEnhancer","build","emitFile","options","s","startsWith"],"mappings":"AAAA,OAAOA,QAAQ,UAAU;AACzB,OAAOC,UAAU,YAAY;AAI7B,eAAeC,UAAU,EAAEC,OAAO,EAAgB;IAChD,MAAMC,YAAYH,KAAKI,OAAO,CAC5BJ,KAAKK,IAAI,CAACH,SAAS,UAAU;IAE/BH,GAAGO,aAAa,CACdH,WACA,CAAC;;;;;;AAML,CAAC;IAGC,MAAMI,mBAAmBP,KAAKI,OAAO,CAAC;IACtC,MAAMI,mBAAmBR,KAAKI,OAAO,CAAC;IACtC,MAAMK,oBAAoBT,KAAKI,OAAO,CAAC;IACvC,IACE,CAACL,GAAGW,UAAU,CAACH,qBACf,CAACR,GAAGW,UAAU,CAACF,qBACf,CAACT,GAAGW,UAAU,CAACD,oBACf;QACAV,GAAGO,aAAa,CACdG,mBACA,CAAC;;;UAGG,EAAEE,KAAKC,SAAS,CAACC,kBAAkBb,KAAKc,QAAQ,CAACC,QAAQC,GAAG,IAAIb,aAAa;;;;;;;;;;;;;;AAcvF,CAAC;IAEC;AACF;AAEA,eAAe,eAAec,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMnB,UAAUmB;IAClB;AACF;AAEA,MAAMP,oBAAoB,CAACQ,IAAeA,EAAEC,UAAU,CAAC,OAAOD,IAAI,OAAOA"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -1,10 +1,5 @@
1
1
  import { Hono } from 'hono';
2
2
  import { unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
3
- import { joinPath as joinPathOrig } from '../lib/utils/path.js';
4
- function joinPath(path1, path2) {
5
- const p = joinPathOrig(path1, path2);
6
- return p.startsWith('/') ? p : './' + p;
7
- }
8
3
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
9
4
  export default createServerEntryAdapter(({ processRequest, processBuild, config, notFoundHtml }, options)=>{
10
5
  const { middlewareFns = [], middlewareModules = {} } = options || {};
@@ -23,16 +18,15 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
23
18
  app.use(rscMiddleware({
24
19
  processRequest
25
20
  }));
26
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/cloudflare-post-build.js');
27
- const postBuildArg = {
21
+ const buildOptions = {
28
22
  distDir: config.distDir
29
23
  };
30
24
  return {
31
25
  fetch: app.fetch,
32
26
  build: processBuild,
33
- postBuild: [
34
- postBuildScript,
35
- postBuildArg
27
+ buildOptions,
28
+ buildEnhancers: [
29
+ 'waku/adapters/cloudflare-build-enhancer'
36
30
  ]
37
31
  };
38
32
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/cloudflare.ts"],"sourcesContent":["import { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';\nimport {\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport { joinPath as joinPathOrig } from '../lib/utils/path.js';\n\ndeclare global {\n interface ImportMeta {\n glob: ImportGlobFunction;\n readonly __WAKU_ORIGINAL_PATH__: string;\n }\n}\n\nfunction joinPath(path1: string, path2: string) {\n const p = joinPathOrig(path1, path2);\n return p.startsWith('/') ? p : './' + p;\n}\n\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const postBuildScript = joinPath(\n import.meta.__WAKU_ORIGINAL_PATH__,\n '../lib/cloudflare-post-build.js',\n );\n const postBuildArg: Parameters<\n typeof import('./lib/cloudflare-post-build.js').default\n >[0] = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["Hono","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","joinPathOrig","path1","path2","p","startsWith","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","middlewareFn","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","distDir","fetch","build","postBuild"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAG5B,SACEC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AACxB,SAASC,YAAYC,YAAY,QAAQ,uBAAuB;AAShE,SAASD,SAASE,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIH,aAAaC,OAAOC;IAC9B,OAAOC,EAAEC,UAAU,CAAC,OAAOD,IAAI,OAAOA;AACxC;AAEA,MAAM,EAAEE,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGT;AAE/D,eAAeF,yBACb,CACE,EAAEY,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIrB;IAChBqB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACAJ,IAAIK,GAAG,CAACf;IACR,KAAK,MAAMgB,gBAAgBR,cAAe;QACxCE,IAAIK,GAAG,CAACC;IACV;IACAN,IAAIK,GAAG,CAACb,iBAAiBO;IACzBC,IAAIK,GAAG,CAACd,cAAc;QAAEE;IAAe;IACvC,MAAMc,kBAAkBvB,SACtB,YAAYwB,sBAAsB,EAClC;IAEF,MAAMC,eAEC;QACLC,SAASf,OAAOe,OAAO;IACzB;IACA,OAAO;QACLC,OAAOX,IAAIW,KAAK;QAChBC,OAAOlB;QACPmB,WAAW;YAACN;YAAiBE;SAAa;IAC5C;AACF,GACA"}
1
+ {"version":3,"sources":["../../src/adapters/cloudflare.ts"],"sourcesContent":["import { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport {\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport type { BuildOptions } from './cloudflare-build-enhancer.js';\n\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n buildOptions,\n buildEnhancers: ['waku/adapters/cloudflare-build-enhancer'],\n };\n },\n);\n"],"names":["Hono","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","middlewareFn","buildOptions","distDir","fetch","build","buildEnhancers"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAE5B,SACEC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AAGxB,MAAM,EAAEC,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGH;AAE/D,eAAeF,yBACb,CACE,EAAEM,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIf;IAChBe,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACAJ,IAAIK,GAAG,CAACf;IACR,KAAK,MAAMgB,gBAAgBR,cAAe;QACxCE,IAAIK,GAAG,CAACC;IACV;IACAN,IAAIK,GAAG,CAACb,iBAAiBO;IACzBC,IAAIK,GAAG,CAACd,cAAc;QAAEE;IAAe;IACvC,MAAMc,eAA6B;QACjCC,SAASb,OAAOa,OAAO;IACzB;IACA,OAAO;QACLC,OAAOT,IAAIS,KAAK;QAChBC,OAAOhB;QACPa;QACAI,gBAAgB;YAAC;SAA0C;IAC7D;AACF,GACA"}
@@ -0,0 +1,4 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ };
4
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir }) {
3
+ async function postBuild({ distDir }) {
4
4
  const SERVE_JS = 'serve-deno.js';
5
5
  const serveCode = `
6
6
  import { Hono } from 'jsr:@hono/hono';
@@ -16,5 +16,11 @@ Deno.serve((req, ...args) => INTERNAL_runFetch(env, req, ...args));
16
16
  `;
17
17
  writeFileSync(path.join(distDir, SERVE_JS), serveCode);
18
18
  }
19
+ export default async function buildEnhancer(build) {
20
+ return async (emitFile, options)=>{
21
+ await build(emitFile, options);
22
+ await postBuild(options);
23
+ };
24
+ }
19
25
 
20
- //# sourceMappingURL=deno-post-build.js.map
26
+ //# sourceMappingURL=deno-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/deno-build-enhancer.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = { distDir: string };\n\nasync function postBuild({ distDir }: BuildOptions) {\n const SERVE_JS = 'serve-deno.js';\n const serveCode = `\nimport { Hono } from 'jsr:@hono/hono';\nimport { serveStatic } from 'jsr:@hono/hono/deno';\n\nglobalThis.__WAKU_DENO_ADAPTER_HONO__ = Hono;\nglobalThis.__WAKU_DENO_ADAPTER_SERVE_STATIC__ = serveStatic;\n\nconst { INTERNAL_runFetch } = await import('./server/index.js');\n\nconst env = Deno.env.toObject();\nDeno.serve((req, ...args) => INTERNAL_runFetch(env, req, ...args));\n`;\n writeFileSync(path.join(distDir, SERVE_JS), serveCode);\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n"],"names":["writeFileSync","path","postBuild","distDir","SERVE_JS","serveCode","join","buildEnhancer","build","emitFile","options"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,OAAOC,UAAU,YAAY;AAI7B,eAAeC,UAAU,EAAEC,OAAO,EAAgB;IAChD,MAAMC,WAAW;IACjB,MAAMC,YAAY,CAAC;;;;;;;;;;;AAWrB,CAAC;IACCL,cAAcC,KAAKK,IAAI,CAACH,SAASC,WAAWC;AAC9C;AAEA,eAAe,eAAeE,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMR,UAAUQ;IAClB;AACF"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -2,10 +2,6 @@ import path from 'node:path';
2
2
  // FIXME hopefully we should avoid bundling this
3
3
  import { Hono as HonoForDevAndBuild } from 'hono';
4
4
  import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
5
- function joinPath(path1, path2) {
6
- const p = path.posix.join(path1, path2);
7
- return p.startsWith('/') ? p : './' + p;
8
- }
9
5
  const { DIST_PUBLIC } = constants;
10
6
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
11
7
  export default createServerEntryAdapter(({ processRequest, processBuild, config, notFoundHtml }, options)=>{
@@ -31,16 +27,15 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
31
27
  app.use(rscMiddleware({
32
28
  processRequest
33
29
  }));
34
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/deno-post-build.js');
35
- const postBuildArg = {
30
+ const buildOptions = {
36
31
  distDir: config.distDir
37
32
  };
38
33
  return {
39
34
  fetch: app.fetch,
40
35
  build: processBuild,
41
- postBuild: [
42
- postBuildScript,
43
- postBuildArg
36
+ buildOptions,
37
+ buildEnhancers: [
38
+ 'waku/adapters/deno-build-enhancer'
44
39
  ]
45
40
  };
46
41
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/deno.ts"],"sourcesContent":["import path from 'node:path';\n// FIXME hopefully we should avoid bundling this\nimport { Hono as HonoForDevAndBuild } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\n\ndeclare global {\n interface ImportMeta {\n glob: ImportGlobFunction;\n readonly __WAKU_ORIGINAL_PATH__: string;\n }\n}\n\nfunction joinPath(path1: string, path2: string) {\n const p = path.posix.join(path1, path2);\n return p.startsWith('/') ? p : './' + p;\n}\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = options || {};\n const {\n __WAKU_DENO_ADAPTER_HONO__: Hono = HonoForDevAndBuild,\n __WAKU_DENO_ADAPTER_SERVE_STATIC__: serveStatic,\n } = globalThis as any;\n const app = new Hono();\n app.notFound((c: any) => {\n if (notFoundHtml) {\n return c.html(notFoundHtml, 404);\n }\n return c.text('404 Not Found', 404);\n });\n if (serveStatic) {\n app.use(serveStatic({ root: path.join(config.distDir, DIST_PUBLIC) }));\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const postBuildScript = joinPath(\n import.meta.__WAKU_ORIGINAL_PATH__,\n '../lib/deno-post-build.js',\n );\n const postBuildArg: Parameters<\n typeof import('./lib/deno-post-build.js').default\n >[0] = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["path","Hono","HonoForDevAndBuild","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","path1","path2","p","posix","join","startsWith","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","__WAKU_DENO_ADAPTER_HONO__","__WAKU_DENO_ADAPTER_SERVE_STATIC__","serveStatic","globalThis","app","notFound","c","html","text","use","root","distDir","middlewareFn","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","fetch","build","postBuild"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,gDAAgD;AAChD,SAASC,QAAQC,kBAAkB,QAAQ,OAAO;AAGlD,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AASxB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIZ,KAAKa,KAAK,CAACC,IAAI,CAACJ,OAAOC;IACjC,OAAOC,EAAEG,UAAU,CAAC,OAAOH,IAAI,OAAOA;AACxC;AAEA,MAAM,EAAEI,WAAW,EAAE,GAAGZ;AACxB,MAAM,EAAEa,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGX;AAE/D,eAAeF,yBACb,CACE,EAAEc,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAM,EACJG,4BAA4B1B,OAAOC,kBAAkB,EACrD0B,oCAAoCC,WAAW,EAChD,GAAGC;IACJ,MAAMC,MAAM,IAAI9B;IAChB8B,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIV,cAAc;YAChB,OAAOU,EAAEC,IAAI,CAACX,cAAc;QAC9B;QACA,OAAOU,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIN,aAAa;QACfE,IAAIK,GAAG,CAACP,YAAY;YAAEQ,MAAMrC,KAAKc,IAAI,CAACQ,OAAOgB,OAAO,EAAEtB;QAAa;IACrE;IACAe,IAAIK,GAAG,CAACnB;IACR,KAAK,MAAMsB,gBAAgBd,cAAe;QACxCM,IAAIK,GAAG,CAACG;IACV;IACAR,IAAIK,GAAG,CAACjB,iBAAiBO;IACzBK,IAAIK,GAAG,CAAClB,cAAc;QAAEE;IAAe;IACvC,MAAMoB,kBAAkB/B,SACtB,YAAYgC,sBAAsB,EAClC;IAEF,MAAMC,eAEC;QACLJ,SAAShB,OAAOgB,OAAO;IACzB;IACA,OAAO;QACLK,OAAOZ,IAAIY,KAAK;QAChBC,OAAOvB;QACPwB,WAAW;YAACL;YAAiBE;SAAa;IAC5C;AACF,GACA"}
1
+ {"version":3,"sources":["../../src/adapters/deno.ts"],"sourcesContent":["import path from 'node:path';\n// FIXME hopefully we should avoid bundling this\nimport { Hono as HonoForDevAndBuild } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport type { BuildOptions } from './deno-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = options || {};\n const {\n __WAKU_DENO_ADAPTER_HONO__: Hono = HonoForDevAndBuild,\n __WAKU_DENO_ADAPTER_SERVE_STATIC__: serveStatic,\n } = globalThis as any;\n const app = new Hono();\n app.notFound((c: any) => {\n if (notFoundHtml) {\n return c.html(notFoundHtml, 404);\n }\n return c.text('404 Not Found', 404);\n });\n if (serveStatic) {\n app.use(serveStatic({ root: path.join(config.distDir, DIST_PUBLIC) }));\n }\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n distDir: config.distDir,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n buildOptions,\n buildEnhancers: ['waku/adapters/deno-build-enhancer'],\n };\n },\n);\n"],"names":["path","Hono","HonoForDevAndBuild","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","__WAKU_DENO_ADAPTER_HONO__","__WAKU_DENO_ADAPTER_SERVE_STATIC__","serveStatic","globalThis","app","notFound","c","html","text","use","root","join","distDir","middlewareFn","buildOptions","fetch","build","buildEnhancers"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,gDAAgD;AAChD,SAASC,QAAQC,kBAAkB,QAAQ,OAAO;AAElD,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGL;AACxB,MAAM,EAAEM,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGJ;AAE/D,eAAeF,yBACb,CACE,EAAEO,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAKA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAM,EACJG,4BAA4BnB,OAAOC,kBAAkB,EACrDmB,oCAAoCC,WAAW,EAChD,GAAGC;IACJ,MAAMC,MAAM,IAAIvB;IAChBuB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIV,cAAc;YAChB,OAAOU,EAAEC,IAAI,CAACX,cAAc;QAC9B;QACA,OAAOU,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACA,IAAIN,aAAa;QACfE,IAAIK,GAAG,CAACP,YAAY;YAAEQ,MAAM9B,KAAK+B,IAAI,CAAChB,OAAOiB,OAAO,EAAEvB;QAAa;IACrE;IACAe,IAAIK,GAAG,CAACnB;IACR,KAAK,MAAMuB,gBAAgBf,cAAe;QACxCM,IAAIK,GAAG,CAACI;IACV;IACAT,IAAIK,GAAG,CAACjB,iBAAiBO;IACzBK,IAAIK,GAAG,CAAClB,cAAc;QAAEE;IAAe;IACvC,MAAMqB,eAA6B;QACjCF,SAASjB,OAAOiB,OAAO;IACzB;IACA,OAAO;QACLG,OAAOX,IAAIW,KAAK;QAChBC,OAAOtB;QACPoB;QACAG,gBAAgB;YAAC;SAAoC;IACvD;AACF,GACA"}
@@ -0,0 +1,7 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ privateDir: string;
4
+ DIST_PUBLIC: string;
5
+ serverless: boolean;
6
+ };
7
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir, privateDir, DIST_PUBLIC, serverless }) {
3
+ async function postBuild({ distDir, privateDir, DIST_PUBLIC, serverless }) {
4
4
  if (serverless) {
5
5
  const functionsDir = path.resolve('netlify-functions');
6
6
  mkdirSync(functionsDir, {
@@ -30,5 +30,11 @@ export const config = {
30
30
  `);
31
31
  }
32
32
  }
33
+ export default async function buildEnhancer(build) {
34
+ return async (emitFile, options)=>{
35
+ await build(emitFile, options);
36
+ await postBuild(options);
37
+ };
38
+ }
33
39
 
34
- //# sourceMappingURL=netlify-post-build.js.map
40
+ //# sourceMappingURL=netlify-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/netlify-build-enhancer.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = {\n distDir: string;\n privateDir: string;\n DIST_PUBLIC: string;\n serverless: boolean;\n};\n\nasync function postBuild({\n distDir,\n privateDir,\n DIST_PUBLIC,\n serverless,\n}: BuildOptions) {\n if (serverless) {\n const functionsDir = path.resolve('netlify-functions');\n mkdirSync(functionsDir, {\n recursive: true,\n });\n writeFileSync(\n path.join(functionsDir, 'serve.js'),\n `\\\nconst { INTERNAL_runFetch } = await import('../${distDir}/server/index.js');\n\nexport default async (request, context) =>\n INTERNAL_runFetch(process.env, request, { context });\n\nexport const config = {\n preferStatic: true,\n path: ['/', '/*'],\n};\n`,\n );\n }\n const netlifyTomlFile = path.resolve('netlify.toml');\n if (!existsSync(netlifyTomlFile)) {\n writeFileSync(\n netlifyTomlFile,\n `\\\n[build]\n command = \"npm run build\"\n publish = \"${distDir}/${DIST_PUBLIC}\"\n[functions]\n included_files = [\"${privateDir}/**\"]\n directory = \"netlify-functions\"\n`,\n );\n }\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n"],"names":["existsSync","mkdirSync","writeFileSync","path","postBuild","distDir","privateDir","DIST_PUBLIC","serverless","functionsDir","resolve","recursive","join","netlifyTomlFile","buildEnhancer","build","emitFile","options"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,aAAa,QAAQ,UAAU;AAC/D,OAAOC,UAAU,YAAY;AAS7B,eAAeC,UAAU,EACvBC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,UAAU,EACG;IACb,IAAIA,YAAY;QACd,MAAMC,eAAeN,KAAKO,OAAO,CAAC;QAClCT,UAAUQ,cAAc;YACtBE,WAAW;QACb;QACAT,cACEC,KAAKS,IAAI,CAACH,cAAc,aACxB,CAAC;+CACwC,EAAEJ,QAAQ;;;;;;;;;AASzD,CAAC;IAEC;IACA,MAAMQ,kBAAkBV,KAAKO,OAAO,CAAC;IACrC,IAAI,CAACV,WAAWa,kBAAkB;QAChCX,cACEW,iBACA,CAAC;;;aAGM,EAAER,QAAQ,CAAC,EAAEE,YAAY;;qBAEjB,EAAED,WAAW;;AAElC,CAAC;IAEC;AACF;AAEA,eAAe,eAAeQ,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMb,UAAUa;IAClB;AACF"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -1,10 +1,5 @@
1
- import path from 'node:path';
2
1
  import { Hono } from 'hono';
3
2
  import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
4
- function joinPath(path1, path2) {
5
- const p = path.posix.join(path1, path2);
6
- return p.startsWith('/') ? p : './' + p;
7
- }
8
3
  const { DIST_PUBLIC } = constants;
9
4
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
10
5
  export default createServerEntryAdapter(({ processRequest, processBuild, config, notFoundHtml }, options)=>{
@@ -24,8 +19,7 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
24
19
  app.use(rscMiddleware({
25
20
  processRequest
26
21
  }));
27
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/netlify-post-build.js');
28
- const postBuildArg = {
22
+ const buildOptions = {
29
23
  distDir: config.distDir,
30
24
  privateDir: config.privateDir,
31
25
  DIST_PUBLIC,
@@ -34,9 +28,9 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
34
28
  return {
35
29
  fetch: app.fetch,
36
30
  build: processBuild,
37
- postBuild: [
38
- postBuildScript,
39
- postBuildArg
31
+ buildOptions,
32
+ buildEnhancers: [
33
+ 'waku/adapters/netlify-build-enhancer'
40
34
  ]
41
35
  };
42
36
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/adapters/netlify.ts"],"sourcesContent":["import path from 'node:path';\nimport { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\n\ndeclare global {\n interface ImportMeta {\n glob: ImportGlobFunction;\n readonly __WAKU_ORIGINAL_PATH__: string;\n }\n}\n\nfunction joinPath(path1: string, path2: string) {\n const p = path.posix.join(path1, path2);\n return p.startsWith('/') ? p : './' + p;\n}\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n static?: boolean;\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const postBuildScript = joinPath(\n import.meta.__WAKU_ORIGINAL_PATH__,\n '../lib/netlify-post-build.js',\n );\n const postBuildArg: Parameters<\n typeof import('./lib/netlify-post-build.js').default\n >[0] = {\n distDir: config.distDir,\n privateDir: config.privateDir,\n DIST_PUBLIC,\n serverless: !options?.static,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["path","Hono","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","path1","path2","p","posix","join","startsWith","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","middlewareFn","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","distDir","privateDir","serverless","static","fetch","build","postBuild"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAC7B,SAASC,IAAI,QAAQ,OAAO;AAG5B,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AASxB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIX,KAAKY,KAAK,CAACC,IAAI,CAACJ,OAAOC;IACjC,OAAOC,EAAEG,UAAU,CAAC,OAAOH,IAAI,OAAOA;AACxC;AAEA,MAAM,EAAEI,WAAW,EAAE,GAAGZ;AACxB,MAAM,EAAEa,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGX;AAE/D,eAAeF,yBACb,CACE,EAAEc,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAMA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIzB;IAChByB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACAJ,IAAIK,GAAG,CAACf;IACR,KAAK,MAAMgB,gBAAgBR,cAAe;QACxCE,IAAIK,GAAG,CAACC;IACV;IACAN,IAAIK,GAAG,CAACb,iBAAiBO;IACzBC,IAAIK,GAAG,CAACd,cAAc;QAAEE;IAAe;IACvC,MAAMc,kBAAkBzB,SACtB,YAAY0B,sBAAsB,EAClC;IAEF,MAAMC,eAEC;QACLC,SAASf,OAAOe,OAAO;QACvBC,YAAYhB,OAAOgB,UAAU;QAC7BtB;QACAuB,YAAY,CAACf,SAASgB;IACxB;IACA,OAAO;QACLC,OAAOd,IAAIc,KAAK;QAChBC,OAAOrB;QACPsB,WAAW;YAACT;YAAiBE;SAAa;IAC5C;AACF,GACA"}
1
+ {"version":3,"sources":["../../src/adapters/netlify.ts"],"sourcesContent":["import { Hono } from 'hono';\nimport type { MiddlewareHandler } from 'hono';\nimport {\n unstable_constants as constants,\n unstable_createServerEntryAdapter as createServerEntryAdapter,\n unstable_honoMiddleware as honoMiddleware,\n} from 'waku/internals';\nimport type { BuildOptions } from './netlify-build-enhancer.js';\n\nconst { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config, notFoundHtml },\n options?: {\n static?: boolean;\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<string, () => Promise<unknown>>;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = 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 app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules as never));\n app.use(rscMiddleware({ processRequest }));\n const buildOptions: BuildOptions = {\n distDir: config.distDir,\n privateDir: config.privateDir,\n DIST_PUBLIC,\n serverless: !options?.static,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n buildOptions,\n buildEnhancers: ['waku/adapters/netlify-build-enhancer'],\n };\n },\n);\n"],"names":["Hono","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","notFoundHtml","options","middlewareFns","middlewareModules","app","notFound","c","html","text","use","middlewareFn","buildOptions","distDir","privateDir","serverless","static","fetch","build","buildEnhancers"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAE5B,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,EAC7DC,2BAA2BC,cAAc,QACpC,iBAAiB;AAGxB,MAAM,EAAEC,WAAW,EAAE,GAAGL;AACxB,MAAM,EAAEM,iBAAiB,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGJ;AAE/D,eAAeF,yBACb,CACE,EAAEO,cAAc,EAAEC,YAAY,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACtDC;IAMA,MAAM,EAAEC,gBAAgB,EAAE,EAAEC,oBAAoB,CAAC,CAAC,EAAE,GAAGF,WAAW,CAAC;IACnE,MAAMG,MAAM,IAAIlB;IAChBkB,IAAIC,QAAQ,CAAC,CAACC;QACZ,IAAIN,cAAc;YAChB,OAAOM,EAAEC,IAAI,CAACP,cAAc;QAC9B;QACA,OAAOM,EAAEE,IAAI,CAAC,iBAAiB;IACjC;IACAJ,IAAIK,GAAG,CAACf;IACR,KAAK,MAAMgB,gBAAgBR,cAAe;QACxCE,IAAIK,GAAG,CAACC;IACV;IACAN,IAAIK,GAAG,CAACb,iBAAiBO;IACzBC,IAAIK,GAAG,CAACd,cAAc;QAAEE;IAAe;IACvC,MAAMc,eAA6B;QACjCC,SAASb,OAAOa,OAAO;QACvBC,YAAYd,OAAOc,UAAU;QAC7BpB;QACAqB,YAAY,CAACb,SAASc;IACxB;IACA,OAAO;QACLC,OAAOZ,IAAIY,KAAK;QAChBC,OAAOnB;QACPa;QACAO,gBAAgB;YAAC;SAAuC;IAC1D;AACF,GACA"}
@@ -0,0 +1,4 @@
1
+ export type BuildOptions = {
2
+ distDir: string;
3
+ };
4
+ export default function buildEnhancer(build: (emitFile: unknown, options: BuildOptions) => Promise<void>): Promise<typeof build>;
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
- export default async function postBuild({ distDir }) {
3
+ async function postBuild({ distDir }) {
4
4
  const SERVE_JS = 'serve-node.js';
5
5
  const serveCode = `
6
6
  import { INTERNAL_runFetch, unstable_serverEntry } from './server/index.js';
@@ -18,5 +18,11 @@ serve({
18
18
  `;
19
19
  writeFileSync(path.resolve(distDir, SERVE_JS), serveCode);
20
20
  }
21
+ export default async function buildEnhancer(build) {
22
+ return async (emitFile, options)=>{
23
+ await build(emitFile, options);
24
+ await postBuild(options);
25
+ };
26
+ }
21
27
 
22
- //# sourceMappingURL=node-post-build.js.map
28
+ //# sourceMappingURL=node-build-enhancer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/node-build-enhancer.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport type BuildOptions = { distDir: string };\n\nasync function postBuild({ distDir }: BuildOptions) {\n const SERVE_JS = 'serve-node.js';\n const serveCode = `\nimport { INTERNAL_runFetch, unstable_serverEntry } from './server/index.js';\n\nconst { serve } = unstable_serverEntry;\n\nconst host = process.env.HOST;\nconst port = process.env.PORT;\n\nserve({\n fetch: (req, ...args) => INTERNAL_runFetch(process.env, req, ...args),\n ...(host ? { hostname: host } : {}),\n ...(port ? { port: parseInt(port, 10) } : {}),\n});\n`;\n writeFileSync(path.resolve(distDir, SERVE_JS), serveCode);\n}\n\nexport default async function buildEnhancer(\n build: (emitFile: unknown, options: BuildOptions) => Promise<void>,\n): Promise<typeof build> {\n return async (emitFile: unknown, options: BuildOptions) => {\n await build(emitFile, options);\n await postBuild(options);\n };\n}\n"],"names":["writeFileSync","path","postBuild","distDir","SERVE_JS","serveCode","resolve","buildEnhancer","build","emitFile","options"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,OAAOC,UAAU,YAAY;AAI7B,eAAeC,UAAU,EAAEC,OAAO,EAAgB;IAChD,MAAMC,WAAW;IACjB,MAAMC,YAAY,CAAC;;;;;;;;;;;;;AAarB,CAAC;IACCL,cAAcC,KAAKK,OAAO,CAACH,SAASC,WAAWC;AACjD;AAEA,eAAe,eAAeE,cAC5BC,KAAkE;IAElE,OAAO,OAAOC,UAAmBC;QAC/B,MAAMF,MAAMC,UAAUC;QACtB,MAAMR,UAAUQ;IAClB;AACF"}
@@ -1,11 +1,4 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
- import type { ImportGlobFunction } from 'vite/types/importGlob.d.ts';
3
- declare global {
4
- interface ImportMeta {
5
- glob: ImportGlobFunction;
6
- readonly __WAKU_ORIGINAL_PATH__: string;
7
- }
8
- }
9
2
  declare const _default: (args: {
10
3
  handleRequest: import("../lib/types.js").Unstable_HandleRequest;
11
4
  handleBuild: import("../lib/types.js").Unstable_HandleBuild;
@@ -3,10 +3,6 @@ import { serve } from '@hono/node-server';
3
3
  import { serveStatic } from '@hono/node-server/serve-static';
4
4
  import { Hono } from 'hono';
5
5
  import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
6
- function joinPath(path1, path2) {
7
- const p = path.posix.join(path1, path2);
8
- return p.startsWith('/') ? p : './' + p;
9
- }
10
6
  const { DIST_PUBLIC } = constants;
11
7
  const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
12
8
  export default createServerEntryAdapter(({ processRequest, processBuild, config, isBuild, notFoundHtml }, options)=>{
@@ -32,16 +28,15 @@ export default createServerEntryAdapter(({ processRequest, processBuild, config,
32
28
  app.use(rscMiddleware({
33
29
  processRequest
34
30
  }));
35
- const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/node-post-build.js');
36
- const postBuildArg = {
31
+ const buildOptions = {
37
32
  distDir: config.distDir
38
33
  };
39
34
  return {
40
35
  fetch: app.fetch,
41
36
  build: processBuild,
42
- postBuild: [
43
- postBuildScript,
44
- postBuildArg
37
+ buildOptions,
38
+ buildEnhancers: [
39
+ 'waku/adapters/node-build-enhancer'
45
40
  ],
46
41
  serve
47
42
  };