Skip to content

About

Website of OpenDocument Reader, with a live in-browser demo running the WebAssembly build of OpenDocument.core.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

opendocument.app

The website for OpenDocument Reader: the homepage, a privacy policy, a demo that renders a dropped document in the browser, and /web, the same viewer as an installable web app. The renderer is @opendocument/odr-core, the apps' C++ engine compiled to WebAssembly. Nothing is uploaded.

Running it

Node 22.12+ (see .nvmrc).

npm install
npm run dev                        # http://localhost:4321
npm run build && npm run preview   # needed to test the viewer and /web

The viewer does not work under npm run dev. Vite will not serve the renderer's files from public/odr/ as a module, so the demo reports that the renderer could not be loaded. The service worker for /web is also only registered in a build.

Layout

Path What
src/pages/ index (homepage), privacy, tryit (full-window viewer), web (the PWA)
src/scripts/viewer.ts the viewer, shared by every page that shows it
src/scripts/frame-bridge.js the script injected into the document frame; talks to viewer.ts over postMessage
src/scripts/web-app.ts PWA features: launched files, install button, updates, recent files
src/components/viewer/ viewer markup shared by the pages
src/data/links.ts every outbound URL
src/styles/global.css design tokens (the Android app's Material 3 colours)
public/samples/ one sample document per supported format
scripts/sync-odr.mjs copies the renderer into public/odr/<version>/ before dev and build
scripts/build-web-sw.mjs writes the service worker into dist/ after the build

Things that are easy to break

  • The renderer is not bundled. It is copied to public/odr/<version>/ and imported at runtime, because the emscripten glue finds its .wasm through import.meta.url. The version is a directory, not a ?v= query, so the glue and the wasm can never come from different releases. public/odr/ is generated and gitignored.
  • The renderer loads on first use, never on page load: it is about 6.5 MB.
  • The document frame is sandboxed with allow-scripts and no allow-same-origin. A dropped file's scripts run in an opaque origin and cannot reach the page. The page cannot reach into the frame either, so everything goes through frame-bridge.js. That script is inlined as a string and must never contain a closing </script> tag.
  • The CSP in firebase.json needs 'wasm-unsafe-eval' and 'unsafe-inline'. The renderer writes its editor scripts inline into the frame, and a frame with an opaque origin cannot load hashed or 'self' scripts.
  • Caching: /_astro/** and /odr/<version>/** are immutable; /odr/index.js (a forwarder to the current version) is no-store; the service worker and manifest are no-cache.
  • /app-ads.txt must stay at the domain root. It carries the AdMob publisher line for the free apps.
  • Store IDs differ by platform. at.tomtasche.reader is the free app on Android but the paid app on iOS. Pick links by edition and platform; see src/data/links.ts.
  • The format list comes from odr.fileTypes(), not the store listing. If they disagree, fix the store listing.

How editing, saving, annotation and the rest of the viewer behave is described in the code and in core's editing design doc.

Deployment

Pushes to main deploy to Firebase Hosting (project admob-app-id-9025061963) via .github/workflows/deploy.yml. Pull requests get a preview channel for 14 days. The workflow needs one secret, FIREBASE_SERVICE_ACCOUNT: the JSON key of a service account with the Firebase Hosting Admin role.

The old site lived in OpenDocument.fx, which should be archived: a firebase deploy from it would overwrite this site.

About

Website of OpenDocument Reader, with a live in-browser demo running the WebAssembly build of OpenDocument.core.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages