diff --git a/web/public/demo/picasso.gexf b/web/public/demo/picasso.gexf new file mode 100644 index 00000000..f7b68fcd --- /dev/null +++ b/web/public/demo/picasso.gexf @@ -0,0 +1,46 @@ + + + + Enola.dev + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/browser/index.ts b/web/src/browser/index.ts index 7b60811b..e1a4d5b3 100644 --- a/web/src/browser/index.ts +++ b/web/src/browser/index.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import Graph from "graphology" +import { DirectedGraph } from "graphology" import { parse } from "graphology-gexf/browser" import { random } from "graphology-layout" import forceAtlas2, { inferSettings } from "graphology-layout-forceatlas2" @@ -30,13 +30,13 @@ function getElementByIdOrFail(id: string): HTMLElement { return element } -// TODO Replace hard-coded q=enola:/inline with ?q= read from the URL -fetch("/gexf?q=enola:/inline") // TODO "enola.gexf" for easy Dev mode?! Nah, let's keep it real... +// TODO Replace hard-coded demo with ?q= read from the URL e.g. for "/gexf?q=enola:/inline" +fetch("/demo/picasso.gexf") .then(res => res.text()) .then(gexf => { // Parse GEXF string: // TODO Remove addMissingNodes once GexfGenerator adds them itself - const graph = parse(Graph, gexf, { addMissingNodes: true }) + const graph = parse(DirectedGraph, gexf, { addMissingNodes: true }) // https://graphology.github.io/standard-library/layout-forceatlas2.html: // "Each node’s starting position must be set before running ForceAtlas 2 layout" diff --git a/web/src/bun/build.ts b/web/src/bun/build.ts index 152bc069..b206721f 100755 --- a/web/src/bun/build.ts +++ b/web/src/bun/build.ts @@ -19,12 +19,16 @@ */ import { $, build } from "bun" +// TODO Use https://github.com/google/zx/ or https://github.com/dsherret/dax +// instead of Bun's $ (see also https://github.com/google/zx/pull/1082) +// if they handle (contrib?) https://github.com/oven-sh/bun/issues/16496 ? // TODO FIXME await $`bun tsc` process.stdout.write("🧪 ") await $`bun test` console.log() +await $`rm -f "web-out/*.html web-out/*.js web-out/*.js.map"` const result = await build({ html: true, experimentalCss: true, diff --git a/web/src/bun/develop.ts b/web/src/bun/develop.ts index ded06c78..77efa68e 100755 --- a/web/src/bun/develop.ts +++ b/web/src/bun/develop.ts @@ -18,12 +18,9 @@ * limitations under the License. */ -// TODO Run tsc & test by using e.g. `concurrently`? Or no need? -// Use https://github.com/google/zx/ or https://github.com/dsherret/dax -// instead of Bun's $ (see also https://github.com/google/zx/pull/1082) -// if they handle (contrib?) https://github.com/oven-sh/bun/issues/16496 ? +// TODO Also run tsc & test in BG by using e.g. `concurrently`? Or no need? -import { serve } from "bun" +import { file, serve } from "bun" import index from "../../public/index.html" const PORT = 7070 @@ -36,10 +33,10 @@ serve({ "/": index, }, async fetch(req) { - if (IGNORE.includes(req.url)) { - return new Response("🪹 No Content ", { status: 204 }) - } - return new Response("🙅🏽‍♀️ Not Found", { status: 404 }) + const path = new URL(req.url).pathname + if (path.startsWith("/demo")) return new Response(file(`./public${path}`)) + else if (IGNORE.includes(path)) return new Response("🪹 No Content ", { status: 204 }) + else return new Response("🙅🏽‍♀️ Not Found", { status: 404 }) }, })