create-waku 0.5.0 → 0.5.2

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 (109) hide show
  1. package/dist/cli.js +7744 -0
  2. package/package.json +2 -1
  3. package/src/cli.ts +3 -3
  4. package/template/01_counter/node_modules/.bin/tsc +17 -0
  5. package/template/01_counter/node_modules/.bin/tsserver +17 -0
  6. package/template/01_counter/node_modules/.bin/waku +17 -0
  7. package/template/01_counter/package.json +23 -0
  8. package/template/01_counter/src/components/App.tsx +13 -0
  9. package/template/01_counter/src/components/Counter.tsx +14 -0
  10. package/template/01_counter/src/entries.tsx +34 -0
  11. package/template/01_counter/src/index.html +36 -0
  12. package/template/01_counter/src/main.tsx +13 -0
  13. package/template/01_counter/tsconfig.json +13 -0
  14. package/template/02_async/node_modules/.bin/tsc +17 -0
  15. package/template/02_async/node_modules/.bin/tsserver +17 -0
  16. package/template/02_async/node_modules/.bin/waku +17 -0
  17. package/template/02_async/package.json +23 -0
  18. package/template/02_async/src/components/App.tsx +35 -0
  19. package/template/02_async/src/components/Counter.tsx +14 -0
  20. package/template/02_async/src/entries.tsx +34 -0
  21. package/template/02_async/src/index.html +36 -0
  22. package/template/02_async/src/main.tsx +24 -0
  23. package/template/02_async/tsconfig.json +13 -0
  24. package/template/02_async/vite.config.ts +16 -0
  25. package/template/03_promise/node_modules/.bin/tsc +17 -0
  26. package/template/03_promise/node_modules/.bin/tsserver +17 -0
  27. package/template/03_promise/node_modules/.bin/waku +17 -0
  28. package/template/03_promise/package.json +23 -0
  29. package/template/03_promise/src/components/App.tsx +18 -0
  30. package/template/03_promise/src/components/Counter.tsx +34 -0
  31. package/template/03_promise/src/entries.tsx +39 -0
  32. package/template/03_promise/src/index.html +36 -0
  33. package/template/03_promise/src/main.tsx +15 -0
  34. package/template/03_promise/tsconfig.json +13 -0
  35. package/template/04_callserver/node_modules/.bin/tsc +17 -0
  36. package/template/04_callserver/node_modules/.bin/tsserver +17 -0
  37. package/template/04_callserver/node_modules/.bin/waku +17 -0
  38. package/template/04_callserver/package.json +23 -0
  39. package/template/04_callserver/src/components/App.tsx +18 -0
  40. package/template/04_callserver/src/components/Counter.tsx +31 -0
  41. package/template/04_callserver/src/components/funcs.ts +3 -0
  42. package/template/04_callserver/src/entries.tsx +34 -0
  43. package/template/04_callserver/src/index.html +36 -0
  44. package/template/04_callserver/src/main.tsx +13 -0
  45. package/template/04_callserver/tsconfig.json +13 -0
  46. package/template/05_mutation/node_modules/.bin/tsc +17 -0
  47. package/template/05_mutation/node_modules/.bin/tsserver +17 -0
  48. package/template/05_mutation/node_modules/.bin/waku +17 -0
  49. package/template/05_mutation/package.json +23 -0
  50. package/template/05_mutation/src/components/App.tsx +21 -0
  51. package/template/05_mutation/src/components/Counter.tsx +24 -0
  52. package/template/05_mutation/src/components/funcs.ts +13 -0
  53. package/template/05_mutation/src/entries.tsx +34 -0
  54. package/template/05_mutation/src/index.html +36 -0
  55. package/template/05_mutation/src/main.tsx +13 -0
  56. package/template/05_mutation/tsconfig.json +13 -0
  57. package/template/06_nesting/node_modules/.bin/tsc +17 -0
  58. package/template/06_nesting/node_modules/.bin/tsserver +17 -0
  59. package/template/06_nesting/node_modules/.bin/waku +17 -0
  60. package/template/06_nesting/package.json +23 -0
  61. package/template/06_nesting/src/components/App.tsx +13 -0
  62. package/template/06_nesting/src/components/Counter.tsx +32 -0
  63. package/template/06_nesting/src/components/InnerApp.tsx +13 -0
  64. package/template/06_nesting/src/entries.tsx +49 -0
  65. package/template/06_nesting/src/index.html +36 -0
  66. package/template/06_nesting/src/main.tsx +13 -0
  67. package/template/06_nesting/tsconfig.json +13 -0
  68. package/template/07_router/node_modules/.bin/glob +17 -0
  69. package/template/07_router/node_modules/.bin/tsc +17 -0
  70. package/template/07_router/node_modules/.bin/tsserver +17 -0
  71. package/template/07_router/node_modules/.bin/waku +17 -0
  72. package/template/07_router/package.json +24 -0
  73. package/template/07_router/src/components/Counter.tsx +17 -0
  74. package/template/07_router/src/components/ErrorBoundary.tsx +28 -0
  75. package/template/07_router/src/entries.tsx +38 -0
  76. package/template/07_router/src/index.html +36 -0
  77. package/template/07_router/src/main.tsx +15 -0
  78. package/template/07_router/src/routes/bar/page.tsx +10 -0
  79. package/template/07_router/src/routes/foo/page.tsx +10 -0
  80. package/template/07_router/src/routes/layout.tsx +54 -0
  81. package/template/07_router/src/routes/nested/baz/page.tsx +7 -0
  82. package/template/07_router/src/routes/nested/layout.tsx +13 -0
  83. package/template/07_router/src/routes/nested/qux/page.tsx +7 -0
  84. package/template/07_router/src/routes/page.tsx +8 -0
  85. package/template/07_router/tsconfig.json +13 -0
  86. package/template/07_router/vite.config.ts +22 -0
  87. package/template/08_cookies/dev.js +29 -0
  88. package/template/08_cookies/node_modules/.bin/tsc +17 -0
  89. package/template/08_cookies/node_modules/.bin/tsserver +17 -0
  90. package/template/08_cookies/node_modules/.bin/waku +17 -0
  91. package/template/08_cookies/package.json +24 -0
  92. package/template/08_cookies/src/components/App.tsx +16 -0
  93. package/template/08_cookies/src/components/Counter.tsx +14 -0
  94. package/template/08_cookies/src/entries.tsx +38 -0
  95. package/template/08_cookies/src/index.html +36 -0
  96. package/template/08_cookies/src/main.tsx +13 -0
  97. package/template/08_cookies/start.js +36 -0
  98. package/template/08_cookies/tsconfig.json +13 -0
  99. package/template/09_cssmodules/node_modules/.bin/tsc +17 -0
  100. package/template/09_cssmodules/node_modules/.bin/tsserver +17 -0
  101. package/template/09_cssmodules/node_modules/.bin/waku +17 -0
  102. package/template/09_cssmodules/package.json +23 -0
  103. package/template/09_cssmodules/src/components/App.module.css +3 -0
  104. package/template/09_cssmodules/src/components/App.tsx +15 -0
  105. package/template/09_cssmodules/src/components/Counter.tsx +14 -0
  106. package/template/09_cssmodules/src/entries.tsx +34 -0
  107. package/template/09_cssmodules/src/index.html +36 -0
  108. package/template/09_cssmodules/src/main.tsx +13 -0
  109. package/template/09_cssmodules/tsconfig.json +13 -0
@@ -0,0 +1,39 @@
1
+ import { lazy } from "react";
2
+
3
+ import { defineEntries } from "waku/server";
4
+ import { Children } from "waku/client";
5
+
6
+ const App = lazy(() => import("./components/App.js"));
7
+
8
+ export default defineEntries(
9
+ // renderEntries
10
+ async (input) => {
11
+ return {
12
+ App: (
13
+ <App name={input || "Waku"}>
14
+ <Children />
15
+ </App>
16
+ ),
17
+ };
18
+ },
19
+ // getBuildConfig
20
+ async () => {
21
+ return {
22
+ "/": {
23
+ entries: [[""]],
24
+ },
25
+ };
26
+ },
27
+ // getSsrConfig
28
+ async () => ({
29
+ getInput: (pathStr) => {
30
+ switch (pathStr) {
31
+ case "/":
32
+ return "";
33
+ default:
34
+ return null;
35
+ }
36
+ },
37
+ filter: (elements) => elements.App,
38
+ }),
39
+ );
@@ -0,0 +1,36 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Waku example</title>
6
+ <style>
7
+ @keyframes spinner {
8
+ to {
9
+ transform: rotate(360deg);
10
+ }
11
+ }
12
+ .spinner {
13
+ width: 36px;
14
+ height: 36px;
15
+ margin: auto;
16
+ border: 2px solid #ddd;
17
+ border-top-color: #222;
18
+ border-radius: 50%;
19
+ animation: spinner 1s linear infinite;
20
+ }
21
+ #root > .spinner {
22
+ margin-top: calc(50% - 18px);
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <!--placeholder1-->
28
+ <div id="root">
29
+ <div class="spinner"></div>
30
+ </div>
31
+ <!--/placeholder1-->
32
+ <script src="/main.tsx" async type="module"></script>
33
+ <!--placeholder2-->
34
+ <!--/placeholder2-->
35
+ </body>
36
+ </html>
@@ -0,0 +1,15 @@
1
+ import { StrictMode } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { Root, Slot } from "waku/client";
4
+
5
+ const rootElement = (
6
+ <StrictMode>
7
+ <Root>
8
+ <Slot id="App">
9
+ <h3>A client element</h3>
10
+ </Slot>
11
+ </Root>
12
+ </StrictMode>
13
+ );
14
+
15
+ createRoot(document.getElementById("root")!).render(rootElement);
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "esnext",
5
+ "downlevelIteration": true,
6
+ "esModuleInterop": true,
7
+ "module": "nodenext",
8
+ "skipLibCheck": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "jsx": "react-jsx"
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../packages/waku/dist/cli.js" "$@"
15
+ else
16
+ exec node "$basedir/../../../../packages/waku/dist/cli.js" "$@"
17
+ fi
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "waku-example",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "waku dev --with-ssr",
8
+ "build": "waku build",
9
+ "start": "waku start --with-ssr"
10
+ },
11
+ "dependencies": {
12
+ "express": "^4.18.2",
13
+ "react": "18.3.0-canary-7118f5dd7-20230705",
14
+ "react-dom": "18.3.0-canary-7118f5dd7-20230705",
15
+ "react-server-dom-webpack": "18.3.0-canary-7118f5dd7-20230705",
16
+ "waku": "0.15.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.2.21",
20
+ "@types/react-dom": "^18.2.7",
21
+ "typescript": "^5.2.2"
22
+ }
23
+ }
@@ -0,0 +1,18 @@
1
+ import { Counter } from "./Counter.js";
2
+ import { greet } from "./funcs.js";
3
+
4
+ type ServerFunction<T> = T extends (...args: infer A) => infer R
5
+ ? (...args: A) => Promise<R>
6
+ : never;
7
+
8
+ const App = ({ name }: { name: string }) => {
9
+ return (
10
+ <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
11
+ <h1>Hello {name}!!</h1>
12
+ <h3>This is a server component.</h3>
13
+ <Counter greet={greet as unknown as ServerFunction<typeof greet>} />
14
+ </div>
15
+ );
16
+ };
17
+
18
+ export default App;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import { useState, useTransition } from "react";
4
+
5
+ export const Counter = ({
6
+ greet,
7
+ }: {
8
+ greet: (name: string) => Promise<string>;
9
+ }) => {
10
+ const [count, setCount] = useState(0);
11
+ const [text, setText] = useState<string | Promise<string>>("");
12
+ const [isPending, startTransition] = useTransition();
13
+ const handleClick = () => {
14
+ startTransition(() => {
15
+ setText(greet("c=" + count));
16
+ });
17
+ };
18
+ return (
19
+ <div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
20
+ <p>Count: {count}</p>
21
+ <button onClick={() => setCount((c) => c + 1)}>Increment</button>
22
+ <p>
23
+ <button onClick={handleClick}>
24
+ greet(&quot;c=&quot; + count) = {text as string}
25
+ </button>{" "}
26
+ {isPending ? "Pending..." : ""}
27
+ </p>
28
+ <h3>This is a client component.</h3>
29
+ </div>
30
+ );
31
+ };
@@ -0,0 +1,3 @@
1
+ "use server";
2
+
3
+ export const greet = (name: string) => `Hello ${name} from server!`;
@@ -0,0 +1,34 @@
1
+ import { lazy } from "react";
2
+
3
+ import { defineEntries } from "waku/server";
4
+
5
+ const App = lazy(() => import("./components/App.js"));
6
+
7
+ export default defineEntries(
8
+ // renderEntries
9
+ async (input) => {
10
+ return {
11
+ App: <App name={input || "Waku"} />,
12
+ };
13
+ },
14
+ // getBuildConfig
15
+ async () => {
16
+ return {
17
+ "/": {
18
+ entries: [[""]],
19
+ },
20
+ };
21
+ },
22
+ // getSsrConfig
23
+ async () => ({
24
+ getInput: (pathStr) => {
25
+ switch (pathStr) {
26
+ case "/":
27
+ return "";
28
+ default:
29
+ return null;
30
+ }
31
+ },
32
+ filter: (elements) => elements.App,
33
+ }),
34
+ );
@@ -0,0 +1,36 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Waku example</title>
6
+ <style>
7
+ @keyframes spinner {
8
+ to {
9
+ transform: rotate(360deg);
10
+ }
11
+ }
12
+ .spinner {
13
+ width: 36px;
14
+ height: 36px;
15
+ margin: auto;
16
+ border: 2px solid #ddd;
17
+ border-top-color: #222;
18
+ border-radius: 50%;
19
+ animation: spinner 1s linear infinite;
20
+ }
21
+ #root > .spinner {
22
+ margin-top: calc(50% - 18px);
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <!--placeholder1-->
28
+ <div id="root">
29
+ <div class="spinner"></div>
30
+ </div>
31
+ <!--/placeholder1-->
32
+ <script src="/main.tsx" async type="module"></script>
33
+ <!--placeholder2-->
34
+ <!--/placeholder2-->
35
+ </body>
36
+ </html>
@@ -0,0 +1,13 @@
1
+ import { StrictMode } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { Root, Slot } from "waku/client";
4
+
5
+ const rootElement = (
6
+ <StrictMode>
7
+ <Root>
8
+ <Slot id="App" />
9
+ </Root>
10
+ </StrictMode>
11
+ );
12
+
13
+ createRoot(document.getElementById("root")!).render(rootElement);
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "esnext",
5
+ "downlevelIteration": true,
6
+ "esModuleInterop": true,
7
+ "module": "nodenext",
8
+ "skipLibCheck": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "jsx": "react-jsx"
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../packages/waku/dist/cli.js" "$@"
15
+ else
16
+ exec node "$basedir/../../../../packages/waku/dist/cli.js" "$@"
17
+ fi
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "waku-example",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "waku dev --with-ssr",
8
+ "build": "waku build",
9
+ "start": "waku start --with-ssr"
10
+ },
11
+ "dependencies": {
12
+ "express": "^4.18.2",
13
+ "react": "18.3.0-canary-7118f5dd7-20230705",
14
+ "react-dom": "18.3.0-canary-7118f5dd7-20230705",
15
+ "react-server-dom-webpack": "18.3.0-canary-7118f5dd7-20230705",
16
+ "waku": "0.15.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.2.21",
20
+ "@types/react-dom": "^18.2.7",
21
+ "typescript": "^5.2.2"
22
+ }
23
+ }
@@ -0,0 +1,21 @@
1
+ import { Counter } from "./Counter.js";
2
+ import { getCounter, increment } from "./funcs.js";
3
+
4
+ type ServerFunction<T> = T extends (...args: infer A) => infer R
5
+ ? (...args: A) => Promise<R>
6
+ : never;
7
+
8
+ const App = ({ name }: { name: string }) => {
9
+ return (
10
+ <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
11
+ <h1>Hello {name}!!</h1>
12
+ <h3>This is a server component.</h3>
13
+ <p>Server counter: {getCounter()}</p>
14
+ <Counter
15
+ increment={increment as unknown as ServerFunction<typeof increment>}
16
+ />
17
+ </div>
18
+ );
19
+ };
20
+
21
+ export default App;
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ import { useState, useTransition } from "react";
4
+
5
+ export const Counter = ({ increment }: { increment: () => void }) => {
6
+ const [count, setCount] = useState(0);
7
+ const [isPending, startTransition] = useTransition();
8
+ const handleClick = () => {
9
+ startTransition(() => {
10
+ increment();
11
+ });
12
+ };
13
+ return (
14
+ <div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
15
+ <p>Count: {count}</p>
16
+ <button onClick={() => setCount((c) => c + 1)}>Increment</button>
17
+ <p>
18
+ <button onClick={handleClick}>Increment server counter</button>{" "}
19
+ {isPending ? "Pending..." : ""}
20
+ </p>
21
+ <h3>This is a client component.</h3>
22
+ </div>
23
+ );
24
+ };
@@ -0,0 +1,13 @@
1
+ "use server";
2
+
3
+ import { rerender } from "waku/server";
4
+
5
+ // module state on server
6
+ let counter = 0;
7
+
8
+ export const getCounter = () => counter;
9
+
10
+ export const increment = () => {
11
+ counter += 1;
12
+ rerender("Waku");
13
+ };
@@ -0,0 +1,34 @@
1
+ import { lazy } from "react";
2
+
3
+ import { defineEntries } from "waku/server";
4
+
5
+ const App = lazy(() => import("./components/App.js"));
6
+
7
+ export default defineEntries(
8
+ // renderEntries
9
+ async (input) => {
10
+ return {
11
+ App: <App name={input || "Waku"} />,
12
+ };
13
+ },
14
+ // getBuildConfig
15
+ async () => {
16
+ return {
17
+ "/": {
18
+ entries: [[""]],
19
+ },
20
+ };
21
+ },
22
+ // getSsrConfig
23
+ async () => ({
24
+ getInput: (pathStr) => {
25
+ switch (pathStr) {
26
+ case "/":
27
+ return "";
28
+ default:
29
+ return null;
30
+ }
31
+ },
32
+ filter: (elements) => elements.App,
33
+ }),
34
+ );
@@ -0,0 +1,36 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Waku example</title>
6
+ <style>
7
+ @keyframes spinner {
8
+ to {
9
+ transform: rotate(360deg);
10
+ }
11
+ }
12
+ .spinner {
13
+ width: 36px;
14
+ height: 36px;
15
+ margin: auto;
16
+ border: 2px solid #ddd;
17
+ border-top-color: #222;
18
+ border-radius: 50%;
19
+ animation: spinner 1s linear infinite;
20
+ }
21
+ #root > .spinner {
22
+ margin-top: calc(50% - 18px);
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <!--placeholder1-->
28
+ <div id="root">
29
+ <div class="spinner"></div>
30
+ </div>
31
+ <!--/placeholder1-->
32
+ <script src="/main.tsx" async type="module"></script>
33
+ <!--placeholder2-->
34
+ <!--/placeholder2-->
35
+ </body>
36
+ </html>
@@ -0,0 +1,13 @@
1
+ import { StrictMode } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { Root, Slot } from "waku/client";
4
+
5
+ const rootElement = (
6
+ <StrictMode>
7
+ <Root>
8
+ <Slot id="App" />
9
+ </Root>
10
+ </StrictMode>
11
+ );
12
+
13
+ createRoot(document.getElementById("root")!).render(rootElement);
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "esnext",
5
+ "downlevelIteration": true,
6
+ "esModuleInterop": true,
7
+ "module": "nodenext",
8
+ "skipLibCheck": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "jsx": "react-jsx"
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/typescript@5.2.2/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/home/runner/work/waku/waku/packages/waku/dist/node_modules:/home/runner/work/waku/waku/packages/waku/node_modules:/home/runner/work/waku/waku/packages/node_modules:/home/runner/work/waku/waku/node_modules:/home/runner/work/waku/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../packages/waku/dist/cli.js" "$@"
15
+ else
16
+ exec node "$basedir/../../../../packages/waku/dist/cli.js" "$@"
17
+ fi