@lupinum/nuxt-pdf 0.3.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 (75) hide show
  1. package/API_REPORT.md +262 -0
  2. package/CHANGELOG.md +168 -0
  3. package/CONFORMANCE.md +496 -0
  4. package/LICENSE +21 -0
  5. package/README.md +203 -0
  6. package/THIRD_PARTY_NOTICES.md +75 -0
  7. package/dist/module.d.mts +24 -0
  8. package/dist/module.json +12 -0
  9. package/dist/module.mjs +368 -0
  10. package/dist/runtime/authoring.d.ts +141 -0
  11. package/dist/runtime/authoring.js +25 -0
  12. package/dist/runtime/components/_props.d.ts +196 -0
  13. package/dist/runtime/components/_props.js +63 -0
  14. package/dist/runtime/components/document.d.ts +9 -0
  15. package/dist/runtime/components/document.js +26 -0
  16. package/dist/runtime/components/index.d.ts +4 -0
  17. package/dist/runtime/components/index.js +27 -0
  18. package/dist/runtime/components/svg.d.ts +17 -0
  19. package/dist/runtime/components/svg.js +50 -0
  20. package/dist/runtime/composables/index.d.ts +2 -0
  21. package/dist/runtime/composables/index.js +3 -0
  22. package/dist/runtime/composables/use-pdf-page-numbers.d.ts +39 -0
  23. package/dist/runtime/composables/use-pdf-page-numbers.js +17 -0
  24. package/dist/runtime/define-pdf.d.ts +6 -0
  25. package/dist/runtime/define-pdf.js +5 -0
  26. package/dist/runtime/fonts.d.ts +16 -0
  27. package/dist/runtime/fonts.js +0 -0
  28. package/dist/runtime/renderer/index.d.ts +3 -0
  29. package/dist/runtime/renderer/index.js +1 -0
  30. package/dist/runtime/renderer/node-ops.d.ts +5 -0
  31. package/dist/runtime/renderer/node-ops.js +281 -0
  32. package/dist/runtime/renderer/patch-prop.d.ts +3 -0
  33. package/dist/runtime/renderer/patch-prop.js +223 -0
  34. package/dist/runtime/renderer/render-component.d.ts +14 -0
  35. package/dist/runtime/renderer/render-component.js +201 -0
  36. package/dist/runtime/renderer/types.d.ts +33 -0
  37. package/dist/runtime/renderer/types.js +56 -0
  38. package/dist/runtime/renderer/validate-tree.d.ts +3 -0
  39. package/dist/runtime/renderer/validate-tree.js +428 -0
  40. package/dist/runtime/server/assets/errors.d.ts +12 -0
  41. package/dist/runtime/server/assets/errors.js +15 -0
  42. package/dist/runtime/server/assets/remote.d.ts +48 -0
  43. package/dist/runtime/server/assets/remote.js +234 -0
  44. package/dist/runtime/server/assets/resolve-asset.d.ts +53 -0
  45. package/dist/runtime/server/assets/resolve-asset.js +482 -0
  46. package/dist/runtime/server/engine/CONTRACTS.md +386 -0
  47. package/dist/runtime/server/engine/fonts.d.ts +8 -0
  48. package/dist/runtime/server/engine/fonts.js +19 -0
  49. package/dist/runtime/server/engine/layout-passes.d.ts +42 -0
  50. package/dist/runtime/server/engine/layout-passes.js +58 -0
  51. package/dist/runtime/server/engine/react-pdf-pdfkit.d.ts +7 -0
  52. package/dist/runtime/server/engine/render-document.d.ts +31 -0
  53. package/dist/runtime/server/engine/render-document.js +236 -0
  54. package/dist/runtime/server/index.d.ts +5 -0
  55. package/dist/runtime/server/index.js +9 -0
  56. package/dist/runtime/server/preview.d.ts +17 -0
  57. package/dist/runtime/server/preview.js +332 -0
  58. package/dist/runtime/server/registry.d.ts +41 -0
  59. package/dist/runtime/server/registry.js +270 -0
  60. package/dist/runtime/server/render-limits.d.ts +51 -0
  61. package/dist/runtime/server/render-limits.js +143 -0
  62. package/dist/runtime/server/result.d.ts +6 -0
  63. package/dist/runtime/server/result.js +81 -0
  64. package/dist/runtime/server/tsconfig.json +3 -0
  65. package/dist/runtime/shared/errors.d.ts +22 -0
  66. package/dist/runtime/shared/errors.js +22 -0
  67. package/dist/runtime/shared/index.d.ts +4 -0
  68. package/dist/runtime/shared/index.js +7 -0
  69. package/dist/runtime/shared/template.d.ts +63 -0
  70. package/dist/runtime/shared/template.js +1 -0
  71. package/dist/shared/nuxt-pdf.D2ZziYn4.mjs +1132 -0
  72. package/dist/test.d.mts +198 -0
  73. package/dist/test.mjs +696 -0
  74. package/dist/types.d.mts +13 -0
  75. package/package.json +135 -0
@@ -0,0 +1,141 @@
1
+ import type { PdfFontStyle, PdfFontWeight } from './fonts.js';
2
+ /** Stable host tags shared by PDF authoring components and the renderer. */
3
+ export declare const PDF_PRIMITIVES: {
4
+ readonly Document: "DOCUMENT";
5
+ readonly Page: "PAGE";
6
+ readonly View: "VIEW";
7
+ readonly Text: "TEXT";
8
+ readonly Image: "IMAGE";
9
+ readonly Link: "LINK";
10
+ readonly Note: "NOTE";
11
+ readonly Tspan: "TSPAN";
12
+ readonly Svg: "SVG";
13
+ readonly G: "G";
14
+ readonly Path: "PATH";
15
+ readonly Rect: "RECT";
16
+ readonly Circle: "CIRCLE";
17
+ readonly Ellipse: "ELLIPSE";
18
+ readonly Line: "LINE";
19
+ readonly Polyline: "POLYLINE";
20
+ readonly Polygon: "POLYGON";
21
+ readonly Defs: "DEFS";
22
+ readonly ClipPath: "CLIP_PATH";
23
+ readonly LinearGradient: "LINEAR_GRADIENT";
24
+ readonly RadialGradient: "RADIAL_GRADIENT";
25
+ readonly Stop: "STOP";
26
+ readonly TextInstance: "TEXT_INSTANCE";
27
+ };
28
+ /** Units resolved by the PDF stylesheet engine. Unitless numbers are points. */
29
+ export type PdfLengthUnit = 'pt' | 'px' | 'in' | 'mm' | 'cm' | 'rem' | 'vh' | 'vw';
30
+ export type PdfUnitLength = `${number}${PdfLengthUnit}`;
31
+ export type PdfPercentage = `${number}%`;
32
+ export type PdfLength = number | PdfUnitLength;
33
+ export type PdfLengthOrPercentage = PdfLength | PdfPercentage;
34
+ export type PdfBorderStyle = 'solid' | 'dashed' | 'dotted';
35
+ export type PdfFlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
36
+ export type PdfFlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
37
+ export type PdfAlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
38
+ export type PdfJustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
39
+ export type PdfTextAlign = 'left' | 'right' | 'center' | 'justify';
40
+ export type PdfTextDecoration = 'none' | 'underline' | 'line-through' | 'underline line-through' | 'line-through underline';
41
+ export type PdfTextTransform = 'none' | 'capitalize' | 'lowercase' | 'uppercase';
42
+ export type PdfObjectFit = 'contain' | 'cover';
43
+ /**
44
+ * Transform operations covered by the conformance corpus. Translation values
45
+ * are unitless points because the pinned transform parser does not resolve CSS
46
+ * length units inside `translate()`.
47
+ */
48
+ export type PdfTransformOperation = `rotate(${number}deg)` | `rotate(${number}rad)` | `scale(${number})` | `scale(${number},${number})` | `scale(${number}, ${number})` | `scale(${number} ${number})` | `translate(${number},${number})` | `translate(${number}, ${number})` | `translate(${number} ${number})`;
49
+ /** One to three left-to-right transform operations. */
50
+ export type PdfTransform = PdfTransformOperation | `${PdfTransformOperation} ${PdfTransformOperation}` | `${PdfTransformOperation} ${PdfTransformOperation} ${PdfTransformOperation}`;
51
+ /**
52
+ * Framework-owned style surface for PDF primitives.
53
+ *
54
+ * This deliberately describes the tested Nuxt PDF contract instead of
55
+ * re-exporting the wider, version-dependent upstream stylesheet types.
56
+ */
57
+ export interface PdfStyle {
58
+ width?: PdfLengthOrPercentage;
59
+ height?: PdfLengthOrPercentage;
60
+ minWidth?: PdfLengthOrPercentage;
61
+ minHeight?: PdfLengthOrPercentage;
62
+ maxWidth?: PdfLengthOrPercentage;
63
+ maxHeight?: PdfLengthOrPercentage;
64
+ flex?: number;
65
+ flexBasis?: PdfLengthOrPercentage | 'auto';
66
+ flexDirection?: PdfFlexDirection;
67
+ flexGrow?: number;
68
+ flexShrink?: number;
69
+ flexWrap?: PdfFlexWrap;
70
+ alignItems?: PdfAlignItems;
71
+ justifyContent?: PdfJustifyContent;
72
+ gap?: PdfLength;
73
+ margin?: PdfLengthOrPercentage | 'auto';
74
+ marginHorizontal?: PdfLengthOrPercentage | 'auto';
75
+ marginVertical?: PdfLengthOrPercentage | 'auto';
76
+ marginTop?: PdfLengthOrPercentage | 'auto';
77
+ marginRight?: PdfLengthOrPercentage | 'auto';
78
+ marginBottom?: PdfLengthOrPercentage | 'auto';
79
+ marginLeft?: PdfLengthOrPercentage | 'auto';
80
+ padding?: PdfLengthOrPercentage;
81
+ paddingHorizontal?: PdfLengthOrPercentage;
82
+ paddingVertical?: PdfLengthOrPercentage;
83
+ paddingTop?: PdfLengthOrPercentage;
84
+ paddingRight?: PdfLengthOrPercentage;
85
+ paddingBottom?: PdfLengthOrPercentage;
86
+ paddingLeft?: PdfLengthOrPercentage;
87
+ position?: 'absolute' | 'relative';
88
+ top?: PdfLengthOrPercentage;
89
+ right?: PdfLengthOrPercentage;
90
+ bottom?: PdfLengthOrPercentage;
91
+ left?: PdfLengthOrPercentage;
92
+ backgroundColor?: string;
93
+ color?: string;
94
+ opacity?: number;
95
+ borderWidth?: PdfLength;
96
+ borderColor?: string;
97
+ borderStyle?: PdfBorderStyle;
98
+ borderRadius?: PdfLength;
99
+ borderTopWidth?: PdfLength;
100
+ borderTopColor?: string;
101
+ borderTopStyle?: PdfBorderStyle;
102
+ borderRightWidth?: PdfLength;
103
+ borderRightColor?: string;
104
+ borderRightStyle?: PdfBorderStyle;
105
+ borderBottomWidth?: PdfLength;
106
+ borderBottomColor?: string;
107
+ borderBottomStyle?: PdfBorderStyle;
108
+ borderLeftWidth?: PdfLength;
109
+ borderLeftColor?: string;
110
+ borderLeftStyle?: PdfBorderStyle;
111
+ borderTopLeftRadius?: PdfLengthOrPercentage;
112
+ borderTopRightRadius?: PdfLengthOrPercentage;
113
+ borderBottomRightRadius?: PdfLengthOrPercentage;
114
+ borderBottomLeftRadius?: PdfLengthOrPercentage;
115
+ fontFamily?: string;
116
+ fontSize?: PdfLength;
117
+ fontStyle?: PdfFontStyle;
118
+ fontWeight?: PdfFontWeight;
119
+ letterSpacing?: PdfLength;
120
+ lineHeight?: number | PdfUnitLength | PdfPercentage;
121
+ maxLines?: number;
122
+ textAlign?: PdfTextAlign;
123
+ textDecoration?: PdfTextDecoration;
124
+ textDecorationColor?: string;
125
+ textDecorationStyle?: PdfBorderStyle;
126
+ textOverflow?: 'ellipsis';
127
+ textTransform?: PdfTextTransform;
128
+ objectFit?: PdfObjectFit;
129
+ transform?: PdfTransform;
130
+ }
131
+ /** One recursively nestable entry inside a style array. */
132
+ export type PdfStyleEntry = PdfStyle | readonly PdfStyleEntry[] | false | null | undefined;
133
+ /** A style object or a recursively nested, left-to-right style array. */
134
+ export type PdfStyleValue = PdfStyle | readonly PdfStyleEntry[];
135
+ export type PdfDynamicPageProps = {
136
+ pageNumber: number;
137
+ totalPages?: number;
138
+ subPageNumber?: number;
139
+ subPageTotalPages?: number;
140
+ };
141
+ export type PdfDynamicTextRender = (props: PdfDynamicPageProps) => string | number | null | undefined;
@@ -0,0 +1,25 @@
1
+ export const PDF_PRIMITIVES = {
2
+ Document: "DOCUMENT",
3
+ Page: "PAGE",
4
+ View: "VIEW",
5
+ Text: "TEXT",
6
+ Image: "IMAGE",
7
+ Link: "LINK",
8
+ Note: "NOTE",
9
+ Tspan: "TSPAN",
10
+ Svg: "SVG",
11
+ G: "G",
12
+ Path: "PATH",
13
+ Rect: "RECT",
14
+ Circle: "CIRCLE",
15
+ Ellipse: "ELLIPSE",
16
+ Line: "LINE",
17
+ Polyline: "POLYLINE",
18
+ Polygon: "POLYGON",
19
+ Defs: "DEFS",
20
+ ClipPath: "CLIP_PATH",
21
+ LinearGradient: "LINEAR_GRADIENT",
22
+ RadialGradient: "RADIAL_GRADIENT",
23
+ Stop: "STOP",
24
+ TextInstance: "TEXT_INSTANCE"
25
+ };
@@ -0,0 +1,196 @@
1
+ import type { PdfDynamicTextRender, PdfStyleValue } from '../authoring.js';
2
+ export type PdfBookmark = string | {
3
+ title: string;
4
+ expanded?: boolean;
5
+ };
6
+ export type PdfBaseProps = {
7
+ id?: string;
8
+ fixed?: boolean;
9
+ break?: boolean;
10
+ debug?: boolean;
11
+ minPresenceAhead?: number;
12
+ style?: PdfStyleValue;
13
+ };
14
+ type PdfBookmarkProp = {
15
+ bookmark?: PdfBookmark;
16
+ };
17
+ export type PdfDocumentProps = {
18
+ title?: string;
19
+ author?: string;
20
+ subject?: string;
21
+ creator?: string;
22
+ keywords?: string;
23
+ producer?: string;
24
+ language?: string;
25
+ creationDate?: Date;
26
+ pdfVersion?: '1.3' | '1.4' | '1.5' | '1.6' | '1.7' | '1.7ext3';
27
+ pageLayout?: 'singlePage' | 'oneColumn' | 'twoColumnLeft' | 'twoColumnRight' | 'twoPageLeft' | 'twoPageRight';
28
+ };
29
+ export declare const PDF_PAGE_SIZE_NAMES: readonly ["4A0", "2A0", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "RA0", "RA1", "RA2", "RA3", "RA4", "SRA0", "SRA1", "SRA2", "SRA3", "SRA4", "EXECUTIVE", "FOLIO", "LEGAL", "LETTER", "TABLOID", "ID1"];
30
+ export type PdfPageSizeName = (typeof PDF_PAGE_SIZE_NAMES)[number];
31
+ export type PdfPageUnit = 'pt' | 'in' | 'mm' | 'cm' | 'px';
32
+ export type PdfPageDimension = number | `${number}${PdfPageUnit}`;
33
+ export type PdfPageSize = PdfPageSizeName | readonly [PdfPageDimension, PdfPageDimension] | {
34
+ width: PdfPageDimension;
35
+ height: PdfPageDimension;
36
+ };
37
+ export type PdfPageProps = PdfBaseProps & PdfBookmarkProp & {
38
+ wrap?: boolean;
39
+ size?: PdfPageSize;
40
+ orientation?: 'portrait' | 'landscape';
41
+ dpi?: number;
42
+ };
43
+ /** Numeric SVG values accepted by the pinned layout parser. */
44
+ export type PdfSvgNumber = number | `${number}`;
45
+ export type PdfSvgLength = PdfSvgNumber | `${number}%`;
46
+ export type PdfSvgTransformOperation = `translate(${number})` | `translate(${number},${number})` | `translate(${number}, ${number})` | `translate(${number} ${number})` | `rotate(${number})`;
47
+ export type PdfSvgTransform = PdfSvgTransformOperation | `${PdfSvgTransformOperation} ${PdfSvgTransformOperation}` | `${PdfSvgTransformOperation} ${PdfSvgTransformOperation} ${PdfSvgTransformOperation}`;
48
+ export type PdfViewProps = PdfBaseProps & PdfBookmarkProp & {
49
+ wrap?: boolean;
50
+ };
51
+ type PdfFlowTextProps = PdfBaseProps & PdfBookmarkProp & {
52
+ wrap?: boolean;
53
+ widows?: number;
54
+ orphans?: number;
55
+ render?: PdfDynamicTextRender;
56
+ hyphenationCallback?: (word: string) => string[];
57
+ };
58
+ type PdfSvgTextProps = {
59
+ /** SVG text positioning is explicit and required inside a `PdfSvg`. */
60
+ x: PdfSvgLength;
61
+ y: PdfSvgLength;
62
+ fill?: string;
63
+ style?: PdfStyleValue;
64
+ hyphenationCallback?: (word: string) => string[];
65
+ };
66
+ export type PdfTextProps = PdfFlowTextProps | PdfSvgTextProps;
67
+ export type PdfImageSource = string | Uint8Array | ArrayBuffer | {
68
+ data: Uint8Array;
69
+ format: 'png' | 'jpg';
70
+ } | {
71
+ uri: string;
72
+ format?: 'png' | 'jpg';
73
+ };
74
+ type PdfImageSourceProp = {
75
+ src: PdfImageSource;
76
+ source?: never;
77
+ } | {
78
+ src?: never;
79
+ source: PdfImageSource;
80
+ };
81
+ export type PdfImageProps = PdfBaseProps & PdfBookmarkProp & PdfImageSourceProp;
82
+ type PdfLinkTarget = {
83
+ href: string;
84
+ src?: never;
85
+ } | {
86
+ href?: never;
87
+ src: string;
88
+ };
89
+ export type PdfLinkProps = PdfBaseProps & PdfLinkTarget & {
90
+ wrap?: boolean;
91
+ hitSlop?: {
92
+ top?: number;
93
+ right?: number;
94
+ bottom?: number;
95
+ left?: number;
96
+ };
97
+ };
98
+ export type PdfNoteProps = PdfBaseProps;
99
+ /**
100
+ * Fixture-proven subset of the engine's SVG presentation attributes. On SVG
101
+ * nodes these are camelCase props. `transform` is a prop here (unlike
102
+ * `PdfView`, where it is a style key).
103
+ */
104
+ export type PdfSvgPresentationProps = {
105
+ fill?: string;
106
+ stroke?: string;
107
+ transform?: PdfSvgTransform;
108
+ strokeWidth?: PdfSvgNumber;
109
+ fillOpacity?: PdfSvgLength;
110
+ strokeOpacity?: PdfSvgLength;
111
+ strokeLinecap?: 'butt' | 'round' | 'square';
112
+ strokeLinejoin?: 'miter' | 'round' | 'bevel';
113
+ clipPath?: string;
114
+ };
115
+ export type PdfSvgProps = {
116
+ width?: PdfSvgLength;
117
+ height?: PdfSvgLength;
118
+ viewBox?: string;
119
+ /** Page-flow sizing and positioning for the SVG root. */
120
+ style?: PdfStyleValue;
121
+ };
122
+ export type PdfGProps = PdfSvgPresentationProps;
123
+ export type PdfPathProps = PdfSvgPresentationProps & {
124
+ d: string;
125
+ };
126
+ export type PdfRectProps = PdfSvgPresentationProps & {
127
+ x?: PdfSvgLength;
128
+ y?: PdfSvgLength;
129
+ width: PdfSvgLength;
130
+ height: PdfSvgLength;
131
+ rx?: PdfSvgLength;
132
+ ry?: PdfSvgLength;
133
+ };
134
+ export type PdfCircleProps = PdfSvgPresentationProps & {
135
+ cx?: PdfSvgLength;
136
+ cy?: PdfSvgLength;
137
+ r: PdfSvgLength;
138
+ };
139
+ export type PdfEllipseProps = PdfSvgPresentationProps & {
140
+ cx?: PdfSvgLength;
141
+ cy?: PdfSvgLength;
142
+ rx: PdfSvgLength;
143
+ ry: PdfSvgLength;
144
+ };
145
+ export type PdfLineProps = PdfSvgPresentationProps & {
146
+ x1: PdfSvgLength;
147
+ y1: PdfSvgLength;
148
+ x2: PdfSvgLength;
149
+ y2: PdfSvgLength;
150
+ };
151
+ export type PdfPolylineProps = PdfSvgPresentationProps & {
152
+ points: string;
153
+ };
154
+ export type PdfPolygonProps = PdfSvgPresentationProps & {
155
+ points: string;
156
+ };
157
+ export type PdfDefsProps = Record<never, never>;
158
+ export type PdfClipPathProps = {
159
+ id: string;
160
+ };
161
+ type PdfGradientProps = {
162
+ id: string;
163
+ };
164
+ export type PdfLinearGradientProps = PdfGradientProps & {
165
+ x1?: PdfSvgLength;
166
+ y1?: PdfSvgLength;
167
+ x2?: PdfSvgLength;
168
+ y2?: PdfSvgLength;
169
+ };
170
+ export type PdfRadialGradientProps = PdfGradientProps & {
171
+ cx?: PdfSvgLength;
172
+ cy?: PdfSvgLength;
173
+ r?: PdfSvgLength;
174
+ fx?: PdfSvgLength;
175
+ fy?: PdfSvgLength;
176
+ };
177
+ export type PdfStopProps = {
178
+ offset: PdfSvgLength;
179
+ stopColor: string;
180
+ stopOpacity?: PdfSvgLength;
181
+ };
182
+ export type PdfTspanProps = {
183
+ x?: PdfSvgLength;
184
+ y?: PdfSvgLength;
185
+ fill?: string;
186
+ };
187
+ /**
188
+ * Compact props for PDF and SVG primitives, coercing kebab-case attribute
189
+ * names (`stroke-width`, `stop-color`, `min-presence-ahead`) to the exact
190
+ * camelCase keys the engine reads. Without this, static kebab attributes from
191
+ * Vue templates would silently no-op. Pure input coercion, not a second
192
+ * source of truth. `data-`/`aria-` names stay kebab so `patchPdfProp` keeps
193
+ * rejecting them as DOM-only.
194
+ */
195
+ export declare const compactProps: (props: object) => Record<string, unknown>;
196
+ export {};
@@ -0,0 +1,63 @@
1
+ export const PDF_PAGE_SIZE_NAMES = [
2
+ "4A0",
3
+ "2A0",
4
+ "A0",
5
+ "A1",
6
+ "A2",
7
+ "A3",
8
+ "A4",
9
+ "A5",
10
+ "A6",
11
+ "A7",
12
+ "A8",
13
+ "A9",
14
+ "A10",
15
+ "B0",
16
+ "B1",
17
+ "B2",
18
+ "B3",
19
+ "B4",
20
+ "B5",
21
+ "B6",
22
+ "B7",
23
+ "B8",
24
+ "B9",
25
+ "B10",
26
+ "C0",
27
+ "C1",
28
+ "C2",
29
+ "C3",
30
+ "C4",
31
+ "C5",
32
+ "C6",
33
+ "C7",
34
+ "C8",
35
+ "C9",
36
+ "C10",
37
+ "RA0",
38
+ "RA1",
39
+ "RA2",
40
+ "RA3",
41
+ "RA4",
42
+ "SRA0",
43
+ "SRA1",
44
+ "SRA2",
45
+ "SRA3",
46
+ "SRA4",
47
+ "EXECUTIVE",
48
+ "FOLIO",
49
+ "LEGAL",
50
+ "LETTER",
51
+ "TABLOID",
52
+ "ID1"
53
+ ];
54
+ const KEBAB_SEGMENT = /-([a-z])/g;
55
+ const normalizePropName = (key) => key.startsWith("data-") || key.startsWith("aria-") ? key : key.replace(KEBAB_SEGMENT, (_, letter) => letter.toUpperCase());
56
+ export const compactProps = (props) => {
57
+ const result = {};
58
+ for (const [key, value] of Object.entries(props)) {
59
+ if (value === void 0) continue;
60
+ result[normalizePropName(key)] = value;
61
+ }
62
+ return result;
63
+ };
@@ -0,0 +1,9 @@
1
+ import { type FunctionalComponent } from 'vue';
2
+ import { type PdfDocumentProps, type PdfImageProps, type PdfLinkProps, type PdfNoteProps, type PdfPageProps, type PdfTextProps, type PdfViewProps } from './_props.js';
3
+ export declare const PdfDocument: FunctionalComponent<PdfDocumentProps>;
4
+ export declare const PdfPage: FunctionalComponent<PdfPageProps>;
5
+ export declare const PdfView: FunctionalComponent<PdfViewProps>;
6
+ export declare const PdfText: FunctionalComponent<PdfTextProps>;
7
+ export declare const PdfImage: FunctionalComponent<PdfImageProps>;
8
+ export declare const PdfLink: FunctionalComponent<PdfLinkProps>;
9
+ export declare const PdfNote: FunctionalComponent<PdfNoteProps>;
@@ -0,0 +1,26 @@
1
+ import { h } from "vue";
2
+ import { PDF_PRIMITIVES } from "../authoring.js";
3
+ import {
4
+ compactProps
5
+ } from "./_props.js";
6
+ export const PdfDocument = (props, { slots }) => h(PDF_PRIMITIVES.Document, compactProps(props), slots.default?.());
7
+ PdfDocument.displayName = "PdfDocument";
8
+ PdfDocument.inheritAttrs = false;
9
+ export const PdfPage = (props, { slots }) => h(PDF_PRIMITIVES.Page, compactProps(props), slots.default?.());
10
+ PdfPage.displayName = "PdfPage";
11
+ PdfPage.inheritAttrs = false;
12
+ export const PdfView = (props, { slots }) => h(PDF_PRIMITIVES.View, compactProps(props), slots.default?.());
13
+ PdfView.displayName = "PdfView";
14
+ PdfView.inheritAttrs = false;
15
+ export const PdfText = (props, { slots }) => h(PDF_PRIMITIVES.Text, compactProps(props), slots.default?.());
16
+ PdfText.displayName = "PdfText";
17
+ PdfText.inheritAttrs = false;
18
+ export const PdfImage = (props) => h(PDF_PRIMITIVES.Image, compactProps(props));
19
+ PdfImage.displayName = "PdfImage";
20
+ PdfImage.inheritAttrs = false;
21
+ export const PdfLink = (props, { slots }) => h(PDF_PRIMITIVES.Link, compactProps(props), slots.default?.());
22
+ PdfLink.displayName = "PdfLink";
23
+ PdfLink.inheritAttrs = false;
24
+ export const PdfNote = (props, { slots }) => h(PDF_PRIMITIVES.Note, compactProps(props), slots.default?.());
25
+ PdfNote.displayName = "PdfNote";
26
+ PdfNote.inheritAttrs = false;
@@ -0,0 +1,4 @@
1
+ export { PdfDocument, PdfImage, PdfLink, PdfNote, PdfPage, PdfText, PdfView, } from './document.js';
2
+ export { PDF_PAGE_SIZE_NAMES } from './_props.js';
3
+ export { PdfCircle, PdfClipPath, PdfDefs, PdfEllipse, PdfG, PdfLine, PdfLinearGradient, PdfPath, PdfPolygon, PdfPolyline, PdfRadialGradient, PdfRect, PdfStop, PdfSvg, PdfTspan, } from './svg.js';
4
+ export type { PdfBaseProps, PdfBookmark, PdfCircleProps, PdfClipPathProps, PdfDefsProps, PdfDocumentProps, PdfEllipseProps, PdfGProps, PdfImageProps, PdfImageSource, PdfLinearGradientProps, PdfLineProps, PdfLinkProps, PdfNoteProps, PdfPageDimension, PdfPageProps, PdfPageSize, PdfPageSizeName, PdfPageUnit, PdfPathProps, PdfPolygonProps, PdfPolylineProps, PdfRadialGradientProps, PdfRectProps, PdfStopProps, PdfSvgPresentationProps, PdfSvgLength, PdfSvgNumber, PdfSvgTransform, PdfSvgTransformOperation, PdfSvgProps, PdfTextProps, PdfTspanProps, PdfViewProps, } from './_props.js';
@@ -0,0 +1,27 @@
1
+ export {
2
+ PdfDocument,
3
+ PdfImage,
4
+ PdfLink,
5
+ PdfNote,
6
+ PdfPage,
7
+ PdfText,
8
+ PdfView
9
+ } from "./document.js";
10
+ export { PDF_PAGE_SIZE_NAMES } from "./_props.js";
11
+ export {
12
+ PdfCircle,
13
+ PdfClipPath,
14
+ PdfDefs,
15
+ PdfEllipse,
16
+ PdfG,
17
+ PdfLine,
18
+ PdfLinearGradient,
19
+ PdfPath,
20
+ PdfPolygon,
21
+ PdfPolyline,
22
+ PdfRadialGradient,
23
+ PdfRect,
24
+ PdfStop,
25
+ PdfSvg,
26
+ PdfTspan
27
+ } from "./svg.js";
@@ -0,0 +1,17 @@
1
+ import { type FunctionalComponent } from 'vue';
2
+ import { type PdfCircleProps, type PdfClipPathProps, type PdfDefsProps, type PdfEllipseProps, type PdfGProps, type PdfLinearGradientProps, type PdfLineProps, type PdfPathProps, type PdfPolygonProps, type PdfPolylineProps, type PdfRadialGradientProps, type PdfRectProps, type PdfStopProps, type PdfSvgProps, type PdfTspanProps } from './_props.js';
3
+ export declare const PdfSvg: FunctionalComponent<PdfSvgProps>;
4
+ export declare const PdfG: FunctionalComponent<PdfGProps>;
5
+ export declare const PdfPath: FunctionalComponent<PdfPathProps>;
6
+ export declare const PdfRect: FunctionalComponent<PdfRectProps>;
7
+ export declare const PdfCircle: FunctionalComponent<PdfCircleProps>;
8
+ export declare const PdfEllipse: FunctionalComponent<PdfEllipseProps>;
9
+ export declare const PdfLine: FunctionalComponent<PdfLineProps>;
10
+ export declare const PdfPolyline: FunctionalComponent<PdfPolylineProps>;
11
+ export declare const PdfPolygon: FunctionalComponent<PdfPolygonProps>;
12
+ export declare const PdfDefs: FunctionalComponent<PdfDefsProps>;
13
+ export declare const PdfClipPath: FunctionalComponent<PdfClipPathProps>;
14
+ export declare const PdfLinearGradient: FunctionalComponent<PdfLinearGradientProps>;
15
+ export declare const PdfRadialGradient: FunctionalComponent<PdfRadialGradientProps>;
16
+ export declare const PdfStop: FunctionalComponent<PdfStopProps>;
17
+ export declare const PdfTspan: FunctionalComponent<PdfTspanProps>;
@@ -0,0 +1,50 @@
1
+ import { h } from "vue";
2
+ import { PDF_PRIMITIVES } from "../authoring.js";
3
+ import {
4
+ compactProps
5
+ } from "./_props.js";
6
+ export const PdfSvg = (props, { slots }) => h(PDF_PRIMITIVES.Svg, compactProps(props), slots.default?.());
7
+ PdfSvg.displayName = "PdfSvg";
8
+ PdfSvg.inheritAttrs = false;
9
+ export const PdfG = (props, { slots }) => h(PDF_PRIMITIVES.G, compactProps(props), slots.default?.());
10
+ PdfG.displayName = "PdfG";
11
+ PdfG.inheritAttrs = false;
12
+ export const PdfPath = (props) => h(PDF_PRIMITIVES.Path, compactProps(props));
13
+ PdfPath.displayName = "PdfPath";
14
+ PdfPath.inheritAttrs = false;
15
+ export const PdfRect = (props) => h(PDF_PRIMITIVES.Rect, compactProps(props));
16
+ PdfRect.displayName = "PdfRect";
17
+ PdfRect.inheritAttrs = false;
18
+ export const PdfCircle = (props) => h(PDF_PRIMITIVES.Circle, compactProps(props));
19
+ PdfCircle.displayName = "PdfCircle";
20
+ PdfCircle.inheritAttrs = false;
21
+ export const PdfEllipse = (props) => h(PDF_PRIMITIVES.Ellipse, compactProps(props));
22
+ PdfEllipse.displayName = "PdfEllipse";
23
+ PdfEllipse.inheritAttrs = false;
24
+ export const PdfLine = (props) => h(PDF_PRIMITIVES.Line, compactProps(props));
25
+ PdfLine.displayName = "PdfLine";
26
+ PdfLine.inheritAttrs = false;
27
+ export const PdfPolyline = (props) => h(PDF_PRIMITIVES.Polyline, compactProps(props));
28
+ PdfPolyline.displayName = "PdfPolyline";
29
+ PdfPolyline.inheritAttrs = false;
30
+ export const PdfPolygon = (props) => h(PDF_PRIMITIVES.Polygon, compactProps(props));
31
+ PdfPolygon.displayName = "PdfPolygon";
32
+ PdfPolygon.inheritAttrs = false;
33
+ export const PdfDefs = (props, { slots }) => h(PDF_PRIMITIVES.Defs, compactProps(props), slots.default?.());
34
+ PdfDefs.displayName = "PdfDefs";
35
+ PdfDefs.inheritAttrs = false;
36
+ export const PdfClipPath = (props, { slots }) => h(PDF_PRIMITIVES.ClipPath, compactProps(props), slots.default?.());
37
+ PdfClipPath.displayName = "PdfClipPath";
38
+ PdfClipPath.inheritAttrs = false;
39
+ export const PdfLinearGradient = (props, { slots }) => h(PDF_PRIMITIVES.LinearGradient, compactProps(props), slots.default?.());
40
+ PdfLinearGradient.displayName = "PdfLinearGradient";
41
+ PdfLinearGradient.inheritAttrs = false;
42
+ export const PdfRadialGradient = (props, { slots }) => h(PDF_PRIMITIVES.RadialGradient, compactProps(props), slots.default?.());
43
+ PdfRadialGradient.displayName = "PdfRadialGradient";
44
+ PdfRadialGradient.inheritAttrs = false;
45
+ export const PdfStop = (props) => h(PDF_PRIMITIVES.Stop, compactProps(props));
46
+ PdfStop.displayName = "PdfStop";
47
+ PdfStop.inheritAttrs = false;
48
+ export const PdfTspan = (props, { slots }) => h(PDF_PRIMITIVES.Tspan, compactProps(props), slots.default?.());
49
+ PdfTspan.displayName = "PdfTspan";
50
+ PdfTspan.inheritAttrs = false;
@@ -0,0 +1,2 @@
1
+ export { usePdfPageNumbers, } from './use-pdf-page-numbers.js';
2
+ export type { PdfPageNumbers, } from './use-pdf-page-numbers.js';
@@ -0,0 +1,3 @@
1
+ export {
2
+ usePdfPageNumbers
3
+ } from "./use-pdf-page-numbers.js";
@@ -0,0 +1,39 @@
1
+ import { type InjectionKey } from 'vue';
2
+ /**
3
+ * A readonly, reactive map from a destination `id` to the 1-based page number it
4
+ * finally resolves to. A value is `undefined` until the layout loop has located
5
+ * the destination — on the FIRST layout pass every entry is `undefined`, so a
6
+ * table-of-contents template must tolerate a missing number (render a blank or a
7
+ * placeholder) rather than assume it exists.
8
+ */
9
+ export type PdfPageNumbers = Readonly<Record<string, number | undefined>>;
10
+ /**
11
+ * The value `mountPdfComponent` provides so `usePdfPageNumbers` can read the live
12
+ * page-number map and flag the render as multi-pass. Injecting it is the ONLY
13
+ * signal that turns on the fixed-point layout loop; a document that never calls
14
+ * the composable stays on the single-pass path (internal `#id` links resolve by
15
+ * name in a single pass and do not need the loop).
16
+ */
17
+ export interface PdfPageNumbersContext {
18
+ /** The reactive backing map the render loop feeds each pass. */
19
+ readonly pages: Record<string, number | undefined>;
20
+ /** Called at setup time to flag the mounted render as multi-pass. */
21
+ markUsed(): void;
22
+ }
23
+ export declare const PDF_PAGE_NUMBERS_KEY: InjectionKey<PdfPageNumbersContext>;
24
+ /**
25
+ * Access the resolved page number of every destination `id` in the current PDF.
26
+ * Auto-imported inside PDF templates and components. Calling it flags the render
27
+ * as multi-pass: the engine lays the document out repeatedly, feeding each pass's
28
+ * `id → page` map back through this composable until the numbers stabilize.
29
+ *
30
+ * ```ts
31
+ * const pageNumbers = usePdfPageNumbers()
32
+ * // in the template: {{ pageNumbers[section.id] ?? '' }}
33
+ * ```
34
+ *
35
+ * Outside a PDF render there is nothing to resolve, and a silently empty map
36
+ * would be indistinguishable from legitimate first-pass state, so calling it
37
+ * anywhere but a PDF template's setup fails fast instead.
38
+ */
39
+ export declare const usePdfPageNumbers: () => PdfPageNumbers;
@@ -0,0 +1,17 @@
1
+ import {
2
+ inject,
3
+ readonly
4
+ } from "vue";
5
+ import { NuxtPdfError, PDF_ERROR_CODES } from "../shared/errors.js";
6
+ export const PDF_PAGE_NUMBERS_KEY = Symbol.for("@lupinum/nuxt-pdf:page-numbers");
7
+ export const usePdfPageNumbers = () => {
8
+ const context = inject(PDF_PAGE_NUMBERS_KEY, null);
9
+ if (!context) {
10
+ throw new NuxtPdfError(
11
+ PDF_ERROR_CODES.TemplateInvalid,
12
+ "usePdfPageNumbers() is only available inside a PDF template rendered by nuxt-pdf. Call it in the setup of a pdfs/*.vue template or a component it renders."
13
+ );
14
+ }
15
+ context.markUsed();
16
+ return readonly(context.pages);
17
+ };
@@ -0,0 +1,6 @@
1
+ import type { PdfDefinition } from './shared/template.js';
2
+ /**
3
+ * Type and runtime fallback for the `definePdf` compiler macro.
4
+ * Discovered PDF templates erase this call before execution.
5
+ */
6
+ export declare function definePdf<Props extends object = Record<string, unknown>>(_definition: PdfDefinition<Props>): void;
@@ -0,0 +1,5 @@
1
+ export function definePdf(_definition) {
2
+ throw new Error(
3
+ "definePdf() is a compiler macro that only works as a top-level call in a discovered pdfs/*.vue template."
4
+ );
5
+ }
@@ -0,0 +1,16 @@
1
+ export type PdfFontStyle = 'italic' | 'normal' | 'oblique';
2
+ export type PdfFontWeightName = 'black' | 'bold' | 'demibold' | 'extrabold' | 'extralight' | 'hairline' | 'heavy' | 'light' | 'medium' | 'normal' | 'semibold' | 'thin' | 'ultrabold' | 'ultralight';
3
+ export type PdfFontWeight = number | PdfFontWeightName;
4
+ export interface PdfFontDeclaration {
5
+ family: string;
6
+ src: string;
7
+ fontStyle?: PdfFontStyle;
8
+ fontWeight?: PdfFontWeight;
9
+ }
10
+ export type PdfFontDataUrl = `data:font/${'otf' | 'ttf'};base64,${string}`;
11
+ export interface BundledPdfFontDescriptor {
12
+ family: string;
13
+ src: PdfFontDataUrl;
14
+ fontStyle?: PdfFontStyle;
15
+ fontWeight?: number;
16
+ }
File without changes