Skip to content

feat(react-pdf): support $computed functions and custom directives - #396

Open
Kavishkagaya wants to merge 1 commit into
vercel-labs:mainfrom
Kavishkagaya:feat/react-pdf-functions-directives
Open

Kavishkagaya wants to merge 1 commit into
vercel-labs:mainfrom
Kavishkagaya:feat/react-pdf-functions-directives

Conversation

@Kavishkagaya

Copy link
Copy Markdown

Summary

@json-render/react-pdf built its resolution context with only stateModel, so every $computed expression resolved to undefined and custom directives were left as unresolved objects. This adds functions and directives support, mirroring @json-render/react.

  • VisibilityProvider accepts functions and directives, builds a memoized directive registry with core's createDirectiveRegistry, and puts both in the context
  • JSONUIProvider and createRenderer output accept and forward both props
  • renderToBuffer / renderToStream / renderToFile accept both options and pass them through renderElement, including repeat children

No changes to core or other renderers.

Tests

  • renderer.test.tsx: $computed via JSONUIProvider + Renderer, a custom directive, a directive wrapping $computed, and $computed with $item args per repeat iteration
  • render.test.tsx: the same cases through renderToBuffer

The new tests fail without the fix and pass with it. check-types, lint and the react-pdf/core vitest suites pass.

Docs

  • directives.mdx: lists React PDF among renderers that accept directives
  • api/react-pdf.mdx, package README and skill: document functions / directives
  • docs-baseline.json: refreshed hashes for the two edited pages (pnpm --filter web test:routes passes, 122/122)

The react-pdf resolution context only carried `stateModel`, so every
`$computed` expression resolved to undefined and custom directives were
left as unresolved objects.

- VisibilityProvider accepts `functions` and `directives` and adds them
  (directives as a memoized registry) to the resolution context
- JSONUIProvider and createRenderer output forward both props
- renderToBuffer/renderToStream/renderToFile accept both options and
  thread them through renderElement, including repeat children
- Docs: list react-pdf among renderers that accept `directives`, and
  document the new options

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZtZvDfKrHFRWTuTqwNq26
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@Kavishkagaya is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant