Repository navigation
Settle a finished block to a plain render, and stop bundling tippy's stylesheet - #2
Merged
Merged
Conversation
A streamed block wore the animated shape for its whole life, and the closed render then replaced it with markup that carried no animation at all. For the words that was invisible — they had finished fading — but the swap itself was not. The code gutter was rebuilt from scratch, every entry restarting its fade, and a table's last row jumped from partial opacity to full in a single frame. Every block kind now makes that swap once, after the fade it started has run, one pass per closed block: - `MarkdownCode` books the pass on a timer instead of swapping children during render, and the guard is a flag rather than the children, so a settle that produced nothing to adopt cannot re-arm it; - the pass is skipped when the animation is off, where the closed shape is already the plain one, and `reset()` cancels one that is still booked; - line numbers take the code cache's tally in both phases — the settled tree holds the same lines — and remember the last tally, so a caller that withdraws it can no longer collapse the gutter and remount every entry; - tables and markup get the same pass from the renderer, rebuilt from a cache of its own so a later block cannot race it; - a finished block carries no `data-animate-word`, `data-animate-key` or `data-animate-marker`: its frame is byte-identical to the same document streamed with the animation off, and blocks already settled are never re-passed when new ones stream. Coverage stays at 100%, including the guards these passes added.
tippy.js became an optional peer so that a consumer which never renders a
toolbar would not pay for it, but the stylesheet still inlined tippy's base
CSS: every consumer shipped it, and the build in turn needed the package
installed, which nothing did — so `npm run build` could not pass from a clean
`npm ci`.
The main stylesheet now carries only the toolbar skin and no longer imports
from `node_modules`. A host that renders toolbars imports tippy's own sheet
beside the one it already imports for KaTeX:
import "tippy.js/dist/tippy.css";
Documented in `styling.md` and the README, and applied to the site demo, the
playground and the example page. The built stylesheet drops by the 1.4 kB
tippy sheet, and the build assertion still guards the skin. tippy.js stays a
peer and a devDependency, exactly as KaTeX does: `tsc` needs its types and
the tooltip loader test needs the runtime.
Also comments out `will-change: opacity` on the word and marker fades, which
promoted a compositor layer per word for no measured gain.
Coverage Report for Unit
File CoverageNo changed files found. |
Coverage Report for All
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Fixed
A finished block now settles to a plain render once, after the fade it started has run. A streamed block wore the animated shape for its whole life, and the closed render then replaced it with markup carrying no animation at all. The words had finished fading, so they did not move — but everything else did: the code gutter was rebuilt from scratch with every line number restarting its fade, and a table's last row jumped from partial opacity to full in a single frame.
Each block kind now books one settled pass, a second after it closes, which is when its fade has finished and the swap is therefore invisible:
MarkdownCodeschedules the pass instead of swapping children insiderender(), and a flag — not the children — decides whether it has been applied, so a settle that produced nothing to adopt cannot re-arm it;reset()cancels one that is still booked;data-animate-word,data-animate-keyordata-animate-marker, and its frame is byte-identical to the same document streamed withanimation: false. Blocks already settled are never re-passed when new ones stream.Toolbar tooltip CSS is no longer bundled.
tippy.jsbecame an optional peer so a consumer that never renders a toolbar would not pay for it, but the stylesheet still inlined tippy's base CSS — so every consumer shipped it — and the build then needed the package installed, which nothing did, which meantnpm run buildcould not pass from a cleannpm ci.The main stylesheet now carries only the toolbar skin and no longer imports from
node_modules. A host that renders toolbars imports tippy's own sheet beside the one it already imports for KaTeX:Documented in
styling.mdand the README, and applied to the site demo, the playground and the example page. The builtdist/hypermarkdown.cssdrops by the 1.4 kB tippy sheet (46 478 → 45 064 bytes), and the assertion inbuild-css.mjsstill guards the skin.tippy.jsstays a peer and a devDependency, exactly as KaTeX does:tscneeds its types and the tooltip loader test needs the runtime.The word and marker fades also drop
will-change: opacity, which promoted a compositor layer per word for no measured gain.Verification
npm run lint,npm run typecheck(React 18 and 19),npm run test:coverage,npm run test:coverage:unitandnpm run buildall pass; coverage is 100% statements, branches, functions and lines, and the new guards are covered.npm pack --dry-run: 72 files, 355 kB.Compatibility
No API change. A host that renders block toolbars needs one extra stylesheet import; without it the toolbars still work and the tips simply lose their positioning and sizing. Patch release.