@e280/hottie 0.1.0-1
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/LICENSE +23 -0
- package/README.md +30 -0
- package/package.json +49 -0
- package/s/cli.ts +35 -0
- package/s/fns/log/file.ts +17 -0
- package/s/fns/log/html.ts +17 -0
- package/s/fns/log/intro.ts +40 -0
- package/s/fns/log/nope.ts +17 -0
- package/s/fns/log/reload.ts +19 -0
- package/s/fns/on-change.ts +21 -0
- package/s/fns/parts/chain.ts +32 -0
- package/s/fns/parts/inject-script.ts +7 -0
- package/s/fns/parts/listen.ts +11 -0
- package/s/fns/parts/not-found.ts +12 -0
- package/s/fns/parts/resolve-html-path.ts +18 -0
- package/s/fns/parts/script.ts +19 -0
- package/s/fns/parts/serve-files.ts +9 -0
- package/s/fns/parts/setup-proxy.ts +10 -0
- package/s/fns/parts/ws-path.ts +3 -0
- package/s/fns/serve-http.ts +43 -0
- package/s/fns/serve-websocket.ts +15 -0
- package/s/fns/spike-html-files.ts +28 -0
- package/s/fns/types.ts +17 -0
- package/s/index.html +10 -0
- package/s/serve.ts +24 -0
- package/x/cli.d.ts +2 -0
- package/x/cli.js +32 -0
- package/x/cli.js.map +1 -0
- package/x/fns/log/file.d.ts +1 -0
- package/x/fns/log/file.js +12 -0
- package/x/fns/log/file.js.map +1 -0
- package/x/fns/log/html.d.ts +1 -0
- package/x/fns/log/html.js +12 -0
- package/x/fns/log/html.js.map +1 -0
- package/x/fns/log/intro.d.ts +2 -0
- package/x/fns/log/intro.js +26 -0
- package/x/fns/log/intro.js.map +1 -0
- package/x/fns/log/nope.d.ts +1 -0
- package/x/fns/log/nope.js +12 -0
- package/x/fns/log/nope.js.map +1 -0
- package/x/fns/log/reload.d.ts +1 -0
- package/x/fns/log/reload.js +13 -0
- package/x/fns/log/reload.js.map +1 -0
- package/x/fns/on-change.d.ts +2 -0
- package/x/fns/on-change.js +16 -0
- package/x/fns/on-change.js.map +1 -0
- package/x/fns/parts/chain.d.ts +3 -0
- package/x/fns/parts/chain.js +25 -0
- package/x/fns/parts/chain.js.map +1 -0
- package/x/fns/parts/inject-script.d.ts +1 -0
- package/x/fns/parts/inject-script.js +6 -0
- package/x/fns/parts/inject-script.js.map +1 -0
- package/x/fns/parts/listen.d.ts +2 -0
- package/x/fns/parts/listen.js +8 -0
- package/x/fns/parts/listen.js.map +1 -0
- package/x/fns/parts/not-found.d.ts +2 -0
- package/x/fns/parts/not-found.js +9 -0
- package/x/fns/parts/not-found.js.map +1 -0
- package/x/fns/parts/resolve-html-path.d.ts +1 -0
- package/x/fns/parts/resolve-html-path.js +12 -0
- package/x/fns/parts/resolve-html-path.js.map +1 -0
- package/x/fns/parts/script.d.ts +1 -0
- package/x/fns/parts/script.js +17 -0
- package/x/fns/parts/script.js.map +1 -0
- package/x/fns/parts/serve-files.d.ts +2 -0
- package/x/fns/parts/serve-files.js +6 -0
- package/x/fns/parts/serve-files.js.map +1 -0
- package/x/fns/parts/setup-proxy.d.ts +5 -0
- package/x/fns/parts/setup-proxy.js +7 -0
- package/x/fns/parts/setup-proxy.js.map +1 -0
- package/x/fns/parts/ws-path.d.ts +1 -0
- package/x/fns/parts/ws-path.js +2 -0
- package/x/fns/parts/ws-path.js.map +1 -0
- package/x/fns/serve-http.d.ts +3 -0
- package/x/fns/serve-http.js +28 -0
- package/x/fns/serve-http.js.map +1 -0
- package/x/fns/serve-websocket.d.ts +4 -0
- package/x/fns/serve-websocket.js +11 -0
- package/x/fns/serve-websocket.js.map +1 -0
- package/x/fns/spike-html-files.d.ts +2 -0
- package/x/fns/spike-html-files.js +24 -0
- package/x/fns/spike-html-files.js.map +1 -0
- package/x/fns/types.d.ts +9 -0
- package/x/fns/types.js +2 -0
- package/x/fns/types.js.map +1 -0
- package/x/index.html +10 -0
- package/x/serve.d.ts +2 -0
- package/x/serve.js +18 -0
- package/x/serve.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 Chase Moskal
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
# 💅 hottie — *hot-reloading http server*
|
|
3
|
+
|
|
4
|
+
```bash
|
|
5
|
+
npm install --save-dev @e280/hottie
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
hottie x
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
serves `./x/` at `http://localhost:8080`, and refreshes the browser when files change.
|
|
13
|
+
|
|
14
|
+
- **--port**
|
|
15
|
+
http port to serve on. *(default `8080`)*
|
|
16
|
+
- **--debounce**
|
|
17
|
+
file watcher hesitation in milliseconds. *(default `100`)*
|
|
18
|
+
- **--proxy**
|
|
19
|
+
requests fallback to this proxy url.
|
|
20
|
+
- **--cold, -c**
|
|
21
|
+
actually don't do the hot-reloading, just be a server.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<br/>
|
|
26
|
+
|
|
27
|
+
## 🧑💻 by e280
|
|
28
|
+
reward us with github stars
|
|
29
|
+
build with us at https://e280.org/ but only if you're cool
|
|
30
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@e280/hottie",
|
|
3
|
+
"version": "0.1.0-1",
|
|
4
|
+
"description": "⚡ hot-reloading http server",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Chase Moskal <chasemoskal@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"x",
|
|
11
|
+
"s"
|
|
12
|
+
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"hottie": "x/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -rf x && mkdir x && tsc && cp s/index.html x/index.html && chmod 665 x/index.html",
|
|
18
|
+
"test": "exit 0",
|
|
19
|
+
"start": "node x/cli.js",
|
|
20
|
+
"count": "find s -path '*/_archive' -prune -o -name '*.ts' -exec wc -l {} +"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@benev/argv": "^0.3.14",
|
|
24
|
+
"@e280/stz": "^0.2.24",
|
|
25
|
+
"chokidar": "^5.0.0",
|
|
26
|
+
"http-proxy-3": "^1.23.2",
|
|
27
|
+
"sirv": "^3.0.2",
|
|
28
|
+
"ws": "^8.19.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^25.4.0",
|
|
32
|
+
"@types/ws": "^8.18.1",
|
|
33
|
+
"typescript": "^5.9.3"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"http server",
|
|
37
|
+
"dev server",
|
|
38
|
+
"hot reload",
|
|
39
|
+
"hot reloading"
|
|
40
|
+
],
|
|
41
|
+
"homepage": "https://github.com/e280/hottie#readme",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/e280/hottie.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/e280/hottie/issues"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/s/cli.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {serve} from "./serve.js"
|
|
4
|
+
import {arg, cli, command, number, param, string} from "@benev/argv"
|
|
5
|
+
|
|
6
|
+
await cli(process.argv, {
|
|
7
|
+
name: "hottie",
|
|
8
|
+
readme: "https://github.com/e280/hottie",
|
|
9
|
+
help: "hot-reloading http server.",
|
|
10
|
+
commands: command({
|
|
11
|
+
args: [
|
|
12
|
+
arg("root").default(string, "x", {help: "directory to serve"}),
|
|
13
|
+
],
|
|
14
|
+
params: {
|
|
15
|
+
port: param.default(number, "8080", {
|
|
16
|
+
help: "http port.",
|
|
17
|
+
}),
|
|
18
|
+
debounce: param.default(number, "100", {
|
|
19
|
+
help: "file watcher hesitation in milliseconds.",
|
|
20
|
+
}),
|
|
21
|
+
proxy: param.optional(string, {
|
|
22
|
+
help: "requests fallback to this proxy url.",
|
|
23
|
+
}),
|
|
24
|
+
cold: param.flag("-c", {
|
|
25
|
+
help: "actually don't do the hot-reloading, just be a server.",
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async execute({args, params}) {
|
|
30
|
+
const {root} = args
|
|
31
|
+
await serve({root, ...params})
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
}).execute()
|
|
35
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import {pipe} from "@e280/stz"
|
|
3
|
+
import {color} from "@benev/argv"
|
|
4
|
+
|
|
5
|
+
export const logFile = (url?: string) => console.log([
|
|
6
|
+
|
|
7
|
+
pipe("file")
|
|
8
|
+
.to(color.blue)
|
|
9
|
+
.done(),
|
|
10
|
+
|
|
11
|
+
pipe(url ?? "")
|
|
12
|
+
.to(color.blue)
|
|
13
|
+
.to(color.dim)
|
|
14
|
+
.done(),
|
|
15
|
+
|
|
16
|
+
].join(" "))
|
|
17
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import {pipe} from "@e280/stz"
|
|
3
|
+
import {color} from "@benev/argv"
|
|
4
|
+
|
|
5
|
+
export const logHtml = (url?: string) => console.log([
|
|
6
|
+
|
|
7
|
+
pipe("html")
|
|
8
|
+
.to(color.green)
|
|
9
|
+
.done(),
|
|
10
|
+
|
|
11
|
+
pipe(url ?? "")
|
|
12
|
+
.to(color.green)
|
|
13
|
+
.to(color.dim)
|
|
14
|
+
.done(),
|
|
15
|
+
|
|
16
|
+
].join(" "))
|
|
17
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import {pipe} from "@e280/stz"
|
|
3
|
+
import {color} from "@benev/argv"
|
|
4
|
+
import {Options} from "../types.js"
|
|
5
|
+
|
|
6
|
+
export const logIntro = (options: Options) => {
|
|
7
|
+
|
|
8
|
+
console.log([
|
|
9
|
+
"💅",
|
|
10
|
+
|
|
11
|
+
pipe("hottie")
|
|
12
|
+
.to(color.brightMagenta)
|
|
13
|
+
.to(color.bold)
|
|
14
|
+
.done(),
|
|
15
|
+
|
|
16
|
+
pipe(options.root)
|
|
17
|
+
.to(color.magenta)
|
|
18
|
+
.to(color.dim)
|
|
19
|
+
.done(),
|
|
20
|
+
].join(" "))
|
|
21
|
+
|
|
22
|
+
console.log(
|
|
23
|
+
pipe(`https://localhost:${options.port}/`)
|
|
24
|
+
.to(color.cyan)
|
|
25
|
+
.done(),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const info = options.cold
|
|
29
|
+
? `http server. (--cold disabled hot-reloading)`
|
|
30
|
+
: `hot-reloading http server.`
|
|
31
|
+
|
|
32
|
+
console.log(
|
|
33
|
+
pipe(info)
|
|
34
|
+
.to(color.dim)
|
|
35
|
+
.done(),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
console.log("")
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import {pipe} from "@e280/stz"
|
|
3
|
+
import {color} from "@benev/argv"
|
|
4
|
+
|
|
5
|
+
export const logNope = (url?: string) => console.log([
|
|
6
|
+
|
|
7
|
+
pipe("nope")
|
|
8
|
+
.to(color.red)
|
|
9
|
+
.done(),
|
|
10
|
+
|
|
11
|
+
pipe(url ?? "")
|
|
12
|
+
.to(color.red)
|
|
13
|
+
.to(color.dim)
|
|
14
|
+
.done(),
|
|
15
|
+
|
|
16
|
+
].join(" "))
|
|
17
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import {pipe} from "@e280/stz"
|
|
3
|
+
import {color} from "@benev/argv"
|
|
4
|
+
|
|
5
|
+
export const logReload = (count: number) => console.log("\n" + [
|
|
6
|
+
|
|
7
|
+
"⚡",
|
|
8
|
+
|
|
9
|
+
pipe("reload")
|
|
10
|
+
.to(color.brightMagenta)
|
|
11
|
+
.done(),
|
|
12
|
+
|
|
13
|
+
pipe(`${count}`)
|
|
14
|
+
.to(color.magenta)
|
|
15
|
+
.to(color.dim)
|
|
16
|
+
.done(),
|
|
17
|
+
|
|
18
|
+
].join(" "))
|
|
19
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
import chokidar from "chokidar"
|
|
3
|
+
import {debounce} from "@e280/stz"
|
|
4
|
+
import {Options} from "./types.js"
|
|
5
|
+
|
|
6
|
+
// TODO we should really do an 'exclude' param with globby minimatch patterns...
|
|
7
|
+
const illegals = [
|
|
8
|
+
"node_modules",
|
|
9
|
+
".git",
|
|
10
|
+
".DS_Store",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
export function onChange(options: Options, fn: () => void) {
|
|
14
|
+
const watcher = chokidar.watch(options.root, {
|
|
15
|
+
ignoreInitial: true,
|
|
16
|
+
ignored: file => illegals.some(illegal => file.includes(illegal)),
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
watcher.on("all", debounce(options.debounce, fn))
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
import http from "node:http"
|
|
3
|
+
import {Middleware} from "../types.js"
|
|
4
|
+
|
|
5
|
+
export function chain(...middlewares: (Middleware | undefined)[]): http.RequestListener {
|
|
6
|
+
middlewares = middlewares.filter(Boolean)
|
|
7
|
+
|
|
8
|
+
return async (req, res) => {
|
|
9
|
+
let i = 0
|
|
10
|
+
|
|
11
|
+
const next = async(): Promise<void> => {
|
|
12
|
+
const middleware = middlewares[i++]
|
|
13
|
+
if (middleware)
|
|
14
|
+
await middleware(req, res, next)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await next()
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error("middleware error", error)
|
|
22
|
+
if (!res.headersSent) {
|
|
23
|
+
res.writeHead(500, {"content-type": "text/plain; charset=utf-8"})
|
|
24
|
+
res.end("500 internal server error")
|
|
25
|
+
}
|
|
26
|
+
else if (!res.writableEnded) {
|
|
27
|
+
res.end()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import {logNope} from "../log/nope.js"
|
|
3
|
+
import {Middleware} from "../types.js"
|
|
4
|
+
|
|
5
|
+
export function notFound(): Middleware {
|
|
6
|
+
return async(req, res) => {
|
|
7
|
+
logNope(req.url)
|
|
8
|
+
res.writeHead(404, {"content-type": "text/plain; charset=utf-8"})
|
|
9
|
+
res.end("404 not found")
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
|
|
4
|
+
export function resolveHtmlPath(root: string, pathname: string) {
|
|
5
|
+
if (pathname.endsWith("/"))
|
|
6
|
+
pathname = pathname + "index.html"
|
|
7
|
+
|
|
8
|
+
pathname = path.normalize(path.join(root, "." + pathname))
|
|
9
|
+
|
|
10
|
+
if (!path.resolve(pathname).startsWith(path.resolve(root)))
|
|
11
|
+
return null
|
|
12
|
+
|
|
13
|
+
if ([".html", ".htm"].includes(path.extname(pathname)))
|
|
14
|
+
return pathname
|
|
15
|
+
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import {templateString as html} from "@e280/stz"
|
|
3
|
+
import {wsPath} from "./ws-path.js"
|
|
4
|
+
|
|
5
|
+
export const script = () => html`
|
|
6
|
+
<script type="module">
|
|
7
|
+
const protocol = location.protocol === "https:" ? "wss:" : "ws:"
|
|
8
|
+
const socket = new WebSocket(protocol + "//" + location.host + "${wsPath}")
|
|
9
|
+
const events = {
|
|
10
|
+
message: () => location.reload(),
|
|
11
|
+
open: () => console.log("💅 hottie hot-reload connected"),
|
|
12
|
+
close: () => console.log("🔥 hottie hot-reload connection closed"),
|
|
13
|
+
error: () => console.log("🔥 hottie hot-reload connection failed"),
|
|
14
|
+
}
|
|
15
|
+
for (const [event, fn] of Object.entries(events))
|
|
16
|
+
socket.addEventListener(event, fn)
|
|
17
|
+
</script>
|
|
18
|
+
`
|
|
19
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
import {Middleware} from "../types.js"
|
|
3
|
+
import {createProxyServer} from "http-proxy-3"
|
|
4
|
+
|
|
5
|
+
export function setupProxy(target: string) {
|
|
6
|
+
const server = createProxyServer()
|
|
7
|
+
const middleware: Middleware = async(req, res) => server.web(req, res, {target})
|
|
8
|
+
return {server, middleware}
|
|
9
|
+
}
|
|
10
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import sirv from "sirv"
|
|
3
|
+
import http from "node:http"
|
|
4
|
+
import {WebSocketServer} from "ws"
|
|
5
|
+
|
|
6
|
+
import {Options} from "./types.js"
|
|
7
|
+
import {chain} from "./parts/chain.js"
|
|
8
|
+
import {listen} from "./parts/listen.js"
|
|
9
|
+
import {wsPath} from "./parts/ws-path.js"
|
|
10
|
+
import {notFound} from "./parts/not-found.js"
|
|
11
|
+
import {logFiles} from "./parts/serve-files.js"
|
|
12
|
+
import {setupProxy} from "./parts/setup-proxy.js"
|
|
13
|
+
import {spikeHtmlFiles} from "./spike-html-files.js"
|
|
14
|
+
|
|
15
|
+
export async function serveHttp(options: Options, wss: WebSocketServer) {
|
|
16
|
+
const proxy = options.proxy
|
|
17
|
+
? setupProxy(options.proxy)
|
|
18
|
+
: undefined
|
|
19
|
+
|
|
20
|
+
const server = http.createServer(chain(
|
|
21
|
+
options.cold
|
|
22
|
+
? undefined
|
|
23
|
+
: spikeHtmlFiles(options),
|
|
24
|
+
logFiles,
|
|
25
|
+
sirv(options.root, {dev: true}),
|
|
26
|
+
proxy?.middleware ?? notFound(),
|
|
27
|
+
))
|
|
28
|
+
|
|
29
|
+
server.on("upgrade", (req, socket, head) => {
|
|
30
|
+
if (req.url === wsPath) {
|
|
31
|
+
wss.handleUpgrade(req, socket, head, ws => wss.emit("connection", ws, req))
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (proxy)
|
|
36
|
+
return proxy.server.ws(req, socket, head)
|
|
37
|
+
|
|
38
|
+
socket.destroy()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
await listen(options.port, server)
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import {WebSocketServer} from "ws"
|
|
3
|
+
|
|
4
|
+
export function serveWebsocket() {
|
|
5
|
+
const wss = new WebSocketServer({noServer: true})
|
|
6
|
+
|
|
7
|
+
function sendReload() {
|
|
8
|
+
for (const client of wss.clients)
|
|
9
|
+
if (client.readyState === client.OPEN)
|
|
10
|
+
client.send("reload")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {wss, sendReload}
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import fs from "node:fs/promises"
|
|
3
|
+
|
|
4
|
+
import {logHtml} from "./log/html.js"
|
|
5
|
+
import {script} from "./parts/script.js"
|
|
6
|
+
import {Middleware, Options} from "./types.js"
|
|
7
|
+
import {injectScript} from "./parts/inject-script.js"
|
|
8
|
+
import {resolveHtmlPath} from "./parts/resolve-html-path.js"
|
|
9
|
+
|
|
10
|
+
export const spikeHtmlFiles = (options: Options): Middleware => async(req, res, next) => {
|
|
11
|
+
const url = new URL(req.url ?? "/", "http://localhost")
|
|
12
|
+
const pathname = decodeURIComponent(url.pathname)
|
|
13
|
+
const htmlPath = resolveHtmlPath(options.root, pathname)
|
|
14
|
+
|
|
15
|
+
if (htmlPath) try {
|
|
16
|
+
const html = await fs.readFile(htmlPath, "utf8")
|
|
17
|
+
logHtml(req.url)
|
|
18
|
+
const body = injectScript(html, script())
|
|
19
|
+
res.statusCode = 200
|
|
20
|
+
res.setHeader("content-type", "text/html; charset=utf-8")
|
|
21
|
+
res.setHeader("content-length", Buffer.byteLength(body))
|
|
22
|
+
res.end(body)
|
|
23
|
+
return
|
|
24
|
+
} catch {}
|
|
25
|
+
|
|
26
|
+
await next()
|
|
27
|
+
}
|
|
28
|
+
|
package/s/fns/types.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import http from "node:http"
|
|
3
|
+
|
|
4
|
+
export type Options = {
|
|
5
|
+
root: string
|
|
6
|
+
port: number
|
|
7
|
+
debounce: number
|
|
8
|
+
proxy: string | undefined
|
|
9
|
+
cold: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type Middleware = (
|
|
13
|
+
req: http.IncomingMessage,
|
|
14
|
+
res: http.ServerResponse,
|
|
15
|
+
next: () => Promise<void>,
|
|
16
|
+
) => void | Promise<void>
|
|
17
|
+
|
package/s/index.html
ADDED
package/s/serve.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import {Options} from "./fns/types.js"
|
|
3
|
+
import {logIntro} from "./fns/log/intro.js"
|
|
4
|
+
import {onChange} from "./fns/on-change.js"
|
|
5
|
+
import {logReload} from "./fns/log/reload.js"
|
|
6
|
+
import {serveHttp} from "./fns/serve-http.js"
|
|
7
|
+
import {serveWebsocket} from "./fns/serve-websocket.js"
|
|
8
|
+
|
|
9
|
+
export async function serve(options: Options) {
|
|
10
|
+
const {wss, sendReload} = serveWebsocket()
|
|
11
|
+
|
|
12
|
+
await serveHttp(options, wss)
|
|
13
|
+
|
|
14
|
+
if (!options.cold) {
|
|
15
|
+
let count = 1
|
|
16
|
+
onChange(options, () => {
|
|
17
|
+
logReload(count++)
|
|
18
|
+
sendReload()
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
logIntro(options)
|
|
23
|
+
}
|
|
24
|
+
|
package/x/cli.d.ts
ADDED
package/x/cli.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { serve } from "./serve.js";
|
|
3
|
+
import { arg, cli, command, number, param, string } from "@benev/argv";
|
|
4
|
+
await cli(process.argv, {
|
|
5
|
+
name: "hottie",
|
|
6
|
+
readme: "https://github.com/e280/hottie",
|
|
7
|
+
help: "hot-reloading http server.",
|
|
8
|
+
commands: command({
|
|
9
|
+
args: [
|
|
10
|
+
arg("root").default(string, "x", { help: "directory to serve" }),
|
|
11
|
+
],
|
|
12
|
+
params: {
|
|
13
|
+
port: param.default(number, "8080", {
|
|
14
|
+
help: "http port.",
|
|
15
|
+
}),
|
|
16
|
+
debounce: param.default(number, "100", {
|
|
17
|
+
help: "file watcher hesitation in milliseconds.",
|
|
18
|
+
}),
|
|
19
|
+
proxy: param.optional(string, {
|
|
20
|
+
help: "requests fallback to this proxy url.",
|
|
21
|
+
}),
|
|
22
|
+
cold: param.flag("-c", {
|
|
23
|
+
help: "actually don't do the hot-reloading, just be a server.",
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
async execute({ args, params }) {
|
|
27
|
+
const { root } = args;
|
|
28
|
+
await serve({ root, ...params });
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
}).execute();
|
|
32
|
+
//# sourceMappingURL=cli.js.map
|
package/x/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../s/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,aAAa,CAAA;AAEpE,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;IACvB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,gCAAgC;IACxC,IAAI,EAAE,4BAA4B;IAClC,QAAQ,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE;YACL,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,EAAC,IAAI,EAAE,oBAAoB,EAAC,CAAC;SAC9D;QACD,MAAM,EAAE;YACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE;gBACnC,IAAI,EAAE,YAAY;aAClB,CAAC;YACF,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE;gBACtC,IAAI,EAAE,0CAA0C;aAChD,CAAC;YACF,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC7B,IAAI,EAAE,sCAAsC;aAC5C,CAAC;YACF,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;gBACtB,IAAI,EAAE,wDAAwD;aAC9D,CAAC;SACF;QAED,KAAK,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC;YAC3B,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAA;YACnB,MAAM,KAAK,CAAC,EAAC,IAAI,EAAE,GAAG,MAAM,EAAC,CAAC,CAAA;QAC/B,CAAC;KACD,CAAC;CACF,CAAC,CAAC,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logFile: (url?: string) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pipe } from "@e280/stz";
|
|
2
|
+
import { color } from "@benev/argv";
|
|
3
|
+
export const logFile = (url) => console.log([
|
|
4
|
+
pipe("file")
|
|
5
|
+
.to(color.blue)
|
|
6
|
+
.done(),
|
|
7
|
+
pipe(url ?? "")
|
|
8
|
+
.to(color.blue)
|
|
9
|
+
.to(color.dim)
|
|
10
|
+
.done(),
|
|
11
|
+
].join(" "));
|
|
12
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../s/fns/log/file.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAEpD,IAAI,CAAC,MAAM,CAAC;SACV,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SACd,IAAI,EAAE;IAER,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;SACb,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SACd,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE;CAER,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logHtml: (url?: string) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pipe } from "@e280/stz";
|
|
2
|
+
import { color } from "@benev/argv";
|
|
3
|
+
export const logHtml = (url) => console.log([
|
|
4
|
+
pipe("html")
|
|
5
|
+
.to(color.green)
|
|
6
|
+
.done(),
|
|
7
|
+
pipe(url ?? "")
|
|
8
|
+
.to(color.green)
|
|
9
|
+
.to(color.dim)
|
|
10
|
+
.done(),
|
|
11
|
+
].join(" "));
|
|
12
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../s/fns/log/html.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAEpD,IAAI,CAAC,MAAM,CAAC;SACV,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;SACf,IAAI,EAAE;IAER,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;SACb,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;SACf,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE;CAER,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { pipe } from "@e280/stz";
|
|
2
|
+
import { color } from "@benev/argv";
|
|
3
|
+
export const logIntro = (options) => {
|
|
4
|
+
console.log([
|
|
5
|
+
"💅",
|
|
6
|
+
pipe("hottie")
|
|
7
|
+
.to(color.brightMagenta)
|
|
8
|
+
.to(color.bold)
|
|
9
|
+
.done(),
|
|
10
|
+
pipe(options.root)
|
|
11
|
+
.to(color.magenta)
|
|
12
|
+
.to(color.dim)
|
|
13
|
+
.done(),
|
|
14
|
+
].join(" "));
|
|
15
|
+
console.log(pipe(`https://localhost:${options.port}/`)
|
|
16
|
+
.to(color.cyan)
|
|
17
|
+
.done());
|
|
18
|
+
const info = options.cold
|
|
19
|
+
? `http server. (--cold disabled hot-reloading)`
|
|
20
|
+
: `hot-reloading http server.`;
|
|
21
|
+
console.log(pipe(info)
|
|
22
|
+
.to(color.dim)
|
|
23
|
+
.done());
|
|
24
|
+
console.log("");
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=intro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intro.js","sourceRoot":"","sources":["../../../s/fns/log/intro.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAGjC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAgB,EAAE,EAAE;IAE5C,OAAO,CAAC,GAAG,CAAC;QACX,IAAI;QAEJ,IAAI,CAAC,QAAQ,CAAC;aACZ,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC;aACvB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aACd,IAAI,EAAE;QAER,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;aAChB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;aACjB,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;aACb,IAAI,EAAE;KACR,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IAEZ,OAAO,CAAC,GAAG,CACV,IAAI,CAAC,qBAAqB,OAAO,CAAC,IAAI,GAAG,CAAC;SACxC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SACd,IAAI,EAAE,CACR,CAAA;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI;QACxB,CAAC,CAAC,8CAA8C;QAChD,CAAC,CAAC,4BAA4B,CAAA;IAE/B,OAAO,CAAC,GAAG,CACV,IAAI,CAAC,IAAI,CAAC;SACR,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE,CACR,CAAA;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logNope: (url?: string) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pipe } from "@e280/stz";
|
|
2
|
+
import { color } from "@benev/argv";
|
|
3
|
+
export const logNope = (url) => console.log([
|
|
4
|
+
pipe("nope")
|
|
5
|
+
.to(color.red)
|
|
6
|
+
.done(),
|
|
7
|
+
pipe(url ?? "")
|
|
8
|
+
.to(color.red)
|
|
9
|
+
.to(color.dim)
|
|
10
|
+
.done(),
|
|
11
|
+
].join(" "));
|
|
12
|
+
//# sourceMappingURL=nope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nope.js","sourceRoot":"","sources":["../../../s/fns/log/nope.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAEpD,IAAI,CAAC,MAAM,CAAC;SACV,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE;IAER,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;SACb,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE;CAER,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logReload: (count: number) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { pipe } from "@e280/stz";
|
|
2
|
+
import { color } from "@benev/argv";
|
|
3
|
+
export const logReload = (count) => console.log("\n" + [
|
|
4
|
+
"⚡",
|
|
5
|
+
pipe("reload")
|
|
6
|
+
.to(color.brightMagenta)
|
|
7
|
+
.done(),
|
|
8
|
+
pipe(`${count}`)
|
|
9
|
+
.to(color.magenta)
|
|
10
|
+
.to(color.dim)
|
|
11
|
+
.done(),
|
|
12
|
+
].join(" "));
|
|
13
|
+
//# sourceMappingURL=reload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../../s/fns/log/reload.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG;IAE9D,GAAG;IAEH,IAAI,CAAC,QAAQ,CAAC;SACZ,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC;SACvB,IAAI,EAAE;IAER,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;SACd,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;SACjB,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACb,IAAI,EAAE;CAER,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import chokidar from "chokidar";
|
|
2
|
+
import { debounce } from "@e280/stz";
|
|
3
|
+
// TODO we should really do an 'exclude' param with globby minimatch patterns...
|
|
4
|
+
const illegals = [
|
|
5
|
+
"node_modules",
|
|
6
|
+
".git",
|
|
7
|
+
".DS_Store",
|
|
8
|
+
];
|
|
9
|
+
export function onChange(options, fn) {
|
|
10
|
+
const watcher = chokidar.watch(options.root, {
|
|
11
|
+
ignoreInitial: true,
|
|
12
|
+
ignored: file => illegals.some(illegal => file.includes(illegal)),
|
|
13
|
+
});
|
|
14
|
+
watcher.on("all", debounce(options.debounce, fn));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=on-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-change.js","sourceRoot":"","sources":["../../s/fns/on-change.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAGlC,gFAAgF;AAChF,MAAM,QAAQ,GAAG;IAChB,cAAc;IACd,MAAM;IACN,WAAW;CACX,CAAA;AAED,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,EAAc;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QAC5C,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACjE,CAAC,CAAA;IAEF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function chain(...middlewares) {
|
|
2
|
+
middlewares = middlewares.filter(Boolean);
|
|
3
|
+
return async (req, res) => {
|
|
4
|
+
let i = 0;
|
|
5
|
+
const next = async () => {
|
|
6
|
+
const middleware = middlewares[i++];
|
|
7
|
+
if (middleware)
|
|
8
|
+
await middleware(req, res, next);
|
|
9
|
+
};
|
|
10
|
+
try {
|
|
11
|
+
await next();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error("middleware error", error);
|
|
15
|
+
if (!res.headersSent) {
|
|
16
|
+
res.writeHead(500, { "content-type": "text/plain; charset=utf-8" });
|
|
17
|
+
res.end("500 internal server error");
|
|
18
|
+
}
|
|
19
|
+
else if (!res.writableEnded) {
|
|
20
|
+
res.end();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../s/fns/parts/chain.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,KAAK,CAAC,GAAG,WAAuC;IAC/D,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACzB,IAAI,CAAC,GAAG,CAAC,CAAA;QAET,MAAM,IAAI,GAAG,KAAK,IAAkB,EAAE;YACrC,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAA;YACnC,IAAI,UAAU;gBACb,MAAM,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC,CAAA;QAED,IAAI,CAAC;YACJ,MAAM,IAAI,EAAE,CAAA;QACb,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;YACxC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACtB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,2BAA2B,EAAC,CAAC,CAAA;gBACjE,GAAG,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;YACrC,CAAC;iBACI,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;gBAC7B,GAAG,CAAC,GAAG,EAAE,CAAA;YACV,CAAC;QACF,CAAC;IACF,CAAC,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectScript(html: string, script: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-script.js","sourceRoot":"","sources":["../../../s/fns/parts/inject-script.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACxD,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC9B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,MAAM,WAAW,CAAC;QAC/C,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen.js","sourceRoot":"","sources":["../../../s/fns/parts/listen.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY,EAAE,MAAmB;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;QACjC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { logNope } from "../log/nope.js";
|
|
2
|
+
export function notFound() {
|
|
3
|
+
return async (req, res) => {
|
|
4
|
+
logNope(req.url);
|
|
5
|
+
res.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
6
|
+
res.end("404 not found");
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.js","sourceRoot":"","sources":["../../../s/fns/parts/not-found.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAA;AAGtC,MAAM,UAAU,QAAQ;IACvB,OAAO,KAAK,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,2BAA2B,EAAC,CAAC,CAAA;QACjE,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACzB,CAAC,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveHtmlPath(root: string, pathname: string): string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export function resolveHtmlPath(root, pathname) {
|
|
3
|
+
if (pathname.endsWith("/"))
|
|
4
|
+
pathname = pathname + "index.html";
|
|
5
|
+
pathname = path.normalize(path.join(root, "." + pathname));
|
|
6
|
+
if (!path.resolve(pathname).startsWith(path.resolve(root)))
|
|
7
|
+
return null;
|
|
8
|
+
if ([".html", ".htm"].includes(path.extname(pathname)))
|
|
9
|
+
return pathname;
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=resolve-html-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-html-path.js","sourceRoot":"","sources":["../../../s/fns/parts/resolve-html-path.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,QAAgB;IAC7D,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QACzB,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAA;IAEnC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAA;IAE1D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzD,OAAO,IAAI,CAAA;IAEZ,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAA;IAEhB,OAAO,IAAI,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const script: () => string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { templateString as html } from "@e280/stz";
|
|
2
|
+
import { wsPath } from "./ws-path.js";
|
|
3
|
+
export const script = () => html `
|
|
4
|
+
<script type="module">
|
|
5
|
+
const protocol = location.protocol === "https:" ? "wss:" : "ws:"
|
|
6
|
+
const socket = new WebSocket(protocol + "//" + location.host + "${wsPath}")
|
|
7
|
+
const events = {
|
|
8
|
+
message: () => location.reload(),
|
|
9
|
+
open: () => console.log("💅 hottie hot-reload connected"),
|
|
10
|
+
close: () => console.log("🔥 hottie hot-reload connection closed"),
|
|
11
|
+
error: () => console.log("🔥 hottie hot-reload connection failed"),
|
|
12
|
+
}
|
|
13
|
+
for (const [event, fn] of Object.entries(events))
|
|
14
|
+
socket.addEventListener(event, fn)
|
|
15
|
+
</script>
|
|
16
|
+
`;
|
|
17
|
+
//# sourceMappingURL=script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../../s/fns/parts/script.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,IAAI,IAAI,EAAC,MAAM,WAAW,CAAA;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;;;oEAGoC,MAAM;;;;;;;;;;CAUzE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-files.js","sourceRoot":"","sources":["../../../s/fns/parts/serve-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAA;AAGtC,MAAM,CAAC,MAAM,QAAQ,GAAe,KAAK,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,MAAM,IAAI,EAAE,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createProxyServer } from "http-proxy-3";
|
|
2
|
+
export function setupProxy(target) {
|
|
3
|
+
const server = createProxyServer();
|
|
4
|
+
const middleware = async (req, res) => server.web(req, res, { target });
|
|
5
|
+
return { server, middleware };
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=setup-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-proxy.js","sourceRoot":"","sources":["../../../s/fns/parts/setup-proxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAE9C,MAAM,UAAU,UAAU,CAAC,MAAc;IACxC,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAA;IAClC,MAAM,UAAU,GAAe,KAAK,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,MAAM,EAAC,CAAC,CAAA;IAChF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const wsPath = "/e280-hottie-ws";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-path.js","sourceRoot":"","sources":["../../../s/fns/parts/ws-path.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sirv from "sirv";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { chain } from "./parts/chain.js";
|
|
4
|
+
import { listen } from "./parts/listen.js";
|
|
5
|
+
import { wsPath } from "./parts/ws-path.js";
|
|
6
|
+
import { notFound } from "./parts/not-found.js";
|
|
7
|
+
import { logFiles } from "./parts/serve-files.js";
|
|
8
|
+
import { setupProxy } from "./parts/setup-proxy.js";
|
|
9
|
+
import { spikeHtmlFiles } from "./spike-html-files.js";
|
|
10
|
+
export async function serveHttp(options, wss) {
|
|
11
|
+
const proxy = options.proxy
|
|
12
|
+
? setupProxy(options.proxy)
|
|
13
|
+
: undefined;
|
|
14
|
+
const server = http.createServer(chain(options.cold
|
|
15
|
+
? undefined
|
|
16
|
+
: spikeHtmlFiles(options), logFiles, sirv(options.root, { dev: true }), proxy?.middleware ?? notFound()));
|
|
17
|
+
server.on("upgrade", (req, socket, head) => {
|
|
18
|
+
if (req.url === wsPath) {
|
|
19
|
+
wss.handleUpgrade(req, socket, head, ws => wss.emit("connection", ws, req));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (proxy)
|
|
23
|
+
return proxy.server.ws(req, socket, head);
|
|
24
|
+
socket.destroy();
|
|
25
|
+
});
|
|
26
|
+
await listen(options.port, server);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=serve-http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-http.js","sourceRoot":"","sources":["../../s/fns/serve-http.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAA;AAEpD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAgB,EAAE,GAAoB;IACrE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK;QAC1B,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC,CAAC,SAAS,CAAA;IAEZ,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CACrC,OAAO,CAAC,IAAI;QACX,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,EAC/B,KAAK,EAAE,UAAU,IAAI,QAAQ,EAAE,CAC/B,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC1C,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC;YACxB,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;YAC3E,OAAM;QACP,CAAC;QAED,IAAI,KAAK;YACR,OAAO,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAE1C,MAAM,CAAC,OAAO,EAAE,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WebSocketServer } from "ws";
|
|
2
|
+
export function serveWebsocket() {
|
|
3
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
4
|
+
function sendReload() {
|
|
5
|
+
for (const client of wss.clients)
|
|
6
|
+
if (client.readyState === client.OPEN)
|
|
7
|
+
client.send("reload");
|
|
8
|
+
}
|
|
9
|
+
return { wss, sendReload };
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=serve-websocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-websocket.js","sourceRoot":"","sources":["../../s/fns/serve-websocket.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,IAAI,CAAA;AAElC,MAAM,UAAU,cAAc;IAC7B,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IAEjD,SAAS,UAAU;QAClB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI;gBACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,EAAC,GAAG,EAAE,UAAU,EAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { logHtml } from "./log/html.js";
|
|
3
|
+
import { script } from "./parts/script.js";
|
|
4
|
+
import { injectScript } from "./parts/inject-script.js";
|
|
5
|
+
import { resolveHtmlPath } from "./parts/resolve-html-path.js";
|
|
6
|
+
export const spikeHtmlFiles = (options) => async (req, res, next) => {
|
|
7
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
8
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
9
|
+
const htmlPath = resolveHtmlPath(options.root, pathname);
|
|
10
|
+
if (htmlPath)
|
|
11
|
+
try {
|
|
12
|
+
const html = await fs.readFile(htmlPath, "utf8");
|
|
13
|
+
logHtml(req.url);
|
|
14
|
+
const body = injectScript(html, script());
|
|
15
|
+
res.statusCode = 200;
|
|
16
|
+
res.setHeader("content-type", "text/html; charset=utf-8");
|
|
17
|
+
res.setHeader("content-length", Buffer.byteLength(body));
|
|
18
|
+
res.end(body);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
catch { }
|
|
22
|
+
await next();
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=spike-html-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spike-html-files.js","sourceRoot":"","sources":["../../s/fns/spike-html-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAEjC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAA;AAE5D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAc,EAAE,CAAC,KAAK,EAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IACvF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,kBAAkB,CAAC,CAAA;IACvD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAExD,IAAI,QAAQ;QAAE,IAAI,CAAC;YAClB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAChD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChB,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;YACzC,GAAG,CAAC,UAAU,GAAG,GAAG,CAAA;YACpB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAA;YACzD,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;YACxD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACb,OAAM;QACP,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IAEV,MAAM,IAAI,EAAE,CAAA;AACb,CAAC,CAAA"}
|
package/x/fns/types.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
export type Options = {
|
|
3
|
+
root: string;
|
|
4
|
+
port: number;
|
|
5
|
+
debounce: number;
|
|
6
|
+
proxy: string | undefined;
|
|
7
|
+
cold: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type Middleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => Promise<void>) => void | Promise<void>;
|
package/x/fns/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../s/fns/types.ts"],"names":[],"mappings":""}
|
package/x/index.html
ADDED
package/x/serve.d.ts
ADDED
package/x/serve.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logIntro } from "./fns/log/intro.js";
|
|
2
|
+
import { onChange } from "./fns/on-change.js";
|
|
3
|
+
import { logReload } from "./fns/log/reload.js";
|
|
4
|
+
import { serveHttp } from "./fns/serve-http.js";
|
|
5
|
+
import { serveWebsocket } from "./fns/serve-websocket.js";
|
|
6
|
+
export async function serve(options) {
|
|
7
|
+
const { wss, sendReload } = serveWebsocket();
|
|
8
|
+
await serveHttp(options, wss);
|
|
9
|
+
if (!options.cold) {
|
|
10
|
+
let count = 1;
|
|
11
|
+
onChange(options, () => {
|
|
12
|
+
logReload(count++);
|
|
13
|
+
sendReload();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
logIntro(options);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=serve.js.map
|
package/x/serve.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../s/serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAA;AAEvD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAgB;IAC3C,MAAM,EAAC,GAAG,EAAE,UAAU,EAAC,GAAG,cAAc,EAAE,CAAA;IAE1C,MAAM,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAE7B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,KAAK,GAAG,CAAC,CAAA;QACb,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;YAClB,UAAU,EAAE,CAAA;QACb,CAAC,CAAC,CAAA;IACH,CAAC;IAED,QAAQ,CAAC,OAAO,CAAC,CAAA;AAClB,CAAC"}
|