Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,23 +248,36 @@ packages/embed/ @missing-elements/h5p-embed — the embed page as a st
site/ the page: index.html (its CSP a placeholder the writer fills), main.js,
embed.js (startEmbed, also what the demo's /embed runs), embed.css,
resizer.js (the page-side half of the resizer protocol, served at the
folder's root, and at /resizer.js on the demo)
folder's root, and at /resizer.js on the demo); and the SCORM page:
scorm.html, scorm-main.js, scorm-page.js (startScormPage, also what the
demo's /demo/scorm.html runs) and scorm-page.css (#122)
lib/build.mjs buildSite(): copies the page, the player's dist/, the runtime's dist/ as
frame-assets/ and the library pack; writes config.js, the policy into the
page, the headers for five kinds of host and NOTICE.txt
lib/scorm.mjs buildScorm(), `--scorm`: one .h5p, the player, the runtime and the parts of the
pack it needs as a SCORM 1.2 zip, planned with the player's `./plan`; refused for
a library neither the package nor the pack carries
lib/scorm-core.mjs what the SCORM zip is wherever it is written, and no Node import: the
package read and its parts planned, the entries laid out, the zip written
into a zip.js writer; lib/scorm-browser.mjs, `./scorm/browser`,
buildScormInPage(): the same zip in a page, from a File, the files
fetched from the site and the zip a Blob; lib/shared.mjs, EmbedError and
the player's file names, for the modules that import no Node (#122)
scorm/ the SCORM package's launch page (index.html, its title, language and
build filled in by the writer) and scorm.js, its bridge to the LMS's API
bin/h5p-embed.mjs the command
scripts/ check-published.mjs, the publish guard for the player it pins exactly (#109)
and the normalizer's `./crc32` (#108)
scripts/ build.mjs, dist/scorm-page.js: the SCORM page's script bundled with zip.js
and the player's `./plan` for a written site, which has no bundler
(#122); check-published.mjs, the publish guard for the player it pins
exactly (#109) and the normalizer's `./crc32` (#108)
tests/ build.test.ts, no browser; site.test.ts, a written site on 127.0.0.1
framed by a page on localhost, as deployed; scorm.test.ts, the zip in Node
and the launch page under a stand-in for an LMS's player page in
Chromium; package-types.ts as for the normalizer
types/ generated, not in git: the declarations of the three entries
Chromium; scorm-browser.test.ts, the page's builder run in Node against
the command's zip, entry for entry; scorm-page.test.ts, the page itself
in Chromium; helpers/, the static host and the quiz helpers those share;
package-types.ts as for the normalizer
types/ generated, not in git: the declarations of the five entries

packages/vscode/ h5p-preview, "H5P Preview by Missing Elements" — the VS Code extension, a .vsix
for the Visual Studio Marketplace and Open VSX, not on npm (see *The VS Code
Expand Down Expand Up @@ -297,7 +310,9 @@ apps/demo/ the demo app: the dev server for the whole repository,
demo/ demo/index.html is the examples index, demo/setup.html the setup page for
integrators, demo/compare.html how it compares with h5p.com, the H5P
plugins, Lumi and h5p-standalone, demo/normalize.html why deflated media cannot stream and how
the normalizer fixes it (prose and a CSS-only diagram, no script), the rest
the normalizer fixes it (prose and a CSS-only diagram, no script),
demo/scorm.html the H5P-to-SCORM page, the embed package's run with the
demo's own copies (demo/scorm-page.js, #122), the rest
the individual embedding demos, all sharing demo/player-page.css;
demo/cmi5.html with demo/cmi5-page.js is a cmi5 assignable unit around
the element, on @missing-elements/h5p-cmi5, and demo/cmi5-course.zip the
Expand Down Expand Up @@ -2574,6 +2589,36 @@ one row each; an LMS added here gets a row there.
its success unknown. The pack, its parts, the demo packages (the normalizer's) and h5p-author's
quiz have no stored entry with a descriptor, so nothing else needed the change.

- **The same zip is built in a page, with nothing uploaded** (#122, 2026-11-03). The people who
need a SCORM package, designers and teachers with Canvas, Moodle or Blackboard, do not run `npx`:
their route, H5P → Lumi → SCORM, which UBC, UFL, ISU, the University of Alberta and others
publish guides for, has had Lumi's export broken since April 2026, and no converter ran in the
browser. So `scorm.mjs` was split as #108 split h5p-author's build. `scorm-core.mjs` reads the
package, plans the parts, lays out the entries and writes them, and imports no Node; `scorm.mjs`
is the Node side, the files from the installed packages and the zip to a path, its API unchanged;
`scorm-browser.mjs`, `./scorm/browser`, is the page's, `buildScormInPage()`: the package a
`File`, the player's files, the runtime and the pack fetched from the site the page is on (`base`,
`pack` or `packBase`, or `assets` for a page that bundles the launch page, the bridge, the
stylesheet and the licence list), each part checked against the index's SHA-256 since it came
over the network, and the zip a `Blob`. The runtime's files are named by a list,
`RUNTIME_FILES`, plus the fonts from its `MANIFEST.json`, since a folder on a server cannot be
listed; `scorm-browser.test.ts` runs the builder in Node, which has `fetch`, `File` and
`crypto.subtle`, against a written site and holds its zip to the command's entry for entry, so a
file the runtime adds shows up there. `site/scorm-page.js` is the page's script,
`startScormPage()`, which reads `#file`, `#status`, `#download` and `#notice`, and a `#state`
badge where the page has one; the written site loads it as `scripts/build.mjs` bundles it with
zip.js and the player's `./plan` (`dist/scorm-page.js`, zip.js's licence in its header, since the
site has no bundler), from `scorm.html`, with the launch page and the bridge copied beside it as
`scorm-launch.html` and `scorm.js` and the player's and the pack's versions in `config.js`. The
demo reuses the source at `/demo/scorm.html` in the site's own design: the pack's parts as Vite
emits them, the four files as `?raw` strings, the player's version from a `define`, and the
player's built files from the site root, which a dev middleware serves from the player's `dist/`
(`playerDistPlugin`). Decided with the owner that day: SCORM 1.2 only, H5P's result rule kept,
the tested LMSs the supported ones. Canvas, the audience's LMS, runs its SCORM on Rustici's
SCORM Cloud by all accounts and cannot be tested here, since Canvas Free-for-Teacher has no SCORM
upload. `scorm-page.test.ts` drives the page in Chromium: a chosen file, the download, which is
the command's zip and plays unpacked, a refusal, and the next file after it.

`tests/scorm.test.ts` checks the zip, the parts it carries, its stored entries' local headers and
its refusals in Node. In Chromium it plays the unpacked zip under a page that holds the API and
frames the launch page, as Moodle's player does. It covers:
Expand Down Expand Up @@ -2755,6 +2800,7 @@ Three artefacts, built three different ways, because they are consumed three dif
| `dist/h5p-sw-mount.js` | esbuild, ESM | For hosts that enforce one worker per origin |
| `dist/h5p-jobs.js` | esbuild, IIFE | The Jobs worker as a file, for a page whose CSP refuses a `blob:` worker |
| `dist/h5p-plan.js` | esbuild, ESM, not minified | The player's library rules, `./plan`, for the packages that write what it plays; the build fails if zip.js gets in |
| `packages/embed/dist/scorm-page.js` | esbuild, ESM | The SCORM page's script for a written site, which has no bundler: zip.js and the player's `./plan` inside, zip.js's licence in its header |
| `packages/runtime/dist/` | `packages/runtime/scripts/build.mjs` | The H5P core from `vendor/h5p-core/`, its scripts joined and minified under a licence header, its stylesheets rebuilt to stand alone, and the boot script; a package of its own, GPL |
| `apps/demo/dist-demo/` | `apps/demo/scripts/build-demo.mjs` | The hosted demo: the pages, and `dist/`'s layout at the site root |

Expand Down Expand Up @@ -3608,7 +3654,8 @@ deliberate additions to it, not drift:
- A VS Code extension. The design has the player on websites; the extension plays a package in
the editor, from a server on the author's own computer.
- A SCORM package. The design emits results and stores none; `h5p-embed --scorm` puts one package
in an LMS, which records its score, result, time and the learner's place.
in an LMS, which records its score, result, time and the learner's place; since #122 a page on
the written site, and on the demo, builds the same zip in the browser.
- The libraries are warmed into the cache before the frame boots on a `Range` host. The design
reads every entry on demand; on a high-latency host that made the boot a matter of minutes.
- A library source that cannot be reached falls back to a bundle downloaded whole from the same
Expand Down
6 changes: 6 additions & 0 deletions apps/demo/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ <h2>More ways to host it</h2>
<span>The player as an assignable unit: launched by an LMS, statements to its LRS, completion by the mastery score. The package stays on this site.</span>
</a>
</li>
<li>
<a class="card" href="/demo/scorm.html">
<strong>H5P to SCORM</strong>
<span>Drop a <code>.h5p</code> and download it as a SCORM 1.2 package for Moodle, ILIAS, OpenOLAT, Chamilo or SCORM Cloud, built in your browser with nothing uploaded.</span>
</a>
</li>
<li>
<a class="card" href="/demo/local-file.html">
<strong>A file from disk</strong>
Expand Down
5 changes: 4 additions & 1 deletion apps/demo/demo/player-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,10 @@ label.file:has(input:focus-visible) { outline: 2px solid var(--accent); outline-
.status[data-state="error"] { border-left-color: var(--danger); }
.status[data-state="probing"],
.status[data-state="downloading"],
.status[data-state="indexing"] { border-left-color: var(--accent); }
.status[data-state="indexing"],
.status[data-state="building"] { border-left-color: var(--accent); }
/* The SCORM page's link to the zip it built, at the strip's right. */
.status a { margin-left: auto; font-weight: 600; }

.badge {
display: inline-flex;
Expand Down
17 changes: 17 additions & 0 deletions apps/demo/demo/scorm-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* The demo's `/demo/scorm.html`: the SCORM page `@missing-elements/h5p-embed` writes into a player
* domain, run with the demo's own copies — the pack's parts as Vite emits them, the launch page,
* the bridge, the stylesheet and the pack's licence list as strings — and the player's files from
* the site root, where the build puts them. One script for both, so what the demo offers is what
* a host's own site offers.
*/

import { startScormPage } from '@missing-elements/h5p-embed/scorm-page.js'
import launch from '@missing-elements/h5p-embed/scorm/index.html?raw'
import bridge from '@missing-elements/h5p-embed/scorm/scorm.js?raw'
import css from '@missing-elements/h5p-embed/embed.css?raw'
import { pack } from '@missing-elements/h5p-libraries'
import libraries from '@missing-elements/h5p-libraries/libraries.txt?raw'
import { version as packVersion } from '@missing-elements/h5p-libraries/package.json'

startScormPage({ base: '/', pack, assets: { launch, bridge, css, libraries }, version: __PLAYER_VERSION__, packVersion })
115 changes: 115 additions & 0 deletions apps/demo/demo/scorm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Convert H5P to SCORM in your browser — h5p-offline-player</title>
<meta name="description" content="Drop a .h5p file and download it as a SCORM 1.2 package for Moodle, ILIAS, OpenOLAT, Chamilo or SCORM Cloud. Built in your browser with nothing uploaded; the LMS records the score, the result, the time and the learner's place." />
<link rel="canonical" href="%SITE_URL%/demo/scorm.html" />
<meta name="theme-color" content="#2f6df6" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="h5p-offline-player by Missing Elements" />
<meta property="og:locale" content="en_US" />
<meta property="og:title" content="Convert H5P to SCORM in your browser — h5p-offline-player" />
<meta property="og:description" content="Drop a .h5p file and download it as a SCORM 1.2 package for Moodle, ILIAS, OpenOLAT, Chamilo or SCORM Cloud. Built in your browser with nothing uploaded; the LMS records the score, the result, the time and the learner's place." />
<meta property="og:url" content="%SITE_URL%/demo/scorm.html" />
<meta property="og:image" content="%SITE_URL%/demo/og-image.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="h5p-offline-player: self-hosted H5P, with no H5P server" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Convert H5P to SCORM in your browser — h5p-offline-player" />
<meta name="twitter:description" content="Drop a .h5p file and download it as a SCORM 1.2 package for Moodle, ILIAS, OpenOLAT, Chamilo or SCORM Cloud. Built in your browser with nothing uploaded; the LMS records the score, the result, the time and the learner's place." />
<meta name="twitter:image" content="%SITE_URL%/demo/og-image.png" />
<!-- partial: head -->
<script type="module" src="/demo/scorm-page.js"></script>
</head>

<body>
<!-- partial: topbar -->

<main>
<p class="eyebrow">SCORM</p>
<h1>H5P to SCORM</h1>
<p class="lede">
Drop a <code>.h5p</code> file here, or choose one, and download it as a SCORM 1.2 package
for your LMS. It is built in your browser with the player this site serves, and nothing is
uploaded: the package never leaves your computer.
</p>

<form class="controls">
<label class="file">
Choose a .h5p file
<input type="file" id="file" accept=".h5p,application/zip" />
</label>
</form>

<div class="status" data-state="idle">
<span class="badge" id="state" data-state="idle">idle</span>
<span id="status"></span>
<a id="download" hidden>Download</a>
</div>

<!-- The live region is on the page from the start, as on the player page, so that a refusal
put into it is announced. -->
<div role="status" aria-live="polite">
<p class="message error" id="notice" hidden></p>
</div>

<h2>In the LMS</h2>
<p>
Add the zip to a course as a SCORM activity. The LMS records the score out of 100, whether
the content was passed or failed, or completed when it does not say, the time spent, and
the learner's place, so the next launch continues where they left off. Content that reports
no result of its own, an Accordion or a Virtual Tour, stays incomplete. The package plays
with its own code on the LMS's origin, as every SCORM package does.
</p>
<table class="table">
<thead>
<tr><th>Checked in</th><th>Add the zip as</th><th>Change from the defaults</th></tr>
</thead>
<tbody>
<tr><td>Moodle 4.5</td><td>a SCORM package activity</td><td>nothing; keep the maximum grade at 100</td></tr>
<tr><td>ILIAS 11</td><td>a SCORM learning module</td><td>turn Learning Progress on</td></tr>
<tr><td>OpenOLAT 21.1</td><td>a "SCORM 1.2" course element</td><td>the pass mark; in a learning path, the completion criterion</td></tr>
<tr><td>Chamilo 3.0</td><td>an imported learning path</td><td>publish the learning path</td></tr>
<tr><td>SCORM Cloud</td><td>a course</td><td>nothing</td></tr>
<tr><td>Frappe LMS</td><td>a SCORM chapter</td><td>nothing; the content needs a pass mark</td></tr>
</tbody>
</table>
<p>
Another LMS that takes SCORM 1.2 may work as well; these are the ones checked, as a learner
in Chrome. The LMS has to be served over https, since the player needs its Service Worker.
SCORM 1.2 keeps 4,096 characters of saved state, enough for a quiz; a larger state is not
saved.
</p>

<h2>What goes in the zip</h2>
<p>
The package, the player and the H5P runtime, and a launch page that reports to the LMS. A
package exported without its libraries, as h5p.com and h5p.org export, gets the ones it
needs from this site's copy of the library pack, and only those: a quiz with formulas takes
eleven, most of it the formula renderer. One that carries its libraries, as exports from
Lumi and the H5P plugins of Moodle, WordPress and Drupal do, plays with its own. A package
that needs a library neither has is refused here, with the library named, rather than in
front of a learner.
</p>

<h2>From the command line</h2>
<p>
The same zip, from the same code, for a script or a pipeline; on Node 22 or later. A site
written by <code>h5p-embed</code> for a player domain of your own carries this page too, at
<code>/scorm.html</code>.
</p>
<pre class="code" data-lang="sh">npx @missing-elements/h5p-embed@latest --scorm course.h5p # writes ./course.scorm.zip</pre>

<footer>
<nav class="footer-links" aria-label="More on this site">
<a href="/demo/">All examples</a>
<a href="/">Player page</a>
<a href="https://www.npmjs.com/package/@missing-elements/h5p-embed" rel="noopener">The embed package on npm</a>
</nav>
</footer>
</main>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/demo/partials/topbar-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="/">Player</a>
<a href="/demo/setup.html">Setup</a>
<a href="/demo/compare.html">Compare</a>
<a href="/demo/normalize.html">Normalize</a>
<a href="/demo/scorm.html">SCORM</a>
<a href="/demo/">Examples</a>
<a href="/app/">App</a>
</nav>
1 change: 1 addition & 0 deletions apps/demo/scripts/lib/pages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const PAGES = [
{ name: 'normalize', file: 'demo/normalize.html', path: '/demo/normalize.html' },
{ name: 'xapi', file: 'demo/xapi.html', path: '/demo/xapi.html' },
{ name: 'cmi5', file: 'demo/cmi5.html', path: '/demo/cmi5.html' },
{ name: 'scorm', file: 'demo/scorm.html', path: '/demo/scorm.html' },
{ name: 'local-file', file: 'demo/local-file.html', path: '/demo/local-file.html' },
{ name: 'two-players', file: 'demo/two-players.html', path: '/demo/two-players.html' },
{ name: 'demo-embed', file: 'demo/embed.html', path: '/demo/embed.html' }
Expand Down
Loading
Loading