Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typst-kit crate #4540

Merged
merged 4 commits into from
Aug 5, 2024
Merged

Add typst-kit crate #4540

merged 4 commits into from
Aug 5, 2024

Conversation

tingerrr
Copy link
Contributor

@tingerrr tingerrr commented Jul 11, 2024

This PR adds the typst-kit crate, which contains various default implementations of things a Typst tool may need, such as:

  • font searching
  • manifest validation
  • package storage with on demand package downloads from package registries
  • project management
    • project lookup
    • project locking

Resolves #4452.

@tingerrr tingerrr force-pushed the tingerrr/wrtkpytukyvp branch 7 times, most recently from 778016f to 21a4d46 Compare July 12, 2024 12:19
@tingerrr tingerrr marked this pull request as ready for review July 19, 2024 10:55
@tingerrr tingerrr force-pushed the tingerrr/wrtkpytukyvp branch 2 times, most recently from 6b70d18 to a2600d7 Compare July 19, 2024 11:21
@tingerrr
Copy link
Contributor Author

tingerrr commented Jul 19, 2024

For the reviewers: I suggest reviewing commit by commit for simplicity.

Manifest validation is left out for now, this is only relevant for the package I think, but if it is relevant to other downstream tools we can add it in post.

I have added a project crate which should at some point have things like the project locking mentioned in #4452, but I left the feature out as I'm not 100% sure how to implement it in a cross-platform manner. Currently, it only contains recursive project lookup by searching for the manifest file.

Regarding package downloads, I initially wanted to abstract this a little more, but it proved difficult. I think this is the feature where it's least clear what should be configurable and what shouldn't, so this can be extended later when the API surface is clearer. It will likely change once we add support for custom registries and git packages, so it's ok that it's not yet fully defined, I think.

@tingerrr tingerrr force-pushed the tingerrr/wrtkpytukyvp branch 2 times, most recently from 7921cf1 to 5aa22c6 Compare July 19, 2024 11:26
@tingerrr
Copy link
Contributor Author

I should note that I had a discussion with @Thumuss regarding manifest validation. While this is something that only 2 projects need, utpm and the package bundler, it may still be beneficial to add to typst-kit or typst-syntax.

@Thumuss
Copy link

Thumuss commented Jul 19, 2024

I should note that I had a discussion with @Thumuss regarding manifest validation. While this is something that only 2 projects need, utpm and the package bundler, it may still be beneficial to add to typst-kit or typst-syntax.

As I said earlier on discord, utpm will need manifest validation because it will publish directly a PR on typst/packages. We don't need a big validation system, just enough to block malformed typst.toml.

@laurmaedje
Copy link
Member

I think the Typst Universe specific checks don't really belong in the compiler repository. Was that the idea or are you talking about some other kind of validation?

@tingerrr
Copy link
Contributor Author

tingerrr commented Jul 20, 2024

I was thinking of this, yeah, but there are other forms like package names being identifiers which are directly tied to how package specs are parsed.

But I guess we can leave it out.

crates/typst-kit/src/project.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/Cargo.toml Outdated Show resolved Hide resolved
crates/typst-kit/Cargo.toml Outdated Show resolved Hide resolved
crates/typst-cli/src/update.rs Outdated Show resolved Hide resolved
Copy link
Member

@laurmaedje laurmaedje left a comment

Choose a reason for hiding this comment

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

I left some further minor comments. Other than that, it looks good to merge.

There are some unticked boxes in the PR description. Do you still want to tackle those here? Personally, I think we can merge what's there first and proceed with the rest separately.

crates/typst-kit/Cargo.toml Outdated Show resolved Hide resolved
crates/typst-kit/Cargo.toml Outdated Show resolved Hide resolved
crates/typst-kit/Cargo.toml Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/download.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/fonts.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/fonts.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/lib.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/lib.rs Outdated Show resolved Hide resolved
crates/typst-kit/src/package.rs Outdated Show resolved Hide resolved
@tingerrr
Copy link
Contributor Author

tingerrr commented Aug 5, 2024

There are some unticked boxes in the PR description. Do you still want to tackle those here? Personally, I think we can merge what's there first and proceed with the rest separately.

For project locking, I was unable to come up with anything cross-platform and safe. I left some notes on #4658 regarding those issues.

Regarding manifest validation, we decided to leave this out of typst-kit since it's universe specific.

@laurmaedje laurmaedje added this pull request to the merge queue Aug 5, 2024
@laurmaedje laurmaedje removed this pull request from the merge queue due to a manual request Aug 5, 2024
@laurmaedje
Copy link
Member

laurmaedje commented Aug 5, 2024

Alright, then we can merge once you've pushed.

@tingerrr
Copy link
Contributor Author

tingerrr commented Aug 5, 2024

Alright, then we can merge once you've pushed.

One review comment is left open, do you prefer getters setters for effectively public fields?

@tingerrr tingerrr force-pushed the tingerrr/wrtkpytukyvp branch 2 times, most recently from e9a15c2 to b241652 Compare August 5, 2024 16:20
@laurmaedje laurmaedje added this pull request to the merge queue Aug 5, 2024
@laurmaedje
Copy link
Member

Thank you!

Merged via the queue into typst:main with commit 672f6e5 Aug 5, 2024
6 checks passed
@tingerrr tingerrr deleted the tingerrr/wrtkpytukyvp branch August 6, 2024 07:17
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.

Crate for downstream tooling
3 participants