create-waku 0.6.1 → 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.
Files changed (124) hide show
  1. package/dist/cli.d.ts +2 -0
  2. package/dist/cli.js +131 -0
  3. package/package.json +2 -2
  4. package/src/cli.ts +45 -45
  5. package/template/01_counter/dist/components/App.js +2 -2
  6. package/template/01_counter/dist/components/Counter.js +3 -3
  7. package/template/01_counter/dist/entries.js +9 -9
  8. package/template/01_counter/dist/main.js +5 -5
  9. package/template/01_counter/src/components/App.tsx +2 -2
  10. package/template/01_counter/src/components/Counter.tsx +3 -3
  11. package/template/01_counter/src/entries.tsx +9 -9
  12. package/template/01_counter/src/main.tsx +5 -5
  13. package/template/02_async/dist/components/App.js +3 -3
  14. package/template/02_async/dist/components/Counter.js +3 -3
  15. package/template/02_async/dist/entries.js +9 -9
  16. package/template/02_async/dist/main.js +5 -5
  17. package/template/02_async/src/components/App.tsx +3 -3
  18. package/template/02_async/src/components/Counter.tsx +3 -3
  19. package/template/02_async/src/entries.tsx +9 -9
  20. package/template/02_async/src/main.tsx +5 -5
  21. package/template/03_promise/dist/components/App.js +3 -3
  22. package/template/03_promise/dist/components/Counter.js +3 -3
  23. package/template/03_promise/dist/entries.js +9 -9
  24. package/template/03_promise/dist/main.js +5 -5
  25. package/template/03_promise/src/components/App.tsx +4 -4
  26. package/template/03_promise/src/components/Counter.tsx +3 -3
  27. package/template/03_promise/src/entries.tsx +9 -9
  28. package/template/03_promise/src/main.tsx +5 -5
  29. package/template/04_callserver/dist/components/App.js +3 -3
  30. package/template/04_callserver/dist/components/Counter.js +6 -6
  31. package/template/04_callserver/dist/components/TextBox.js +2 -2
  32. package/template/04_callserver/dist/components/funcs.js +1 -1
  33. package/template/04_callserver/dist/entries.js +9 -9
  34. package/template/04_callserver/dist/main.js +5 -5
  35. package/template/04_callserver/src/components/App.tsx +3 -3
  36. package/template/04_callserver/src/components/Counter.tsx +8 -8
  37. package/template/04_callserver/src/components/TextBox.tsx +2 -2
  38. package/template/04_callserver/src/components/funcs.ts +1 -1
  39. package/template/04_callserver/src/entries.tsx +9 -9
  40. package/template/04_callserver/src/main.tsx +5 -5
  41. package/template/05_mutation/dist/components/App.js +4 -4
  42. package/template/05_mutation/dist/components/Counter.js +3 -3
  43. package/template/05_mutation/dist/components/funcs.js +3 -3
  44. package/template/05_mutation/dist/entries.js +9 -9
  45. package/template/05_mutation/dist/main.js +5 -5
  46. package/template/05_mutation/src/components/App.tsx +4 -4
  47. package/template/05_mutation/src/components/Counter.tsx +5 -5
  48. package/template/05_mutation/src/components/funcs.ts +3 -3
  49. package/template/05_mutation/src/entries.tsx +9 -9
  50. package/template/05_mutation/src/main.tsx +5 -5
  51. package/template/06_nesting/dist/components/App.js +2 -2
  52. package/template/06_nesting/dist/components/Counter.js +5 -5
  53. package/template/06_nesting/dist/components/InnerApp.js +2 -2
  54. package/template/06_nesting/dist/entries.js +19 -19
  55. package/template/06_nesting/dist/main.js +5 -5
  56. package/template/06_nesting/src/components/App.tsx +2 -2
  57. package/template/06_nesting/src/components/Counter.tsx +7 -7
  58. package/template/06_nesting/src/components/InnerApp.tsx +2 -2
  59. package/template/06_nesting/src/entries.tsx +20 -20
  60. package/template/06_nesting/src/main.tsx +5 -5
  61. package/template/07_router/dist/node/tsconfig.node.tsbuildinfo +1 -1
  62. package/template/07_router/dist/node/vite.config.js +4 -4
  63. package/template/07_router/dist/src/components/Counter.js +4 -4
  64. package/template/07_router/dist/src/components/ErrorBoundary.d.ts +1 -1
  65. package/template/07_router/dist/src/components/ErrorBoundary.js +2 -2
  66. package/template/07_router/dist/src/entries.js +9 -9
  67. package/template/07_router/dist/src/main.js +6 -6
  68. package/template/07_router/dist/src/routes/bar/page.js +1 -1
  69. package/template/07_router/dist/src/routes/foo/page.js +1 -1
  70. package/template/07_router/dist/src/routes/layout.d.ts +1 -1
  71. package/template/07_router/dist/src/routes/layout.js +2 -2
  72. package/template/07_router/dist/src/routes/nested/layout.d.ts +1 -1
  73. package/template/07_router/dist/src/routes/nested/layout.js +1 -1
  74. package/template/07_router/dist/tsconfig.tsbuildinfo +1 -1
  75. package/template/07_router/src/components/Counter.tsx +4 -4
  76. package/template/07_router/src/components/ErrorBoundary.tsx +3 -3
  77. package/template/07_router/src/entries.tsx +9 -9
  78. package/template/07_router/src/main.tsx +6 -6
  79. package/template/07_router/src/routes/bar/page.tsx +1 -1
  80. package/template/07_router/src/routes/foo/page.tsx +1 -1
  81. package/template/07_router/src/routes/layout.tsx +3 -3
  82. package/template/07_router/src/routes/nested/layout.tsx +2 -2
  83. package/template/07_router/vite.config.ts +4 -4
  84. package/template/08_cookies/dev.js +7 -7
  85. package/template/08_cookies/dist/components/App.js +3 -3
  86. package/template/08_cookies/dist/components/Counter.js +3 -3
  87. package/template/08_cookies/dist/entries.js +9 -9
  88. package/template/08_cookies/dist/main.js +5 -5
  89. package/template/08_cookies/src/components/App.tsx +3 -3
  90. package/template/08_cookies/src/components/Counter.tsx +3 -3
  91. package/template/08_cookies/src/entries.tsx +9 -9
  92. package/template/08_cookies/src/main.tsx +5 -5
  93. package/template/08_cookies/start.js +12 -12
  94. package/template/09_cssmodules/dist/components/App.js +3 -3
  95. package/template/09_cssmodules/dist/components/Counter.js +3 -3
  96. package/template/09_cssmodules/dist/entries.js +9 -9
  97. package/template/09_cssmodules/dist/main.js +5 -5
  98. package/template/09_cssmodules/src/components/App.tsx +3 -3
  99. package/template/09_cssmodules/src/components/Counter.tsx +3 -3
  100. package/template/09_cssmodules/src/entries.tsx +9 -9
  101. package/template/09_cssmodules/src/main.tsx +5 -5
  102. package/template/10_dynamicroute/dist/node/tsconfig.node.tsbuildinfo +1 -1
  103. package/template/10_dynamicroute/dist/node/vite.config.js +4 -4
  104. package/template/10_dynamicroute/dist/src/entries.js +15 -15
  105. package/template/10_dynamicroute/dist/src/main.js +5 -5
  106. package/template/10_dynamicroute/dist/src/routes/layout.d.ts +1 -1
  107. package/template/10_dynamicroute/dist/src/routes/layout.js +1 -1
  108. package/template/10_dynamicroute/dist/tsconfig.tsbuildinfo +1 -1
  109. package/template/10_dynamicroute/src/entries.tsx +15 -15
  110. package/template/10_dynamicroute/src/main.tsx +5 -5
  111. package/template/10_dynamicroute/src/routes/layout.tsx +2 -2
  112. package/template/10_dynamicroute/vite.config.ts +4 -4
  113. package/template/11_form/dist/components/App.js +4 -4
  114. package/template/11_form/dist/components/Counter.js +4 -4
  115. package/template/11_form/dist/components/Form.js +4 -4
  116. package/template/11_form/dist/components/funcs.js +5 -5
  117. package/template/11_form/dist/entries.js +9 -9
  118. package/template/11_form/dist/main.js +5 -5
  119. package/template/11_form/src/components/App.tsx +4 -4
  120. package/template/11_form/src/components/Counter.tsx +4 -4
  121. package/template/11_form/src/components/Form.tsx +4 -4
  122. package/template/11_form/src/components/funcs.ts +5 -5
  123. package/template/11_form/src/entries.tsx +9 -9
  124. package/template/11_form/src/main.tsx +5 -5
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { default as prompts } from 'prompts';
5
+ import { red, green, bold } from 'kolorist';
6
+ import fse from 'fs-extra/esm';
7
+ import { fileURLToPath } from 'node:url';
8
+ function isValidPackageName(projectName) {
9
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
10
+ }
11
+ function toValidPackageName(projectName) {
12
+ return projectName
13
+ .trim()
14
+ .toLowerCase()
15
+ .replace(/\s+/g, '-')
16
+ .replace(/^[._]/, '')
17
+ .replace(/[^a-z0-9-~]+/g, '-');
18
+ }
19
+ // if the dir is empty or not exist
20
+ function canSafelyOverwrite(dir) {
21
+ return !fs.existsSync(dir) || fs.readdirSync(dir).length === 0;
22
+ }
23
+ async function init() {
24
+ let targetDir = '';
25
+ const defaultProjectName = 'waku-project';
26
+ const templateRoot = fileURLToPath(new URL('../template', import.meta.url));
27
+ const CHOICES = fs.readdirSync(templateRoot);
28
+ let result;
29
+ try {
30
+ result = await prompts([
31
+ {
32
+ name: 'projectName',
33
+ type: 'text',
34
+ message: 'Project Name',
35
+ initial: defaultProjectName,
36
+ onState: (state) => (targetDir = String(state.value).trim() || defaultProjectName),
37
+ },
38
+ {
39
+ name: 'shouldOverwrite',
40
+ type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'),
41
+ message: `${targetDir} is not empty. Remove existing files and continue?`,
42
+ },
43
+ {
44
+ name: 'overwriteChecker',
45
+ type: (values) => {
46
+ if (values === false) {
47
+ throw new Error(red('✖') + ' Operation cancelled');
48
+ }
49
+ return null;
50
+ },
51
+ },
52
+ {
53
+ name: 'packageName',
54
+ type: () => (isValidPackageName(targetDir) ? null : 'text'),
55
+ message: 'Package name',
56
+ initial: () => toValidPackageName(targetDir),
57
+ validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name',
58
+ },
59
+ {
60
+ name: 'chooseProject',
61
+ type: 'select',
62
+ message: 'Choose a starter template',
63
+ choices: [
64
+ { title: 'basic-template', value: CHOICES[0] },
65
+ { title: 'async-template', value: CHOICES[1] },
66
+ { title: 'promise-template', value: CHOICES[2] },
67
+ ],
68
+ },
69
+ ], {
70
+ onCancel: () => {
71
+ throw new Error(red('✖') + ' Operation cancelled');
72
+ },
73
+ });
74
+ }
75
+ catch (cancelled) {
76
+ if (cancelled instanceof Error) {
77
+ console.log(cancelled.message);
78
+ }
79
+ process.exit(1);
80
+ }
81
+ const { packageName, shouldOverwrite, chooseProject } = result;
82
+ const root = path.resolve(targetDir);
83
+ if (shouldOverwrite) {
84
+ fse.emptyDirSync(root);
85
+ }
86
+ else if (!fs.existsSync(root)) {
87
+ fs.mkdirSync(root, { recursive: true });
88
+ }
89
+ const pkg = {
90
+ name: packageName ?? toValidPackageName(targetDir),
91
+ version: '0.0.0',
92
+ };
93
+ console.log('Setting up project...');
94
+ const templateDir = path.join(templateRoot, chooseProject);
95
+ // Read existing package.json from the root directory
96
+ const packageJsonPath = path.join(root, 'package.json');
97
+ // Read new package.json from the template directory
98
+ const newPackageJsonPath = path.join(templateDir, 'package.json');
99
+ const newPackageJson = JSON.parse(fs.readFileSync(newPackageJsonPath, 'utf-8'));
100
+ fse.copySync(templateDir, root);
101
+ fs.writeFileSync(packageJsonPath, JSON.stringify({
102
+ ...newPackageJson,
103
+ ...pkg,
104
+ }, null, 2));
105
+ const manager = process.env.npm_config_user_agent ?? '';
106
+ const packageManager = /pnpm/.test(manager)
107
+ ? 'pnpm'
108
+ : /yarn/.test(manager)
109
+ ? 'yarn'
110
+ : 'npm';
111
+ const commandsMap = {
112
+ install: {
113
+ pnpm: 'pnpm install',
114
+ yarn: 'yarn',
115
+ npm: 'npm install',
116
+ },
117
+ dev: {
118
+ pnpm: 'pnpm dev',
119
+ yarn: 'yarn dev',
120
+ npm: 'npm run dev',
121
+ },
122
+ };
123
+ console.log(`\nDone. Now run:\n`);
124
+ console.log(`${bold(green(`cd ${targetDir}`))}`);
125
+ console.log(`${bold(green(commandsMap.install[packageManager]))}`);
126
+ console.log(`${bold(green(commandsMap.dev[packageManager]))}`);
127
+ console.log();
128
+ }
129
+ init().catch((e) => {
130
+ console.error(e);
131
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-waku",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "author": "Daishi Kato",
5
5
  "type": "module",
6
6
  "contributors": [
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "scripts": {
29
29
  "start": "node dist/cli.js",
30
- "compile": "rm -rf template dist && pnpm run template && pnpm run build",
30
+ "compile": "rm -rf template dist *.tsbuildinfo && pnpm run template && pnpm run build",
31
31
  "template": "cp -r ../../examples template/",
32
32
  "build": "tsc -b"
33
33
  }
package/src/cli.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import { default as prompts } from "prompts";
6
- import { red, green, bold } from "kolorist";
7
- import fse from "fs-extra/esm";
8
- import { fileURLToPath } from "node:url";
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { default as prompts } from 'prompts';
6
+ import { red, green, bold } from 'kolorist';
7
+ import fse from 'fs-extra/esm';
8
+ import { fileURLToPath } from 'node:url';
9
9
 
10
10
  function isValidPackageName(projectName: string) {
11
11
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
@@ -17,9 +17,9 @@ function toValidPackageName(projectName: string) {
17
17
  return projectName
18
18
  .trim()
19
19
  .toLowerCase()
20
- .replace(/\s+/g, "-")
21
- .replace(/^[._]/, "")
22
- .replace(/[^a-z0-9-~]+/g, "-");
20
+ .replace(/\s+/g, '-')
21
+ .replace(/^[._]/, '')
22
+ .replace(/[^a-z0-9-~]+/g, '-');
23
23
  }
24
24
 
25
25
  // if the dir is empty or not exist
@@ -28,10 +28,10 @@ function canSafelyOverwrite(dir: string) {
28
28
  }
29
29
 
30
30
  async function init() {
31
- let targetDir = "";
32
- const defaultProjectName = "waku-project";
31
+ let targetDir = '';
32
+ const defaultProjectName = 'waku-project';
33
33
 
34
- const templateRoot = fileURLToPath(new URL("../template", import.meta.url));
34
+ const templateRoot = fileURLToPath(new URL('../template', import.meta.url));
35
35
  const CHOICES = fs.readdirSync(templateRoot);
36
36
  let result: {
37
37
  packageName: string;
@@ -43,49 +43,49 @@ async function init() {
43
43
  result = await prompts(
44
44
  [
45
45
  {
46
- name: "projectName",
47
- type: "text",
48
- message: "Project Name",
46
+ name: 'projectName',
47
+ type: 'text',
48
+ message: 'Project Name',
49
49
  initial: defaultProjectName,
50
50
  onState: (state: any) =>
51
51
  (targetDir = String(state.value).trim() || defaultProjectName),
52
52
  },
53
53
  {
54
- name: "shouldOverwrite",
55
- type: () => (canSafelyOverwrite(targetDir) ? null : "confirm"),
54
+ name: 'shouldOverwrite',
55
+ type: () => (canSafelyOverwrite(targetDir) ? null : 'confirm'),
56
56
  message: `${targetDir} is not empty. Remove existing files and continue?`,
57
57
  },
58
58
  {
59
- name: "overwriteChecker",
59
+ name: 'overwriteChecker',
60
60
  type: (values: any) => {
61
61
  if (values === false) {
62
- throw new Error(red("") + " Operation cancelled");
62
+ throw new Error(red('') + ' Operation cancelled');
63
63
  }
64
64
  return null;
65
65
  },
66
66
  },
67
67
  {
68
- name: "packageName",
69
- type: () => (isValidPackageName(targetDir) ? null : "text"),
70
- message: "Package name",
68
+ name: 'packageName',
69
+ type: () => (isValidPackageName(targetDir) ? null : 'text'),
70
+ message: 'Package name',
71
71
  initial: () => toValidPackageName(targetDir),
72
72
  validate: (dir: string) =>
73
- isValidPackageName(dir) || "Invalid package.json name",
73
+ isValidPackageName(dir) || 'Invalid package.json name',
74
74
  },
75
75
  {
76
- name: "chooseProject",
77
- type: "select",
78
- message: "Choose a starter template",
76
+ name: 'chooseProject',
77
+ type: 'select',
78
+ message: 'Choose a starter template',
79
79
  choices: [
80
- { title: "basic-template", value: CHOICES[0] },
81
- { title: "async-template", value: CHOICES[1] },
82
- { title: "promise-template", value: CHOICES[2] },
80
+ { title: 'basic-template', value: CHOICES[0] },
81
+ { title: 'async-template', value: CHOICES[1] },
82
+ { title: 'promise-template', value: CHOICES[2] },
83
83
  ],
84
84
  },
85
85
  ],
86
86
  {
87
87
  onCancel: () => {
88
- throw new Error(red("") + " Operation cancelled");
88
+ throw new Error(red('') + ' Operation cancelled');
89
89
  },
90
90
  },
91
91
  );
@@ -108,20 +108,20 @@ async function init() {
108
108
 
109
109
  const pkg = {
110
110
  name: packageName ?? toValidPackageName(targetDir),
111
- version: "0.0.0",
111
+ version: '0.0.0',
112
112
  };
113
113
 
114
- console.log("Setting up project...");
114
+ console.log('Setting up project...');
115
115
 
116
116
  const templateDir = path.join(templateRoot, chooseProject);
117
117
 
118
118
  // Read existing package.json from the root directory
119
- const packageJsonPath = path.join(root, "package.json");
119
+ const packageJsonPath = path.join(root, 'package.json');
120
120
 
121
121
  // Read new package.json from the template directory
122
- const newPackageJsonPath = path.join(templateDir, "package.json");
122
+ const newPackageJsonPath = path.join(templateDir, 'package.json');
123
123
  const newPackageJson = JSON.parse(
124
- fs.readFileSync(newPackageJsonPath, "utf-8"),
124
+ fs.readFileSync(newPackageJsonPath, 'utf-8'),
125
125
  );
126
126
 
127
127
  fse.copySync(templateDir, root);
@@ -138,23 +138,23 @@ async function init() {
138
138
  ),
139
139
  );
140
140
 
141
- const manager = process.env.npm_config_user_agent ?? "";
141
+ const manager = process.env.npm_config_user_agent ?? '';
142
142
  const packageManager = /pnpm/.test(manager)
143
- ? "pnpm"
143
+ ? 'pnpm'
144
144
  : /yarn/.test(manager)
145
- ? "yarn"
146
- : "npm";
145
+ ? 'yarn'
146
+ : 'npm';
147
147
 
148
148
  const commandsMap = {
149
149
  install: {
150
- pnpm: "pnpm install",
151
- yarn: "yarn",
152
- npm: "npm install",
150
+ pnpm: 'pnpm install',
151
+ yarn: 'yarn',
152
+ npm: 'npm install',
153
153
  },
154
154
  dev: {
155
- pnpm: "pnpm dev",
156
- yarn: "yarn dev",
157
- npm: "npm run dev",
155
+ pnpm: 'pnpm dev',
156
+ yarn: 'yarn dev',
157
+ npm: 'npm run dev',
158
158
  },
159
159
  };
160
160
 
@@ -1,6 +1,6 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { Counter } from "./Counter.js";
2
+ import { Counter } from './Counter.js';
3
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, {})] }));
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
5
  };
6
6
  export default App;
@@ -1,7 +1,7 @@
1
- "use client";
1
+ 'use client';
2
2
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from "react";
3
+ import { useState } from 'react';
4
4
  export const Counter = () => {
5
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." })] }));
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
  };
@@ -1,29 +1,29 @@
1
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"));
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
6
  export default defineEntries(
7
7
  // renderEntries
8
8
  async (input) => {
9
9
  return {
10
- App: _jsx(App, { name: input || "Waku" }),
10
+ App: _jsx(App, { name: input || 'Waku' }),
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
22
  async (pathStr) => {
23
23
  switch (pathStr) {
24
- case "/":
24
+ case '/':
25
25
  return {
26
- input: "",
26
+ input: '',
27
27
  unstable_render: () => _jsx(Slot, { id: "App" }),
28
28
  };
29
29
  default:
@@ -1,11 +1,11 @@
1
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";
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" }) }) }));
6
6
  if (globalThis.__WAKU_SSR_ENABLED__) {
7
- hydrateRoot(document.getElementById("root"), rootElement);
7
+ hydrateRoot(document.getElementById('root'), rootElement);
8
8
  }
9
9
  else {
10
- createRoot(document.getElementById("root")).render(rootElement);
10
+ createRoot(document.getElementById('root')).render(rootElement);
11
11
  }
@@ -1,8 +1,8 @@
1
- import { Counter } from "./Counter.js";
1
+ import { Counter } from './Counter.js';
2
2
 
3
3
  const App = ({ name }: { name: string }) => {
4
4
  return (
5
- <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
5
+ <div style={{ border: '3px red dashed', margin: '1em', padding: '1em' }}>
6
6
  <h1>Hello {name}!!</h1>
7
7
  <h3>This is a server component.</h3>
8
8
  <Counter />
@@ -1,11 +1,11 @@
1
- "use client";
1
+ 'use client';
2
2
 
3
- import { useState } from "react";
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: "3px blue dashed", margin: "1em", padding: "1em" }}>
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,30 +1,30 @@
1
- import { lazy } from "react";
2
- import { defineEntries } from "waku/server";
3
- import { Slot } from "waku/client";
1
+ import { lazy } from 'react';
2
+ import { defineEntries } from 'waku/server';
3
+ import { Slot } from 'waku/client';
4
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 || "Waku"} />,
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
23
  async (pathStr) => {
24
24
  switch (pathStr) {
25
- case "/":
25
+ case '/':
26
26
  return {
27
- input: "",
27
+ input: '',
28
28
  unstable_render: () => <Slot id="App" />,
29
29
  };
30
30
  default:
@@ -1,6 +1,6 @@
1
- import { StrictMode } from "react";
2
- import { createRoot, hydrateRoot } from "react-dom/client";
3
- import { Root, Slot } from "waku/client";
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>
@@ -11,7 +11,7 @@ const rootElement = (
11
11
  );
12
12
 
13
13
  if ((globalThis as any).__WAKU_SSR_ENABLED__) {
14
- hydrateRoot(document.getElementById("root")!, rootElement);
14
+ hydrateRoot(document.getElementById('root')!, rootElement);
15
15
  } else {
16
- createRoot(document.getElementById("root")!).render(rootElement);
16
+ createRoot(document.getElementById('root')!).render(rootElement);
17
17
  }
@@ -1,10 +1,10 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  /// Async Server Component
3
3
  /// <reference types="react/experimental" />
4
- import { Suspense } from "react";
5
- import { Counter } from "./Counter.js";
4
+ import { Suspense } from 'react';
5
+ import { Counter } from './Counter.js';
6
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, {})] }));
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
8
  };
9
9
  const ServerMessage = async () => {
10
10
  await new Promise((resolve) => setTimeout(resolve, 2000));
@@ -1,7 +1,7 @@
1
- "use client";
1
+ 'use client';
2
2
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { useState } from "react";
3
+ import { useState } from 'react';
4
4
  export const Counter = () => {
5
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." })] }));
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
  };
@@ -1,29 +1,29 @@
1
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"));
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
6
  export default defineEntries(
7
7
  // renderEntries
8
8
  async (input) => {
9
9
  return {
10
- App: _jsx(App, { name: input || "Waku" }),
10
+ App: _jsx(App, { name: input || 'Waku' }),
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
22
  async (pathStr) => {
23
23
  switch (pathStr) {
24
- case "/":
24
+ case '/':
25
25
  return {
26
- input: "",
26
+ input: '',
27
27
  unstable_render: () => _jsx(Slot, { id: "App" }),
28
28
  };
29
29
  default:
@@ -1,11 +1,11 @@
1
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";
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" }) }) }));
6
6
  if (globalThis.__WAKU_SSR_ENABLED__) {
7
- hydrateRoot(document.getElementById("root"), rootElement);
7
+ hydrateRoot(document.getElementById('root'), rootElement);
8
8
  }
9
9
  else {
10
- createRoot(document.getElementById("root")).render(rootElement);
10
+ createRoot(document.getElementById('root')).render(rootElement);
11
11
  }
@@ -1,12 +1,12 @@
1
1
  /// Async Server Component
2
2
  /// <reference types="react/experimental" />
3
- import { Suspense } from "react";
3
+ import { Suspense } from 'react';
4
4
 
5
- import { Counter } from "./Counter.js";
5
+ import { Counter } from './Counter.js';
6
6
 
7
7
  const App = ({ name }: { name: string }) => {
8
8
  return (
9
- <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
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...">
@@ -1,11 +1,11 @@
1
- "use client";
1
+ 'use client';
2
2
 
3
- import { useState } from "react";
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: "3px blue dashed", margin: "1em", padding: "1em" }}>
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>