Skip to content

Improve 0.3 document validation, bundled types and developer tooling - #2952

Open
marcelMaier wants to merge 2 commits into
bpampuch:masterfrom
marcelMaier:improve/docs-tooling-ci
Open

marcelMaier wants to merge 2 commits into
bpampuch:masterfrom
marcelMaier:improve/docs-tooling-ci

Conversation

@marcelMaier

@marcelMaier marcelMaier commented Oct 20, 2026 •

Copy link
Copy Markdown

Document authoring currently spans loosely connected runtime errors, external type declarations and an outdated standalone playground. This change brings the 0.3 authoring workflow together while retaining the JavaScript runtime and existing Promise-based API.

Changes

  • Ship MIT-attributed TypeScript declarations with separate Node/browser APIs and typed package, browser-bundle, VFS and font entry points. Consumers no longer need @types/pdfmake with this build.
  • Add validateDocument(input, options) with accumulated diagnostics, document paths, strict handling of unknown properties, table/span and reference checks, numeric constraints, cycle/accessor checks and bounded traversal. The structural contract is generated from the shipped declarations and checked for drift.
  • Add opt-in createPdf(definition, { validation: true }) preflight. Dynamic callback results, resource decoding/access and final layout remain rendering checks; preflight does not mutate input or execute callbacks.
  • Report malformed-node paths and reliably reject interrupted output streams. Replace repeated array concatenation in text flattening with a linear traversal, backed by regression tests and a comparison benchmark.
  • Rebuild the standalone playground with CodeMirror, local PDF preview, editable JavaScript/TypeScript, live updates, undo/redo, persisted workspaces, named saves and import/export.
  • Update build dependencies and portable build tasks, add lockfiles, and check actual packed consumers in CI and the release workflow. Rewrite the README and add contributor source guidance.

Compatibility

The runtime remains CommonJS in Node and UMD in the browser, with Node ESM default imports tested through interop. This does not introduce a second native-ESM runtime. Node remains supported from version 20; development-tool minimums are documented separately. Definitions are still processed during layout, so callers should construct fresh definitions for independent generation.

This branch now tracks upstream 0.3.13 and current master, including the follow-up fix for reversed lists with nested lists. The version change comes from upstream; bundled declarations, preflight and structured diagnostics remain unreleased additions for maintainer review.

Upstream 0.3.13 compatibility

  • Preserve upstream stream-consumption tracking and buffered write() reuse alongside the additional premature-close diagnostics.
  • Carry the React Native ICC-profile URL fix through a small build loader, without reintroducing the removed string-replacement dependency.
  • Include tableAlignment: 'left' | 'center' | 'right' in bundled types and the generated validation contract, with positive and negative regression cases.
  • Refresh affected development dependency lockfile entries; audits remain clear after a clean install.

Validation

Locally verified on Windows:

  • All 651 library tests on Node 20.20.2 and Node 24.15.0; ESLint passed.
  • Strict TypeScript 5.9.3 consumers installed from the actual npm tarball, without @types/pdfmake: CommonJS, Node ESM, browser bundling, negative assertions, font/VFS imports and real PDF output.
  • Production-only tarball smoke tests for Node file/buffer output and both browser bundles, including preflight, buffer-to-file reuse, consumed-stream rejection and browser initialization with a React-Native-style URL implementation.
  • All 32 library examples generated successfully; standalone playground build passed.
  • Library, production-only and playground dependency audits reported zero findings.

The workflow prepares a Linux/macOS/Windows and Node 20/22/24 matrix; that hosted matrix has not been run locally.

Companion documentation pull request: pdfmake/docs#25

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