Skip to content

feat(vscode): H5P Preview by Missing Elements, a VS Code extension that plays .h5p files - #84

Merged
alekswebnet merged 7 commits into
mainfrom
feat/vscode-extension
Oct 27, 2026
Merged

alekswebnet merged 7 commits into
mainfrom
feat/vscode-extension

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #83.

VS Code showed a .h5p as a binary file it could not open. Now it opens in a read-only editor that plays it in the real player: H5P Preview by Missing Elements (missing-elements.h5p-preview), a new workspace part at packages/vscode.

How it plays

A webview's own origin, vscode-webview://, cannot register a Service Worker, so the player cannot run in the webview's document. The editor's webview frames a page from a server on 127.0.0.1 instead, one per window, on port 4646 when it is free. Measured before building, in VS Code 1.143.1 (Electron 43) on macOS: the frame's worker controls it, the demo quiz is ready in 0.5 s, and the Interactive Video's H.264 clip decodes.

The server is the verifier's, bundled from this checkout. The extension carries the player, the runtime and the library pack's parts, so content-only exports play offline and nothing leaves the machine.

Changes

  • packages/verify: a refactor in its own commit, nothing changes for the command.
    • The package file, the library sources and the static server move from lib/verify.mjs to lib/serve.mjs. verify.mjs imports Playwright at its top, and the preview took its server from there, so starting a preview loaded a browser driver it never used.
    • previewPackage takes roots, and sendArchive is exported, both @internal.
    • VerifyError is still exported from the package's entry, and the generated declarations show only it.
  • packages/vscode:
    • src/ holds the editor provider, the window's server, the page the webview frames, and the webview: a bar with the package's title, content type and licence, an Untrusted switch and a Newest libraries switch.
    • Restricted Mode plays every package untrusted, with the switch disabled. Settings changes and granted trust replay the open previews.
    • The page posts to the webview's origin only. The webview takes the frame's messages by window and origin, and the extension's by its own origin, so a package's code cannot reload the preview or switch its trust.
    • Reload and Open in Browser sit in the title bar. Open in Browser runs the command's preview, also from the Explorer's menu.
    • A file written again plays again after 500 ms. A file from a remote or virtual workspace is copied to a temporary folder first.
    • scripts/build.mjs writes dist/extension.cjs (33 KB, Playwright refused by an esbuild plugin), assets/ and NOTICE.txt. scripts/package.mjs writes the .vsix: 13.8 MB in 141 files, no node_modules.
  • CI: a vscode job. It runs the suite in a downloaded VS Code under xvfb-run, caches the editor by week, and uploads the .vsix as an artifact.
  • pnpm-workspace.yaml: @vscode/vsce-sign may run its install script. It copies the platform's signing binary out of its optional dependency, and vsce publish signs with it.
  • AGENTS.md: the layout, the commands, and a section The VS Code extension with the decisions and measurements above, plus a line each under Licensing and Where this differs from the original design.

Testing

  • Unit: 11 of 11 in Node. The server runs against the built player, runtime and pack:

    • pages and settings, and a file name that tries to end the script block;
    • ranges, and 404s for wrong names and ids;
    • a package served until its last preview closes, and nothing outside the served folders.

    The webview's policy and nonces, and the page's messaging, have tests of their own.

  • In a real VS Code (1.143.1, test-electron): 7 of 7.

    • The quiz, the Interactive Video, and formulas.h5p (a content-only export, played from the pack).
    • Reload, untrusted by setting, and an open preview switching to untrusted live.
    • A file overwritten with another package, which plays the new one.
  • Against the packed .vsix: the same 7 of 7, with the unpacked .vsix as the extension, so the shipped files alone suffice.

  • The verifier: 24 of 24 in Chrome, and the skills' preview playback test 2 of 2. pnpm typecheck passes for every package.

  • The bar, by eye: rendered in Chromium with VS Code's theme variables, in dark, in light, and in a 420 px Restricted Mode pane, where the switches wrap together.

Not verified: Windows, Restricted Mode and Open in Browser in VS Code, remote and virtual workspaces, and the bar inside VS Code's own window (I could not capture it).

Release

Not on npm. To publish 0.1.0:

  1. Create the publisher missing-elements on the Marketplace and the namespace on Open VSX, if they don't exist.
  2. Take the .vsix from CI's artifact or from pnpm build && pnpm --filter h5p-preview package.
  3. Publish it to both:
    • npx @vscode/vsce publish --packagePath h5p-preview-0.1.0.vsix
    • npx ovsx publish h5p-preview-0.1.0.vsix -p <token>

Before publishing:

  • The icon is the app's: "H5P" in white on blue, close to H5P's own logo. The trademark policy that shaped the name may make you want a different one.
  • The Marketplace page has no screenshot yet. One from VS Code's own window would help it most.

The verifier needs no release: its refactor changes nothing for the command, and its next release carries it. The root README and the skills can mention the extension once it is listed.

🤖 Generated with Claude Code

alekswebnet and others added 2 commits October 26, 2026 22:24
…eview loads no Playwright

lib/verify.mjs imports Playwright at its top, and lib/preview.mjs took its server from there, so
starting a preview loaded the check's browser driver it never uses. The package file, the library
sources, the player's dist and the static server now live in lib/serve.mjs; verify.mjs and
preview.mjs both import them, and verify.mjs re-exports VerifyError, the one of them that is public.

For the VS Code extension (#83), which bundles the preview server: previewPackage takes `roots`, the
player's and the runtime's files where a host ships them itself, and sendArchive is exported, both
@internal. Nothing changes for the command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at plays .h5p files

A .h5p opens in a read-only custom editor that plays it in the real player. The editor is a webview
framing a page from a server on 127.0.0.1, one per window on port 4646 when free: a webview's own
origin cannot register a Service Worker, and a page it frames from a local server can. The server
is the verifier's, bundled; the extension carries the player, the runtime and the library pack's
parts, so content-only exports play offline and nothing leaves the machine.

- Restricted Mode plays every package untrusted; a trusted workspace plays by the settings, with
  an Untrusted and a Newest libraries switch in each editor.
- Reload and Open in Browser in the title bar; a file written again plays again.
- A file from a remote or virtual workspace is copied to this computer first.

Tests: the server and the HTML in Node, and a suite that runs in a real VS Code, also in CI under
xvfb-run, which uploads the .vsix. Not on npm: the owner publishes the .vsix.

Closes #83.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@socket-security

socket-security Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​vscode@​1.90.01001008092100
Added@​vscode/​test-electron@​3.1.09910010086100
Added@​vscode/​vsce@​4.0.09610010098100

View full report

Comment thread packages/vscode/tests/html.test.ts Fixed
alekswebnet and others added 2 commits October 26, 2026 22:27
CodeQL (js/bad-tag-filter): the test's pattern for the webview's script and style tags matched
lower case only, so an upper-case `<SCRIPT>` without the nonce would have passed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packages/vscode/tests/html.test.ts Fixed
- Updated the project's logo in `demo/favicon.svg` to a new design.
- Modified `AGENTS.md` to reflect changes in logo and icon dimensions.
- Enhanced icon generation scripts in `build-app-icons.mjs` and `build-og-image.mjs` to use the new logo.
- Added a new script `icon.mjs` for generating the extension's icon from the logo.
- Updated `package.json` to include the new icon generation script and added `playwright-core` as a dependency.
- Updated binary assets for various icons and screenshots to reflect the new logo design.
@alekswebnet
alekswebnet merged commit fb7bd12 into main Oct 27, 2026
8 checks passed
@alekswebnet
alekswebnet deleted the feat/vscode-extension branch October 30, 2026 23:03
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.

A VS Code extension that plays .h5p files: H5P Preview by Missing Elements

2 participants