@lupinum/nuxt-pdf 0.4.0-beta.4 → 0.4.0-beta.6
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 +18 -0
- package/CONFORMANCE.md +4 -4
- package/README.md +54 -12
- package/dist/agent/AGENTS.md +44 -0
- package/dist/agent/pages/docs/examples/supported-behavior.md +75 -0
- package/dist/agent/pages/docs/examples.md +163 -0
- package/dist/agent/pages/docs/getting-started/installation.md +75 -0
- package/dist/agent/pages/docs/getting-started/quickstart.md +126 -0
- package/dist/agent/pages/docs/getting-started.md +63 -0
- package/dist/agent/pages/docs/guides/contents-links-bookmarks.md +123 -0
- package/dist/agent/pages/docs/guides/deployment.md +118 -0
- package/dist/agent/pages/docs/guides/errors-and-debugging.md +90 -0
- package/dist/agent/pages/docs/guides/images-and-fonts.md +102 -0
- package/dist/agent/pages/docs/guides/recipes.md +258 -0
- package/dist/agent/pages/docs/guides/remote-images.md +72 -0
- package/dist/agent/pages/docs/guides/reusable-components.md +81 -0
- package/dist/agent/pages/docs/guides/standalone-node.md +107 -0
- package/dist/agent/pages/docs/guides/svg-graphics.md +165 -0
- package/dist/agent/pages/docs/guides/testing.md +119 -0
- package/dist/agent/pages/docs/learn/document-tree.md +91 -0
- package/dist/agent/pages/docs/learn/runtime-and-data.md +63 -0
- package/dist/agent/pages/docs/learn/styling-and-layout.md +79 -0
- package/dist/agent/pages/docs/learn/templates-and-registry.md +96 -0
- package/dist/agent/pages/docs/reference/composables.md +55 -0
- package/dist/agent/pages/docs/reference/define-pdf.md +96 -0
- package/dist/agent/pages/docs/reference/errors-and-limits.md +89 -0
- package/dist/agent/pages/docs/reference/module-options.md +104 -0
- package/dist/agent/pages/docs/reference/page-sizes.md +54 -0
- package/dist/agent/pages/docs/reference/primitives.md +216 -0
- package/dist/agent/pages/docs/reference/registry.md +185 -0
- package/dist/agent/pages/docs/reference/standalone.md +53 -0
- package/dist/agent/pages/docs/reference/styles.md +176 -0
- package/dist/agent/pages/docs/reference/test-utilities.md +128 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/test.mjs +13 -1
- package/package.json +27 -48
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Styles"
|
|
3
|
+
description: "Accepted style keys, values, units, inheritance, and primitive support."
|
|
4
|
+
url: "https://nuxt-pdf.lupinum.com/docs/reference/styles"
|
|
5
|
+
route: "/docs/reference/styles"
|
|
6
|
+
locale: "en"
|
|
7
|
+
section: "Documentation"
|
|
8
|
+
collection: "docs"
|
|
9
|
+
source: "ginko-content"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Styles
|
|
13
|
+
|
|
14
|
+
> Accepted style keys, values, units, inheritance, and primitive support.
|
|
15
|
+
|
|
16
|
+
`PdfStyle` is Nuxt PDF's framework-owned authoring contract. It
|
|
17
|
+
contains the behavior this package tests and supports; it does not re-export
|
|
18
|
+
the wider upstream stylesheet types and it is not browser CSS.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import type { PdfStyle } from '@lupinum/nuxt-pdf'
|
|
22
|
+
|
|
23
|
+
const pageStyle = {
|
|
24
|
+
color: '#18251d',
|
|
25
|
+
fontFamily: 'Invoice Sans',
|
|
26
|
+
fontSize: 10,
|
|
27
|
+
paddingHorizontal: 48,
|
|
28
|
+
paddingVertical: 40,
|
|
29
|
+
} satisfies PdfStyle
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Use `satisfies`, not a type assertion. It preserves the object's useful
|
|
33
|
+
inferred type while making `vue-tsc` reject unknown keys, invalid enums, and
|
|
34
|
+
unsupported units.
|
|
35
|
+
|
|
36
|
+
`PdfStyle` belongs to page-flow layout and text metrics. SVG paint and geometry
|
|
37
|
+
use direct props: `PdfG` and shapes do not accept `style`, `PdfSvg.style` places
|
|
38
|
+
the SVG root in page flow, and SVG `PdfText.style` controls text metrics while
|
|
39
|
+
its direct `fill` prop controls paint.
|
|
40
|
+
|
|
41
|
+
## Values and units
|
|
42
|
+
|
|
43
|
+
| Type | Accepted values | Notes |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `PdfLength` | A number, or `pt`, `px`, `in`, `mm`, `cm`, `rem`, `vh`, or `vw` (for example `12`, `'12pt'`, `'4mm'`) | A unitless number is a PDF point. `px` uses the page DPI; the default is 72. |
|
|
46
|
+
| `PdfPercentage` | A numeric percentage string such as `'50%'` | Accepted only by properties whose type includes percentages. |
|
|
47
|
+
| Color | A color string such as `'#18251d'`, `'rgb(24, 37, 29)'`, or `'red'` | There are no CSS variables or global cascade. |
|
|
48
|
+
| Enum | One of the literals listed below | Browser-only values are rejected even when a similarly named CSS property exists. |
|
|
49
|
+
|
|
50
|
+
`rem` uses the engine's 18-point base. `vw` and `vh` resolve against the PDF
|
|
51
|
+
page container, not a browser window. Percentages resolve against the relevant
|
|
52
|
+
parent dimension.
|
|
53
|
+
|
|
54
|
+
`em`, `ch`, `ex`, `calc()`, `var()`, container queries, and arbitrary CSS
|
|
55
|
+
strings are not part of the contract.
|
|
56
|
+
|
|
57
|
+
## Dimensions and positioning
|
|
58
|
+
|
|
59
|
+
These keys are valid on page-flow primitives (`PdfPage`, `PdfView`, `PdfText`,
|
|
60
|
+
`PdfImage`, `PdfLink`, and `PdfNote`). `width` and `height` also size `PdfSvg`
|
|
61
|
+
inside page flow.
|
|
62
|
+
|
|
63
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
64
|
+
| --- | --- | --- | --- |
|
|
65
|
+
| `width`, `height` | `PdfLength \| PdfPercentage` | No | Sets the resolved box size. |
|
|
66
|
+
| `minWidth`, `minHeight`, `maxWidth`, `maxHeight` | `PdfLength \| PdfPercentage` | No | Constrains the resolved box size. |
|
|
67
|
+
| `position` | `'relative' \| 'absolute'` | No | Use the component `fixed` prop to repeat content across pages. Browser `fixed` and `static` values are not accepted. |
|
|
68
|
+
| `top`, `right`, `bottom`, `left` | `PdfLength \| PdfPercentage` | No | Offsets a positioned node. |
|
|
69
|
+
|
|
70
|
+
## Flex layout
|
|
71
|
+
|
|
72
|
+
Flex properties primarily belong on `PdfPage` and `PdfView`. Text, links,
|
|
73
|
+
images, notes, and SVGs can be flex items. The engine defaults to a `column`
|
|
74
|
+
direction.
|
|
75
|
+
|
|
76
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| `flexDirection` | `'row' \| 'row-reverse' \| 'column' \| 'column-reverse'` | No | Controls the main axis. The default is `column`. |
|
|
79
|
+
| `flex`, `flexGrow`, `flexShrink` | `number` | No | Controls available-space growth and shrinkage. |
|
|
80
|
+
| `flexBasis` | `PdfLength \| PdfPercentage \| 'auto'` | No | Sets the initial main-axis size. |
|
|
81
|
+
| `flexWrap` | `'nowrap' \| 'wrap' \| 'wrap-reverse'` | No | Controls flex-line wrapping. |
|
|
82
|
+
| `alignItems` | `'flex-start' \| 'flex-end' \| 'center' \| 'stretch' \| 'baseline'` | No | Aligns children on the cross axis. |
|
|
83
|
+
| `justifyContent` | `'flex-start' \| 'flex-end' \| 'center' \| 'space-between' \| 'space-around' \| 'space-evenly'` | No | Distributes children on the main axis. |
|
|
84
|
+
| `gap` | `PdfLength` | No | Adds space between flex children. |
|
|
85
|
+
|
|
86
|
+
There is no grid, browser block layout, floats, selectors, or CSS cascade.
|
|
87
|
+
|
|
88
|
+
## Box model
|
|
89
|
+
|
|
90
|
+
The box model is valid on page-flow primitives. Percentages resolve through
|
|
91
|
+
the engine's PDF layout container, not a browser viewport.
|
|
92
|
+
|
|
93
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `margin`, `marginHorizontal`, `marginVertical`, `marginTop`, `marginRight`, `marginBottom`, `marginLeft` | `PdfLength \| PdfPercentage \| 'auto'` | No | Sets space outside the box. |
|
|
96
|
+
| `padding`, `paddingHorizontal`, `paddingVertical`, `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft` | `PdfLength \| PdfPercentage` | No | Sets space inside the box. Padding does not accept `auto`. |
|
|
97
|
+
|
|
98
|
+
## Borders and paint
|
|
99
|
+
|
|
100
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
101
|
+
| --- | --- | --- | --- |
|
|
102
|
+
| `backgroundColor` | color string | Only through nested `PdfText` runs | Paints the page-flow box background. |
|
|
103
|
+
| `color` | color string | Yes | Sets text color on text-bearing primitives. |
|
|
104
|
+
| `opacity` | `number` | Yes | Sets node opacity. |
|
|
105
|
+
| `borderWidth`, `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` | `PdfLength` | No | Sets all or individual border widths. |
|
|
106
|
+
| `borderColor`, `borderTopColor`, `borderRightColor`, `borderBottomColor`, `borderLeftColor` | color string | No | Sets all or individual border colors. |
|
|
107
|
+
| `borderStyle`, `borderTopStyle`, `borderRightStyle`, `borderBottomStyle`, `borderLeftStyle` | `'solid' \| 'dashed' \| 'dotted'` | No | Sets all or individual border styles. |
|
|
108
|
+
| `borderRadius` | `PdfLength` | No | Page-flow primitives. Percent shorthand is not accepted because the engine requires a resolved number. |
|
|
109
|
+
| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` | `PdfLength \| PdfPercentage` | No | Page-flow primitives; edge radii are resolved independently. |
|
|
110
|
+
|
|
111
|
+
Full CSS border strings such as `'1px solid red'` are not public authoring
|
|
112
|
+
syntax. Use the explicit width, style, and color keys so invalid values remain
|
|
113
|
+
type-checkable.
|
|
114
|
+
|
|
115
|
+
## Text
|
|
116
|
+
|
|
117
|
+
Text keys apply to `PdfText` and `PdfLink`. They may be set on ancestor
|
|
118
|
+
`PdfPage`/`PdfView` nodes when the table marks them inherited.
|
|
119
|
+
|
|
120
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
121
|
+
| --- | --- | --- | --- |
|
|
122
|
+
| `fontFamily` | `string` | Yes | Selects one registered family or a built-in engine family. |
|
|
123
|
+
| `fontSize` | `PdfLength` | Yes | Sets glyph size. |
|
|
124
|
+
| `fontStyle` | `'normal' \| 'italic' \| 'oblique'` | Yes | Selects the matching registered face. |
|
|
125
|
+
| `fontWeight` | `number` or `thin`, `hairline`, `ultralight`, `extralight`, `light`, `normal`, `medium`, `semibold`, `demibold`, `bold`, `ultrabold`, `extrabold`, `heavy`, `black` | Yes | Selects the matching registered numeric weight. |
|
|
126
|
+
| `letterSpacing` | `PdfLength` | Yes | Adds space between glyphs and affects wrapping. |
|
|
127
|
+
| `lineHeight` | unitless multiplier, `PdfLength`, or `PdfPercentage` | Yes for static text | Static text supports it. Dynamic `render` text uses font-default line spacing; see [Supported behavior](/raw/docs/examples/supported-behavior.md). |
|
|
128
|
+
| `maxLines` | `number` | No | Limits rendered lines. Use `textOverflow: 'ellipsis'` for an ellipsis. |
|
|
129
|
+
| `textAlign` | `'left' \| 'right' \| 'center' \| 'justify'` | Yes | Aligns text inside its line box. |
|
|
130
|
+
| `textDecoration` | `'none' \| 'underline' \| 'line-through'` or both decoration names separated by a space | Yes | Applies one or both decorations. |
|
|
131
|
+
| `textDecorationColor` | color string | No | `PdfText` and `PdfLink`. |
|
|
132
|
+
| `textDecorationStyle` | `'solid' \| 'dashed' \| 'dotted'` | No | `PdfText` and `PdfLink`. |
|
|
133
|
+
| `textOverflow` | `'ellipsis'` | No | Adds an ellipsis when `maxLines` truncates text. |
|
|
134
|
+
| `textTransform` | `'none' \| 'capitalize' \| 'lowercase' \| 'uppercase'` | Yes | Transforms rendered text casing. |
|
|
135
|
+
|
|
136
|
+
`wordSpacing` is not supported. The pinned text layout pipeline accepts
|
|
137
|
+
the key but does not apply it to glyph advances or wrapping. Nuxt PDF does not
|
|
138
|
+
type a no-op as supported authoring; use `letterSpacing` instead.
|
|
139
|
+
|
|
140
|
+
## Images and transforms
|
|
141
|
+
|
|
142
|
+
| Property | Accepted value | Inherited | Behavior |
|
|
143
|
+
| --- | --- | --- | --- |
|
|
144
|
+
| `objectFit` | `'contain' \| 'cover'` | No | Fits a `PdfImage` inside its resolved box. |
|
|
145
|
+
| `transform` | One to three space-separated `rotate(...)`, `scale(...)`, or `translate(...)` operations | No | Applies to page-flow primitives. Rotate accepts degrees or radians. Translate uses unitless PDF points. SVG transforms remain direct SVG props. |
|
|
146
|
+
|
|
147
|
+
## Style arrays
|
|
148
|
+
|
|
149
|
+
`PdfStyleValue` is either one `PdfStyle` or a recursively nested readonly array.
|
|
150
|
+
Arrays merge left-to-right. `false`, `null`, and `undefined` entries are ignored,
|
|
151
|
+
which makes Vue conditionals direct and type-safe:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import type { PdfStyle, PdfStyleValue } from '@lupinum/nuxt-pdf'
|
|
155
|
+
|
|
156
|
+
const base = { fontSize: 10 } satisfies PdfStyle
|
|
157
|
+
const total = { fontWeight: 700 } satisfies PdfStyle
|
|
158
|
+
|
|
159
|
+
const style = [base, [isTotal && total], null] satisfies PdfStyleValue
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Numbers, strings, `true`, functions, and arbitrary objects are not valid array
|
|
163
|
+
entries.
|
|
164
|
+
|
|
165
|
+
## Exported style types
|
|
166
|
+
|
|
167
|
+
Import these types from `@lupinum/nuxt-pdf`:
|
|
168
|
+
|
|
169
|
+
| Export | Describes |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `PdfStyle` | One style object |
|
|
172
|
+
| `PdfStyleValue` | One style object or a nested style array |
|
|
173
|
+
| `PdfStyleEntry` | One accepted entry in a style array |
|
|
174
|
+
| `PdfLength` | A point number or supported length string |
|
|
175
|
+
| `PdfPercentage` | A numeric percentage string |
|
|
176
|
+
| `PdfLengthOrPercentage` | A supported length or percentage |
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Test utilities"
|
|
3
|
+
description: "The render, parse, assert, and snapshot exports of @lupinum/nuxt-pdf/test."
|
|
4
|
+
url: "https://nuxt-pdf.lupinum.com/docs/reference/test-utilities"
|
|
5
|
+
route: "/docs/reference/test-utilities"
|
|
6
|
+
locale: "en"
|
|
7
|
+
section: "Documentation"
|
|
8
|
+
collection: "docs"
|
|
9
|
+
source: "ginko-content"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Test utilities
|
|
13
|
+
|
|
14
|
+
> The render, parse, assert, and snapshot exports of @lupinum/nuxt-pdf/test.
|
|
15
|
+
|
|
16
|
+
`@lupinum/nuxt-pdf/test` exposes the helpers Nuxt PDF is tested with. They are
|
|
17
|
+
runner-agnostic (they throw `PdfAssertionError`, not Vitest/Jest matchers) and
|
|
18
|
+
load `pdfjs-dist` and `@napi-rs/canvas` lazily. See
|
|
19
|
+
[Testing your PDFs](/raw/docs/guides/testing.md) for a worked example.
|
|
20
|
+
|
|
21
|
+
## renderPdfTemplate
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
const { bytes, parsed } = await renderPdfTemplate(Component, props)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Renders a Vue PDF component through the real registry pipeline, with or without
|
|
28
|
+
a `definePdf` block. Returns the raw `bytes`, immutable `result`, and a `parsed`
|
|
29
|
+
document. Options use the same input shapes as `pdf.remote` and `pdf.limits`, so
|
|
30
|
+
partial limits and URL-prefix allowlists can be shared with `nuxt.config`.
|
|
31
|
+
|
|
32
|
+
Use `renderPdfSfc` when the document depends on discovered local images or
|
|
33
|
+
custom font files. Prepared asset maps, embedded font descriptors, and template
|
|
34
|
+
attribution are registry internals and are not public test configuration.
|
|
35
|
+
|
|
36
|
+
## renderPdfSfc
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const rendered = await renderPdfSfc('./pdfs/invoice.vue', props)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Compiles a real template and its nested child SFCs with the production
|
|
43
|
+
compiler, discovers and validates `pdfs/assets`, and bundles the declared faces
|
|
44
|
+
from `pdfs/fonts`. Its options mirror `pdf.fonts`, `pdf.remote`, and `pdf.limits`;
|
|
45
|
+
the application root and template identity are inferred from the `pdfs/*.vue`
|
|
46
|
+
path. `loadPdfSfc` exposes only the compile step when a test needs the Vue
|
|
47
|
+
component separately.
|
|
48
|
+
|
|
49
|
+
When `fonts` is omitted, the helper reads `pdf.fonts` from the application's
|
|
50
|
+
Nuxt configuration, including its layers. It does not start Nuxt modules or
|
|
51
|
+
load dotenv files. Explicit `fonts` replaces that list; pass `fonts: []` for
|
|
52
|
+
built-in fonts only. Invalid configured fonts fail the test. The helper still
|
|
53
|
+
takes `remote` and `limits` explicitly.
|
|
54
|
+
|
|
55
|
+
## parsePdf
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const parsed = await parsePdf(input)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Accepts PDF bytes (`Uint8Array`/`ArrayBuffer`/`Buffer`) **or** a
|
|
62
|
+
`PdfRenderResult` straight from the `#pdf` registry. Returns page text, page
|
|
63
|
+
count, flattened link annotations (named destination or external URL), and the
|
|
64
|
+
outline hierarchy with its initial expanded/collapsed state.
|
|
65
|
+
|
|
66
|
+
## expectPdf
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
expectPdf(parsed)
|
|
70
|
+
.toHavePageCount(2)
|
|
71
|
+
.toContainText('Invoice for Acme Corp', { page: 1 })
|
|
72
|
+
.toHaveLink({ destination: 'terms', page: 1 })
|
|
73
|
+
.toHaveLink({ url: 'https://example.com/' })
|
|
74
|
+
.toHaveOutline([{ title: 'Terms', expanded: true }])
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A chainable expectation that throws `PdfAssertionError` with an actionable
|
|
78
|
+
message on failure.
|
|
79
|
+
|
|
80
|
+
| Method | Checks |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `toHavePageCount(n)` | Page count equals `n` |
|
|
83
|
+
| `toContainText(text, { page? })` | Extracted text contains `text` |
|
|
84
|
+
| `toHaveLink({ destination?, url?, page? })` | A matching link annotation exists |
|
|
85
|
+
| `toHaveOutline(shape)` | The outline matches the title hierarchy and any requested expansion states |
|
|
86
|
+
|
|
87
|
+
## rasterizePdf and comparePdfSnapshot
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
await comparePdfSnapshot(bytes, './test/baselines/invoice')
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`rasterizePdf` renders pages to PNGs; `comparePdfSnapshot` implements the
|
|
94
|
+
reviewed-baseline flow. It writes per-page baselines when
|
|
95
|
+
`UPDATE_PDF_BASELINES=1` (or `{ update: true }`) and otherwise compares within a
|
|
96
|
+
pixel threshold.
|
|
97
|
+
|
|
98
|
+
`parsePdf` also returns page dimensions and normalized `textRuns` with text,
|
|
99
|
+
position, size, font name, direction, width, and height. Use tolerant numeric
|
|
100
|
+
assertions for geometry because font and raster backends can vary slightly
|
|
101
|
+
between supported environments.
|
|
102
|
+
|
|
103
|
+
When a raster comparison fails, the helper checks every page and writes
|
|
104
|
+
`expected`, `actual`, and `diff` PNGs plus a machine-readable `metrics.json` to
|
|
105
|
+
`reports/pdf-snapshots/<baseline-name>`. Pass `{ artifactDir }` to choose a
|
|
106
|
+
different CI artifact directory.
|
|
107
|
+
|
|
108
|
+
## All exports
|
|
109
|
+
|
|
110
|
+
| Export | Kind | Purpose |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `renderPdfTemplate` | function | Render a component through the real pipeline |
|
|
113
|
+
| `renderPdfSfc` | function | Compile and render a real nested `pdfs/*.vue` graph |
|
|
114
|
+
| `loadPdfSfc` | function | Compile a PDF SFC graph into a Vue component |
|
|
115
|
+
| `parsePdf` | function | Parse bytes or a render result into a `ParsedPdf` |
|
|
116
|
+
| `rasterizePdf` | function | Render pages to PNG images |
|
|
117
|
+
| `comparePdfSnapshot` | function | Reviewed-baseline raster comparison |
|
|
118
|
+
| `toPdfBytes` | function | Normalize inputs to PDF bytes |
|
|
119
|
+
| `expectPdf` | function | Fluent, runner-agnostic assertions |
|
|
120
|
+
| `PdfAssertionError` | class | Thrown by assertions on failure |
|
|
121
|
+
| `PdfComponentProps`, `RenderedPdfTemplate`, `RenderPdfTemplateOptions`, `RenderPdfSfcOptions` | types | Typed component props and render results/options |
|
|
122
|
+
| `ParsedPdf`, `ParsedPdfPage`, `ParsedPdfTextRun`, `ParsedPdfLink`, `PdfOutlineItem`, `PdfInput`, `PdfPageImage` | types | Parsed PDF structures |
|
|
123
|
+
| `PdfExpectation`, `LinkQuery`, `OutlineShape`, `ToContainTextOptions` | types | Assertion inputs and chain type |
|
|
124
|
+
| `RasterizePdfOptions`, `ComparePdfSnapshotOptions`, `PdfSnapshotResult` | types | Raster and snapshot options/results |
|
|
125
|
+
|
|
126
|
+
`pdfjs-dist` and `@napi-rs/canvas` are optional peer dependencies; install them
|
|
127
|
+
in the project under test. They are absent from the module's production
|
|
128
|
+
dependency graph.
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import 'unimport';
|
|
|
16
16
|
import '../dist/runtime/shared/template.js';
|
|
17
17
|
import '../dist/runtime/server/assets/resolve-asset.js';
|
|
18
18
|
|
|
19
|
-
const version = "0.4.0-beta.
|
|
19
|
+
const version = "0.4.0-beta.6";
|
|
20
20
|
|
|
21
21
|
const existingDirectories = async (directories) => {
|
|
22
22
|
const result = [];
|
package/dist/test.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { mkdir, writeFile, rm, readFile, readdir } from 'node:fs/promises';
|
|
|
10
10
|
import { resolve, dirname, join, relative, basename } from 'node:path';
|
|
11
11
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
12
12
|
import { build } from 'esbuild';
|
|
13
|
+
import { loadNuxtConfig } from '@nuxt/kit';
|
|
13
14
|
import { t as templateKeyFromRelativePath, a as discoverPdfImageFiles, b as bundlePdfFonts, c as compilePdfSfc } from './shared/nuxt-pdf.C-E8MM_K.mjs';
|
|
14
15
|
import { pdfImageFormatFromKey } from '../dist/runtime/server/assets/resolve-asset.js';
|
|
15
16
|
import '@vue/compiler-sfc';
|
|
@@ -571,10 +572,21 @@ async function renderPdfSfc(filename, props, options = {}) {
|
|
|
571
572
|
throw new Error(`PDF SFC ${JSON.stringify(entry)} must be a template directly inside pdfs/ or one of its feature directories.`);
|
|
572
573
|
}
|
|
573
574
|
const normalizedLimits = normalizePdfLimits(options.limits);
|
|
575
|
+
const config = options.fonts === void 0 ? await loadNuxtConfig({ cwd: rootDir, dotenv: false, globalRc: false }) : void 0;
|
|
576
|
+
const pdfConfig = config && "pdf" in config ? config.pdf : void 0;
|
|
577
|
+
if (pdfConfig !== void 0 && (typeof pdfConfig !== "object" || pdfConfig === null || Array.isArray(pdfConfig))) {
|
|
578
|
+
throw new TypeError("pdf configuration must be an object.");
|
|
579
|
+
}
|
|
580
|
+
const configuredFonts = pdfConfig && "fonts" in pdfConfig ? pdfConfig.fonts : void 0;
|
|
581
|
+
const declaredFonts = options.fonts ?? (configuredFonts === void 0 ? [] : configuredFonts);
|
|
582
|
+
if (!Array.isArray(declaredFonts)) {
|
|
583
|
+
throw new TypeError("pdf.fonts must be an array of local font declarations.");
|
|
584
|
+
}
|
|
585
|
+
const fontRoots = (config?._layers.map((layer) => layer.config.rootDir || layer.cwd) ?? [rootDir]).map((directory) => join(directory, "pdfs", "fonts")).filter((directory) => existsSync(directory));
|
|
574
586
|
const [component, imageFiles, fonts] = await Promise.all([
|
|
575
587
|
loadPdfSfc(entry),
|
|
576
588
|
discoverPdfImageFiles([{ name: "test", rootDir }]),
|
|
577
|
-
bundlePdfFonts(
|
|
589
|
+
bundlePdfFonts(declaredFonts, { fontRoots })
|
|
578
590
|
]);
|
|
579
591
|
const assets = Object.fromEntries(imageFiles.map((image) => [
|
|
580
592
|
image.key,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lupinum/nuxt-pdf",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.6",
|
|
4
4
|
"description": "Author and render PDFs with Vue components in Nuxt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Lupinum OG <info@lupinum.com> (https://lupinum.com)",
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"packageManager": "pnpm@11.21.0",
|
|
23
22
|
"type": "module",
|
|
24
23
|
"sideEffects": false,
|
|
25
24
|
"exports": {
|
|
@@ -38,7 +37,8 @@
|
|
|
38
37
|
"./server": {
|
|
39
38
|
"types": "./dist/server.d.mts",
|
|
40
39
|
"import": "./dist/server.mjs"
|
|
41
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"./agent-docs": "./dist/agent/AGENTS.md"
|
|
42
42
|
},
|
|
43
43
|
"main": "./dist/module.mjs",
|
|
44
44
|
"types": "./dist/types.d.mts",
|
|
@@ -55,49 +55,6 @@
|
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": "^22.14.0 || ^24.0.0 || ^26.0.0"
|
|
57
57
|
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"prepack": "pnpm build",
|
|
60
|
-
"prepublishOnly": "node scripts/block-source-publish.mjs",
|
|
61
|
-
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
62
|
-
"dev:build": "nuxt build playground",
|
|
63
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
64
|
-
"build": "nuxt prepare && nuxt-module-build build",
|
|
65
|
-
"api:write": "node scripts/check-api-report.mjs --write",
|
|
66
|
-
"changelog": "changelogen --no-output",
|
|
67
|
-
"docs:build": "pnpm docs:theme && pnpm build && pnpm --dir docs build",
|
|
68
|
-
"docs:build:vercel": "node scripts/build-docs-vercel.mjs",
|
|
69
|
-
"docs:dev": "pnpm --dir docs dev",
|
|
70
|
-
"docs:theme": "node scripts/check-docs-theme.mjs",
|
|
71
|
-
"format": "eslint . --fix",
|
|
72
|
-
"format:check": "eslint .",
|
|
73
|
-
"lint": "eslint .",
|
|
74
|
-
"test": "pnpm test:prepare && vitest run",
|
|
75
|
-
"test:api": "node scripts/check-api-report.mjs",
|
|
76
|
-
"release:notes": "node scripts/write-release-notes.mjs",
|
|
77
|
-
"release:pack": "pnpm build && node scripts/check-release-artifact.mjs release-artifacts",
|
|
78
|
-
"release:prepare": "changelogen --bump --clean",
|
|
79
|
-
"release:verify": "pnpm check:dependencies && pnpm audit:all && pnpm check:source && node scripts/check-release-artifact.mjs release-artifacts",
|
|
80
|
-
"test:artifact": "node scripts/check-release-artifact.mjs",
|
|
81
|
-
"test:dependencies": "node scripts/check-production-dependencies.mjs",
|
|
82
|
-
"test:docs": "node scripts/check-documentation.mjs && pnpm --dir docs check",
|
|
83
|
-
"test:package": "node scripts/check-package.mjs",
|
|
84
|
-
"test:performance": "node --expose-gc ./node_modules/vitest/vitest.mjs run --config vitest.performance.config.ts",
|
|
85
|
-
"test:prepare": "pnpm dev:prepare && nuxt prepare test/fixtures/layers",
|
|
86
|
-
"test:production": "pnpm build && vitest run --config vitest.production.config.ts",
|
|
87
|
-
"test:quickstart": "node scripts/test-package-quickstart.mjs",
|
|
88
|
-
"test:raster": "vitest run --config vitest.raster.config.ts",
|
|
89
|
-
"test:version-headings": "node scripts/check-version-headings.mjs",
|
|
90
|
-
"test:workflows": "node scripts/check-workflow-policy.mjs && node scripts/test-npm-recovery.mjs && node scripts/test-release-recovery.mjs",
|
|
91
|
-
"check:vercel": "node scripts/check-vercel-config.mjs",
|
|
92
|
-
"test:serverless": "vitest run --config vitest.serverless.config.ts",
|
|
93
|
-
"test:watch": "vitest watch",
|
|
94
|
-
"typecheck": "pnpm test:prepare && nuxt prepare && vue-tsc --noEmit && nuxt prepare test/fixtures/basic && vue-tsc --noEmit -p test/fixtures/basic/tsconfig.json && pnpm --dir playground exec vue-tsc --noEmit",
|
|
95
|
-
"audit:all": "pnpm audit",
|
|
96
|
-
"check:dependencies": "node scripts/check-dependency-policy.mjs",
|
|
97
|
-
"verify": "pnpm check:dependencies && pnpm audit:all && pnpm check",
|
|
98
|
-
"check": "pnpm check:source && pnpm test:artifact",
|
|
99
|
-
"check:source": "pnpm format:check && pnpm check:vercel && pnpm typecheck && pnpm test:docs && pnpm test:version-headings && pnpm test:workflows && pnpm test:dependencies && pnpm test && pnpm test:production && pnpm test:serverless && pnpm build && pnpm test:api && pnpm dev:build"
|
|
100
|
-
},
|
|
101
58
|
"dependencies": {
|
|
102
59
|
"@jridgewell/remapping": "2.3.5",
|
|
103
60
|
"@nuxt/kit": "^4.5.2",
|
|
@@ -130,6 +87,8 @@
|
|
|
130
87
|
},
|
|
131
88
|
"devDependencies": {
|
|
132
89
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
90
|
+
"@changesets/changelog-github": "1.0.1",
|
|
91
|
+
"@changesets/cli": "3.0.3",
|
|
133
92
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
134
93
|
"@napi-rs/canvas": "0.1.97",
|
|
135
94
|
"@nuxt/devtools": "^3.3.1",
|
|
@@ -140,7 +99,6 @@
|
|
|
140
99
|
"@react-pdf/renderer": "4.5.1",
|
|
141
100
|
"@types/node": "26.1.1",
|
|
142
101
|
"@types/react": "19.2.14",
|
|
143
|
-
"changelogen": "0.6.2",
|
|
144
102
|
"eslint": "^10.4.1",
|
|
145
103
|
"nuxt": "^4.5.2",
|
|
146
104
|
"pdfjs-dist": "6.2.108",
|
|
@@ -151,5 +109,26 @@
|
|
|
151
109
|
"vitest": "^4.1.8",
|
|
152
110
|
"vue": "3.5.42",
|
|
153
111
|
"yaml": "2.9.0"
|
|
112
|
+
},
|
|
113
|
+
"scripts": {
|
|
114
|
+
"dev": "pnpm dev:prepare && nuxt dev playground",
|
|
115
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
116
|
+
"build": "nuxt-module-build prepare && nuxt-module-build build && pnpm docs:build && node scripts/agent-docs.mjs && publint",
|
|
117
|
+
"lint": "eslint . && node scripts/lint-changesets.mjs",
|
|
118
|
+
"format": "eslint . --fix",
|
|
119
|
+
"typecheck": "pnpm test:prepare && nuxt prepare && vue-tsc --noEmit && nuxt prepare test/fixtures/basic && vue-tsc --noEmit -p test/fixtures/basic/tsconfig.json && pnpm --dir playground exec vue-tsc --noEmit",
|
|
120
|
+
"test": "pnpm test:prepare && vitest run",
|
|
121
|
+
"test:prepare": "pnpm dev:prepare && nuxt prepare test/fixtures/layers",
|
|
122
|
+
"test:production": "nuxt-module-build prepare && nuxt-module-build build && vitest run --config vitest.production.config.ts && vitest run --config vitest.serverless.config.ts && nuxt build playground",
|
|
123
|
+
"test:raster": "vitest run --config vitest.raster.config.ts",
|
|
124
|
+
"test:performance": "node --expose-gc ./node_modules/vitest/vitest.mjs run --config vitest.performance.config.ts",
|
|
125
|
+
"test:docs": "node scripts/check-docs-snippets.mjs && node scripts/check-docs-contracts.mjs && pnpm --dir docs check",
|
|
126
|
+
"test:api": "node scripts/check-api-report.mjs",
|
|
127
|
+
"test:packed": "node scripts/check-package.mjs && node scripts/test-package-quickstart.mjs",
|
|
128
|
+
"api:write": "node scripts/check-api-report.mjs --write",
|
|
129
|
+
"docs:dev": "pnpm --dir docs dev",
|
|
130
|
+
"docs:build": "nuxt-module-build prepare && pnpm --dir docs build",
|
|
131
|
+
"verify": "pnpm lint && pnpm typecheck && pnpm test:docs && pnpm test && pnpm test:production && pnpm build && pnpm test:api && pnpm test:packed && node scripts/audit-deps.mjs",
|
|
132
|
+
"changeset": "changeset"
|
|
154
133
|
}
|
|
155
|
-
}
|
|
134
|
+
}
|