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.
Files changed (102) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/README.md +874 -795
  3. package/dist/assets.d.ts +4 -2
  4. package/dist/assets.d.ts.map +1 -1
  5. package/dist/assets.js +22 -1
  6. package/dist/assets.js.map +1 -1
  7. package/dist/benchmarks/corpora.d.ts +11 -0
  8. package/dist/benchmarks/corpora.d.ts.map +1 -0
  9. package/dist/benchmarks/corpora.js +228 -0
  10. package/dist/benchmarks/corpora.js.map +1 -0
  11. package/dist/builder.d.ts +10 -2
  12. package/dist/builder.d.ts.map +1 -1
  13. package/dist/builder.js +12 -4
  14. package/dist/builder.js.map +1 -1
  15. package/dist/cli.js +19 -19
  16. package/dist/element-types.d.ts +16 -0
  17. package/dist/element-types.d.ts.map +1 -0
  18. package/dist/element-types.js +16 -0
  19. package/dist/element-types.js.map +1 -0
  20. package/dist/errors.d.ts +8 -1
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +4 -0
  23. package/dist/errors.js.map +1 -1
  24. package/dist/fonts.d.ts +2 -1
  25. package/dist/fonts.d.ts.map +1 -1
  26. package/dist/fonts.js.map +1 -1
  27. package/dist/index.d.ts +21 -17
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +25 -309
  30. package/dist/index.js.map +1 -1
  31. package/dist/layout-state.d.ts +39 -0
  32. package/dist/layout-state.d.ts.map +1 -0
  33. package/dist/layout-state.js +46 -0
  34. package/dist/layout-state.js.map +1 -0
  35. package/dist/measure-blocks.d.ts +2 -1
  36. package/dist/measure-blocks.d.ts.map +1 -1
  37. package/dist/measure-blocks.js.map +1 -1
  38. package/dist/measure.d.ts +4 -2
  39. package/dist/measure.d.ts.map +1 -1
  40. package/dist/measure.js +15 -5
  41. package/dist/measure.js.map +1 -1
  42. package/dist/page-sizes.d.ts +1 -0
  43. package/dist/page-sizes.d.ts.map +1 -1
  44. package/dist/page-sizes.js.map +1 -1
  45. package/dist/paginate.d.ts +1 -1
  46. package/dist/paginate.d.ts.map +1 -1
  47. package/dist/paginate.js +11 -2
  48. package/dist/paginate.js.map +1 -1
  49. package/dist/pipeline-footnotes.d.ts +18 -0
  50. package/dist/pipeline-footnotes.d.ts.map +1 -0
  51. package/dist/pipeline-footnotes.js +98 -0
  52. package/dist/pipeline-footnotes.js.map +1 -0
  53. package/dist/pipeline-toc.d.ts +11 -0
  54. package/dist/pipeline-toc.d.ts.map +1 -0
  55. package/dist/pipeline-toc.js +28 -0
  56. package/dist/pipeline-toc.js.map +1 -0
  57. package/dist/pipeline.d.ts +24 -0
  58. package/dist/pipeline.d.ts.map +1 -0
  59. package/dist/pipeline.js +116 -0
  60. package/dist/pipeline.js.map +1 -0
  61. package/dist/plugin-registry.d.ts +40 -0
  62. package/dist/plugin-registry.d.ts.map +1 -0
  63. package/dist/plugin-registry.js +104 -0
  64. package/dist/plugin-registry.js.map +1 -0
  65. package/dist/plugin-types.d.ts +185 -0
  66. package/dist/plugin-types.d.ts.map +1 -0
  67. package/dist/plugin-types.js +27 -0
  68. package/dist/plugin-types.js.map +1 -0
  69. package/dist/post-process.d.ts +16 -0
  70. package/dist/post-process.d.ts.map +1 -0
  71. package/dist/post-process.js +80 -0
  72. package/dist/post-process.js.map +1 -0
  73. package/dist/render-blocks.d.ts +2 -1
  74. package/dist/render-blocks.d.ts.map +1 -1
  75. package/dist/render-blocks.js.map +1 -1
  76. package/dist/render-extras.d.ts +2 -2
  77. package/dist/render-extras.d.ts.map +1 -1
  78. package/dist/render-extras.js.map +1 -1
  79. package/dist/render.d.ts +4 -2
  80. package/dist/render.d.ts.map +1 -1
  81. package/dist/render.js +23 -4
  82. package/dist/render.js.map +1 -1
  83. package/dist/types-internal.d.ts +302 -0
  84. package/dist/types-internal.d.ts.map +1 -0
  85. package/dist/types-internal.js +9 -0
  86. package/dist/types-internal.js.map +1 -0
  87. package/dist/types-public.d.ts +1031 -0
  88. package/dist/types-public.d.ts.map +1 -0
  89. package/dist/types-public.js +2 -0
  90. package/dist/types-public.js.map +1 -0
  91. package/dist/types.d.ts +6 -1224
  92. package/dist/types.d.ts.map +1 -1
  93. package/dist/types.js +7 -0
  94. package/dist/types.js.map +1 -1
  95. package/dist/validate.d.ts +6 -4
  96. package/dist/validate.d.ts.map +1 -1
  97. package/dist/validate.js +35 -4
  98. package/dist/validate.js.map +1 -1
  99. package/package.json +192 -184
  100. package/docs/screenshots/showcase-invoice.png +0 -0
  101. package/docs/screenshots/showcase-report.png +0 -0
  102. 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.