Skip to content

Commit

Permalink
fix (web): Fix minor TSC problem
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Jan 19, 2025
1 parent 38b4b73 commit 09545d3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
46 changes: 46 additions & 0 deletions web/public/demo/picasso.gexf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://gexf.net/1.3"
xsi:schemaLocation="http://gexf.net/1.3 http://gexf.net/1.3/gexf.xsd" version="1.3">
<meta>
<creator>Enola.dev</creator>
</meta>
<graph defaultedgetype="directed" mode="dynamic" timeformat="dateTime"
timerepresentation="interval">
<nodes>
<node id="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl"
label="picasso.ttl" start="2025-01-04T17:47:57.136095755Z">
<parents>
<parent for="https://enola.dev/files/File" />
<parent for="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl" />
</parents>
</node>
<node id="http://example.enola.dev/DalΓ­" label="DalΓ­">
<parents>
<parent for="http://example.enola.dev/Artist" />
<parent for="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl" />
</parents>
</node>
<node id="http://example.enola.dev/Picasso" label="Picasso">
<parents>
<parent for="http://example.enola.dev/Artist" />
<parent for="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl" />
</parents>
</node>
</nodes>
<edges>
<edge source="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl"
target="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl"
kind="https://enola.dev/origin" label="enola:origin" />
<edge source="http://example.enola.dev/DalΓ­" target="http://example.enola.dev/Artist"
kind="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" label="rdf:type" />
<edge source="http://example.enola.dev/DalΓ­"
target="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl"
kind="https://enola.dev/origin" label="enola:origin" />
<edge source="http://example.enola.dev/Picasso" target="http://example.enola.dev/Artist"
kind="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" label="rdf:type" />
<edge source="http://example.enola.dev/Picasso"
target="file:/home/vorburger/git/github.com/enola-dev/enola/test/picasso.ttl"
kind="https://enola.dev/origin" label="enola:origin" />
</edges>
</graph>
</gexf>
8 changes: 4 additions & 4 deletions web/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions web/src/bun/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions web/src/bun/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 })
},
})

Expand Down

0 comments on commit 09545d3

Please sign in to comment.