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.
- package/dist/.tsbuildinfo +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +118 -7731
- package/package.json +5 -6
- package/src/cli.ts +3 -7
- package/template/01_counter/dist/components/App.js +6 -0
- package/template/01_counter/dist/components/Counter.js +7 -0
- package/template/01_counter/dist/entries.js +31 -0
- package/template/01_counter/dist/main.js +6 -0
- package/template/01_counter/node_modules/.bin/tsc +2 -2
- package/template/01_counter/node_modules/.bin/tsserver +2 -2
- package/template/01_counter/node_modules/.bin/waku +2 -2
- package/template/01_counter/package.json +6 -6
- package/template/01_counter/src/entries.tsx +2 -2
- package/template/01_counter/tsconfig.json +3 -1
- package/template/02_async/dist/.tsbuildinfo +1 -0
- package/template/02_async/dist/node/.tsbuildinfo +1 -0
- package/template/02_async/dist/node/vite.config.d.ts +2 -0
- package/template/02_async/dist/node/vite.config.js +14 -0
- package/template/02_async/dist/src/components/App.d.ts +4 -0
- package/template/02_async/dist/src/components/App.js +16 -0
- package/template/02_async/dist/src/components/Counter.d.ts +1 -0
- package/template/02_async/dist/src/components/Counter.js +7 -0
- package/template/02_async/dist/src/entries.d.ts +6 -0
- package/template/02_async/dist/src/entries.js +31 -0
- package/template/02_async/dist/src/main.d.ts +1 -0
- package/template/02_async/dist/src/main.js +15 -0
- package/template/02_async/node_modules/.bin/tsc +2 -2
- package/template/02_async/node_modules/.bin/tsserver +2 -2
- package/template/02_async/node_modules/.bin/waku +2 -2
- package/template/02_async/package.json +6 -6
- package/template/02_async/src/components/App.tsx +2 -0
- package/template/02_async/src/entries.tsx +2 -2
- package/template/02_async/tsconfig.json +11 -2
- package/template/02_async/tsconfig.node.json +9 -0
- package/template/03_promise/dist/components/App.js +9 -0
- package/template/03_promise/dist/components/Counter.js +8 -0
- package/template/03_promise/dist/entries.js +32 -0
- package/template/03_promise/dist/main.js +6 -0
- package/template/03_promise/node_modules/.bin/tsc +2 -2
- package/template/03_promise/node_modules/.bin/tsserver +2 -2
- package/template/03_promise/node_modules/.bin/waku +2 -2
- package/template/03_promise/package.json +6 -6
- package/template/03_promise/src/entries.tsx +2 -2
- package/template/03_promise/tsconfig.json +3 -1
- package/template/04_callserver/dist/components/App.js +7 -0
- package/template/04_callserver/dist/components/Counter.js +14 -0
- package/template/04_callserver/dist/components/funcs.js +2 -0
- package/template/04_callserver/dist/entries.js +31 -0
- package/template/04_callserver/dist/main.js +6 -0
- package/template/04_callserver/node_modules/.bin/tsc +2 -2
- package/template/04_callserver/node_modules/.bin/tsserver +2 -2
- package/template/04_callserver/node_modules/.bin/waku +2 -2
- package/template/04_callserver/package.json +6 -6
- package/template/04_callserver/src/entries.tsx +2 -2
- package/template/04_callserver/tsconfig.json +3 -1
- package/template/05_mutation/dist/components/App.js +7 -0
- package/template/05_mutation/dist/components/Counter.js +13 -0
- package/template/05_mutation/dist/components/funcs.js +9 -0
- package/template/05_mutation/dist/entries.js +31 -0
- package/template/05_mutation/dist/main.js +6 -0
- package/template/05_mutation/node_modules/.bin/tsc +2 -2
- package/template/05_mutation/node_modules/.bin/tsserver +2 -2
- package/template/05_mutation/node_modules/.bin/waku +2 -2
- package/template/05_mutation/package.json +6 -6
- package/template/05_mutation/src/entries.tsx +2 -2
- package/template/05_mutation/tsconfig.json +3 -1
- package/template/06_nesting/dist/components/App.js +6 -0
- package/template/06_nesting/dist/components/Counter.js +24 -0
- package/template/06_nesting/dist/components/InnerApp.js +6 -0
- package/template/06_nesting/dist/entries.js +45 -0
- package/template/06_nesting/dist/main.js +6 -0
- package/template/06_nesting/node_modules/.bin/tsc +2 -2
- package/template/06_nesting/node_modules/.bin/tsserver +2 -2
- package/template/06_nesting/node_modules/.bin/waku +2 -2
- package/template/06_nesting/package.json +6 -6
- package/template/06_nesting/src/entries.tsx +2 -2
- package/template/06_nesting/tsconfig.json +3 -1
- package/template/07_router/dist/.tsbuildinfo +1 -0
- package/template/07_router/dist/node/.tsbuildinfo +1 -0
- package/template/07_router/dist/node/vite.config.d.ts +2 -0
- package/template/07_router/dist/node/vite.config.js +16 -0
- package/template/07_router/dist/src/components/Counter.d.ts +1 -0
- package/template/07_router/dist/src/components/Counter.js +8 -0
- package/template/07_router/dist/src/components/ErrorBoundary.d.ts +7 -0
- package/template/07_router/dist/src/components/ErrorBoundary.js +17 -0
- package/template/07_router/dist/src/entries.d.ts +6 -0
- package/template/07_router/dist/src/entries.js +29 -0
- package/template/07_router/dist/src/main.d.ts +1 -0
- package/template/07_router/dist/src/main.js +7 -0
- package/template/07_router/dist/src/routes/bar/page.d.ts +2 -0
- package/template/07_router/dist/src/routes/bar/page.js +4 -0
- package/template/07_router/dist/src/routes/foo/page.d.ts +2 -0
- package/template/07_router/dist/src/routes/foo/page.js +4 -0
- package/template/07_router/dist/src/routes/layout.d.ts +5 -0
- package/template/07_router/dist/src/routes/layout.js +9 -0
- package/template/07_router/dist/src/routes/nested/baz/page.d.ts +2 -0
- package/template/07_router/dist/src/routes/nested/baz/page.js +3 -0
- package/template/07_router/dist/src/routes/nested/layout.d.ts +5 -0
- package/template/07_router/dist/src/routes/nested/layout.js +4 -0
- package/template/07_router/dist/src/routes/nested/qux/page.d.ts +2 -0
- package/template/07_router/dist/src/routes/nested/qux/page.js +3 -0
- package/template/07_router/dist/src/routes/page.d.ts +2 -0
- package/template/07_router/dist/src/routes/page.js +3 -0
- package/template/07_router/node_modules/.bin/glob +4 -4
- package/template/07_router/node_modules/.bin/tsc +2 -2
- package/template/07_router/node_modules/.bin/tsserver +2 -2
- package/template/07_router/node_modules/.bin/waku +2 -2
- package/template/07_router/package.json +7 -7
- package/template/07_router/src/entries.tsx +1 -1
- package/template/07_router/tsconfig.json +11 -2
- package/template/07_router/tsconfig.node.json +9 -0
- package/template/08_cookies/dev.js +1 -1
- package/template/08_cookies/dist/components/App.js +8 -0
- package/template/08_cookies/dist/components/Counter.js +7 -0
- package/template/08_cookies/dist/entries.js +22 -0
- package/template/08_cookies/dist/main.js +6 -0
- package/template/08_cookies/node_modules/.bin/tsc +2 -2
- package/template/08_cookies/node_modules/.bin/tsserver +2 -2
- package/template/08_cookies/node_modules/.bin/waku +2 -2
- package/template/08_cookies/package.json +6 -6
- package/template/08_cookies/src/entries.tsx +2 -2
- package/template/08_cookies/tsconfig.json +3 -1
- package/template/09_cssmodules/dist/components/App.js +8 -0
- package/template/09_cssmodules/dist/components/Counter.js +7 -0
- package/template/09_cssmodules/dist/entries.js +31 -0
- package/template/09_cssmodules/dist/main.js +6 -0
- package/template/09_cssmodules/node_modules/.bin/tsc +2 -2
- package/template/09_cssmodules/node_modules/.bin/tsserver +2 -2
- package/template/09_cssmodules/node_modules/.bin/waku +2 -2
- package/template/09_cssmodules/package.json +6 -6
- package/template/09_cssmodules/src/entries.tsx +2 -2
- package/template/09_cssmodules/tsconfig.json +3 -1
- package/template/10_dynamicroute/dist/.tsbuildinfo +1 -0
- package/template/10_dynamicroute/dist/node/.tsbuildinfo +1 -0
- package/template/10_dynamicroute/dist/node/vite.config.d.ts +2 -0
- package/template/10_dynamicroute/dist/node/vite.config.js +16 -0
- package/template/10_dynamicroute/dist/src/entries.d.ts +6 -0
- package/template/10_dynamicroute/dist/src/entries.js +61 -0
- package/template/10_dynamicroute/dist/src/main.d.ts +1 -0
- package/template/10_dynamicroute/dist/src/main.js +6 -0
- package/template/10_dynamicroute/dist/src/routes/[name]/page.d.ts +4 -0
- package/template/10_dynamicroute/dist/src/routes/[name]/page.js +3 -0
- package/template/10_dynamicroute/dist/src/routes/layout.d.ts +5 -0
- package/template/10_dynamicroute/dist/src/routes/layout.js +4 -0
- package/template/10_dynamicroute/dist/src/routes/page.d.ts +2 -0
- package/template/10_dynamicroute/dist/src/routes/page.js +3 -0
- package/template/10_dynamicroute/node_modules/.bin/glob +17 -0
- package/template/10_dynamicroute/node_modules/.bin/tsc +17 -0
- package/template/10_dynamicroute/node_modules/.bin/tsserver +17 -0
- package/template/10_dynamicroute/node_modules/.bin/waku +17 -0
- package/template/10_dynamicroute/package.json +24 -0
- package/template/10_dynamicroute/src/entries.tsx +75 -0
- package/template/10_dynamicroute/src/index.html +36 -0
- package/template/10_dynamicroute/src/main.tsx +11 -0
- package/template/10_dynamicroute/src/routes/[name]/page.tsx +7 -0
- package/template/10_dynamicroute/src/routes/layout.tsx +25 -0
- package/template/10_dynamicroute/src/routes/page.tsx +7 -0
- package/template/10_dynamicroute/tsconfig.json +22 -0
- package/template/10_dynamicroute/tsconfig.node.json +9 -0
- package/template/10_dynamicroute/vite.config.ts +22 -0
- package/template/11_form/dist/components/App.js +8 -0
- package/template/11_form/dist/components/Counter.js +13 -0
- package/template/11_form/dist/components/Form.js +10 -0
- package/template/11_form/dist/components/funcs.js +10 -0
- package/template/11_form/dist/entries.js +31 -0
- package/template/11_form/dist/main.js +6 -0
- package/template/11_form/node_modules/.bin/tsc +17 -0
- package/template/11_form/node_modules/.bin/tsserver +17 -0
- package/template/11_form/node_modules/.bin/waku +17 -0
- package/template/11_form/package.json +23 -0
- package/template/11_form/src/components/App.tsx +25 -0
- package/template/11_form/src/components/Counter.tsx +29 -0
- package/template/11_form/src/components/Form.tsx +35 -0
- package/template/11_form/src/components/funcs.ts +15 -0
- package/template/11_form/src/entries.tsx +34 -0
- package/template/11_form/src/index.html +36 -0
- package/template/11_form/src/main.tsx +13 -0
- 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
|
+
}
|