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
150 changes: 83 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# H5P Toolkit by Missing Elements
# H5P Toolkit

Play, build, check and package [H5P](https://h5p.org) content without an H5P server.

![The demo page playing a quiz in the h5p-player element: untrusted, its libraries from the site's pack, its content checked](docs/media/player.png)

H5P is an open-source framework for interactive learning content (quizzes, interactive videos,
presentations), shipped as `.h5p` files. Playing one usually takes Moodle, WordPress or Drupal with
the H5P plugin, an h5p.com account, or Lumi on a desktop. This toolkit does those jobs with static
Expand All @@ -13,41 +15,9 @@ files on your own site, command-line tools on your computer, and skills for your
[H5P to SCORM](https://h5p-offline-player.vercel.app/demo/scorm.html) ·
[VS Code extension](https://marketplace.visualstudio.com/items?itemName=MissingElements.h5p-preview)

## What it does
## Play a package on your site

| To | Use | Agent skill |
|---|---|---|
| Play `.h5p` files on your own site, from a URL or from disk | The `<h5p-player>` web component: [`h5p-offline-player`](packages/player/README.md) with [`h5p-runtime`](packages/runtime/README.md) | [`h5p-player-setup`](skills/h5p-player-setup/SKILL.md) |
| Play exports that lack their libraries | [`h5p-libraries`](packages/libraries/README.md), the library pack | |
| Keep the player on a separate domain and embed it by iframe | [`h5p-embed`](packages/embed/README.md) | [`h5p-player-setup`](skills/h5p-player-setup/SKILL.md) |
| Put a package into an LMS | [`h5p-embed --scorm`](packages/embed/README.md#a-scorm-package-for-an-lms) for a SCORM zip, [`h5p-cmi5`](packages/cmi5/README.md) for a cmi5 unit | [`h5p-to-scorm`](skills/h5p-to-scorm/SKILL.md) |
| Build an activity from a prompt or a short JSON source | [`h5p-author`](packages/author/README.md); [`h5p-mcp`](packages/mcp/README.md) in Claude Desktop and other MCP apps; [`h5p-mcp-app`](packages/mcp-app/README.md) to play it in a chat app's reply; [the build page](https://missing-elements.github.io/h5p/build/) in a chat app | [`h5p-author`](skills/h5p-author/SKILL.md) |
| Check that a package plays, or preview it in your browser | [`h5p-verify`](packages/verify/README.md) | [`h5p-verify`](skills/h5p-verify/SKILL.md) |
| Make a package's video start at once, not after a full download | [`h5p-normalize`](packages/normalize/README.md) | [`h5p-normalize`](skills/h5p-normalize/SKILL.md) |
| Play `.h5p` files with no network, or in your editor | [The offline app](https://h5p-offline-player.vercel.app/app/); [H5P Preview](https://marketplace.visualstudio.com/items?itemName=MissingElements.h5p-preview) for VS Code, and on [Open VSX](https://open-vsx.org/extension/MissingElements/h5p-preview) for Cursor and VSCodium | |

The tools named `h5p-…` are on npm as `@missing-elements/h5p-…`, and each name links to its README.

## Terms

- **Package:** a `.h5p` file, not an npm package: a zip of the content and, usually, its
*libraries*, the code of its content types. Exports from h5p.com and h5p.org often leave the
libraries out.
- **Library pack:** the libraries of every content type the H5P hub serves. By default the player
takes a package's libraries from it; with `trusted` and `libraries="pack"`, those a package
lacks, and newer versions of those it carries.
- **Runtime:** the H5P core, which runs the content in the player's frame. It is an npm package of
its own because it is GPL-3.0 and the player is MIT.
- **Untrusted, the default:** played as it is, a package's code would run as your site. So a package
plays as data: none of its own code runs, the libraries come from the pack, or a bundle you name,
and the content is checked as the H5P plugins for Moodle, WordPress and Drupal check an upload.
**`trusted`** plays a package as it is, with its own code, as your site: only for packages you made.

## Quick start

### Play a package on your site

With Vite or webpack 5:
A package, a `.h5p` file, plays from a URL or from disk. With Vite or webpack 5:

```bash
npm install @missing-elements/h5p-offline-player @missing-elements/h5p-runtime
Expand All @@ -68,18 +38,30 @@ player.addEventListener('xapi', (e) => console.log(e.detail.statement)) // resul

- The page must be on `https://` or `localhost`, and a package on another origin needs CORS
headers on its host.
- **Packages play safely by default,** whoever made them: none of their own code runs, and an
export without its libraries gets them from the library pack. Add `trusted` only for a package
you made, to play it with its own code. On a site with signed-in users, keep `trusted` off, or
embed the player from a separate domain with `h5p-embed`.
- **Packages play safely by default,** whoever made them: none of their own code runs. Add
`trusted` only for a package you made, to play it with its own code. On a site with signed-in
users, keep `trusted` off, or embed the player from a separate domain with
[`h5p-embed`](packages/embed/README.md).

[Setting up the player](docs/setup.md) covers pages without a bundler, other bundlers, and the
choice between installing and embedding. [The element's API](docs/api.md) lists every attribute,
property and event.

### Build an activity with AI
## Build an activity with AI

Ask a chat for an activity: the reply plays it, and its `.h5p` is saved from there.

<p>
<img src="docs/media/chat-claude.png" width="32%" alt="Claude, asked for a quiz on the water cycle: the reply plays it in a card with a Download .h5p button">
<img src="docs/media/chat-chatgpt.png" width="32%" alt="ChatGPT: a drag and drop activity on capitals playing in the reply">
<img src="docs/media/chat-grok.jpg" width="32%" alt="Grok: a Course Presentation playing in the reply">
</p>

Claude, ChatGPT and Grok, each with [`h5p-mcp-app`](packages/mcp-app/README.md) added as a
connector: a server you host at a public https address. The activity is built and played in the
person's browser.

In Claude Code or another agent that runs commands:
In Claude Code or another agent that runs commands, install the skill:

```bash
npx skills add missing-elements/h5p-toolkit --skill h5p-author
Expand All @@ -88,11 +70,11 @@ npx skills add missing-elements/h5p-toolkit --skill h5p-author
Then ask for an activity, such as "a five-question quiz on the water cycle, as H5P". The skill
asks which content type, builds the `.h5p`, checks it and opens it for you to play.

Where no command can run, [the build page](https://missing-elements.github.io/h5p/build/) turns
what a chat app wrote into the file, in your browser, and [`h5p-mcp`](packages/mcp/README.md)
builds it onto your disk from Claude Desktop or another MCP app.
With neither, [`h5p-mcp`](packages/mcp/README.md) builds the file onto your disk from Claude
Desktop or another MCP app, and [the build page](https://missing-elements.github.io/h5p/build/)
turns what a chat app wrote into the file, in your browser.

### Use the command-line tools
## Check a package, and put it into an LMS

```bash
npx @missing-elements/h5p-verify@latest course.h5p # does it play? exit code 0 yes, 1 no
Expand All @@ -105,6 +87,57 @@ npx @missing-elements/h5p-author@latest build quiz.json quiz.h5p # build a pack
They need Node 22 or later, and `h5p-verify` a Chromium-based browser such as Chrome or Edge. Keep
`@latest`: without it, npm on an older Node quietly installs an old release.

<p>
<img src="docs/media/scorm.png" width="70%" alt="The H5P to SCORM page with a quiz chosen, showing what its zip will hold">
</p>

[H5P to SCORM](https://h5p-offline-player.vercel.app/demo/scorm.html) builds the same zip in your
browser, and nothing is uploaded. The LMS records the score, each question's result and the
learner's place, as far as the content and SCORM allow
([what is recorded](packages/embed/README.md#a-scorm-package-for-an-lms)). For a cmi5 unit, there
is [`h5p-cmi5`](packages/cmi5/README.md).

## Play offline, and in your editor

<p>
<img src="apps/demo/app/screenshots/wide-video.jpg" width="49%" alt="The offline app playing an interactive video from a .h5p file">
<img src="packages/vscode/images/preview.png" width="49%" alt="H5P Preview: a quiz playing in a VS Code editor tab, with the Explorer beside it">
</p>

[The offline app](https://h5p-offline-player.vercel.app/app/) installs from the browser and plays
`.h5p` files with no network.
[H5P Preview](https://marketplace.visualstudio.com/items?itemName=MissingElements.h5p-preview)
plays them in VS Code, and from [Open VSX](https://open-vsx.org/extension/MissingElements/h5p-preview)
in Cursor and VSCodium.

## The tools

| Tool | What it does | Agent skill |
|---|---|---|
| [`h5p-offline-player`](packages/player/README.md) | The `<h5p-player>` web component | [`h5p-player-setup`](skills/h5p-player-setup/SKILL.md) |
| [`h5p-runtime`](packages/runtime/README.md) | The H5P core, which runs the content in the player's frame. GPL-3.0, so a package of its own | |
| [`h5p-libraries`](packages/libraries/README.md) | The library pack: the libraries of every content type the H5P hub serves, for exports that lack theirs | |
| [`h5p-embed`](packages/embed/README.md) | The player as a site for a separate domain, embedded by iframe; `--scorm` writes a SCORM zip | [`h5p-player-setup`](skills/h5p-player-setup/SKILL.md), [`h5p-to-scorm`](skills/h5p-to-scorm/SKILL.md) |
| [`h5p-cmi5`](packages/cmi5/README.md) | A page holding the player as a cmi5 unit | |
| [`h5p-author`](packages/author/README.md) | A package from a short JSON source, and a package back to one | [`h5p-author`](skills/h5p-author/SKILL.md) |
| [`h5p-mcp`](packages/mcp/README.md) | Builds, reads and checks packages from Claude Desktop and other MCP apps on your computer | |
| [`h5p-mcp-app`](packages/mcp-app/README.md) | Plays an activity in a chat app's reply | |
| [`h5p-verify`](packages/verify/README.md) | Checks that a package plays, or previews it in your browser | [`h5p-verify`](skills/h5p-verify/SKILL.md) |
| [`h5p-normalize`](packages/normalize/README.md) | Rewrites a package so that its video can start at once, not after a full download | [`h5p-normalize`](skills/h5p-normalize/SKILL.md) |
| [H5P Preview](packages/vscode/README.md) | Plays a `.h5p` in a VS Code editor tab | |

The tools named `h5p-…` are on npm as `@missing-elements/h5p-…`. The skills are for Claude Code
and other agents that read files and run commands, installed with [skills](https://skills.sh/);
add `--skill <name>` for one. None needs a provider API key or an H5P server.

```bash
npx skills add missing-elements/h5p-toolkit
```

A chat app takes `h5p-author` as a zip to upload instead:
[download it](https://missing-elements.github.io/h5p/create-with-ai/#install) from the page that
says where it goes in each app.

## Why this one

- **Safe by default.** Every package plays as data: none of its own code runs on your site, and its
Expand All @@ -121,24 +154,15 @@ They need Node 22 or later, and `h5p-verify` a Chromium-based browser such as Ch
- **Nothing you play passes through a server of ours.** The packages have no account, cookies or
telemetry. The library pack comes from jsDelivr unless you serve a copy, and the hosted demo
counts page views, with no cookies ([privacy](docs/privacy.md)).
- **Kept current.** Every week, CI rebuilds the library pack from the H5P hub and H5P's interface
strings from Moodle's translations, opens a pull request when either changed, and plays every
content type in the pack, trusted and untrusted. The player, `h5p-embed` and `h5p-verify` are at
version 2 and the other npm packages at 1, except `h5p-mcp`, `h5p-mcp-app` and H5P Preview, which
are 0.x; [Compatibility](docs/compatibility.md) says what a version number promises.

It is not an editor, so content comes from the tools above or from an H5P site. It stores no
results either: the player raises xAPI events, and your page decides where they go.

## Agent skills

The five skills in the table are for Claude Code and other agents that read files and run
commands, installed with [skills](https://skills.sh/); add `--skill <name>` for one. None needs a
provider API key or an H5P server.

```bash
npx skills add missing-elements/h5p-toolkit
```

A chat app takes `h5p-author` as a zip to upload instead:
[download it](https://missing-elements.github.io/h5p/create-with-ai/#install) from the page that
says where it goes in each app.

## Documentation

- **Set up:** [Setting up the player](docs/setup.md) ·
Expand All @@ -161,14 +185,6 @@ says where it goes in each app.
[Accessibility](ACCESSIBILITY.md) ·
[Security](SECURITY.md)

## Status

The player, `h5p-embed` and `h5p-verify` are at version 2 and the other npm packages at 1, except
`h5p-mcp`, `h5p-mcp-app` and the H5P Preview extension, which are 0.x;
[Compatibility](docs/compatibility.md) says what a version number promises. Every week, CI rebuilds
the library pack from the H5P hub and H5P's interface strings from Moodle's translations, opens a
pull request when either changed, and plays every content type in the pack, trusted and untrusted.

## Contributing

A pnpm workspace: see [CONTRIBUTING.md](CONTRIBUTING.md) and
Expand Down
1 change: 1 addition & 0 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"demo:og": "node scripts/build-og-image.mjs",
"demo:icons": "node scripts/build-app-icons.mjs",
"demo:screenshots": "node scripts/build-app-screenshots.mjs",
"demo:media": "node scripts/build-readme-media.mjs",
"typecheck": "tsc -p tsconfig.json",
"libraries": "node scripts/build-libraries.mjs",
"sweep": "node scripts/sweep-content-types.mjs",
Expand Down
60 changes: 60 additions & 0 deletions apps/demo/scripts/build-readme-media.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { mkdir } from 'node:fs/promises'
import { resolve } from 'node:path'
import { chromium } from 'playwright'
import { preview } from 'vite'

/**
* Renders the README's pictures of this site's pages into `docs/media/`, from the built site: run
* `pnpm build:demo` first. Run this when a page it shows changes its look.
*/

const rootDir = resolve(import.meta.dirname, '..')
const outDir = resolve(rootDir, '..', '..', 'docs', 'media')
const quiz = resolve(rootDir, 'demo', 'content', 'quiz.h5p')
// GitHub draws a README about 830 px wide: 1100 px at 1.5 is twice that, for a dense screen.
const width = 1100
const scale = 1.5

await mkdir(outDir, { recursive: true })
const server = await preview({ root: rootDir, logLevel: 'warn', preview: { port: 4397, strictPort: false } })
const base = server.resolvedUrls.local[0].replace(/\/$/, '')
const browser = await chromium.launch()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
try {
const context = await browser.newContext({ viewport: { width, height: 700 }, deviceScaleFactor: scale, colorScheme: 'light' })
const page = await context.newPage()
/** @param {string} name @param {number} height */
const shoot = async (name, height) => {
await page.setViewportSize({ width, height: Math.ceil(height) })
await page.evaluate(() => document.fonts.ready)
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))))
await page.screenshot({ path: resolve(outDir, name) })
console.log(`[readme-media] ${name} ${width * scale}x${Math.round(Math.ceil(height) * scale)}`)
}

// The player page from its samples down, with the quiz at its first question.
await page.goto(`${base}/`)
await page.getByRole('button', { name: 'Quiz', exact: true }).click()
await page.waitForFunction(() => document.querySelector('h5p-player')?.state === 'ready', null, { timeout: 60_000 })
const frame = page.frames().find((candidate) => candidate.url().includes('/h5p/frame/'))
if (!frame) throw new Error('the player has no frame')
await frame.getByRole('button', { name: 'Start' }).click()
await frame.getByRole('button', { name: 'Check' }).first().waitFor()
await frame.evaluate(() => document.fonts.ready)
// The frame's new height reaches the element a message later, so the page waits for it.
await page.waitForFunction(() => (document.querySelector('h5p-player')?.getBoundingClientRect().height ?? 0) > 400)
await page.locator('.samples').evaluate((samples) => {
const bar = document.querySelector('.topbar')
scrollTo(0, scrollY + samples.getBoundingClientRect().top - (bar instanceof HTMLElement ? bar.offsetHeight : 0) - 8)
})
await shoot('player.png', await page.locator('h5p-player').evaluate((player) => player.getBoundingClientRect().bottom + 8))

// The SCORM page with one package chosen, down to what its zip will hold.
await page.goto(`${base}/demo/scorm.html`)
await page.locator('#file').setInputFiles(quiz)
// A row is listed as soon as it is chosen, and says "Reading…" until its plan is known.
await page.locator('#files li[data-state="planned"]').first().waitFor()
await shoot('scorm.png', await page.locator('#files').evaluate((rows) => rows.getBoundingClientRect().bottom + 24))
} finally {
await browser.close()
await server.close()
}
6 changes: 6 additions & 0 deletions design/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ people integrating the packages: what to do and what happens, with no history an
this folder. Every claim is checked by running the command or reading the source; where a doc looks
wrong, the code settles it, never a comment or this folder's account of it.

**The README shows the product in pictures, each one re-made when what it shows changes.** They are
in `docs/media/`. Those of the site's pages, `player.png` and `scorm.png`, are rendered from the
built site by `pnpm demo:media`. Those of a chat app, `chat-*`, are captures made by hand, since a
chat cannot be scripted, cut down to the conversation so that no account shows. The offline app's
and the extension's are the ones their own commands render.

## Publishing and Node versions

**The packages are published from CI, by trusted publishing** (#246). `publish.yml` is run by hand
Expand Down
2 changes: 2 additions & 0 deletions design/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pnpm demo:og # re-render the social card, apps/demo/demo/og-image.png
pnpm demo:icons # re-render the installable app's icons, apps/demo/app/icons/
pnpm demo:screenshots # re-render the app's install-dialog screenshots, apps/demo/app/screenshots/,
# from the built site: after pnpm build:demo
pnpm demo:media # re-render the README's pictures of the site's pages, docs/media/, from the
# built site too
pnpm libraries # rebuild packages/libraries from the H5P hub; before a release, and every
# Monday by .github/workflows/libraries.yml, which opens a PR when a library changed
pnpm l10n # take the core's translations from Moodle's language packs again, into
Expand Down
6 changes: 4 additions & 2 deletions design/licensing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ library pack", which nobody sees. Changing that one changes
every part's bytes, so every package's `libraries` revision, and every learner's saved state
starts over once; it goes with the next pack release that rewrites every part anyway. The VS Code
extension and the MCP server, "H5P Author MCP by Missing Elements", were named to the rule from
the start, and so is the README's title, "H5P Toolkit by Missing Elements". The player's own
README, its page on npm, is titled with the package's name, whose scope names the author.
the start. The README's title is "H5P Toolkit": it is read under the repository's name, which
names the author as an npm scope does, and its last lines say who makes the toolkit and that H5P
Group does not endorse it. The player's own README, its page on npm, is titled with the package's
name, whose scope names the author.
Not decided: the site's address,
`h5p-offline-player.vercel.app`, which names no owner (the policy approves "h5p.terrisblog.com"
and refuses "h5pbootcamp.com"), and the tab title "H5P player" of `/embed` and the embed package's
Expand Down
Binary file added docs/media/chat-chatgpt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/chat-claude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/chat-grok.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/scorm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"demo:og": "pnpm --filter @missing-elements/h5p-demo demo:og",
"demo:icons": "pnpm --filter @missing-elements/h5p-demo demo:icons",
"demo:screenshots": "pnpm --filter @missing-elements/h5p-demo demo:screenshots",
"demo:media": "pnpm --filter @missing-elements/h5p-demo demo:media",
"libraries": "pnpm --filter @missing-elements/h5p-demo libraries",
"sweep": "pnpm --filter @missing-elements/h5p-demo sweep",
"l10n": "pnpm --filter @missing-elements/h5p-runtime l10n",
Expand Down
Loading