Skip to content

Carry the editor libraries an H5P site's upload check wants, so h5p-author packages install on a fresh Moodle - #147

Merged
alekswebnet merged 3 commits into
mainfrom
feat/editor-libraries
Nov 6, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/editor-libraries

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #146.

What changes

  • The pack, @missing-elements/h5p-libraries 1.1.0, keeps beside the newest minor of each major what H5P core's upload check wants of them, at the exact versions: 37 H5PEditor.* libraries and four older minors (H5P.Audio 1.2, H5P.DragNBar 1.4, H5P.Question 1.4, H5P.ImageHotspots 1.10), 41 parts and 1.9 MB. They are marked installOnly in parts/index.json, which now also carries each library's editorDependencies and dynamicDependencies. Every one is MIT: declared, or read from its repository where library.json says nothing (UNDECLARED). The runtime parts' bytes are unchanged.
  • The pack export (index.js) lists what the player serves, as before, so a bundler, the installable app's precache and the extension's copy stay at 105 parts; a new ./install export has the whole pack, for a page that writes packages.
  • The player's plan never takes a marked part (planPack), packLibrariesIn keeps the mark and the two lists, and the pinned PACK_INDEX is stamped without the marked parts. The pin moved to pack 1.1.0.
  • h5p-author (lib/install.mjs) carries the closure after the content, where nothing reads it as the package plays; h5p.json lists what plays, as the platforms' exports write it. The CLI says "… 3 more for installing on an H5P site", buildPackage returns them as install, and missingForInstall(libraries) is the rule as a check (./core). In Node the pack is read from parts/index.json; in a page openPack takes @missing-elements/h5p-libraries/install's pack, and a build from the plain one is refused naming the first library and where the pack with them is. A package with media goes through the normalizer, which sorts library folders before content/, so there the run precedes content.json.
  • The VS Code extension and the embed builder (h5p-embed's libraries/) copy only the served parts, with an index of them: the .vsix stays 13.79 MB and an embed site's libraries/ 13.8 MB.
  • The demo's own packages (pnpm demo:content): build-demo-content.mjs follows the preloaded, dynamic and editor dependencies of the libraries it takes from the hub's bundle, at their exact versions, writes them after the libraries that play, and refuses to write a package missingForInstall finds short. The quiz, the video and the glossary changed, 0.13, 2.7 and 0.01 MB larger (8.3 MB for the four); how-it-works and markup needed nothing; formulas.h5p stays content only on purpose. The quiz also took the hub's newer patches of five libraries, which the pack has had since 1.0.1.
  • Design: a new invariant in design/libraries.md, a bullet in design/author.md, the demo's note in design/demo.md, the index line, the layout map, docs/compatibility.md, both READMEs, the skill's delivery note.

Checked

  • A fresh Moodle 4.5.15, no library installed, accepts all 32 type files' examples built on this branch as an admin (4 of 32 before): notes/moodle-upload/fresh-admin-branch-examples.json. Moodle is the one site tried; WordPress and Drupal run the same upload check.
  • The demo's packages on the same site: glossary, quiz and video were refused for H5PEditor.* and are accepted. That is 5 of 6, formulas.h5p being content only (it needs Question Set installed, as an h5p.com export does), and 6 of 6 once Moodle's hub task has run. All five that carry libraries play with their own and against the pack, with no errors or warnings (h5p-verify). Every suite that reads the demo's packages passes with them: verify 27, embed 81, author 142, extension 24, demo 21, skills 73. One test had the quiz's size, 1.5 MB, written in (the SCORM page's row); it takes it from the file now.
  • apps/skills: every example builds, passes missingForInstall, checks as saved content unchanged, and plays trusted and untrusted (73 tests). Author 142 tests (141 in Node, the page build in a browser), three new; player unit 386, with new tests of the plan and the index shape; range-requests.test.ts on the new installable.h5p fixture: a package with the run after the content costs the same four requests over a Range host (probe, tail, head, warm).
  • pnpm sweep, every content type against the larger libraries.h5p: 110 of 110 plays, untrusted and trusted. pnpm build:demo still emits 105 parts, and the demo's tests (the installable app, the sweep's content rules) pass, 21.
  • h5p-embed: a new assertion that a site's libraries/ holds exactly the served parts, which fails without the change; the extension's unit tests pass, 24.
  • Sizes, real files: Question Set +123 kB; most types under 50 kB; Interactive Video 2.4 → 5.1 MB, Course Presentation 1.2 → 4.8 MB, Branching Scenario 2.2 → 7.3 MB, what a platform's export of the same carries, since their editors preload every type they can hold. The demo: quiz 1.49 → 1.62 MB, video 2.49 → 5.22 MB, glossary 0.92 → 0.93 MB.

Costs, plainly

  • Over a host with Range the warm pulls the run with the rest, one request either way, so a Course Presentation's warm is 3.6 MB larger, as a Moodle export's already is. On a host without Range a package without media boots before the run arrives; one with media goes through the normalizer, whose orderEntries sorts library folders before content/, so it boots after the run: the demo's video has 4.1 MB before its content, where it had 1.5. Keeping the run last takes an option in the normalizer, last: that is Normalizer: an option to write named library folders after the media #148, built apart from this pull request as Normalizer: write named library folders after the media (last) #149. Once both are merged and the normalizer is released, h5p-author's Node build and the demo script pass it, which puts the video's content back at 1.5 MB (from a host paced to 1 MB/s that ignores Range it is ready at 2.3 s instead of 4.5).
  • A host that attaches libraries.h5p whole as a bundle downloads 1.8 MB more (13.7 to 15.5 MB), which its player never reads; the parts the player fetches are unchanged.
  • The index carries editorDependencies and dynamicDependencies for every library, and nothing reads them: h5p-author reads each part's own library.json. They are 10.7 kB more in each of the Service Worker's pinned index, index.js and a site's index.json. Dropping them costs nothing while 1.1.0 is unpublished; say if you want that here.
  • The plan refreshes every library a package carries, the ones nothing plays too, as it does for a platform's export: the demo video's refresh fetches H5P.SingleChoiceSet 1.11 (patch 88 to 89, 180 kB) from the pack, its bundle having an older patch than the pack.
  • A package carrying two minors of one library (Image Sequencing: H5P.Audio 1.2 beside 1.5) has the older refreshed to the pack's 1.5 as any older minor is, one small part downloaded that the package's own 1.5 could have answered for. Left as is: one part in a rare case, against a rule in the plan and a refresh reported that fetched nothing.

Release order: the pack first (check-library-pack refuses the player until its pinned index is on jsDelivr), then the player as a minor (the pin moved), then h5p-author as a minor (install in the result, missingForInstall); the extension and h5p-embed (a patch: its site stops copying the parts the player never serves) with the player.

…e h5p-author write it

H5P core's validator, which Moodle, WordPress and Drupal run on an upload, wants every
library a package carries to have its preloaded, dynamic and editor dependencies with it at
the exact major.minor. The pack dropped H5PEditor.* and kept one minor per major, so a Moodle
with no library installed refused 28 of the 32 type files' examples (#146).

The pack (1.1.0) keeps the closure beside the newest minor of each major: 37 editor libraries
and four older minors, 41 parts and 1.8 MB, marked installOnly in parts/index.json, which now
also carries editorDependencies and dynamicDependencies; the pack export lists what the player
serves, and ./install the whole pack. The player's plan never takes a marked part, and its
pinned index is stamped without them. h5p-author writes the closure after the content, at the
exact versions; the CLI says how many, buildPackage returns them as install, and
missingForInstall is the rule as a check. The VS Code extension copies only the served parts.

Checked in a fresh Moodle 4.5.15: all 32 examples accepted as an admin, and every one still
plays. A package with the run after the content costs no request more over a Range host.

Closes #146
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.

h5p-author packages carry no H5P editor libraries, so Moodle refuses them on a site that lacks those

1 participant