pretext-pdf 0.9.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -0
- package/README.md +874 -795
- package/dist/assets.d.ts +4 -2
- package/dist/assets.d.ts.map +1 -1
- package/dist/assets.js +22 -1
- package/dist/assets.js.map +1 -1
- package/dist/benchmarks/corpora.d.ts +11 -0
- package/dist/benchmarks/corpora.d.ts.map +1 -0
- package/dist/benchmarks/corpora.js +228 -0
- package/dist/benchmarks/corpora.js.map +1 -0
- package/dist/builder.d.ts +10 -2
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +12 -4
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +19 -19
- package/dist/element-types.d.ts +16 -0
- package/dist/element-types.d.ts.map +1 -0
- package/dist/element-types.js +16 -0
- package/dist/element-types.js.map +1 -0
- package/dist/errors.d.ts +8 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -1
- package/dist/fonts.d.ts +2 -1
- package/dist/fonts.d.ts.map +1 -1
- package/dist/fonts.js.map +1 -1
- package/dist/index.d.ts +21 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -309
- package/dist/index.js.map +1 -1
- package/dist/layout-state.d.ts +39 -0
- package/dist/layout-state.d.ts.map +1 -0
- package/dist/layout-state.js +46 -0
- package/dist/layout-state.js.map +1 -0
- package/dist/measure-blocks.d.ts +2 -1
- package/dist/measure-blocks.d.ts.map +1 -1
- package/dist/measure-blocks.js.map +1 -1
- package/dist/measure.d.ts +4 -2
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +15 -5
- package/dist/measure.js.map +1 -1
- package/dist/page-sizes.d.ts +1 -0
- package/dist/page-sizes.d.ts.map +1 -1
- package/dist/page-sizes.js.map +1 -1
- package/dist/paginate.d.ts +1 -1
- package/dist/paginate.d.ts.map +1 -1
- package/dist/paginate.js +11 -2
- package/dist/paginate.js.map +1 -1
- package/dist/pipeline-footnotes.d.ts +18 -0
- package/dist/pipeline-footnotes.d.ts.map +1 -0
- package/dist/pipeline-footnotes.js +98 -0
- package/dist/pipeline-footnotes.js.map +1 -0
- package/dist/pipeline-toc.d.ts +11 -0
- package/dist/pipeline-toc.d.ts.map +1 -0
- package/dist/pipeline-toc.js +28 -0
- package/dist/pipeline-toc.js.map +1 -0
- package/dist/pipeline.d.ts +24 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +116 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/plugin-registry.d.ts +40 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +104 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/plugin-types.d.ts +185 -0
- package/dist/plugin-types.d.ts.map +1 -0
- package/dist/plugin-types.js +27 -0
- package/dist/plugin-types.js.map +1 -0
- package/dist/post-process.d.ts +16 -0
- package/dist/post-process.d.ts.map +1 -0
- package/dist/post-process.js +80 -0
- package/dist/post-process.js.map +1 -0
- package/dist/render-blocks.d.ts +2 -1
- package/dist/render-blocks.d.ts.map +1 -1
- package/dist/render-blocks.js.map +1 -1
- package/dist/render-extras.d.ts +2 -2
- package/dist/render-extras.d.ts.map +1 -1
- package/dist/render-extras.js.map +1 -1
- package/dist/render.d.ts +4 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +23 -4
- package/dist/render.js.map +1 -1
- package/dist/types-internal.d.ts +302 -0
- package/dist/types-internal.d.ts.map +1 -0
- package/dist/types-internal.js +9 -0
- package/dist/types-internal.js.map +1 -0
- package/dist/types-public.d.ts +1031 -0
- package/dist/types-public.d.ts.map +1 -0
- package/dist/types-public.js +2 -0
- package/dist/types-public.js.map +1 -0
- package/dist/types.d.ts +6 -1224
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -1
- package/dist/validate.d.ts +6 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +35 -4
- package/dist/validate.js.map +1 -1
- package/package.json +192 -184
- package/docs/screenshots/showcase-invoice.png +0 -0
- package/docs/screenshots/showcase-report.png +0 -0
- package/docs/screenshots/showcase-resume.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,105 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/)
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.0.0] — 2026-05-02
|
|
11
|
+
|
|
12
|
+
First stable release. Completes the plugin extension API, closes all v1.0 gate requirements,
|
|
13
|
+
and ships a fully verified public surface with zero breaking changes from 0.9.x.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **Plugin extension API** — Register custom element types via `RenderOptions.plugins`.
|
|
18
|
+
Each `PluginDefinition` participates in all four pipeline stages: `validate`, `loadAsset`,
|
|
19
|
+
`measure`, and `render`. Plugins are fully typed and tree-shaken from documents
|
|
20
|
+
that don't use them. See README § Custom element types (plugins) and
|
|
21
|
+
`examples/plugin-custom-element.ts` for a runnable example.
|
|
22
|
+
- **`PluginDefinition`, `PluginMeasureContext`, `PluginMeasureResult`, `PluginRenderContext`**
|
|
23
|
+
exported from `pretext-pdf` public surface (previously internal).
|
|
24
|
+
- **`PdfBuilder` and `PdfBuilderOptions`** exported from `pretext-pdf` (enables type-safe
|
|
25
|
+
builder construction in downstream code without re-declaring the interface).
|
|
26
|
+
- **`TocEntryElement`** exported from `pretext-pdf` public surface (was in the `ContentElement`
|
|
27
|
+
union but not individually importable).
|
|
28
|
+
- **`plugins` option on `createPdf()`** — `PdfBuilderOptions.plugins` threads plugins through
|
|
29
|
+
the builder's `build()` call automatically.
|
|
30
|
+
- **`Intl.Segmenter` pre-flight guard** in `render()` — throws `RENDER_FAILED` with a clear
|
|
31
|
+
message on Node.js < 16 or runtimes without full-ICU data, instead of silently producing
|
|
32
|
+
incorrect line breaks.
|
|
33
|
+
- **`PluginRenderContext.pageWidth/pageHeight/margins`** — render hooks now receive full page
|
|
34
|
+
geometry for layout calculations (page-relative positioning, bleed boxes, etc.).
|
|
35
|
+
- **`render` context Y-coordinate docs** — expanded JSDoc with multi-line text example showing
|
|
36
|
+
how to position text baselines relative to `context.y`.
|
|
37
|
+
- **Benchmark corpora manifest** and **smoke staging** tests wired into `npm test`
|
|
38
|
+
(previously orphaned). Total test count: 672.
|
|
39
|
+
- `examples/plugin-custom-element.ts` — runnable plugin example (`npm run example:plugin`).
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **`SIGNATURE_CERT_AND_ENCRYPTION` error code** — was declared in the `ErrorCode` union
|
|
44
|
+
but never thrown; validate.ts now uses it correctly when a document specifies both
|
|
45
|
+
signatures and encryption (previously threw a generic `VALIDATION_ERROR`).
|
|
46
|
+
- **Build break under `exactOptionalPropertyTypes: true`** — `PdfBuilder.build()` no longer
|
|
47
|
+
passes `{ plugins: undefined }` to `runPipeline` when no plugins are configured.
|
|
48
|
+
- **Plugin `validate` hook empty-string normalization** — `plugin.validate()` returning `''`
|
|
49
|
+
now correctly accepts the element (was previously treated as a rejection message).
|
|
50
|
+
- **`toc` element reaching render default arm** — `render.ts` now has an explicit
|
|
51
|
+
`case 'toc': return` guard before the default arm; TOC elements are pre-processed
|
|
52
|
+
during pagination and should never reach the renderer.
|
|
53
|
+
- **`RichLine` and `RichFragment`** demoted from `@public` to `@internal`; these are
|
|
54
|
+
implementation details of the rich-text pipeline, not intended for external use.
|
|
55
|
+
- **Sentinel value documentation** — `MeasuredBlock` comment now explicitly states that
|
|
56
|
+
`lines: []`, `fontSize: 0`, `lineHeight: 0`, `fontKey: ''` applies to spacers, tables,
|
|
57
|
+
images, hr, *and plugin blocks* — not a bug but a documented convention.
|
|
58
|
+
|
|
59
|
+
### Internal
|
|
60
|
+
|
|
61
|
+
- `src/plugin-registry.ts` (new): Pure orchestration helpers for the four plugin injection
|
|
62
|
+
points (`findPlugin`, `runPluginValidate`, `runPluginLoadAsset`, `runPluginMeasure`,
|
|
63
|
+
`runPluginRender`).
|
|
64
|
+
- `src/plugin-types.ts` (new): `PluginDefinition` interface and context/result types.
|
|
65
|
+
- `src/layout-state.ts`: `prepareLayoutState` now accepts `options?: RenderOptions` and
|
|
66
|
+
threads plugins to `stageValidate`, `stageLoadAssets`, and `stageMeasure`.
|
|
67
|
+
- `docs/V1.0-RUNBOOK.md`: Full release runbook with first-principles audit, anti-hallucination
|
|
68
|
+
protocol, verified-facts table, and phase-by-phase plan.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## [0.9.4] — 2026-05-02
|
|
73
|
+
|
|
74
|
+
Architecture hardening + API surface snapshot. No public API changes; internal
|
|
75
|
+
restructuring to eliminate circular dependencies and add drift guards before v1.0 freeze.
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- **API surface snapshot** (`etc/pretext-pdf.api.md`) checked into source control as
|
|
80
|
+
the v1.0 baseline. The `api:check` CI step will fail on unintentional public-API drift.
|
|
81
|
+
- **`src/layout-state.ts`** — `prepareLayoutState()` and `summarizeLayoutState()` extracted
|
|
82
|
+
from the pipeline for testability; `layout-contract` and `hard-text-contract` tests
|
|
83
|
+
wired into `test:unit`.
|
|
84
|
+
- **`src/benchmarks/corpora.ts`** — benchmark corpus manifest (`getBenchmarkCorpora()`)
|
|
85
|
+
restored from git history; `benchmark-baseline.test.ts` wired into `test:contract`.
|
|
86
|
+
- **Drift guards** (`test/drift-guards.test.ts`) — asserts that `ELEMENT_TYPES`,
|
|
87
|
+
`ALLOWED_PROPS`, `validate.ts` cases, and `render.ts` cases all agree at test time.
|
|
88
|
+
Catches any future element-type addition that isn't plumbed through all four places.
|
|
89
|
+
- **`render.ts` default arm** — unknown element types now throw immediately instead of
|
|
90
|
+
silently producing a blank block.
|
|
91
|
+
|
|
92
|
+
### Refactored
|
|
93
|
+
|
|
94
|
+
- **Circular dependency broken**: `src/post-process.ts` extracted so `builder.ts` and
|
|
95
|
+
`index.ts` no longer form a cycle through each other.
|
|
96
|
+
- **`ELEMENT_TYPES` extracted** to `src/element-types.ts` as single source of truth;
|
|
97
|
+
re-exported from `index.ts`, imported by `validate.ts` — eliminates the previous
|
|
98
|
+
per-file string-literal duplication.
|
|
99
|
+
|
|
100
|
+
### Fixed
|
|
101
|
+
|
|
102
|
+
- `post-process.ts`: drop raw signing library error message from `SIGNATURE_FAILED`
|
|
103
|
+
to avoid leaking certificate or passphrase details in error output.
|
|
104
|
+
- `layout-state.ts`: polyfill install wrapped in try/catch; throws `CANVAS_UNAVAILABLE`
|
|
105
|
+
on failure instead of an untyped exception.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
10
109
|
## [0.9.3] — 2026-04-23
|
|
11
110
|
|
|
12
111
|
Strict validation release. Opt-in property validation to catch unknown properties on elements and sub-structures via typo detection and precise JSONPath error reporting.
|