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
|
@@ -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,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "waku-example",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "node dev.js",
|
|
8
|
+
"build": "waku build",
|
|
9
|
+
"start": "node start.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"cookie-parser": "^1.4.6",
|
|
13
|
+
"express": "^4.18.2",
|
|
14
|
+
"react": "18.3.0-canary-7118f5dd7-20230705",
|
|
15
|
+
"react-dom": "18.3.0-canary-7118f5dd7-20230705",
|
|
16
|
+
"react-server-dom-webpack": "18.3.0-canary-7118f5dd7-20230705",
|
|
17
|
+
"waku": "0.15.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/react": "^18.2.21",
|
|
21
|
+
"@types/react-dom": "^18.2.7",
|
|
22
|
+
"typescript": "^5.2.2"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getContext } from "waku/server";
|
|
2
|
+
import { Counter } from "./Counter.js";
|
|
3
|
+
|
|
4
|
+
const App = ({ name }: { name: string }) => {
|
|
5
|
+
const ctx = getContext<{ count: number }>();
|
|
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
|
+
<p>Cookie count: {ctx.count}</p>
|
|
11
|
+
<Counter />
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
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,38 @@
|
|
|
1
|
+
import { lazy } from "react";
|
|
2
|
+
|
|
3
|
+
import { defineEntries, getContext } from "waku/server";
|
|
4
|
+
|
|
5
|
+
const App = lazy(() => import("./components/App.js"));
|
|
6
|
+
|
|
7
|
+
export default defineEntries(
|
|
8
|
+
// renderEntries
|
|
9
|
+
async (input) => {
|
|
10
|
+
const ctx = getContext<{ count: number }>();
|
|
11
|
+
++ctx.count;
|
|
12
|
+
return {
|
|
13
|
+
App: <App name={input || "Waku"} />,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
// getBuildConfig
|
|
17
|
+
async () => {
|
|
18
|
+
return {
|
|
19
|
+
"/": {
|
|
20
|
+
entries: [[""]],
|
|
21
|
+
context: { count: 0 },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
// getSsrConfig
|
|
26
|
+
// Passing cookies through SSR server isn't supported (yet).
|
|
27
|
+
// async () => ({
|
|
28
|
+
// getInput: (pathStr) => {
|
|
29
|
+
// switch (pathStr) {
|
|
30
|
+
// case "/":
|
|
31
|
+
// return "";
|
|
32
|
+
// default:
|
|
33
|
+
// return null;
|
|
34
|
+
// }
|
|
35
|
+
// },
|
|
36
|
+
// filter: (elements) => elements.App,
|
|
37
|
+
// }),
|
|
38
|
+
);
|
|
@@ -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,36 @@
|
|
|
1
|
+
import url from "node:url";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import express from "express";
|
|
4
|
+
import cookieParser from "cookie-parser";
|
|
5
|
+
import {
|
|
6
|
+
rsc,
|
|
7
|
+
// ssr,
|
|
8
|
+
} from "waku";
|
|
9
|
+
|
|
10
|
+
const root = path.join(
|
|
11
|
+
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
12
|
+
"dist",
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const app = express();
|
|
16
|
+
app.use(cookieParser());
|
|
17
|
+
app.use(
|
|
18
|
+
rsc({
|
|
19
|
+
command: "start",
|
|
20
|
+
unstable_prehook: (req) => {
|
|
21
|
+
return { count: Number(req.cookies.count) || 0 };
|
|
22
|
+
},
|
|
23
|
+
unstable_posthook: (req, res, ctx) => {
|
|
24
|
+
res.cookie("count", String(ctx.count));
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
// Passing cookies through SSR server isn't supported (yet).
|
|
29
|
+
// app.use(ssr({ command: "start" }));
|
|
30
|
+
app.use(express.static(path.join(root, "public")));
|
|
31
|
+
express.static.mime.default_type = "";
|
|
32
|
+
|
|
33
|
+
const port = process.env.PORT || 8080;
|
|
34
|
+
app.listen(port, () => {
|
|
35
|
+
console.info("Listening on", port);
|
|
36
|
+
});
|
|
@@ -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,15 @@
|
|
|
1
|
+
// @ts-expect-error no types
|
|
2
|
+
import styles from "./App.module.css";
|
|
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 className={styles.title}>Hello {name}!!</h1>
|
|
9
|
+
<h3>This is a server component.</h3>
|
|
10
|
+
<Counter />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
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
|
+
}
|