waku 0.26.0 → 0.27.0
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 +217 -13
- package/dist/adapters/aws-lambda.d.ts +17 -0
- package/dist/adapters/aws-lambda.js +51 -0
- package/dist/adapters/aws-lambda.js.map +1 -0
- package/dist/adapters/cloudflare.d.ts +16 -0
- package/dist/adapters/cloudflare.js +46 -0
- package/dist/adapters/cloudflare.js.map +1 -0
- package/dist/adapters/default.d.ts +5 -0
- package/dist/adapters/deno.d.ts +16 -0
- package/dist/adapters/deno.js +46 -0
- package/dist/adapters/deno.js.map +1 -0
- package/dist/adapters/lib/aws-lambda-post-build.d.ts +3 -0
- package/dist/adapters/lib/aws-lambda-post-build.js +20 -0
- package/dist/adapters/lib/aws-lambda-post-build.js.map +1 -0
- package/dist/adapters/lib/cloudflare-post-build.d.ts +4 -0
- package/dist/adapters/lib/cloudflare-post-build.js +133 -0
- package/dist/adapters/lib/cloudflare-post-build.js.map +1 -0
- package/dist/adapters/lib/deno-post-build.d.ts +4 -0
- package/dist/adapters/lib/deno-post-build.js +31 -0
- package/dist/adapters/lib/deno-post-build.js.map +1 -0
- package/dist/adapters/lib/netlify-post-build.d.ts +6 -0
- package/dist/adapters/lib/netlify-post-build.js +39 -0
- package/dist/adapters/lib/netlify-post-build.js.map +1 -0
- package/dist/adapters/lib/vercel-post-build.d.ts +9 -0
- package/dist/adapters/lib/vercel-post-build.js +77 -0
- package/dist/adapters/lib/vercel-post-build.js.map +1 -0
- package/dist/adapters/netlify.d.ts +17 -0
- package/dist/adapters/netlify.js +45 -0
- package/dist/adapters/netlify.js.map +1 -0
- package/dist/adapters/node.d.ts +11 -0
- package/dist/adapters/node.js +43 -0
- package/dist/adapters/node.js.map +1 -0
- package/dist/adapters/vercel.d.ts +17 -0
- package/dist/adapters/vercel.js +51 -0
- package/dist/adapters/vercel.js.map +1 -0
- package/dist/cli.js +25 -51
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -33
- package/dist/config.js.map +1 -1
- package/dist/internals.d.ts +3 -0
- package/dist/internals.js +5 -0
- package/dist/internals.js.map +1 -0
- package/dist/lib/{builder/constants.d.ts → constants.d.ts} +1 -0
- package/dist/lib/{builder/constants.js → constants.js} +1 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/{middleware/context.d.ts → context.d.ts} +1 -2
- package/dist/lib/context.js +25 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/hono/middleware.d.ts +9 -0
- package/dist/lib/hono/middleware.js +33 -0
- package/dist/lib/hono/middleware.js.map +1 -0
- package/dist/lib/types.d.ts +21 -14
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils/default-adapter.d.ts +1 -0
- package/dist/lib/utils/default-adapter.js +3 -0
- package/dist/lib/utils/default-adapter.js.map +1 -0
- package/dist/lib/utils/managed.d.ts +3 -2
- package/dist/lib/utils/managed.js +12 -10
- package/dist/lib/utils/managed.js.map +1 -1
- package/dist/lib/utils/node-fs.js +1 -1
- package/dist/lib/utils/node-fs.js.map +1 -1
- package/dist/lib/utils/path.d.ts +2 -0
- package/dist/lib/utils/path.js +23 -13
- package/dist/lib/utils/path.js.map +1 -1
- package/dist/lib/utils/render.d.ts +1 -1
- package/dist/lib/utils/render.js +1 -0
- package/dist/lib/utils/render.js.map +1 -1
- package/dist/lib/utils/request.d.ts +18 -22
- package/dist/lib/utils/request.js +18 -21
- package/dist/lib/utils/request.js.map +1 -1
- package/dist/lib/{renderers/utils.d.ts → utils/rsc-path.d.ts} +0 -2
- package/dist/lib/{renderers/utils.js → utils/rsc-path.js} +1 -27
- package/dist/lib/utils/rsc-path.js.map +1 -0
- package/dist/lib/utils/ssr.d.ts +3 -0
- package/dist/lib/{renderers/html.js → utils/ssr.js} +10 -3
- package/dist/lib/utils/ssr.js.map +1 -0
- package/dist/lib/utils/stream.d.ts +0 -2
- package/dist/lib/utils/stream.js +0 -29
- package/dist/lib/utils/stream.js.map +1 -1
- package/dist/lib/utils/task-runner.d.ts +5 -0
- package/dist/lib/{builder/build.js → utils/task-runner.js} +17 -15
- package/dist/lib/utils/task-runner.js.map +1 -0
- package/dist/lib/vite-entries/entry.browser.d.ts +0 -1
- package/dist/lib/vite-entries/entry.browser.js +9 -1
- package/dist/lib/vite-entries/entry.browser.js.map +1 -1
- package/dist/lib/vite-entries/entry.build.d.ts +3 -0
- package/dist/lib/vite-entries/entry.build.js +15 -0
- package/dist/lib/vite-entries/entry.build.js.map +1 -0
- package/dist/lib/vite-entries/entry.server.d.ts +3 -3
- package/dist/lib/vite-entries/entry.server.js +5 -31
- package/dist/lib/vite-entries/entry.server.js.map +1 -1
- package/dist/lib/vite-plugins/allow-server.js.map +1 -1
- package/dist/lib/vite-plugins/fs-router-typegen.js +11 -6
- package/dist/lib/vite-plugins/fs-router-typegen.js.map +1 -1
- package/dist/lib/vite-rsc/cli.d.ts +1 -0
- package/dist/lib/vite-rsc/cli.js +27 -16
- package/dist/lib/vite-rsc/cli.js.map +1 -1
- package/dist/lib/vite-rsc/handler.d.ts +2 -2
- package/dist/lib/vite-rsc/handler.js +88 -43
- package/dist/lib/vite-rsc/handler.js.map +1 -1
- package/dist/lib/vite-rsc/plugin.d.ts +0 -9
- package/dist/lib/vite-rsc/plugin.js +114 -183
- package/dist/lib/vite-rsc/plugin.js.map +1 -1
- package/dist/lib/vite-rsc/ssr.js +9 -14
- package/dist/lib/vite-rsc/ssr.js.map +1 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/main.react-server.d.ts +1 -1
- package/dist/main.react-server.js +1 -1
- package/dist/main.react-server.js.map +1 -1
- package/dist/minimal/client.js +2 -2
- package/dist/minimal/client.js.map +1 -1
- package/dist/minimal/server.d.ts +12 -4
- package/dist/minimal/server.js +4 -1
- package/dist/minimal/server.js.map +1 -1
- package/dist/router/client.d.ts +2 -2
- package/dist/router/client.js +26 -9
- package/dist/router/client.js.map +1 -1
- package/dist/router/common.js +8 -2
- package/dist/router/common.js.map +1 -1
- package/dist/router/create-pages-utils/inferred-path-types.d.ts +1 -1
- package/dist/router/create-pages-utils/inferred-path-types.js.map +1 -1
- package/dist/router/create-pages.d.ts +3 -4
- package/dist/router/create-pages.js +5 -8
- package/dist/router/create-pages.js.map +1 -1
- package/dist/router/define-router.d.ts +2 -2
- package/dist/router/define-router.js +78 -100
- package/dist/router/define-router.js.map +1 -1
- package/dist/router/fs-router.d.ts +7 -10
- package/dist/router/fs-router.js +8 -5
- package/dist/router/fs-router.js.map +1 -1
- package/dist/router/server.d.ts +1 -1
- package/dist/router/server.js +1 -1
- package/dist/router/server.js.map +1 -1
- package/dist/server.d.ts +1 -20
- package/dist/server.js +2 -64
- package/dist/server.js.map +1 -1
- package/package.json +25 -21
- package/dist/lib/builder/build.d.ts +0 -4
- package/dist/lib/builder/build.js.map +0 -1
- package/dist/lib/builder/constants.js.map +0 -1
- package/dist/lib/config/types.d.ts +0 -4
- package/dist/lib/config/types.js +0 -3
- package/dist/lib/config/types.js.map +0 -1
- package/dist/lib/middleware/context.js +0 -54
- package/dist/lib/middleware/context.js.map +0 -1
- package/dist/lib/middleware/types.d.ts +0 -17
- package/dist/lib/middleware/types.js +0 -3
- package/dist/lib/middleware/types.js.map +0 -1
- package/dist/lib/renderers/html.d.ts +0 -1
- package/dist/lib/renderers/html.js.map +0 -1
- package/dist/lib/renderers/utils.js.map +0 -1
- package/dist/lib/utils/swc.d.ts +0 -9
- package/dist/lib/utils/swc.js +0 -16
- package/dist/lib/utils/swc.js.map +0 -1
- package/dist/lib/vite-rsc/browser-preamble.d.ts +0 -1
- package/dist/lib/vite-rsc/browser-preamble.js +0 -11
- package/dist/lib/vite-rsc/browser-preamble.js.map +0 -1
- package/dist/lib/vite-rsc/build.d.ts +0 -11
- package/dist/lib/vite-rsc/build.js +0 -33
- package/dist/lib/vite-rsc/build.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/aws-lambda/entry.d.ts +0 -2
- package/dist/lib/vite-rsc/deploy/aws-lambda/entry.js +0 -30
- package/dist/lib/vite-rsc/deploy/aws-lambda/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/aws-lambda/plugin.d.ts +0 -6
- package/dist/lib/vite-rsc/deploy/aws-lambda/plugin.js +0 -46
- package/dist/lib/vite-rsc/deploy/aws-lambda/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/cloudflare/entry.d.ts +0 -5
- package/dist/lib/vite-rsc/deploy/cloudflare/entry.js +0 -31
- package/dist/lib/vite-rsc/deploy/cloudflare/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/cloudflare/plugin.d.ts +0 -5
- package/dist/lib/vite-rsc/deploy/cloudflare/plugin.js +0 -175
- package/dist/lib/vite-rsc/deploy/cloudflare/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/deno/entry.d.ts +0 -1
- package/dist/lib/vite-rsc/deploy/deno/entry.js +0 -33
- package/dist/lib/vite-rsc/deploy/deno/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/deno/plugin.d.ts +0 -5
- package/dist/lib/vite-rsc/deploy/deno/plugin.js +0 -43
- package/dist/lib/vite-rsc/deploy/deno/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/netlify/entry.d.ts +0 -3
- package/dist/lib/vite-rsc/deploy/netlify/entry.js +0 -23
- package/dist/lib/vite-rsc/deploy/netlify/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/netlify/plugin.d.ts +0 -6
- package/dist/lib/vite-rsc/deploy/netlify/plugin.js +0 -69
- package/dist/lib/vite-rsc/deploy/netlify/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/partykit/entry.d.ts +0 -5
- package/dist/lib/vite-rsc/deploy/partykit/entry.js +0 -31
- package/dist/lib/vite-rsc/deploy/partykit/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/partykit/plugin.d.ts +0 -5
- package/dist/lib/vite-rsc/deploy/partykit/plugin.js +0 -66
- package/dist/lib/vite-rsc/deploy/partykit/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/vercel/entry.d.ts +0 -3
- package/dist/lib/vite-rsc/deploy/vercel/entry.js +0 -26
- package/dist/lib/vite-rsc/deploy/vercel/entry.js.map +0 -1
- package/dist/lib/vite-rsc/deploy/vercel/plugin.d.ts +0 -6
- package/dist/lib/vite-rsc/deploy/vercel/plugin.js +0 -94
- package/dist/lib/vite-rsc/deploy/vercel/plugin.js.map +0 -1
- package/dist/lib/vite-rsc/engine.d.ts +0 -2
- package/dist/lib/vite-rsc/engine.js +0 -46
- package/dist/lib/vite-rsc/engine.js.map +0 -1
- package/dist/lib/vite-rsc/middleware/handler.d.ts +0 -3
- package/dist/lib/vite-rsc/middleware/handler.js +0 -5
- package/dist/lib/vite-rsc/middleware/handler.js.map +0 -1
- package/dist/lib/vite-types.d.js +0 -4
- package/dist/lib/vite-types.d.js.map +0 -1
- package/dist/middleware/context.d.ts +0 -2
- package/dist/middleware/context.js +0 -4
- package/dist/middleware/context.js.map +0 -1
- package/dist/types.d.js +0 -3
- package/dist/types.d.js.map +0 -1
package/README.md
CHANGED
|
@@ -415,6 +415,107 @@ export const getConfig = async () => {
|
|
|
415
415
|
};
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
+
#### Group routes
|
|
419
|
+
|
|
420
|
+
Group routes allow you to organize routes into logical groups without affecting the URL structure. They're created by wrapping directory names in parentheses (e.g., `(group)`). This is particularly useful for sharing layouts across multiple routes while keeping the URL clean.
|
|
421
|
+
|
|
422
|
+
For example, you might want a home page at `/` that doesn't use a shared layout, but all other routes should share a common layout. This can be achieved by grouping those routes:
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
├── (main)
|
|
426
|
+
│ ├── _layout.tsx
|
|
427
|
+
│ ├── about.tsx
|
|
428
|
+
│ └── contact.tsx
|
|
429
|
+
└── index.tsx
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
In this structure, `/about` and `/contact` will use the layout from `(main)/_layout.tsx`, but `/` (from `index.tsx`) will not.
|
|
433
|
+
|
|
434
|
+
```tsx
|
|
435
|
+
// ./src/pages/(main)/_layout.tsx
|
|
436
|
+
import { Header } from '../../components/header';
|
|
437
|
+
import { Footer } from '../../components/footer';
|
|
438
|
+
|
|
439
|
+
// Create shared layout for main pages
|
|
440
|
+
export default async function MainLayout({ children }) {
|
|
441
|
+
return (
|
|
442
|
+
<>
|
|
443
|
+
<Header />
|
|
444
|
+
<main>{children}</main>
|
|
445
|
+
<Footer />
|
|
446
|
+
</>
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export const getConfig = async () => {
|
|
451
|
+
return {
|
|
452
|
+
render: 'static',
|
|
453
|
+
} as const;
|
|
454
|
+
};
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
```tsx
|
|
458
|
+
// ./src/pages/(main)/about.tsx
|
|
459
|
+
export default async function AboutPage() {
|
|
460
|
+
return <h1>About Us</h1>;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export const getConfig = async () => {
|
|
464
|
+
return {
|
|
465
|
+
render: 'static',
|
|
466
|
+
} as const;
|
|
467
|
+
};
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
Group routes can be nested to create complex layout compositions. For instance, you could have a static layout at the group level and a dynamic layout nested within:
|
|
471
|
+
|
|
472
|
+
```
|
|
473
|
+
(main)
|
|
474
|
+
├── (dynamic)
|
|
475
|
+
│ ├── _layout.tsx # dynamic layout
|
|
476
|
+
│ ├── dashboard.tsx
|
|
477
|
+
│ └── profile.tsx
|
|
478
|
+
└── _layout.tsx # static layout
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
This allows for fine-grained control over rendering modes - some work can be done at build time (`static`) while other work happens at runtime (`dynamic`).
|
|
482
|
+
|
|
483
|
+
```tsx
|
|
484
|
+
// ./src/pages/(main)/_layout.tsx
|
|
485
|
+
// Static layout - runs at build time
|
|
486
|
+
export default async function MainLayout({ children }) {
|
|
487
|
+
return <div className="main-container">{children}</div>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export const getConfig = async () => {
|
|
491
|
+
return {
|
|
492
|
+
render: 'static',
|
|
493
|
+
} as const;
|
|
494
|
+
};
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
```tsx
|
|
498
|
+
// ./src/pages/(main)/(dynamic)/_layout.tsx
|
|
499
|
+
// Dynamic layout - runs at request time
|
|
500
|
+
export default async function DynamicLayout({ children }) {
|
|
501
|
+
const userData = await fetchUserData(); // Dynamic data fetching
|
|
502
|
+
|
|
503
|
+
return (
|
|
504
|
+
<div className="dynamic-container">
|
|
505
|
+
<UserContext.Provider value={userData}>{children}</UserContext.Provider>
|
|
506
|
+
</div>
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export const getConfig = async () => {
|
|
511
|
+
return {
|
|
512
|
+
render: 'dynamic',
|
|
513
|
+
} as const;
|
|
514
|
+
};
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Group routes are especially powerful for organizing complex applications where different sections need different layouts, state management, or data requirements while maintaining clean URLs.
|
|
518
|
+
|
|
418
519
|
### Layouts
|
|
419
520
|
|
|
420
521
|
Layouts are created with a special `_layout.tsx` file name and wrap the entire route and its descendents. They must accept a `children` prop of type `ReactNode`. While not required, you will typically want at least a root layout.
|
|
@@ -513,6 +614,113 @@ export const getConfig = async () => {
|
|
|
513
614
|
};
|
|
514
615
|
```
|
|
515
616
|
|
|
617
|
+
### Slices
|
|
618
|
+
|
|
619
|
+
Slices are reusable components that are defined in the `src/pages/_slices` directory. They allow you to compose pages by assembling components like normal React components while specifying alternate rendering patterns.
|
|
620
|
+
|
|
621
|
+
#### Creating slices
|
|
622
|
+
|
|
623
|
+
Slices are created by placing files in the `src/pages/_slices` directory. The slice ID corresponds to the filename, and nested slices use the full path as the ID.
|
|
624
|
+
|
|
625
|
+
```
|
|
626
|
+
src/pages
|
|
627
|
+
├── _slices
|
|
628
|
+
│ ├── one.tsx
|
|
629
|
+
│ ├── two.tsx
|
|
630
|
+
│ └── nested
|
|
631
|
+
│ └── three.tsx
|
|
632
|
+
└── some-page.tsx
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Each slice file exports a default React component and a `getConfig` function that specifies the render method.
|
|
636
|
+
|
|
637
|
+
```tsx
|
|
638
|
+
// ./src/pages/_slices/one.tsx
|
|
639
|
+
|
|
640
|
+
// Create slice component
|
|
641
|
+
export default function SliceOne() {
|
|
642
|
+
return <p>🍕</p>;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export const getConfig = () => {
|
|
646
|
+
return {
|
|
647
|
+
render: 'static', // default is 'static'
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
```tsx
|
|
653
|
+
// ./src/pages/_slices/nested/three.tsx
|
|
654
|
+
|
|
655
|
+
// Create nested slice component
|
|
656
|
+
export default function SliceThree() {
|
|
657
|
+
return <p>🍰</p>;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export const getConfig = () => {
|
|
661
|
+
return {
|
|
662
|
+
render: 'dynamic',
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
#### Using slices
|
|
668
|
+
|
|
669
|
+
Slices are used in pages and layouts by importing the `Slice` component from Waku and specifying the slice ID. The `slices` array in the page's `getConfig` must include all slice IDs used on that page.
|
|
670
|
+
|
|
671
|
+
```tsx
|
|
672
|
+
// ./src/pages/some-page.tsx
|
|
673
|
+
import { Slice } from 'waku';
|
|
674
|
+
|
|
675
|
+
// Create page with slices
|
|
676
|
+
export default function SomePage() {
|
|
677
|
+
return (
|
|
678
|
+
<div>
|
|
679
|
+
<Slice id="one" />
|
|
680
|
+
<Slice id="two" />
|
|
681
|
+
<Slice id="nested/three" />
|
|
682
|
+
</div>
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
export const getConfig = () => {
|
|
687
|
+
return {
|
|
688
|
+
render: 'static',
|
|
689
|
+
slices: ['one', 'two', 'nested/three'],
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
#### Lazy slices
|
|
695
|
+
|
|
696
|
+
Lazy slices allow components to be requested independently from the page they are used on, similar to Astro's server islands feature. This is useful for components that will be dynamically rendered on otherwise static pages.
|
|
697
|
+
|
|
698
|
+
Lazy slices are marked with the `lazy` prop and can include a `fallback` component to display while loading.
|
|
699
|
+
|
|
700
|
+
```tsx
|
|
701
|
+
// ./src/pages/some-page.tsx
|
|
702
|
+
import { Slice } from 'waku';
|
|
703
|
+
|
|
704
|
+
// Create page with lazy slice
|
|
705
|
+
export default function SomePage() {
|
|
706
|
+
return (
|
|
707
|
+
<div>
|
|
708
|
+
<Slice id="one" />
|
|
709
|
+
<Slice id="two" lazy fallback={<p>Two is loading...</p>} />
|
|
710
|
+
</div>
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export const getConfig = () => {
|
|
715
|
+
return {
|
|
716
|
+
render: 'static',
|
|
717
|
+
slices: ['one'], // Note: 'two' is lazy, so it is not included
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
This allows you to have a `dynamic` slice component while keeping the rest of the page static.
|
|
723
|
+
|
|
516
724
|
## Navigation
|
|
517
725
|
|
|
518
726
|
### Link
|
|
@@ -673,7 +881,7 @@ export const getConfig = async () => {
|
|
|
673
881
|
|
|
674
882
|
### Global styles
|
|
675
883
|
|
|
676
|
-
Install any required dev dependencies (e.g., `npm i -D tailwindcss @tailwindcss/
|
|
884
|
+
Install any required dev dependencies (e.g., `npm i -D tailwindcss @tailwindcss/vite`) and set up any required configuration (e.g., `waku.config.ts`). Then create your global stylesheet (e.g., `./src/styles.css`) and import it into the root layout.
|
|
677
885
|
|
|
678
886
|
```tsx
|
|
679
887
|
// ./src/pages/_layout.tsx
|
|
@@ -696,12 +904,15 @@ export const getConfig = async () => {
|
|
|
696
904
|
```
|
|
697
905
|
|
|
698
906
|
```js
|
|
699
|
-
// ./
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
907
|
+
// ./waku.config.ts
|
|
908
|
+
import { defineConfig } from 'waku/config';
|
|
909
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
910
|
+
|
|
911
|
+
export default defineConfig({
|
|
912
|
+
vite: {
|
|
913
|
+
plugins: [tailwindcss()],
|
|
703
914
|
},
|
|
704
|
-
};
|
|
915
|
+
});
|
|
705
916
|
```
|
|
706
917
|
|
|
707
918
|
## Static assets
|
|
@@ -1215,13 +1426,6 @@ npm run build -- --with-cloudflare
|
|
|
1215
1426
|
npx wrangler dev # or deploy
|
|
1216
1427
|
```
|
|
1217
1428
|
|
|
1218
|
-
### PartyKit (experimental)
|
|
1219
|
-
|
|
1220
|
-
```sh
|
|
1221
|
-
npm run build -- --with-partykit
|
|
1222
|
-
npx partykit dev # or deploy
|
|
1223
|
-
```
|
|
1224
|
-
|
|
1225
1429
|
### Deno Deploy (experimental)
|
|
1226
1430
|
|
|
1227
1431
|
```sh
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
declare global {
|
|
3
|
+
interface ImportMeta {
|
|
4
|
+
readonly __WAKU_ORIGINAL_PATH__: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const _default: (args: {
|
|
8
|
+
handleRequest: import("../lib/types.js").Unstable_HandleRequest;
|
|
9
|
+
handleBuild: import("../lib/types.js").Unstable_HandleBuild;
|
|
10
|
+
}, options?: {
|
|
11
|
+
streaming?: boolean;
|
|
12
|
+
middlewareFns?: (() => MiddlewareHandler)[];
|
|
13
|
+
middlewareModules?: Record<string, () => Promise<{
|
|
14
|
+
default: () => MiddlewareHandler;
|
|
15
|
+
}>>;
|
|
16
|
+
} | undefined) => import("../lib/types.js").Unstable_ServerEntry["default"];
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { serveStatic } from '@hono/node-server/serve-static';
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
import * as honoAwsLambda from 'hono/aws-lambda';
|
|
6
|
+
import { unstable_constants as constants, unstable_createServerEntryAdapter as createServerEntryAdapter, unstable_honoMiddleware as honoMiddleware } from 'waku/internals';
|
|
7
|
+
function joinPath(path1, path2) {
|
|
8
|
+
const p = path.posix.join(path1, path2);
|
|
9
|
+
return p.startsWith('/') ? p : './' + p;
|
|
10
|
+
}
|
|
11
|
+
const { DIST_PUBLIC } = constants;
|
|
12
|
+
const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
|
|
13
|
+
export default createServerEntryAdapter(({ processRequest, processBuild, config, isBuild }, options)=>{
|
|
14
|
+
const { middlewareFns = [], middlewareModules = {} } = options || {};
|
|
15
|
+
const app = new Hono();
|
|
16
|
+
if (isBuild) {
|
|
17
|
+
app.use(serveStatic({
|
|
18
|
+
root: path.join(config.distDir, DIST_PUBLIC)
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
app.use(contextMiddleware());
|
|
22
|
+
for (const middlewareFn of middlewareFns){
|
|
23
|
+
app.use(middlewareFn());
|
|
24
|
+
}
|
|
25
|
+
app.use(middlewareRunner(middlewareModules));
|
|
26
|
+
app.use(rscMiddleware({
|
|
27
|
+
processRequest
|
|
28
|
+
}));
|
|
29
|
+
app.notFound((c)=>{
|
|
30
|
+
const file = path.join(config.distDir, DIST_PUBLIC, '404.html');
|
|
31
|
+
if (existsSync(file)) {
|
|
32
|
+
return c.html(readFileSync(file, 'utf8'), 404);
|
|
33
|
+
}
|
|
34
|
+
return c.text('404 Not Found', 404);
|
|
35
|
+
});
|
|
36
|
+
const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/aws-lambda-post-build.js');
|
|
37
|
+
const postBuildArg = {
|
|
38
|
+
distDir: config.distDir
|
|
39
|
+
};
|
|
40
|
+
globalThis.__WAKU_AWS_LAMBDA_HANDLE__ = options?.streaming ? honoAwsLambda.streamHandle : honoAwsLambda.handle;
|
|
41
|
+
return {
|
|
42
|
+
fetch: app.fetch,
|
|
43
|
+
build: processBuild,
|
|
44
|
+
postBuild: [
|
|
45
|
+
postBuildScript,
|
|
46
|
+
postBuildArg
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=aws-lambda.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/aws-lambda.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport 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';\n\ndeclare global {\n interface ImportMeta {\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 },\n options?: {\n streaming?: boolean;\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<\n string,\n () => Promise<{\n default: () => MiddlewareHandler;\n }>\n >;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = options || {};\n const app = new Hono();\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));\n app.use(rscMiddleware({ processRequest }));\n app.notFound((c) => {\n const file = path.join(config.distDir, DIST_PUBLIC, '404.html');\n if (existsSync(file)) {\n return c.html(readFileSync(file, 'utf8'), 404);\n }\n return c.text('404 Not Found', 404);\n });\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":["existsSync","readFileSync","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","options","middlewareFns","middlewareModules","app","use","root","distDir","middlewareFn","notFound","c","file","html","text","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","globalThis","__WAKU_AWS_LAMBDA_HANDLE__","streaming","streamHandle","handle","fetch","build","postBuild"],"mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,UAAU;AACnD,OAAOC,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;AAQxB,SAASC,SAASC,KAAa,EAAEC,KAAa;IAC5C,MAAMC,IAAIb,KAAKc,KA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ACA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
declare global {
|
|
3
|
+
interface ImportMeta {
|
|
4
|
+
readonly __WAKU_ORIGINAL_PATH__: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const _default: (args: {
|
|
8
|
+
handleRequest: import("../lib/types.js").Unstable_HandleRequest;
|
|
9
|
+
handleBuild: import("../lib/types.js").Unstable_HandleBuild;
|
|
10
|
+
}, options?: {
|
|
11
|
+
middlewareFns?: (() => MiddlewareHandler)[];
|
|
12
|
+
middlewareModules?: Record<string, () => Promise<{
|
|
13
|
+
default: () => MiddlewareHandler;
|
|
14
|
+
}>>;
|
|
15
|
+
} | undefined) => import("../lib/types.js").Unstable_ServerEntry["default"];
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { unstable_constants as constants, 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
|
+
const { DIST_PUBLIC } = constants;
|
|
9
|
+
const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
|
|
10
|
+
export default createServerEntryAdapter(({ processRequest, processBuild, config }, options)=>{
|
|
11
|
+
const { middlewareFns = [], middlewareModules = {} } = options || {};
|
|
12
|
+
const app = new Hono();
|
|
13
|
+
app.use(contextMiddleware());
|
|
14
|
+
for (const middlewareFn of middlewareFns){
|
|
15
|
+
app.use(middlewareFn());
|
|
16
|
+
}
|
|
17
|
+
app.use(middlewareRunner(middlewareModules));
|
|
18
|
+
app.use(rscMiddleware({
|
|
19
|
+
processRequest
|
|
20
|
+
}));
|
|
21
|
+
app.notFound(async (c)=>{
|
|
22
|
+
const assetsFetcher = c.env.ASSETS;
|
|
23
|
+
const url = new URL(c.req.raw.url);
|
|
24
|
+
const errorHtmlUrl = url.origin + '/404.html';
|
|
25
|
+
const notFoundStaticAssetResponse = await assetsFetcher.fetch(new URL(errorHtmlUrl));
|
|
26
|
+
if (notFoundStaticAssetResponse && notFoundStaticAssetResponse.status < 400) {
|
|
27
|
+
return c.body(notFoundStaticAssetResponse.body, 404);
|
|
28
|
+
}
|
|
29
|
+
return c.text('404 Not Found', 404);
|
|
30
|
+
});
|
|
31
|
+
const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/cloudflare-post-build.js');
|
|
32
|
+
const postBuildArg = {
|
|
33
|
+
distDir: config.distDir,
|
|
34
|
+
DIST_PUBLIC
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
fetch: app.fetch,
|
|
38
|
+
build: processBuild,
|
|
39
|
+
postBuild: [
|
|
40
|
+
postBuildScript,
|
|
41
|
+
postBuildArg
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=cloudflare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/cloudflare.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 { joinPath as joinPathOrig } from '../lib/utils/path.js';\n\ndeclare global {\n interface ImportMeta {\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 { DIST_PUBLIC } = constants;\nconst { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;\n\nexport default createServerEntryAdapter(\n (\n { processRequest, processBuild, config },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<\n string,\n () => Promise<{\n default: () => MiddlewareHandler;\n }>\n >;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = options || {};\n const app = new Hono();\n app.use(contextMiddleware());\n for (const middlewareFn of middlewareFns) {\n app.use(middlewareFn());\n }\n app.use(middlewareRunner(middlewareModules));\n app.use(rscMiddleware({ processRequest }));\n app.notFound(async (c) => {\n const assetsFetcher = (c.env as any).ASSETS;\n const url = new URL(c.req.raw.url);\n const errorHtmlUrl = url.origin + '/404.html';\n const notFoundStaticAssetResponse = await assetsFetcher.fetch(\n new URL(errorHtmlUrl),\n );\n if (\n notFoundStaticAssetResponse &&\n notFoundStaticAssetResponse.status < 400\n ) {\n return c.body(notFoundStaticAssetResponse.body, 404);\n }\n return c.text('404 Not Found', 404);\n });\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 DIST_PUBLIC,\n };\n return {\n fetch: app.fetch,\n build: processBuild,\n postBuild: [postBuildScript, postBuildArg],\n };\n },\n);\n"],"names":["Hono","unstable_constants","constants","unstable_createServerEntryAdapter","createServerEntryAdapter","unstable_honoMiddleware","honoMiddleware","joinPath","joinPathOrig","path1","path2","p","startsWith","DIST_PUBLIC","contextMiddleware","rscMiddleware","middlewareRunner","processRequest","processBuild","config","options","middlewareFns","middlewareModules","app","use","middlewareFn","notFound","c","assetsFetcher","env","ASSETS","url","URL","req","raw","errorHtmlUrl","origin","notFoundStaticAssetResponse","fetch","status","body","text","postBuildScript","__WAKU_ORIGINAL_PATH__","postBuildArg","distDir","build","postBuild"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAE5B,SACEC,sBAAsBC,SAAS,EAC/BC,qCAAqCC,wBAAwB,E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LyB,OAAOf,IAAIe,KAAK;QAChBQ,OAAO5B;QACP6B,WAAW;YAACL;YAAiBE;SAAa;IAC5C;AACF,GACA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
declare global {
|
|
3
|
+
interface ImportMeta {
|
|
4
|
+
readonly __WAKU_ORIGINAL_PATH__: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare const _default: (args: {
|
|
8
|
+
handleRequest: import("../lib/types.js").Unstable_HandleRequest;
|
|
9
|
+
handleBuild: import("../lib/types.js").Unstable_HandleBuild;
|
|
10
|
+
}, options?: {
|
|
11
|
+
middlewareFns?: (() => MiddlewareHandler)[];
|
|
12
|
+
middlewareModules?: Record<string, () => Promise<{
|
|
13
|
+
default: () => MiddlewareHandler;
|
|
14
|
+
}>>;
|
|
15
|
+
} | undefined) => import("../lib/types.js").Unstable_ServerEntry["default"];
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
// FIXME hopefully we should avoid bundling this
|
|
3
|
+
import { Hono as HonoForDevAndBuild } from 'hono';
|
|
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
|
+
const { DIST_PUBLIC } = constants;
|
|
10
|
+
const { contextMiddleware, rscMiddleware, middlewareRunner } = honoMiddleware;
|
|
11
|
+
export default createServerEntryAdapter(({ processRequest, processBuild, config }, options)=>{
|
|
12
|
+
const { middlewareFns = [], middlewareModules = {} } = options || {};
|
|
13
|
+
const { __WAKU_DENO_ADAPTER_HONO__: Hono = HonoForDevAndBuild, __WAKU_DENO_ADAPTER_SERVE_STATIC__: serveStatic, __WAKU_DENO_ADAPTER_NOT_FOUND_FN__: notFoundFn } = globalThis;
|
|
14
|
+
const app = new Hono();
|
|
15
|
+
if (serveStatic) {
|
|
16
|
+
app.use(serveStatic({
|
|
17
|
+
root: path.join(config.distDir, DIST_PUBLIC)
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
app.use(contextMiddleware());
|
|
21
|
+
for (const middlewareFn of middlewareFns){
|
|
22
|
+
app.use(middlewareFn());
|
|
23
|
+
}
|
|
24
|
+
app.use(middlewareRunner(middlewareModules));
|
|
25
|
+
app.use(rscMiddleware({
|
|
26
|
+
processRequest
|
|
27
|
+
}));
|
|
28
|
+
if (notFoundFn) {
|
|
29
|
+
app.notFound(notFoundFn);
|
|
30
|
+
}
|
|
31
|
+
const postBuildScript = joinPath(import.meta.__WAKU_ORIGINAL_PATH__, '../lib/deno-post-build.js');
|
|
32
|
+
const postBuildArg = {
|
|
33
|
+
distDir: config.distDir,
|
|
34
|
+
DIST_PUBLIC
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
fetch: app.fetch,
|
|
38
|
+
build: processBuild,
|
|
39
|
+
postBuild: [
|
|
40
|
+
postBuildScript,
|
|
41
|
+
postBuildArg
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=deno.js.map
|
|
@@ -0,0 +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 {\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 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 },\n options?: {\n middlewareFns?: (() => MiddlewareHandler)[];\n middlewareModules?: Record<\n string,\n () => Promise<{\n default: () => MiddlewareHandler;\n }>\n >;\n },\n ) => {\n const { middlewareFns = [], middlewareModules = {} } = options || {};\n const {\n __WAKU_DENO_ADAPTER_HONO__: Hono = HonoForDevAndBuild,\n __WAKU_DENO_ADAPTER_SERVE_STATIC__: serveStatic,\n __WAKU_DENO_ADAPTER_NOT_FOUND_FN__: notFoundFn,\n } = globalThis as any;\n const app = new Hono();\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));\n app.use(rscMiddleware({ processRequest }));\n if (notFoundFn) {\n app.notFound(notFoundFn);\n }\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 DIST_PUBLIC,\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","options","middlewareFns","middlewareModules","__WAKU_DENO_ADAPTER_HONO__","__WAKU_DENO_ADAPTER_SERVE_STATIC__","serveStatic","__WAKU_DENO_ADAPTER_NOT_FOUND_FN__","notFoundFn","globalThis","app","use","root","distDir","middlewareFn","notFound","postBuildScript","__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AOa,OAAO;QACvBnB;IACF;IACA,OAAO;QACLyB,OAAOT,IAAIS,KAAK;QAChBC,OAAOrB;QACPsB,WAAW;YAACL;YAAiBE;SAAa;IAC5C;AACF,GACA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export default async function postBuild({ distDir }) {
|
|
4
|
+
const SERVE_JS = 'serve-aws-lambda.js';
|
|
5
|
+
const serveCode = `
|
|
6
|
+
import { INTERNAL_runFetch } from './server/index.js';
|
|
7
|
+
|
|
8
|
+
const handle = globalThis.__WAKU_AWS_LAMBDA_HANDLE__;
|
|
9
|
+
|
|
10
|
+
export const handler = handle({
|
|
11
|
+
fetch: (req, ...args) => INTERNAL_runFetch(process.env, req, ...args),
|
|
12
|
+
});
|
|
13
|
+
`;
|
|
14
|
+
writeFileSync(path.join(distDir, SERVE_JS), serveCode);
|
|
15
|
+
writeFileSync(path.join(distDir, 'package.json'), JSON.stringify({
|
|
16
|
+
type: 'module'
|
|
17
|
+
}, null, 2));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=aws-lambda-post-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/lib/aws-lambda-post-build.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport default async function postBuild({ distDir }: { distDir: string }) {\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"],"names":["writeFileSync","path","postBuild","distDir","SERVE_JS","serveCode","join","JSON","stringify","type"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,OAAOC,UAAU,YAAY;AAE7B,eAAe,eAAeC,UAAU,EAAEC,OAAO,EAAuB;IACtE,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"}
|