Repository navigation
feat(h5p-author): export the library loader and the text checks, on the player's library rules - #110
Merged
Merged
Conversation
…he player's library rules (#106) The player exports its library rules at ./plan: planPack, librariesNamedIn, addonPatterns, textMatches and dependenciesIn, the last four moved out of package-reader.ts into a module without zip.js, built to dist/h5p-plan.js. h5p-author plans the parts a package carries with planPack in place of its own closure, keeping the order it has always listed them in, and exports openPack, loadLibraries and the text checks for a tool beside the build. Every type file's example builds with the libraries, order, folders and notes it had before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… player pin, the library order held by a test, three small fixes - check-pack-published.mjs refuses to publish until the pinned player version is on npm and exports ./plan: 1.2.0 is there without it, and the author would install and fail on its first import - build.test.ts holds a build's h5p.json to the depth-first order, derived from the zip's own library.json files; it fails on the plan's breadth-first order - Pack.close() closes each part on its own, so one that fails to close leaves no other open - the addon note lists addons alone, not what an addon would need in turn - loadLibraries finds the main library by folder, not identity, for a LibrarySource that builds its records on each call - the README and author.mjs say what is exported, and LibraryRecord and TranslationReport are exported as types Co-Authored-By: Claude Fable 5.1 <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 #106.
What
h5p-author exports what a tool beside the build needs (embed-my/creator's
outlineandapply), and stops keeping its own versions of the player's library rules.The player exports its library rules at a new subpath,
./plan, built todist/h5p-plan.js(7.7 kB, not minified):planPack, pluslibrariesNamedIn,addonPatterns,textMatchesanddependenciesIn. The last four moved out ofsw/package-reader.ts, which loads zip.js, intosrc/shared/content-libraries.ts. The Service Worker imports them from there, and the build fails if zip.js ever gets intoh5p-plan.js.build:planbuilds that file on its own.prepare:devand h5p-author's tests run it, since h5p-author imports it as it runs../planis not named in docs/compatibility.md, which now says so, so h5p-author depends on the player's exact version (workspace:*).h5p-author exports:
openPack(libraries?), the packbuildPackageopens.loadLibraries(pack, { type, language, params }), now inlib/libraries.mjs, which has no Node import of its own. It loads, as the build does:patchSemantics;buildPackagecalls it. It takes any object withlibraries,newest,openandtranslation, so h5p-author: a check of saved content, which the build also runs on what it writes #107 can pass one built on a package's own folders.markupText,plainTextandallowedTags.Pack.opennow returns{ folder, library, semantics, index, translations }, withtranslationsas names. The part's file and zip.js's reader stay inside the pack, so no zip.js type is in the published declarations, and the build reaches them through an@internalarchiveOf.SourceErrormoved tolib/source-error.mjs, andbuild.mjsre-exports it.Reuse
buildPackagenow plans the parts a package carries with the player'splanPack, for a package that carries nothing yet, in place of its own closure. Addons go through the player's patterns, so a package carries what the player would take from the pack for it.Two things stay in h5p-author:
h5p.jsonand the zip's folders follow.On the plan's own order, breadth first, all five sources I first tried listed their libraries differently. The runtime keeps the listed order between libraries that don't depend on each other, and that order decides whose stylesheet comes later.
The old closure also followed
dynamicDependencies. No library in the pack has any (checked today).Not reused: the runtime's library-name parser, content check and content upgrade. They are GPL-3.0-only, and h5p-author is MIT.
embed's SCORM writer still carries copies of these functions: embed: plan the SCORM zip's parts with the player's own functions, not copies #109.
Checks
main: all 32 type files' examples (28 content types and the four parts types), media included, built with this branch and withmain. Each came out with the same libraries, in the same order, the same folders and the same notes.pnpm typecheckpasses, every package. That includes the player's consumer check, which now imports./planundernodenext, and h5p-author'spackage-types.ts, which imports the new exports and expectspart.fileandarchiveOfto be errors.pack.test.tsandlibraries.test.tspass (39), and the full build passes.libraries.test.ts, which covers:SourceError.sweep-content.test.tspasses (5).The full browser suite in all three engines is left to CI.
Release
Publish the player before h5p-author: the author pins the player's exact version, and needs a version that has
./plan.Next
After review
A self-review of the branch found the following, fixed in the second commit:
prepublishOnlyguards the player pin as it guards the pack's:check-pack-published.mjsrefuses to publish until the pinned player version is on npm and exports./plan. Today it refuses, correctly: 1.2.0 is on npm without./plan.build.test.tsholds a build'sh5p.jsonto the depth-first order, derived from the zip's ownlibrary.jsonfiles, and checks that True/False's dependencies come before the text beside it. Run against the plan's breadth-first order, the test fails.Pack.close()closes each part on its own again, so one that fails to close leaves no other open.loadLibrariesfinds the main library by folder rather than identity, for aLibrarySourcethat builds its records on each call.LibraryRecordandTranslationReportare exported as types.🤖 Generated with Claude Code