Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion design/author.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ to 3,000. Twenty-four things the code does not say by itself:
that embed-my.github.io (embed-my/embed-my.github.io#14), whose `/bundles/` stays until the next
pack release for copies of the skill installed earlier. The build tool beside them is the
command line as one file, which the site's Vite bundles: 575 kB, and it builds from an unzipped
bundle with nothing installed.
bundle with nothing installed. Its `--version` read this package's `package.json` and the
pack's as files, neither of them beside it, and crashed (found by ChatGPT's plugin creator,
2026-11-13). Each version is now an import too, which the bundler writes into the file, about
9 kB; the files are read first where the packages are installed, since Node before 22.12 warns
on a JSON import, and a `package.json` above the one file that is not this package's is passed
over.
- **A preview inside Claude is the desktop app's browser panel, not a card** (2026-11-10). A
connector's card in Claude is an iframe under Claude's policy, measured that day in Claude
Desktop 4.23118.1 with a probe server: it fetches from the hosts the server declares, grows to
Expand Down
19 changes: 17 additions & 2 deletions packages/author/bin/h5p-author.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ npx @missing-elements/h5p-verify@latest before handing it over.`
/** A size in kilobytes below a megabyte, in megabytes above. @param {number} bytes */
const sized = (bytes) => (bytes < 1_000_000 ? `${Math.max(1, Math.round(bytes / 1000))} kB` : `${(bytes / 1_000_000).toFixed(1)} MB`)

/**
* This package's version, from its package.json where the package is installed. The command line
* as one file, which the organisation's site bundles, has no package.json of its own beside it, and
* the one above it may be another's: there it is the copy its bundler wrote in from the import.
* The file comes first, since Node before 22.12 warns on a JSON import.
*/
async function ownVersion() {
try {
const own = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
if (own.name === '@missing-elements/h5p-author') return String(own.version)
} catch {
// No package.json beside it: the command line as one file.
}
return (await import('../package.json', { with: { type: 'json' } })).default.version
}

/**
* The command line as the verifier's and embed's read theirs: `--libraries dir` or
* `--libraries=dir`, and `-h`, `-v`. Which flags a command takes is checked after.
Expand Down Expand Up @@ -57,8 +73,7 @@ try {
const { positional, flags } = parse(process.argv.slice(2))
const [command, ...rest] = positional
if (flags.version) {
const own = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')).version
console.log(`@missing-elements/h5p-author ${own}, library pack ${await packVersion()}`)
console.log(`@missing-elements/h5p-author ${await ownVersion()}, library pack ${await packVersion()}`)
} else if (flags.help || !command) {
console.log(USAGE)
if (!command && !flags.help) process.exitCode = 1
Expand Down
15 changes: 12 additions & 3 deletions packages/author/lib/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,19 @@ export async function openPack(folder) {
}, 'reinstall the pack')
}

/** The pinned pack's version, for messages and reports. */
/**
* The pinned pack's version, for messages and reports, from the libraries package's package.json
* where it is installed beside this one. The command line as one file, which the organisation's
* site bundles, has no package beside it: there it is the copy its bundler wrote in from the
* import. The file comes first, since Node before 22.12 warns on a JSON import.
*/
export async function packVersion() {
const url = import.meta.resolve('@missing-elements/h5p-libraries/package.json')
return JSON.parse(await readFile(fileURLToPath(url), 'utf8')).version
try {
const url = import.meta.resolve('@missing-elements/h5p-libraries/package.json')
return String(JSON.parse(await readFile(fileURLToPath(url), 'utf8')).version)
} catch {
return (await import('@missing-elements/h5p-libraries/package.json', { with: { type: 'json' } })).default.version
}
}

/**
Expand Down
Loading