create-waku 0.5.3 → 0.6.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.
Files changed (179) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +118 -7731
  4. package/package.json +5 -6
  5. package/src/cli.ts +3 -7
  6. package/template/01_counter/dist/components/App.js +6 -0
  7. package/template/01_counter/dist/components/Counter.js +7 -0
  8. package/template/01_counter/dist/entries.js +31 -0
  9. package/template/01_counter/dist/main.js +6 -0
  10. package/template/01_counter/node_modules/.bin/tsc +2 -2
  11. package/template/01_counter/node_modules/.bin/tsserver +2 -2
  12. package/template/01_counter/node_modules/.bin/waku +2 -2
  13. package/template/01_counter/package.json +6 -6
  14. package/template/01_counter/src/entries.tsx +2 -2
  15. package/template/01_counter/tsconfig.json +3 -1
  16. package/template/02_async/dist/.tsbuildinfo +1 -0
  17. package/template/02_async/dist/node/.tsbuildinfo +1 -0
  18. package/template/02_async/dist/node/vite.config.d.ts +2 -0
  19. package/template/02_async/dist/node/vite.config.js +14 -0
  20. package/template/02_async/dist/src/components/App.d.ts +4 -0
  21. package/template/02_async/dist/src/components/App.js +16 -0
  22. package/template/02_async/dist/src/components/Counter.d.ts +1 -0
  23. package/template/02_async/dist/src/components/Counter.js +7 -0
  24. package/template/02_async/dist/src/entries.d.ts +6 -0
  25. package/template/02_async/dist/src/entries.js +31 -0
  26. package/template/02_async/dist/src/main.d.ts +1 -0
  27. package/template/02_async/dist/src/main.js +15 -0
  28. package/template/02_async/node_modules/.bin/tsc +2 -2
  29. package/template/02_async/node_modules/.bin/tsserver +2 -2
  30. package/template/02_async/node_modules/.bin/waku +2 -2
  31. package/template/02_async/package.json +6 -6
  32. package/template/02_async/src/components/App.tsx +2 -0
  33. package/template/02_async/src/entries.tsx +2 -2
  34. package/template/02_async/tsconfig.json +11 -2
  35. package/template/02_async/tsconfig.node.json +9 -0
  36. package/template/03_promise/dist/components/App.js +9 -0
  37. package/template/03_promise/dist/components/Counter.js +8 -0
  38. package/template/03_promise/dist/entries.js +32 -0
  39. package/template/03_promise/dist/main.js +6 -0
  40. package/template/03_promise/node_modules/.bin/tsc +2 -2
  41. package/template/03_promise/node_modules/.bin/tsserver +2 -2
  42. package/template/03_promise/node_modules/.bin/waku +2 -2
  43. package/template/03_promise/package.json +6 -6
  44. package/template/03_promise/src/entries.tsx +2 -2
  45. package/template/03_promise/tsconfig.json +3 -1
  46. package/template/04_callserver/dist/components/App.js +7 -0
  47. package/template/04_callserver/dist/components/Counter.js +14 -0
  48. package/template/04_callserver/dist/components/funcs.js +2 -0
  49. package/template/04_callserver/dist/entries.js +31 -0
  50. package/template/04_callserver/dist/main.js +6 -0
  51. package/template/04_callserver/node_modules/.bin/tsc +2 -2
  52. package/template/04_callserver/node_modules/.bin/tsserver +2 -2
  53. package/template/04_callserver/node_modules/.bin/waku +2 -2
  54. package/template/04_callserver/package.json +6 -6
  55. package/template/04_callserver/src/entries.tsx +2 -2
  56. package/template/04_callserver/tsconfig.json +3 -1
  57. package/template/05_mutation/dist/components/App.js +7 -0
  58. package/template/05_mutation/dist/components/Counter.js +13 -0
  59. package/template/05_mutation/dist/components/funcs.js +9 -0
  60. package/template/05_mutation/dist/entries.js +31 -0
  61. package/template/05_mutation/dist/main.js +6 -0
  62. package/template/05_mutation/node_modules/.bin/tsc +2 -2
  63. package/template/05_mutation/node_modules/.bin/tsserver +2 -2
  64. package/template/05_mutation/node_modules/.bin/waku +2 -2
  65. package/template/05_mutation/package.json +6 -6
  66. package/template/05_mutation/src/entries.tsx +2 -2
  67. package/template/05_mutation/tsconfig.json +3 -1
  68. package/template/06_nesting/dist/components/App.js +6 -0
  69. package/template/06_nesting/dist/components/Counter.js +24 -0
  70. package/template/06_nesting/dist/components/InnerApp.js +6 -0
  71. package/template/06_nesting/dist/entries.js +45 -0
  72. package/template/06_nesting/dist/main.js +6 -0
  73. package/template/06_nesting/node_modules/.bin/tsc +2 -2
  74. package/template/06_nesting/node_modules/.bin/tsserver +2 -2
  75. package/template/06_nesting/node_modules/.bin/waku +2 -2
  76. package/template/06_nesting/package.json +6 -6
  77. package/template/06_nesting/src/entries.tsx +2 -2
  78. package/template/06_nesting/tsconfig.json +3 -1
  79. package/template/07_router/dist/.tsbuildinfo +1 -0
  80. package/template/07_router/dist/node/.tsbuildinfo +1 -0
  81. package/template/07_router/dist/node/vite.config.d.ts +2 -0
  82. package/template/07_router/dist/node/vite.config.js +16 -0
  83. package/template/07_router/dist/src/components/Counter.d.ts +1 -0
  84. package/template/07_router/dist/src/components/Counter.js +8 -0
  85. package/template/07_router/dist/src/components/ErrorBoundary.d.ts +7 -0
  86. package/template/07_router/dist/src/components/ErrorBoundary.js +17 -0
  87. package/template/07_router/dist/src/entries.d.ts +6 -0
  88. package/template/07_router/dist/src/entries.js +29 -0
  89. package/template/07_router/dist/src/main.d.ts +1 -0
  90. package/template/07_router/dist/src/main.js +7 -0
  91. package/template/07_router/dist/src/routes/bar/page.d.ts +2 -0
  92. package/template/07_router/dist/src/routes/bar/page.js +4 -0
  93. package/template/07_router/dist/src/routes/foo/page.d.ts +2 -0
  94. package/template/07_router/dist/src/routes/foo/page.js +4 -0
  95. package/template/07_router/dist/src/routes/layout.d.ts +5 -0
  96. package/template/07_router/dist/src/routes/layout.js +9 -0
  97. package/template/07_router/dist/src/routes/nested/baz/page.d.ts +2 -0
  98. package/template/07_router/dist/src/routes/nested/baz/page.js +3 -0
  99. package/template/07_router/dist/src/routes/nested/layout.d.ts +5 -0
  100. package/template/07_router/dist/src/routes/nested/layout.js +4 -0
  101. package/template/07_router/dist/src/routes/nested/qux/page.d.ts +2 -0
  102. package/template/07_router/dist/src/routes/nested/qux/page.js +3 -0
  103. package/template/07_router/dist/src/routes/page.d.ts +2 -0
  104. package/template/07_router/dist/src/routes/page.js +3 -0
  105. package/template/07_router/node_modules/.bin/glob +4 -4
  106. package/template/07_router/node_modules/.bin/tsc +2 -2
  107. package/template/07_router/node_modules/.bin/tsserver +2 -2
  108. package/template/07_router/node_modules/.bin/waku +2 -2
  109. package/template/07_router/package.json +7 -7
  110. package/template/07_router/src/entries.tsx +1 -1
  111. package/template/07_router/tsconfig.json +11 -2
  112. package/template/07_router/tsconfig.node.json +9 -0
  113. package/template/08_cookies/dev.js +1 -1
  114. package/template/08_cookies/dist/components/App.js +8 -0
  115. package/template/08_cookies/dist/components/Counter.js +7 -0
  116. package/template/08_cookies/dist/entries.js +22 -0
  117. package/template/08_cookies/dist/main.js +6 -0
  118. package/template/08_cookies/node_modules/.bin/tsc +2 -2
  119. package/template/08_cookies/node_modules/.bin/tsserver +2 -2
  120. package/template/08_cookies/node_modules/.bin/waku +2 -2
  121. package/template/08_cookies/package.json +6 -6
  122. package/template/08_cookies/src/entries.tsx +2 -2
  123. package/template/08_cookies/tsconfig.json +3 -1
  124. package/template/09_cssmodules/dist/components/App.js +8 -0
  125. package/template/09_cssmodules/dist/components/Counter.js +7 -0
  126. package/template/09_cssmodules/dist/entries.js +31 -0
  127. package/template/09_cssmodules/dist/main.js +6 -0
  128. package/template/09_cssmodules/node_modules/.bin/tsc +2 -2
  129. package/template/09_cssmodules/node_modules/.bin/tsserver +2 -2
  130. package/template/09_cssmodules/node_modules/.bin/waku +2 -2
  131. package/template/09_cssmodules/package.json +6 -6
  132. package/template/09_cssmodules/src/entries.tsx +2 -2
  133. package/template/09_cssmodules/tsconfig.json +3 -1
  134. package/template/10_dynamicroute/dist/.tsbuildinfo +1 -0
  135. package/template/10_dynamicroute/dist/node/.tsbuildinfo +1 -0
  136. package/template/10_dynamicroute/dist/node/vite.config.d.ts +2 -0
  137. package/template/10_dynamicroute/dist/node/vite.config.js +16 -0
  138. package/template/10_dynamicroute/dist/src/entries.d.ts +6 -0
  139. package/template/10_dynamicroute/dist/src/entries.js +61 -0
  140. package/template/10_dynamicroute/dist/src/main.d.ts +1 -0
  141. package/template/10_dynamicroute/dist/src/main.js +6 -0
  142. package/template/10_dynamicroute/dist/src/routes/[name]/page.d.ts +4 -0
  143. package/template/10_dynamicroute/dist/src/routes/[name]/page.js +3 -0
  144. package/template/10_dynamicroute/dist/src/routes/layout.d.ts +5 -0
  145. package/template/10_dynamicroute/dist/src/routes/layout.js +4 -0
  146. package/template/10_dynamicroute/dist/src/routes/page.d.ts +2 -0
  147. package/template/10_dynamicroute/dist/src/routes/page.js +3 -0
  148. package/template/10_dynamicroute/node_modules/.bin/glob +17 -0
  149. package/template/10_dynamicroute/node_modules/.bin/tsc +17 -0
  150. package/template/10_dynamicroute/node_modules/.bin/tsserver +17 -0
  151. package/template/10_dynamicroute/node_modules/.bin/waku +17 -0
  152. package/template/10_dynamicroute/package.json +24 -0
  153. package/template/10_dynamicroute/src/entries.tsx +75 -0
  154. package/template/10_dynamicroute/src/index.html +36 -0
  155. package/template/10_dynamicroute/src/main.tsx +11 -0
  156. package/template/10_dynamicroute/src/routes/[name]/page.tsx +7 -0
  157. package/template/10_dynamicroute/src/routes/layout.tsx +25 -0
  158. package/template/10_dynamicroute/src/routes/page.tsx +7 -0
  159. package/template/10_dynamicroute/tsconfig.json +22 -0
  160. package/template/10_dynamicroute/tsconfig.node.json +9 -0
  161. package/template/10_dynamicroute/vite.config.ts +22 -0
  162. package/template/11_form/dist/components/App.js +8 -0
  163. package/template/11_form/dist/components/Counter.js +13 -0
  164. package/template/11_form/dist/components/Form.js +10 -0
  165. package/template/11_form/dist/components/funcs.js +10 -0
  166. package/template/11_form/dist/entries.js +31 -0
  167. package/template/11_form/dist/main.js +6 -0
  168. package/template/11_form/node_modules/.bin/tsc +17 -0
  169. package/template/11_form/node_modules/.bin/tsserver +17 -0
  170. package/template/11_form/node_modules/.bin/waku +17 -0
  171. package/template/11_form/package.json +23 -0
  172. package/template/11_form/src/components/App.tsx +25 -0
  173. package/template/11_form/src/components/Counter.tsx +29 -0
  174. package/template/11_form/src/components/Form.tsx +35 -0
  175. package/template/11_form/src/components/funcs.ts +15 -0
  176. package/template/11_form/src/entries.tsx +34 -0
  177. package/template/11_form/src/index.html +36 -0
  178. package/template/11_form/src/main.tsx +13 -0
  179. package/template/11_form/tsconfig.json +15 -0
@@ -0,0 +1,25 @@
1
+ import { Counter } from "./Counter.js";
2
+ import { Form } from "./Form.js";
3
+ import { getMessage, greet, increment } from "./funcs.js";
4
+
5
+ type ServerFunction<T> = T extends (...args: infer A) => infer R
6
+ ? (...args: A) => Promise<R>
7
+ : never;
8
+
9
+ const App = ({ name }: { name: string }) => {
10
+ return (
11
+ <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
12
+ <h1>Hello {name}!!</h1>
13
+ <h3>This is a server component.</h3>
14
+ <Counter
15
+ increment={increment as unknown as ServerFunction<typeof increment>}
16
+ />
17
+ <Form
18
+ message={getMessage()}
19
+ greet={greet as unknown as ServerFunction<typeof greet>}
20
+ />
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default App;
@@ -0,0 +1,29 @@
1
+ /// <reference types="react/canary" />
2
+ /// <reference types="react-dom/canary" />
3
+
4
+ "use client";
5
+
6
+ import { useFormState, useFormStatus } from "react-dom";
7
+
8
+ const FormStatus = () => {
9
+ const { pending } = useFormStatus();
10
+ return pending ? "Pending..." : null;
11
+ };
12
+
13
+ export const Counter = ({
14
+ increment,
15
+ }: {
16
+ increment: (count: number) => Promise<number>;
17
+ }) => {
18
+ const [count, dispatch] = useFormState(increment, 0);
19
+ return (
20
+ <div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
21
+ <form>
22
+ <p>Count: {count}</p>
23
+ <button formAction={dispatch}>Increment</button>
24
+ <FormStatus />
25
+ </form>
26
+ <h3>This is a client component.</h3>
27
+ </div>
28
+ );
29
+ };
@@ -0,0 +1,35 @@
1
+ /// <reference types="react/canary" />
2
+ /// <reference types="react-dom/canary" />
3
+
4
+ "use client";
5
+
6
+ import { useFormStatus } from "react-dom";
7
+
8
+ const SubmitButton = () => {
9
+ const { pending } = useFormStatus();
10
+ return (
11
+ <>
12
+ <button disabled={pending} type="submit">
13
+ Submit
14
+ </button>
15
+ {pending ? "Pending..." : null}
16
+ </>
17
+ );
18
+ };
19
+
20
+ export const Form = ({
21
+ message,
22
+ greet,
23
+ }: {
24
+ message: string;
25
+ greet: (formData: FormData) => Promise<void>;
26
+ }) => (
27
+ <div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
28
+ <p>{message}</p>
29
+ <form action={greet}>
30
+ Name: <input name="name" />
31
+ <SubmitButton />
32
+ </form>
33
+ <h3>This is a client component.</h3>
34
+ </div>
35
+ );
@@ -0,0 +1,15 @@
1
+ "use server";
2
+
3
+ import { rerender } from "waku/server";
4
+
5
+ // module state on server
6
+ let message = "";
7
+
8
+ export const getMessage = () => message;
9
+
10
+ export const greet = (formData: FormData) => {
11
+ message = `Hello ${formData.get("name") || "Anonymous"} from server!`;
12
+ rerender("");
13
+ };
14
+
15
+ export const increment = (count: number) => count + 1;
@@ -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
+ () => ({
24
+ getInput: async (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,15 @@
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
+ "outDir": "./dist",
13
+ "rootDir": "./src"
14
+ }
15
+ }