@missing-elements/h5p-embed 1.2.0 → 1.3.0
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 +1 -0
- package/package.json +2 -2
- package/site/embed.js +20 -11
- package/types/site/embed.d.ts +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ To update, run the command again with `--force` and redeploy.
|
|
|
83
83
|
| `src=<url>` | The package, required: an `http` or `https` URL, or a path on the player domain. Encode `&`, `#`, `+`, `%` and spaces |
|
|
84
84
|
| `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` |
|
|
85
85
|
| `refresh-libraries=off` | Play the libraries a package carries as exported; `pack` then only fills gaps |
|
|
86
|
+
| `downgrade-libraries=off` | Refuse content made for a newer version of a library than any source has, instead of playing it at the newest older one |
|
|
86
87
|
| `frame`, `copyright`, `export`, `icon`, `reporting` | H5P's action bar and its buttons |
|
|
87
88
|
| `fullscreen=off` | No fullscreen button |
|
|
88
89
|
| `preload=auto` | Start fetching media at once |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@missing-elements/h5p-embed",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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; or wraps one .h5p as a SCORM 1.2 package an LMS plays and grades. No H5P server, no third-party service; optional allowlists for package hosts and embedding sites.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@zip.js/zip.js": "^2.24.0",
|
|
62
62
|
"@missing-elements/h5p-libraries": "^1.0.0",
|
|
63
|
-
"@missing-elements/h5p-offline-player": "^1.
|
|
63
|
+
"@missing-elements/h5p-offline-player": "^1.2.0",
|
|
64
64
|
"@missing-elements/h5p-runtime": "^1.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
package/site/embed.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `h5p-embed` was told when it wrote the site, and the demo's `/embed` with the demo's copy of the
|
|
6
6
|
* library pack.
|
|
7
7
|
*
|
|
8
|
-
* ?src=<package url>[&libraries=pack|<url> …|none][&refresh-libraries=off][&preload=auto]
|
|
8
|
+
* ?src=<package url>[&libraries=pack|<url> …|none][&refresh-libraries=off][&downgrade-libraries=off][&preload=auto]
|
|
9
9
|
* [&xapi=<parent origin>][&frame][©right][&export][&icon][&reporting][&fullscreen=off]
|
|
10
10
|
* [&activity-id=<IRI>][&custom-css=<stylesheet url>][&lang=<language tag>]
|
|
11
11
|
*
|
|
@@ -141,20 +141,23 @@ export function startEmbed({ packBase = null, pack = null, librariesPack = null,
|
|
|
141
141
|
* What the player learnt about the package, for the embedding page to show: whether the host
|
|
142
142
|
* streamed it or made the browser download it whole (`source.type`), how big it is, what it
|
|
143
143
|
* says it is (`metadata`), where libraries it did not carry came from (`libraryBundle`, `null`
|
|
144
|
-
* when it carried its own),
|
|
144
|
+
* when it carried its own), which played at an older version than the content names
|
|
145
|
+
* (`downgradedLibraries`, empty when none did), and how long it took here. Posted once, when the
|
|
146
|
+
* content is up:
|
|
145
147
|
*
|
|
146
|
-
* { context: 'h5p-offline-player', action: 'report', source, metadata, libraryBundle,
|
|
148
|
+
* { context: 'h5p-offline-player', action: 'report', source, metadata, libraryBundle,
|
|
149
|
+
* downgradedLibraries, elapsedMs }
|
|
147
150
|
*
|
|
148
151
|
* and to any parent, like the heights: the parent named the package, and the manifest's strings
|
|
149
152
|
* are the package's own to tell. A parent treats them as text. A load that fails before the
|
|
150
153
|
* content is up posts `{ context: 'h5p-offline-player', action: 'error', code, message }`
|
|
151
154
|
* instead, a refusal by this page included (`code: 'refused'`). The shapes are an interface:
|
|
152
|
-
* a site that checks packages builds its preview from them, so
|
|
155
|
+
* a site that checks packages builds its preview from them, so a field is only ever added.
|
|
153
156
|
*/
|
|
154
157
|
let startedAt = 0
|
|
155
158
|
|
|
156
159
|
player.addEventListener('ready', (event) => {
|
|
157
|
-
const { source, metadata, libraryBundle } = /** @type {CustomEvent<ReadyDetail>} */ (event).detail
|
|
160
|
+
const { source, metadata, libraryBundle, downgradedLibraries } = /** @type {CustomEvent<ReadyDetail>} */ (event).detail
|
|
158
161
|
post({
|
|
159
162
|
context: 'h5p-offline-player',
|
|
160
163
|
action: 'report',
|
|
@@ -167,6 +170,8 @@ export function startEmbed({ packBase = null, pack = null, librariesPack = null,
|
|
|
167
170
|
mainLibrary: metadata.mainLibrary
|
|
168
171
|
},
|
|
169
172
|
libraryBundle,
|
|
173
|
+
// Absent from an element older than the page's own; this page and the element ship together.
|
|
174
|
+
downgradedLibraries: downgradedLibraries ?? [],
|
|
170
175
|
elapsedMs: Math.round(performance.now() - startedAt)
|
|
171
176
|
})
|
|
172
177
|
})
|
|
@@ -311,12 +316,13 @@ export function startEmbed({ packBase = null, pack = null, librariesPack = null,
|
|
|
311
316
|
* The element's display options, by their attribute names, for the embedding page to ask for:
|
|
312
317
|
* `&frame©right&export` shows H5P's action bar with those buttons, `&fullscreen=off` takes
|
|
313
318
|
* that one away, `&refresh-libraries=off` plays a package's own libraries even where the pack
|
|
314
|
-
* has newer ones, `&
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
319
|
+
* has newer ones, `&downgrade-libraries=off` refuses content made for a newer version of a
|
|
320
|
+
* library than any source has, `&activity-id=` names the statements' object and `&custom-css=`
|
|
321
|
+
* restyles the content to the embedding site's taste. `&lang=` is the embedding page's
|
|
322
|
+
* language, which this page cannot read across origins: H5P's own buttons and dialogs follow it
|
|
323
|
+
* for a package that does not name its own language, and follow the content's where it does.
|
|
324
|
+
* Not `custom-js`, `embed-code` or `user`: a script is a capability on this origin that a link
|
|
325
|
+
* should not hand out, the embed is the embed, and a learner's name has no place in a URL.
|
|
320
326
|
*/
|
|
321
327
|
const applyOptions = () => {
|
|
322
328
|
for (const name of ['frame', 'copyright', 'export', 'icon', 'reporting']) {
|
|
@@ -326,6 +332,9 @@ export function startEmbed({ packBase = null, pack = null, librariesPack = null,
|
|
|
326
332
|
// The pack's newer versions of the libraries a package carries, unless the embedding page
|
|
327
333
|
// needs the package exactly as exported.
|
|
328
334
|
if (params.get('refresh-libraries') === 'off') player.setAttribute('refresh-libraries', 'off')
|
|
335
|
+
// Content made for a newer version than any source has plays at the older one, unless the
|
|
336
|
+
// embedding page would rather have it refused.
|
|
337
|
+
if (params.get('downgrade-libraries') === 'off') player.setAttribute('downgrade-libraries', 'off')
|
|
329
338
|
for (const name of ['activity-id', 'custom-css']) {
|
|
330
339
|
const value = params.get(name)?.trim()
|
|
331
340
|
if (value) player.setAttribute(name, value)
|
package/types/site/embed.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `h5p-embed` was told when it wrote the site, and the demo's `/embed` with the demo's copy of the
|
|
6
6
|
* library pack.
|
|
7
7
|
*
|
|
8
|
-
* ?src=<package url>[&libraries=pack|<url> …|none][&refresh-libraries=off][&preload=auto]
|
|
8
|
+
* ?src=<package url>[&libraries=pack|<url> …|none][&refresh-libraries=off][&downgrade-libraries=off][&preload=auto]
|
|
9
9
|
* [&xapi=<parent origin>][&frame][©right][&export][&icon][&reporting][&fullscreen=off]
|
|
10
10
|
* [&activity-id=<IRI>][&custom-css=<stylesheet url>][&lang=<language tag>]
|
|
11
11
|
*
|