fix(typst-preview): use RenderByContentOptions to avoid Rust aliasing
Build and Deploy Verso / deploy (push) Successful in 10m35s
Build and Deploy Verso / deploy (push) Successful in 10m35s
Replace runWithSession + manipulateData + session.renderToSvg with the
direct RenderByContentOptions form: renderer.renderToSvg({ format: 'vector',
artifactContent, container }).
The session-based API kept hitting 'recursive use of an object detected
which would lead to unsafe aliasing in rust' because runWithSession holds
a mutable borrow of the session while renderToSvg also takes one —
regardless of whether you call renderer.renderToSvg({ renderSession }) or
session.renderToSvg(). The content-based form creates and disposes the
session internally without any caller-visible borrow.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -71,11 +71,12 @@ const TypstWasmPreview: FC = () => {
|
|||||||
dataToRender = null
|
dataToRender = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await renderer.runWithSession(async session => {
|
// Use RenderByContentOptions: pass artifactContent directly instead of
|
||||||
session.manipulateData({ action: 'reset', data })
|
// using runWithSession + manipulateData, which causes Rust aliasing errors
|
||||||
// Use session.renderToSvg (NOT renderer.renderToSvg with renderSession)
|
await renderer.renderToSvg({
|
||||||
// to avoid double-aliasing the same Rust object inside runWithSession
|
format: 'vector',
|
||||||
await session.renderToSvg({ container })
|
artifactContent: data,
|
||||||
|
container,
|
||||||
})
|
})
|
||||||
pendingVectorRef.current = null
|
pendingVectorRef.current = null
|
||||||
setStatus('ready')
|
setStatus('ready')
|
||||||
|
|||||||
Reference in New Issue
Block a user