Repository navigation
feat: h5p-verify --preview, a package in the real player in your browser - #70
Merged
Merged
Conversation
The check says whether a package starts. Whether it is right, a person judges by playing it, the same way for every content type. - --preview checks nothing. It serves the package and a page of its own from the verifier's server, with the same player, runtime and library sources as the check, and opens the default browser on it. --no-open prints the address instead. - The package is served with Range, as a static host serves it, so the element reads it range-http: the libraries in a few requests, media by the ranges asked for. With a 32 MB stored video added beside the demo's clip, 1.58 MB of 36.1 MB reached ready, and one range of that video cost a kilobyte. - It ends ten seconds after its last tab closes, or ten minutes after starting if no tab opens. It takes port 4645 when that is free, so every preview shares one origin's worker and caches. - The check shares the server: it now takes the caller's routes and a port, and a folder given as the package is refused by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e natively - The preview page resolves its src and sets it only when it is http or https, as CodeQL's js/xss-through-dom suggested. - The server test compared the 1.5 MB archive with toEqual, which walks it a byte at a time: 2.6 s locally and past the 5 s timeout on CI. Buffer.equals takes it to 36 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
Closed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file's beforeAll launched Chrome under Vitest's ten-second hook timeout. On CI, beside verify.test.ts's browsers, it took longer, and all six tests were skipped. The browser now starts in the browser test, under its own timeout (120 s, as verify.test.ts gives its browser tests), so the other five do not wait on it. The options test, three node start-ups in a row, gets the 30 s the other command test has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alekswebnet
added a commit
that referenced
this pull request
Oct 23, 2026
…eside the author skill Two conflicts, both kept whole: AGENTS.md's layout of packages/verify/tests names preview.test.ts and author.test.mjs, and docs/verify.md has the preview paragraph followed by the author skill's. The verifier's tests pass on the merged tree, 28 of 28, author.test.mjs and preview.test.ts among them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #69.
The check says whether a package starts. Whether it is right, a person judges by playing it, the same way for every content type.
h5p-verify <package.h5p> --previewchecks nothing. It opens the package in the real player in the person's own browser, served from their computer:Changes
The preview (
lib/preview.mjs,lib/preview.html)Same player as the check. It serves the package and a page of its own from the verifier's server, with the same player, runtime and library sources.
--untrusted,--librariesand--no-refresh-librariesmean what they mean for the check.Served with
Range, as a static host serves it, rather than handed over as a picked file, which a page cannot get without a click:206withContent-Range,200whole,416past the end;ETagfrom the file's size and time, so a package written again at the same path is a new package to the element;The element reads it
range-http: the libraries in the warm's few requests, media by the ranges the player asks for.The page shows the file name, and a status line with the element's error if the package does not open. It sets the element as the check does.
It ends by itself. The page holds an event stream open. The preview ends ten seconds after the last stream closes, which a reload reconnects within, or ten minutes after starting if no tab ever opened. Once its server has gone, the page says so and stops reconnecting, so a stale tab cannot keep a later preview alive.
Port 4645 when free. Every preview then shares one origin's Service Worker and caches, instead of leaving a new origin's behind for each run. If another preview or another program holds the port, it takes any free one.
The browser opener is
open,cmd /c startorxdg-open. The address is printed either way.The command (
bin/h5p-verify.mjs)--preview, and--no-opento print the address instead of opening a browser.--out,--browser,--ready,--settle,--json,-q) are refused with--preview, not ignored, and so is--no-openwithout it.Shared with the check (
lib/verify.mjs)serve()takes the caller's routes and a port to try first, closes open connections when it stops, and answers a path that does not decode with a400rather than crashing.packageFile()now refuses a folder given as the package by name, for the check too.serve,packageFile,librarySources,playerDistandlaunchare exported as@internal. The published declarations are unchanged:verifyPackage,summarize,VerifyErrorand the report's types.Docs: a Preview section and two option rows in the package README, a paragraph in
docs/verify.md, the preview's exit codes indocs/compatibility.md, and AGENTS.md's layout and verifier sections.Testing
tests/preview.test.ts, 6 tests:byteRangeagainst 14 headers;--no-openand Ctrl+C;The browser test adds a 32 MB stored video, which nothing plays, beside the demo's clip. It then checks four things:
range-http;206through the player;Results:
pnpm --filter @missing-elements/h5p-verify typecheckpasses, withcheckJsover the new module.Measured in Chrome, on the 36.1 MB package from the test:
ready;Range.In each engine: the demo's video package was previewed in installed Chrome and in Playwright's Firefox and WebKit.
range-httprange-httprange-httpPort fallback: two previews at once took 4645 and a free port, and both played.
Not verified
--no-open, soopen,xdg-openandcmd /c startwere not run.Range, but its time to first frame through the preview was not measured.Release
A minor of
h5p-verify:--previewand--no-openare added, anddocs/compatibility.mdgains the preview's exit codes.After that release is on npm,
skills/h5p-verify(andskills/h5p-author, once #68 is merged) should tell the agent to open the preview after the check. That change is left out of this PR so that no skill names an option npm does not have yet.🤖 Generated with Claude Code