@missing-elements/h5p-embed 0.8.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,7 +65,8 @@ The headers themselves, for a host not listed:
65
65
  |---|---|
66
66
  | every path | `Content-Security-Policy` (the policy the command prints, with `frame-ancestors` from `--ancestors`), `X-Content-Type-Options: nosniff`, `Referrer-Policy: strict-origin-when-cross-origin` |
67
67
  | `/h5p-sw.js` | `Cache-Control: no-cache`, so an update reaches learners on their next visit |
68
- | `/frame-assets/*`, `/resizer.js`, `/libraries/*` | `Cache-Control: public, max-age=3600, stale-while-revalidate=86400` |
68
+ | `/frame-assets/*`, `/libraries/*` | `Cache-Control: no-cache`: the runtime and the library pack keep their file names between versions, so a copy from before an update must not be used after it |
69
+ | `/resizer.js` | `Cache-Control: public, max-age=3600, stale-while-revalidate=86400` |
69
70
 
70
71
  To update, run the command again with `--force` and redeploy.
71
72
 
@@ -74,7 +75,7 @@ To update, run the command again with `--force` and redeploy.
74
75
  | Parameter | Effect |
75
76
  |---|---|
76
77
  | `src=<url>` | The package, required. Encode `&`, `#`, `+`, `%` and spaces |
77
- | `libraries=pack`, `<url>` or `none` | Where libraries come from; several are tried in order. `pack` is this domain's copy, or jsDelivr's without one: a package gets the libraries it lacks from it, and those it carries at the pack's newer versions. `hub` means `pack`; `none` turns off `--default-libraries` |
78
+ | `libraries=pack`, `<url>` or `none` | Where libraries come from; several are tried in order. `pack` is this domain's copy, or jsDelivr's without one: a package gets the libraries it lacks from it, and those it carries at the pack's newer versions. `none` turns off `--default-libraries` |
78
79
  | `refresh-libraries=off` | Play the libraries a package carries as exported; `pack` then only fills gaps |
79
80
  | `frame`, `copyright`, `export`, `icon`, `reporting` | H5P's action bar and its buttons |
80
81
  | `fullscreen=off` | No fullscreen button |
package/lib/build.mjs CHANGED
@@ -57,7 +57,7 @@ const PACK_CDN_ORIGIN = 'https://cdn.jsdelivr.net'
57
57
 
58
58
  /**
59
59
  * A `libraries` value for addresses that name none, checked against the site it goes into: the
60
- * tokens the page understands (`pack`, `hub`, `none`, https URLs), and with a host list, nothing
60
+ * tokens the page understands (`pack`, `none`, https URLs), and with a host list, nothing
61
61
  * the page would then refuse on every load. Returns the value normalised to single spaces.
62
62
  *
63
63
  * @param {string | null | undefined} value
@@ -74,19 +74,19 @@ export function parseDefaultLibraries(value, { packages = null, libraries = true
74
74
  return null
75
75
  }
76
76
  // An exact match on a parsed origin, not a substring of a URL. Without its own copy, `pack` is
77
- // the copy on jsDelivr that the element names; `hub` has meant `pack` since player 0.6.
77
+ // the copy on jsDelivr that the element names.
78
78
  const cdnAllowed = !packages || packages.some((origin) => origin === PACK_CDN_ORIGIN)
79
79
  for (const token of tokens) {
80
- if (token === 'pack' || token === 'hub') {
80
+ if (token === 'pack') {
81
81
  if (!libraries && !cdnAllowed) {
82
- throw new EmbedError(`--default-libraries names ${token}, but the site has no pack (--no-libraries) and --packages does not list ${PACK_CDN_ORIGIN}.`)
82
+ throw new EmbedError(`--default-libraries names pack, but the site has no pack (--no-libraries) and --packages does not list ${PACK_CDN_ORIGIN}.`)
83
83
  }
84
84
  } else {
85
85
  let url
86
86
  try {
87
87
  url = new URL(token)
88
88
  } catch {
89
- throw new EmbedError(`--default-libraries: not pack, hub, none or a URL: ${token}`)
89
+ throw new EmbedError(`--default-libraries: not pack, none or a URL: ${token}`)
90
90
  }
91
91
  if (url.protocol !== 'https:' && !['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) {
92
92
  throw new EmbedError(`--default-libraries: not an https URL: ${token}`)
@@ -137,6 +137,13 @@ export function contentSecurityPolicy({ packages = null, ancestors = null, meta
137
137
  /** Header rules, one set for every host format: the policy everywhere, and the caching that matters. */
138
138
  function headerRules(csp) {
139
139
  const revalidate = 'public, max-age=3600, stale-while-revalidate=86400'
140
+ // Asked again on every load, a 304 when nothing changed. The runtime's files keep their names
141
+ // from one version to the next, and the worker's version decides which it needs: kept for an
142
+ // hour, the runtime of the version before ran under the new worker after an update, and every
143
+ // play failed until the hour was out (0.10 to 1.0, measured, #49). The pack the same way, for
144
+ // whatever reads it with the browser's defaults: the element itself asks for its index
145
+ // revalidated and for its parts past the HTTP cache, so for it the header changes nothing.
146
+ const current = 'no-cache'
140
147
  return [
141
148
  {
142
149
  path: '/*',
@@ -148,9 +155,9 @@ function headerRules(csp) {
148
155
  },
149
156
  // The worker is checked on every load, so an update reaches learners on their next visit.
150
157
  { path: '/h5p-sw.js', headers: { 'Cache-Control': 'no-cache' } },
151
- { path: '/frame-assets/*', headers: { 'Cache-Control': revalidate } },
158
+ { path: '/frame-assets/*', headers: { 'Cache-Control': current } },
152
159
  { path: '/resizer.js', headers: { 'Cache-Control': revalidate } },
153
- { path: '/libraries/*', headers: { 'Cache-Control': revalidate } }
160
+ { path: '/libraries/*', headers: { 'Cache-Control': current } }
154
161
  ]
155
162
  }
156
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@missing-elements/h5p-embed",
3
- "version": "0.8.1",
3
+ "version": "1.0.1",
4
4
  "description": "Self-hosted H5P embeds: writes the H5P embed page as a static site for a player domain of your own, then any site frames it with an iframe and one script line. No H5P server, no third-party service; optional allowlists for package hosts and embedding sites.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,9 +43,9 @@
43
43
  "cli"
44
44
  ],
45
45
  "dependencies": {
46
- "@missing-elements/h5p-libraries": "^0.3.0",
47
- "@missing-elements/h5p-runtime": "^0.2.5",
48
- "@missing-elements/h5p-offline-player": "^0.10.0"
46
+ "@missing-elements/h5p-libraries": "^1.0.0",
47
+ "@missing-elements/h5p-offline-player": "^1.0.1",
48
+ "@missing-elements/h5p-runtime": "^1.0.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^26.6.5",
package/site/embed.js CHANGED
@@ -244,12 +244,10 @@ export function startEmbed({ packBase = null, pack = null, librariesPack = null,
244
244
  const sources = []
245
245
  if (value === 'none') return { value: '' }
246
246
  for (const token of value.split(/\s+/).filter(Boolean)) {
247
- if (token === 'pack' || token === 'hub') {
247
+ if (token === 'pack') {
248
248
  // This site's copy of the pack, which the element was pointed at above; without one, the
249
249
  // element's own `pack`, the copy on jsDelivr, where that may be reached, so a snippet
250
- // written for `pack` keeps playing after a rebuild with --no-libraries. `hub` has meant
251
- // `pack` since player 0.6: the one H5P hub host that answers a browser serves a
252
- // catalogue older than current exports need.
250
+ // written for `pack` keeps playing after a rebuild with --no-libraries.
253
251
  if (ownPack || (!librariesPack && permitted(PACK_CDN_ORIGIN))) sources.push('pack')
254
252
  else if (librariesPack) sources.push(librariesPack)
255
253
  else return { error: 'This player was set up without the library pack, so libraries=pack is not available here.' }
package/site/index.html CHANGED
@@ -16,7 +16,7 @@
16
16
  <span class="spinner" aria-hidden="true"></span>
17
17
  <span class="loader-text">Loading…</span>
18
18
  </div>
19
- <h5p-player auto-resize></h5p-player>
19
+ <h5p-player></h5p-player>
20
20
  <p class="notice" id="notice" hidden></p>
21
21
  </body>
22
22
  </html>