feat(author): export sourceType, so the build page hands over the type the build took
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 holdssourceTypeto whatsourceOftakes the type to be in every case it reads one. Three mutations (nocontentTypeorlibrary, those read beside atypethat names nothing, no quiz exception) each fail it. The typecheck passes, and the declaration issourceType(source: unknown, names: Iterable<string>): string | null.- On the 328 sources the weak-model tests stored, it names what
sourceOfdoes 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
typenames (exact or loose); with notype, the name undercontentTypeorlibrary;nullwhere none can be meant and for a quiz in the published format. - A test covers each shape and holds
sourceTypeto whatsourceOfreads on all 328 stored sources; the suite passes 179 tests. - Requires a minor release of
h5p-author(0.8.0) for the new export.