documents.js 1.58.0 → 1.60.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/README.md +65 -26
- package/dist/convert/capability.cjs +239 -0
- package/dist/convert/capability.d.cts +42 -0
- package/dist/convert/capability.d.ts +42 -0
- package/dist/convert/capability.js +236 -0
- package/dist/convert/codec.cjs +20 -0
- package/dist/convert/codec.d.cts +5 -1
- package/dist/convert/codec.d.ts +5 -1
- package/dist/convert/codec.js +19 -3
- package/dist/convert/convert.cjs +114 -0
- package/dist/convert/convert.d.cts +9 -1
- package/dist/convert/convert.d.ts +9 -1
- package/dist/convert/convert.js +107 -1
- package/dist/convert/local.cjs +26 -335
- package/dist/convert/local.js +26 -335
- package/dist/convert/port.d.cts +1 -1
- package/dist/convert/port.d.ts +1 -1
- package/dist/edit/ods/column-row.cjs +31 -0
- package/dist/edit/ods/column-row.d.cts +6 -0
- package/dist/edit/ods/column-row.d.ts +6 -0
- package/dist/edit/ods/column-row.js +29 -0
- package/dist/edit/ods/content.cjs +2 -0
- package/dist/edit/ods/content.js +2 -0
- package/dist/edit/ods/sheet.cjs +7 -0
- package/dist/edit/ods/sheet.d.cts +2 -0
- package/dist/edit/ods/sheet.d.ts +2 -0
- package/dist/edit/ods/sheet.js +7 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -4
- package/dist/markdown/read.cjs +16 -0
- package/dist/markdown/read.d.cts +6 -0
- package/dist/markdown/read.d.ts +6 -0
- package/dist/markdown/read.js +15 -0
- package/dist/markdown/text.cjs +16 -0
- package/dist/markdown/text.d.cts +5 -0
- package/dist/markdown/text.d.ts +5 -0
- package/dist/markdown/text.js +14 -0
- package/dist/markdown/write.cjs +8 -0
- package/dist/markdown/write.d.cts +6 -0
- package/dist/markdown/write.d.ts +6 -0
- package/dist/markdown/write.js +7 -0
- package/dist/model/bytes.cjs +10 -0
- package/dist/model/bytes.d.cts +2 -1
- package/dist/model/bytes.d.ts +2 -1
- package/dist/model/bytes.js +10 -1
- package/package.json +2 -1
package/dist/convert/local.cjs
CHANGED
|
@@ -1,84 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_convert_capability = require("./capability.cjs");
|
|
3
3
|
//#region src/convert/local.ts
|
|
4
|
-
const SUPPORTED_CONVERSIONS =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
source: "pptx",
|
|
11
|
-
target: "pdf"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
source: "odt",
|
|
15
|
-
target: "pdf"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
source: "odp",
|
|
19
|
-
target: "pdf"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
source: "ods",
|
|
23
|
-
target: "pdf"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
source: "odg",
|
|
27
|
-
target: "pdf"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
source: "odf",
|
|
31
|
-
target: "pdf"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
source: "pdf",
|
|
35
|
-
target: "docx"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
source: "pdf",
|
|
39
|
-
target: "pptx"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
source: "pdf",
|
|
43
|
-
target: "odt"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
source: "pdf",
|
|
47
|
-
target: "odp"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
source: "pdf",
|
|
51
|
-
target: "ods"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
source: "pdf",
|
|
55
|
-
target: "odg"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
source: "odt",
|
|
59
|
-
target: "docx"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
source: "docx",
|
|
63
|
-
target: "odt"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
source: "odp",
|
|
67
|
-
target: "pptx"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
source: "pptx",
|
|
71
|
-
target: "odp"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
source: "ods",
|
|
75
|
-
target: "xlsx"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
source: "xlsx",
|
|
79
|
-
target: "ods"
|
|
80
|
-
}
|
|
81
|
-
];
|
|
4
|
+
const SUPPORTED_CONVERSIONS = require_convert_capability.DIRECT_EDGES.map((edge) => ({
|
|
5
|
+
source: edge.source,
|
|
6
|
+
target: edge.target
|
|
7
|
+
}));
|
|
82
8
|
function substitutionDiagnostic(substitution, context) {
|
|
83
9
|
return {
|
|
84
10
|
severity: "info",
|
|
@@ -106,286 +32,51 @@ function createLocalDocumentConverter() {
|
|
|
106
32
|
const onDocument = (pkg) => {
|
|
107
33
|
documentPackage = pkg;
|
|
108
34
|
};
|
|
109
|
-
|
|
110
|
-
|
|
35
|
+
const strategy = require_convert_capability.resolveConversionPath(source.format, targetFormat);
|
|
36
|
+
if (strategy?.kind !== "direct") return Promise.reject(/* @__PURE__ */ new Error(`unsupported conversion: ${source.format} -> ${targetFormat}`));
|
|
37
|
+
const edge = strategy.edge;
|
|
38
|
+
if (edge.kind === "toPdf") {
|
|
39
|
+
const bytes = edge.convert(source.bytes, {
|
|
111
40
|
signal: options.signal,
|
|
112
41
|
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
113
42
|
onDocument
|
|
114
43
|
});
|
|
115
44
|
return Promise.resolve({
|
|
116
45
|
document: {
|
|
117
|
-
format:
|
|
46
|
+
format: edge.target,
|
|
118
47
|
bytes
|
|
119
48
|
},
|
|
120
49
|
diagnostics,
|
|
121
50
|
package: documentPackage
|
|
122
51
|
});
|
|
123
52
|
}
|
|
124
|
-
if (
|
|
125
|
-
const bytes =
|
|
126
|
-
signal: options.signal,
|
|
127
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
128
|
-
onDocument
|
|
129
|
-
});
|
|
130
|
-
return Promise.resolve({
|
|
131
|
-
document: {
|
|
132
|
-
format: "pdf",
|
|
133
|
-
bytes
|
|
134
|
-
},
|
|
135
|
-
diagnostics,
|
|
136
|
-
package: documentPackage
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (source.format === "odt" && targetFormat === "pdf") {
|
|
140
|
-
const bytes = require_convert_convert.odtToPdf(source.bytes, {
|
|
141
|
-
signal: options.signal,
|
|
142
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
143
|
-
onDocument
|
|
144
|
-
});
|
|
145
|
-
return Promise.resolve({
|
|
146
|
-
document: {
|
|
147
|
-
format: "pdf",
|
|
148
|
-
bytes
|
|
149
|
-
},
|
|
150
|
-
diagnostics,
|
|
151
|
-
package: documentPackage
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
if (source.format === "odp" && targetFormat === "pdf") {
|
|
155
|
-
const bytes = require_convert_convert.odpToPdf(source.bytes, {
|
|
156
|
-
signal: options.signal,
|
|
157
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
158
|
-
onDocument
|
|
159
|
-
});
|
|
160
|
-
return Promise.resolve({
|
|
161
|
-
document: {
|
|
162
|
-
format: "pdf",
|
|
163
|
-
bytes
|
|
164
|
-
},
|
|
165
|
-
diagnostics,
|
|
166
|
-
package: documentPackage
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
if (source.format === "ods" && targetFormat === "pdf") {
|
|
170
|
-
const bytes = require_convert_convert.odsToPdf(source.bytes, {
|
|
171
|
-
signal: options.signal,
|
|
172
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
173
|
-
onDocument
|
|
174
|
-
});
|
|
175
|
-
return Promise.resolve({
|
|
176
|
-
document: {
|
|
177
|
-
format: "pdf",
|
|
178
|
-
bytes
|
|
179
|
-
},
|
|
180
|
-
diagnostics,
|
|
181
|
-
package: documentPackage
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (source.format === "odg" && targetFormat === "pdf") {
|
|
185
|
-
const bytes = require_convert_convert.odgToPdf(source.bytes, {
|
|
186
|
-
signal: options.signal,
|
|
187
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
188
|
-
onDocument
|
|
189
|
-
});
|
|
190
|
-
return Promise.resolve({
|
|
191
|
-
document: {
|
|
192
|
-
format: "pdf",
|
|
193
|
-
bytes
|
|
194
|
-
},
|
|
195
|
-
diagnostics,
|
|
196
|
-
package: documentPackage
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
if (source.format === "odf" && targetFormat === "pdf") {
|
|
200
|
-
const bytes = require_convert_convert.odfToPdf(source.bytes, {
|
|
201
|
-
signal: options.signal,
|
|
202
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
203
|
-
onDocument
|
|
204
|
-
});
|
|
205
|
-
return Promise.resolve({
|
|
206
|
-
document: {
|
|
207
|
-
format: "pdf",
|
|
208
|
-
bytes
|
|
209
|
-
},
|
|
210
|
-
diagnostics,
|
|
211
|
-
package: documentPackage
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
if (source.format === "pdf" && targetFormat === "docx") {
|
|
215
|
-
const bytes = require_convert_convert.pdfToDocx(source.bytes, {
|
|
216
|
-
signal: options.signal,
|
|
217
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
218
|
-
onDocument
|
|
219
|
-
});
|
|
220
|
-
return Promise.resolve({
|
|
221
|
-
document: {
|
|
222
|
-
format: "docx",
|
|
223
|
-
bytes
|
|
224
|
-
},
|
|
225
|
-
diagnostics,
|
|
226
|
-
package: documentPackage
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (source.format === "pdf" && targetFormat === "pptx") {
|
|
230
|
-
const bytes = require_convert_convert.pdfToPptx(source.bytes, {
|
|
231
|
-
signal: options.signal,
|
|
232
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
233
|
-
onDocument
|
|
234
|
-
});
|
|
235
|
-
return Promise.resolve({
|
|
236
|
-
document: {
|
|
237
|
-
format: "pptx",
|
|
238
|
-
bytes
|
|
239
|
-
},
|
|
240
|
-
diagnostics,
|
|
241
|
-
package: documentPackage
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
if (source.format === "pdf" && targetFormat === "odt") {
|
|
245
|
-
const bytes = require_convert_convert.pdfToOdt(source.bytes, {
|
|
246
|
-
signal: options.signal,
|
|
247
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
248
|
-
onDocument
|
|
249
|
-
});
|
|
250
|
-
return Promise.resolve({
|
|
251
|
-
document: {
|
|
252
|
-
format: "odt",
|
|
253
|
-
bytes
|
|
254
|
-
},
|
|
255
|
-
diagnostics,
|
|
256
|
-
package: documentPackage
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if (source.format === "pdf" && targetFormat === "odp") {
|
|
260
|
-
const bytes = require_convert_convert.pdfToOdp(source.bytes, {
|
|
261
|
-
signal: options.signal,
|
|
262
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
263
|
-
onDocument
|
|
264
|
-
});
|
|
265
|
-
return Promise.resolve({
|
|
266
|
-
document: {
|
|
267
|
-
format: "odp",
|
|
268
|
-
bytes
|
|
269
|
-
},
|
|
270
|
-
diagnostics,
|
|
271
|
-
package: documentPackage
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
if (source.format === "pdf" && targetFormat === "ods") {
|
|
275
|
-
const bytes = require_convert_convert.pdfToOds(source.bytes, {
|
|
276
|
-
signal: options.signal,
|
|
277
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
278
|
-
onDocument
|
|
279
|
-
});
|
|
280
|
-
return Promise.resolve({
|
|
281
|
-
document: {
|
|
282
|
-
format: "ods",
|
|
283
|
-
bytes
|
|
284
|
-
},
|
|
285
|
-
diagnostics,
|
|
286
|
-
package: documentPackage
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
if (source.format === "pdf" && targetFormat === "odg") {
|
|
290
|
-
const bytes = require_convert_convert.pdfToOdg(source.bytes, {
|
|
53
|
+
if (edge.kind === "fromPdf") {
|
|
54
|
+
const bytes = edge.convert(source.bytes, {
|
|
291
55
|
signal: options.signal,
|
|
292
56
|
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
293
57
|
onDocument
|
|
294
58
|
});
|
|
295
59
|
return Promise.resolve({
|
|
296
60
|
document: {
|
|
297
|
-
format:
|
|
298
|
-
bytes
|
|
299
|
-
},
|
|
300
|
-
diagnostics,
|
|
301
|
-
package: documentPackage
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
if (source.format === "odt" && targetFormat === "docx") {
|
|
305
|
-
const bytes = require_convert_convert.odtToDocx(source.bytes, {
|
|
306
|
-
signal: options.signal,
|
|
307
|
-
onDocument
|
|
308
|
-
});
|
|
309
|
-
return Promise.resolve({
|
|
310
|
-
document: {
|
|
311
|
-
format: "docx",
|
|
312
|
-
bytes
|
|
313
|
-
},
|
|
314
|
-
diagnostics,
|
|
315
|
-
package: documentPackage
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
if (source.format === "docx" && targetFormat === "odt") {
|
|
319
|
-
const bytes = require_convert_convert.docxToOdt(source.bytes, {
|
|
320
|
-
signal: options.signal,
|
|
321
|
-
onDocument
|
|
322
|
-
});
|
|
323
|
-
return Promise.resolve({
|
|
324
|
-
document: {
|
|
325
|
-
format: "odt",
|
|
326
|
-
bytes
|
|
327
|
-
},
|
|
328
|
-
diagnostics,
|
|
329
|
-
package: documentPackage
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
if (source.format === "odp" && targetFormat === "pptx") {
|
|
333
|
-
const bytes = require_convert_convert.odpToPptx(source.bytes, {
|
|
334
|
-
signal: options.signal,
|
|
335
|
-
onDocument
|
|
336
|
-
});
|
|
337
|
-
return Promise.resolve({
|
|
338
|
-
document: {
|
|
339
|
-
format: "pptx",
|
|
340
|
-
bytes
|
|
341
|
-
},
|
|
342
|
-
diagnostics,
|
|
343
|
-
package: documentPackage
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
if (source.format === "pptx" && targetFormat === "odp") {
|
|
347
|
-
const bytes = require_convert_convert.pptxToOdp(source.bytes, {
|
|
348
|
-
signal: options.signal,
|
|
349
|
-
onDocument
|
|
350
|
-
});
|
|
351
|
-
return Promise.resolve({
|
|
352
|
-
document: {
|
|
353
|
-
format: "odp",
|
|
354
|
-
bytes
|
|
355
|
-
},
|
|
356
|
-
diagnostics,
|
|
357
|
-
package: documentPackage
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
if (source.format === "ods" && targetFormat === "xlsx") {
|
|
361
|
-
const bytes = require_convert_convert.odsToXlsx(source.bytes, {
|
|
362
|
-
signal: options.signal,
|
|
363
|
-
onDocument
|
|
364
|
-
});
|
|
365
|
-
return Promise.resolve({
|
|
366
|
-
document: {
|
|
367
|
-
format: "xlsx",
|
|
368
|
-
bytes
|
|
369
|
-
},
|
|
370
|
-
diagnostics,
|
|
371
|
-
package: documentPackage
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
if (source.format === "xlsx" && targetFormat === "ods") {
|
|
375
|
-
const bytes = require_convert_convert.xlsxToOds(source.bytes, {
|
|
376
|
-
signal: options.signal,
|
|
377
|
-
onDocument
|
|
378
|
-
});
|
|
379
|
-
return Promise.resolve({
|
|
380
|
-
document: {
|
|
381
|
-
format: "ods",
|
|
61
|
+
format: edge.target,
|
|
382
62
|
bytes
|
|
383
63
|
},
|
|
384
64
|
diagnostics,
|
|
385
65
|
package: documentPackage
|
|
386
66
|
});
|
|
387
67
|
}
|
|
388
|
-
|
|
68
|
+
const bytes = edge.convert(source.bytes, {
|
|
69
|
+
signal: options.signal,
|
|
70
|
+
onDocument
|
|
71
|
+
});
|
|
72
|
+
return Promise.resolve({
|
|
73
|
+
document: {
|
|
74
|
+
format: edge.target,
|
|
75
|
+
bytes
|
|
76
|
+
},
|
|
77
|
+
diagnostics,
|
|
78
|
+
package: documentPackage
|
|
79
|
+
});
|
|
389
80
|
}
|
|
390
81
|
};
|
|
391
82
|
}
|