Compare commits

..

No commits in common. "ad04ab79cd760ebae771b447bf79e3edef46c608" and "a6c99ee91d26ff8eab2f4904144eed1278e19c86" have entirely different histories.

4 changed files with 6 additions and 20 deletions

View File

@ -4,7 +4,6 @@
"": { "": {
"name": "foam", "name": "foam",
"dependencies": { "dependencies": {
"ansi_up": "^6.0.6",
"hono": "^4.10.4", "hono": "^4.10.4",
"shrimp": "git+https://git.nose.space/probablycorey/shrimp", "shrimp": "git+https://git.nose.space/probablycorey/shrimp",
}, },
@ -47,8 +46,6 @@
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="], "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
"ansi_up": ["ansi_up@6.0.6", "", {}, "sha512-yIa1x3Ecf8jWP4UWEunNjqNX6gzE4vg2gGz+xqRGY+TBSucnYp6RRdPV4brmtg6bQ1ljD48mZ5iGSEj7QEpRKA=="],
"bun-plugin-tailwind": ["bun-plugin-tailwind@0.0.15", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-qtAXMNGG4R0UGGI8zWrqm2B7BdXqx48vunJXBPzfDOHPA5WkRUZdTSbE7TFwO4jLhYqSE23YMWsM9NhE6ovobw=="], "bun-plugin-tailwind": ["bun-plugin-tailwind@0.0.15", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-qtAXMNGG4R0UGGI8zWrqm2B7BdXqx48vunJXBPzfDOHPA5WkRUZdTSbE7TFwO4jLhYqSE23YMWsM9NhE6ovobw=="],
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
@ -63,7 +60,7 @@
"reefvm": ["reefvm@git+https://git.nose.space/defunkt/reefvm#0f39e9401eb7a0a7c906e150127f9829458a79b6", { "peerDependencies": { "typescript": "^5" } }, "0f39e9401eb7a0a7c906e150127f9829458a79b6"], "reefvm": ["reefvm@git+https://git.nose.space/defunkt/reefvm#0f39e9401eb7a0a7c906e150127f9829458a79b6", { "peerDependencies": { "typescript": "^5" } }, "0f39e9401eb7a0a7c906e150127f9829458a79b6"],
"shrimp": ["shrimp@git+https://git.nose.space/probablycorey/shrimp#e0e5e828692713fcaf5d62f88d3ad2c3a43802d4", { "dependencies": { "@codemirror/view": "^6.38.3", "@lezer/generator": "^1.8.0", "bun-plugin-tailwind": "^0.0.15", "codemirror": "^6.0.2", "hono": "^4.9.8", "reefvm": "git+https://git.nose.space/defunkt/reefvm", "tailwindcss": "^4.1.11" } }, "e0e5e828692713fcaf5d62f88d3ad2c3a43802d4"], "shrimp": ["shrimp@git+https://git.nose.space/probablycorey/shrimp#d707ee7e6b074cc0d64179004e5b6cc8250e0c91", { "dependencies": { "@codemirror/view": "^6.38.3", "@lezer/generator": "^1.8.0", "bun-plugin-tailwind": "^0.0.15", "codemirror": "^6.0.2", "hono": "^4.9.8", "reefvm": "git+https://git.nose.space/defunkt/reefvm", "tailwindcss": "^4.1.11" } }, "d707ee7e6b074cc0d64179004e5b6cc8250e0c91"],
"style-mod": ["style-mod@4.1.3", "", {}, "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ=="], "style-mod": ["style-mod@4.1.3", "", {}, "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ=="],

View File

@ -17,7 +17,6 @@
"typescript": "^5" "typescript": "^5"
}, },
"dependencies": { "dependencies": {
"ansi_up": "^6.0.6",
"hono": "^4.10.4", "hono": "^4.10.4",
"shrimp": "git+https://git.nose.space/probablycorey/shrimp" "shrimp": "git+https://git.nose.space/probablycorey/shrimp"
} }

0
src/cli.ts Normal file
View File

View File

@ -2,14 +2,13 @@ import { Hono } from 'hono'
import { serveStatic } from 'hono/bun' import { serveStatic } from 'hono/bun'
import { join, resolve } from 'path' import { join, resolve } from 'path'
import { wrapAndRunCode } from './ribbit' import { wrapAndRunCode } from './ribbit'
import { AnsiUp } from 'ansi_up'
export function startWeb(rootPath: string) { export function startWeb(rootPath: string) {
const root = resolve(rootPath) const root = resolve(rootPath)
const app = new Hono() const app = new Hono()
// console logging // console logging
app.use('*', async (c, next) => { app.use("*", async (c, next) => {
const start = Date.now() const start = Date.now()
await next() await next()
const end = Date.now() const end = Date.now()
@ -19,22 +18,13 @@ export function startWeb(rootPath: string) {
// static files get served out of pub/ // static files get served out of pub/
app.use('/*', serveStatic({ root: join(root, 'pub') })) app.use('/*', serveStatic({ root: join(root, 'pub') }))
app.on(['GET', 'POST'], ['/', '/:page{.+}'], async (c) => { app.on(['GET', 'POST'], ['/', '/:page{.+}'], async c => {
const page = c.req.param('page') || 'index' const page = c.req.param('page') || 'index'
const params = c.req.query() const params = c.req.query()
const path = join(root, `${page}.sh`) const file = Bun.file(join(root, `${page}.sh`))
const file = Bun.file(path)
if (await file.exists()) { if (await file.exists()) {
try { return c.html(await wrapAndRunCode(await file.text(), { params }))
return c.html(await wrapAndRunCode(await file.text(), { params }))
} catch (e) {
let error = e instanceof Error ? e.message : String(e)
const ansiUp = new AnsiUp()
const errorHtml = ansiUp.ansi_to_html(error)
const blue = '#42A5F5'
return c.html(`<h1 style='color:${blue}'>🫧 Error in <a href='vscode://file/${path}' style='text-decoration:none;border-bottom:1px dotted ${blue};color:${blue}'>${path}</a></h1><pre>${errorHtml}</pre>`)
}
} else { } else {
return c.text('404 Not Found', 404) return c.text('404 Not Found', 404)
} }