Repository navigation
fix(runtime): the content's id is the same on every load of a package - #131
Merged
Merged
Conversation
The boot script gave the content a random id on every load, as h5p-standalone did. Interactive Book keeps its chapter under that id, in its saved state and in the page's address, and takes it back only when the id matches, so a book always reopened on its first chapter, in any resume mode and in the SCORM zip. A site gives each content its row's number, the same every time; the id is now a number made from the package's id, twelve of its hex digits, which a double holds exactly through jQuery's .data(). Cornell Notes, which reads the copy of its notes it keeps by the id only for a number, finds it again too. Closes #127 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the stable content ID change intended to support saved chapter restoration.
No open issues 🎉
What changed in this PR
Fixes #127 by giving each package a stable numeric content ID, allowing Interactive Book to restore its saved chapter across loads, including in SCORM packages.
Changes:
- Derives the content ID from the first twelve hexadecimal digits of the package ID instead of generating it randomly.
- Adds browser coverage for numeric IDs, stability across reloads, and distinct IDs for different packages.
- Updates resume documentation and design notes to describe chapter restoration and shared IDs.
| File | Description |
|---|---|
packages/runtime/src/frame-boot.ts |
Derives a stable numeric content ID from the package ID. |
packages/player/tests/browser/resume.test.ts |
Tests ID stability, numeric values, and integration keys. |
docs/resume.md |
Includes chapters among the positions content can save. |
AGENTS.md |
Documents the ID invariant, its consequences, and the chapter-resume fix. |
Review effort: Balanced
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 #127.
Interactive Book reopened on its first chapter after every leave, in every
resumemode and in the SCORM zip, while its answers came back. It keeps its chapter under the content's id, in its saved state and in the page's address (urlFragments,h5pbookid), and takes it back only when the id matches. The boot script gave the content a random id on every load, as h5p-standalone did, so it never matched.The change
contentIdOfin the runtime's boot script: the content's id is now a number made from the package's id, the first twelve of its hex digits. Nothing changes in the player or the worker: the boot configuration has always carried the package id.localStorageunder the id and reads it back only whentypeof id === 'number'; Course Presentation accepts a string or a number. No other library in the pack tests or parses the id..data(), which turns a string of digits into a number, and a double holds twelve hex digits exactly; the full 32 would not.One consequence: two players of one book on one page share the address's chapter and turn pages together, as two copies of one content do on an H5P site.
Checked
resume.test.ts: the id is the package id's number on two loads of one package, the core'scid-key names it, and another package gets another. It fails on the old boot script, which gavexga807z.resume="device", on a site written from this branch: read to chapter 5, then a reload with the book's hash in the address, and a fresh address with only the saved state. Both reopened on chapter 5; before, chapter 1.entrywasresumeand the book showed chapter 12 of 12; before, chapter 1.Release
A runtime patch, 1.0.1: the player's peer range already takes it. Embed should require it in its next release, so every SCORM zip it writes carries the fix.
🤖 Generated with Claude Code