v0.2.0 — The declarative renderer + a token-frugal agent authoring layer#10
Merged
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
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.
v0.2.0 — The declarative renderer + a token-frugal agent authoring layer
Summary
v0.2.0 is the first functional release of pdfnative-react — the declarative
React renderer for the
pdfnativePDF engine. JSX compiles, via a custom React reconciler, into a
pdfnativeDocumentParamsobject and renders real PDF bytes — no DOM, no headlessbrowser, no native modules. Three themes, one release:
(
Document,Page,Heading,Paragraph/Text,List/Item,Table/Row/Cell,Image,Link,Spacer,PageBreak,TableOfContents/Toc,Barcode,Svg,FormField), four render targets(
renderToBytes/Blob/Stream/File+compileDocument), client hooks(
usePdf,usePdfStream) and preview components (PDFViewer,PDFDownloadLink,BlobProvider).DocSpecgrammar that lets autonomous AI agents emit documents with several times
fewer tokens than JSX, and compiles to the same PDF because it is built
on the very same components. No MCP server (that is
pdfnative-mcp), no daemon, nonew runtime dependency — just a grammar + a versioned JSON Schema.
samples/tree covering every capability, a CycloneDX SBOM attached to eachrelease, and provenance-signed npm publishes (OIDC Trusted Publishing).
Changes
New:
src/spec/(token-frugal agent authoring)types.ts— theDocSpecgrammar: block tuples[kind, …payload, opts?]whose per-block opts types are derived from the component prop interfaces
(via
Pick/Omit) so the spec inherits the components' type safety and cannever drift.
TableRowSpecaccepts astring[](widened to{ cells, type:'default', pointed:false }) or a fullPdfRow.compile.ts—blockToElementprojects each tuple onto the existingcomponents via
createElement;specToElement(spec)builds the<Document>tree;
compileSpec+renderSpecToBytes/Blob/Stream/Filereuse theisomorphic
render*pipeline. Parity is guaranteed by construction.schema.ts—docSpecSchema()returns a Draft 2020-12 JSON Schema whose$id(https://pdfnative.dev/schema/react/<version>/doc-spec.schema.json)embeds the package version;
docSpecSchemaId()returns it. Pure data.index.ts— spec barrel.New:
src/version.tsimport cycle between the barrel and the schema).
tests/version.test.tspinsit to
package.json.src/index.tscompileSpec,specToElement,renderSpec*,docSpecSchema,docSpecSchemaId, and theDocSpec/BlockSpectypes) andnow sources
versionfromsrc/version.ts.New:
samples/text/typography,table/data-table,media/{image,link,barcode,svg},forms/form-fields,structure/sections,fonts/custom-fonts,layout/page-setup(PDF/A-2b),client/{use-pdf,viewer}('use client'),and
agent/{compact-spec,schema}— plus the originalinvoice/report.Every runnable sample produces a valid PDF.
samples/tsconfig.json+ a newtypecheck:samplesscript folded intotypecheck:allso the samples are a CI gate.samples/README.mdindexes them.(Replaces the old root
tsconfig.samples.json.)New: tests
tests/spec.test.tsx— assertscompileSpectoEqualthe equivalent JSXcompileDocument,ol→numbered /ul→bullet,PdfRowobjects alongsidestring arrays,
['page', …]grouping, all media/link/svg/field/img blocks,h1/h2/h3and all five barcode formats, realrenderSpec*PDF output(
%PDF-…%%EOF),renderSpecToFile, and the schema$id/version.tests/version.test.ts— pinsversiontopackage.json(reads it viaprocess.cwd(); animport.meta.urlfile URL breaks under jsdom).Docs & governance
README.md— full 0.2.0 rewrite (components/render/hooks tables, a migrationtable from
@react-pdf/renderer, a "Agent authoring (token-frugal)"section, a samples index, and an OpenSSF Scorecard badge).
docs/KNOWLEDGE_BASE.md— new §7 Agent authoring contract (parity rules,the versioned schema, the
createElementdefault-param gotcha).AGENTS.md—src/spec//src/version.ts/samples/in the layout table, agolden rule to keep
DocSpec↔JSX in parity, and a token-frugal authoring note.CHANGELOG.md,release-notes/v0.2.0.md,ROADMAP.md— DocSpec, schema,samples, and SBOM entries.
CITATION.cff+package.jsonkeywords(
ai-agent,agentic,json-schema,sbom,supply-chain).llms.txt—the compact-spec grammar.
.github/instructions/spec.instructions.md—applyTo: src/spec/**authoringcontract (parity-by-construction, no
'use client', versioned$id)..github/workflows/publish.yml— SHA-pinned actions,timeout-minutes: 20,contents: write+id-token: write, verify-dist + import smoke test, andCycloneDX SBOM generate→upload→attach.
ci.yml—typecheck:allnow coverssamples; sample changes trigger CI.
Validation
npm run typecheck:all→ clean (src + tests + samples).npm run lint→ clean.npx vitest run --coverage→ 46 / 46 passing; thresholds met — statements94.29 %, branches 84.61 %, functions 97.7 %, lines 95.73 %.
npm run build→ CJS 26.25 KB, ESM 24.64 KB, types 27.12 KB(
.d.ts+.d.cts).npm pack --dry-run→pdfnative-react-0.2.0.tgz, 9 files, 69.5 kB(README + dist + types only).
require('./dist/index.cjs')exposesrenderToBytes,renderSpecToBytes,docSpecSchema,version === '0.2.0'; the ESM importresolves the same surface. All 12 runnable samples emit valid PDFs.
Backward compatibility
is no prior surface to break.
DocSpeclayer and the schema are new exports; the component/render/hook surface is
unchanged.
versionmoving tosrc/version.tsis internal (the exportedvalue is identical).
Out of scope (by design)
pdfnative-mcpserver; thispackage stays a library.
pdfnativeremains the only one; the SBOMgenerator is CI-only.
<View>— pdfnative is a declarative block flow by design.dual-support costly to do correctly).
Self-review checklist
src/core-bridge/index.tsimportspdfnative; the spec layer reusesthe existing components/render pipeline (no new engine surface).
<View>introduced; block kinds map 1:1 onto pdfnative.DocSpec↔ JSX parity is asserted (compileSpectoEqualcompileDocument) and guaranteed by construction.'use client';renderSpec*reuse the isomorphic
render*entry points.$idis derived fromsrc/version.ts, which a test pins topackage.json.any;type-only imports; ESM-first.jsimports.pdfnativeis still the only runtime dependency (SBOM generator is CI-only).typecheck:all(incl.samples), lint, build, and
npm pack --dry-runall clean.