-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
096e02f
commit 09a2707
Showing
17 changed files
with
1,221 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Waku example</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style> | ||
@keyframes spinner { | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
.spinner { | ||
width: 36px; | ||
height: 36px; | ||
margin: auto; | ||
border: 2px solid #ddd; | ||
border-top-color: #222; | ||
border-radius: 50%; | ||
animation: spinner 1s linear infinite; | ||
} | ||
#root > .spinner { | ||
margin-top: calc(50% - 18px); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<!--placeholder1--> | ||
<div id="root"> | ||
<div class="spinner"></div> | ||
</div> | ||
<!--/placeholder1--> | ||
<script src="/src/main.tsx" async type="module"></script> | ||
<!--placeholder2--> | ||
<!--/placeholder2--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "waku-example", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "waku dev --with-ssr", | ||
"build": "waku build --with-ssr", | ||
"start": "waku start --with-ssr" | ||
}, | ||
"dependencies": { | ||
"@hono/node-server": "^1.2.2", | ||
"hono": "^3.10.0", | ||
"react": "18.3.0-canary-6c7b41da3-20231123", | ||
"react-dom": "18.3.0-canary-6c7b41da3-20231123", | ||
"react-server-dom-webpack": "18.3.0-canary-6c7b41da3-20231123", | ||
"waku": "0.17.1" | ||
}, | ||
"devDependencies": { | ||
"@swc/core": "1.3.96", | ||
"@types/react": "^18.2.37", | ||
"@types/react-dom": "^18.2.15", | ||
"@vanilla-extract/css": "^1.14.0", | ||
"@vanilla-extract/vite-plugin": "^3.9.2", | ||
"@vitejs/plugin-react": "4.2.0", | ||
"typescript": "^5.2.2", | ||
"vite": "5.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.title { | ||
background-color: pink; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// @ts-expect-error no types | ||
import styles from './App.module.css'; | ||
import './App.css'; | ||
import { container } from './styles.css.js'; | ||
import { Counter } from './Counter.js'; | ||
|
||
const App = ({ name }: { name: string }) => { | ||
return ( | ||
<div style={{ border: '3px red dashed', margin: '1em', padding: '1em' }}> | ||
<h1>Hello {name}!!</h1> | ||
<h1 className={styles.title}>Hello {name}!!</h1> | ||
<h3 className={container}>This is a server component.</h3> | ||
<Counter /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
|
||
export const Counter = () => { | ||
const [count, setCount] = useState(0); | ||
return ( | ||
<div style={{ border: '3px blue dashed', margin: '1em', padding: '1em' }}> | ||
<p>Count: {count}</p> | ||
<button onClick={() => setCount((c) => c + 1)}>Increment</button> | ||
<h3>This is a client component.</h3> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const container = style({ | ||
border: '3px green dashed', | ||
margin: '1em', | ||
padding: '1em', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { lazy } from 'react'; | ||
import { defineEntries } from 'waku/server'; | ||
|
||
const App = lazy(() => import('./components/App.js')); | ||
|
||
export default defineEntries( | ||
// renderEntries | ||
async (input) => { | ||
return { | ||
App: <App name={input || 'Waku'} />, | ||
}; | ||
}, | ||
// getBuildConfig | ||
async () => { | ||
return { | ||
'/': { | ||
entries: [['']], | ||
}, | ||
}; | ||
}, | ||
// getSsrConfig | ||
async (pathStr) => { | ||
switch (pathStr) { | ||
case '/': | ||
return { | ||
input: '', | ||
unstable_render: ({ createElement, Slot }) => | ||
createElement(Slot, { id: 'App' }), | ||
}; | ||
default: | ||
return null; | ||
} | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { StrictMode } from 'react'; | ||
import { createRoot, hydrateRoot } from 'react-dom/client'; | ||
import { Root, Slot } from 'waku/client'; | ||
|
||
const rootElement = ( | ||
<StrictMode> | ||
<Root> | ||
<Slot id="App" /> | ||
</Root> | ||
</StrictMode> | ||
); | ||
|
||
if ((globalThis as any).__WAKU_SSR_ENABLED__) { | ||
hydrateRoot(document.getElementById('root')!, rootElement); | ||
} else { | ||
createRoot(document.getElementById('root')!).render(rootElement); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"target": "esnext", | ||
"downlevelIteration": true, | ||
"esModuleInterop": true, | ||
"module": "nodenext", | ||
"skipLibCheck": true, | ||
"noUncheckedIndexedAccess": true, | ||
"exactOptionalPropertyTypes": true, | ||
"jsx": "react-jsx", | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import url from 'node:url'; | ||
import path from 'node:path'; | ||
// import { defineConfig } from 'waku/config' | ||
import { defineConfig } from 'vite'; | ||
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; | ||
|
||
export default defineConfig({ | ||
root: path.dirname(url.fileURLToPath(import.meta.url)), | ||
plugins: [vanillaExtractPlugin({ emitCssInSsr: true })], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.