documents.js 1.97.11 → 1.98.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/dist/capability-DX0lCSiI.d.ts +16 -0
- package/dist/capability-an5gSNsu.d.cts +16 -0
- package/dist/convert/capability.cjs +65 -5
- package/dist/convert/capability.d.cts +2 -38
- package/dist/convert/capability.d.ts +2 -38
- package/dist/convert/capability.js +64 -2
- package/dist/convert/codec.cjs +29 -29
- package/dist/convert/codec.js +1 -1
- package/dist/convert/composition.cjs +414 -4
- package/dist/convert/composition.d.cts +2 -2
- package/dist/convert/composition.d.ts +1 -1
- package/dist/convert/composition.js +411 -1
- package/dist/convert/convert.cjs +350 -42
- package/dist/convert/convert.d.cts +105 -1
- package/dist/convert/convert.d.ts +105 -1
- package/dist/convert/convert.js +309 -1
- package/dist/convert/local.cjs +23 -8
- package/dist/convert/local.js +20 -5
- package/dist/fonts/registry.d.cts +19 -1
- package/dist/fonts/registry.d.ts +19 -1
- package/dist/hsqldb/binary-script.d.cts +1 -1
- package/dist/hsqldb/binary-script.d.ts +1 -1
- package/dist/hsqldb/cache.d.cts +1 -1
- package/dist/hsqldb/cache.d.ts +1 -1
- package/dist/hsqldb/rowformat.d.cts +24 -1
- package/dist/hsqldb/rowformat.d.ts +24 -1
- package/dist/index.cjs +44 -41
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -2
- package/dist/metadata/read.cjs +2 -2
- package/dist/metadata/read.js +1 -1
- package/dist/odb/read.d.cts +1 -1
- package/dist/odb/read.d.ts +1 -1
- package/dist/odb/report/content.d.cts +1 -1
- package/dist/odb/report/content.d.ts +1 -1
- package/dist/odb/report/source.d.cts +1 -1
- package/dist/odb/report/source.d.ts +1 -1
- package/package.json +1 -1
- package/dist/convert-B1izrvnQ.d.cts +0 -106
- package/dist/convert-BO_4tCwz.cjs +0 -1262
- package/dist/convert-HYsWA-LI.d.ts +0 -106
- package/dist/convert-ULGgwmSb.js +0 -975
- package/dist/registry-DpF4A9EM.d.ts +0 -20
- package/dist/registry-ZAWlWHqJ.d.cts +0 -20
- package/dist/rowformat-Cl2exlEh.d.cts +0 -25
- package/dist/rowformat-Cl2exlEh.d.ts +0 -25
|
@@ -1,1262 +0,0 @@
|
|
|
1
|
-
const require_model_geometry = require("./model/geometry.cjs");
|
|
2
|
-
const require_model_metadata = require("./model/metadata.cjs");
|
|
3
|
-
const require_edit_docx_content = require("./edit/docx/content.cjs");
|
|
4
|
-
const require_edit_pptx_content = require("./edit/pptx/content.cjs");
|
|
5
|
-
const require_edit_odt_content = require("./edit/odt/content.cjs");
|
|
6
|
-
const require_edit_odp_content = require("./edit/odp/content.cjs");
|
|
7
|
-
const require_edit_ods_content = require("./edit/ods/content.cjs");
|
|
8
|
-
const require_edit_odg_content = require("./edit/odg/content.cjs");
|
|
9
|
-
const require_markdown_read = require("./markdown/read.cjs");
|
|
10
|
-
const require_markdown_write = require("./markdown/write.cjs");
|
|
11
|
-
const require_fonts_registry = require("./fonts/registry.cjs");
|
|
12
|
-
const require_mathml_layout = require("./mathml/layout.cjs");
|
|
13
|
-
const require_ooxml_docx_read = require("./ooxml/docx/read.cjs");
|
|
14
|
-
const require_ooxml_pptx_read = require("./ooxml/pptx/read.cjs");
|
|
15
|
-
const require_odf_formula_read = require("./odf/formula/read.cjs");
|
|
16
|
-
const require_odf_odt_read = require("./odf/odt/read.cjs");
|
|
17
|
-
const require_odf_odp_read = require("./odf/odp/read.cjs");
|
|
18
|
-
const require_odf_ods_read = require("./odf/ods/read.cjs");
|
|
19
|
-
const require_odf_odg_read = require("./odf/odg/read.cjs");
|
|
20
|
-
const require_markdown_text = require("./markdown/text.cjs");
|
|
21
|
-
const require_layout_engine = require("./layout/engine.cjs");
|
|
22
|
-
const require_layout_slides = require("./layout/slides.cjs");
|
|
23
|
-
const require_ports_abort = require("./ports/abort.cjs");
|
|
24
|
-
const require_layout_sheets = require("./layout/sheets.cjs");
|
|
25
|
-
const require_layout_drawing = require("./layout/drawing.cjs");
|
|
26
|
-
const require_layout_reconstruct = require("./layout/reconstruct.cjs");
|
|
27
|
-
const require_odb_csv = require("./odb/csv.cjs");
|
|
28
|
-
const require_odb_read = require("./odb/read.cjs");
|
|
29
|
-
const require_odb_spreadsheet = require("./odb/spreadsheet.cjs");
|
|
30
|
-
const require_convert_variant_bridges = require("./convert/variant-bridges.cjs");
|
|
31
|
-
let ooxml_js = require("ooxml.js");
|
|
32
|
-
let document_schema_js = require("document-schema.js");
|
|
33
|
-
let odf_js = require("odf.js");
|
|
34
|
-
require("markdown-codec");
|
|
35
|
-
let pdf_codec = require("pdf-codec");
|
|
36
|
-
//#region src/convert/capability.ts
|
|
37
|
-
const FORMAT_CAPABILITIES = {
|
|
38
|
-
docx: {
|
|
39
|
-
format: "docx",
|
|
40
|
-
variant: "wordprocessing",
|
|
41
|
-
hasLayoutPath: true
|
|
42
|
-
},
|
|
43
|
-
odt: {
|
|
44
|
-
format: "odt",
|
|
45
|
-
variant: "wordprocessing",
|
|
46
|
-
hasLayoutPath: true
|
|
47
|
-
},
|
|
48
|
-
pptx: {
|
|
49
|
-
format: "pptx",
|
|
50
|
-
variant: "presentation",
|
|
51
|
-
hasLayoutPath: true
|
|
52
|
-
},
|
|
53
|
-
odp: {
|
|
54
|
-
format: "odp",
|
|
55
|
-
variant: "presentation",
|
|
56
|
-
hasLayoutPath: true
|
|
57
|
-
},
|
|
58
|
-
ods: {
|
|
59
|
-
format: "ods",
|
|
60
|
-
variant: "spreadsheet",
|
|
61
|
-
hasLayoutPath: true
|
|
62
|
-
},
|
|
63
|
-
xlsx: {
|
|
64
|
-
format: "xlsx",
|
|
65
|
-
variant: "spreadsheet",
|
|
66
|
-
hasLayoutPath: false
|
|
67
|
-
},
|
|
68
|
-
odg: {
|
|
69
|
-
format: "odg",
|
|
70
|
-
variant: "drawing",
|
|
71
|
-
hasLayoutPath: true
|
|
72
|
-
},
|
|
73
|
-
odf: {
|
|
74
|
-
format: "odf",
|
|
75
|
-
variant: "formula",
|
|
76
|
-
hasLayoutPath: false
|
|
77
|
-
},
|
|
78
|
-
markdown: {
|
|
79
|
-
format: "markdown",
|
|
80
|
-
variant: "wordprocessing",
|
|
81
|
-
hasLayoutPath: true
|
|
82
|
-
},
|
|
83
|
-
pdf: {
|
|
84
|
-
format: "pdf",
|
|
85
|
-
hasLayoutPath: false
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const DIRECT_EDGES = [
|
|
89
|
-
{
|
|
90
|
-
kind: "toPdf",
|
|
91
|
-
source: "docx",
|
|
92
|
-
target: "pdf",
|
|
93
|
-
convert: docxToPdf
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
kind: "toPdf",
|
|
97
|
-
source: "pptx",
|
|
98
|
-
target: "pdf",
|
|
99
|
-
convert: pptxToPdf
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
kind: "toPdf",
|
|
103
|
-
source: "odt",
|
|
104
|
-
target: "pdf",
|
|
105
|
-
convert: odtToPdf
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
kind: "toPdf",
|
|
109
|
-
source: "odp",
|
|
110
|
-
target: "pdf",
|
|
111
|
-
convert: odpToPdf
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
kind: "toPdf",
|
|
115
|
-
source: "ods",
|
|
116
|
-
target: "pdf",
|
|
117
|
-
convert: odsToPdf
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
kind: "toPdf",
|
|
121
|
-
source: "odg",
|
|
122
|
-
target: "pdf",
|
|
123
|
-
convert: odgToPdf
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
kind: "toPdf",
|
|
127
|
-
source: "odf",
|
|
128
|
-
target: "pdf",
|
|
129
|
-
convert: odfToPdf
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
kind: "toPdf",
|
|
133
|
-
source: "xlsx",
|
|
134
|
-
target: "pdf",
|
|
135
|
-
convert: xlsxToPdf
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
kind: "toPdf",
|
|
139
|
-
source: "markdown",
|
|
140
|
-
target: "pdf",
|
|
141
|
-
convert: markdownToPdf
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
kind: "fromPdf",
|
|
145
|
-
source: "pdf",
|
|
146
|
-
target: "docx",
|
|
147
|
-
convert: pdfToDocx
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
kind: "fromPdf",
|
|
151
|
-
source: "pdf",
|
|
152
|
-
target: "pptx",
|
|
153
|
-
convert: pdfToPptx
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
kind: "fromPdf",
|
|
157
|
-
source: "pdf",
|
|
158
|
-
target: "odt",
|
|
159
|
-
convert: pdfToOdt
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
kind: "fromPdf",
|
|
163
|
-
source: "pdf",
|
|
164
|
-
target: "odp",
|
|
165
|
-
convert: pdfToOdp
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
kind: "fromPdf",
|
|
169
|
-
source: "pdf",
|
|
170
|
-
target: "ods",
|
|
171
|
-
convert: pdfToOds
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
kind: "fromPdf",
|
|
175
|
-
source: "pdf",
|
|
176
|
-
target: "odg",
|
|
177
|
-
convert: pdfToOdg
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
kind: "fromPdf",
|
|
181
|
-
source: "pdf",
|
|
182
|
-
target: "xlsx",
|
|
183
|
-
convert: pdfToXlsx
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
kind: "fromPdf",
|
|
187
|
-
source: "pdf",
|
|
188
|
-
target: "markdown",
|
|
189
|
-
convert: pdfToMarkdown
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
kind: "bridge",
|
|
193
|
-
source: "odt",
|
|
194
|
-
target: "docx",
|
|
195
|
-
convert: odtToDocx
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
kind: "bridge",
|
|
199
|
-
source: "docx",
|
|
200
|
-
target: "odt",
|
|
201
|
-
convert: docxToOdt
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
kind: "bridge",
|
|
205
|
-
source: "odp",
|
|
206
|
-
target: "pptx",
|
|
207
|
-
convert: odpToPptx
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
kind: "bridge",
|
|
211
|
-
source: "pptx",
|
|
212
|
-
target: "odp",
|
|
213
|
-
convert: pptxToOdp
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
kind: "bridge",
|
|
217
|
-
source: "ods",
|
|
218
|
-
target: "xlsx",
|
|
219
|
-
convert: odsToXlsx
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
kind: "bridge",
|
|
223
|
-
source: "xlsx",
|
|
224
|
-
target: "ods",
|
|
225
|
-
convert: xlsxToOds
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
kind: "bridge",
|
|
229
|
-
source: "markdown",
|
|
230
|
-
target: "docx",
|
|
231
|
-
convert: markdownToDocx
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
kind: "bridge",
|
|
235
|
-
source: "docx",
|
|
236
|
-
target: "markdown",
|
|
237
|
-
convert: docxToMarkdown
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
kind: "bridge",
|
|
241
|
-
source: "markdown",
|
|
242
|
-
target: "odt",
|
|
243
|
-
convert: markdownToOdt
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
kind: "bridge",
|
|
247
|
-
source: "odt",
|
|
248
|
-
target: "markdown",
|
|
249
|
-
convert: odtToMarkdown
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
kind: "bridge",
|
|
253
|
-
source: "docx",
|
|
254
|
-
target: "pptx",
|
|
255
|
-
convert: docxToPptx
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
kind: "bridge",
|
|
259
|
-
source: "pptx",
|
|
260
|
-
target: "docx",
|
|
261
|
-
convert: pptxToDocx
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
kind: "bridge",
|
|
265
|
-
source: "odt",
|
|
266
|
-
target: "odp",
|
|
267
|
-
convert: odtToOdp
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
kind: "bridge",
|
|
271
|
-
source: "odp",
|
|
272
|
-
target: "odt",
|
|
273
|
-
convert: odpToOdt
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
kind: "bridge",
|
|
277
|
-
source: "xlsx",
|
|
278
|
-
target: "markdown",
|
|
279
|
-
convert: xlsxToMarkdown
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
kind: "bridge",
|
|
283
|
-
source: "markdown",
|
|
284
|
-
target: "xlsx",
|
|
285
|
-
convert: markdownToXlsx
|
|
286
|
-
}
|
|
287
|
-
];
|
|
288
|
-
var UnsupportedConversionError = class extends Error {
|
|
289
|
-
source;
|
|
290
|
-
target;
|
|
291
|
-
constructor(source, target) {
|
|
292
|
-
super(`unsupported conversion: ${source} -> ${target}`);
|
|
293
|
-
this.name = "UnsupportedConversionError";
|
|
294
|
-
this.source = source;
|
|
295
|
-
this.target = target;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
function resolveConversionPath(source, target, edges = DIRECT_EDGES) {
|
|
299
|
-
if (source === target) return;
|
|
300
|
-
return edges.find((edge) => edge.source === source && edge.target === target);
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/convert/composition.ts
|
|
304
|
-
const mathMetricsAt$1 = (sizePt) => (0, pdf_codec.loadMathFont)().metricsAt(sizePt);
|
|
305
|
-
const CONTENT_FORMATS = [
|
|
306
|
-
"docx",
|
|
307
|
-
"pptx",
|
|
308
|
-
"xlsx",
|
|
309
|
-
"odt",
|
|
310
|
-
"odp",
|
|
311
|
-
"ods",
|
|
312
|
-
"odg",
|
|
313
|
-
"markdown"
|
|
314
|
-
];
|
|
315
|
-
const FORMAT_NODES = {
|
|
316
|
-
docx: {
|
|
317
|
-
variant: "wordprocessing",
|
|
318
|
-
family: "ooxml",
|
|
319
|
-
decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
|
|
320
|
-
read: (pkg, options) => require_ooxml_docx_read.readDocxContent(pkg, { onMathDiagnostic: options?.onMathDiagnostic }),
|
|
321
|
-
build: (content, options) => require_edit_docx_content.buildDocxPackage(content, { onMathDiagnostic: options?.onMathDiagnostic }),
|
|
322
|
-
encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
|
|
323
|
-
hasSourcePackage: true
|
|
324
|
-
},
|
|
325
|
-
pptx: {
|
|
326
|
-
variant: "presentation",
|
|
327
|
-
family: "ooxml",
|
|
328
|
-
decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
|
|
329
|
-
read: (pkg) => require_ooxml_pptx_read.readPptxContent(pkg),
|
|
330
|
-
build: (content) => require_edit_pptx_content.buildPptxPackage(content),
|
|
331
|
-
encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
|
|
332
|
-
hasSourcePackage: true
|
|
333
|
-
},
|
|
334
|
-
xlsx: {
|
|
335
|
-
variant: "spreadsheet",
|
|
336
|
-
family: "ooxml",
|
|
337
|
-
decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
|
|
338
|
-
read: (pkg) => (0, ooxml_js.readXlsxContent)(pkg),
|
|
339
|
-
build: (content) => (0, ooxml_js.buildXlsxPackage)(content),
|
|
340
|
-
encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
|
|
341
|
-
hasSourcePackage: true
|
|
342
|
-
},
|
|
343
|
-
odt: {
|
|
344
|
-
variant: "wordprocessing",
|
|
345
|
-
family: "odf",
|
|
346
|
-
decode: (bytes) => (0, odf_js.decodePackage)(bytes),
|
|
347
|
-
read: (pkg) => require_odf_odt_read.readOdtContent(pkg),
|
|
348
|
-
build: (content) => require_edit_odt_content.buildOdtPackage(content),
|
|
349
|
-
encode: (pkg) => (0, odf_js.encodePackage)(pkg),
|
|
350
|
-
hasSourcePackage: true
|
|
351
|
-
},
|
|
352
|
-
odp: {
|
|
353
|
-
variant: "presentation",
|
|
354
|
-
family: "odf",
|
|
355
|
-
decode: (bytes) => (0, odf_js.decodePackage)(bytes),
|
|
356
|
-
read: (pkg) => require_odf_odp_read.readOdpContent(pkg),
|
|
357
|
-
build: (content) => require_edit_odp_content.buildOdpPackage(content),
|
|
358
|
-
encode: (pkg) => (0, odf_js.encodePackage)(pkg),
|
|
359
|
-
hasSourcePackage: true
|
|
360
|
-
},
|
|
361
|
-
ods: {
|
|
362
|
-
variant: "spreadsheet",
|
|
363
|
-
family: "odf",
|
|
364
|
-
decode: (bytes) => (0, odf_js.decodePackage)(bytes),
|
|
365
|
-
read: (pkg) => require_odf_ods_read.readOdsContent(pkg),
|
|
366
|
-
build: (content) => require_edit_ods_content.buildOdsPackage(content),
|
|
367
|
-
encode: (pkg) => (0, odf_js.encodePackage)(pkg),
|
|
368
|
-
hasSourcePackage: true
|
|
369
|
-
},
|
|
370
|
-
odg: {
|
|
371
|
-
variant: "drawing",
|
|
372
|
-
family: "odf",
|
|
373
|
-
decode: (bytes) => (0, odf_js.decodePackage)(bytes),
|
|
374
|
-
read: (pkg) => require_odf_odg_read.readOdgContent(pkg),
|
|
375
|
-
build: (content) => require_edit_odg_content.buildOdgPackage(content),
|
|
376
|
-
encode: (pkg) => (0, odf_js.encodePackage)(pkg),
|
|
377
|
-
hasSourcePackage: true
|
|
378
|
-
},
|
|
379
|
-
markdown: {
|
|
380
|
-
variant: "wordprocessing",
|
|
381
|
-
family: "markdown",
|
|
382
|
-
decode: (bytes) => require_markdown_text.decodeMarkdownText(bytes),
|
|
383
|
-
read: (text, options) => require_markdown_read.readMarkdownContent(text, {
|
|
384
|
-
signal: options?.signal,
|
|
385
|
-
images: options?.images
|
|
386
|
-
}),
|
|
387
|
-
build: (content) => require_markdown_write.buildMarkdownText(content),
|
|
388
|
-
encode: (text) => require_markdown_text.encodeMarkdownText(text),
|
|
389
|
-
hasSourcePackage: false
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
const LAYOUT_CAPABLE = /* @__PURE__ */ new Set([
|
|
393
|
-
"docx",
|
|
394
|
-
"pptx",
|
|
395
|
-
"odt",
|
|
396
|
-
"odp",
|
|
397
|
-
"ods",
|
|
398
|
-
"odg",
|
|
399
|
-
"markdown"
|
|
400
|
-
]);
|
|
401
|
-
const TRANSFORMS = {
|
|
402
|
-
"wordprocessing->presentation": (doc) => {
|
|
403
|
-
if (doc.kind !== "wordprocessing") throw new Error("wordprocessingToPresentation: expected a wordprocessing ContentDocument");
|
|
404
|
-
return require_convert_variant_bridges.wordprocessingToPresentation(doc);
|
|
405
|
-
},
|
|
406
|
-
"presentation->wordprocessing": (doc) => {
|
|
407
|
-
if (doc.kind !== "presentation") throw new Error("presentationToWordprocessing: expected a presentation ContentDocument");
|
|
408
|
-
return require_convert_variant_bridges.presentationToWordprocessing(doc);
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
const LAYOUT_ENGINES = {
|
|
412
|
-
wordprocessing: require_layout_engine.convertWordprocessingToLayout,
|
|
413
|
-
presentation: require_layout_slides.convertPresentationToLayout,
|
|
414
|
-
spreadsheet: require_layout_sheets.convertSpreadsheetToLayout,
|
|
415
|
-
drawing: require_layout_drawing.convertDrawingToLayout
|
|
416
|
-
};
|
|
417
|
-
const RECONSTRUCTORS = {
|
|
418
|
-
wordprocessing: require_layout_reconstruct.reconstructWordprocessing,
|
|
419
|
-
presentation: require_layout_reconstruct.reconstructPresentation,
|
|
420
|
-
drawing: require_layout_reconstruct.reconstructDrawing,
|
|
421
|
-
spreadsheet: require_layout_reconstruct.reconstructSpreadsheet
|
|
422
|
-
};
|
|
423
|
-
function executeBridge(source, target, bytes, options) {
|
|
424
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
425
|
-
const sourceNode = FORMAT_NODES[source];
|
|
426
|
-
const targetNode = FORMAT_NODES[target];
|
|
427
|
-
let content;
|
|
428
|
-
if (sourceNode.family === "markdown") {
|
|
429
|
-
const text = sourceNode.decode(bytes);
|
|
430
|
-
content = sourceNode.read(text, options);
|
|
431
|
-
} else {
|
|
432
|
-
const pkg = sourceNode.decode(bytes);
|
|
433
|
-
content = sourceNode.read(pkg, options);
|
|
434
|
-
}
|
|
435
|
-
if (content.kind !== sourceNode.variant) throw new Error(`executeBridge: ${source} read returned a non-${sourceNode.variant} ContentDocument`);
|
|
436
|
-
let buildContent = content;
|
|
437
|
-
if (sourceNode.variant !== targetNode.variant) {
|
|
438
|
-
const key = `${sourceNode.variant}->${targetNode.variant}`;
|
|
439
|
-
const transform = TRANSFORMS[key];
|
|
440
|
-
if (transform === void 0) throw new Error(`executeBridge: no transform registered for ${key}`);
|
|
441
|
-
buildContent = transform(content);
|
|
442
|
-
}
|
|
443
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
444
|
-
options?.onDocument?.({
|
|
445
|
-
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
446
|
-
content: buildContent
|
|
447
|
-
});
|
|
448
|
-
if (targetNode.family === "markdown") {
|
|
449
|
-
const text = targetNode.build(buildContent);
|
|
450
|
-
return targetNode.encode(text);
|
|
451
|
-
}
|
|
452
|
-
const pkg = targetNode.build(buildContent, options);
|
|
453
|
-
return targetNode.encode(pkg);
|
|
454
|
-
}
|
|
455
|
-
function executeToPdf(format, bytes, options) {
|
|
456
|
-
if (!LAYOUT_CAPABLE.has(format)) throw new Error(`executeToPdf: '${format}' has no layout engine of its own`);
|
|
457
|
-
const node = FORMAT_NODES[format];
|
|
458
|
-
let content;
|
|
459
|
-
let fonts;
|
|
460
|
-
if (node.family === "markdown") {
|
|
461
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
462
|
-
const text = node.decode(bytes);
|
|
463
|
-
const read = node.read(text, options);
|
|
464
|
-
content = {
|
|
465
|
-
...read,
|
|
466
|
-
metadata: require_model_metadata.resolveMetadataTimestamps(read.metadata, options?.clock)
|
|
467
|
-
};
|
|
468
|
-
fonts = (0, pdf_codec.createFontRegistry)({
|
|
469
|
-
fonts: options?.fonts,
|
|
470
|
-
onSubstitution: options?.onFontSubstitution
|
|
471
|
-
});
|
|
472
|
-
} else {
|
|
473
|
-
const pkg = node.decode(bytes);
|
|
474
|
-
const read = node.read(pkg, options);
|
|
475
|
-
content = {
|
|
476
|
-
...read,
|
|
477
|
-
metadata: require_model_metadata.resolveMetadataTimestamps(read.metadata, options?.clock)
|
|
478
|
-
};
|
|
479
|
-
const fontSource = node.family === "odf" ? {
|
|
480
|
-
kind: "odf",
|
|
481
|
-
package: pkg
|
|
482
|
-
} : format === "pptx" ? {
|
|
483
|
-
kind: "pptx",
|
|
484
|
-
package: pkg
|
|
485
|
-
} : {
|
|
486
|
-
kind: "docx",
|
|
487
|
-
package: pkg
|
|
488
|
-
};
|
|
489
|
-
fonts = require_fonts_registry.createDocumentFontRegistry(fontSource, {
|
|
490
|
-
fonts: options?.fonts,
|
|
491
|
-
onFontSubstitution: options?.onFontSubstitution
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
const measurer = (0, pdf_codec.createFontMeasurer)(fonts);
|
|
495
|
-
let layout;
|
|
496
|
-
let formulas;
|
|
497
|
-
switch (content.kind) {
|
|
498
|
-
case "wordprocessing": {
|
|
499
|
-
const result = LAYOUT_ENGINES.wordprocessing(content, {
|
|
500
|
-
measurer,
|
|
501
|
-
mathMetricsAt: mathMetricsAt$1
|
|
502
|
-
});
|
|
503
|
-
layout = result.document;
|
|
504
|
-
formulas = result.formulas;
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
case "presentation": {
|
|
508
|
-
const result = LAYOUT_ENGINES.presentation(content, {
|
|
509
|
-
measurer,
|
|
510
|
-
mathMetricsAt: mathMetricsAt$1
|
|
511
|
-
});
|
|
512
|
-
layout = result.document;
|
|
513
|
-
formulas = result.formulas;
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
case "spreadsheet": {
|
|
517
|
-
const result = LAYOUT_ENGINES.spreadsheet(content, {
|
|
518
|
-
measurer,
|
|
519
|
-
mathMetricsAt: mathMetricsAt$1,
|
|
520
|
-
signal: options?.signal
|
|
521
|
-
});
|
|
522
|
-
layout = result.document;
|
|
523
|
-
formulas = result.formulas;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
case "drawing":
|
|
527
|
-
layout = LAYOUT_ENGINES.drawing(content, { measurer });
|
|
528
|
-
break;
|
|
529
|
-
default: throw new Error(`executeToPdf: cannot lay out a '${content.kind}' document`);
|
|
530
|
-
}
|
|
531
|
-
options?.onDocument?.({
|
|
532
|
-
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
533
|
-
content,
|
|
534
|
-
layout
|
|
535
|
-
});
|
|
536
|
-
if (formulas === void 0) return (0, pdf_codec.writePdf)(layout, {
|
|
537
|
-
signal: options?.signal,
|
|
538
|
-
onSubstitution: options?.onSubstitution,
|
|
539
|
-
fonts
|
|
540
|
-
});
|
|
541
|
-
return (0, pdf_codec.writePdf)(layout, {
|
|
542
|
-
signal: options?.signal,
|
|
543
|
-
onSubstitution: options?.onSubstitution,
|
|
544
|
-
formulas,
|
|
545
|
-
fonts
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
function executeFromPdf(target, bytes, options) {
|
|
549
|
-
const node = FORMAT_NODES[target];
|
|
550
|
-
const layout = (0, pdf_codec.readPdf)(bytes, {
|
|
551
|
-
signal: options?.signal,
|
|
552
|
-
sink: options?.sink
|
|
553
|
-
});
|
|
554
|
-
const content = RECONSTRUCTORS[node.variant](layout, { signal: options?.signal });
|
|
555
|
-
options?.onDocument?.({
|
|
556
|
-
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
557
|
-
content,
|
|
558
|
-
layout
|
|
559
|
-
});
|
|
560
|
-
if (node.family === "markdown") {
|
|
561
|
-
const text = node.build(content);
|
|
562
|
-
return node.encode(text);
|
|
563
|
-
}
|
|
564
|
-
const pkg = node.build(content);
|
|
565
|
-
return node.encode(pkg);
|
|
566
|
-
}
|
|
567
|
-
function buildCompositionGraph() {
|
|
568
|
-
const adj = /* @__PURE__ */ new Map();
|
|
569
|
-
const addDirected = (from, to, cost) => {
|
|
570
|
-
const list = adj.get(from);
|
|
571
|
-
if (list === void 0) adj.set(from, [{
|
|
572
|
-
to,
|
|
573
|
-
cost
|
|
574
|
-
}]);
|
|
575
|
-
else list.push({
|
|
576
|
-
to,
|
|
577
|
-
cost
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
const addEdge = (from, to, cost) => {
|
|
581
|
-
addDirected(from, to, cost);
|
|
582
|
-
addDirected(to, from, cost);
|
|
583
|
-
};
|
|
584
|
-
for (const a of CONTENT_FORMATS) for (const b of CONTENT_FORMATS) {
|
|
585
|
-
if (a === b) continue;
|
|
586
|
-
if (FORMAT_NODES[a].variant === FORMAT_NODES[b].variant) addEdge(a, b, 1);
|
|
587
|
-
}
|
|
588
|
-
for (const key of Object.keys(TRANSFORMS)) {
|
|
589
|
-
const parts = key.split("->");
|
|
590
|
-
const fromVariant = parts[0];
|
|
591
|
-
const toVariant = parts[1];
|
|
592
|
-
if (fromVariant === void 0 || toVariant === void 0) continue;
|
|
593
|
-
for (const a of CONTENT_FORMATS) {
|
|
594
|
-
if (FORMAT_NODES[a].variant !== fromVariant) continue;
|
|
595
|
-
for (const b of CONTENT_FORMATS) {
|
|
596
|
-
if (FORMAT_NODES[b].variant !== toVariant) continue;
|
|
597
|
-
addEdge(a, b, 2);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
for (const format of CONTENT_FORMATS) if (LAYOUT_CAPABLE.has(format)) addEdge(format, "pdf", 3);
|
|
602
|
-
return adj;
|
|
603
|
-
}
|
|
604
|
-
const COMPOSITION_GRAPH = buildCompositionGraph();
|
|
605
|
-
function shortestPath(source, target) {
|
|
606
|
-
if (source === target) return;
|
|
607
|
-
const distances = /* @__PURE__ */ new Map([[source, 0]]);
|
|
608
|
-
const previous = /* @__PURE__ */ new Map();
|
|
609
|
-
const visited = /* @__PURE__ */ new Set();
|
|
610
|
-
while (true) {
|
|
611
|
-
let current = void 0;
|
|
612
|
-
let currentDist = Infinity;
|
|
613
|
-
for (const [node, dist] of distances) if (!visited.has(node) && dist < currentDist) {
|
|
614
|
-
current = node;
|
|
615
|
-
currentDist = dist;
|
|
616
|
-
}
|
|
617
|
-
if (current === void 0 || current === target) break;
|
|
618
|
-
visited.add(current);
|
|
619
|
-
for (const edge of COMPOSITION_GRAPH.get(current) ?? []) {
|
|
620
|
-
if (visited.has(edge.to)) continue;
|
|
621
|
-
const alt = currentDist + edge.cost;
|
|
622
|
-
const known = distances.get(edge.to);
|
|
623
|
-
if (known === void 0 || alt < known) {
|
|
624
|
-
distances.set(edge.to, alt);
|
|
625
|
-
previous.set(edge.to, current);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
if (distances.get(target) === void 0) return;
|
|
630
|
-
const path = [];
|
|
631
|
-
let cursor = target;
|
|
632
|
-
while (cursor !== void 0) {
|
|
633
|
-
path.unshift(cursor);
|
|
634
|
-
cursor = previous.get(cursor);
|
|
635
|
-
}
|
|
636
|
-
return path;
|
|
637
|
-
}
|
|
638
|
-
function resolveCompositionPlan(source, target) {
|
|
639
|
-
const path = shortestPath(source, target);
|
|
640
|
-
if (path === void 0) return;
|
|
641
|
-
if (path.length > 4) return;
|
|
642
|
-
const hops = [];
|
|
643
|
-
for (let i = 0; i + 1 < path.length; i++) {
|
|
644
|
-
const from = path[i];
|
|
645
|
-
const to = path[i + 1];
|
|
646
|
-
if (from === void 0 || to === void 0) return;
|
|
647
|
-
const executor = to === "pdf" ? "toPdf" : from === "pdf" ? "fromPdf" : "bridge";
|
|
648
|
-
hops.push({
|
|
649
|
-
executor,
|
|
650
|
-
from,
|
|
651
|
-
to
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
return { hops };
|
|
655
|
-
}
|
|
656
|
-
function isContentFormat(format) {
|
|
657
|
-
return format !== "pdf" && format !== "odf";
|
|
658
|
-
}
|
|
659
|
-
function convertDocument(source, target, bytes, options) {
|
|
660
|
-
const plan = resolveCompositionPlan(source, target);
|
|
661
|
-
if (plan === void 0) throw new UnsupportedConversionError(source, target);
|
|
662
|
-
let current = bytes;
|
|
663
|
-
for (let i = 0; i < plan.hops.length; i++) {
|
|
664
|
-
const hop = plan.hops[i];
|
|
665
|
-
if (hop === void 0) throw new Error("convertDocument: resolveCompositionPlan returned a malformed hop");
|
|
666
|
-
const hopOptions = i === plan.hops.length - 1 ? options : options === void 0 ? void 0 : {
|
|
667
|
-
...options,
|
|
668
|
-
onDocument: void 0
|
|
669
|
-
};
|
|
670
|
-
if (hop.executor === "toPdf") {
|
|
671
|
-
if (!isContentFormat(hop.from)) throw new Error(`convertDocument: toPdf source '${hop.from}' is not a content format`);
|
|
672
|
-
current = executeToPdf(hop.from, current, hopOptions);
|
|
673
|
-
} else if (hop.executor === "fromPdf") {
|
|
674
|
-
if (!isContentFormat(hop.to)) throw new Error(`convertDocument: fromPdf target '${hop.to}' is not a content format`);
|
|
675
|
-
current = executeFromPdf(hop.to, current, hopOptions);
|
|
676
|
-
} else {
|
|
677
|
-
if (!isContentFormat(hop.from) || !isContentFormat(hop.to)) throw new Error(`convertDocument: bridge endpoints '${hop.from}' -> '${hop.to}' are not both content formats`);
|
|
678
|
-
current = executeBridge(hop.from, hop.to, current, hopOptions);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return current;
|
|
682
|
-
}
|
|
683
|
-
//#endregion
|
|
684
|
-
//#region src/convert/convert.ts
|
|
685
|
-
const mathMetricsAt = (sizePt) => (0, pdf_codec.loadMathFont)().metricsAt(sizePt);
|
|
686
|
-
function docxToPdf(bytes, options) {
|
|
687
|
-
return convertDocument("docx", "pdf", bytes, options);
|
|
688
|
-
}
|
|
689
|
-
function odtToPdf(bytes, options) {
|
|
690
|
-
return convertDocument("odt", "pdf", bytes, options);
|
|
691
|
-
}
|
|
692
|
-
function pptxToPdf(bytes, options) {
|
|
693
|
-
return convertDocument("pptx", "pdf", bytes, options);
|
|
694
|
-
}
|
|
695
|
-
function odpToPdf(bytes, options) {
|
|
696
|
-
return convertDocument("odp", "pdf", bytes, options);
|
|
697
|
-
}
|
|
698
|
-
function odsToPdf(bytes, options) {
|
|
699
|
-
return convertDocument("ods", "pdf", bytes, options);
|
|
700
|
-
}
|
|
701
|
-
function odgToPdf(bytes, options) {
|
|
702
|
-
return convertDocument("odg", "pdf", bytes, options);
|
|
703
|
-
}
|
|
704
|
-
function markdownToPdf(bytes, options) {
|
|
705
|
-
return convertDocument("markdown", "pdf", bytes, options);
|
|
706
|
-
}
|
|
707
|
-
const STANDALONE_FORMULA_SIZE_PT = 18;
|
|
708
|
-
const STANDALONE_FORMULA_MARGIN_PT = 72;
|
|
709
|
-
function odfToPdf(bytes, options) {
|
|
710
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
711
|
-
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
712
|
-
const read = require_odf_formula_read.readOdfFormulaContent(pkg);
|
|
713
|
-
if (read.kind !== "formula") throw new Error("readOdfFormulaContent returned a non-formula ContentDocument");
|
|
714
|
-
const content = {
|
|
715
|
-
...read,
|
|
716
|
-
metadata: require_model_metadata.resolveMetadataTimestamps(read.metadata, options?.clock)
|
|
717
|
-
};
|
|
718
|
-
const metrics = (0, pdf_codec.loadMathFont)().metricsAt(STANDALONE_FORMULA_SIZE_PT);
|
|
719
|
-
const { box } = require_mathml_layout.layoutFormula(content.formula.mathml, {
|
|
720
|
-
metrics,
|
|
721
|
-
sizePt: STANDALONE_FORMULA_SIZE_PT,
|
|
722
|
-
color: document_schema_js.COLOR_BLACK
|
|
723
|
-
});
|
|
724
|
-
const flipped = require_model_geometry.flipY({
|
|
725
|
-
xPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
726
|
-
yPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
727
|
-
widthPt: box.widthPt,
|
|
728
|
-
heightPt: box.heightPt
|
|
729
|
-
}, document_schema_js.PAGE_SIZE_A4.heightPt);
|
|
730
|
-
const layout = {
|
|
731
|
-
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
732
|
-
metadata: content.metadata,
|
|
733
|
-
pages: [{
|
|
734
|
-
widthPt: document_schema_js.PAGE_SIZE_A4.widthPt,
|
|
735
|
-
heightPt: document_schema_js.PAGE_SIZE_A4.heightPt,
|
|
736
|
-
items: []
|
|
737
|
-
}],
|
|
738
|
-
images: {}
|
|
739
|
-
};
|
|
740
|
-
options?.onDocument?.({
|
|
741
|
-
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
742
|
-
content,
|
|
743
|
-
layout
|
|
744
|
-
});
|
|
745
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
746
|
-
return (0, pdf_codec.writePdf)(layout, {
|
|
747
|
-
signal: options?.signal,
|
|
748
|
-
formulas: [{
|
|
749
|
-
pageIndex: 0,
|
|
750
|
-
xPt: flipped.xPt,
|
|
751
|
-
yPt: flipped.yPt,
|
|
752
|
-
box
|
|
753
|
-
}]
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
function pdfToDocx(bytes, options) {
|
|
757
|
-
return convertDocument("pdf", "docx", bytes, options);
|
|
758
|
-
}
|
|
759
|
-
function pdfToPptx(bytes, options) {
|
|
760
|
-
return convertDocument("pdf", "pptx", bytes, options);
|
|
761
|
-
}
|
|
762
|
-
function pdfToOdt(bytes, options) {
|
|
763
|
-
return convertDocument("pdf", "odt", bytes, options);
|
|
764
|
-
}
|
|
765
|
-
function pdfToOdp(bytes, options) {
|
|
766
|
-
return convertDocument("pdf", "odp", bytes, options);
|
|
767
|
-
}
|
|
768
|
-
function pdfToOdg(bytes, options) {
|
|
769
|
-
return convertDocument("pdf", "odg", bytes, options);
|
|
770
|
-
}
|
|
771
|
-
function pdfToOds(bytes, options) {
|
|
772
|
-
return convertDocument("pdf", "ods", bytes, options);
|
|
773
|
-
}
|
|
774
|
-
function pdfToMarkdown(bytes, options) {
|
|
775
|
-
return convertDocument("pdf", "markdown", bytes, options);
|
|
776
|
-
}
|
|
777
|
-
function odtToDocx(bytes, options) {
|
|
778
|
-
return convertDocument("odt", "docx", bytes, options);
|
|
779
|
-
}
|
|
780
|
-
function docxToOdt(bytes, options) {
|
|
781
|
-
return convertDocument("docx", "odt", bytes, options);
|
|
782
|
-
}
|
|
783
|
-
function odpToPptx(bytes, options) {
|
|
784
|
-
return convertDocument("odp", "pptx", bytes, options);
|
|
785
|
-
}
|
|
786
|
-
function pptxToOdp(bytes, options) {
|
|
787
|
-
return convertDocument("pptx", "odp", bytes, options);
|
|
788
|
-
}
|
|
789
|
-
function odsToXlsx(bytes, options) {
|
|
790
|
-
return convertDocument("ods", "xlsx", bytes, options);
|
|
791
|
-
}
|
|
792
|
-
function xlsxToOds(bytes, options) {
|
|
793
|
-
return convertDocument("xlsx", "ods", bytes, options);
|
|
794
|
-
}
|
|
795
|
-
function markdownToDocx(bytes, options) {
|
|
796
|
-
return convertDocument("markdown", "docx", bytes, options);
|
|
797
|
-
}
|
|
798
|
-
function docxToMarkdown(bytes, options) {
|
|
799
|
-
return convertDocument("docx", "markdown", bytes, options);
|
|
800
|
-
}
|
|
801
|
-
function markdownToOdt(bytes, options) {
|
|
802
|
-
return convertDocument("markdown", "odt", bytes, options);
|
|
803
|
-
}
|
|
804
|
-
function odtToMarkdown(bytes, options) {
|
|
805
|
-
return convertDocument("odt", "markdown", bytes, options);
|
|
806
|
-
}
|
|
807
|
-
function docxToPptx(bytes, options) {
|
|
808
|
-
return convertDocument("docx", "pptx", bytes, options);
|
|
809
|
-
}
|
|
810
|
-
function pptxToDocx(bytes, options) {
|
|
811
|
-
return convertDocument("pptx", "docx", bytes, options);
|
|
812
|
-
}
|
|
813
|
-
function odtToOdp(bytes, options) {
|
|
814
|
-
return convertDocument("odt", "odp", bytes, options);
|
|
815
|
-
}
|
|
816
|
-
function odpToOdt(bytes, options) {
|
|
817
|
-
return convertDocument("odp", "odt", bytes, options);
|
|
818
|
-
}
|
|
819
|
-
function xlsxToPdf(bytes, options) {
|
|
820
|
-
return convertDocument("xlsx", "pdf", bytes, options);
|
|
821
|
-
}
|
|
822
|
-
function pdfToXlsx(bytes, options) {
|
|
823
|
-
return convertDocument("pdf", "xlsx", bytes, options);
|
|
824
|
-
}
|
|
825
|
-
function xlsxToMarkdown(bytes, options) {
|
|
826
|
-
return convertDocument("xlsx", "markdown", bytes, options);
|
|
827
|
-
}
|
|
828
|
-
function markdownToXlsx(bytes, options) {
|
|
829
|
-
return convertDocument("markdown", "xlsx", bytes, options);
|
|
830
|
-
}
|
|
831
|
-
var OdmUnresolvedSectionError = class extends Error {
|
|
832
|
-
hrefs;
|
|
833
|
-
constructor(hrefs) {
|
|
834
|
-
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved -- no inline content and no resolveSubDocument result for: ${hrefs.join(", ")}`);
|
|
835
|
-
this.name = "OdmUnresolvedSectionError";
|
|
836
|
-
this.hrefs = hrefs;
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
const INLINE_SECTION_MARGIN_PT = 56.69291338582677;
|
|
840
|
-
const INLINE_SECTION_MARGINS = {
|
|
841
|
-
topPt: INLINE_SECTION_MARGIN_PT,
|
|
842
|
-
rightPt: INLINE_SECTION_MARGIN_PT,
|
|
843
|
-
bottomPt: INLINE_SECTION_MARGIN_PT,
|
|
844
|
-
leftPt: INLINE_SECTION_MARGIN_PT
|
|
845
|
-
};
|
|
846
|
-
function inlineOdmSectionToContentSection(section, pkg) {
|
|
847
|
-
const blocks = [];
|
|
848
|
-
for (const node of section.inlineContent ?? []) {
|
|
849
|
-
if (node.type !== "element") continue;
|
|
850
|
-
if (node.tag === "text:p" || node.tag === "text:h") blocks.push((0, odf_js.readOdfParagraph)(node, pkg));
|
|
851
|
-
else if (node.tag === "table:table") blocks.push((0, odf_js.readOdfTable)(node, pkg));
|
|
852
|
-
}
|
|
853
|
-
return {
|
|
854
|
-
pageSize: document_schema_js.PAGE_SIZE_A4,
|
|
855
|
-
margins: INLINE_SECTION_MARGINS,
|
|
856
|
-
blocks
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
function withLeadingChapterBreak(section) {
|
|
860
|
-
const pageBreak = { kind: "pageBreak" };
|
|
861
|
-
return {
|
|
862
|
-
...section,
|
|
863
|
-
blocks: [pageBreak, ...section.blocks]
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
function odmToPdf(bytes, options) {
|
|
867
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
868
|
-
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
869
|
-
const odm = (0, odf_js.readOdm)(pkg);
|
|
870
|
-
const unresolvedHrefs = [];
|
|
871
|
-
const chapterSections = [];
|
|
872
|
-
const sourceFonts = require_fonts_registry.extractSourceFonts({
|
|
873
|
-
kind: "odf",
|
|
874
|
-
package: pkg
|
|
875
|
-
});
|
|
876
|
-
for (const section of odm.sections) {
|
|
877
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
878
|
-
if (section.inlineContent !== void 0) {
|
|
879
|
-
chapterSections.push([inlineOdmSectionToContentSection(section, pkg)]);
|
|
880
|
-
continue;
|
|
881
|
-
}
|
|
882
|
-
const chapterBytes = options?.resolveSubDocument?.(section.href);
|
|
883
|
-
if (chapterBytes === void 0) {
|
|
884
|
-
unresolvedHrefs.push(section.href);
|
|
885
|
-
continue;
|
|
886
|
-
}
|
|
887
|
-
const chapterPkg = (0, odf_js.decodePackage)(chapterBytes);
|
|
888
|
-
sourceFonts.push(...require_fonts_registry.extractSourceFonts({
|
|
889
|
-
kind: "odf",
|
|
890
|
-
package: chapterPkg
|
|
891
|
-
}));
|
|
892
|
-
const chapterContent = require_odf_odt_read.readOdtContent(chapterPkg);
|
|
893
|
-
if (chapterContent.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
894
|
-
chapterSections.push(chapterContent.sections);
|
|
895
|
-
}
|
|
896
|
-
if (unresolvedHrefs.length > 0) throw new OdmUnresolvedSectionError(unresolvedHrefs);
|
|
897
|
-
const combinedSections = [];
|
|
898
|
-
chapterSections.forEach((sections, chapterIndex) => {
|
|
899
|
-
if (chapterIndex === 0) {
|
|
900
|
-
combinedSections.push(...sections);
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
combinedSections.push(...sections.map((section, sectionIndex) => sectionIndex === 0 ? withLeadingChapterBreak(section) : section));
|
|
904
|
-
});
|
|
905
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
906
|
-
const content = {
|
|
907
|
-
kind: "wordprocessing",
|
|
908
|
-
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
909
|
-
metadata: require_model_metadata.resolveMetadataTimestamps((0, odf_js.readOdfMetadata)(pkg), options?.clock),
|
|
910
|
-
sections: combinedSections
|
|
911
|
-
};
|
|
912
|
-
const fonts = (0, pdf_codec.createFontRegistry)({
|
|
913
|
-
sourceFonts,
|
|
914
|
-
fonts: options?.fonts,
|
|
915
|
-
onSubstitution: options?.onFontSubstitution
|
|
916
|
-
});
|
|
917
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
918
|
-
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
919
|
-
mathMetricsAt
|
|
920
|
-
});
|
|
921
|
-
return (0, pdf_codec.writePdf)(layout, {
|
|
922
|
-
signal: options?.signal,
|
|
923
|
-
onSubstitution: options?.onSubstitution,
|
|
924
|
-
formulas,
|
|
925
|
-
fonts
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
function odbToXlsx(bytes, options) {
|
|
929
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
930
|
-
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
931
|
-
const tables = require_odb_read.readOdbTables(pkg, { timeZone: options?.timeZone });
|
|
932
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
933
|
-
const content = require_odb_spreadsheet.odbTablesToSpreadsheetDocument(tables);
|
|
934
|
-
return (0, ooxml_js.encodePackage)((0, ooxml_js.buildXlsxPackage)(content));
|
|
935
|
-
}
|
|
936
|
-
function odbToCsv(bytes, options) {
|
|
937
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
938
|
-
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
939
|
-
const tables = require_odb_read.readOdbTables(pkg, { timeZone: options?.timeZone });
|
|
940
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
941
|
-
return require_odb_csv.buildOdbTableCsv(tables, options?.table);
|
|
942
|
-
}
|
|
943
|
-
function odbReportToDocx(content, options) {
|
|
944
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
945
|
-
return (0, ooxml_js.encodePackage)(require_edit_docx_content.buildDocxPackage(content, { onMathDiagnostic: options?.onMathDiagnostic }));
|
|
946
|
-
}
|
|
947
|
-
function odbReportToOdt(content, options) {
|
|
948
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
949
|
-
return (0, odf_js.encodePackage)(require_edit_odt_content.buildOdtPackage(content));
|
|
950
|
-
}
|
|
951
|
-
function odbReportToPdf(content, options) {
|
|
952
|
-
require_ports_abort.throwIfAborted(options?.signal);
|
|
953
|
-
if (content.kind !== "wordprocessing") throw new Error("odbReportToPdf requires a wordprocessing ContentDocument");
|
|
954
|
-
const fonts = (0, pdf_codec.createFontRegistry)({
|
|
955
|
-
fonts: options?.fonts,
|
|
956
|
-
onSubstitution: options?.onFontSubstitution
|
|
957
|
-
});
|
|
958
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
959
|
-
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
960
|
-
mathMetricsAt
|
|
961
|
-
});
|
|
962
|
-
options?.onDocument?.({
|
|
963
|
-
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
964
|
-
content,
|
|
965
|
-
layout
|
|
966
|
-
});
|
|
967
|
-
return (0, pdf_codec.writePdf)(layout, {
|
|
968
|
-
signal: options?.signal,
|
|
969
|
-
onSubstitution: options?.onSubstitution,
|
|
970
|
-
formulas,
|
|
971
|
-
fonts
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
//#endregion
|
|
975
|
-
Object.defineProperty(exports, "DIRECT_EDGES", {
|
|
976
|
-
enumerable: true,
|
|
977
|
-
get: function() {
|
|
978
|
-
return DIRECT_EDGES;
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
|
-
Object.defineProperty(exports, "FORMAT_CAPABILITIES", {
|
|
982
|
-
enumerable: true,
|
|
983
|
-
get: function() {
|
|
984
|
-
return FORMAT_CAPABILITIES;
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
Object.defineProperty(exports, "FORMAT_NODES", {
|
|
988
|
-
enumerable: true,
|
|
989
|
-
get: function() {
|
|
990
|
-
return FORMAT_NODES;
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
Object.defineProperty(exports, "OdmUnresolvedSectionError", {
|
|
994
|
-
enumerable: true,
|
|
995
|
-
get: function() {
|
|
996
|
-
return OdmUnresolvedSectionError;
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
Object.defineProperty(exports, "UnsupportedConversionError", {
|
|
1000
|
-
enumerable: true,
|
|
1001
|
-
get: function() {
|
|
1002
|
-
return UnsupportedConversionError;
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
Object.defineProperty(exports, "convertDocument", {
|
|
1006
|
-
enumerable: true,
|
|
1007
|
-
get: function() {
|
|
1008
|
-
return convertDocument;
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
Object.defineProperty(exports, "docxToMarkdown", {
|
|
1012
|
-
enumerable: true,
|
|
1013
|
-
get: function() {
|
|
1014
|
-
return docxToMarkdown;
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
Object.defineProperty(exports, "docxToOdt", {
|
|
1018
|
-
enumerable: true,
|
|
1019
|
-
get: function() {
|
|
1020
|
-
return docxToOdt;
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
Object.defineProperty(exports, "docxToPdf", {
|
|
1024
|
-
enumerable: true,
|
|
1025
|
-
get: function() {
|
|
1026
|
-
return docxToPdf;
|
|
1027
|
-
}
|
|
1028
|
-
});
|
|
1029
|
-
Object.defineProperty(exports, "docxToPptx", {
|
|
1030
|
-
enumerable: true,
|
|
1031
|
-
get: function() {
|
|
1032
|
-
return docxToPptx;
|
|
1033
|
-
}
|
|
1034
|
-
});
|
|
1035
|
-
Object.defineProperty(exports, "inlineOdmSectionToContentSection", {
|
|
1036
|
-
enumerable: true,
|
|
1037
|
-
get: function() {
|
|
1038
|
-
return inlineOdmSectionToContentSection;
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
Object.defineProperty(exports, "markdownToDocx", {
|
|
1042
|
-
enumerable: true,
|
|
1043
|
-
get: function() {
|
|
1044
|
-
return markdownToDocx;
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
Object.defineProperty(exports, "markdownToOdt", {
|
|
1048
|
-
enumerable: true,
|
|
1049
|
-
get: function() {
|
|
1050
|
-
return markdownToOdt;
|
|
1051
|
-
}
|
|
1052
|
-
});
|
|
1053
|
-
Object.defineProperty(exports, "markdownToPdf", {
|
|
1054
|
-
enumerable: true,
|
|
1055
|
-
get: function() {
|
|
1056
|
-
return markdownToPdf;
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
Object.defineProperty(exports, "markdownToXlsx", {
|
|
1060
|
-
enumerable: true,
|
|
1061
|
-
get: function() {
|
|
1062
|
-
return markdownToXlsx;
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
Object.defineProperty(exports, "odbReportToDocx", {
|
|
1066
|
-
enumerable: true,
|
|
1067
|
-
get: function() {
|
|
1068
|
-
return odbReportToDocx;
|
|
1069
|
-
}
|
|
1070
|
-
});
|
|
1071
|
-
Object.defineProperty(exports, "odbReportToOdt", {
|
|
1072
|
-
enumerable: true,
|
|
1073
|
-
get: function() {
|
|
1074
|
-
return odbReportToOdt;
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
Object.defineProperty(exports, "odbReportToPdf", {
|
|
1078
|
-
enumerable: true,
|
|
1079
|
-
get: function() {
|
|
1080
|
-
return odbReportToPdf;
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
Object.defineProperty(exports, "odbToCsv", {
|
|
1084
|
-
enumerable: true,
|
|
1085
|
-
get: function() {
|
|
1086
|
-
return odbToCsv;
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
Object.defineProperty(exports, "odbToXlsx", {
|
|
1090
|
-
enumerable: true,
|
|
1091
|
-
get: function() {
|
|
1092
|
-
return odbToXlsx;
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
Object.defineProperty(exports, "odfToPdf", {
|
|
1096
|
-
enumerable: true,
|
|
1097
|
-
get: function() {
|
|
1098
|
-
return odfToPdf;
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
Object.defineProperty(exports, "odgToPdf", {
|
|
1102
|
-
enumerable: true,
|
|
1103
|
-
get: function() {
|
|
1104
|
-
return odgToPdf;
|
|
1105
|
-
}
|
|
1106
|
-
});
|
|
1107
|
-
Object.defineProperty(exports, "odmToPdf", {
|
|
1108
|
-
enumerable: true,
|
|
1109
|
-
get: function() {
|
|
1110
|
-
return odmToPdf;
|
|
1111
|
-
}
|
|
1112
|
-
});
|
|
1113
|
-
Object.defineProperty(exports, "odpToOdt", {
|
|
1114
|
-
enumerable: true,
|
|
1115
|
-
get: function() {
|
|
1116
|
-
return odpToOdt;
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
Object.defineProperty(exports, "odpToPdf", {
|
|
1120
|
-
enumerable: true,
|
|
1121
|
-
get: function() {
|
|
1122
|
-
return odpToPdf;
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
Object.defineProperty(exports, "odpToPptx", {
|
|
1126
|
-
enumerable: true,
|
|
1127
|
-
get: function() {
|
|
1128
|
-
return odpToPptx;
|
|
1129
|
-
}
|
|
1130
|
-
});
|
|
1131
|
-
Object.defineProperty(exports, "odsToPdf", {
|
|
1132
|
-
enumerable: true,
|
|
1133
|
-
get: function() {
|
|
1134
|
-
return odsToPdf;
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
Object.defineProperty(exports, "odsToXlsx", {
|
|
1138
|
-
enumerable: true,
|
|
1139
|
-
get: function() {
|
|
1140
|
-
return odsToXlsx;
|
|
1141
|
-
}
|
|
1142
|
-
});
|
|
1143
|
-
Object.defineProperty(exports, "odtToDocx", {
|
|
1144
|
-
enumerable: true,
|
|
1145
|
-
get: function() {
|
|
1146
|
-
return odtToDocx;
|
|
1147
|
-
}
|
|
1148
|
-
});
|
|
1149
|
-
Object.defineProperty(exports, "odtToMarkdown", {
|
|
1150
|
-
enumerable: true,
|
|
1151
|
-
get: function() {
|
|
1152
|
-
return odtToMarkdown;
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
Object.defineProperty(exports, "odtToOdp", {
|
|
1156
|
-
enumerable: true,
|
|
1157
|
-
get: function() {
|
|
1158
|
-
return odtToOdp;
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
Object.defineProperty(exports, "odtToPdf", {
|
|
1162
|
-
enumerable: true,
|
|
1163
|
-
get: function() {
|
|
1164
|
-
return odtToPdf;
|
|
1165
|
-
}
|
|
1166
|
-
});
|
|
1167
|
-
Object.defineProperty(exports, "pdfToDocx", {
|
|
1168
|
-
enumerable: true,
|
|
1169
|
-
get: function() {
|
|
1170
|
-
return pdfToDocx;
|
|
1171
|
-
}
|
|
1172
|
-
});
|
|
1173
|
-
Object.defineProperty(exports, "pdfToMarkdown", {
|
|
1174
|
-
enumerable: true,
|
|
1175
|
-
get: function() {
|
|
1176
|
-
return pdfToMarkdown;
|
|
1177
|
-
}
|
|
1178
|
-
});
|
|
1179
|
-
Object.defineProperty(exports, "pdfToOdg", {
|
|
1180
|
-
enumerable: true,
|
|
1181
|
-
get: function() {
|
|
1182
|
-
return pdfToOdg;
|
|
1183
|
-
}
|
|
1184
|
-
});
|
|
1185
|
-
Object.defineProperty(exports, "pdfToOdp", {
|
|
1186
|
-
enumerable: true,
|
|
1187
|
-
get: function() {
|
|
1188
|
-
return pdfToOdp;
|
|
1189
|
-
}
|
|
1190
|
-
});
|
|
1191
|
-
Object.defineProperty(exports, "pdfToOds", {
|
|
1192
|
-
enumerable: true,
|
|
1193
|
-
get: function() {
|
|
1194
|
-
return pdfToOds;
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
Object.defineProperty(exports, "pdfToOdt", {
|
|
1198
|
-
enumerable: true,
|
|
1199
|
-
get: function() {
|
|
1200
|
-
return pdfToOdt;
|
|
1201
|
-
}
|
|
1202
|
-
});
|
|
1203
|
-
Object.defineProperty(exports, "pdfToPptx", {
|
|
1204
|
-
enumerable: true,
|
|
1205
|
-
get: function() {
|
|
1206
|
-
return pdfToPptx;
|
|
1207
|
-
}
|
|
1208
|
-
});
|
|
1209
|
-
Object.defineProperty(exports, "pdfToXlsx", {
|
|
1210
|
-
enumerable: true,
|
|
1211
|
-
get: function() {
|
|
1212
|
-
return pdfToXlsx;
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
|
-
Object.defineProperty(exports, "pptxToDocx", {
|
|
1216
|
-
enumerable: true,
|
|
1217
|
-
get: function() {
|
|
1218
|
-
return pptxToDocx;
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
Object.defineProperty(exports, "pptxToOdp", {
|
|
1222
|
-
enumerable: true,
|
|
1223
|
-
get: function() {
|
|
1224
|
-
return pptxToOdp;
|
|
1225
|
-
}
|
|
1226
|
-
});
|
|
1227
|
-
Object.defineProperty(exports, "pptxToPdf", {
|
|
1228
|
-
enumerable: true,
|
|
1229
|
-
get: function() {
|
|
1230
|
-
return pptxToPdf;
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
Object.defineProperty(exports, "resolveCompositionPlan", {
|
|
1234
|
-
enumerable: true,
|
|
1235
|
-
get: function() {
|
|
1236
|
-
return resolveCompositionPlan;
|
|
1237
|
-
}
|
|
1238
|
-
});
|
|
1239
|
-
Object.defineProperty(exports, "resolveConversionPath", {
|
|
1240
|
-
enumerable: true,
|
|
1241
|
-
get: function() {
|
|
1242
|
-
return resolveConversionPath;
|
|
1243
|
-
}
|
|
1244
|
-
});
|
|
1245
|
-
Object.defineProperty(exports, "xlsxToMarkdown", {
|
|
1246
|
-
enumerable: true,
|
|
1247
|
-
get: function() {
|
|
1248
|
-
return xlsxToMarkdown;
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
Object.defineProperty(exports, "xlsxToOds", {
|
|
1252
|
-
enumerable: true,
|
|
1253
|
-
get: function() {
|
|
1254
|
-
return xlsxToOds;
|
|
1255
|
-
}
|
|
1256
|
-
});
|
|
1257
|
-
Object.defineProperty(exports, "xlsxToPdf", {
|
|
1258
|
-
enumerable: true,
|
|
1259
|
-
get: function() {
|
|
1260
|
-
return xlsxToPdf;
|
|
1261
|
-
}
|
|
1262
|
-
});
|