Skip to content

feat(author): export sourceType, so the build page hands over the type the build took - #177

Merged
alekswebnet merged 3 commits into
mainfrom
feat/author-source-type
Nov 10, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/author-source-type

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #176.

The build page hands a chat, with a source's problems, the type file of the content type the source is written in. It found that type by a rule of its own, the source's type as written, so a type named loosely ("interactive-book") or under contentType got no file, though the build reads both since 0.7.1 (#175). The 12 of 12 measured in #175 with no skill text were with a page that hands the file back for such a type.

What changes

sourceType(source, names) is exported from ., ./core and ./browser: of the machine names given, the one the source's type names, as it is or loosely; where it has no type, the one name under contentType or library; null where none can be meant, and for a quiz in the published format, which has rules of its own.

It is made of the two functions sourceOf reads a type with (machineNameOf, namingKey), so the page asks the build it ships instead of keeping a copy of the rule. That is the only change: no build reads anything differently.

Tested

  • pnpm --filter @missing-elements/h5p-author test: 179 pass. A new test covers each shape, and holds sourceType to what sourceOf takes the type to be in every case it reads one. Three mutations (no contentType or library, those read beside a type that names nothing, no quiz exception) each fail it. The typecheck passes, and the declaration is sourceType(source: unknown, names: Iterable<string>): string | null.
  • On the 328 sources the weak-model tests stored, it names what sourceOf does in every one: 322 with a type, 6 without.

To release

h5p-author 0.8.0, a minor for the new export. Then the build page's pull request in missing-elements.github.io pins it and attaches the type file of sourceType(source, listed), with the files of what the source names below it.


Summary by cubic

Exports sourceType so the build page hands a chat the content type file the build itself would read.

The page previously found the type by its own rule—the source's type as written—so a loosely named type ("interactive-book") or one under contentType got no file, though the build reads both. sourceType(source, names) is now exported from ., ./core, and ./browser, built from the same functions sourceOf reads a type with, so the page asks the build it ships instead of keeping a copy of the rule.

  • Returns the machine name the source's type names (exact or loose); with no type, the name under contentType or library; null where none can be meant and for a quiz in the published format.
  • A test covers each shape and holds sourceType to what sourceOf reads on all 328 stored sources; the suite passes 179 tests.
  • Requires a minor release of h5p-author (0.8.0) for the new export.

Written for commit 7b3747d. Summary will update on new commits.

View guided diff Turn on auto-fix

… type (#176)

The build page hands a chat the type file of the content type a source is written in. It found
that type by a rule of its own, the source's `type` as written, so a type named loosely or under
`contentType` got no file, though the build reads both since 0.7.1. A copy of the build's rule in
the page would drift from the build it ships, so the build's reading is exported instead.

`sourceType(source, names)`, from `.`, `./core` and `./browser`: of the machine names given, the
one the source's `type` names, as it is or loosely; where it has no `type`, the one name under
`contentType` or `library`; null where none can be meant, and for a quiz in the published format,
which has rules of its own. It is made of the two functions `sourceOf` reads a type with.

On the 328 sources the weak-model tests stored, it names what `sourceOf` takes the type to be in
every one, 322 with a type and 6 without. A test holds it to `sourceOf` on every shape it reads.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/author/README.md Resolved
@alekswebnet
alekswebnet merged commit 82a5137 into main Nov 10, 2026
9 checks passed
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.

h5p-author: a page cannot ask which content type a source names, as the build reads it

1 participant