@hilvana/office 0.0.0-stage → 0.1.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.
@@ -0,0 +1,129 @@
1
+ /** Intermediate document model produced by the .docx reader and consumed by the layout engine. All lengths are in PDF points. */
2
+ export interface RunStyle {
3
+ font: string;
4
+ size: number;
5
+ bold: boolean;
6
+ italic: boolean;
7
+ underline: boolean;
8
+ strike: boolean;
9
+ color: string;
10
+ /** True when no explicit color was set (Word's "automatic"): it turns white on dark shading. */
11
+ autoColor?: boolean;
12
+ highlight?: string;
13
+ vertAlign?: 'superscript' | 'subscript';
14
+ caps: boolean;
15
+ }
16
+ export type Inline = {
17
+ kind: 'text';
18
+ text: string;
19
+ style: RunStyle;
20
+ } | {
21
+ kind: 'tab';
22
+ style: RunStyle;
23
+ } | {
24
+ kind: 'break';
25
+ style: RunStyle;
26
+ } | {
27
+ kind: 'image';
28
+ bytes: Uint8Array;
29
+ format: 'png' | 'jpg';
30
+ width: number;
31
+ height: number;
32
+ };
33
+ export interface ParagraphStyle {
34
+ align: 'left' | 'center' | 'right' | 'justify';
35
+ spaceBefore: number;
36
+ spaceAfter: number;
37
+ /** Line height: a multiple of the font's natural line height, or an exact/minimum value in points. */
38
+ line: {
39
+ rule: 'auto';
40
+ value: number;
41
+ } | {
42
+ rule: 'exact' | 'atLeast';
43
+ value: number;
44
+ };
45
+ indentLeft: number;
46
+ indentRight: number;
47
+ /** Positive: first-line indent. Negative: hanging indent. */
48
+ firstLine: number;
49
+ pageBreakBefore: boolean;
50
+ keepNext: boolean;
51
+ contextualSpacing: boolean;
52
+ styleId?: string;
53
+ shading?: string;
54
+ borderBottom?: {
55
+ width: number;
56
+ color: string;
57
+ };
58
+ }
59
+ export interface Paragraph {
60
+ type: 'paragraph';
61
+ style: ParagraphStyle;
62
+ inlines: Inline[];
63
+ /** List label such as "1." or "•", rendered in the hanging indent. */
64
+ label?: {
65
+ text: string;
66
+ style: RunStyle;
67
+ };
68
+ }
69
+ export interface TableCell {
70
+ blocks: Block[];
71
+ span: number;
72
+ /** "restart" starts a vertical merge, "continue" is covered by the cell above. */
73
+ vMerge?: 'restart' | 'continue';
74
+ shading?: string;
75
+ vAlign: 'top' | 'center' | 'bottom';
76
+ /** Per-side borders set on the cell itself; null means explicitly none. Absent sides follow the table. */
77
+ borders?: Partial<Record<'top' | 'right' | 'bottom' | 'left', {
78
+ width: number;
79
+ color: string;
80
+ } | null>>;
81
+ }
82
+ export interface TableRow {
83
+ cells: TableCell[];
84
+ minHeight: number;
85
+ header: boolean;
86
+ }
87
+ export interface Table {
88
+ type: 'table';
89
+ columns: number[];
90
+ rows: TableRow[];
91
+ borders: boolean;
92
+ borderColor: string;
93
+ indent: number;
94
+ cellPadding: {
95
+ top: number;
96
+ right: number;
97
+ bottom: number;
98
+ left: number;
99
+ };
100
+ }
101
+ /** A page break; `section` is set when it ends a section, with that section's page setup. */
102
+ export type Block = Paragraph | Table | {
103
+ type: 'pageBreak';
104
+ section?: PageSetup;
105
+ };
106
+ export interface PageSetup {
107
+ width: number;
108
+ height: number;
109
+ margin: {
110
+ top: number;
111
+ right: number;
112
+ bottom: number;
113
+ left: number;
114
+ };
115
+ }
116
+ export interface Section {
117
+ page: PageSetup;
118
+ blocks: Block[];
119
+ }
120
+ export interface DocModel {
121
+ /** Page setup of the last section (the document default). */
122
+ page: PageSetup;
123
+ blocks: Block[];
124
+ /** The document split by section breaks, each with its own page size, orientation and margins. */
125
+ sections: Section[];
126
+ defaultTab: number;
127
+ warnings: string[];
128
+ }
129
+ //# sourceMappingURL=model.d.ts.map
package/dist/model.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Intermediate document model produced by the .docx reader and consumed by the layout engine. All lengths are in PDF points. */
2
+ export {};
3
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1,15 @@
1
+ import type { Block, DocModel } from './model.js';
2
+ export interface ParsedDocx extends DocModel {
3
+ header?: Block[];
4
+ footer?: Block[];
5
+ headerDistance: number;
6
+ footerDistance: number;
7
+ }
8
+ export declare class DocxError extends Error {
9
+ readonly code: 'NOT_DOCX' | 'ENCRYPTED_DOCX' | 'CORRUPT_DOCX';
10
+ constructor(code: 'NOT_DOCX' | 'ENCRYPTED_DOCX' | 'CORRUPT_DOCX', message?: string);
11
+ }
12
+ /** True when the bytes look like a Word .docx package. */
13
+ export declare function isDocx(bytes: Uint8Array): boolean;
14
+ export declare function parseDocx(bytes: Uint8Array): ParsedDocx;
15
+ //# sourceMappingURL=parse.d.ts.map