create-waku 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/package.json +5 -3
  2. package/template/01_counter/package.json +4 -4
  3. package/template/02_async/package.json +4 -4
  4. package/template/03_promise/package.json +4 -4
  5. package/template/04_callserver/package.json +4 -4
  6. package/template/05_mutation/package.json +4 -4
  7. package/template/06_nesting/package.json +4 -4
  8. package/template/07_router/package.json +4 -4
  9. package/template/08_cookies/db/items.json +12 -0
  10. package/template/08_cookies/package.json +4 -4
  11. package/template/08_cookies/src/components/App.tsx +2 -1
  12. package/template/08_cookies/src/entries.tsx +13 -1
  13. package/template/09_cssmodules/package.json +4 -4
  14. package/template/10_dynamicroute/package.json +4 -4
  15. package/template/11_form/package.json +4 -4
  16. package/template/01_counter/dist/components/App.js +0 -6
  17. package/template/01_counter/dist/components/Counter.js +0 -7
  18. package/template/01_counter/dist/entries.js +0 -32
  19. package/template/01_counter/dist/main.js +0 -11
  20. package/template/02_async/dist/components/App.js +0 -13
  21. package/template/02_async/dist/components/Counter.js +0 -7
  22. package/template/02_async/dist/entries.js +0 -32
  23. package/template/02_async/dist/main.js +0 -11
  24. package/template/03_promise/dist/components/App.js +0 -9
  25. package/template/03_promise/dist/components/Counter.js +0 -8
  26. package/template/03_promise/dist/entries.js +0 -32
  27. package/template/03_promise/dist/main.js +0 -11
  28. package/template/04_callserver/dist/components/App.js +0 -7
  29. package/template/04_callserver/dist/components/Counter.js +0 -15
  30. package/template/04_callserver/dist/components/TextBox.js +0 -6
  31. package/template/04_callserver/dist/components/funcs.js +0 -2
  32. package/template/04_callserver/dist/entries.js +0 -32
  33. package/template/04_callserver/dist/main.js +0 -11
  34. package/template/05_mutation/dist/components/App.js +0 -8
  35. package/template/05_mutation/dist/components/Counter.js +0 -13
  36. package/template/05_mutation/dist/components/funcs.js +0 -9
  37. package/template/05_mutation/dist/entries.js +0 -32
  38. package/template/05_mutation/dist/main.js +0 -11
  39. package/template/06_nesting/dist/components/App.js +0 -6
  40. package/template/06_nesting/dist/components/Counter.js +0 -24
  41. package/template/06_nesting/dist/components/InnerApp.js +0 -6
  42. package/template/06_nesting/dist/entries.js +0 -46
  43. package/template/06_nesting/dist/main.js +0 -11
  44. package/template/07_router/dist/node/tsconfig.node.tsbuildinfo +0 -1
  45. package/template/07_router/dist/node/vite.config.d.ts +0 -15
  46. package/template/07_router/dist/node/vite.config.js +0 -19
  47. package/template/07_router/dist/src/components/Counter.d.ts +0 -1
  48. package/template/07_router/dist/src/components/Counter.js +0 -8
  49. package/template/07_router/dist/src/components/ErrorBoundary.d.ts +0 -7
  50. package/template/07_router/dist/src/components/ErrorBoundary.js +0 -17
  51. package/template/07_router/dist/src/entries.d.ts +0 -6
  52. package/template/07_router/dist/src/entries.js +0 -29
  53. package/template/07_router/dist/src/main.d.ts +0 -1
  54. package/template/07_router/dist/src/main.js +0 -12
  55. package/template/07_router/dist/src/routes/bar/page.d.ts +0 -2
  56. package/template/07_router/dist/src/routes/bar/page.js +0 -4
  57. package/template/07_router/dist/src/routes/foo/page.d.ts +0 -2
  58. package/template/07_router/dist/src/routes/foo/page.js +0 -4
  59. package/template/07_router/dist/src/routes/layout.d.ts +0 -5
  60. package/template/07_router/dist/src/routes/layout.js +0 -9
  61. package/template/07_router/dist/src/routes/nested/baz/page.d.ts +0 -2
  62. package/template/07_router/dist/src/routes/nested/baz/page.js +0 -3
  63. package/template/07_router/dist/src/routes/nested/layout.d.ts +0 -5
  64. package/template/07_router/dist/src/routes/nested/layout.js +0 -4
  65. package/template/07_router/dist/src/routes/nested/qux/page.d.ts +0 -2
  66. package/template/07_router/dist/src/routes/nested/qux/page.js +0 -3
  67. package/template/07_router/dist/src/routes/page.d.ts +0 -2
  68. package/template/07_router/dist/src/routes/page.js +0 -3
  69. package/template/07_router/dist/tsconfig.tsbuildinfo +0 -1
  70. package/template/08_cookies/dist/components/App.js +0 -8
  71. package/template/08_cookies/dist/components/Counter.js +0 -7
  72. package/template/08_cookies/dist/entries.js +0 -35
  73. package/template/08_cookies/dist/main.js +0 -11
  74. package/template/09_cssmodules/dist/components/App.js +0 -8
  75. package/template/09_cssmodules/dist/components/Counter.js +0 -7
  76. package/template/09_cssmodules/dist/entries.js +0 -32
  77. package/template/09_cssmodules/dist/main.js +0 -11
  78. package/template/10_dynamicroute/dist/node/tsconfig.node.tsbuildinfo +0 -1
  79. package/template/10_dynamicroute/dist/node/vite.config.d.ts +0 -15
  80. package/template/10_dynamicroute/dist/node/vite.config.js +0 -19
  81. package/template/10_dynamicroute/dist/src/entries.d.ts +0 -6
  82. package/template/10_dynamicroute/dist/src/entries.js +0 -61
  83. package/template/10_dynamicroute/dist/src/main.d.ts +0 -1
  84. package/template/10_dynamicroute/dist/src/main.js +0 -11
  85. package/template/10_dynamicroute/dist/src/routes/[name]/page.d.ts +0 -4
  86. package/template/10_dynamicroute/dist/src/routes/[name]/page.js +0 -3
  87. package/template/10_dynamicroute/dist/src/routes/layout.d.ts +0 -5
  88. package/template/10_dynamicroute/dist/src/routes/layout.js +0 -4
  89. package/template/10_dynamicroute/dist/src/routes/page.d.ts +0 -2
  90. package/template/10_dynamicroute/dist/src/routes/page.js +0 -3
  91. package/template/10_dynamicroute/dist/tsconfig.tsbuildinfo +0 -1
  92. package/template/11_form/dist/components/App.js +0 -8
  93. package/template/11_form/dist/components/Counter.js +0 -13
  94. package/template/11_form/dist/components/Form.js +0 -10
  95. package/template/11_form/dist/components/funcs.js +0 -10
  96. package/template/11_form/dist/entries.js +0 -32
  97. package/template/11_form/dist/main.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-waku",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "author": "Daishi Kato",
5
5
  "type": "module",
6
6
  "contributors": [
@@ -10,7 +10,9 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/dai-shi/waku.git"
12
12
  },
13
- "bin": "./dist/cli.js",
13
+ "bin": {
14
+ "create-waku": "./dist/cli.js"
15
+ },
14
16
  "files": [
15
17
  "src",
16
18
  "dist",
@@ -28,7 +30,7 @@
28
30
  "scripts": {
29
31
  "start": "node dist/cli.js",
30
32
  "compile": "rm -rf template dist *.tsbuildinfo && pnpm run template && pnpm run build",
31
- "template": "cp -r ../../examples template/",
33
+ "template": "cp -r ../../examples template/ && rm -rf template/*/dist && rm -rf template/node_modules",
32
34
  "build": "tsc -b"
33
35
  }
34
36
  }
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -10,11 +10,11 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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",
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
16
  "react-wrap-balancer": "^1.1.0",
17
- "waku": "0.17.0"
17
+ "waku": "0.17.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@swc/core": "1.3.96",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -11,10 +11,10 @@
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
13
13
  "glob": "^10.3.10",
14
- "react": "18.3.0-canary-0e352ea01-20231109",
15
- "react-dom": "18.3.0-canary-0e352ea01-20231109",
16
- "react-server-dom-webpack": "18.3.0-canary-0e352ea01-20231109",
17
- "waku": "0.17.0"
14
+ "react": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
16
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
17
+ "waku": "0.17.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@swc/core": "1.3.96",
@@ -0,0 +1,12 @@
1
+ [
2
+ { "id": 1, "name": "John" },
3
+ { "id": 2, "name": "Jane" },
4
+ { "id": 3, "name": "Bob" },
5
+ { "id": 4, "name": "Mary" },
6
+ { "id": 5, "name": "Peter" },
7
+ { "id": 6, "name": "Kate" },
8
+ { "id": 7, "name": "Mike" },
9
+ { "id": 8, "name": "Liz" },
10
+ { "id": 9, "name": "Steve" },
11
+ { "id": 10, "name": "Sue" }
12
+ ]
@@ -11,10 +11,10 @@
11
11
  "dependencies": {
12
12
  "cookie-parser": "^1.4.6",
13
13
  "express": "^4.18.2",
14
- "react": "18.3.0-canary-0e352ea01-20231109",
15
- "react-dom": "18.3.0-canary-0e352ea01-20231109",
16
- "react-server-dom-webpack": "18.3.0-canary-0e352ea01-20231109",
17
- "waku": "0.17.0"
14
+ "react": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
16
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
17
+ "waku": "0.17.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@swc/core": "1.3.96",
@@ -1,7 +1,7 @@
1
1
  import { getContext } from 'waku/server';
2
2
  import { Counter } from './Counter.js';
3
3
 
4
- const App = ({ name }: { name: string }) => {
4
+ const App = ({ name, items }: { name: string; items: unknown[] }) => {
5
5
  const ctx = getContext<{ count: number }>();
6
6
  return (
7
7
  <div style={{ border: '3px red dashed', margin: '1em', padding: '1em' }}>
@@ -9,6 +9,7 @@ const App = ({ name }: { name: string }) => {
9
9
  <h3>This is a server component.</h3>
10
10
  <p>Cookie count: {ctx.count}</p>
11
11
  <Counter />
12
+ <p>Item count: {items.length}</p>
12
13
  </div>
13
14
  );
14
15
  };
@@ -1,3 +1,6 @@
1
+ import path from 'node:path';
2
+ import url from 'node:url';
3
+ import fsPromises from 'node:fs/promises';
1
4
  import { lazy } from 'react';
2
5
  import { defineEntries, getContext } from 'waku/server';
3
6
  import { Slot } from 'waku/client';
@@ -9,8 +12,17 @@ export default defineEntries(
9
12
  async (input) => {
10
13
  const ctx = getContext<{ count: number }>();
11
14
  ++ctx.count;
15
+ const items = JSON.parse(
16
+ await fsPromises.readFile(
17
+ path.join(
18
+ path.dirname(url.fileURLToPath(import.meta.url)),
19
+ '../db/items.json',
20
+ ),
21
+ 'utf8',
22
+ ),
23
+ );
12
24
  return {
13
- App: <App name={input || 'Waku'} />,
25
+ App: <App name={input || 'Waku'} items={items} />,
14
26
  };
15
27
  },
16
28
  // getBuildConfig
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -11,10 +11,10 @@
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
13
13
  "glob": "^10.3.10",
14
- "react": "18.3.0-canary-0e352ea01-20231109",
15
- "react-dom": "18.3.0-canary-0e352ea01-20231109",
16
- "react-server-dom-webpack": "18.3.0-canary-0e352ea01-20231109",
17
- "waku": "0.17.0"
14
+ "react": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
16
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
17
+ "waku": "0.17.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@swc/core": "1.3.96",
@@ -10,10 +10,10 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "express": "^4.18.2",
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"
13
+ "react": "18.3.0-canary-6c7b41da3-20231123",
14
+ "react-dom": "18.3.0-canary-6c7b41da3-20231123",
15
+ "react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123",
16
+ "waku": "0.17.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@swc/core": "1.3.96",
@@ -1,6 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Counter } from './Counter.js';
3
- const App = ({ name }) => {
4
- 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, {})] }));
5
- };
6
- export default App;
@@ -1,7 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from 'react';
4
- export const Counter = () => {
5
- const [count, setCount] = useState(0);
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
- };
@@ -1,32 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- /// Async Server Component
3
- /// <reference types="react/experimental" />
4
- import { Suspense } from 'react';
5
- import { Counter } from './Counter.js';
6
- const App = ({ name }) => {
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(Suspense, { fallback: "Pending...", children: _jsx(ServerMessage, {}) }), _jsx(Counter, {})] }));
8
- };
9
- const ServerMessage = async () => {
10
- await new Promise((resolve) => setTimeout(resolve, 2000));
11
- return _jsx("p", { children: "Hello from server!" });
12
- };
13
- export default App;
@@ -1,7 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from 'react';
4
- export const Counter = () => {
5
- const [count, setCount] = useState(0);
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
- };
@@ -1,32 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Counter } from './Counter.js';
3
- const App = ({ name, children }) => {
4
- const delayedMessage = new Promise((resolve) => {
5
- setTimeout(() => resolve('Hello from server!'), 2000);
6
- });
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
- };
9
- export default App;
@@ -1,8 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { Suspense, useState } from 'react';
4
- export const Counter = ({ delayedMessage, }) => {
5
- const [count, setCount] = useState(0);
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
- };
8
- const Message = ({ count, delayedMessage, }) => (_jsxs("ul", { children: [_jsxs("li", { children: ["count: ", count] }), _jsxs("li", { children: ["delayedMessage: ", delayedMessage] })] }));
@@ -1,32 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
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
- export default defineEntries(
7
- // renderEntries
8
- async (input) => {
9
- return {
10
- App: (_jsx(App, { name: input || 'Waku', children: _jsx(Children, {}) })),
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", children: _jsx("h3", { children: "A client element" }) })),
28
- };
29
- default:
30
- return null;
31
- }
32
- });
@@ -1,11 +0,0 @@
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", children: _jsx("h3", { children: "A client element" }) }) }) }));
6
- if (globalThis.__WAKU_SSR_ENABLED__) {
7
- hydrateRoot(document.getElementById('root'), rootElement);
8
- }
9
- else {
10
- createRoot(document.getElementById('root')).render(rootElement);
11
- }
@@ -1,7 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Counter } from './Counter.js';
3
- import { greet } from './funcs.js';
4
- const App = ({ name }) => {
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
- };
7
- export default App;
@@ -1,15 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState, useTransition } from 'react';
4
- import { TextBox } from './TextBox.js';
5
- export const Counter = ({ greet, }) => {
6
- const [count, setCount] = useState(0);
7
- const [text, setText] = useState('');
8
- const [isPending, startTransition] = useTransition();
9
- const handleClick = () => {
10
- startTransition(() => {
11
- setText(greet('c=' + count));
12
- });
13
- };
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, {})] }));
15
- };
@@ -1,6 +0,0 @@
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 +0,0 @@
1
- 'use server';
2
- export const greet = (name) => `Hello ${name} from server!`;
@@ -1,32 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Balancer } from 'react-wrap-balancer';
3
- import { Counter } from './Counter.js';
4
- import { getCounter, increment } from './funcs.js';
5
- const App = ({ name }) => {
6
- 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." }), _jsxs("p", { children: ["Server counter: ", getCounter()] }), _jsx(Counter, { increment: increment }), _jsx(Balancer, { children: "My Awesome Title" })] }));
7
- };
8
- export default App;
@@ -1,13 +0,0 @@
1
- 'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState, useTransition } from 'react';
4
- export const Counter = ({ increment }) => {
5
- const [count, setCount] = useState(0);
6
- const [isPending, startTransition] = useTransition();
7
- const handleClick = () => {
8
- startTransition(() => {
9
- increment();
10
- });
11
- };
12
- 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: [_jsx("button", { onClick: handleClick, children: "Increment server counter" }), ' ', isPending ? 'Pending...' : ''] }), _jsx("h3", { children: "This is a client component." })] }));
13
- };
@@ -1,9 +0,0 @@
1
- 'use server';
2
- import { rerender } from 'waku/server';
3
- // module state on server
4
- let counter = 0;
5
- export const getCounter = () => counter;
6
- export const increment = () => {
7
- counter += 1;
8
- rerender('Waku');
9
- };
@@ -1,32 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
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
- }