reamkit 0.1.0-alpha.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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/esm/bidi/algorithm.d.ts +9 -0
  4. package/dist/esm/bidi/algorithm.js +458 -0
  5. package/dist/esm/bidi/char-types.d.ts +2 -0
  6. package/dist/esm/bidi/char-types.js +439 -0
  7. package/dist/esm/bidi/index.d.ts +14 -0
  8. package/dist/esm/bidi/index.js +25 -0
  9. package/dist/esm/converter/docx-to-pdf.d.ts +15 -0
  10. package/dist/esm/converter/docx-to-pdf.js +227 -0
  11. package/dist/esm/converter/index.d.ts +4 -0
  12. package/dist/esm/converter/index.js +2 -0
  13. package/dist/esm/converter/xlsx-to-pdf.d.ts +13 -0
  14. package/dist/esm/converter/xlsx-to-pdf.js +515 -0
  15. package/dist/esm/crypto/asn1.d.ts +23 -0
  16. package/dist/esm/crypto/asn1.js +123 -0
  17. package/dist/esm/crypto/cms.d.ts +9 -0
  18. package/dist/esm/crypto/cms.js +34 -0
  19. package/dist/esm/crypto/index.d.ts +2 -0
  20. package/dist/esm/crypto/index.js +1 -0
  21. package/dist/esm/document-model/index.d.ts +1 -0
  22. package/dist/esm/document-model/index.js +0 -0
  23. package/dist/esm/document-model/types.d.ts +403 -0
  24. package/dist/esm/font/arabic-joining.d.ts +4 -0
  25. package/dist/esm/font/arabic-joining.js +97 -0
  26. package/dist/esm/font/binary-reader.d.ts +13 -0
  27. package/dist/esm/font/binary-reader.js +44 -0
  28. package/dist/esm/font/font-registry.d.ts +19 -0
  29. package/dist/esm/font/font-registry.js +39 -0
  30. package/dist/esm/font/index.d.ts +7 -0
  31. package/dist/esm/font/opentype-layout.d.ts +21 -0
  32. package/dist/esm/font/opentype-layout.js +329 -0
  33. package/dist/esm/font/ttf-parser.d.ts +29 -0
  34. package/dist/esm/font/ttf-parser.js +290 -0
  35. package/dist/esm/font/ttf-subset.d.ts +3 -0
  36. package/dist/esm/font/ttf-subset.js +201 -0
  37. package/dist/esm/fonts/index.d.ts +2 -0
  38. package/dist/esm/fonts/remote-fonts.d.ts +13 -0
  39. package/dist/esm/fonts/remote-fonts.js +94 -0
  40. package/dist/esm/hyphenation/index.d.ts +10 -0
  41. package/dist/esm/hyphenation/index.js +38 -0
  42. package/dist/esm/hyphenation/liang.d.ts +10 -0
  43. package/dist/esm/hyphenation/liang.js +79 -0
  44. package/dist/esm/hyphenation/patterns-en-us.d.ts +2 -0
  45. package/dist/esm/hyphenation/patterns-en-us.js +5 -0
  46. package/dist/esm/hyphenation/patterns-ru.d.ts +2 -0
  47. package/dist/esm/hyphenation/patterns-ru.js +5 -0
  48. package/dist/esm/index.d.ts +12 -0
  49. package/dist/esm/index.js +13 -0
  50. package/dist/esm/line-breaker/index.d.ts +2 -0
  51. package/dist/esm/line-breaker/knuth-plass.d.ts +30 -0
  52. package/dist/esm/line-breaker/knuth-plass.js +172 -0
  53. package/dist/esm/numbering/index.d.ts +1 -0
  54. package/dist/esm/numbering/state.d.ts +6 -0
  55. package/dist/esm/numbering/state.js +83 -0
  56. package/dist/esm/ooxml/drawingml/chart-parser.d.ts +3 -0
  57. package/dist/esm/ooxml/drawingml/chart-parser.js +218 -0
  58. package/dist/esm/ooxml/drawingml/colors.d.ts +17 -0
  59. package/dist/esm/ooxml/drawingml/colors.js +125 -0
  60. package/dist/esm/ooxml/drawingml/theme-parser.d.ts +1 -0
  61. package/dist/esm/ooxml/drawingml/theme-parser.js +55 -0
  62. package/dist/esm/ooxml/index.d.ts +1 -0
  63. package/dist/esm/ooxml/math/omml-parser.d.ts +4 -0
  64. package/dist/esm/ooxml/math/omml-parser.js +217 -0
  65. package/dist/esm/ooxml/spreadsheet/cell-reference.d.ts +6 -0
  66. package/dist/esm/ooxml/spreadsheet/cell-reference.js +26 -0
  67. package/dist/esm/ooxml/spreadsheet/defined-name-ref.d.ts +11 -0
  68. package/dist/esm/ooxml/spreadsheet/defined-name-ref.js +64 -0
  69. package/dist/esm/ooxml/spreadsheet/index.d.ts +12 -0
  70. package/dist/esm/ooxml/spreadsheet/index.js +7 -0
  71. package/dist/esm/ooxml/spreadsheet/number-format.d.ts +1 -0
  72. package/dist/esm/ooxml/spreadsheet/number-format.js +438 -0
  73. package/dist/esm/ooxml/spreadsheet/shared-strings-parser.d.ts +1 -0
  74. package/dist/esm/ooxml/spreadsheet/shared-strings-parser.js +47 -0
  75. package/dist/esm/ooxml/spreadsheet/styles-parser.d.ts +52 -0
  76. package/dist/esm/ooxml/spreadsheet/styles-parser.js +225 -0
  77. package/dist/esm/ooxml/spreadsheet/workbook-parser.d.ts +16 -0
  78. package/dist/esm/ooxml/spreadsheet/workbook-parser.js +90 -0
  79. package/dist/esm/ooxml/spreadsheet/worksheet-parser.d.ts +60 -0
  80. package/dist/esm/ooxml/spreadsheet/worksheet-parser.js +311 -0
  81. package/dist/esm/ooxml/wordproc/document-parser.d.ts +9 -0
  82. package/dist/esm/ooxml/wordproc/document-parser.js +274 -0
  83. package/dist/esm/ooxml/wordproc/drawing-parser.d.ts +33 -0
  84. package/dist/esm/ooxml/wordproc/drawing-parser.js +374 -0
  85. package/dist/esm/ooxml/wordproc/font-table.d.ts +15 -0
  86. package/dist/esm/ooxml/wordproc/font-table.js +82 -0
  87. package/dist/esm/ooxml/wordproc/index.d.ts +10 -0
  88. package/dist/esm/ooxml/wordproc/index.js +9 -0
  89. package/dist/esm/ooxml/wordproc/numbering-parser.d.ts +3 -0
  90. package/dist/esm/ooxml/wordproc/numbering-parser.js +89 -0
  91. package/dist/esm/ooxml/wordproc/paragraph-properties.d.ts +2 -0
  92. package/dist/esm/ooxml/wordproc/paragraph-properties.js +85 -0
  93. package/dist/esm/ooxml/wordproc/po-helpers.d.ts +14 -0
  94. package/dist/esm/ooxml/wordproc/po-helpers.js +76 -0
  95. package/dist/esm/ooxml/wordproc/po-to-flat.d.ts +2 -0
  96. package/dist/esm/ooxml/wordproc/po-to-flat.js +28 -0
  97. package/dist/esm/ooxml/wordproc/run-properties.d.ts +2 -0
  98. package/dist/esm/ooxml/wordproc/run-properties.js +82 -0
  99. package/dist/esm/ooxml/wordproc/settings-parser.d.ts +5 -0
  100. package/dist/esm/ooxml/wordproc/settings-parser.js +26 -0
  101. package/dist/esm/ooxml/wordproc/styles-parser.d.ts +3 -0
  102. package/dist/esm/ooxml/wordproc/styles-parser.js +67 -0
  103. package/dist/esm/ooxml/wordproc/table-parser.d.ts +3 -0
  104. package/dist/esm/ooxml/wordproc/table-parser.js +162 -0
  105. package/dist/esm/ooxml/wordproc/text-extractor.d.ts +1 -0
  106. package/dist/esm/ooxml/wordproc/text-extractor.js +1 -0
  107. package/dist/esm/ooxml/wordproc/xml-helpers.d.ts +9 -0
  108. package/dist/esm/ooxml/wordproc/xml-helpers.js +36 -0
  109. package/dist/esm/opc/core-properties.d.ts +11 -0
  110. package/dist/esm/opc/core-properties.js +51 -0
  111. package/dist/esm/opc/index.d.ts +5 -0
  112. package/dist/esm/opc/index.js +3 -0
  113. package/dist/esm/opc/package.d.ts +26 -0
  114. package/dist/esm/opc/package.js +113 -0
  115. package/dist/esm/opc/relationship-types.d.ts +3 -0
  116. package/dist/esm/opc/relationship-types.js +4 -0
  117. package/dist/esm/opc/relationships.d.ts +7 -0
  118. package/dist/esm/opc/relationships.js +28 -0
  119. package/dist/esm/pdf/arc-to-bezier.d.ts +5 -0
  120. package/dist/esm/pdf/arc-to-bezier.js +58 -0
  121. package/dist/esm/pdf/builtin-fonts.d.ts +2 -0
  122. package/dist/esm/pdf/chart-geometry.d.ts +64 -0
  123. package/dist/esm/pdf/chart-geometry.js +674 -0
  124. package/dist/esm/pdf/cid-font.d.ts +15 -0
  125. package/dist/esm/pdf/cid-font.js +174 -0
  126. package/dist/esm/pdf/embedded-file.d.ts +11 -0
  127. package/dist/esm/pdf/embedded-file.js +23 -0
  128. package/dist/esm/pdf/icc-profile.d.ts +1 -0
  129. package/dist/esm/pdf/icc-profile.js +166 -0
  130. package/dist/esm/pdf/image-xobject.d.ts +13 -0
  131. package/dist/esm/pdf/image-xobject.js +335 -0
  132. package/dist/esm/pdf/index.d.ts +11 -0
  133. package/dist/esm/pdf/index.js +5 -0
  134. package/dist/esm/pdf/math-layout.d.ts +45 -0
  135. package/dist/esm/pdf/math-layout.js +1138 -0
  136. package/dist/esm/pdf/objects.d.ts +32 -0
  137. package/dist/esm/pdf/objects.js +54 -0
  138. package/dist/esm/pdf/preset-geometry.d.ts +6 -0
  139. package/dist/esm/pdf/preset-geometry.js +199 -0
  140. package/dist/esm/pdf/serialize.d.ts +3 -0
  141. package/dist/esm/pdf/serialize.js +54 -0
  142. package/dist/esm/pdf/signature.d.ts +25 -0
  143. package/dist/esm/pdf/signature.js +126 -0
  144. package/dist/esm/pdf/struct-tree.d.ts +31 -0
  145. package/dist/esm/pdf/struct-tree.js +109 -0
  146. package/dist/esm/pdf/styled-page-renderer.d.ts +43 -0
  147. package/dist/esm/pdf/styled-page-renderer.js +2317 -0
  148. package/dist/esm/pdf/text-encoding.d.ts +2 -0
  149. package/dist/esm/pdf/text-page-renderer.d.ts +16 -0
  150. package/dist/esm/pdf/text-page-renderer.js +4 -0
  151. package/dist/esm/pdf/vector-graphics.d.ts +46 -0
  152. package/dist/esm/pdf/vector-graphics.js +103 -0
  153. package/dist/esm/pdf/writer.d.ts +10 -0
  154. package/dist/esm/pdf/writer.js +81 -0
  155. package/dist/esm/pdf/xmp.d.ts +13 -0
  156. package/dist/esm/pdf/xmp.js +38 -0
  157. package/dist/esm/style-cascade/index.d.ts +3 -0
  158. package/dist/esm/style-cascade/resolver.d.ts +4 -0
  159. package/dist/esm/style-cascade/resolver.js +96 -0
  160. package/dist/esm/style-cascade/types.d.ts +29 -0
  161. package/dist/esm/style-cascade/types.js +26 -0
  162. package/package.json +90 -0
@@ -0,0 +1,34 @@
1
+ import { certIssuerAndSerial, cmsTime, concat, explicit, integer, nullValue, octetString, oid, seq, set, setOfBody, tlv } from "./asn1.js";
2
+ //#region src/crypto/cms.ts
3
+ var OID = {
4
+ sha256: "2.16.840.1.101.3.4.2.1",
5
+ rsaEncryption: "1.2.840.113549.1.1.1",
6
+ ecdsaWithSHA256: "1.2.840.10045.4.3.2",
7
+ idData: "1.2.840.113549.1.7.1",
8
+ idSignedData: "1.2.840.113549.1.7.2",
9
+ contentType: "1.2.840.113549.1.9.3",
10
+ messageDigest: "1.2.840.113549.1.9.4",
11
+ signingTime: "1.2.840.113549.1.9.5"
12
+ };
13
+ var sha256AlgId = () => seq(oid(OID.sha256));
14
+ var rsaAlgId = () => seq(oid(OID.rsaEncryption), nullValue());
15
+ var ecdsaAlgId = () => seq(oid(OID.ecdsaWithSHA256));
16
+ var attribute = (oidStr, value) => seq(oid(oidStr), set(value));
17
+ async function buildPkcs7Detached(params) {
18
+ const { issuer, serial } = certIssuerAndSerial(params.certificate);
19
+ const attrsBody = setOfBody([
20
+ attribute(OID.contentType, oid(OID.idData)),
21
+ attribute(OID.messageDigest, octetString(params.messageDigest)),
22
+ attribute(OID.signingTime, cmsTime(params.signingTime))
23
+ ]);
24
+ const signedAttrsForSigning = tlv(49, attrsBody);
25
+ const signedAttrsTagged = tlv(160, attrsBody);
26
+ const signature = await params.sign(signedAttrsForSigning);
27
+ const sigAlgId = params.signatureAlgorithm === "ecdsa" ? ecdsaAlgId() : rsaAlgId();
28
+ const signerInfo = seq(integer(1), seq(issuer, serial), sha256AlgId(), signedAttrsTagged, sigAlgId, octetString(signature));
29
+ const certificates = tlv(160, concat([params.certificate, ...params.extraCertificates ?? []]));
30
+ const signedData = seq(integer(1), set(sha256AlgId()), seq(oid(OID.idData)), certificates, set(signerInfo));
31
+ return seq(oid(OID.idSignedData), explicit(0, signedData));
32
+ }
33
+ //#endregion
34
+ export { buildPkcs7Detached };
@@ -0,0 +1,2 @@
1
+ export { buildPkcs7Detached } from './cms.js';
2
+ export type { CmsParams } from './cms.js';
@@ -0,0 +1 @@
1
+ import "./cms.js";
@@ -0,0 +1 @@
1
+ export type { AbstractNumbering, Alignment, Border, BorderStyle, BodyElement, CellBorders, CellMargins, CellProperties, CellShading, Chart, ChartBlock, ChartDataPoint, ChartSeries, ChartType, CustomGeometry, CustomPathCmd, DocumentModel, FontFamilyMap, HeaderFooterReference, HeaderFooterType, ImageBlock, InlineImage, MathAccent, MathBar, MathDelimiter, MathEqArray, MathFraction, MathFunc, MathGroupChr, MathLimit, MathMatrix, MathNary, MathNode, MathRadical, MathRow, MathRun, MathScript, Numbering, NumberingFormat, NumberingInstance, NumberingLevel, NumberingReference, PageMargins, PageSize, Paragraph, ParagraphProperties, Run, RunProperties, RowProperties, Section, SectionProperties, ShapeBlock, ShapeDash, ShapeFill, ShapeFillKind, ShapeGeometry, ShapeLine, ShapeTextBody, ShapeTransform, Style, StyleSheet, StyleType, Table, TableCell, TableProperties, TableRow, UnderlineStyle, VerticalAlign, } from './types.js';
File without changes
@@ -0,0 +1,403 @@
1
+ export type Alignment = 'left' | 'right' | 'center' | 'both' | 'distribute';
2
+ export type UnderlineStyle = 'none' | 'single' | 'double' | 'thick' | 'dotted' | 'dottedHeavy' | 'dash' | 'dashHeavy' | 'wave';
3
+ export type VerticalAlign = 'baseline' | 'superscript' | 'subscript';
4
+ export interface FontFamilyMap {
5
+ readonly ascii?: string;
6
+ readonly hAnsi?: string;
7
+ readonly cs?: string;
8
+ readonly eastAsia?: string;
9
+ }
10
+ export interface RunProperties {
11
+ readonly styleId?: string;
12
+ readonly bold?: boolean;
13
+ readonly italic?: boolean;
14
+ readonly underline?: UnderlineStyle;
15
+ readonly strike?: boolean;
16
+ readonly fontSizeHalfPoints?: number;
17
+ readonly colorHex?: string;
18
+ readonly fontFamily?: FontFamilyMap;
19
+ readonly verticalAlign?: VerticalAlign;
20
+ readonly rtl?: boolean;
21
+ readonly lang?: string;
22
+ }
23
+ export interface ParagraphProperties {
24
+ readonly styleId?: string;
25
+ readonly alignment?: Alignment;
26
+ readonly spacingBeforeTwips?: number;
27
+ readonly spacingAfterTwips?: number;
28
+ readonly spacingLineTwips?: number;
29
+ readonly spacingLineRule?: 'auto' | 'exact' | 'atLeast';
30
+ readonly indentLeftTwips?: number;
31
+ readonly indentRightTwips?: number;
32
+ readonly indentFirstLineTwips?: number;
33
+ readonly runProperties?: RunProperties;
34
+ readonly numbering?: NumberingReference;
35
+ readonly pageBreakBefore?: boolean;
36
+ readonly bidi?: boolean;
37
+ readonly outlineLevel?: number;
38
+ }
39
+ export interface InlineImage {
40
+ readonly imageId: string;
41
+ readonly widthEmu: number;
42
+ readonly heightEmu: number;
43
+ }
44
+ export type MathNode = MathRow | MathRun | MathFraction | MathScript | MathRadical | MathNary | MathFunc | MathLimit | MathDelimiter | MathMatrix | MathAccent | MathBar | MathGroupChr | MathEqArray;
45
+ export interface MathRow {
46
+ readonly type: 'row';
47
+ readonly children: ReadonlyArray<MathNode>;
48
+ }
49
+ export interface MathRun {
50
+ readonly type: 'run';
51
+ readonly text: string;
52
+ readonly italic?: boolean;
53
+ readonly bold?: boolean;
54
+ readonly nor?: boolean;
55
+ }
56
+ export interface MathFraction {
57
+ readonly type: 'fraction';
58
+ readonly num: MathNode;
59
+ readonly den: MathNode;
60
+ readonly barless?: boolean;
61
+ }
62
+ export interface MathScript {
63
+ readonly type: 'script';
64
+ readonly base: MathNode;
65
+ readonly sub?: MathNode;
66
+ readonly sup?: MathNode;
67
+ readonly pre?: boolean;
68
+ }
69
+ export interface MathRadical {
70
+ readonly type: 'radical';
71
+ readonly radicand: MathNode;
72
+ readonly degree?: MathNode;
73
+ }
74
+ export interface MathNary {
75
+ readonly type: 'nary';
76
+ readonly op: string;
77
+ readonly body: MathNode;
78
+ readonly sub?: MathNode;
79
+ readonly sup?: MathNode;
80
+ readonly limLoc?: 'undOvr' | 'subSup';
81
+ }
82
+ export interface MathFunc {
83
+ readonly type: 'func';
84
+ readonly name: MathNode;
85
+ readonly body: MathNode;
86
+ }
87
+ export interface MathLimit {
88
+ readonly type: 'limit';
89
+ readonly base: MathNode;
90
+ readonly lim: MathNode;
91
+ readonly pos: 'low' | 'upp';
92
+ }
93
+ export interface MathDelimiter {
94
+ readonly type: 'delimiter';
95
+ readonly begChr: string;
96
+ readonly endChr: string;
97
+ readonly sepChr?: string;
98
+ readonly children: ReadonlyArray<MathNode>;
99
+ }
100
+ export interface MathMatrix {
101
+ readonly type: 'matrix';
102
+ readonly rows: ReadonlyArray<ReadonlyArray<MathNode>>;
103
+ }
104
+ export interface MathAccent {
105
+ readonly type: 'accent';
106
+ readonly char: string;
107
+ readonly base: MathNode;
108
+ }
109
+ export interface MathBar {
110
+ readonly type: 'bar';
111
+ readonly base: MathNode;
112
+ readonly pos: 'top' | 'bot';
113
+ }
114
+ export interface MathGroupChr {
115
+ readonly type: 'groupChr';
116
+ readonly char: string;
117
+ readonly base: MathNode;
118
+ readonly pos: 'top' | 'bot';
119
+ }
120
+ export interface MathEqArray {
121
+ readonly type: 'eqArr';
122
+ readonly rows: ReadonlyArray<MathNode>;
123
+ }
124
+ export interface Run {
125
+ readonly text: string;
126
+ readonly properties: RunProperties;
127
+ readonly inlineImage?: InlineImage;
128
+ readonly math?: MathNode;
129
+ readonly pageBreak?: boolean;
130
+ }
131
+ export interface Paragraph {
132
+ readonly properties: ParagraphProperties;
133
+ readonly runs: ReadonlyArray<Run>;
134
+ }
135
+ export type NumberingFormat = 'decimal' | 'lowerLetter' | 'upperLetter' | 'lowerRoman' | 'upperRoman' | 'bullet' | 'none';
136
+ export interface NumberingReference {
137
+ readonly numId: string;
138
+ readonly ilvl: number;
139
+ }
140
+ export interface NumberingLevel {
141
+ readonly ilvl: number;
142
+ readonly start: number;
143
+ readonly format: NumberingFormat;
144
+ readonly lvlText: string;
145
+ readonly paragraphProperties: ParagraphProperties;
146
+ readonly runProperties: RunProperties;
147
+ }
148
+ export interface AbstractNumbering {
149
+ readonly id: string;
150
+ readonly levels: ReadonlyMap<number, NumberingLevel>;
151
+ }
152
+ export interface NumberingInstance {
153
+ readonly numId: string;
154
+ readonly abstractNumId: string;
155
+ }
156
+ export interface Numbering {
157
+ readonly abstractNums: ReadonlyMap<string, AbstractNumbering>;
158
+ readonly numInstances: ReadonlyMap<string, NumberingInstance>;
159
+ }
160
+ export type StyleType = 'paragraph' | 'character' | 'table' | 'numbering';
161
+ export interface Style {
162
+ readonly id: string;
163
+ readonly type: StyleType;
164
+ readonly basedOn?: string;
165
+ readonly isDefault: boolean;
166
+ readonly runProperties: RunProperties;
167
+ readonly paragraphProperties: ParagraphProperties;
168
+ }
169
+ export interface StyleSheet {
170
+ readonly defaultRunProperties: RunProperties;
171
+ readonly defaultParagraphProperties: ParagraphProperties;
172
+ readonly styles: ReadonlyMap<string, Style>;
173
+ }
174
+ export type BorderStyle = 'none' | 'single' | 'double' | 'thick' | 'dotted' | 'dashed';
175
+ export interface Border {
176
+ readonly style: BorderStyle;
177
+ readonly sizeEighthPt?: number;
178
+ readonly colorHex?: string;
179
+ }
180
+ export interface CellBorders {
181
+ readonly top?: Border;
182
+ readonly right?: Border;
183
+ readonly bottom?: Border;
184
+ readonly left?: Border;
185
+ readonly insideH?: Border;
186
+ readonly insideV?: Border;
187
+ }
188
+ export interface CellMargins {
189
+ readonly topTwips?: number;
190
+ readonly rightTwips?: number;
191
+ readonly bottomTwips?: number;
192
+ readonly leftTwips?: number;
193
+ }
194
+ export interface CellShading {
195
+ readonly colorHex: string;
196
+ }
197
+ export interface CellProperties {
198
+ readonly widthTwips?: number;
199
+ readonly gridSpan?: number;
200
+ readonly vMerge?: 'restart' | 'continue';
201
+ readonly borders?: CellBorders;
202
+ readonly margins?: CellMargins;
203
+ readonly shading?: CellShading;
204
+ }
205
+ export interface RowProperties {
206
+ readonly heightTwips?: number;
207
+ readonly heightRule?: 'auto' | 'atLeast' | 'exact';
208
+ readonly cantSplit?: boolean;
209
+ readonly isHeader?: boolean;
210
+ readonly pageBreakBefore?: boolean;
211
+ }
212
+ export interface TableProperties {
213
+ readonly widthTwips?: number;
214
+ readonly widthType?: 'auto' | 'dxa' | 'pct' | 'nil';
215
+ readonly layout?: 'auto' | 'fixed';
216
+ readonly defaultCellMargins?: CellMargins;
217
+ readonly borders?: CellBorders;
218
+ readonly alignment?: 'left' | 'center' | 'right';
219
+ }
220
+ export interface TableCell {
221
+ readonly properties: CellProperties;
222
+ readonly content: ReadonlyArray<BodyElement>;
223
+ }
224
+ export interface TableRow {
225
+ readonly properties: RowProperties;
226
+ readonly cells: ReadonlyArray<TableCell>;
227
+ }
228
+ export interface Table {
229
+ readonly properties: TableProperties;
230
+ readonly grid: ReadonlyArray<number>;
231
+ readonly rows: ReadonlyArray<TableRow>;
232
+ }
233
+ export interface ImageBlock {
234
+ readonly imageId: string;
235
+ readonly widthEmu: number;
236
+ readonly heightEmu: number;
237
+ readonly paragraphProperties: ParagraphProperties;
238
+ readonly altText?: string;
239
+ }
240
+ export type CustomPathCmd = {
241
+ readonly cmd: 'move';
242
+ readonly x: number;
243
+ readonly y: number;
244
+ } | {
245
+ readonly cmd: 'line';
246
+ readonly x: number;
247
+ readonly y: number;
248
+ } | {
249
+ readonly cmd: 'cubic';
250
+ readonly x1: number;
251
+ readonly y1: number;
252
+ readonly x2: number;
253
+ readonly y2: number;
254
+ readonly x: number;
255
+ readonly y: number;
256
+ } | {
257
+ readonly cmd: 'quad';
258
+ readonly x1: number;
259
+ readonly y1: number;
260
+ readonly x: number;
261
+ readonly y: number;
262
+ } | {
263
+ readonly cmd: 'arc';
264
+ readonly wR: number;
265
+ readonly hR: number;
266
+ readonly stAng: number;
267
+ readonly swAng: number;
268
+ } | {
269
+ readonly cmd: 'close';
270
+ };
271
+ export interface CustomGeometry {
272
+ readonly pathWidth: number;
273
+ readonly pathHeight: number;
274
+ readonly commands: ReadonlyArray<CustomPathCmd>;
275
+ }
276
+ export interface ShapeGeometry {
277
+ readonly kind: 'preset' | 'custom';
278
+ readonly preset?: string;
279
+ readonly adjust?: ReadonlyMap<string, number>;
280
+ readonly custom?: CustomGeometry;
281
+ }
282
+ export type ShapeFillKind = 'none' | 'solid';
283
+ export interface ShapeFill {
284
+ readonly kind: ShapeFillKind;
285
+ readonly colorHex?: string;
286
+ }
287
+ export type ShapeDash = 'solid' | 'dot' | 'dash' | 'dashDot' | 'lgDash' | 'lgDashDot' | 'sysDash' | 'sysDot';
288
+ export interface ShapeLine {
289
+ readonly widthEmu?: number;
290
+ readonly colorHex?: string;
291
+ readonly dash?: ShapeDash;
292
+ readonly cap?: 'flat' | 'round' | 'square';
293
+ readonly fill?: 'solid' | 'none';
294
+ }
295
+ export interface ShapeTransform {
296
+ readonly rotation60k?: number;
297
+ readonly flipH?: boolean;
298
+ readonly flipV?: boolean;
299
+ }
300
+ export interface ShapeTextBody {
301
+ readonly content: ReadonlyArray<BodyElement>;
302
+ readonly insetLeftEmu?: number;
303
+ readonly insetTopEmu?: number;
304
+ readonly insetRightEmu?: number;
305
+ readonly insetBottomEmu?: number;
306
+ readonly anchor?: 't' | 'ctr' | 'b';
307
+ }
308
+ export interface ShapeBlock {
309
+ readonly widthEmu: number;
310
+ readonly heightEmu: number;
311
+ readonly geometry: ShapeGeometry;
312
+ readonly fill: ShapeFill;
313
+ readonly line?: ShapeLine;
314
+ readonly transform?: ShapeTransform;
315
+ readonly text?: ShapeTextBody;
316
+ readonly paragraphProperties: ParagraphProperties;
317
+ readonly altText?: string;
318
+ }
319
+ export type ChartType = 'bar' | 'line' | 'pie' | 'area' | 'scatter' | 'unknown';
320
+ export interface ChartDataPoint {
321
+ readonly idx: number;
322
+ readonly colorHex: string;
323
+ }
324
+ export interface ChartSeries {
325
+ readonly name?: string;
326
+ readonly values: ReadonlyArray<number>;
327
+ readonly xValues?: ReadonlyArray<number>;
328
+ readonly colorHex?: string;
329
+ readonly pointColors?: ReadonlyArray<ChartDataPoint>;
330
+ }
331
+ export interface Chart {
332
+ readonly type: ChartType;
333
+ readonly title?: string;
334
+ readonly categories: ReadonlyArray<string>;
335
+ readonly series: ReadonlyArray<ChartSeries>;
336
+ readonly hasLegend: boolean;
337
+ readonly legendPos?: 'r' | 'l' | 't' | 'b';
338
+ readonly barDir?: 'col' | 'bar';
339
+ readonly grouping?: 'clustered' | 'stacked' | 'percentStacked' | 'standard';
340
+ readonly doughnut?: boolean;
341
+ readonly showValues?: boolean;
342
+ readonly catAxisTitle?: string;
343
+ readonly valAxisTitle?: string;
344
+ }
345
+ export interface ChartBlock {
346
+ readonly chartRelId: string;
347
+ readonly widthEmu: number;
348
+ readonly heightEmu: number;
349
+ readonly paragraphProperties: ParagraphProperties;
350
+ readonly altText?: string;
351
+ }
352
+ export type BodyElement = {
353
+ readonly kind: 'paragraph';
354
+ readonly paragraph: Paragraph;
355
+ } | {
356
+ readonly kind: 'table';
357
+ readonly table: Table;
358
+ } | {
359
+ readonly kind: 'image';
360
+ readonly image: ImageBlock;
361
+ } | {
362
+ readonly kind: 'shape';
363
+ readonly shape: ShapeBlock;
364
+ } | {
365
+ readonly kind: 'chart';
366
+ readonly chart: ChartBlock;
367
+ };
368
+ export interface PageSize {
369
+ readonly widthTwips: number;
370
+ readonly heightTwips: number;
371
+ readonly orientation?: 'portrait' | 'landscape';
372
+ }
373
+ export interface PageMargins {
374
+ readonly topTwips: number;
375
+ readonly rightTwips: number;
376
+ readonly bottomTwips: number;
377
+ readonly leftTwips: number;
378
+ readonly headerTwips?: number;
379
+ readonly footerTwips?: number;
380
+ }
381
+ export type HeaderFooterType = 'default' | 'first' | 'even';
382
+ export interface HeaderFooterReference {
383
+ readonly type: HeaderFooterType;
384
+ readonly relationshipId: string;
385
+ }
386
+ export interface SectionProperties {
387
+ readonly pageSize?: PageSize;
388
+ readonly margins?: PageMargins;
389
+ readonly headers: ReadonlyArray<HeaderFooterReference>;
390
+ readonly footers: ReadonlyArray<HeaderFooterReference>;
391
+ readonly titlePg?: boolean;
392
+ readonly evenAndOddHeaders?: boolean;
393
+ }
394
+ export interface Section {
395
+ readonly properties: SectionProperties;
396
+ readonly endIndex: number;
397
+ }
398
+ export interface DocumentModel {
399
+ readonly body: ReadonlyArray<BodyElement>;
400
+ readonly styleSheet: StyleSheet;
401
+ readonly numbering?: Numbering;
402
+ readonly section?: SectionProperties;
403
+ }
@@ -0,0 +1,4 @@
1
+ export type JoiningType = 'R' | 'L' | 'D' | 'C' | 'U' | 'T';
2
+ export type ArabicForm = 'isol' | 'init' | 'medi' | 'fina';
3
+ export declare function arabicJoiningType(cp: number): JoiningType;
4
+ export declare function assignArabicForms(cps: ReadonlyArray<number>): Array<ArabicForm>;
@@ -0,0 +1,97 @@
1
+ //#region src/font/arabic-joining.ts
2
+ var RIGHT_JOINING = new Set([
3
+ 1570,
4
+ 1571,
5
+ 1572,
6
+ 1573,
7
+ 1575,
8
+ 1577,
9
+ 1583,
10
+ 1584,
11
+ 1585,
12
+ 1586,
13
+ 1608,
14
+ 1649,
15
+ 1650,
16
+ 1651,
17
+ 1653,
18
+ 1654,
19
+ 1655,
20
+ 1672,
21
+ 1673,
22
+ 1674,
23
+ 1675,
24
+ 1676,
25
+ 1677,
26
+ 1678,
27
+ 1679,
28
+ 1680,
29
+ 1681,
30
+ 1682,
31
+ 1683,
32
+ 1684,
33
+ 1685,
34
+ 1686,
35
+ 1687,
36
+ 1688,
37
+ 1689,
38
+ 1728,
39
+ 1731,
40
+ 1732,
41
+ 1733,
42
+ 1734,
43
+ 1735,
44
+ 1736,
45
+ 1737,
46
+ 1738,
47
+ 1739,
48
+ 1741,
49
+ 1743,
50
+ 1746,
51
+ 1747,
52
+ 1749,
53
+ 1774,
54
+ 1775
55
+ ]);
56
+ function isTransparentMark(cp) {
57
+ return cp >= 1552 && cp <= 1562 || cp >= 1611 && cp <= 1631 || cp === 1648 || cp >= 1750 && cp <= 1756 || cp >= 1759 && cp <= 1764 || cp === 1767 || cp === 1768 || cp >= 1770 && cp <= 1773;
58
+ }
59
+ function arabicJoiningType(cp) {
60
+ if (cp === 1600) return "C";
61
+ if (cp === 8205) return "C";
62
+ if (cp === 8204) return "U";
63
+ if (isTransparentMark(cp)) return "T";
64
+ if (RIGHT_JOINING.has(cp)) return "R";
65
+ if (cp >= 1568 && cp <= 1610 || cp >= 1646 && cp <= 1747 || cp === 1791) return "D";
66
+ return "U";
67
+ }
68
+ var canJoinRight = (t) => t === "R" || t === "D" || t === "C";
69
+ var canJoinLeft = (t) => t === "L" || t === "D" || t === "C";
70
+ function assignArabicForms(cps) {
71
+ const types = cps.map(arabicJoiningType);
72
+ const forms = new Array(cps.length).fill("isol");
73
+ const prevNonT = new Array(cps.length).fill(-1);
74
+ const nextNonT = new Array(cps.length).fill(-1);
75
+ let last = -1;
76
+ for (let i = 0; i < cps.length; i++) {
77
+ prevNonT[i] = last;
78
+ if (types[i] !== "T") last = i;
79
+ }
80
+ let nxt = -1;
81
+ for (let i = cps.length - 1; i >= 0; i--) {
82
+ nextNonT[i] = nxt;
83
+ if (types[i] !== "T") nxt = i;
84
+ }
85
+ for (let i = 0; i < cps.length; i++) {
86
+ const t = types[i];
87
+ if (t === "U" || t === "T") continue;
88
+ const p = prevNonT[i];
89
+ const n = nextNonT[i];
90
+ const joinsPrev = canJoinRight(t) && p >= 0 && canJoinLeft(types[p]);
91
+ const joinsNext = canJoinLeft(t) && n >= 0 && canJoinRight(types[n]);
92
+ forms[i] = joinsPrev && joinsNext ? "medi" : joinsPrev ? "fina" : joinsNext ? "init" : "isol";
93
+ }
94
+ return forms;
95
+ }
96
+ //#endregion
97
+ export { assignArabicForms };
@@ -0,0 +1,13 @@
1
+ export declare class BigEndianReader {
2
+ readonly data: Uint8Array;
3
+ offset: number;
4
+ constructor(data: Uint8Array, offset?: number);
5
+ seek(offset: number): void;
6
+ skip(bytes: number): void;
7
+ u8(): number;
8
+ u16(): number;
9
+ i16(): number;
10
+ u32(): number;
11
+ i32(): number;
12
+ tag(): string;
13
+ }
@@ -0,0 +1,44 @@
1
+ //#region src/font/binary-reader.ts
2
+ var BigEndianReader = class {
3
+ constructor(data, offset = 0) {
4
+ this.data = data;
5
+ this.offset = offset;
6
+ }
7
+ seek(offset) {
8
+ this.offset = offset;
9
+ }
10
+ skip(bytes) {
11
+ this.offset += bytes;
12
+ }
13
+ u8() {
14
+ return this.data[this.offset++];
15
+ }
16
+ u16() {
17
+ const d = this.data;
18
+ const p = this.offset;
19
+ this.offset += 2;
20
+ return d[p] << 8 | d[p + 1];
21
+ }
22
+ i16() {
23
+ const v = this.u16();
24
+ return v >= 32768 ? v - 65536 : v;
25
+ }
26
+ u32() {
27
+ const d = this.data;
28
+ const p = this.offset;
29
+ this.offset += 4;
30
+ return d[p] * 16777216 + (d[p + 1] << 16 | d[p + 2] << 8 | d[p + 3]);
31
+ }
32
+ i32() {
33
+ const v = this.u32();
34
+ return v >= 2147483648 ? v - 4294967296 : v;
35
+ }
36
+ tag() {
37
+ const d = this.data;
38
+ const p = this.offset;
39
+ this.offset += 4;
40
+ return String.fromCharCode(d[p], d[p + 1], d[p + 2], d[p + 3]);
41
+ }
42
+ };
43
+ //#endregion
44
+ export { BigEndianReader };
@@ -0,0 +1,19 @@
1
+ import { ParsedTtf } from './ttf-parser.js';
2
+ export type FontVariant = 'regular' | 'bold' | 'italic' | 'boldItalic';
3
+ export interface FontBytesByVariant {
4
+ readonly regular: Uint8Array;
5
+ readonly bold?: Uint8Array;
6
+ readonly italic?: Uint8Array;
7
+ readonly boldItalic?: Uint8Array;
8
+ }
9
+ export declare class FontRegistry {
10
+ private readonly fonts;
11
+ private constructor();
12
+ static fromBytes(input: FontBytesByVariant): FontRegistry;
13
+ resolveByStyle(bold: boolean, italic: boolean): {
14
+ variant: FontVariant;
15
+ parsed: ParsedTtf;
16
+ };
17
+ entries(): IterableIterator<[FontVariant, ParsedTtf]>;
18
+ hasVariant(v: FontVariant): boolean;
19
+ }
@@ -0,0 +1,39 @@
1
+ import { parseTtf } from "./ttf-parser.js";
2
+ //#region src/font/font-registry.ts
3
+ var FontRegistry = class FontRegistry {
4
+ constructor(fonts) {
5
+ this.fonts = fonts;
6
+ }
7
+ static fromBytes(input) {
8
+ const map = /* @__PURE__ */ new Map();
9
+ map.set("regular", parseTtf(input.regular));
10
+ if (input.bold) map.set("bold", parseTtf(input.bold));
11
+ if (input.italic) map.set("italic", parseTtf(input.italic));
12
+ if (input.boldItalic) map.set("boldItalic", parseTtf(input.boldItalic));
13
+ return new FontRegistry(map);
14
+ }
15
+ resolveByStyle(bold, italic) {
16
+ const candidates = bold && italic ? [
17
+ "boldItalic",
18
+ "bold",
19
+ "italic",
20
+ "regular"
21
+ ] : bold ? ["bold", "regular"] : italic ? ["italic", "regular"] : ["regular"];
22
+ for (const v of candidates) {
23
+ const parsed = this.fonts.get(v);
24
+ if (parsed) return {
25
+ variant: v,
26
+ parsed
27
+ };
28
+ }
29
+ throw new Error("FontRegistry has no regular font");
30
+ }
31
+ entries() {
32
+ return this.fonts.entries();
33
+ }
34
+ hasVariant(v) {
35
+ return this.fonts.has(v);
36
+ }
37
+ };
38
+ //#endregion
39
+ export { FontRegistry };
@@ -0,0 +1,7 @@
1
+ export { parseTtf } from './ttf-parser.js';
2
+ export type { ParsedTtf, TtfTableInfo } from './ttf-parser.js';
3
+ export { subsetTtf, glyphClosure } from './ttf-subset.js';
4
+ export { FontRegistry } from './font-registry.js';
5
+ export type { FontVariant, FontBytesByVariant } from './font-registry.js';
6
+ export { parseGposKerning, parseGsubLigatures, shapeText } from './opentype-layout.js';
7
+ export type { KerningMap, LigatureMap, ShapedRun } from './opentype-layout.js';