Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 7.32 KB

File metadata and controls

31 lines (27 loc) · 7.32 KB

Release Notes

[Unreleased]

Fixed

  • Fixed a stream from document.OpenOutputStream() leaving the rendered document in ArrayPool<byte>.Shared. Only the byte-array reads were overridden, so span-shaped and asynchronous reads, and CopyTo, fell through to Stream, which stages the bytes through a rented array and returns it to the pool without clearing it. The next component in the process to rent from that pool could read the document back. The reads and the copy now go straight from native memory, which also removes a second copy of every byte: a 4 MiB span read measured 0.767 ms before and 0.274 ms after.
  • Fixed a compiler reused across compilations never seeing a change made to the files it reads. The main file and every import were read on first access and then kept forever, so a cached TypstCompiler — which the README recommends, because it takes a compile from around 40ms down to 3ms — went on rendering the template it had read at startup, with no error to show for it. Every compilation now starts by invalidating the file slots, the way typst-cli does between watch runs, so a template redeployed underneath a running process takes effect. Files whose content has not changed are recognised by their hash and are not parsed again, and a document passed in as a string is unaffected: there is no file behind it. Two consequences worth knowing about: templates should be replaced atomically, because a compilation that lands halfway through a plain overwrite now renders the half-written file; and a warm compilation costs one stat and one read per file it touches, so a template split across many files is measurably more expensive to recompile than a single one.
  • Fixed an input path in a subfolder aborting the process instead of compiling. The path was handed to Typst verbatim, and a Typst virtual path only accepts forward slashes, so on Windows an ordinary relative path such as templates\letter.typ panicked inside a native call and took the host process down with it. Paths are now resolved against the project root before being converted, and a path that genuinely leaves the root reports an error instead of panicking. Note that the root is matched against an absolute input path textually, so on Windows both have to be spelled with the same casing.
  • Fixed ua-1 (PDF/UA-1, the accessibility standard) being rejected by pdfStandards. The accepted names are now taken from typst_pdf::PdfStandard itself, so every standard Typst supports is accepted, including ones added by later Typst releases. The documented v- prefix on plain PDF versions still works, and applies only to them: v-a-2b is not a spelling of a-2b.

Changed

  • TypstCompiler.FromSource(...) and the static one-shot helpers no longer copy the source onto the managed heap before handing it to the compiler. It is encoded straight into the native buffer, so a source over roughly 42,500 characters no longer puts an array on the large object heap for the duration of one call: a 200 KB source measured 200,024 bytes of managed heap before and none after. Native memory allocated while building a compiler is also released now when construction fails part way through, rather than leaking.
  • Breaking (binary): SvgResult.GetEnumerator() and PngResult.GetEnumerator() now return PageEnumerator<T> rather than IEnumerator<T>, so that foreach over a result no longer boxes the enumerator. Source-compatible: foreach, LINQ, Count and the indexer all keep compiling. Because a return type is part of the method signature and the compiler emits a direct call for pattern-based foreach, an assembly compiled against an earlier version throws MissingMethodException on that foreach until it is recompiled.
  • Breaking: an invalid combination of PDF standards now fails the compilation instead of silently producing an ordinary PDF. The validation error from PdfStandards::new was discarded and export fell back to the default, so a pipeline could believe it was writing PDF/A while it was not. Combinations such as two PDF/A levels, or a PDF/A level that contradicts the requested PDF version, now throw with the message and hints from Typst. Callers passing a contradictory combination today receive a document and will receive an exception after this change.
  • Note for PDF/A and PDF/UA: the exporter deliberately writes no timestamp, so the document has to carry its own date (#set document(date: ...)) and, for PDF/UA, a title and language.
  • compiler.CompilePdf(Stream), compiler.CompilePdfAsync(Stream), compiler.CompilePdf(string outputFile) and compiler.CompilePdfAsync(string outputFile) now stream the document straight from native memory to the destination and return the compiler warnings, rather than returning a PdfResult that had to be materialised on the managed heap first. Use compiler.CompilePdf() when you want the bytes.
  • compiler.Compile(outputFile, format) and compiler.CompileSvg(...) no longer copy the rendered output onto the managed heap before writing or decoding it.
  • sysInputs parameters on TypstCompiler and the SetSysInputs argument are now IDictionary<string, string> instead of Dictionary<string, string>, so a ReadOnlyDictionary<string, string>, ImmutableDictionary<string, string> or any other implementation can be passed. Existing calls that pass a Dictionary<string, string> are unaffected.

Added

  • Added merged SVG export, rendering every page into a single SVG stacked top to bottom as Typst's svg_merged does. Use compiler.CompileMergedSvg(gapInPoints), the static TypstCompiler.CompileMergedSvg(...) / TypstCompiler.CompileMergedSvgFromFile(...), or the svg-merged format with the new mergedGap parameter on CompileToDocument and Compile(outputFile, format). The gap between pages is given in points.
  • Added compiler.CompileToDocument(...), returning a disposable TypstDocument that exposes the rendered output while it is still in the memory the native library allocated. GetOutputSpan, OpenOutputStream, CopyOutputTo, WriteOutputToFile and RentOutput read it without putting a multi-megabyte PDF on the large object heap; GetOutputBytes copies when a byte[] is what you need.
  • Added easier PDF compilation APIs on TypstCompiler:
    • compiler.CompilePdf(...) returning a PdfResult (with implicit conversion to byte[], ReadOnlySpan<byte>, and ReadOnlyMemory<byte>).
    • compiler.CompilePdf(string outputFile) / compiler.CompilePdfAsync(string outputFile) for direct file saving.
    • compiler.CompilePdf(Stream destination) / compiler.CompilePdfAsync(Stream destination) for stream output.
    • Static TypstCompiler.CompilePdf(...) and TypstCompiler.CompilePdfFromFile(...) for quick one-line compilations.
    • compiler.CompileSvg(...) and compiler.CompilePng(...) for format-specific image export.
    • outcome.AsPdf() and outcome.PrimaryBuffer on CompileOutcome.
  • Added includeSystemPackages to TypstCompiler. Setting it to false resolves packages from packagePath only, so an import that is not vendored there fails instead of being downloaded from Typst Universe and compilation stays off the network.
  • Added support for compiling Typst documents with multiple PDF standards simultaneously (e.g. v-1.7, a-2b, etc.) by exposing a pdfStandards parameter in the TypstCompiler.Compile API, leveraging the underlying typst-pdf crate updates in Typst 0.15.