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.
- package/dist/cli.js +7744 -0
- package/package.json +2 -1
- package/src/cli.ts +3 -3
- package/template/01_counter/node_modules/.bin/tsc +17 -0
- package/template/01_counter/node_modules/.bin/tsserver +17 -0
- package/template/01_counter/node_modules/.bin/waku +17 -0
- package/template/01_counter/package.json +23 -0
- package/template/01_counter/src/components/App.tsx +13 -0
- package/template/01_counter/src/components/Counter.tsx +14 -0
- package/template/01_counter/src/entries.tsx +34 -0
- package/template/01_counter/src/index.html +36 -0
- package/template/01_counter/src/main.tsx +13 -0
- package/template/01_counter/tsconfig.json +13 -0
- package/template/02_async/node_modules/.bin/tsc +17 -0
- package/template/02_async/node_modules/.bin/tsserver +17 -0
- package/template/02_async/node_modules/.bin/waku +17 -0
- package/template/02_async/package.json +23 -0
- package/template/02_async/src/components/App.tsx +35 -0
- package/template/02_async/src/components/Counter.tsx +14 -0
- package/template/02_async/src/entries.tsx +34 -0
- package/template/02_async/src/index.html +36 -0
- package/template/02_async/src/main.tsx +24 -0
- package/template/02_async/tsconfig.json +13 -0
- package/template/02_async/vite.config.ts +16 -0
- package/template/03_promise/node_modules/.bin/tsc +17 -0
- package/template/03_promise/node_modules/.bin/tsserver +17 -0
- package/template/03_promise/node_modules/.bin/waku +17 -0
- package/template/03_promise/package.json +23 -0
- package/template/03_promise/src/components/App.tsx +18 -0
- package/template/03_promise/src/components/Counter.tsx +34 -0
- package/template/03_promise/src/entries.tsx +39 -0
- package/template/03_promise/src/index.html +36 -0
- package/template/03_promise/src/main.tsx +15 -0
- package/template/03_promise/tsconfig.json +13 -0
- package/template/04_callserver/node_modules/.bin/tsc +17 -0
- package/template/04_callserver/node_modules/.bin/tsserver +17 -0
- package/template/04_callserver/node_modules/.bin/waku +17 -0
- package/template/04_callserver/package.json +23 -0
- package/template/04_callserver/src/components/App.tsx +18 -0
- package/template/04_callserver/src/components/Counter.tsx +31 -0
- package/template/04_callserver/src/components/funcs.ts +3 -0
- package/template/04_callserver/src/entries.tsx +34 -0
- package/template/04_callserver/src/index.html +36 -0
- package/template/04_callserver/src/main.tsx +13 -0
- package/template/04_callserver/tsconfig.json +13 -0
- package/template/05_mutation/node_modules/.bin/tsc +17 -0
- package/template/05_mutation/node_modules/.bin/tsserver +17 -0
- package/template/05_mutation/node_modules/.bin/waku +17 -0
- package/template/05_mutation/package.json +23 -0
- package/template/05_mutation/src/components/App.tsx +21 -0
- package/template/05_mutation/src/components/Counter.tsx +24 -0
- package/template/05_mutation/src/components/funcs.ts +13 -0
- package/template/05_mutation/src/entries.tsx +34 -0
- package/template/05_mutation/src/index.html +36 -0
- package/template/05_mutation/src/main.tsx +13 -0
- package/template/05_mutation/tsconfig.json +13 -0
- package/template/06_nesting/node_modules/.bin/tsc +17 -0
- package/template/06_nesting/node_modules/.bin/tsserver +17 -0
- package/template/06_nesting/node_modules/.bin/waku +17 -0
- package/template/06_nesting/package.json +23 -0
- package/template/06_nesting/src/components/App.tsx +13 -0
- package/template/06_nesting/src/components/Counter.tsx +32 -0
- package/template/06_nesting/src/components/InnerApp.tsx +13 -0
- package/template/06_nesting/src/entries.tsx +49 -0
- package/template/06_nesting/src/index.html +36 -0
- package/template/06_nesting/src/main.tsx +13 -0
- package/template/06_nesting/tsconfig.json +13 -0
- package/template/07_router/node_modules/.bin/glob +17 -0
- package/template/07_router/node_modules/.bin/tsc +17 -0
- package/template/07_router/node_modules/.bin/tsserver +17 -0
- package/template/07_router/node_modules/.bin/waku +17 -0
- package/template/07_router/package.json +24 -0
- package/template/07_router/src/components/Counter.tsx +17 -0
- package/template/07_router/src/components/ErrorBoundary.tsx +28 -0
- package/template/07_router/src/entries.tsx +38 -0
- package/template/07_router/src/index.html +36 -0
- package/template/07_router/src/main.tsx +15 -0
- package/template/07_router/src/routes/bar/page.tsx +10 -0
- package/template/07_router/src/routes/foo/page.tsx +10 -0
- package/template/07_router/src/routes/layout.tsx +54 -0
- package/template/07_router/src/routes/nested/baz/page.tsx +7 -0
- package/template/07_router/src/routes/nested/layout.tsx +13 -0
- package/template/07_router/src/routes/nested/qux/page.tsx +7 -0
- package/template/07_router/src/routes/page.tsx +8 -0
- package/template/07_router/tsconfig.json +13 -0
- package/template/07_router/vite.config.ts +22 -0
- package/template/08_cookies/dev.js +29 -0
- package/template/08_cookies/node_modules/.bin/tsc +17 -0
- package/template/08_cookies/node_modules/.bin/tsserver +17 -0
- package/template/08_cookies/node_modules/.bin/waku +17 -0
- package/template/08_cookies/package.json +24 -0
- package/template/08_cookies/src/components/App.tsx +16 -0
- package/template/08_cookies/src/components/Counter.tsx +14 -0
- package/template/08_cookies/src/entries.tsx +38 -0
- package/template/08_cookies/src/index.html +36 -0
- package/template/08_cookies/src/main.tsx +13 -0
- package/template/08_cookies/start.js +36 -0
- package/template/08_cookies/tsconfig.json +13 -0
- package/template/09_cssmodules/node_modules/.bin/tsc +17 -0
- package/template/09_cssmodules/node_modules/.bin/tsserver +17 -0
- package/template/09_cssmodules/node_modules/.bin/waku +17 -0
- package/template/09_cssmodules/package.json +23 -0
- package/template/09_cssmodules/src/components/App.module.css +3 -0
- package/template/09_cssmodules/src/components/App.tsx +15 -0
- package/template/09_cssmodules/src/components/Counter.tsx +14 -0
- package/template/09_cssmodules/src/entries.tsx +34 -0
- package/template/09_cssmodules/src/index.html +36 -0
- package/template/09_cssmodules/src/main.tsx +13 -0
- package/template/09_cssmodules/tsconfig.json +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-waku",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"author": "Daishi Kato",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Vasu Singh"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"start": "node dist/cli.js",
|
|
31
|
+
"compile": "rm -rf template dist && pnpm run template && pnpm run build",
|
|
31
32
|
"template": "cp -r ../../examples template/",
|
|
32
33
|
"build": "esbuild src/* --bundle --platform=node --outdir=dist"
|
|
33
34
|
}
|
package/src/cli.ts
CHANGED
|
@@ -35,7 +35,8 @@ async function init() {
|
|
|
35
35
|
let targetDir = "";
|
|
36
36
|
const defaultProjectName = "waku-project";
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const templateRoot = path.join(__dirname, "../template");
|
|
39
|
+
const CHOICES = fs.readdirSync(templateRoot);
|
|
39
40
|
let result: {
|
|
40
41
|
packageName: string;
|
|
41
42
|
shouldOverwrite: string;
|
|
@@ -116,8 +117,7 @@ async function init() {
|
|
|
116
117
|
|
|
117
118
|
console.log("Setting up project...");
|
|
118
119
|
|
|
119
|
-
const
|
|
120
|
-
const templateDir = path.resolve(templateRoot, chooseProject);
|
|
120
|
+
const templateDir = path.join(templateRoot, chooseProject);
|
|
121
121
|
|
|
122
122
|
// Read existing package.json from the root directory
|
|
123
123
|
const packageJsonPath = path.join(root, "package.json");
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { Counter } from "./Counter.js";
|
|
2
|
+
|
|
3
|
+
const App = ({ name }: { name: string }) => {
|
|
4
|
+
return (
|
|
5
|
+
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
|
|
6
|
+
<h1>Hello {name}!!</h1>
|
|
7
|
+
<h3>This is a server component.</h3>
|
|
8
|
+
<Counter />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default App;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export const Counter = () => {
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
return (
|
|
8
|
+
<div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
|
|
9
|
+
<p>Count: {count}</p>
|
|
10
|
+
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
|
|
11
|
+
<h3>This is a client component.</h3>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -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,35 @@
|
|
|
1
|
+
import { Suspense } from "react";
|
|
2
|
+
|
|
3
|
+
import { Counter } from "./Counter.js";
|
|
4
|
+
|
|
5
|
+
const App = ({ name }: { name: string }) => {
|
|
6
|
+
return (
|
|
7
|
+
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
|
|
8
|
+
<h1>Hello {name}!!</h1>
|
|
9
|
+
<h3>This is a server component.</h3>
|
|
10
|
+
<Suspense fallback="Pending...">
|
|
11
|
+
<ServerMessage />
|
|
12
|
+
</Suspense>
|
|
13
|
+
<Suspense fallback={<CounterSkeleton />}>
|
|
14
|
+
<Counter />
|
|
15
|
+
</Suspense>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ServerMessage = async () => {
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
22
|
+
return <p>Hello from server!</p>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const CounterSkeleton = () => {
|
|
26
|
+
return (
|
|
27
|
+
<div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
|
|
28
|
+
<p>Count: {0}</p>
|
|
29
|
+
<button disabled>Increment</button>
|
|
30
|
+
<h3>This is a skeleton component.</h3>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default App;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export const Counter = () => {
|
|
6
|
+
const [count, setCount] = useState(0);
|
|
7
|
+
return (
|
|
8
|
+
<div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
|
|
9
|
+
<p>Count: {count}</p>
|
|
10
|
+
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
|
|
11
|
+
<h3>This is a client component.</h3>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -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" defer type="module"></script>
|
|
33
|
+
<!--placeholder2-->
|
|
34
|
+
<!--/placeholder2-->
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { hydrateRoot } 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
|
+
hydrateRoot(document.getElementById("root")!, rootElement, {
|
|
14
|
+
onRecoverableError(err) {
|
|
15
|
+
if (
|
|
16
|
+
err instanceof Error &&
|
|
17
|
+
err.message.startsWith("Client-only component")
|
|
18
|
+
) {
|
|
19
|
+
// ignore
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.error(err);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -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,16 @@
|
|
|
1
|
+
import { defineConfig } from "waku/config";
|
|
2
|
+
|
|
3
|
+
const getFallback = (id: string) => {
|
|
4
|
+
if (id.endsWith("#Counter")) {
|
|
5
|
+
return "waku/server#ClientOnly";
|
|
6
|
+
}
|
|
7
|
+
return "waku/server#ClientFallback";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
framework: {
|
|
12
|
+
ssr: {
|
|
13
|
+
getFallback,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -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 type { ReactNode } from "react";
|
|
2
|
+
import { Counter } from "./Counter.js";
|
|
3
|
+
|
|
4
|
+
const App = ({ name, children }: { name: string; children: ReactNode }) => {
|
|
5
|
+
const delayedMessage = new Promise<string>((resolve) => {
|
|
6
|
+
setTimeout(() => resolve("Hello from server!"), 2000);
|
|
7
|
+
});
|
|
8
|
+
return (
|
|
9
|
+
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
|
|
10
|
+
<h1>Hello {name}!!</h1>
|
|
11
|
+
<h3>This is a server component.</h3>
|
|
12
|
+
<Counter delayedMessage={delayedMessage} />
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default App;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Suspense, useState } from "react";
|
|
4
|
+
|
|
5
|
+
export const Counter = ({
|
|
6
|
+
delayedMessage,
|
|
7
|
+
}: {
|
|
8
|
+
delayedMessage: Promise<string>;
|
|
9
|
+
}) => {
|
|
10
|
+
const [count, setCount] = useState(0);
|
|
11
|
+
return (
|
|
12
|
+
<div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
|
|
13
|
+
<p>Count: {count}</p>
|
|
14
|
+
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
|
|
15
|
+
<h3>This is a client component.</h3>
|
|
16
|
+
<Suspense fallback="Pending...">
|
|
17
|
+
<Message count={count} delayedMessage={delayedMessage} />
|
|
18
|
+
</Suspense>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Message = ({
|
|
24
|
+
count,
|
|
25
|
+
delayedMessage,
|
|
26
|
+
}: {
|
|
27
|
+
count: number;
|
|
28
|
+
delayedMessage: Promise<string>;
|
|
29
|
+
}) => (
|
|
30
|
+
<ul>
|
|
31
|
+
<li>count: {count}</li>
|
|
32
|
+
<li>delayedMessage: {delayedMessage as any}</li>
|
|
33
|
+
</ul>
|
|
34
|
+
);
|