@pyreon/document 0.10.0 → 0.11.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/lib/analysis/index.js.html +1 -1
- package/lib/confluence-Bd3ua1Ut.js.map +1 -1
- package/lib/csv-COrS4qdy.js.map +1 -1
- package/lib/discord-BLUnkEh9.js.map +1 -1
- package/lib/{dist-BsqdI2nY.js → dist-CYL41kqQ.js} +2 -2
- package/lib/dist-CYL41kqQ.js.map +1 -0
- package/lib/{docx-BEBOihjl.js → docx-uNAel545.js} +7 -2
- package/lib/docx-uNAel545.js.map +1 -0
- package/lib/email-D0bbfWq4.js.map +1 -1
- package/lib/{exceljs-BoIDUUaw.js → exceljs-BYETsesT.js} +314 -314
- package/lib/exceljs-BYETsesT.js.map +1 -0
- package/lib/google-chat-CkKCBUWC.js.map +1 -1
- package/lib/html-B5biprN2.js.map +1 -1
- package/lib/index.js +17 -8
- package/lib/index.js.map +1 -1
- package/lib/markdown-CdtlFGC0.js.map +1 -1
- package/lib/notion-iG2C5bEY.js.map +1 -1
- package/lib/{pdf-DIUQUEdj.js → pdf-IuBgTb3T.js} +9 -3
- package/lib/pdf-IuBgTb3T.js.map +1 -0
- package/lib/{pdfmake-DnmLxK4Q.js → pdfmake-CKMX5URW.js} +2 -4
- package/lib/pdfmake-CKMX5URW.js.map +1 -0
- package/lib/{pptx-Dd33oL3_.js → pptx-DXiMiYFM.js} +7 -2
- package/lib/pptx-DXiMiYFM.js.map +1 -0
- package/lib/{pptxgen.es-COcgXsyx.js → pptxgen.es-FsqHs8mD.js} +3 -6
- package/lib/pptxgen.es-FsqHs8mD.js.map +1 -0
- package/lib/sanitize-O_3j1mNJ.js.map +1 -1
- package/lib/slack-BI3EQwYm.js.map +1 -1
- package/lib/svg-BKxumy-p.js.map +1 -1
- package/lib/teams-Cwz9lce0.js.map +1 -1
- package/lib/telegram-gYFqyMXb.js.map +1 -1
- package/lib/text-l1XNXBOC.js.map +1 -1
- package/lib/types/index.d.ts +43 -39
- package/lib/types/index.d.ts.map +1 -1
- package/lib/{vfs_fonts-Df1kkZ4Y.js → vfs_fonts-Cap07Jg3.js} +2 -2
- package/lib/vfs_fonts-Cap07Jg3.js.map +1 -0
- package/lib/whatsapp-CjSGoOKx.js.map +1 -1
- package/lib/{xlsx-Bb5TWyXQ.js → xlsx-Cvu4LBNy.js} +8 -2
- package/lib/xlsx-Cvu4LBNy.js.map +1 -0
- package/package.json +19 -7
- package/src/builder.ts +53 -44
- package/src/download.ts +32 -36
- package/src/env.d.ts +3 -17
- package/src/index.ts +6 -8
- package/src/nodes.ts +45 -45
- package/src/render.ts +45 -118
- package/src/renderers/confluence.ts +64 -80
- package/src/renderers/csv.ts +11 -18
- package/src/renderers/discord.ts +38 -50
- package/src/renderers/docx.ts +78 -120
- package/src/renderers/email.ts +73 -92
- package/src/renderers/google-chat.ts +35 -47
- package/src/renderers/html.ts +78 -101
- package/src/renderers/markdown.ts +43 -53
- package/src/renderers/notion.ts +63 -85
- package/src/renderers/pdf.ts +92 -115
- package/src/renderers/pptx.ts +60 -66
- package/src/renderers/slack.ts +49 -61
- package/src/renderers/svg.ts +49 -63
- package/src/renderers/teams.ts +68 -80
- package/src/renderers/telegram.ts +40 -54
- package/src/renderers/text.ts +44 -66
- package/src/renderers/whatsapp.ts +34 -48
- package/src/renderers/xlsx.ts +47 -61
- package/src/sanitize.ts +21 -25
- package/src/tests/document.test.ts +1337 -1385
- package/src/tests/stress.test.ts +111 -111
- package/src/types.ts +66 -65
- package/lib/dist-BsqdI2nY.js.map +0 -1
- package/lib/docx-BEBOihjl.js.map +0 -1
- package/lib/exceljs-BoIDUUaw.js.map +0 -1
- package/lib/pdf-DIUQUEdj.js.map +0 -1
- package/lib/pdfmake-DnmLxK4Q.js.map +0 -1
- package/lib/pptx-Dd33oL3_.js.map +0 -1
- package/lib/pptxgen.es-COcgXsyx.js.map +0 -1
- package/lib/vfs_fonts-Df1kkZ4Y.js.map +0 -1
- package/lib/xlsx-Bb5TWyXQ.js.map +0 -1
package/src/types.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// ─── Node Types ─────────────────────────────────────────────────────────────
|
|
2
2
|
|
|
3
3
|
export type NodeType =
|
|
4
|
-
|
|
|
5
|
-
|
|
|
6
|
-
|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
4
|
+
| "document"
|
|
5
|
+
| "page"
|
|
6
|
+
| "section"
|
|
7
|
+
| "row"
|
|
8
|
+
| "column"
|
|
9
|
+
| "heading"
|
|
10
|
+
| "text"
|
|
11
|
+
| "link"
|
|
12
|
+
| "image"
|
|
13
|
+
| "table"
|
|
14
|
+
| "list"
|
|
15
|
+
| "list-item"
|
|
16
|
+
| "page-break"
|
|
17
|
+
| "code"
|
|
18
|
+
| "divider"
|
|
19
|
+
| "spacer"
|
|
20
|
+
| "button"
|
|
21
|
+
| "quote"
|
|
22
22
|
|
|
23
23
|
/** A format-agnostic document node. */
|
|
24
24
|
export interface DocNode {
|
|
@@ -36,12 +36,12 @@ export type DocChild = DocNode | string
|
|
|
36
36
|
export interface ResolvedStyles {
|
|
37
37
|
fontSize?: number
|
|
38
38
|
fontFamily?: string
|
|
39
|
-
fontWeight?:
|
|
40
|
-
fontStyle?:
|
|
41
|
-
textDecoration?:
|
|
39
|
+
fontWeight?: "normal" | "bold" | number
|
|
40
|
+
fontStyle?: "normal" | "italic"
|
|
41
|
+
textDecoration?: "none" | "underline" | "line-through"
|
|
42
42
|
color?: string
|
|
43
43
|
backgroundColor?: string
|
|
44
|
-
textAlign?:
|
|
44
|
+
textAlign?: "left" | "center" | "right" | "justify"
|
|
45
45
|
lineHeight?: number
|
|
46
46
|
letterSpacing?: number
|
|
47
47
|
padding?: number | [number, number] | [number, number, number, number]
|
|
@@ -49,7 +49,7 @@ export interface ResolvedStyles {
|
|
|
49
49
|
borderRadius?: number
|
|
50
50
|
borderWidth?: number
|
|
51
51
|
borderColor?: string
|
|
52
|
-
borderStyle?:
|
|
52
|
+
borderStyle?: "solid" | "dashed" | "dotted"
|
|
53
53
|
width?: number | string
|
|
54
54
|
height?: number | string
|
|
55
55
|
maxWidth?: number | string
|
|
@@ -67,8 +67,8 @@ export interface DocumentProps {
|
|
|
67
67
|
children?: unknown
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export type PageSize =
|
|
71
|
-
export type PageOrientation =
|
|
70
|
+
export type PageSize = "A4" | "A3" | "A5" | "letter" | "legal" | "tabloid"
|
|
71
|
+
export type PageOrientation = "portrait" | "landscape"
|
|
72
72
|
|
|
73
73
|
export interface PageProps {
|
|
74
74
|
size?: PageSize
|
|
@@ -82,7 +82,7 @@ export interface PageProps {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export interface SectionProps {
|
|
85
|
-
direction?:
|
|
85
|
+
direction?: "column" | "row"
|
|
86
86
|
gap?: number
|
|
87
87
|
padding?: number | [number, number] | [number, number, number, number]
|
|
88
88
|
background?: string
|
|
@@ -93,20 +93,20 @@ export interface SectionProps {
|
|
|
93
93
|
|
|
94
94
|
export interface RowProps {
|
|
95
95
|
gap?: number
|
|
96
|
-
align?:
|
|
96
|
+
align?: "start" | "center" | "end" | "stretch"
|
|
97
97
|
children?: unknown
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export interface ColumnProps {
|
|
101
101
|
width?: number | string
|
|
102
|
-
align?:
|
|
102
|
+
align?: "start" | "center" | "end"
|
|
103
103
|
children?: unknown
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export interface HeadingProps {
|
|
107
107
|
level?: 1 | 2 | 3 | 4 | 5 | 6
|
|
108
108
|
color?: string
|
|
109
|
-
align?:
|
|
109
|
+
align?: "left" | "center" | "right"
|
|
110
110
|
children?: unknown
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -117,7 +117,7 @@ export interface TextProps {
|
|
|
117
117
|
italic?: boolean
|
|
118
118
|
underline?: boolean
|
|
119
119
|
strikethrough?: boolean
|
|
120
|
-
align?:
|
|
120
|
+
align?: "left" | "center" | "right" | "justify"
|
|
121
121
|
lineHeight?: number
|
|
122
122
|
children?: unknown
|
|
123
123
|
}
|
|
@@ -133,14 +133,14 @@ export interface ImageProps {
|
|
|
133
133
|
width?: number
|
|
134
134
|
height?: number
|
|
135
135
|
alt?: string
|
|
136
|
-
align?:
|
|
136
|
+
align?: "left" | "center" | "right"
|
|
137
137
|
caption?: string
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export interface TableColumn {
|
|
141
141
|
header: string
|
|
142
142
|
width?: number | string
|
|
143
|
-
align?:
|
|
143
|
+
align?: "left" | "center" | "right"
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
export interface TableProps {
|
|
@@ -187,7 +187,7 @@ export interface ButtonProps {
|
|
|
187
187
|
color?: string
|
|
188
188
|
borderRadius?: number
|
|
189
189
|
padding?: number | [number, number]
|
|
190
|
-
align?:
|
|
190
|
+
align?: "left" | "center" | "right"
|
|
191
191
|
children?: unknown
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -199,24 +199,24 @@ export interface QuoteProps {
|
|
|
199
199
|
// ─── Render Types ───────────────────────────────────────────────────────────
|
|
200
200
|
|
|
201
201
|
export type OutputFormat =
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
-
|
|
|
215
|
-
|
|
|
216
|
-
|
|
|
217
|
-
|
|
|
218
|
-
|
|
|
219
|
-
|
|
|
202
|
+
| "html"
|
|
203
|
+
| "pdf"
|
|
204
|
+
| "docx"
|
|
205
|
+
| "pptx"
|
|
206
|
+
| "email"
|
|
207
|
+
| "xlsx"
|
|
208
|
+
| "md"
|
|
209
|
+
| "text"
|
|
210
|
+
| "csv"
|
|
211
|
+
| "svg"
|
|
212
|
+
| "slack"
|
|
213
|
+
| "teams"
|
|
214
|
+
| "discord"
|
|
215
|
+
| "telegram"
|
|
216
|
+
| "notion"
|
|
217
|
+
| "confluence"
|
|
218
|
+
| "whatsapp"
|
|
219
|
+
| "google-chat"
|
|
220
220
|
|
|
221
221
|
export interface RenderOptions {
|
|
222
222
|
/** Custom styles to apply (overrides component styles). */
|
|
@@ -224,12 +224,9 @@ export interface RenderOptions {
|
|
|
224
224
|
/** Base URL for relative image sources. */
|
|
225
225
|
baseUrl?: string
|
|
226
226
|
/** Text direction — 'ltr' (default) or 'rtl'. */
|
|
227
|
-
direction?:
|
|
227
|
+
direction?: "ltr" | "rtl"
|
|
228
228
|
/** Custom font configuration for PDF. */
|
|
229
|
-
fonts?: Record<
|
|
230
|
-
string,
|
|
231
|
-
{ normal?: string; bold?: string; italics?: string; bolditalics?: string }
|
|
232
|
-
>
|
|
229
|
+
fonts?: Record<string, { normal?: string; bold?: string; italics?: string; bolditalics?: string }>
|
|
233
230
|
}
|
|
234
231
|
|
|
235
232
|
export type RenderResult = string | Uint8Array
|
|
@@ -242,19 +239,23 @@ export interface DocumentRenderer {
|
|
|
242
239
|
// ─── Builder Types ──────────────────────────────────────────────────────────
|
|
243
240
|
|
|
244
241
|
export interface DocumentBuilder {
|
|
245
|
-
heading(text: string, props?: Omit<HeadingProps,
|
|
246
|
-
text(text: string, props?: Omit<TextProps,
|
|
247
|
-
paragraph(text: string, props?: Omit<TextProps,
|
|
248
|
-
image(src: string, props?: Omit<ImageProps,
|
|
242
|
+
heading(text: string, props?: Omit<HeadingProps, "children">): DocumentBuilder
|
|
243
|
+
text(text: string, props?: Omit<TextProps, "children">): DocumentBuilder
|
|
244
|
+
paragraph(text: string, props?: Omit<TextProps, "children">): DocumentBuilder
|
|
245
|
+
image(src: string, props?: Omit<ImageProps, "src">): DocumentBuilder
|
|
249
246
|
table(props: TableProps): DocumentBuilder
|
|
250
|
-
list(items: string[], props?: Omit<ListProps,
|
|
251
|
-
code(text: string, props?: Omit<CodeProps,
|
|
247
|
+
list(items: string[], props?: Omit<ListProps, "children">): DocumentBuilder
|
|
248
|
+
code(text: string, props?: Omit<CodeProps, "children">): DocumentBuilder
|
|
252
249
|
divider(props?: DividerProps): DocumentBuilder
|
|
253
250
|
spacer(height: number): DocumentBuilder
|
|
254
|
-
quote(text: string, props?: Omit<QuoteProps,
|
|
255
|
-
button(text: string, props: Omit<ButtonProps,
|
|
256
|
-
link(text: string, props: Omit<LinkProps,
|
|
251
|
+
quote(text: string, props?: Omit<QuoteProps, "children">): DocumentBuilder
|
|
252
|
+
button(text: string, props: Omit<ButtonProps, "children">): DocumentBuilder
|
|
253
|
+
link(text: string, props: Omit<LinkProps, "children">): DocumentBuilder
|
|
257
254
|
pageBreak(): DocumentBuilder
|
|
255
|
+
/** Add an arbitrary DocNode (or fragment returned by a helper function). */
|
|
256
|
+
add(node: DocNode | DocNode[]): DocumentBuilder
|
|
257
|
+
/** Add a group of nodes as a logical section. */
|
|
258
|
+
section(children: DocNode[]): DocumentBuilder
|
|
258
259
|
/** Add a chart snapshot from a @pyreon/charts instance. */
|
|
259
260
|
chart(
|
|
260
261
|
instance: unknown,
|