Skip to content

feat: 200-byte data browser, replace mashlib bundle by default - #8

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
feat-tiny-data-browser
May 16, 2026
Merged

melvincarvalho merged 1 commit into
gh-pagesfrom
feat-tiny-data-browser

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Summary

The page is the data. JSS already embeds each Solid resource as JSON-LD in <script type="application/ld+json" id="dataisland"> — the full mashlib bundle (hundreds of KB) is mostly there to render that. This PR replaces it with a deliberately minimal ES module:

  • data-browser.js — ~180 bytes of runtime code: find the data island, turn every URI into an <a>, render to #mashlib
  • data-browser.css — ~290 bytes of runtime CSS: system font, cream background, soft card with rounded corners, blue hover-underline links

Together: well under a kilobyte for the entire "data browser." Click any URI in the rendered page → navigate to that Solid resource → JSS re-serves with the wrapper → our module re-renders. The data is the UI; the URIs are the navigation.

How it works

generateModuleDatabrowserHtml in JSS (verified at node_modules/javascript-solid-server/src/mashlib/index.js:306) produces this HTML when --mashlib-module <url> is set:

<!doctype html><html lang="en"><head>...
<link rel="stylesheet" href="${cssUrl}">     <!-- moduleUrl.replace(/\.js$/, '.css') -->
</head>
<body>
  <script type="application/ld+json" id="dataisland" data-uri="...">{...}</script>
  ...
  <div id="mashlib"></div>
  <script type="module" src="${moduleUrl}"></script>
</body>

Our module reads #dataisland, paints #mashlib. Done.

Hosting

  • Both files are in the npm tarball (files whitelist updated: 4 → 6 files)
  • jspod passes --mashlib-module https://cdn.jsdelivr.net/npm/jspod@${pkg.version}/data-browser.js to JSS
  • Version-pinned URL → immutable per version → cache-immortal at the CDN edge
  • No new infra (jsdelivr serves npm packages for free)

Verification (local)

End-to-end test using a Python http.server in place of jsdelivr (since 0.0.11 isn't published yet):

  • JSS responds to GET /public/ (Accept: text/html, Sec-Fetch-Dest: document) with the module-mode wrapper ✓
  • Data island contains the LDP container JSON-LD ✓
  • Stylesheet auto-loaded from the .css sibling URL ✓
  • Module script tag at end of body, version-pinned URL ✓
  • Renderer simulation shows every URI wrapped as <a>: http://www.w3.org/ns/ldp#, http://127.0.0.1:.../public/, http://127.0.0.1:.../public/.acl, etc. ✓

Reviewer test plan

Because the jsdelivr URL https://cdn.jsdelivr.net/npm/jspod@0.0.11/data-browser.js only exists once we publish 0.0.11, the easiest end-to-end test is:

  1. After merge: publish 0.0.11 to npm
  2. npx jspod@0.0.11 in a clean directory
  3. Sign in with me/me via Pilot (or visit any pod resource with browser navigation)
  4. Confirm the cream-background page with clickable URIs renders

If you want to verify before publish, pull the branch and serve the files locally:

(cd /path/to/jspod-repo && python3 -m http.server 8765) &
# Then run JSS directly with --mashlib-module http://localhost:8765/data-browser.js

What this doesn't try to do

  • Replace mashlib for power users — anyone wanting the full data browser can run JSS directly with --mashlib-cdn
  • Edit, ACL viewer, table-of-properties UI — those are mashlib's job. jspod is the onboarding layer
  • Cover offline-only installs — first paint requires one CDN fetch from jsdelivr. After that, browser cache. Acceptable for the "personal-pod laptop" target audience

This is a positioning move as much as a code change — it's jspod saying the data browser shouldn't be a SPA bundle, it should be the page rendering its own data.

Refs #1

The page is the data. JSS already embeds the resource as JSON-LD in
<script type="application/ld+json" id="dataisland">. The full mashlib
bundle is hundreds of KB just to render that. This change replaces it
with a deliberately tiny ES module that:

- Finds the data island in the served HTML
- Turns every URI into a clickable <a>
- Renders into JSS's <div id="mashlib"> slot

The data is the UI; the URIs are the navigation. Click any link in
the rendered page and you navigate to that Solid resource, which JSS
also serves with the data island wrapper, which our module also
renders. Pure linked-data philosophy.

Files:
- data-browser.js (~180 bytes of runtime code + explanatory comments)
- data-browser.css (~290 bytes of runtime CSS + comments) — system
  font, cream background, soft card, hover-underline links

Hosting:
- Both files are in the npm tarball (files whitelist updated).
- jspod passes --mashlib-module
  https://cdn.jsdelivr.net/npm/jspod@<pkg.version>/data-browser.js
  to JSS. Version-pinned = cache-immortal per version, so a published
  release always loads the matching browser code. JSS auto-fetches
  the .css sibling from moduleUrl.replace(/\.js$/, '.css').
- No new infra; jsdelivr serves npm packages for free.

JSS contract verified locally (Python http.server + JSS in single-
user mode): /public/ responds with the module-mode HTML wrapper,
data island contains the LDP container JSON-LD, all URIs round-trip
through the renderer as <a> tags.

README adds a "The page is the data" section explaining the
philosophy and pointing to the two source files in the package.

Bumps jspod to 0.0.11.

Refs #1
@melvincarvalho
melvincarvalho merged commit 1531910 into gh-pages May 16, 2026
@melvincarvalho
melvincarvalho deleted the feat-tiny-data-browser branch May 16, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant