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.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/esm/bidi/algorithm.d.ts +9 -0
- package/dist/esm/bidi/algorithm.js +458 -0
- package/dist/esm/bidi/char-types.d.ts +2 -0
- package/dist/esm/bidi/char-types.js +439 -0
- package/dist/esm/bidi/index.d.ts +14 -0
- package/dist/esm/bidi/index.js +25 -0
- package/dist/esm/converter/docx-to-pdf.d.ts +15 -0
- package/dist/esm/converter/docx-to-pdf.js +227 -0
- package/dist/esm/converter/index.d.ts +4 -0
- package/dist/esm/converter/index.js +2 -0
- package/dist/esm/converter/xlsx-to-pdf.d.ts +13 -0
- package/dist/esm/converter/xlsx-to-pdf.js +515 -0
- package/dist/esm/crypto/asn1.d.ts +23 -0
- package/dist/esm/crypto/asn1.js +123 -0
- package/dist/esm/crypto/cms.d.ts +9 -0
- package/dist/esm/crypto/cms.js +34 -0
- package/dist/esm/crypto/index.d.ts +2 -0
- package/dist/esm/crypto/index.js +1 -0
- package/dist/esm/document-model/index.d.ts +1 -0
- package/dist/esm/document-model/index.js +0 -0
- package/dist/esm/document-model/types.d.ts +403 -0
- package/dist/esm/font/arabic-joining.d.ts +4 -0
- package/dist/esm/font/arabic-joining.js +97 -0
- package/dist/esm/font/binary-reader.d.ts +13 -0
- package/dist/esm/font/binary-reader.js +44 -0
- package/dist/esm/font/font-registry.d.ts +19 -0
- package/dist/esm/font/font-registry.js +39 -0
- package/dist/esm/font/index.d.ts +7 -0
- package/dist/esm/font/opentype-layout.d.ts +21 -0
- package/dist/esm/font/opentype-layout.js +329 -0
- package/dist/esm/font/ttf-parser.d.ts +29 -0
- package/dist/esm/font/ttf-parser.js +290 -0
- package/dist/esm/font/ttf-subset.d.ts +3 -0
- package/dist/esm/font/ttf-subset.js +201 -0
- package/dist/esm/fonts/index.d.ts +2 -0
- package/dist/esm/fonts/remote-fonts.d.ts +13 -0
- package/dist/esm/fonts/remote-fonts.js +94 -0
- package/dist/esm/hyphenation/index.d.ts +10 -0
- package/dist/esm/hyphenation/index.js +38 -0
- package/dist/esm/hyphenation/liang.d.ts +10 -0
- package/dist/esm/hyphenation/liang.js +79 -0
- package/dist/esm/hyphenation/patterns-en-us.d.ts +2 -0
- package/dist/esm/hyphenation/patterns-en-us.js +5 -0
- package/dist/esm/hyphenation/patterns-ru.d.ts +2 -0
- package/dist/esm/hyphenation/patterns-ru.js +5 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/line-breaker/index.d.ts +2 -0
- package/dist/esm/line-breaker/knuth-plass.d.ts +30 -0
- package/dist/esm/line-breaker/knuth-plass.js +172 -0
- package/dist/esm/numbering/index.d.ts +1 -0
- package/dist/esm/numbering/state.d.ts +6 -0
- package/dist/esm/numbering/state.js +83 -0
- package/dist/esm/ooxml/drawingml/chart-parser.d.ts +3 -0
- package/dist/esm/ooxml/drawingml/chart-parser.js +218 -0
- package/dist/esm/ooxml/drawingml/colors.d.ts +17 -0
- package/dist/esm/ooxml/drawingml/colors.js +125 -0
- package/dist/esm/ooxml/drawingml/theme-parser.d.ts +1 -0
- package/dist/esm/ooxml/drawingml/theme-parser.js +55 -0
- package/dist/esm/ooxml/index.d.ts +1 -0
- package/dist/esm/ooxml/math/omml-parser.d.ts +4 -0
- package/dist/esm/ooxml/math/omml-parser.js +217 -0
- package/dist/esm/ooxml/spreadsheet/cell-reference.d.ts +6 -0
- package/dist/esm/ooxml/spreadsheet/cell-reference.js +26 -0
- package/dist/esm/ooxml/spreadsheet/defined-name-ref.d.ts +11 -0
- package/dist/esm/ooxml/spreadsheet/defined-name-ref.js +64 -0
- package/dist/esm/ooxml/spreadsheet/index.d.ts +12 -0
- package/dist/esm/ooxml/spreadsheet/index.js +7 -0
- package/dist/esm/ooxml/spreadsheet/number-format.d.ts +1 -0
- package/dist/esm/ooxml/spreadsheet/number-format.js +438 -0
- package/dist/esm/ooxml/spreadsheet/shared-strings-parser.d.ts +1 -0
- package/dist/esm/ooxml/spreadsheet/shared-strings-parser.js +47 -0
- package/dist/esm/ooxml/spreadsheet/styles-parser.d.ts +52 -0
- package/dist/esm/ooxml/spreadsheet/styles-parser.js +225 -0
- package/dist/esm/ooxml/spreadsheet/workbook-parser.d.ts +16 -0
- package/dist/esm/ooxml/spreadsheet/workbook-parser.js +90 -0
- package/dist/esm/ooxml/spreadsheet/worksheet-parser.d.ts +60 -0
- package/dist/esm/ooxml/spreadsheet/worksheet-parser.js +311 -0
- package/dist/esm/ooxml/wordproc/document-parser.d.ts +9 -0
- package/dist/esm/ooxml/wordproc/document-parser.js +274 -0
- package/dist/esm/ooxml/wordproc/drawing-parser.d.ts +33 -0
- package/dist/esm/ooxml/wordproc/drawing-parser.js +374 -0
- package/dist/esm/ooxml/wordproc/font-table.d.ts +15 -0
- package/dist/esm/ooxml/wordproc/font-table.js +82 -0
- package/dist/esm/ooxml/wordproc/index.d.ts +10 -0
- package/dist/esm/ooxml/wordproc/index.js +9 -0
- package/dist/esm/ooxml/wordproc/numbering-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/numbering-parser.js +89 -0
- package/dist/esm/ooxml/wordproc/paragraph-properties.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/paragraph-properties.js +85 -0
- package/dist/esm/ooxml/wordproc/po-helpers.d.ts +14 -0
- package/dist/esm/ooxml/wordproc/po-helpers.js +76 -0
- package/dist/esm/ooxml/wordproc/po-to-flat.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/po-to-flat.js +28 -0
- package/dist/esm/ooxml/wordproc/run-properties.d.ts +2 -0
- package/dist/esm/ooxml/wordproc/run-properties.js +82 -0
- package/dist/esm/ooxml/wordproc/settings-parser.d.ts +5 -0
- package/dist/esm/ooxml/wordproc/settings-parser.js +26 -0
- package/dist/esm/ooxml/wordproc/styles-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/styles-parser.js +67 -0
- package/dist/esm/ooxml/wordproc/table-parser.d.ts +3 -0
- package/dist/esm/ooxml/wordproc/table-parser.js +162 -0
- package/dist/esm/ooxml/wordproc/text-extractor.d.ts +1 -0
- package/dist/esm/ooxml/wordproc/text-extractor.js +1 -0
- package/dist/esm/ooxml/wordproc/xml-helpers.d.ts +9 -0
- package/dist/esm/ooxml/wordproc/xml-helpers.js +36 -0
- package/dist/esm/opc/core-properties.d.ts +11 -0
- package/dist/esm/opc/core-properties.js +51 -0
- package/dist/esm/opc/index.d.ts +5 -0
- package/dist/esm/opc/index.js +3 -0
- package/dist/esm/opc/package.d.ts +26 -0
- package/dist/esm/opc/package.js +113 -0
- package/dist/esm/opc/relationship-types.d.ts +3 -0
- package/dist/esm/opc/relationship-types.js +4 -0
- package/dist/esm/opc/relationships.d.ts +7 -0
- package/dist/esm/opc/relationships.js +28 -0
- package/dist/esm/pdf/arc-to-bezier.d.ts +5 -0
- package/dist/esm/pdf/arc-to-bezier.js +58 -0
- package/dist/esm/pdf/builtin-fonts.d.ts +2 -0
- package/dist/esm/pdf/chart-geometry.d.ts +64 -0
- package/dist/esm/pdf/chart-geometry.js +674 -0
- package/dist/esm/pdf/cid-font.d.ts +15 -0
- package/dist/esm/pdf/cid-font.js +174 -0
- package/dist/esm/pdf/embedded-file.d.ts +11 -0
- package/dist/esm/pdf/embedded-file.js +23 -0
- package/dist/esm/pdf/icc-profile.d.ts +1 -0
- package/dist/esm/pdf/icc-profile.js +166 -0
- package/dist/esm/pdf/image-xobject.d.ts +13 -0
- package/dist/esm/pdf/image-xobject.js +335 -0
- package/dist/esm/pdf/index.d.ts +11 -0
- package/dist/esm/pdf/index.js +5 -0
- package/dist/esm/pdf/math-layout.d.ts +45 -0
- package/dist/esm/pdf/math-layout.js +1138 -0
- package/dist/esm/pdf/objects.d.ts +32 -0
- package/dist/esm/pdf/objects.js +54 -0
- package/dist/esm/pdf/preset-geometry.d.ts +6 -0
- package/dist/esm/pdf/preset-geometry.js +199 -0
- package/dist/esm/pdf/serialize.d.ts +3 -0
- package/dist/esm/pdf/serialize.js +54 -0
- package/dist/esm/pdf/signature.d.ts +25 -0
- package/dist/esm/pdf/signature.js +126 -0
- package/dist/esm/pdf/struct-tree.d.ts +31 -0
- package/dist/esm/pdf/struct-tree.js +109 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +43 -0
- package/dist/esm/pdf/styled-page-renderer.js +2317 -0
- package/dist/esm/pdf/text-encoding.d.ts +2 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.js +4 -0
- package/dist/esm/pdf/vector-graphics.d.ts +46 -0
- package/dist/esm/pdf/vector-graphics.js +103 -0
- package/dist/esm/pdf/writer.d.ts +10 -0
- package/dist/esm/pdf/writer.js +81 -0
- package/dist/esm/pdf/xmp.d.ts +13 -0
- package/dist/esm/pdf/xmp.js +38 -0
- package/dist/esm/style-cascade/index.d.ts +3 -0
- package/dist/esm/style-cascade/resolver.d.ts +4 -0
- package/dist/esm/style-cascade/resolver.js +96 -0
- package/dist/esm/style-cascade/types.d.ts +29 -0
- package/dist/esm/style-cascade/types.js +26 -0
- package/package.json +90 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
//#region src/bidi/char-types.ts
|
|
2
|
+
var SINGLE = new Map([
|
|
3
|
+
[9, "S"],
|
|
4
|
+
[10, "B"],
|
|
5
|
+
[11, "S"],
|
|
6
|
+
[12, "WS"],
|
|
7
|
+
[13, "B"],
|
|
8
|
+
[28, "B"],
|
|
9
|
+
[29, "B"],
|
|
10
|
+
[30, "B"],
|
|
11
|
+
[31, "S"],
|
|
12
|
+
[32, "WS"],
|
|
13
|
+
[133, "B"],
|
|
14
|
+
[160, "CS"],
|
|
15
|
+
[171, "ON"],
|
|
16
|
+
[187, "ON"],
|
|
17
|
+
[8234, "LRE"],
|
|
18
|
+
[8235, "RLE"],
|
|
19
|
+
[8236, "PDF"],
|
|
20
|
+
[8237, "LRO"],
|
|
21
|
+
[8238, "RLO"],
|
|
22
|
+
[8294, "LRI"],
|
|
23
|
+
[8295, "RLI"],
|
|
24
|
+
[8296, "FSI"],
|
|
25
|
+
[8297, "PDI"],
|
|
26
|
+
[1564, "AL"],
|
|
27
|
+
[8232, "WS"],
|
|
28
|
+
[8233, "B"]
|
|
29
|
+
]);
|
|
30
|
+
var RANGES = [
|
|
31
|
+
{
|
|
32
|
+
lo: 0,
|
|
33
|
+
hi: 8,
|
|
34
|
+
cls: "BN"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
lo: 14,
|
|
38
|
+
hi: 27,
|
|
39
|
+
cls: "BN"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
lo: 33,
|
|
43
|
+
hi: 34,
|
|
44
|
+
cls: "ON"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
lo: 35,
|
|
48
|
+
hi: 37,
|
|
49
|
+
cls: "ET"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
lo: 38,
|
|
53
|
+
hi: 42,
|
|
54
|
+
cls: "ON"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
lo: 43,
|
|
58
|
+
hi: 43,
|
|
59
|
+
cls: "ES"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
lo: 44,
|
|
63
|
+
hi: 44,
|
|
64
|
+
cls: "CS"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
lo: 45,
|
|
68
|
+
hi: 45,
|
|
69
|
+
cls: "ES"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
lo: 46,
|
|
73
|
+
hi: 47,
|
|
74
|
+
cls: "CS"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
lo: 48,
|
|
78
|
+
hi: 57,
|
|
79
|
+
cls: "EN"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
lo: 58,
|
|
83
|
+
hi: 58,
|
|
84
|
+
cls: "CS"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
lo: 59,
|
|
88
|
+
hi: 64,
|
|
89
|
+
cls: "ON"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
lo: 65,
|
|
93
|
+
hi: 90,
|
|
94
|
+
cls: "L"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
lo: 91,
|
|
98
|
+
hi: 96,
|
|
99
|
+
cls: "ON"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
lo: 97,
|
|
103
|
+
hi: 122,
|
|
104
|
+
cls: "L"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
lo: 123,
|
|
108
|
+
hi: 126,
|
|
109
|
+
cls: "ON"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
lo: 161,
|
|
113
|
+
hi: 169,
|
|
114
|
+
cls: "ON"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
lo: 170,
|
|
118
|
+
hi: 170,
|
|
119
|
+
cls: "L"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
lo: 172,
|
|
123
|
+
hi: 175,
|
|
124
|
+
cls: "ON"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
lo: 176,
|
|
128
|
+
hi: 177,
|
|
129
|
+
cls: "ET"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
lo: 178,
|
|
133
|
+
hi: 179,
|
|
134
|
+
cls: "EN"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
lo: 180,
|
|
138
|
+
hi: 180,
|
|
139
|
+
cls: "ON"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
lo: 181,
|
|
143
|
+
hi: 181,
|
|
144
|
+
cls: "L"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
lo: 182,
|
|
148
|
+
hi: 185,
|
|
149
|
+
cls: "ON"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
lo: 186,
|
|
153
|
+
hi: 186,
|
|
154
|
+
cls: "L"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
lo: 188,
|
|
158
|
+
hi: 191,
|
|
159
|
+
cls: "ON"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
lo: 192,
|
|
163
|
+
hi: 696,
|
|
164
|
+
cls: "L"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
lo: 768,
|
|
168
|
+
hi: 879,
|
|
169
|
+
cls: "NSM"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
lo: 880,
|
|
173
|
+
hi: 1417,
|
|
174
|
+
cls: "L"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
lo: 1425,
|
|
178
|
+
hi: 1469,
|
|
179
|
+
cls: "NSM"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
lo: 1470,
|
|
183
|
+
hi: 1470,
|
|
184
|
+
cls: "R"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
lo: 1471,
|
|
188
|
+
hi: 1471,
|
|
189
|
+
cls: "NSM"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
lo: 1472,
|
|
193
|
+
hi: 1472,
|
|
194
|
+
cls: "R"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
lo: 1473,
|
|
198
|
+
hi: 1474,
|
|
199
|
+
cls: "NSM"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
lo: 1475,
|
|
203
|
+
hi: 1475,
|
|
204
|
+
cls: "R"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
lo: 1476,
|
|
208
|
+
hi: 1477,
|
|
209
|
+
cls: "NSM"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
lo: 1478,
|
|
213
|
+
hi: 1478,
|
|
214
|
+
cls: "R"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
lo: 1479,
|
|
218
|
+
hi: 1479,
|
|
219
|
+
cls: "NSM"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
lo: 1488,
|
|
223
|
+
hi: 1514,
|
|
224
|
+
cls: "R"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
lo: 1519,
|
|
228
|
+
hi: 1524,
|
|
229
|
+
cls: "R"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
lo: 1536,
|
|
233
|
+
hi: 1541,
|
|
234
|
+
cls: "AN"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
lo: 1542,
|
|
238
|
+
hi: 1544,
|
|
239
|
+
cls: "AL"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
lo: 1545,
|
|
243
|
+
hi: 1546,
|
|
244
|
+
cls: "ET"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
lo: 1547,
|
|
248
|
+
hi: 1547,
|
|
249
|
+
cls: "AL"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
lo: 1548,
|
|
253
|
+
hi: 1548,
|
|
254
|
+
cls: "CS"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
lo: 1549,
|
|
258
|
+
hi: 1549,
|
|
259
|
+
cls: "AL"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
lo: 1550,
|
|
263
|
+
hi: 1551,
|
|
264
|
+
cls: "ON"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
lo: 1552,
|
|
268
|
+
hi: 1562,
|
|
269
|
+
cls: "NSM"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
lo: 1563,
|
|
273
|
+
hi: 1563,
|
|
274
|
+
cls: "AL"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
lo: 1565,
|
|
278
|
+
hi: 1610,
|
|
279
|
+
cls: "AL"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
lo: 1611,
|
|
283
|
+
hi: 1631,
|
|
284
|
+
cls: "NSM"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
lo: 1632,
|
|
288
|
+
hi: 1641,
|
|
289
|
+
cls: "AN"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
lo: 1642,
|
|
293
|
+
hi: 1642,
|
|
294
|
+
cls: "ET"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
lo: 1643,
|
|
298
|
+
hi: 1644,
|
|
299
|
+
cls: "AN"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
lo: 1645,
|
|
303
|
+
hi: 1645,
|
|
304
|
+
cls: "AL"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
lo: 1646,
|
|
308
|
+
hi: 1647,
|
|
309
|
+
cls: "AL"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
lo: 1648,
|
|
313
|
+
hi: 1648,
|
|
314
|
+
cls: "NSM"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
lo: 1649,
|
|
318
|
+
hi: 1749,
|
|
319
|
+
cls: "AL"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
lo: 1750,
|
|
323
|
+
hi: 1756,
|
|
324
|
+
cls: "NSM"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
lo: 1757,
|
|
328
|
+
hi: 1757,
|
|
329
|
+
cls: "AN"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
lo: 1758,
|
|
333
|
+
hi: 1764,
|
|
334
|
+
cls: "NSM"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
lo: 1765,
|
|
338
|
+
hi: 1766,
|
|
339
|
+
cls: "AL"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
lo: 1767,
|
|
343
|
+
hi: 1768,
|
|
344
|
+
cls: "NSM"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
lo: 1769,
|
|
348
|
+
hi: 1769,
|
|
349
|
+
cls: "ON"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
lo: 1770,
|
|
353
|
+
hi: 1773,
|
|
354
|
+
cls: "NSM"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
lo: 1774,
|
|
358
|
+
hi: 1775,
|
|
359
|
+
cls: "AL"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
lo: 1776,
|
|
363
|
+
hi: 1785,
|
|
364
|
+
cls: "EN"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
lo: 1786,
|
|
368
|
+
hi: 1791,
|
|
369
|
+
cls: "AL"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
lo: 1792,
|
|
373
|
+
hi: 1871,
|
|
374
|
+
cls: "AL"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
lo: 1872,
|
|
378
|
+
hi: 1919,
|
|
379
|
+
cls: "AL"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
lo: 1920,
|
|
383
|
+
hi: 1983,
|
|
384
|
+
cls: "AL"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
lo: 1984,
|
|
388
|
+
hi: 2047,
|
|
389
|
+
cls: "R"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
lo: 2048,
|
|
393
|
+
hi: 2207,
|
|
394
|
+
cls: "L"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
lo: 2208,
|
|
398
|
+
hi: 2303,
|
|
399
|
+
cls: "AL"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
lo: 64285,
|
|
403
|
+
hi: 64335,
|
|
404
|
+
cls: "R"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
lo: 64336,
|
|
408
|
+
hi: 64975,
|
|
409
|
+
cls: "AL"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
lo: 65008,
|
|
413
|
+
hi: 65023,
|
|
414
|
+
cls: "AL"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
lo: 65136,
|
|
418
|
+
hi: 65279,
|
|
419
|
+
cls: "AL"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
lo: 8208,
|
|
423
|
+
hi: 8231,
|
|
424
|
+
cls: "ON"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
lo: 8240,
|
|
428
|
+
hi: 8286,
|
|
429
|
+
cls: "ON"
|
|
430
|
+
}
|
|
431
|
+
];
|
|
432
|
+
function bidiClass(cp) {
|
|
433
|
+
const single = SINGLE.get(cp);
|
|
434
|
+
if (single !== void 0) return single;
|
|
435
|
+
for (const r of RANGES) if (cp >= r.lo && cp <= r.hi) return r.cls;
|
|
436
|
+
return "L";
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
export { bidiClass };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Direction } from './algorithm.js';
|
|
2
|
+
export type { Direction, BidiResult } from './algorithm.js';
|
|
3
|
+
export type { BidiClass } from './char-types.js';
|
|
4
|
+
export { computeBidi, reorderVisual } from './algorithm.js';
|
|
5
|
+
export { bidiClass } from './char-types.js';
|
|
6
|
+
export interface StringBidi {
|
|
7
|
+
readonly levels: ReadonlyArray<number>;
|
|
8
|
+
readonly codePoints: ReadonlyArray<number>;
|
|
9
|
+
readonly paragraphLevel: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function analyzeString(text: string, dir?: Direction): StringBidi;
|
|
12
|
+
export declare function hasBidiCharacters(text: string): boolean;
|
|
13
|
+
export declare function reverseByCodePoint(text: string): string;
|
|
14
|
+
export declare function reorderTokens(tokenLevels: ReadonlyArray<number>): Array<number>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./char-types.js";
|
|
2
|
+
import { computeBidi } from "./algorithm.js";
|
|
3
|
+
//#region src/bidi/index.ts
|
|
4
|
+
function analyzeString(text, dir = "auto") {
|
|
5
|
+
const codePoints = [];
|
|
6
|
+
for (const ch of text) codePoints.push(ch.codePointAt(0));
|
|
7
|
+
const { levels, paragraphLevel } = computeBidi(codePoints, dir);
|
|
8
|
+
return {
|
|
9
|
+
levels,
|
|
10
|
+
codePoints,
|
|
11
|
+
paragraphLevel
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function hasBidiCharacters(text) {
|
|
15
|
+
for (const ch of text) {
|
|
16
|
+
const cp = ch.codePointAt(0);
|
|
17
|
+
if (cp >= 1424 && cp <= 2303 || cp >= 64285 && cp <= 65023 || cp >= 65136 && cp <= 65279) return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
function reverseByCodePoint(text) {
|
|
22
|
+
return [...text].reverse().join("");
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { analyzeString, hasBidiCharacters, reverseByCodePoint };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FontBytesByVariant } from '../font/index.js';
|
|
2
|
+
import { FamilyKey, FetchLike } from '../fonts/index.js';
|
|
3
|
+
import { SignatureOptions, StyledRenderOptions } from '../pdf/index.js';
|
|
4
|
+
export interface ConvertDocxOptions extends Omit<StyledRenderOptions, 'registry' | 'styles'> {
|
|
5
|
+
readonly fontBytes?: Uint8Array;
|
|
6
|
+
readonly fonts?: FontBytesByVariant;
|
|
7
|
+
readonly fontFamily?: string;
|
|
8
|
+
readonly fontFetch?: FetchLike;
|
|
9
|
+
readonly embedSource?: boolean;
|
|
10
|
+
readonly signature?: SignatureOptions;
|
|
11
|
+
}
|
|
12
|
+
export declare function convertDocxToPdfSync(docx: Uint8Array, options: ConvertDocxOptions): Uint8Array;
|
|
13
|
+
export declare function detectDocxFamilyKeys(docx: Uint8Array): Set<FamilyKey>;
|
|
14
|
+
export declare function convertDocxToPdf(docx: Uint8Array, options?: ConvertDocxOptions): Promise<Uint8Array>;
|
|
15
|
+
export declare function detectDocxFontFamily(docx: Uint8Array): string | undefined;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { FontRegistry } from "../font/font-registry.js";
|
|
2
|
+
import { fetchFontSet, resolveFamilyKey } from "../fonts/remote-fonts.js";
|
|
3
|
+
import { parseChart } from "../ooxml/drawingml/chart-parser.js";
|
|
4
|
+
import { DEFAULT_THEME_PALETTE, makeColorResolver } from "../ooxml/drawingml/colors.js";
|
|
5
|
+
import { parseTheme } from "../ooxml/drawingml/theme-parser.js";
|
|
6
|
+
import { OpcPackage } from "../opc/package.js";
|
|
7
|
+
import { parseCoreProperties } from "../opc/core-properties.js";
|
|
8
|
+
import "../opc/index.js";
|
|
9
|
+
import { EMPTY_SECTION, parseDocument, parseHeaderFooter, parseSections } from "../ooxml/wordproc/document-parser.js";
|
|
10
|
+
import { EMPTY_STYLE_SHEET, parseStyles } from "../ooxml/wordproc/styles-parser.js";
|
|
11
|
+
import { loadEmbeddedFonts } from "../ooxml/wordproc/font-table.js";
|
|
12
|
+
import { EMPTY_NUMBERING, parseNumbering } from "../ooxml/wordproc/numbering-parser.js";
|
|
13
|
+
import { EMPTY_SETTINGS, parseSettings } from "../ooxml/wordproc/settings-parser.js";
|
|
14
|
+
import "../ooxml/wordproc/index.js";
|
|
15
|
+
import { signPdf } from "../pdf/signature.js";
|
|
16
|
+
import { renderStyledPdf } from "../pdf/styled-page-renderer.js";
|
|
17
|
+
import "../pdf/index.js";
|
|
18
|
+
//#region src/converter/docx-to-pdf.ts
|
|
19
|
+
var STYLES_PART = "word/styles.xml";
|
|
20
|
+
var NUMBERING_PART = "word/numbering.xml";
|
|
21
|
+
var SETTINGS_PART = "word/settings.xml";
|
|
22
|
+
var CORE_PROPS_PART = "docProps/core.xml";
|
|
23
|
+
var MAIN_DOCUMENT_PART = "word/document.xml";
|
|
24
|
+
var REL_HEADER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
25
|
+
var REL_FOOTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
|
26
|
+
var REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
27
|
+
var REL_THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
28
|
+
var THEME_PART = "word/theme/theme1.xml";
|
|
29
|
+
var REL_CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
|
30
|
+
function convertDocxToPdfSync(docx, options) {
|
|
31
|
+
const fonts = options.fonts ?? (options.fontBytes ? { regular: options.fontBytes } : void 0);
|
|
32
|
+
if (!fonts) throw new Error("convertDocxToPdfSync requires options.fonts or options.fontBytes");
|
|
33
|
+
const registry = FontRegistry.fromBytes(fonts);
|
|
34
|
+
const pkg = OpcPackage.open(docx);
|
|
35
|
+
const main = pkg.getMainDocument();
|
|
36
|
+
const resolveColor = buildColorResolver(pkg);
|
|
37
|
+
const body = parseDocument(main.data, resolveColor);
|
|
38
|
+
const rawSections = parseSections(main.data);
|
|
39
|
+
const stylesData = pkg.getPart(STYLES_PART);
|
|
40
|
+
const styles = stylesData ? parseStyles(stylesData) : EMPTY_STYLE_SHEET;
|
|
41
|
+
const numberingData = pkg.getPart(NUMBERING_PART);
|
|
42
|
+
const numbering = numberingData ? parseNumbering(numberingData) : EMPTY_NUMBERING;
|
|
43
|
+
const settingsData = pkg.getPart(SETTINGS_PART);
|
|
44
|
+
const settings = settingsData ? parseSettings(settingsData) : EMPTY_SETTINGS;
|
|
45
|
+
const sections = rawSections.length > 0 ? rawSections.map((s) => ({
|
|
46
|
+
...s,
|
|
47
|
+
properties: settings.evenAndOddHeaders ? {
|
|
48
|
+
...s.properties,
|
|
49
|
+
evenAndOddHeaders: true
|
|
50
|
+
} : s.properties
|
|
51
|
+
})) : [{
|
|
52
|
+
properties: settings.evenAndOddHeaders ? {
|
|
53
|
+
...EMPTY_SECTION,
|
|
54
|
+
evenAndOddHeaders: true
|
|
55
|
+
} : EMPTY_SECTION,
|
|
56
|
+
endIndex: body.length
|
|
57
|
+
}];
|
|
58
|
+
const headersFooters = loadHeadersFootersForSections(pkg, sections, resolveColor);
|
|
59
|
+
const images = loadImages(pkg);
|
|
60
|
+
const charts = loadCharts(pkg, resolveColor);
|
|
61
|
+
const embeddedFonts = loadEmbeddedFonts(pkg);
|
|
62
|
+
const coreData = pkg.getPart(CORE_PROPS_PART);
|
|
63
|
+
const coreProps = coreData ? parseCoreProperties(coreData) : void 0;
|
|
64
|
+
const { fontBytes: _ignoreA, fonts: _ignoreB, info: callerInfo, embedSource, attachments: callerAttachments, signature: _ignoreSig, ...renderOptions } = options;
|
|
65
|
+
const info = mergeInfo(coreProps, callerInfo);
|
|
66
|
+
const language = detectDocxLanguage(stylesData, main.data);
|
|
67
|
+
const attachments = [...callerAttachments ?? []];
|
|
68
|
+
if (embedSource && options.pdfA?.startsWith("PDF/A-3")) attachments.push({
|
|
69
|
+
name: "source.docx",
|
|
70
|
+
bytes: docx,
|
|
71
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
72
|
+
relationship: "Source",
|
|
73
|
+
description: "Source Word document"
|
|
74
|
+
});
|
|
75
|
+
return renderStyledPdf(body, {
|
|
76
|
+
registry,
|
|
77
|
+
styles,
|
|
78
|
+
numbering,
|
|
79
|
+
sections,
|
|
80
|
+
headersFooters,
|
|
81
|
+
images,
|
|
82
|
+
charts,
|
|
83
|
+
...embeddedFonts.size > 0 ? { embeddedFonts } : {},
|
|
84
|
+
...info ? { info } : {},
|
|
85
|
+
...language ? { language } : {},
|
|
86
|
+
...attachments.length > 0 ? { attachments } : {},
|
|
87
|
+
...renderOptions
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function detectDocxLanguage(stylesData, documentData) {
|
|
91
|
+
const re = /<w:lang\b[^>]*\bw:val="([^"]+)"/;
|
|
92
|
+
const decoder = new TextDecoder();
|
|
93
|
+
for (const data of [stylesData, documentData]) {
|
|
94
|
+
if (!data) continue;
|
|
95
|
+
const m = re.exec(decoder.decode(data));
|
|
96
|
+
if (m?.[1]) return m[1];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function detectDocxFamilyKeys(docx) {
|
|
100
|
+
const keys = new Set(["roboto"]);
|
|
101
|
+
let pkg;
|
|
102
|
+
try {
|
|
103
|
+
pkg = OpcPackage.open(docx);
|
|
104
|
+
} catch {
|
|
105
|
+
return keys;
|
|
106
|
+
}
|
|
107
|
+
const decoder = new TextDecoder("utf-8");
|
|
108
|
+
const re = /<w:rFonts[^>]*\bw:ascii="([^"]+)"/g;
|
|
109
|
+
for (const part of [STYLES_PART, MAIN_DOCUMENT_PART]) {
|
|
110
|
+
const data = pkg.getPart(part);
|
|
111
|
+
if (!data) continue;
|
|
112
|
+
const xml = decoder.decode(data);
|
|
113
|
+
let m;
|
|
114
|
+
while ((m = re.exec(xml)) !== null) keys.add(resolveFamilyKey(m[1]));
|
|
115
|
+
}
|
|
116
|
+
return keys;
|
|
117
|
+
}
|
|
118
|
+
async function convertDocxToPdf(docx, options = {}) {
|
|
119
|
+
const { signature } = options;
|
|
120
|
+
const pdf = await buildUnsignedDocxPdf(docx, signature ? {
|
|
121
|
+
...options,
|
|
122
|
+
signaturePlaceholder: signature
|
|
123
|
+
} : options);
|
|
124
|
+
return signature ? signPdf(pdf, signature) : pdf;
|
|
125
|
+
}
|
|
126
|
+
async function buildUnsignedDocxPdf(docx, options) {
|
|
127
|
+
if (options.fonts ?? options.fontBytes) return convertDocxToPdfSync(docx, options);
|
|
128
|
+
const fetchOpt = options.fontFetch ? { fetch: options.fontFetch } : {};
|
|
129
|
+
const keys = options.fontFamily ? new Set([resolveFamilyKey(options.fontFamily)]) : detectDocxFamilyKeys(docx);
|
|
130
|
+
if (keys.size <= 1) {
|
|
131
|
+
const family = keys.values().next().value;
|
|
132
|
+
const fonts = await fetchFontSet({
|
|
133
|
+
...family ? { family } : {},
|
|
134
|
+
...fetchOpt
|
|
135
|
+
});
|
|
136
|
+
return convertDocxToPdfSync(docx, {
|
|
137
|
+
...options,
|
|
138
|
+
fonts
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const registriesByFamily = /* @__PURE__ */ new Map();
|
|
142
|
+
let baseBytes;
|
|
143
|
+
for (const key of keys) {
|
|
144
|
+
const bytes = await fetchFontSet({
|
|
145
|
+
family: key,
|
|
146
|
+
...fetchOpt
|
|
147
|
+
});
|
|
148
|
+
registriesByFamily.set(key, FontRegistry.fromBytes(bytes));
|
|
149
|
+
if (key === "roboto" || !baseBytes) baseBytes = bytes;
|
|
150
|
+
}
|
|
151
|
+
return convertDocxToPdfSync(docx, {
|
|
152
|
+
...options,
|
|
153
|
+
fonts: baseBytes,
|
|
154
|
+
registriesByFamily
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function mergeInfo(core, caller) {
|
|
158
|
+
if (!core && !caller) return void 0;
|
|
159
|
+
return {
|
|
160
|
+
...core?.title ? { title: core.title } : {},
|
|
161
|
+
...core?.creator ? { author: core.creator } : {},
|
|
162
|
+
...core?.subject ? { subject: core.subject } : {},
|
|
163
|
+
...core?.keywords ? { keywords: core.keywords } : {},
|
|
164
|
+
...core?.created ? { creationDate: core.created } : {},
|
|
165
|
+
...core?.modified ? { modificationDate: core.modified } : {},
|
|
166
|
+
...caller
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function loadImages(pkg) {
|
|
170
|
+
const rels = pkg.getPartRelationships(MAIN_DOCUMENT_PART);
|
|
171
|
+
if (rels.length === 0) return /* @__PURE__ */ new Map();
|
|
172
|
+
const out = /* @__PURE__ */ new Map();
|
|
173
|
+
for (const rel of rels) {
|
|
174
|
+
if (rel.type !== REL_IMAGE) continue;
|
|
175
|
+
const resolved = pkg.resolveRelatedPart(MAIN_DOCUMENT_PART, rel);
|
|
176
|
+
if (!resolved) continue;
|
|
177
|
+
out.set(rel.id, resolved.data);
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
function loadCharts(pkg, resolveColor) {
|
|
182
|
+
const out = /* @__PURE__ */ new Map();
|
|
183
|
+
for (const rel of pkg.getPartRelationships(MAIN_DOCUMENT_PART)) {
|
|
184
|
+
if (rel.type !== REL_CHART) continue;
|
|
185
|
+
const resolved = pkg.resolveRelatedPart(MAIN_DOCUMENT_PART, rel);
|
|
186
|
+
if (!resolved) continue;
|
|
187
|
+
const chart = parseChart(resolved.data, resolveColor);
|
|
188
|
+
if (chart) out.set(rel.id, chart);
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
function buildColorResolver(pkg) {
|
|
193
|
+
const themeData = loadTheme(pkg);
|
|
194
|
+
if (!themeData) return makeColorResolver(DEFAULT_THEME_PALETTE);
|
|
195
|
+
const palette = new Map(DEFAULT_THEME_PALETTE);
|
|
196
|
+
for (const [slot, hex] of parseTheme(themeData)) palette.set(slot, hex);
|
|
197
|
+
return makeColorResolver(palette);
|
|
198
|
+
}
|
|
199
|
+
function loadTheme(pkg) {
|
|
200
|
+
for (const rel of pkg.getPartRelationships(MAIN_DOCUMENT_PART)) {
|
|
201
|
+
if (rel.type !== REL_THEME) continue;
|
|
202
|
+
const resolved = pkg.resolveRelatedPart(MAIN_DOCUMENT_PART, rel);
|
|
203
|
+
if (resolved) return resolved.data;
|
|
204
|
+
}
|
|
205
|
+
return pkg.getPart(THEME_PART);
|
|
206
|
+
}
|
|
207
|
+
function loadHeadersFootersForSections(pkg, sections, resolveColor) {
|
|
208
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
209
|
+
for (const s of sections) {
|
|
210
|
+
for (const h of s.properties.headers) wanted.add(h.relationshipId);
|
|
211
|
+
for (const f of s.properties.footers) wanted.add(f.relationshipId);
|
|
212
|
+
}
|
|
213
|
+
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
214
|
+
const rels = pkg.getPartRelationships(MAIN_DOCUMENT_PART);
|
|
215
|
+
if (rels.length === 0) return /* @__PURE__ */ new Map();
|
|
216
|
+
const out = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const rel of rels) {
|
|
218
|
+
if (!wanted.has(rel.id)) continue;
|
|
219
|
+
if (rel.type !== REL_HEADER && rel.type !== REL_FOOTER) continue;
|
|
220
|
+
const resolved = pkg.resolveRelatedPart(MAIN_DOCUMENT_PART, rel);
|
|
221
|
+
if (!resolved) continue;
|
|
222
|
+
out.set(rel.id, parseHeaderFooter(resolved.data, resolveColor));
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
export { convertDocxToPdf, convertDocxToPdfSync };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { convertDocxToPdf, convertDocxToPdfSync, detectDocxFontFamily, } from './docx-to-pdf.js';
|
|
2
|
+
export type { ConvertDocxOptions } from './docx-to-pdf.js';
|
|
3
|
+
export { convertXlsxToPdf, convertXlsxToPdfSync } from './xlsx-to-pdf.js';
|
|
4
|
+
export type { ConvertXlsxOptions } from './xlsx-to-pdf.js';
|