Repository navigation
Conversation
…by file name A project file that does not exist is looked up by its bare file name in a host-supplied set of library images, the same rule as `typst compile --fallback-dir`. Project files always win, package files never fall back, and names the host hands in are accepted only as bare file names. Lookups that need bytes not supplied yet are reported through take_missing_library_images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IdeWorld::files now also yields, for each known library image name, the path it would resolve to from the completing file's directory — unless a project file already sits there, which wins and is already listed. Carried from the prior review: library_name gets direct unit coverage (bare names accepted, anything else rejected), and World::source notes that sources deliberately never fall back to the library, unlike the CLI's own fallback which serves both. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading a face lists every codepoint its cmap declares, and a single format 12 group can declare four billion. Count the declared codepoints from the raw table first and reject reversed or out-of-range groups and faces or files that declare too many. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table directory need not be sorted and may list cmap twice; the parser takes the last cmap record in a linear pass, so the coverage check now locates the table the same way instead of by binary search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
File ids come from a global interner that never frees one and holds at most 65,535. Listing files interned a path for every library name in every directory completions were asked about, so a long session with a large library ran out of ids and panicked. Compare virtual paths against the project's files instead, and leave sorting to the IDE, which sorts what it gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Supplying bytes for a name outside the set, or setting the same set of library images again, changes nothing the compiler sees, so it no longer marks the session for recompilation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The font parser walks all 256 keys of a format 2 subtable even when its sub-headers list nothing, but such a subtable counted as empty, so a face with thousands of encoding records pointing at one could take seconds to read. Count every key as at least one and every encoding record as at least one, so the count bounds the parser's work and not only its output. Each subtable is counted once and charged to every record that points at it, which keeps the check itself linear in the table's size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Superseded: this work continues outside this repository. |
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.
Summary
typst compile --fallback-dir(project files win, packages never fall back). JS API:IdeSession.setLibraryImages(names),addLibraryImage(name, bytes),takeMissingLibraryImages()(the host fetches what a compile needed and was not given).fontFaces(bytes). Reads every face of a font file with the compiler's own parser ({ index, family, style, weight, stretch, monospace, serif, math, variable }), so a host can record at upload time the familytext(font: ..)will match. Work is bounded against hostile files: forged collection headers, and cmap tables whose declared codepoints (all formats, every encoding record, located exactly as ttf-parser'scollect_tablesdoes) exceed a per-face and per-file budget are rejected before parsing.crates/typst-ide-wasmchanges (plus oneCargo.lockedge:ttf-parserbecomes a direct dependency at the version already in the tree). Nothing panics on host input.Test plan
cargo test -p typst-ide-wasm(48 tests: fallback rule, missing-name reporting and cache invalidation, completions incl. interner-exhaustion regression, font faces incl..ttc, forged headers, hostile cmaps, unsorted/duplicate table directories, format 2 amplification)cargo clippy -p typst-ide-wasm --all-targets -- -D warnings,cargo check -p typst-ide-wasm --target wasm32-unknown-unknown,cargo fmt --all -- --check🤖 Generated with Claude Code