Skip to content

v0.10.0

Choose a tag to compare

@alekswebnet alekswebnet released this 18 Oct 07:04

@missing-elements/h5p-offline-player 0.10.0, @missing-elements/h5p-libraries 0.3.0, @missing-elements/h5p-embed 0.8.0, @missing-elements/h5p-verify 0.3.0. Embed 0.7.0 and verify 0.2.0, which went to npm without a release of their own, are covered here too.

The pack downloads only the libraries a package needs

With libraries="pack", the player now downloads only the libraries a package needs, one archive per library, and checks each against the SHA-256 in the pack's index. Until now, the first package that needed anything from the pack downloaded all 13.7 MB of it. For the demo's packages it now downloads between 0.04 MB, for a Column, and 4 MB, for a quiz with formulas.

Each archive is kept on the device and shared by every package that uses it. Once kept, it is used without a request, offline as well. The index of the pack the player pins ships with the player, so working out what a package needs takes no request either.

Packages play the pack's newer versions of the libraries they carry

With libraries="pack", a library a package carries now plays at the pack's version when the pack has the same major version at a higher minor or patch. Content written for an older minor is upgraded first, with the steps the library ships in its upgrades.js, as an H5P site does. An old export then plays with the fixes and the look of current H5P: the demo's quiz, for example, now plays H5P.Video 1.6.79 instead of the 1.6.68 it carries.

  • A library never moves to another major version.
  • A library the pack doesn't have keeps the package's own copy.
  • A refresh that fails, because an archive can't be downloaded or doesn't match its hash, is given up, and the package plays with its own libraries. A package that can't play without the archive is refused, with the library named.
  • refresh-libraries="off" turns this off: the libraries a package carries play as exported, and the pack only supplies what's missing.
  • Only pack does this. A .h5p URL in libraries still only supplies what's missing, and without libraries a package plays as it is.

libraryBundle.refreshed, also in the ready event's detail, lists what played at the pack's version, as { library, from, to }.

Your own copy of the pack

  • pack-base names the folder of a copy of the parts/ folder of @missing-elements/h5p-libraries on your site. Its index.json is read from there and kept, so a package can be planned for with no network.
  • With a bundler, set the pack property to the package's pack export, before src. The bundler emits each archive as an asset of your site. Its type is LibraryPack.
import { pack } from '@missing-elements/h5p-libraries'

player.pack = pack
player.setAttribute('libraries', 'pack')

Without either, the archives come from jsDelivr, at the pack version the player pins: 0.3.0 for this release. The URL of a whole libraries.h5p in libraries still works: it is downloaded whole and only supplies what's missing.

Breaking changes

  • With libraries="pack", packages that carry older libraries play the pack's newer versions. refresh-libraries="off" keeps 0.9's behaviour.
  • The libraries sha256: part of revision now covers the pack's archives a package played with. A package that played with the pack under 0.9 reports a different revision from 0.10.0. A package that carries its libraries gets this part as soon as one of them is refreshed. A later pack release that changes none of a package's libraries leaves its revision as it is.
  • A learner's saved state (resume) is kept per revision, so in those packages it starts over once, with H5P's own "content has changed" dialog.
  • For the pack, libraryBundle.url is now the folder the archives come from, not a .h5p URL.
  • From this release on, the pack version a player pins changes only in a minor release, never in a patch, since a new pack changes what packages play. What a version number promises has the rest.

@missing-elements/h5p-libraries 0.3.0

The same libraries as 0.2.0, now also as one archive per library:

  • parts/: 105 archives, and index.json with each library's version, its dependencies, and its archive's size and SHA-256.
  • index.js and index.d.ts: the pack export, one static new URL per archive, so a bundler emits each one as an asset.
  • libraries.h5p is still included.

Archives under 8 kB are padded to just over 8 kB, so that Vite and webpack emit them as files rather than inlining them as data: URLs, which a page's connect-src would refuse.

@missing-elements/h5p-embed 0.7.0 and 0.8.0

0.7.0 also writes headers for a server of your own, beside _headers for Netlify and Cloudflare Pages and vercel.json for Vercel:

  • a Caddyfile to run as it is;
  • an nginx.conf to include in a server block;
  • an .htaccess for Apache with mod_headers.

0.8.0:

  • The site carries the pack as libraries/, one archive per library, in place of libraries.h5p. Writing the site again removes the old file.
  • With libraries=pack, packages that carry older libraries play the pack's newer versions. &refresh-libraries=off in the address turns that off.
  • startEmbed takes pack, the @missing-elements/h5p-libraries export, or packBase, the folder of a copy of its parts/. librariesPack, the URL of a whole libraries.h5p, still works, as a bundle that only supplies what's missing.
  • The report posted on ready includes libraryBundle.refreshed.
  • It needs Node 22 or later, and requires player 0.10.0 and libraries 0.3.0.

@missing-elements/h5p-verify 0.2.0 and 0.3.0

0.2.0 adds --untrusted, which plays a package the way a site plays one it did not make:

  • none of the package's own code runs;
  • its libraries come only from the pack;
  • its content is checked against each library's semantics.json.

Each field the check changes is reported as a warning, since the content still plays. A package that needs its own copy of a library is refused, with what to do about it. --libraries also takes a bundle on disk.

0.3.0:

  • --libraries takes a copy of the pack's parts/ folder, which plays as pack. Naming node_modules/@missing-elements/h5p-libraries/parts runs the check offline.
  • --no-refresh-libraries plays the libraries a package carries as exported.
  • The report lists what played at the pack's version, as refreshed and on a line of its summary.
  • It needs Node 22 or later, and requires player 0.10.0.

Upgrading

  • On a CDN, update the player's URL to h5p-offline-player@0.10.0. The runtime stays at h5p-runtime@0.2.4.
  • Copy dist/h5p-sw.js from 0.10.0 onto your site again, or rebuild a worker that mounts @missing-elements/h5p-offline-player/sw. The Service Worker changed, and the pack's archives need the new one.
  • With a bundler, update the player, and add @missing-elements/h5p-libraries 0.3.0 if you set pack.
  • On a player domain, write the site again with embed 0.8.0 installed, using --force, and deploy it.

@missing-elements/h5p-runtime stays at 0.2.4, @missing-elements/h5p-cmi5 at 0.4.2 and @missing-elements/h5p-normalize at 0.1.3, since none of them changed. Normalize will need Node 22 from its next release.

Full Changelog: v0.9.5...v0.10.0