Automagically resolve Rheo packages from #import statements in content#124
Merged
Conversation
#import statements in content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rheo's packaging system makes use of Typst's packaging format by adding a
[tool.rheo]section as third-party metadata. When this section exists in a Typst package, Rheo will parse it in order to transfer the appropriate additional assets from the package into the build folder.Since #123, a package in Rheo is syntatic sugar for an assets block (as per #122). Thus the
[tool.rheo]section in the Typst package manifest ultimately specifies the options for such an assets block with a deriveddestattribute. For example, say that the following manifest section exists intypst.tomlin a~/.local/share/typst/packages/rheo/slidesfolder:Rheo will derive the following assets block associated with this package:
All fields that are valid in an
[[{format}.assets]]block are valid in a[tool.rheo.{format}]block.Package cache pre-warm for preview namespace
The current behavior of the Typst CLI is to pre-warm packages that correspond to an
#import "@preview/package-name"statement (only for the@previewnamespace). Because Rheo configures and loads asset blocks before deferring to Typst compilation, we need to explicitly pre-warm the preview namespace with the corresponding packages on Typst Universe. This ensures the automagic inclusion of packages that specify Rheo configuration that are hosted on Typst Universe. In other words, if the content in a Rheo project includes the following line:And
rheo-libraryspecifies some[tool.rheo]config in its manifest, Rheo will appropriately register the assets and produce them in the build. This means that Rheo packages can be distributed simply as Typst packages (with one extra config block in the package manifest).@rheo packages
These changes allow us to externalize some of the previous examples (tooltip and slides) into a separate rheo-packages repository. So as not to require upstreaming all new packages to Typst Universe, I have decided to locate these in a
@rheonamespace. This means that the packages are not auto-magically installed by therheoortypstCLIs: but they are easily 'installed' via agit cloneoperation, as the rheo-packages repo is structured as a Typst package namespace. This PR also thus adds this install step to the CI, so that the examples directories can use packages from the@rheonamespace.