Standalone and embed instructions for the shipped client build.
The manual is built with Vite. Sources at the project root:
index.html(Vite entry / host page)src/saiar-manual.js(web component implementation; ES module entry)src/steps.js(manual content;export default [...])src/image-meta.js(generated image dimensions;export default {...})public/images/(optimized images, served verbatim by Vite — do not ship camera originals here)public/assets/(cover logo and similar static files)vite.config.js,package.json(build tooling)scripts/optimize-images.mjs(image optimization, run vianpm run optimize-images)docs/(this file and embed example)
From the project root:
npm install
npm run dev # local dev server on http://localhost:5173
npm run build # produces dist/ for hosting (hashed JS bundle for cache busting)
npm run preview # serves the built dist/ locally for verification
Run npm run build and upload the contents of dist/ to any static host (object storage plus CDN, GitHub Pages, Netlify, IIS, nginx, and so on). The build emits a content-hashed JS bundle so deploys invalidate the browser cache automatically. No server runtime is required.
After npm run build, copy the contents of dist/ (or serve them from a shared static path) and load the hashed module bundle that Vite emits:
<script type="module" src="/path/to/dist/assets/saiar-manual-<hash>.js"></script>
<saiar-manual
data-image-base="/path/to/dist/images/"
data-cover-logo="/path/to/dist/assets/logo.png"
data-cover-title="SAIAR Lab Manual"
data-show-toc="true"
data-persist="both"
data-theme="dark"
data-lang="nl"></saiar-manual>Adjust /path/to/... to match your deployment. See docs/embed-example.html for a full fake-site layout.
Set custom properties on <saiar-manual> (or a wrapper) to tune colors, radius, shadow, and font. Supported hooks:
--saiar-bg--saiar-panel--saiar-panel-2--saiar-text--saiar-muted--saiar-line--saiar-accent--saiar-accent-text--saiar-shadow--saiar-warning-bg--saiar-warning-text--saiar-warning-line--saiar-radius--saiar-font
Unknown variables are ignored and the built-in theme applies.
Steps are the default export of src/steps.js — an array of objects. Common fields:
id- Stable slug for deep links and persistence.section- Section label for grouping.title- Step title.intro- Short lead text.body- Main HTML body (trusted content only).warning- Optional callout text.image- File name under the image base path.imageAlt- Alt text for the image.
Security: body (and similar fields if used) is injected as HTML. Treat steps.js as trusted, author-only content. Do not populate it from untrusted users or remote sources without sanitization.
Only optimized media should ship under public/images/. Camera originals stay out of the bundle.
- Store new originals anywhere on disk (not under
public/images/in the shipped client). - From the project root, run:
npm install
npm run optimize-images -- --input <path-to-originals-folder>
By default the script writes optimized variants into public/images and refreshes both public/images/index.json and src/image-meta.js. Use --output <dir> for a staging folder.
- Custom element:
<saiar-manual> - Attributes:
data-src,data-image-base,data-cover-logo,data-cover-title,data-show-toc,data-persist,data-theme,data-start-step,data-lang(see attribute names onindex.html). - Methods:
goToStep(n),next(),prev(),complete(). - Events:
saiar:stepchangeandsaiar:completebubble from the element. - Upgrade hook: after modules load,
customElements.whenDefined('saiar-manual')resolves when the tag is safe to query or decorate.
CustomEvents (step changes, persistence sync, and similar) are dispatched on the element; event names and detail payloads are documented alongside src/saiar-manual.js. Prefer listening on the <saiar-manual> instance inside your app rather than patching internals.
- Empty manual: Make sure the page is being served over HTTP (e.g. via
npm run dev,npm run preview, or a real host). The bundle uses ES modules, which browsers block onfile://. - Broken images: Check
data-image-basetrailing slash and that files exist underpublic/images/in source (ordist/images/after build). - Script errors in old browsers: Use a current evergreen browser. Vite targets
es2020.