Compare commits
2 Commits
a974b15fd6
...
c29a4092ca
| Author | SHA1 | Date | |
|---|---|---|---|
| c29a4092ca | |||
| ed6dff6639 |
|
|
@ -3,6 +3,6 @@ export default () => (
|
||||||
<h1>Live Reload Demo</h1>
|
<h1>Live Reload Demo</h1>
|
||||||
<p>Run this with <code>bun run dev</code>, then edit this file.</p>
|
<p>Run this with <code>bun run dev</code>, then edit this file.</p>
|
||||||
<p>The browser will automatically refresh — no manual reload needed.</p>
|
<p>The browser will automatically refresh — no manual reload needed.</p>
|
||||||
<p class="hint">Try changing this text and saving!</p>
|
<p class="hint">OMG! Try changing this text and saving!</p>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
36
examples/live-reload/tsconfig.json
Normal file
36
examples/live-reload/tsconfig.json
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// Environment setup & latest features
|
||||||
|
"lib": [
|
||||||
|
"ESNext",
|
||||||
|
"DOM"
|
||||||
|
],
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "Preserve",
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"jsxImportSource": "hono/jsx",
|
||||||
|
"allowJs": true,
|
||||||
|
// Bundler mode
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"noEmit": true,
|
||||||
|
// Best practices
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"noImplicitOverride": true,
|
||||||
|
// Some stricter flags (disabled by default)
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"noUnusedParameters": false,
|
||||||
|
"noPropertyAccessFromIndexSignature": false,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"#*": [
|
||||||
|
"src/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@because/hype",
|
"name": "@because/hype",
|
||||||
"version": "0.0.12",
|
"version": "0.0.13",
|
||||||
"module": "src/index.tsx",
|
"module": "src/index.tsx",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ export class Hype<
|
||||||
// live reload endpoint (dev mode only)
|
// live reload endpoint (dev mode only)
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
this.sse('/__hype/reload', () => {})
|
this.sse('/__hype/reload', () => {})
|
||||||
|
this.get('/__hype/ping', c => c.text('ok'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// healthcheck
|
// healthcheck
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const Layout: FC = ({ children, title, props }) =>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
const RELOAD_SCRIPT = '{let c=false;const e=new EventSource("/__hype/reload");e.onopen=()=>{if(c)location.reload();c=true};e.onerror=()=>{e.close();let d=50;setTimeout(function r(){fetch("/__hype/reload").then(()=>location.reload()).catch(()=>{d=Math.min(d*1.5,2000);setTimeout(r,d)})},d)}}'
|
const RELOAD_SCRIPT = '{let c=false;const e=new EventSource("/__hype/reload");e.onopen=()=>{if(c)location.reload();c=true};e.onerror=()=>{e.close();let d=50;setTimeout(function r(){fetch("/__hype/ping").then(()=>location.reload()).catch(()=>{d=Math.min(d*1.5,2000);setTimeout(r,d)})},d)}}'
|
||||||
|
|
||||||
export const ReloadScript: FC = () =>
|
export const ReloadScript: FC = () =>
|
||||||
isDev ? <script dangerouslySetInnerHTML={{ __html: RELOAD_SCRIPT }} /> : null
|
isDev ? <script dangerouslySetInnerHTML={{ __html: RELOAD_SCRIPT }} /> : null
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user