Skip to content

feat: scaffold api, commands, and tests#2

Open
onehumandev wants to merge 1 commit into
silvermine:masterfrom
onehumandev:onehumandev/api-entry
Open

feat: scaffold api, commands, and tests#2
onehumandev wants to merge 1 commit into
silvermine:masterfrom
onehumandev:onehumandev/api-entry

Conversation

@onehumandev
Copy link
Copy Markdown

@onehumandev onehumandev commented May 11, 2026

Scaffolds the Rust and TS API contracts for path resolution, including:

  1. Tauri commands
  2. Typescript bindings
  3. Rust wiring for commands, pending implementation

The paths for each platforms are strongly typed as enums in both TS and Rust,
based on the APIs available natively for each platform.
iOS and Mac are based on SearchPathDirectory, Android on what is available to the Context
class, Linux on the XDG spec, Win32 paths (for MSI installations) on KNOWNFOLDERID, and AppData (MSIX) paths
based on ApplicationData.

These paths can be accessed with platform-specific methods for resolving the path and
passing in the enum for the requested path.

To allow users to not need to write their own platform branching logic, we also have
the PathMapping object.

This allows the user to define the path for each supported platform, and calling
resolve() will retrieve the path based on the callers OS.

We allow the user to have access to both the convenience of PathMapping, and to the
direct methods that resolve the path.

We do not make any decisions about which paths are available for a platform; this is a
one-to-one matching to what each OS provides.

Even if a path seems to be one that would not be of interest for a Tauri app, we still
include it.

This implementation is based on the discussion here:
tauri-apps/tauri#12276

There are some implementation differences in this API compared to what was originally
suggested in the above issue, listed below:

  1. Enum arguments instead of named methods. Proposal: IosPaths.appLibrary(). This PR:
    resolveApplePath(ApplePath.LibraryDirectory).
    By using enum values instead of one method per path, the surface area of the API is
    vastly smaller. We now only have 6 methods (one per platform, plus one more for Android
    path collections) instead of one method per path.
    This makes the API much more ergonomic and easier to maintain.

  2. Windows is more granular than proposed. The PR's WindowsPath = {win32} | {winMsix}
    tagged union captures the MSI/MSIX distinction that the proposal collapsed into a single
    WindowsPaths.
    This allows for the dev to clearly state which packaging they plan to ship. There is not
    a known use case where an app will need to be built for both MSIX and MSI (as opposed to
    iOS and Mac, where it is very common for an app to be created for both).
    With this pattern, when resolving a path, the dev doesn't have to verbosely differentiate
    between which path they want for their Windows package.

  3. Surface is much wider than "common cases". The proposal says: "simplified path for
    common cases via the cross-platform API, and fine-grained control when platform-specific
    behavior matters."
    Since the actual path resolution is not made more complicated by how many paths we
    expose, there is no benefit to limiting which paths are allowed.
    Instead, by simply reflecting exactly what each platforms API provides, we give the
    client full control with no opinion forced on them.
    As long as the single low-level invocation to resolve a path works, all other paths will
    work without issue.

@onehumandev onehumandev force-pushed the onehumandev/api-entry branch 2 times, most recently from 4477b6a to 2adebbf Compare May 11, 2026 18:52
Comment thread crates/fs-resolver/src/path_mapping.rs Outdated
Comment thread src/commands.rs
Comment thread crates/fs-resolver/src/windows_resolve.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread build.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread crates/fs-resolver/src/lib.rs Outdated
Comment thread README.md Outdated
Comment thread guest-js/path-mapping.ts Outdated
Comment thread guest-js/index.test.ts
@onehumandev onehumandev force-pushed the onehumandev/api-entry branch 4 times, most recently from 95c03bb to b936ce3 Compare May 11, 2026 22:40
@onehumandev onehumandev requested a review from jjhafer May 11, 2026 22:40
Copy link
Copy Markdown

@velocitysystems velocitysystems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description doesn't mention the design discussion in tauri-apps/tauri#12276 — I think it'd be worth linking, since that comment is the broader design context for this plugin.

Reading the proposal alongside this PR:

  • Platform-specific entry points with 1:1 parity to each OS's native APIs ✓
  • A cross-platform overlay on top (PathMapping) rather than being the only option ✓
  • Coexistence of both fine-grained and convenience APIs ✓

Noted a few places where the shape diverges:

  • Enum arguments instead of named methods. Proposal: IosPaths.appLibrary(). This PR: resolveApplePath(ApplePath.LibraryDirectory).

  • iOS and macOS are merged into ApplePath. The proposal has a dedicated IosPaths. The PR's ApplePath enum covers all SearchPathDirectory variants, several of which are macOS-only. Is the plan to split this into per-OS enums later, or to validate at the resolve_apple_path boundary?

  • Windows is more granular than proposed. The PR's WindowsPath = {win32} | {winMsix} tagged union captures the MSI/MSIX distinction that the proposal collapsed into a single WindowsPaths. I think that's an improvement on the proposal, but it's worth calling out as a deliberate divergence so the upstream maintainers can react to it.

  • Surface is much wider than "common cases". The proposal says: "simplified path for common cases via the cross-platform API, and fine-grained control when platform-specific behavior matters."

Curious whether these divergences are deliberate or things we plan to address in follow-up PRs? Just wanted to call out for discussion. Thanks!

Comment thread guest-js/types.ts
Comment thread crates/fs-resolver/src/apple_resolve.rs Outdated
Comment thread README.md
Comment thread README.md
Comment thread README.md Outdated
Comment thread Cargo.toml Outdated
Comment thread crates/fs-resolver/Cargo.toml Outdated
@onehumandev onehumandev force-pushed the onehumandev/api-entry branch 2 times, most recently from ec5166b to be1055c Compare May 13, 2026 18:48
Scaffolds the Rust and TS API contracts for path resolution, including:
1. Tauri commands
1. Typescript bindings
1. Rust wiring for commands, pending implementation

The paths for each platforms are strongly typed as enums in both TS and Rust,
based on the APIs available natively for each platform.
iOS and Mac are based on SearchPathDirectory, Android on what is available to the Context
class, Win32 paths (for MSI installations)  on KNOWNFOLDERID, and AppData (MSIX) paths
based on ApplicationData.

These paths can be accessed with platform-specific methods for resolving the path and
passing in the enum for the requested path.

To allow users to not need to write their own platform branching logic, we also have
the PathMapping object.

This allows the user to define the path for each supported platform, and calling
`resolve()` will retrieve the path based on the callers  OS.

We allow the user to have access to both the convenience of PathMapping, and to the
direct methods that resolve the path.

We do not make any decisions about which paths are available for a platform; this is a
one-to-one matching to what each OS provides.

Even if a path seems to be one that would not be of interest for a Tauri app, we still
include it.

This implementation is based on the discussion here:
tauri-apps/tauri#12276

There are some implementation differences in this API compared to what was originally
suggested in the above issue, listed below:

1) Enum arguments instead of named methods. Proposal: IosPaths.appLibrary(). This PR:
resolveApplePath(ApplePath.LibraryDirectory).
By using enum values instead of one method per path, the surface area of the API is
vastly smaller. We now only have 6 methods (one per platform, plus one more for Android
path collections) instead of one method per path.
This makes the API much more ergonomic and easier to maintain.

2) Windows is more granular than proposed. The PR's WindowsPath = {win32} | {winMsix}
tagged union captures the MSI/MSIX distinction that the proposal collapsed into a single
WindowsPaths.
This allows for the dev to clearly state which packaging they plan to ship. There is not
a known use case where an app will need to be built for both MSIX and MSI (as opposed to
iOS and Mac, where it is very common for an app to be created for both).
With this pattern, when resolving a path, the dev doesn't have to verbosely differentiate
between which path they want for their Windows package.

3) Surface is much wider than "common cases". The proposal says: "simplified path for
common cases via the cross-platform API, and fine-grained control when platform-specific
behavior matters."
Since the actual path resolution is not made more complicated by how many paths we
expose, there is no benefit to limiting which paths are allowed.
Instead, by simply reflecting exactly what each platforms API provides, we give the
client full control with no opinion forced on them.
As long as the single low-level invocation to resolve a path works, all other paths will
work without issue.
@onehumandev onehumandev force-pushed the onehumandev/api-entry branch from be1055c to bdcf289 Compare May 13, 2026 18:54
@onehumandev
Copy link
Copy Markdown
Author

The PR description doesn't mention the design discussion in tauri-apps/tauri#12276 — I think it'd be worth linking, since that comment is the broader design context for this plugin.

Reading the proposal alongside this PR:

  • Platform-specific entry points with 1:1 parity to each OS's native APIs ✓
  • A cross-platform overlay on top (PathMapping) rather than being the only option ✓
  • Coexistence of both fine-grained and convenience APIs ✓

Noted a few places where the shape diverges:

  • Enum arguments instead of named methods. Proposal: IosPaths.appLibrary(). This PR: resolveApplePath(ApplePath.LibraryDirectory).
  • iOS and macOS are merged into ApplePath. The proposal has a dedicated IosPaths. The PR's ApplePath enum covers all SearchPathDirectory variants, several of which are macOS-only. Is the plan to split this into per-OS enums later, or to validate at the resolve_apple_path boundary?
  • Windows is more granular than proposed. The PR's WindowsPath = {win32} | {winMsix} tagged union captures the MSI/MSIX distinction that the proposal collapsed into a single WindowsPaths. I think that's an improvement on the proposal, but it's worth calling out as a deliberate divergence so the upstream maintainers can react to it.
  • Surface is much wider than "common cases". The proposal says: "simplified path for common cases via the cross-platform API, and fine-grained control when platform-specific behavior matters."

Curious whether these divergences are deliberate or things we plan to address in follow-up PRs? Just wanted to call out for discussion. Thanks!

Good points on all the above; PR description has been updated with the above points, and we also now include an API to cover Linux.

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.

4 participants