Skip to content

Robust VirtualPath type that pre-validates paths - #7688

Merged
laurmaedje merged 1 commit into
mainfrom
proper-virtual-path
Jan 13, 2026
Merged

laurmaedje merged 1 commit into
mainfrom
proper-virtual-path

Conversation

@laurmaedje

Copy link
Copy Markdown
Member

This is split off from #7555. There is one difference: The VirtualPath type here remains just the true path part and does not contain the root information. I wasn't so happy with unifying both because a path without a root is also sometimes a useful abstraction (e.g. for multi-file HTML output assets). This is mostly the reason why #7555 hasn't landed yet. In the interest of getting it in piece by piece, I'm landing this first now.

This PR contains the two breaking changes describes in #7555. It does not contain the hints yet; those will be added in a future PR.

@laurmaedje
laurmaedje added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit de641b5 Jan 13, 2026
@laurmaedje
laurmaedje deleted the proper-virtual-path branch January 13, 2026 12:36
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jan 16, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jan 16, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jan 16, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jan 16, 2026
in typst/typst#7688, typst/typst#7689, typst/typst#7690, typst/typst#7555

to make crates other than world crates work

path

path

path

path

path
jassielof pushed a commit to jassielof/typst that referenced this pull request Jan 16, 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 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/typst.ts that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/typst.ts 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 May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 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 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 pushed a commit to Myriad-Dreamin/typst.ts that referenced this pull request Jun 15, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/typst.ts that referenced this pull request Jun 15, 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.

- [`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 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]>
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
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