Repository navigation
Send the first program once the block's editor has its text - #32
Merged
Merged
Conversation
In a fragment, LiaScript creates the editor and the iframe together and fills the editor a few milliseconds later; a cached embed's "ready" came first, so a visualization started empty. While all of the block's editors are empty, the first program now waits for Ace's change event (at most 2 s); anything sent meanwhile replaces it. check:ready (CI) covers it on a test page with a stand-in editor; check:player (not in CI) with the real LiaScript player. Co-Authored-By: Claude Opus 5.5 <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.
A visualization in a LiaScript fragment sometimes started empty: «Keine Schritte aufgezeichnet», with no step buttons. It happened in presentation mode, once the embed was in the browser cache.
Cause. A race in the macro, not in the embed:
loading="lazy", so nothing runs while the fragment is hidden.lia-editorwaits for its Ace editor before it takes the text.readywithin 1–20 ms of being created. The macro then read the editor at once and sent an empty program.One failing visit (ms, course page clock):
ready, program read: 0 charactersFix. On
ready, while all of the block's editors are still empty, the first program waits for their text, then goes out at once. It's the same path forloadandvisualize.changeevent, viaelement.env.editor. LiaScript blocks its owneditorUpdatewhile it sets the text itself. For an editor that isn't connected yet,attach()checks again on each DOM change.ready. A program sent meanwhile carries the block as it is then, and the first one is dropped.Checks.
npm run check:ready(new, in CI): runs the macro's@onloadcode on a test page, with a stand-inlia-editorthat gets its text only afterreadyand a stub embed. Everything is served through Playwright routes, with no external sites. Cases:ready: sent when it arrives;On
main's macro, 4 of the 6 cases fail.npm run check:player [visits](new, not in CI): the real LiaScript player and the live embed, withscripts/player/course.md(a visualization inside{{1}}), visited several times. Run it before macro releases.main's macro: 2 of 4 visits empty.check-macropasses.The repo gets a
package.jsonwithplaywright-core(devDependency) for both scripts, and CI runsnpm ci.Going live. Merging reaches courses at once; then a patch version bump per course. Public behaviour:
loadas well. The result is the same.Manual test. In presentation mode, open slide 5 of a course with a visualization in a fragment on slide 6. Go to 6, show the fragment, go back to 5 and repeat. The program shows every time, also in a warm tab.
🤖 Generated with Claude Code