Skip to content

Add typst-kit crate - #4540

Merged
laurmaedje merged 4 commits into
typst:mainfrom
tingerrr:tingerrr/wrtkpytukyvp
Aug 5, 2024
Merged

laurmaedje merged 4 commits into
typst:mainfrom
tingerrr:tingerrr/wrtkpytukyvp

Conversation

@tingerrr

@tingerrr tingerrr commented Jul 11, 2024 •

Copy link
Copy Markdown
Contributor

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

tingerrr commented Jul 19, 2024 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

Thumuss commented Jul 19, 2024

Copy link
Copy Markdown

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
Copy Markdown
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

tingerrr commented Jul 20, 2024 •

Copy link
Copy Markdown
Contributor Author

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.

Comment thread crates/typst-kit/src/project.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/Cargo.toml Resolved
Comment thread crates/typst-kit/Cargo.toml Resolved
Comment thread crates/typst-cli/src/update.rs Resolved
@tingerrr
tingerrr force-pushed the tingerrr/wrtkpytukyvp branch from 5aa22c6 to 27f592b Compare July 22, 2024 15:27
@tingerrr
tingerrr force-pushed the tingerrr/wrtkpytukyvp branch from 27f592b to 5d74555 Compare July 26, 2024 11:31

@laurmaedje laurmaedje left a comment

Copy link
Copy Markdown
Member

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.

Comment thread crates/typst-kit/Cargo.toml Resolved
Comment thread crates/typst-kit/Cargo.toml Resolved
Comment thread crates/typst-kit/Cargo.toml Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/download.rs Resolved
Comment thread crates/typst-kit/src/fonts.rs Resolved
Comment thread crates/typst-kit/src/fonts.rs Resolved
Comment thread crates/typst-kit/src/lib.rs Resolved
Comment thread crates/typst-kit/src/lib.rs Resolved
Comment thread crates/typst-kit/src/package.rs Resolved
@tingerrr

tingerrr commented Aug 5, 2024

Copy link
Copy Markdown
Contributor Author

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

laurmaedje commented Aug 5, 2024 •

Copy link
Copy Markdown
Member

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

@tingerrr

tingerrr commented Aug 5, 2024

Copy link
Copy Markdown
Contributor Author

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
@tingerrr
tingerrr force-pushed the tingerrr/wrtkpytukyvp branch from b241652 to 9627100 Compare August 5, 2024 16:27
@tingerrr
tingerrr force-pushed the tingerrr/wrtkpytukyvp branch from 9627100 to 690d7d4 Compare August 5, 2024 16:28
@laurmaedje
laurmaedje added this pull request to the merge queue Aug 5, 2024
@laurmaedje

Copy link
Copy Markdown
Member

Thank you!

Merged via the queue into typst:main with commit 672f6e5 Aug 5, 2024
@tingerrr
tingerrr deleted the tingerrr/wrtkpytukyvp branch August 6, 2024 07:17
laurmaedje added a commit that referenced this pull request Aug 9, 2024
# Explicitly depend on OpenSSL if applicable, so that we can add the
# `openssl/vendored` feature to it if `vendor-openssl` is enabled.
[target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos")))'.dependencies]
openssl = { workspace = true }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be optional as well and only enabled under downloads.

@laurmaedje

laurmaedje commented Aug 10, 2024 •

Copy link
Copy Markdown
Member

I reviewed this again after the two regressions, this time actually comparing the moved code fragments. Didn't find anything major, but I noticed that typst-kit's OpenSSL dependency is unconditional on Linux, even though it is only needed for downloading.

@tingerrr

Copy link
Copy Markdown
Contributor Author

I left his completely unchanged, this was already the case before.

@laurmaedje

Copy link
Copy Markdown
Member

Yeah, but the CLI uses downloading unconditionally whereas in typst-kit it is optional.

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