create-waku 0.6.0 → 0.6.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 +45 -45
- package/package.json +4 -4
- package/src/cli.ts +45 -45
- package/template/01_counter/dist/components/App.js +2 -2
- package/template/01_counter/dist/components/Counter.js +3 -3
- package/template/01_counter/dist/entries.js +18 -17
- package/template/01_counter/dist/main.js +9 -4
- package/template/01_counter/node_modules/.bin/vite +17 -0
- package/template/01_counter/package.json +11 -8
- package/template/01_counter/src/components/App.tsx +2 -2
- package/template/01_counter/src/components/Counter.tsx +3 -3
- package/template/01_counter/src/entries.tsx +18 -18
- package/template/01_counter/src/index.html +1 -0
- package/template/01_counter/src/main.tsx +8 -4
- package/template/01_counter/tsconfig.json +2 -2
- package/template/02_async/dist/components/App.js +13 -0
- package/template/02_async/dist/{src/components → components}/Counter.js +3 -3
- package/template/02_async/dist/entries.js +32 -0
- package/template/02_async/dist/main.js +11 -0
- package/template/02_async/node_modules/.bin/vite +17 -0
- package/template/02_async/package.json +11 -8
- package/template/02_async/src/components/App.tsx +5 -17
- package/template/02_async/src/components/Counter.tsx +3 -3
- package/template/02_async/src/entries.tsx +18 -18
- package/template/02_async/src/index.html +2 -1
- package/template/02_async/src/main.tsx +8 -15
- package/template/02_async/tsconfig.json +3 -10
- package/template/03_promise/dist/components/App.js +3 -3
- package/template/03_promise/dist/components/Counter.js +3 -3
- package/template/03_promise/dist/entries.js +18 -18
- package/template/03_promise/dist/main.js +9 -4
- package/template/03_promise/node_modules/.bin/vite +17 -0
- package/template/03_promise/package.json +11 -8
- package/template/03_promise/src/components/App.tsx +5 -4
- package/template/03_promise/src/components/Counter.tsx +3 -3
- package/template/03_promise/src/entries.tsx +22 -19
- package/template/03_promise/src/index.html +1 -0
- package/template/03_promise/src/main.tsx +8 -4
- package/template/03_promise/tsconfig.json +2 -2
- package/template/04_callserver/dist/components/App.js +3 -3
- package/template/04_callserver/dist/components/Counter.js +6 -5
- package/template/04_callserver/dist/components/TextBox.js +6 -0
- package/template/04_callserver/dist/components/funcs.js +1 -1
- package/template/04_callserver/dist/entries.js +18 -17
- package/template/04_callserver/dist/main.js +9 -4
- package/template/04_callserver/node_modules/.bin/vite +17 -0
- package/template/04_callserver/package.json +11 -8
- package/template/04_callserver/src/components/App.tsx +3 -3
- package/template/04_callserver/src/components/Counter.tsx +10 -7
- package/template/04_callserver/src/components/TextBox.tsx +11 -0
- package/template/04_callserver/src/components/funcs.ts +1 -1
- package/template/04_callserver/src/entries.tsx +18 -18
- package/template/04_callserver/src/index.html +1 -0
- package/template/04_callserver/src/main.tsx +8 -4
- package/template/04_callserver/tsconfig.json +2 -2
- package/template/05_mutation/dist/components/App.js +4 -3
- package/template/05_mutation/dist/components/Counter.js +3 -3
- package/template/05_mutation/dist/components/funcs.js +3 -3
- package/template/05_mutation/dist/entries.js +18 -17
- package/template/05_mutation/dist/main.js +9 -4
- package/template/05_mutation/node_modules/.bin/vite +17 -0
- package/template/05_mutation/package.json +12 -8
- package/template/05_mutation/src/components/App.tsx +6 -3
- package/template/05_mutation/src/components/Counter.tsx +5 -5
- package/template/05_mutation/src/components/funcs.ts +3 -3
- package/template/05_mutation/src/entries.tsx +18 -18
- package/template/05_mutation/src/index.html +1 -0
- package/template/05_mutation/src/main.tsx +8 -4
- package/template/05_mutation/tsconfig.json +2 -2
- package/template/06_nesting/dist/components/App.js +2 -2
- package/template/06_nesting/dist/components/Counter.js +6 -6
- package/template/06_nesting/dist/components/InnerApp.js +3 -3
- package/template/06_nesting/dist/entries.js +28 -27
- package/template/06_nesting/dist/main.js +9 -4
- package/template/06_nesting/node_modules/.bin/vite +17 -0
- package/template/06_nesting/package.json +11 -8
- package/template/06_nesting/src/components/App.tsx +2 -2
- package/template/06_nesting/src/components/Counter.tsx +8 -8
- package/template/06_nesting/src/components/InnerApp.tsx +3 -3
- package/template/06_nesting/src/entries.tsx +29 -29
- package/template/06_nesting/src/index.html +1 -0
- package/template/06_nesting/src/main.tsx +8 -4
- package/template/06_nesting/tsconfig.json +2 -2
- package/template/07_router/dist/node/tsconfig.node.tsbuildinfo +1 -0
- package/template/07_router/dist/node/vite.config.d.ts +14 -1
- package/template/07_router/dist/node/vite.config.js +9 -6
- package/template/07_router/dist/src/components/Counter.js +4 -4
- package/template/07_router/dist/src/components/ErrorBoundary.d.ts +1 -1
- package/template/07_router/dist/src/components/ErrorBoundary.js +2 -2
- package/template/07_router/dist/src/entries.js +9 -9
- package/template/07_router/dist/src/main.js +10 -5
- package/template/07_router/dist/src/routes/bar/page.js +1 -1
- package/template/07_router/dist/src/routes/foo/page.js +1 -1
- package/template/07_router/dist/src/routes/layout.d.ts +1 -1
- package/template/07_router/dist/src/routes/layout.js +2 -2
- package/template/07_router/dist/src/routes/nested/layout.d.ts +1 -1
- package/template/07_router/dist/src/routes/nested/layout.js +1 -1
- package/template/07_router/dist/tsconfig.tsbuildinfo +1 -0
- package/template/07_router/node_modules/.bin/vite +17 -0
- package/template/07_router/package.json +11 -8
- package/template/07_router/src/components/Counter.tsx +4 -4
- package/template/07_router/src/components/ErrorBoundary.tsx +3 -3
- package/template/07_router/src/entries.tsx +9 -10
- package/template/07_router/src/index.html +1 -0
- package/template/07_router/src/main.tsx +9 -5
- package/template/07_router/src/routes/bar/page.tsx +1 -1
- package/template/07_router/src/routes/foo/page.tsx +1 -1
- package/template/07_router/src/routes/layout.tsx +3 -3
- package/template/07_router/src/routes/nested/layout.tsx +2 -2
- package/template/07_router/tsconfig.json +0 -1
- package/template/07_router/tsconfig.node.json +0 -1
- package/template/07_router/vite.config.ts +9 -7
- package/template/08_cookies/dev.js +9 -13
- package/template/08_cookies/dist/components/App.js +3 -3
- package/template/08_cookies/dist/components/Counter.js +3 -3
- package/template/08_cookies/dist/entries.js +19 -6
- package/template/08_cookies/dist/main.js +9 -4
- package/template/08_cookies/node_modules/.bin/vite +17 -0
- package/template/08_cookies/package.json +13 -10
- package/template/08_cookies/src/components/App.tsx +3 -3
- package/template/08_cookies/src/components/Counter.tsx +3 -3
- package/template/08_cookies/src/entries.tsx +18 -19
- package/template/08_cookies/src/index.html +1 -0
- package/template/08_cookies/src/main.tsx +8 -4
- package/template/08_cookies/start.js +14 -16
- package/template/08_cookies/tsconfig.json +2 -2
- package/template/09_cssmodules/dist/components/App.js +3 -3
- package/template/09_cssmodules/dist/components/Counter.js +3 -3
- package/template/09_cssmodules/dist/entries.js +18 -17
- package/template/09_cssmodules/dist/main.js +9 -4
- package/template/09_cssmodules/node_modules/.bin/vite +17 -0
- package/template/09_cssmodules/package.json +11 -8
- package/template/09_cssmodules/src/components/App.tsx +3 -3
- package/template/09_cssmodules/src/components/Counter.tsx +3 -3
- package/template/09_cssmodules/src/entries.tsx +18 -18
- package/template/09_cssmodules/src/index.html +1 -0
- package/template/09_cssmodules/src/main.tsx +8 -4
- package/template/09_cssmodules/tsconfig.json +2 -2
- package/template/10_dynamicroute/dist/node/tsconfig.node.tsbuildinfo +1 -0
- package/template/10_dynamicroute/dist/node/vite.config.d.ts +14 -1
- package/template/10_dynamicroute/dist/node/vite.config.js +9 -6
- package/template/10_dynamicroute/dist/src/entries.js +15 -15
- package/template/10_dynamicroute/dist/src/main.js +9 -4
- package/template/10_dynamicroute/dist/src/routes/layout.d.ts +1 -1
- package/template/10_dynamicroute/dist/src/routes/layout.js +1 -1
- package/template/10_dynamicroute/dist/tsconfig.tsbuildinfo +1 -0
- package/template/10_dynamicroute/node_modules/.bin/vite +17 -0
- package/template/10_dynamicroute/package.json +11 -8
- package/template/10_dynamicroute/src/entries.tsx +15 -16
- package/template/10_dynamicroute/src/index.html +1 -0
- package/template/10_dynamicroute/src/main.tsx +8 -4
- package/template/10_dynamicroute/src/routes/layout.tsx +2 -2
- package/template/10_dynamicroute/tsconfig.json +0 -1
- package/template/10_dynamicroute/tsconfig.node.json +0 -1
- package/template/10_dynamicroute/vite.config.ts +9 -7
- package/template/11_form/dist/components/App.js +4 -4
- package/template/11_form/dist/components/Counter.js +4 -4
- package/template/11_form/dist/components/Form.js +4 -4
- package/template/11_form/dist/components/funcs.js +5 -5
- package/template/11_form/dist/entries.js +18 -17
- package/template/11_form/dist/main.js +9 -4
- package/template/11_form/node_modules/.bin/vite +17 -0
- package/template/11_form/package.json +11 -8
- package/template/11_form/src/components/App.tsx +4 -4
- package/template/11_form/src/components/Counter.tsx +4 -4
- package/template/11_form/src/components/Form.tsx +4 -4
- package/template/11_form/src/components/funcs.ts +5 -5
- package/template/11_form/src/entries.tsx +18 -18
- package/template/11_form/src/index.html +1 -0
- package/template/11_form/src/main.tsx +8 -4
- package/template/11_form/tsconfig.json +2 -2
- package/dist/.tsbuildinfo +0 -1
- package/template/02_async/dist/.tsbuildinfo +0 -1
- package/template/02_async/dist/node/.tsbuildinfo +0 -1
- package/template/02_async/dist/node/vite.config.d.ts +0 -2
- package/template/02_async/dist/node/vite.config.js +0 -14
- package/template/02_async/dist/src/components/App.d.ts +0 -4
- package/template/02_async/dist/src/components/App.js +0 -16
- package/template/02_async/dist/src/components/Counter.d.ts +0 -1
- package/template/02_async/dist/src/entries.d.ts +0 -6
- package/template/02_async/dist/src/entries.js +0 -31
- package/template/02_async/dist/src/main.d.ts +0 -1
- package/template/02_async/dist/src/main.js +0 -15
- package/template/02_async/tsconfig.node.json +0 -9
- package/template/02_async/vite.config.ts +0 -16
- package/template/07_router/dist/.tsbuildinfo +0 -1
- package/template/07_router/dist/node/.tsbuildinfo +0 -1
- package/template/10_dynamicroute/dist/.tsbuildinfo +0 -1
- package/template/10_dynamicroute/dist/node/.tsbuildinfo +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from
|
|
3
|
+
import { useState } from 'react';
|
|
4
4
|
export const Counter = () => {
|
|
5
5
|
const [count, setCount] = useState(0);
|
|
6
|
-
return (_jsxs("div", { style: { border:
|
|
6
|
+
return (_jsxs("div", { style: { border: '3px blue dashed', margin: '1em', padding: '1em' }, children: [_jsxs("p", { children: ["Count: ", count] }), _jsx("button", { onClick: () => setCount((c) => c + 1), children: "Increment" }), _jsx("h3", { children: "This is a client component." })] }));
|
|
7
7
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { lazy } from 'react';
|
|
3
|
+
import { defineEntries } from 'waku/server';
|
|
4
|
+
import { Slot } from 'waku/client';
|
|
5
|
+
const App = lazy(() => import('./components/App.js'));
|
|
6
|
+
export default defineEntries(
|
|
7
|
+
// renderEntries
|
|
8
|
+
async (input) => {
|
|
9
|
+
return {
|
|
10
|
+
App: _jsx(App, { name: input || 'Waku' }),
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
// getBuildConfig
|
|
14
|
+
async () => {
|
|
15
|
+
return {
|
|
16
|
+
'/': {
|
|
17
|
+
entries: [['']],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
// getSsrConfig
|
|
22
|
+
async (pathStr) => {
|
|
23
|
+
switch (pathStr) {
|
|
24
|
+
case '/':
|
|
25
|
+
return {
|
|
26
|
+
input: '',
|
|
27
|
+
unstable_render: () => _jsx(Slot, { id: "App" }),
|
|
28
|
+
};
|
|
29
|
+
default:
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StrictMode } from 'react';
|
|
3
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
4
|
+
import { Root, Slot } from 'waku/client';
|
|
5
|
+
const rootElement = (_jsx(StrictMode, { children: _jsx(Root, { children: _jsx(Slot, { id: "App" }) }) }));
|
|
6
|
+
if (globalThis.__WAKU_SSR_ENABLED__) {
|
|
7
|
+
hydrateRoot(document.getElementById('root'), rootElement);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
createRoot(document.getElementById('root')).render(rootElement);
|
|
11
|
+
}
|
|
@@ -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/vite@4.5.0_@types+node@20.9.0/node_modules/vite/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/node_modules/vite/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/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/vite@4.5.0_@types+node@20.9.0/node_modules/vite/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/node_modules/vite/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/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/../vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "waku dev --with-ssr",
|
|
8
|
-
"build": "waku build",
|
|
8
|
+
"build": "waku build --with-ssr",
|
|
9
9
|
"start": "waku start --with-ssr"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"express": "^4.18.2",
|
|
13
|
-
"react": "18.3.0-canary-
|
|
14
|
-
"react-dom": "18.3.0-canary-
|
|
15
|
-
"react-server-dom-webpack": "18.3.0-canary-
|
|
16
|
-
"waku": "0.
|
|
13
|
+
"react": "18.3.0-canary-0e352ea01-20231109",
|
|
14
|
+
"react-dom": "18.3.0-canary-0e352ea01-20231109",
|
|
15
|
+
"react-server-dom-webpack": "18.3.0-canary-0e352ea01-20231109",
|
|
16
|
+
"waku": "0.17.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@types/react
|
|
21
|
-
"
|
|
19
|
+
"@swc/core": "1.3.96",
|
|
20
|
+
"@types/react": "^18.2.37",
|
|
21
|
+
"@types/react-dom": "^18.2.15",
|
|
22
|
+
"@vitejs/plugin-react": "4.1.1",
|
|
23
|
+
"typescript": "^5.2.2",
|
|
24
|
+
"vite": "4.5.0"
|
|
22
25
|
}
|
|
23
26
|
}
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
/// Async Server Component
|
|
2
2
|
/// <reference types="react/experimental" />
|
|
3
|
-
import { Suspense } from
|
|
3
|
+
import { Suspense } from 'react';
|
|
4
4
|
|
|
5
|
-
import { Counter } from
|
|
5
|
+
import { Counter } from './Counter.js';
|
|
6
6
|
|
|
7
7
|
const App = ({ name }: { name: string }) => {
|
|
8
8
|
return (
|
|
9
|
-
<div style={{ border:
|
|
9
|
+
<div style={{ border: '3px red dashed', margin: '1em', padding: '1em' }}>
|
|
10
10
|
<h1>Hello {name}!!</h1>
|
|
11
11
|
<h3>This is a server component.</h3>
|
|
12
12
|
<Suspense fallback="Pending...">
|
|
13
13
|
<ServerMessage />
|
|
14
14
|
</Suspense>
|
|
15
|
-
<
|
|
16
|
-
<Counter />
|
|
17
|
-
</Suspense>
|
|
15
|
+
<Counter />
|
|
18
16
|
</div>
|
|
19
17
|
);
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
const ServerMessage = async () => {
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
21
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
24
22
|
return <p>Hello from server!</p>;
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
const CounterSkeleton = () => {
|
|
28
|
-
return (
|
|
29
|
-
<div style={{ border: "3px blue dashed", margin: "1em", padding: "1em" }}>
|
|
30
|
-
<p>Count: {0}</p>
|
|
31
|
-
<button disabled>Increment</button>
|
|
32
|
-
<h3>This is a skeleton component.</h3>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
25
|
export default App;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
import { useState } from
|
|
3
|
+
import { useState } from 'react';
|
|
4
4
|
|
|
5
5
|
export const Counter = () => {
|
|
6
6
|
const [count, setCount] = useState(0);
|
|
7
7
|
return (
|
|
8
|
-
<div style={{ border:
|
|
8
|
+
<div style={{ border: '3px blue dashed', margin: '1em', padding: '1em' }}>
|
|
9
9
|
<p>Count: {count}</p>
|
|
10
10
|
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
|
|
11
11
|
<h3>This is a client component.</h3>
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { lazy } from
|
|
1
|
+
import { lazy } from 'react';
|
|
2
|
+
import { defineEntries } from 'waku/server';
|
|
3
|
+
import { Slot } from 'waku/client';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const App = lazy(() => import("./components/App.js"));
|
|
5
|
+
const App = lazy(() => import('./components/App.js'));
|
|
6
6
|
|
|
7
7
|
export default defineEntries(
|
|
8
8
|
// renderEntries
|
|
9
9
|
async (input) => {
|
|
10
10
|
return {
|
|
11
|
-
App: <App name={input ||
|
|
11
|
+
App: <App name={input || 'Waku'} />,
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
14
|
// getBuildConfig
|
|
15
15
|
async () => {
|
|
16
16
|
return {
|
|
17
|
-
|
|
18
|
-
entries: [[
|
|
17
|
+
'/': {
|
|
18
|
+
entries: [['']],
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
},
|
|
22
22
|
// getSsrConfig
|
|
23
|
-
() =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
23
|
+
async (pathStr) => {
|
|
24
|
+
switch (pathStr) {
|
|
25
|
+
case '/':
|
|
26
|
+
return {
|
|
27
|
+
input: '',
|
|
28
|
+
unstable_render: () => <Slot id="App" />,
|
|
29
|
+
};
|
|
30
|
+
default:
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
34
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>Waku example</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
7
|
<style>
|
|
7
8
|
@keyframes spinner {
|
|
8
9
|
to {
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
<div class="spinner"></div>
|
|
30
31
|
</div>
|
|
31
32
|
<!--/placeholder1-->
|
|
32
|
-
<script src="/main.tsx"
|
|
33
|
+
<script src="/main.tsx" async type="module"></script>
|
|
33
34
|
<!--placeholder2-->
|
|
34
35
|
<!--/placeholder2-->
|
|
35
36
|
</body>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StrictMode } from
|
|
2
|
-
import { hydrateRoot } from
|
|
3
|
-
import { Root, Slot } from
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
3
|
+
import { Root, Slot } from 'waku/client';
|
|
4
4
|
|
|
5
5
|
const rootElement = (
|
|
6
6
|
<StrictMode>
|
|
@@ -10,15 +10,8 @@ const rootElement = (
|
|
|
10
10
|
</StrictMode>
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
) {
|
|
19
|
-
// ignore
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
console.error(err);
|
|
23
|
-
},
|
|
24
|
-
});
|
|
13
|
+
if ((globalThis as any).__WAKU_SSR_ENABLED__) {
|
|
14
|
+
hydrateRoot(document.getElementById('root')!, rootElement);
|
|
15
|
+
} else {
|
|
16
|
+
createRoot(document.getElementById('root')!).render(rootElement);
|
|
17
|
+
}
|
|
@@ -9,14 +9,7 @@
|
|
|
9
9
|
"noUncheckedIndexedAccess": true,
|
|
10
10
|
"exactOptionalPropertyTypes": true,
|
|
11
11
|
"jsx": "react-jsx",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"include": ["./src"],
|
|
17
|
-
"references": [
|
|
18
|
-
{
|
|
19
|
-
"path": "./tsconfig.node.json"
|
|
20
|
-
}
|
|
21
|
-
]
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"outDir": "./dist"
|
|
14
|
+
}
|
|
22
15
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Counter } from
|
|
2
|
+
import { Counter } from './Counter.js';
|
|
3
3
|
const App = ({ name, children }) => {
|
|
4
4
|
const delayedMessage = new Promise((resolve) => {
|
|
5
|
-
setTimeout(() => resolve(
|
|
5
|
+
setTimeout(() => resolve('Hello from server!'), 2000);
|
|
6
6
|
});
|
|
7
|
-
return (_jsxs("div", { style: { border:
|
|
7
|
+
return (_jsxs("div", { style: { border: '3px red dashed', margin: '1em', padding: '1em' }, children: [_jsxs("h1", { children: ["Hello ", name, "!!"] }), _jsx("h3", { children: "This is a server component." }), _jsx(Counter, { delayedMessage: delayedMessage }), children] }));
|
|
8
8
|
};
|
|
9
9
|
export default App;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Suspense, useState } from
|
|
3
|
+
import { Suspense, useState } from 'react';
|
|
4
4
|
export const Counter = ({ delayedMessage, }) => {
|
|
5
5
|
const [count, setCount] = useState(0);
|
|
6
|
-
return (_jsxs("div", { style: { border:
|
|
6
|
+
return (_jsxs("div", { style: { border: '3px blue dashed', margin: '1em', padding: '1em' }, children: [_jsxs("p", { children: ["Count: ", count] }), _jsx("button", { onClick: () => setCount((c) => c + 1), children: "Increment" }), _jsx("h3", { children: "This is a client component." }), _jsx(Suspense, { fallback: "Pending...", children: _jsx(Message, { count: count, delayedMessage: delayedMessage }) })] }));
|
|
7
7
|
};
|
|
8
8
|
const Message = ({ count, delayedMessage, }) => (_jsxs("ul", { children: [_jsxs("li", { children: ["count: ", count] }), _jsxs("li", { children: ["delayedMessage: ", delayedMessage] })] }));
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { lazy } from
|
|
3
|
-
import { defineEntries } from
|
|
4
|
-
import { Children } from
|
|
5
|
-
const App = lazy(() => import(
|
|
2
|
+
import { lazy } from 'react';
|
|
3
|
+
import { defineEntries } from 'waku/server';
|
|
4
|
+
import { Children, Slot } from 'waku/client';
|
|
5
|
+
const App = lazy(() => import('./components/App.js'));
|
|
6
6
|
export default defineEntries(
|
|
7
7
|
// renderEntries
|
|
8
8
|
async (input) => {
|
|
9
9
|
return {
|
|
10
|
-
App: (_jsx(App, { name: input ||
|
|
10
|
+
App: (_jsx(App, { name: input || 'Waku', children: _jsx(Children, {}) })),
|
|
11
11
|
};
|
|
12
12
|
},
|
|
13
13
|
// getBuildConfig
|
|
14
14
|
async () => {
|
|
15
15
|
return {
|
|
16
|
-
|
|
17
|
-
entries: [[
|
|
16
|
+
'/': {
|
|
17
|
+
entries: [['']],
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
},
|
|
21
21
|
// getSsrConfig
|
|
22
|
-
() =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
22
|
+
async (pathStr) => {
|
|
23
|
+
switch (pathStr) {
|
|
24
|
+
case '/':
|
|
25
|
+
return {
|
|
26
|
+
input: '',
|
|
27
|
+
unstable_render: () => (_jsx(Slot, { id: "App", children: _jsx("h3", { children: "A client element" }) })),
|
|
28
|
+
};
|
|
29
|
+
default:
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StrictMode } from
|
|
3
|
-
import { createRoot } from
|
|
4
|
-
import { Root, Slot } from
|
|
2
|
+
import { StrictMode } from 'react';
|
|
3
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
4
|
+
import { Root, Slot } from 'waku/client';
|
|
5
5
|
const rootElement = (_jsx(StrictMode, { children: _jsx(Root, { children: _jsx(Slot, { id: "App", children: _jsx("h3", { children: "A client element" }) }) }) }));
|
|
6
|
-
|
|
6
|
+
if (globalThis.__WAKU_SSR_ENABLED__) {
|
|
7
|
+
hydrateRoot(document.getElementById('root'), rootElement);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
createRoot(document.getElementById('root')).render(rootElement);
|
|
11
|
+
}
|
|
@@ -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/vite@4.5.0_@types+node@20.9.0/node_modules/vite/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/node_modules/vite/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/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/vite@4.5.0_@types+node@20.9.0/node_modules/vite/bin/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/node_modules/vite/node_modules:/home/runner/work/waku/waku/node_modules/.pnpm/vite@4.5.0_@types+node@20.9.0/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/../vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
"private": true,
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "waku dev --with-ssr",
|
|
8
|
-
"build": "waku build",
|
|
8
|
+
"build": "waku build --with-ssr",
|
|
9
9
|
"start": "waku start --with-ssr"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"express": "^4.18.2",
|
|
13
|
-
"react": "18.3.0-canary-
|
|
14
|
-
"react-dom": "18.3.0-canary-
|
|
15
|
-
"react-server-dom-webpack": "18.3.0-canary-
|
|
16
|
-
"waku": "0.
|
|
13
|
+
"react": "18.3.0-canary-0e352ea01-20231109",
|
|
14
|
+
"react-dom": "18.3.0-canary-0e352ea01-20231109",
|
|
15
|
+
"react-server-dom-webpack": "18.3.0-canary-0e352ea01-20231109",
|
|
16
|
+
"waku": "0.17.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@types/react
|
|
21
|
-
"
|
|
19
|
+
"@swc/core": "1.3.96",
|
|
20
|
+
"@types/react": "^18.2.37",
|
|
21
|
+
"@types/react-dom": "^18.2.15",
|
|
22
|
+
"@vitejs/plugin-react": "4.1.1",
|
|
23
|
+
"typescript": "^5.2.2",
|
|
24
|
+
"vite": "4.5.0"
|
|
22
25
|
}
|
|
23
26
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { ReactNode } from
|
|
2
|
-
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Counter } from './Counter.js';
|
|
3
4
|
|
|
4
5
|
const App = ({ name, children }: { name: string; children: ReactNode }) => {
|
|
5
6
|
const delayedMessage = new Promise<string>((resolve) => {
|
|
6
|
-
setTimeout(() => resolve(
|
|
7
|
+
setTimeout(() => resolve('Hello from server!'), 2000);
|
|
7
8
|
});
|
|
8
9
|
return (
|
|
9
|
-
<div style={{ border:
|
|
10
|
+
<div style={{ border: '3px red dashed', margin: '1em', padding: '1em' }}>
|
|
10
11
|
<h1>Hello {name}!!</h1>
|
|
11
12
|
<h3>This is a server component.</h3>
|
|
12
13
|
<Counter delayedMessage={delayedMessage} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
import { Suspense, useState } from
|
|
3
|
+
import { Suspense, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
export const Counter = ({
|
|
6
6
|
delayedMessage,
|
|
@@ -9,7 +9,7 @@ export const Counter = ({
|
|
|
9
9
|
}) => {
|
|
10
10
|
const [count, setCount] = useState(0);
|
|
11
11
|
return (
|
|
12
|
-
<div style={{ border:
|
|
12
|
+
<div style={{ border: '3px blue dashed', margin: '1em', padding: '1em' }}>
|
|
13
13
|
<p>Count: {count}</p>
|
|
14
14
|
<button onClick={() => setCount((c) => c + 1)}>Increment</button>
|
|
15
15
|
<h3>This is a client component.</h3>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { lazy } from
|
|
1
|
+
import { lazy } from 'react';
|
|
2
|
+
import { defineEntries } from 'waku/server';
|
|
3
|
+
import { Children, Slot } from 'waku/client';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
import { Children } from "waku/client";
|
|
5
|
-
|
|
6
|
-
const App = lazy(() => import("./components/App.js"));
|
|
5
|
+
const App = lazy(() => import('./components/App.js'));
|
|
7
6
|
|
|
8
7
|
export default defineEntries(
|
|
9
8
|
// renderEntries
|
|
10
9
|
async (input) => {
|
|
11
10
|
return {
|
|
12
11
|
App: (
|
|
13
|
-
<App name={input ||
|
|
12
|
+
<App name={input || 'Waku'}>
|
|
14
13
|
<Children />
|
|
15
14
|
</App>
|
|
16
15
|
),
|
|
@@ -19,21 +18,25 @@ export default defineEntries(
|
|
|
19
18
|
// getBuildConfig
|
|
20
19
|
async () => {
|
|
21
20
|
return {
|
|
22
|
-
|
|
23
|
-
entries: [[
|
|
21
|
+
'/': {
|
|
22
|
+
entries: [['']],
|
|
24
23
|
},
|
|
25
24
|
};
|
|
26
25
|
},
|
|
27
26
|
// getSsrConfig
|
|
28
|
-
() =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
async (pathStr) => {
|
|
28
|
+
switch (pathStr) {
|
|
29
|
+
case '/':
|
|
30
|
+
return {
|
|
31
|
+
input: '',
|
|
32
|
+
unstable_render: () => (
|
|
33
|
+
<Slot id="App">
|
|
34
|
+
<h3>A client element</h3>
|
|
35
|
+
</Slot>
|
|
36
|
+
),
|
|
37
|
+
};
|
|
38
|
+
default:
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
39
42
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StrictMode } from
|
|
2
|
-
import { createRoot } from
|
|
3
|
-
import { Root, Slot } from
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
3
|
+
import { Root, Slot } from 'waku/client';
|
|
4
4
|
|
|
5
5
|
const rootElement = (
|
|
6
6
|
<StrictMode>
|
|
@@ -12,4 +12,8 @@ const rootElement = (
|
|
|
12
12
|
</StrictMode>
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
if ((globalThis as any).__WAKU_SSR_ENABLED__) {
|
|
16
|
+
hydrateRoot(document.getElementById('root')!, rootElement);
|
|
17
|
+
} else {
|
|
18
|
+
createRoot(document.getElementById('root')!).render(rootElement);
|
|
19
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Counter } from
|
|
3
|
-
import { greet } from
|
|
2
|
+
import { Counter } from './Counter.js';
|
|
3
|
+
import { greet } from './funcs.js';
|
|
4
4
|
const App = ({ name }) => {
|
|
5
|
-
return (_jsxs("div", { style: { border:
|
|
5
|
+
return (_jsxs("div", { style: { border: '3px red dashed', margin: '1em', padding: '1em' }, children: [_jsxs("h1", { children: ["Hello ", name, "!!"] }), _jsx("h3", { children: "This is a server component." }), _jsx(Counter, { greet: greet })] }));
|
|
6
6
|
};
|
|
7
7
|
export default App;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useTransition } from
|
|
3
|
+
import { useState, useTransition } from 'react';
|
|
4
|
+
import { TextBox } from './TextBox.js';
|
|
4
5
|
export const Counter = ({ greet, }) => {
|
|
5
6
|
const [count, setCount] = useState(0);
|
|
6
|
-
const [text, setText] = useState(
|
|
7
|
+
const [text, setText] = useState('');
|
|
7
8
|
const [isPending, startTransition] = useTransition();
|
|
8
9
|
const handleClick = () => {
|
|
9
10
|
startTransition(() => {
|
|
10
|
-
setText(greet(
|
|
11
|
+
setText(greet('c=' + count));
|
|
11
12
|
});
|
|
12
13
|
};
|
|
13
|
-
return (_jsxs("div", { style: { border:
|
|
14
|
+
return (_jsxs("div", { style: { border: '3px blue dashed', margin: '1em', padding: '1em' }, children: [_jsxs("p", { children: ["Count: ", count] }), _jsx("button", { onClick: () => setCount((c) => c + 1), children: "Increment" }), _jsxs("p", { children: [_jsxs("button", { onClick: handleClick, children: ["greet(\"c=\" + count) = ", text] }), ' ', isPending ? 'Pending...' : ''] }), _jsx("h3", { children: "This is a client component." }), _jsx(TextBox, {})] }));
|
|
14
15
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
export const TextBox = () => {
|
|
4
|
+
const [text, setText] = useState('hello');
|
|
5
|
+
return (_jsxs("div", { children: [_jsx("input", { value: text, onChange: (e) => setText(e.target.value) }), _jsx("span", { children: text.toUpperCase() })] }));
|
|
6
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
'use server';
|
|
2
2
|
export const greet = (name) => `Hello ${name} from server!`;
|