-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added web-socket refreshing example to client + html pages
- Loading branch information
Showing
9 changed files
with
235 additions
and
89 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 |
---|---|---|
|
@@ -10,12 +10,16 @@ | |
"lib" | ||
], | ||
"module": "lib/scripts.js", | ||
"bin": "build/index.js", | ||
"bin": { | ||
"iiif-hss": "build/index.js", | ||
"iiif-hss-dev": "build/server/entrypoint.js" | ||
}, | ||
"author": "Stephen Fraser <[email protected]>", | ||
"license": "MIT", | ||
"typings": "lib/scripts.d.ts", | ||
"scripts": { | ||
"dev": "bun run ./src/index.ts serve", | ||
"dev": "bun run ./src/entrypoint.ts", | ||
"dev-cli": "bun run ./src/index.ts serve", | ||
"build": "pnpm run build:cli && pnpm run build:server && pnpm run build:client && pnpm run build:node-client", | ||
"build:cli": "tsup-node src/index.ts --no-splitting --outDir build --format esm --env.NODE_ENV production", | ||
"build:server": "tsup-node src/entrypoint.ts --no-splitting --outDir build/server --format esm --env.NODE_ENV production", | ||
|
@@ -63,14 +67,16 @@ | |
}, | ||
"dependencies": { | ||
"@hono/node-server": "^1.13.7", | ||
"@hono/node-ws": "^1.0.5", | ||
"@hono/zod-validator": "^0.4.1", | ||
"@iiif/builder": "^2.0.1", | ||
"@iiif/helpers": "^1.0.6", | ||
"chalk": "^5.3.0", | ||
"cli-progress": "^3.12.0", | ||
"commander": "^13.0.0", | ||
"detect-python-interpreter": "^1.0.0", | ||
"fs-extra": "^11.1.1", | ||
"hono": "^4.6.13", | ||
"hono": "^4.6.16", | ||
"js-yaml": "^4.1.0", | ||
"keyword-extractor": "^0.0.28", | ||
"micromatch": "^4.0.5", | ||
|
@@ -85,8 +91,7 @@ | |
"typesense": "1.7.2", | ||
"unionfs": "^4.5.4", | ||
"yaml": "^2.6.1", | ||
"zod": "^3.24.1", | ||
"commander": "^13.0.0" | ||
"zod": "^3.24.1" | ||
}, | ||
"devDependencies": { | ||
"@atlas-viewer/iiif-image-api": "^2.1.1", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,8 +1,32 @@ | ||
#!/usr/bin/env node | ||
import { serve } from "@hono/node-server"; | ||
import app from "./server"; | ||
import { createNodeWebSocket } from "@hono/node-ws"; | ||
import server from "./server"; | ||
|
||
// @todo make this optional? | ||
await app.request("/build?cache=true&emit=true"); | ||
const { app, emitter } = server._extra; | ||
|
||
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app: app }); | ||
|
||
app.get( | ||
"/ws", | ||
upgradeWebSocket((c) => { | ||
return { | ||
onOpen: (evt, ws) => { | ||
emitter.on("*", (event, data) => { | ||
ws.send(event); | ||
}); | ||
}, | ||
onError: (evt, ws) => { | ||
console.log("WebSocket error", evt); | ||
}, | ||
}; | ||
}) | ||
); | ||
|
||
console.log(`Server running: http://localhost:${app.port}`); | ||
serve(app); | ||
console.log(`Server running: http://localhost:${server.port}`); | ||
const runningServer = serve(server); | ||
injectWebSocket(runningServer); | ||
|
||
// @todo make this optional? | ||
await server.request("/build?cache=true&emit=true"); | ||
await server.request("/watch"); |
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
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.