Skip to content

Request standard library from World once upfront - #8215

Merged
laurmaedje merged 1 commit into
mainfrom
prefetch-library
May 5, 2026
Merged

laurmaedje merged 1 commit into
mainfrom
prefetch-library

Conversation

@laurmaedje

@laurmaedje laurmaedje commented May 5, 2026 •

Copy link
Copy Markdown
Member

Stores the standard library in the Engine so that it can be used across the whole compilation without always invoking a tracked call. It's not like the standard library is changing during compilation, so a tracked call is a bit pointless. This is in preparation for a followup PR that allows overriding native show rules and requires access to the Library in realization (where I wanted to avoid adding yet another world.library() tracked call).

A nice side effect of this change is that the ROUTINES static can now be private as it's implicitly threaded into compilation through the LibraryBuilder.

@laurmaedje
laurmaedje enabled auto-merge May 5, 2026 13:13
@laurmaedje
laurmaedje added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit 53b34ce May 5, 2026
23 checks passed
@laurmaedje
laurmaedje deleted the prefetch-library branch May 5, 2026 13:22
gpradofe added a commit to gpradofe/typst that referenced this pull request May 7, 2026
Squashed port of the 14-commit fork/feat/memory-optimization-stack onto
upstream typst/main at 86e3843. Same content as the previous fork branch
(detailed history preserved on fork/feat/memory-optimization-stack and
the experimental-2x-pdf branch); this commit replays the work onto the
current upstream so the PR base is clean.

Notable rebase fixups:
- typst-library: take upstream's moxcms-based color.rs (replaces qcms);
  drop qcms workspace dep, add moxcms.
- typst-pdf/convert.rs: handle krilla's new
  KrillaError::DuplicateNamedDestination variant (upstream PR typst#379);
  consume register_named_destination's must_use return.
- typst/src/lib.rs: Phase 2 streaming Engine construction switched
  from `routines: &ROUTINES` to `library` field (upstream PR typst#8215
  request-stdlib-from-world-once).
- typst-library/foundations/styles.rs: import FxHashMap.
- pages/mod.rs: drop unused Routines import; merge upstream's slimmed
  import block with our streaming-layout-mode imports (At, Resolve, etc.).
- Bump krilla pin to gpradofe/krilla@6bcead6 (rebased streaming-tag
  branch).
- Drop unused [patch.crates-io] entry for pdf-writer; the renumber/io
  extensions in our pdf-writer fork are not consumed by the current
  typst-pdf code path.
- tests/ref/{pdf,svg}/hashes.txt regenerated against new upstream.

Verification:
- cargo build --release: clean.
- cargo test --release -p typst-tests: 3421/0 (parity with the previous
  rebased state at fork.4).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
jassielof pushed a commit to jassielof/typst that referenced this pull request May 7, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 1, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 1, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 1, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 1, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the world/output API group and keeps this slice focused on the new
Typst path model.

## Upstream Typst Changes

- [`typst/typst#7555` Add file `path`
type](typst/typst#7555)
- Introduces the new rooted path model around `RootedPath`,
`VirtualRoot`, and `VirtualPath`.
- `RootedPath` identifies a virtual file location as a pair of root plus
virtual path.
- `VirtualRoot::Project` represents the canonical project root;
`VirtualRoot::Package(PackageSpec)` represents a package root.
- `FileId` is now backed by an interned rooted path instead of the old
optional-package plus path shape. This is why tinymist code now creates
file IDs with `RootedPath::new(...).intern()` / `FileId::unique(...)`
and reads roots through `file_id.root()`.
- Tinymist must preserve its own workspace, untitled, rootless, and
package-root concepts on top of Typst's new project/package root model.

- [`typst/typst#7688` Robust `VirtualPath` type that pre-validates
paths](typst/typst#7688)
- `VirtualPath` construction is no longer just a lossy wrapper around
arbitrary paths; it validates the path shape up front.
- Call sites that previously used raw `Path` conversion now need
`VirtualPath::new(...)`, `VirtualPath::virtualize(...)`, `join(...)`,
`realize(...)`, `get_with_slash()`, or `get_without_slash()` depending
on whether the value is still virtual or should be rendered as a
platform path.
- Tinymist updates workspace entry selection, mock VFS/world paths,
query fixtures, docs imports, rename resolution, and document-link
resolution so virtual paths remain valid and source-relative.

- [`typst/typst#7708` Remove `PartialOrd` and `Ord` for
`FileId`](typst/typst#7708)
- `FileId` should be treated as an opaque interned identifier, not as a
stable ordering key.
- Tinymist replaces ordering-sensitive behavior with explicit
package/path keys where determinism matters, e.g. coverage summaries and
fixture/test ordering.

- [`typst/typst#8215` Request standard library from `World` once
upfront](typst/typst#8215)
- This PR does not include the runtime/engine adaptation from that
group.
- It only carries over the minimal `typst-utils` workspace dependency
because the original nightly order introduced that dependency before
`444c2f2a`, while this logical path-model group already needs
`typst-utils.workspace = true` in `tinymist-query`.

## Tinymist Changes

- Ports the VFS path mapper to `RootedPath`, `VirtualRoot`, and
validated `VirtualPath` operations.
- Updates `EntryState`, mock VFS/world helpers, and tests to create
valid virtual paths instead of relying on raw path wrapping.
- Updates workspace/package/rootless path resolution so tinymist's
workspace IDs continue to map onto Typst package roots where needed.
- Updates analysis, docs, package import, rename, and document-link code
to resolve relative imports from the source file's parent in the new
path model.
- Simplifies import path parent resolution so invalid parent paths
naturally short-circuit instead of falling back to the original virtual
path.
- Adds compatibility helpers in `typst-shim`:
- `as_rooted_path_compat()` for rendering a `VirtualPath` with a leading
slash across stable/nightly Typst APIs.
- `as_rootless_path_compat()` for rendering the same path without a
leading slash.
- `package_compat()` for obtaining the package root through the old or
new `RootedPath` API.
- Keeps snapshot churn and unrelated analysis/runtime changes out of
this PR; those remain for later groups.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the path-model group and keeps this slice focused on analyzer, query,
debug, lint, eval, and typlite API adaptation.

## Upstream Typst Changes

- [`typst/typst#7542`](typst/typst#7542) changes
function internals. Tinymist updates signature, definition, hover, and
rename paths that inspect function internals.
- [`typst/typst#7543`](typst/typst#7543) moves
call sites toward `to_element`-style element handling. Tinymist updates
field access, completion kind inference, and syntax type checking
accordingly.
- [`typst/typst#7808`](typst/typst#7808) changes
parameter metadata. Tinymist updates signature help, built-in type
metadata, scope completion, and type completion to the new parameter
representation.
- [`typst/typst#8215`](typst/typst#8215)
requests the standard library from `World` once upfront. Tinymist
updates tracked values, upstream helpers, global analysis, DAP request
evaluation, and eval engine construction to use the preloaded library
path.
- [`typst/typst#7865`](typst/typst#7865),
[`typst/typst#8116`](typst/typst#8116), and
`typst/typst@5326cd297` adjust math call, math field, and prime syntax.
Tinymist updates syntax matchers, coverage instrumentation, debugger
instrumentation, lint behavior, expression parsing, and query fixtures.
- [`typst/typst#7490`](typst/typst#7490) and
`typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates
document metrics and symbol glyph handling.
- `typst/typst@0f04fd176` changes diagnostic hints into spanned values.
Tinymist updates diagnostic hint rendering.
- [`typst/typst#7897`](typst/typst#7897)
introduces import item placeholders and related attach/text API changes.
Tinymist updates import completions and math text/attach matching.
- Typst 0.15 makes `typst::ROUTINES` private, adds the library argument
to `typst_eval::eval`, and protects engine introspection. Tinymist
updates `typst-shim` eval for both nightly and default feature builds.

## Tinymist Changes

- Ports analysis and query code to the updated function, element,
parameter, font, and math syntax APIs.
- Updates debug coverage and debugger instrumentation for the new math
call/field syntax shapes.
- Updates lint behavior so function-call and math-call handling stay
aligned.
- Updates DAP and `crityp` to the preloaded engine library path.
- Updates `typst-shim` eval and syntax compatibility modules so both
`nightly` and default feature builds compile against the current Typst
0.15 dependency set.
- Refreshes targeted query and typlite fixtures affected by these API
and syntax behavior changes.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the world/output API group and keeps this slice focused on the new
Typst path model.

- [`typst/typst#7555` Add file `path`
type](typst/typst#7555)
- Introduces the new rooted path model around `RootedPath`,
`VirtualRoot`, and `VirtualPath`.
- `RootedPath` identifies a virtual file location as a pair of root plus
virtual path.
- `VirtualRoot::Project` represents the canonical project root;
`VirtualRoot::Package(PackageSpec)` represents a package root.
- `FileId` is now backed by an interned rooted path instead of the old
optional-package plus path shape. This is why tinymist code now creates
file IDs with `RootedPath::new(...).intern()` / `FileId::unique(...)`
and reads roots through `file_id.root()`.
- Tinymist must preserve its own workspace, untitled, rootless, and
package-root concepts on top of Typst's new project/package root model.

- [`typst/typst#7688` Robust `VirtualPath` type that pre-validates
paths](typst/typst#7688)
- `VirtualPath` construction is no longer just a lossy wrapper around
arbitrary paths; it validates the path shape up front.
- Call sites that previously used raw `Path` conversion now need
`VirtualPath::new(...)`, `VirtualPath::virtualize(...)`, `join(...)`,
`realize(...)`, `get_with_slash()`, or `get_without_slash()` depending
on whether the value is still virtual or should be rendered as a
platform path.
- Tinymist updates workspace entry selection, mock VFS/world paths,
query fixtures, docs imports, rename resolution, and document-link
resolution so virtual paths remain valid and source-relative.

- [`typst/typst#7708` Remove `PartialOrd` and `Ord` for
`FileId`](typst/typst#7708)
- `FileId` should be treated as an opaque interned identifier, not as a
stable ordering key.
- Tinymist replaces ordering-sensitive behavior with explicit
package/path keys where determinism matters, e.g. coverage summaries and
fixture/test ordering.

- [`typst/typst#8215` Request standard library from `World` once
upfront](typst/typst#8215)
- This PR does not include the runtime/engine adaptation from that
group.
- It only carries over the minimal `typst-utils` workspace dependency
because the original nightly order introduced that dependency before
`444c2f2a`, while this logical path-model group already needs
`typst-utils.workspace = true` in `tinymist-query`.

- Ports the VFS path mapper to `RootedPath`, `VirtualRoot`, and
validated `VirtualPath` operations.
- Updates `EntryState`, mock VFS/world helpers, and tests to create
valid virtual paths instead of relying on raw path wrapping.
- Updates workspace/package/rootless path resolution so tinymist's
workspace IDs continue to map onto Typst package roots where needed.
- Updates analysis, docs, package import, rename, and document-link code
to resolve relative imports from the source file's parent in the new
path model.
- Simplifies import path parent resolution so invalid parent paths
naturally short-circuit instead of falling back to the original virtual
path.
- Adds compatibility helpers in `typst-shim`:
- `as_rooted_path_compat()` for rendering a `VirtualPath` with a leading
slash across stable/nightly Typst APIs.
- `as_rootless_path_compat()` for rendering the same path without a
leading slash.
- `package_compat()` for obtaining the package root through the old or
new `RootedPath` API.
- Keeps snapshot churn and unrelated analysis/runtime changes out of
this PR; those remain for later groups.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the path-model group and keeps this slice focused on analyzer, query,
debug, lint, eval, and typlite API adaptation.

- [`typst/typst#7542`](typst/typst#7542) changes
function internals. Tinymist updates signature, definition, hover, and
rename paths that inspect function internals.
- [`typst/typst#7543`](typst/typst#7543) moves
call sites toward `to_element`-style element handling. Tinymist updates
field access, completion kind inference, and syntax type checking
accordingly.
- [`typst/typst#7808`](typst/typst#7808) changes
parameter metadata. Tinymist updates signature help, built-in type
metadata, scope completion, and type completion to the new parameter
representation.
- [`typst/typst#8215`](typst/typst#8215)
requests the standard library from `World` once upfront. Tinymist
updates tracked values, upstream helpers, global analysis, DAP request
evaluation, and eval engine construction to use the preloaded library
path.
- [`typst/typst#7865`](typst/typst#7865),
[`typst/typst#8116`](typst/typst#8116), and
`typst/typst@5326cd297` adjust math call, math field, and prime syntax.
Tinymist updates syntax matchers, coverage instrumentation, debugger
instrumentation, lint behavior, expression parsing, and query fixtures.
- [`typst/typst#7490`](typst/typst#7490) and
`typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates
document metrics and symbol glyph handling.
- `typst/typst@0f04fd176` changes diagnostic hints into spanned values.
Tinymist updates diagnostic hint rendering.
- [`typst/typst#7897`](typst/typst#7897)
introduces import item placeholders and related attach/text API changes.
Tinymist updates import completions and math text/attach matching.
- Typst 0.15 makes `typst::ROUTINES` private, adds the library argument
to `typst_eval::eval`, and protects engine introspection. Tinymist
updates `typst-shim` eval for both nightly and default feature builds.

- Ports analysis and query code to the updated function, element,
parameter, font, and math syntax APIs.
- Updates debug coverage and debugger instrumentation for the new math
call/field syntax shapes.
- Updates lint behavior so function-call and math-call handling stay
aligned.
- Updates DAP and `crityp` to the preloaded engine library path.
- Updates `typst-shim` eval and syntax compatibility modules so both
`nightly` and default feature builds compile against the current Typst
0.15 dependency set.
- Refreshes targeted query and typlite fixtures affected by these API
and syntax behavior changes.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the world/output API group and keeps this slice focused on the new
Typst path model.

- [`typst/typst#7555` Add file `path`
type](typst/typst#7555)
- Introduces the new rooted path model around `RootedPath`,
`VirtualRoot`, and `VirtualPath`.
- `RootedPath` identifies a virtual file location as a pair of root plus
virtual path.
- `VirtualRoot::Project` represents the canonical project root;
`VirtualRoot::Package(PackageSpec)` represents a package root.
- `FileId` is now backed by an interned rooted path instead of the old
optional-package plus path shape. This is why tinymist code now creates
file IDs with `RootedPath::new(...).intern()` / `FileId::unique(...)`
and reads roots through `file_id.root()`.
- Tinymist must preserve its own workspace, untitled, rootless, and
package-root concepts on top of Typst's new project/package root model.

- [`typst/typst#7688` Robust `VirtualPath` type that pre-validates
paths](typst/typst#7688)
- `VirtualPath` construction is no longer just a lossy wrapper around
arbitrary paths; it validates the path shape up front.
- Call sites that previously used raw `Path` conversion now need
`VirtualPath::new(...)`, `VirtualPath::virtualize(...)`, `join(...)`,
`realize(...)`, `get_with_slash()`, or `get_without_slash()` depending
on whether the value is still virtual or should be rendered as a
platform path.
- Tinymist updates workspace entry selection, mock VFS/world paths,
query fixtures, docs imports, rename resolution, and document-link
resolution so virtual paths remain valid and source-relative.

- [`typst/typst#7708` Remove `PartialOrd` and `Ord` for
`FileId`](typst/typst#7708)
- `FileId` should be treated as an opaque interned identifier, not as a
stable ordering key.
- Tinymist replaces ordering-sensitive behavior with explicit
package/path keys where determinism matters, e.g. coverage summaries and
fixture/test ordering.

- [`typst/typst#8215` Request standard library from `World` once
upfront](typst/typst#8215)
- This PR does not include the runtime/engine adaptation from that
group.
- It only carries over the minimal `typst-utils` workspace dependency
because the original nightly order introduced that dependency before
`444c2f2a`, while this logical path-model group already needs
`typst-utils.workspace = true` in `tinymist-query`.

- Ports the VFS path mapper to `RootedPath`, `VirtualRoot`, and
validated `VirtualPath` operations.
- Updates `EntryState`, mock VFS/world helpers, and tests to create
valid virtual paths instead of relying on raw path wrapping.
- Updates workspace/package/rootless path resolution so tinymist's
workspace IDs continue to map onto Typst package roots where needed.
- Updates analysis, docs, package import, rename, and document-link code
to resolve relative imports from the source file's parent in the new
path model.
- Simplifies import path parent resolution so invalid parent paths
naturally short-circuit instead of falling back to the original virtual
path.
- Adds compatibility helpers in `typst-shim`:
- `as_rooted_path_compat()` for rendering a `VirtualPath` with a leading
slash across stable/nightly Typst APIs.
- `as_rootless_path_compat()` for rendering the same path without a
leading slash.
- `package_compat()` for obtaining the package root through the old or
new `RootedPath` API.
- Keeps snapshot churn and unrelated analysis/runtime changes out of
this PR; those remain for later groups.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top
of the path-model group and keeps this slice focused on analyzer, query,
debug, lint, eval, and typlite API adaptation.

- [`typst/typst#7542`](typst/typst#7542) changes
function internals. Tinymist updates signature, definition, hover, and
rename paths that inspect function internals.
- [`typst/typst#7543`](typst/typst#7543) moves
call sites toward `to_element`-style element handling. Tinymist updates
field access, completion kind inference, and syntax type checking
accordingly.
- [`typst/typst#7808`](typst/typst#7808) changes
parameter metadata. Tinymist updates signature help, built-in type
metadata, scope completion, and type completion to the new parameter
representation.
- [`typst/typst#8215`](typst/typst#8215)
requests the standard library from `World` once upfront. Tinymist
updates tracked values, upstream helpers, global analysis, DAP request
evaluation, and eval engine construction to use the preloaded library
path.
- [`typst/typst#7865`](typst/typst#7865),
[`typst/typst#8116`](typst/typst#8116), and
`typst/typst@5326cd297` adjust math call, math field, and prime syntax.
Tinymist updates syntax matchers, coverage instrumentation, debugger
instrumentation, lint behavior, expression parsing, and query fixtures.
- [`typst/typst#7490`](typst/typst#7490) and
`typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates
document metrics and symbol glyph handling.
- `typst/typst@0f04fd176` changes diagnostic hints into spanned values.
Tinymist updates diagnostic hint rendering.
- [`typst/typst#7897`](typst/typst#7897)
introduces import item placeholders and related attach/text API changes.
Tinymist updates import completions and math text/attach matching.
- Typst 0.15 makes `typst::ROUTINES` private, adds the library argument
to `typst_eval::eval`, and protects engine introspection. Tinymist
updates `typst-shim` eval for both nightly and default feature builds.

- Ports analysis and query code to the updated function, element,
parameter, font, and math syntax APIs.
- Updates debug coverage and debugger instrumentation for the new math
call/field syntax shapes.
- Updates lint behavior so function-call and math-call handling stay
aligned.
- Updates DAP and `crityp` to the preloaded engine library path.
- Updates `typst-shim` eval and syntax compatibility modules so both
`nightly` and default feature builds compile against the current Typst
0.15 dependency set.
- Refreshes targeted query and typlite fixtures affected by these API
and syntax behavior changes.

---------

Co-authored-by: paran3xus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant