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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_convert_convert = require("./convert.cjs");
|
|
3
|
+
//#region src/convert/capability.ts
|
|
4
|
+
const FORMAT_CAPABILITIES = {
|
|
5
|
+
docx: {
|
|
6
|
+
format: "docx",
|
|
7
|
+
variant: "wordprocessing",
|
|
8
|
+
hasLayoutPath: true
|
|
9
|
+
},
|
|
10
|
+
odt: {
|
|
11
|
+
format: "odt",
|
|
12
|
+
variant: "wordprocessing",
|
|
13
|
+
hasLayoutPath: true
|
|
14
|
+
},
|
|
15
|
+
pptx: {
|
|
16
|
+
format: "pptx",
|
|
17
|
+
variant: "presentation",
|
|
18
|
+
hasLayoutPath: true
|
|
19
|
+
},
|
|
20
|
+
odp: {
|
|
21
|
+
format: "odp",
|
|
22
|
+
variant: "presentation",
|
|
23
|
+
hasLayoutPath: true
|
|
24
|
+
},
|
|
25
|
+
ods: {
|
|
26
|
+
format: "ods",
|
|
27
|
+
variant: "spreadsheet",
|
|
28
|
+
hasLayoutPath: true
|
|
29
|
+
},
|
|
30
|
+
xlsx: {
|
|
31
|
+
format: "xlsx",
|
|
32
|
+
variant: "spreadsheet",
|
|
33
|
+
hasLayoutPath: false
|
|
34
|
+
},
|
|
35
|
+
odg: {
|
|
36
|
+
format: "odg",
|
|
37
|
+
variant: "drawing",
|
|
38
|
+
hasLayoutPath: true
|
|
39
|
+
},
|
|
40
|
+
odf: {
|
|
41
|
+
format: "odf",
|
|
42
|
+
hasLayoutPath: false
|
|
43
|
+
},
|
|
44
|
+
markdown: {
|
|
45
|
+
format: "markdown",
|
|
46
|
+
variant: "wordprocessing",
|
|
47
|
+
hasLayoutPath: true
|
|
48
|
+
},
|
|
49
|
+
pdf: {
|
|
50
|
+
format: "pdf",
|
|
51
|
+
hasLayoutPath: false
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const DIRECT_EDGES = [
|
|
55
|
+
{
|
|
56
|
+
kind: "toPdf",
|
|
57
|
+
source: "docx",
|
|
58
|
+
target: "pdf",
|
|
59
|
+
convert: require_convert_convert.docxToPdf
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
kind: "toPdf",
|
|
63
|
+
source: "pptx",
|
|
64
|
+
target: "pdf",
|
|
65
|
+
convert: require_convert_convert.pptxToPdf
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
kind: "toPdf",
|
|
69
|
+
source: "odt",
|
|
70
|
+
target: "pdf",
|
|
71
|
+
convert: require_convert_convert.odtToPdf
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
kind: "toPdf",
|
|
75
|
+
source: "odp",
|
|
76
|
+
target: "pdf",
|
|
77
|
+
convert: require_convert_convert.odpToPdf
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
kind: "toPdf",
|
|
81
|
+
source: "ods",
|
|
82
|
+
target: "pdf",
|
|
83
|
+
convert: require_convert_convert.odsToPdf
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
kind: "toPdf",
|
|
87
|
+
source: "odg",
|
|
88
|
+
target: "pdf",
|
|
89
|
+
convert: require_convert_convert.odgToPdf
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
kind: "toPdf",
|
|
93
|
+
source: "odf",
|
|
94
|
+
target: "pdf",
|
|
95
|
+
convert: require_convert_convert.odfToPdf
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
kind: "toPdf",
|
|
99
|
+
source: "xlsx",
|
|
100
|
+
target: "pdf",
|
|
101
|
+
convert: require_convert_convert.xlsxToPdf
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
kind: "toPdf",
|
|
105
|
+
source: "markdown",
|
|
106
|
+
target: "pdf",
|
|
107
|
+
convert: require_convert_convert.markdownToPdf
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
kind: "fromPdf",
|
|
111
|
+
source: "pdf",
|
|
112
|
+
target: "docx",
|
|
113
|
+
convert: require_convert_convert.pdfToDocx
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
kind: "fromPdf",
|
|
117
|
+
source: "pdf",
|
|
118
|
+
target: "pptx",
|
|
119
|
+
convert: require_convert_convert.pdfToPptx
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
kind: "fromPdf",
|
|
123
|
+
source: "pdf",
|
|
124
|
+
target: "odt",
|
|
125
|
+
convert: require_convert_convert.pdfToOdt
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
kind: "fromPdf",
|
|
129
|
+
source: "pdf",
|
|
130
|
+
target: "odp",
|
|
131
|
+
convert: require_convert_convert.pdfToOdp
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
kind: "fromPdf",
|
|
135
|
+
source: "pdf",
|
|
136
|
+
target: "ods",
|
|
137
|
+
convert: require_convert_convert.pdfToOds
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
kind: "fromPdf",
|
|
141
|
+
source: "pdf",
|
|
142
|
+
target: "odg",
|
|
143
|
+
convert: require_convert_convert.pdfToOdg
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
kind: "fromPdf",
|
|
147
|
+
source: "pdf",
|
|
148
|
+
target: "xlsx",
|
|
149
|
+
convert: require_convert_convert.pdfToXlsx
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
kind: "fromPdf",
|
|
153
|
+
source: "pdf",
|
|
154
|
+
target: "markdown",
|
|
155
|
+
convert: require_convert_convert.pdfToMarkdown
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
kind: "bridge",
|
|
159
|
+
source: "odt",
|
|
160
|
+
target: "docx",
|
|
161
|
+
convert: require_convert_convert.odtToDocx
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
kind: "bridge",
|
|
165
|
+
source: "docx",
|
|
166
|
+
target: "odt",
|
|
167
|
+
convert: require_convert_convert.docxToOdt
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
kind: "bridge",
|
|
171
|
+
source: "odp",
|
|
172
|
+
target: "pptx",
|
|
173
|
+
convert: require_convert_convert.odpToPptx
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
kind: "bridge",
|
|
177
|
+
source: "pptx",
|
|
178
|
+
target: "odp",
|
|
179
|
+
convert: require_convert_convert.pptxToOdp
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
kind: "bridge",
|
|
183
|
+
source: "ods",
|
|
184
|
+
target: "xlsx",
|
|
185
|
+
convert: require_convert_convert.odsToXlsx
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
kind: "bridge",
|
|
189
|
+
source: "xlsx",
|
|
190
|
+
target: "ods",
|
|
191
|
+
convert: require_convert_convert.xlsxToOds
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
kind: "bridge",
|
|
195
|
+
source: "markdown",
|
|
196
|
+
target: "docx",
|
|
197
|
+
convert: require_convert_convert.markdownToDocx
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
kind: "bridge",
|
|
201
|
+
source: "docx",
|
|
202
|
+
target: "markdown",
|
|
203
|
+
convert: require_convert_convert.docxToMarkdown
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
kind: "bridge",
|
|
207
|
+
source: "markdown",
|
|
208
|
+
target: "odt",
|
|
209
|
+
convert: require_convert_convert.markdownToOdt
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
kind: "bridge",
|
|
213
|
+
source: "odt",
|
|
214
|
+
target: "markdown",
|
|
215
|
+
convert: require_convert_convert.odtToMarkdown
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
function resolveConversionPath(source, target, edges = DIRECT_EDGES) {
|
|
219
|
+
if (source === target) return;
|
|
220
|
+
const direct = edges.find((edge) => edge.source === source && edge.target === target);
|
|
221
|
+
if (direct !== void 0) return {
|
|
222
|
+
kind: "direct",
|
|
223
|
+
edge: direct
|
|
224
|
+
};
|
|
225
|
+
for (const first of edges) {
|
|
226
|
+
if (first.source !== source) continue;
|
|
227
|
+
const second = edges.find((edge) => edge.source === first.target && edge.target === target);
|
|
228
|
+
if (second !== void 0) return {
|
|
229
|
+
kind: "composed",
|
|
230
|
+
via: first.target,
|
|
231
|
+
first,
|
|
232
|
+
second
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
exports.DIRECT_EDGES = DIRECT_EDGES;
|
|
238
|
+
exports.FORMAT_CAPABILITIES = FORMAT_CAPABILITIES;
|
|
239
|
+
exports.resolveConversionPath = resolveConversionPath;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DocumentBridgeOptions, DocumentToPdfOptions, PdfToDocumentOptions } from "./convert.cjs";
|
|
2
|
+
import { DocumentFormat } from "./port.cjs";
|
|
3
|
+
//#region src/convert/capability.d.ts
|
|
4
|
+
type ContentVariant = 'wordprocessing' | 'presentation' | 'spreadsheet' | 'drawing';
|
|
5
|
+
interface FormatCapability {
|
|
6
|
+
readonly format: DocumentFormat;
|
|
7
|
+
readonly variant?: ContentVariant;
|
|
8
|
+
readonly hasLayoutPath: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const FORMAT_CAPABILITIES: Readonly<Record<DocumentFormat, FormatCapability>>;
|
|
11
|
+
interface ToPdfEdge {
|
|
12
|
+
readonly kind: 'toPdf';
|
|
13
|
+
readonly source: DocumentFormat;
|
|
14
|
+
readonly target: 'pdf';
|
|
15
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: DocumentToPdfOptions) => Uint8Array<ArrayBuffer>;
|
|
16
|
+
}
|
|
17
|
+
interface FromPdfEdge {
|
|
18
|
+
readonly kind: 'fromPdf';
|
|
19
|
+
readonly source: 'pdf';
|
|
20
|
+
readonly target: DocumentFormat;
|
|
21
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: PdfToDocumentOptions) => Uint8Array<ArrayBuffer>;
|
|
22
|
+
}
|
|
23
|
+
interface BridgeEdge {
|
|
24
|
+
readonly kind: 'bridge';
|
|
25
|
+
readonly source: DocumentFormat;
|
|
26
|
+
readonly target: DocumentFormat;
|
|
27
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: DocumentBridgeOptions) => Uint8Array<ArrayBuffer>;
|
|
28
|
+
}
|
|
29
|
+
type ConversionEdge = ToPdfEdge | FromPdfEdge | BridgeEdge;
|
|
30
|
+
declare const DIRECT_EDGES: readonly ConversionEdge[];
|
|
31
|
+
type ConversionStrategy = {
|
|
32
|
+
readonly kind: 'direct';
|
|
33
|
+
readonly edge: ConversionEdge;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'composed';
|
|
36
|
+
readonly via: DocumentFormat;
|
|
37
|
+
readonly first: ConversionEdge;
|
|
38
|
+
readonly second: ConversionEdge;
|
|
39
|
+
};
|
|
40
|
+
declare function resolveConversionPath(source: DocumentFormat, target: DocumentFormat, edges?: readonly ConversionEdge[]): ConversionStrategy | undefined;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { BridgeEdge, ContentVariant, ConversionEdge, ConversionStrategy, DIRECT_EDGES, FORMAT_CAPABILITIES, FormatCapability, FromPdfEdge, ToPdfEdge, resolveConversionPath };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DocumentBridgeOptions, DocumentToPdfOptions, PdfToDocumentOptions } from "./convert.js";
|
|
2
|
+
import { DocumentFormat } from "./port.js";
|
|
3
|
+
//#region src/convert/capability.d.ts
|
|
4
|
+
type ContentVariant = 'wordprocessing' | 'presentation' | 'spreadsheet' | 'drawing';
|
|
5
|
+
interface FormatCapability {
|
|
6
|
+
readonly format: DocumentFormat;
|
|
7
|
+
readonly variant?: ContentVariant;
|
|
8
|
+
readonly hasLayoutPath: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const FORMAT_CAPABILITIES: Readonly<Record<DocumentFormat, FormatCapability>>;
|
|
11
|
+
interface ToPdfEdge {
|
|
12
|
+
readonly kind: 'toPdf';
|
|
13
|
+
readonly source: DocumentFormat;
|
|
14
|
+
readonly target: 'pdf';
|
|
15
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: DocumentToPdfOptions) => Uint8Array<ArrayBuffer>;
|
|
16
|
+
}
|
|
17
|
+
interface FromPdfEdge {
|
|
18
|
+
readonly kind: 'fromPdf';
|
|
19
|
+
readonly source: 'pdf';
|
|
20
|
+
readonly target: DocumentFormat;
|
|
21
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: PdfToDocumentOptions) => Uint8Array<ArrayBuffer>;
|
|
22
|
+
}
|
|
23
|
+
interface BridgeEdge {
|
|
24
|
+
readonly kind: 'bridge';
|
|
25
|
+
readonly source: DocumentFormat;
|
|
26
|
+
readonly target: DocumentFormat;
|
|
27
|
+
readonly convert: (bytes: Uint8Array<ArrayBuffer>, options: DocumentBridgeOptions) => Uint8Array<ArrayBuffer>;
|
|
28
|
+
}
|
|
29
|
+
type ConversionEdge = ToPdfEdge | FromPdfEdge | BridgeEdge;
|
|
30
|
+
declare const DIRECT_EDGES: readonly ConversionEdge[];
|
|
31
|
+
type ConversionStrategy = {
|
|
32
|
+
readonly kind: 'direct';
|
|
33
|
+
readonly edge: ConversionEdge;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'composed';
|
|
36
|
+
readonly via: DocumentFormat;
|
|
37
|
+
readonly first: ConversionEdge;
|
|
38
|
+
readonly second: ConversionEdge;
|
|
39
|
+
};
|
|
40
|
+
declare function resolveConversionPath(source: DocumentFormat, target: DocumentFormat, edges?: readonly ConversionEdge[]): ConversionStrategy | undefined;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { BridgeEdge, ContentVariant, ConversionEdge, ConversionStrategy, DIRECT_EDGES, FORMAT_CAPABILITIES, FormatCapability, FromPdfEdge, ToPdfEdge, resolveConversionPath };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { docxToMarkdown, docxToOdt, docxToPdf, markdownToDocx, markdownToOdt, markdownToPdf, odfToPdf, odgToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToOds, xlsxToPdf } from "./convert.js";
|
|
2
|
+
//#region src/convert/capability.ts
|
|
3
|
+
const FORMAT_CAPABILITIES = {
|
|
4
|
+
docx: {
|
|
5
|
+
format: "docx",
|
|
6
|
+
variant: "wordprocessing",
|
|
7
|
+
hasLayoutPath: true
|
|
8
|
+
},
|
|
9
|
+
odt: {
|
|
10
|
+
format: "odt",
|
|
11
|
+
variant: "wordprocessing",
|
|
12
|
+
hasLayoutPath: true
|
|
13
|
+
},
|
|
14
|
+
pptx: {
|
|
15
|
+
format: "pptx",
|
|
16
|
+
variant: "presentation",
|
|
17
|
+
hasLayoutPath: true
|
|
18
|
+
},
|
|
19
|
+
odp: {
|
|
20
|
+
format: "odp",
|
|
21
|
+
variant: "presentation",
|
|
22
|
+
hasLayoutPath: true
|
|
23
|
+
},
|
|
24
|
+
ods: {
|
|
25
|
+
format: "ods",
|
|
26
|
+
variant: "spreadsheet",
|
|
27
|
+
hasLayoutPath: true
|
|
28
|
+
},
|
|
29
|
+
xlsx: {
|
|
30
|
+
format: "xlsx",
|
|
31
|
+
variant: "spreadsheet",
|
|
32
|
+
hasLayoutPath: false
|
|
33
|
+
},
|
|
34
|
+
odg: {
|
|
35
|
+
format: "odg",
|
|
36
|
+
variant: "drawing",
|
|
37
|
+
hasLayoutPath: true
|
|
38
|
+
},
|
|
39
|
+
odf: {
|
|
40
|
+
format: "odf",
|
|
41
|
+
hasLayoutPath: false
|
|
42
|
+
},
|
|
43
|
+
markdown: {
|
|
44
|
+
format: "markdown",
|
|
45
|
+
variant: "wordprocessing",
|
|
46
|
+
hasLayoutPath: true
|
|
47
|
+
},
|
|
48
|
+
pdf: {
|
|
49
|
+
format: "pdf",
|
|
50
|
+
hasLayoutPath: false
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const DIRECT_EDGES = [
|
|
54
|
+
{
|
|
55
|
+
kind: "toPdf",
|
|
56
|
+
source: "docx",
|
|
57
|
+
target: "pdf",
|
|
58
|
+
convert: docxToPdf
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
kind: "toPdf",
|
|
62
|
+
source: "pptx",
|
|
63
|
+
target: "pdf",
|
|
64
|
+
convert: pptxToPdf
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
kind: "toPdf",
|
|
68
|
+
source: "odt",
|
|
69
|
+
target: "pdf",
|
|
70
|
+
convert: odtToPdf
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
kind: "toPdf",
|
|
74
|
+
source: "odp",
|
|
75
|
+
target: "pdf",
|
|
76
|
+
convert: odpToPdf
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
kind: "toPdf",
|
|
80
|
+
source: "ods",
|
|
81
|
+
target: "pdf",
|
|
82
|
+
convert: odsToPdf
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
kind: "toPdf",
|
|
86
|
+
source: "odg",
|
|
87
|
+
target: "pdf",
|
|
88
|
+
convert: odgToPdf
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
kind: "toPdf",
|
|
92
|
+
source: "odf",
|
|
93
|
+
target: "pdf",
|
|
94
|
+
convert: odfToPdf
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
kind: "toPdf",
|
|
98
|
+
source: "xlsx",
|
|
99
|
+
target: "pdf",
|
|
100
|
+
convert: xlsxToPdf
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
kind: "toPdf",
|
|
104
|
+
source: "markdown",
|
|
105
|
+
target: "pdf",
|
|
106
|
+
convert: markdownToPdf
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
kind: "fromPdf",
|
|
110
|
+
source: "pdf",
|
|
111
|
+
target: "docx",
|
|
112
|
+
convert: pdfToDocx
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
kind: "fromPdf",
|
|
116
|
+
source: "pdf",
|
|
117
|
+
target: "pptx",
|
|
118
|
+
convert: pdfToPptx
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
kind: "fromPdf",
|
|
122
|
+
source: "pdf",
|
|
123
|
+
target: "odt",
|
|
124
|
+
convert: pdfToOdt
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
kind: "fromPdf",
|
|
128
|
+
source: "pdf",
|
|
129
|
+
target: "odp",
|
|
130
|
+
convert: pdfToOdp
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
kind: "fromPdf",
|
|
134
|
+
source: "pdf",
|
|
135
|
+
target: "ods",
|
|
136
|
+
convert: pdfToOds
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
kind: "fromPdf",
|
|
140
|
+
source: "pdf",
|
|
141
|
+
target: "odg",
|
|
142
|
+
convert: pdfToOdg
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
kind: "fromPdf",
|
|
146
|
+
source: "pdf",
|
|
147
|
+
target: "xlsx",
|
|
148
|
+
convert: pdfToXlsx
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
kind: "fromPdf",
|
|
152
|
+
source: "pdf",
|
|
153
|
+
target: "markdown",
|
|
154
|
+
convert: pdfToMarkdown
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
kind: "bridge",
|
|
158
|
+
source: "odt",
|
|
159
|
+
target: "docx",
|
|
160
|
+
convert: odtToDocx
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
kind: "bridge",
|
|
164
|
+
source: "docx",
|
|
165
|
+
target: "odt",
|
|
166
|
+
convert: docxToOdt
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
kind: "bridge",
|
|
170
|
+
source: "odp",
|
|
171
|
+
target: "pptx",
|
|
172
|
+
convert: odpToPptx
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
kind: "bridge",
|
|
176
|
+
source: "pptx",
|
|
177
|
+
target: "odp",
|
|
178
|
+
convert: pptxToOdp
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
kind: "bridge",
|
|
182
|
+
source: "ods",
|
|
183
|
+
target: "xlsx",
|
|
184
|
+
convert: odsToXlsx
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
kind: "bridge",
|
|
188
|
+
source: "xlsx",
|
|
189
|
+
target: "ods",
|
|
190
|
+
convert: xlsxToOds
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
kind: "bridge",
|
|
194
|
+
source: "markdown",
|
|
195
|
+
target: "docx",
|
|
196
|
+
convert: markdownToDocx
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
kind: "bridge",
|
|
200
|
+
source: "docx",
|
|
201
|
+
target: "markdown",
|
|
202
|
+
convert: docxToMarkdown
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
kind: "bridge",
|
|
206
|
+
source: "markdown",
|
|
207
|
+
target: "odt",
|
|
208
|
+
convert: markdownToOdt
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
kind: "bridge",
|
|
212
|
+
source: "odt",
|
|
213
|
+
target: "markdown",
|
|
214
|
+
convert: odtToMarkdown
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
function resolveConversionPath(source, target, edges = DIRECT_EDGES) {
|
|
218
|
+
if (source === target) return;
|
|
219
|
+
const direct = edges.find((edge) => edge.source === source && edge.target === target);
|
|
220
|
+
if (direct !== void 0) return {
|
|
221
|
+
kind: "direct",
|
|
222
|
+
edge: direct
|
|
223
|
+
};
|
|
224
|
+
for (const first of edges) {
|
|
225
|
+
if (first.source !== source) continue;
|
|
226
|
+
const second = edges.find((edge) => edge.source === first.target && edge.target === target);
|
|
227
|
+
if (second !== void 0) return {
|
|
228
|
+
kind: "composed",
|
|
229
|
+
via: first.target,
|
|
230
|
+
first,
|
|
231
|
+
second
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
export { DIRECT_EDGES, FORMAT_CAPABILITIES, resolveConversionPath };
|
package/dist/convert/codec.cjs
CHANGED
|
@@ -27,6 +27,14 @@ const odgPdfCodec = zod.z.codec(require_model_bytes.OdgBytesSchema, require_mode
|
|
|
27
27
|
decode: (odgBytes) => require_convert_convert.odgToPdf(odgBytes),
|
|
28
28
|
encode: (pdfBytes) => require_convert_convert.pdfToOdg(pdfBytes)
|
|
29
29
|
});
|
|
30
|
+
const xlsxPdfCodec = zod.z.codec(require_model_bytes.XlsxBytesSchema, require_model_bytes.PdfBytesSchema, {
|
|
31
|
+
decode: (xlsxBytes) => require_convert_convert.xlsxToPdf(xlsxBytes),
|
|
32
|
+
encode: (pdfBytes) => require_convert_convert.pdfToXlsx(pdfBytes)
|
|
33
|
+
});
|
|
34
|
+
const markdownPdfCodec = zod.z.codec(require_model_bytes.MarkdownBytesSchema, require_model_bytes.PdfBytesSchema, {
|
|
35
|
+
decode: (markdownBytes) => require_convert_convert.markdownToPdf(markdownBytes),
|
|
36
|
+
encode: (pdfBytes) => require_convert_convert.pdfToMarkdown(pdfBytes)
|
|
37
|
+
});
|
|
30
38
|
const odtDocxCodec = zod.z.codec(require_model_bytes.OdtBytesSchema, require_model_bytes.DocxBytesSchema, {
|
|
31
39
|
decode: (odtBytes) => require_convert_convert.odtToDocx(odtBytes),
|
|
32
40
|
encode: (docxBytes) => require_convert_convert.docxToOdt(docxBytes)
|
|
@@ -39,8 +47,19 @@ const odsXlsxCodec = zod.z.codec(require_model_bytes.OdsBytesSchema, require_mod
|
|
|
39
47
|
decode: (odsBytes) => require_convert_convert.odsToXlsx(odsBytes),
|
|
40
48
|
encode: (xlsxBytes) => require_convert_convert.xlsxToOds(xlsxBytes)
|
|
41
49
|
});
|
|
50
|
+
const markdownDocxCodec = zod.z.codec(require_model_bytes.MarkdownBytesSchema, require_model_bytes.DocxBytesSchema, {
|
|
51
|
+
decode: (markdownBytes) => require_convert_convert.markdownToDocx(markdownBytes),
|
|
52
|
+
encode: (docxBytes) => require_convert_convert.docxToMarkdown(docxBytes)
|
|
53
|
+
});
|
|
54
|
+
const markdownOdtCodec = zod.z.codec(require_model_bytes.MarkdownBytesSchema, require_model_bytes.OdtBytesSchema, {
|
|
55
|
+
decode: (markdownBytes) => require_convert_convert.markdownToOdt(markdownBytes),
|
|
56
|
+
encode: (odtBytes) => require_convert_convert.odtToMarkdown(odtBytes)
|
|
57
|
+
});
|
|
42
58
|
//#endregion
|
|
43
59
|
exports.docxPdfCodec = docxPdfCodec;
|
|
60
|
+
exports.markdownDocxCodec = markdownDocxCodec;
|
|
61
|
+
exports.markdownOdtCodec = markdownOdtCodec;
|
|
62
|
+
exports.markdownPdfCodec = markdownPdfCodec;
|
|
44
63
|
exports.odgPdfCodec = odgPdfCodec;
|
|
45
64
|
exports.odpPdfCodec = odpPdfCodec;
|
|
46
65
|
exports.odpPptxCodec = odpPptxCodec;
|
|
@@ -49,3 +68,4 @@ exports.odsXlsxCodec = odsXlsxCodec;
|
|
|
49
68
|
exports.odtDocxCodec = odtDocxCodec;
|
|
50
69
|
exports.odtPdfCodec = odtPdfCodec;
|
|
51
70
|
exports.pptxPdfCodec = pptxPdfCodec;
|
|
71
|
+
exports.xlsxPdfCodec = xlsxPdfCodec;
|
package/dist/convert/codec.d.cts
CHANGED
|
@@ -6,8 +6,12 @@ declare const odtPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8
|
|
|
6
6
|
declare const odpPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
7
7
|
declare const odsPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
8
8
|
declare const odgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
9
|
+
declare const xlsxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
10
|
+
declare const markdownPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
9
11
|
declare const odtDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
10
12
|
declare const odpPptxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
11
13
|
declare const odsXlsxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
14
|
+
declare const markdownDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
15
|
+
declare const markdownOdtCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
12
16
|
//#endregion
|
|
13
|
-
export { docxPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec };
|
|
17
|
+
export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxPdfCodec };
|
package/dist/convert/codec.d.ts
CHANGED
|
@@ -6,8 +6,12 @@ declare const odtPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8
|
|
|
6
6
|
declare const odpPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
7
7
|
declare const odsPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
8
8
|
declare const odgPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
9
|
+
declare const xlsxPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
10
|
+
declare const markdownPdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
9
11
|
declare const odtDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
10
12
|
declare const odpPptxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
11
13
|
declare const odsXlsxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
14
|
+
declare const markdownDocxCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
15
|
+
declare const markdownOdtCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
12
16
|
//#endregion
|
|
13
|
-
export { docxPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec };
|
|
17
|
+
export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxPdfCodec };
|
package/dist/convert/codec.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DocxBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema } from "../model/bytes.js";
|
|
2
|
-
import { docxToOdt, docxToPdf, odgToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToPdf, pdfToDocx, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pptxToOdp, pptxToPdf, xlsxToOds } from "./convert.js";
|
|
1
|
+
import { DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema } from "../model/bytes.js";
|
|
2
|
+
import { docxToMarkdown, docxToOdt, docxToPdf, markdownToDocx, markdownToOdt, markdownToPdf, odgToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToOds, xlsxToPdf } from "./convert.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/convert/codec.ts
|
|
5
5
|
const docxPdfCodec = z.codec(DocxBytesSchema, PdfBytesSchema, {
|
|
@@ -26,6 +26,14 @@ const odgPdfCodec = z.codec(OdgBytesSchema, PdfBytesSchema, {
|
|
|
26
26
|
decode: (odgBytes) => odgToPdf(odgBytes),
|
|
27
27
|
encode: (pdfBytes) => pdfToOdg(pdfBytes)
|
|
28
28
|
});
|
|
29
|
+
const xlsxPdfCodec = z.codec(XlsxBytesSchema, PdfBytesSchema, {
|
|
30
|
+
decode: (xlsxBytes) => xlsxToPdf(xlsxBytes),
|
|
31
|
+
encode: (pdfBytes) => pdfToXlsx(pdfBytes)
|
|
32
|
+
});
|
|
33
|
+
const markdownPdfCodec = z.codec(MarkdownBytesSchema, PdfBytesSchema, {
|
|
34
|
+
decode: (markdownBytes) => markdownToPdf(markdownBytes),
|
|
35
|
+
encode: (pdfBytes) => pdfToMarkdown(pdfBytes)
|
|
36
|
+
});
|
|
29
37
|
const odtDocxCodec = z.codec(OdtBytesSchema, DocxBytesSchema, {
|
|
30
38
|
decode: (odtBytes) => odtToDocx(odtBytes),
|
|
31
39
|
encode: (docxBytes) => docxToOdt(docxBytes)
|
|
@@ -38,5 +46,13 @@ const odsXlsxCodec = z.codec(OdsBytesSchema, XlsxBytesSchema, {
|
|
|
38
46
|
decode: (odsBytes) => odsToXlsx(odsBytes),
|
|
39
47
|
encode: (xlsxBytes) => xlsxToOds(xlsxBytes)
|
|
40
48
|
});
|
|
49
|
+
const markdownDocxCodec = z.codec(MarkdownBytesSchema, DocxBytesSchema, {
|
|
50
|
+
decode: (markdownBytes) => markdownToDocx(markdownBytes),
|
|
51
|
+
encode: (docxBytes) => docxToMarkdown(docxBytes)
|
|
52
|
+
});
|
|
53
|
+
const markdownOdtCodec = z.codec(MarkdownBytesSchema, OdtBytesSchema, {
|
|
54
|
+
decode: (markdownBytes) => markdownToOdt(markdownBytes),
|
|
55
|
+
encode: (odtBytes) => odtToMarkdown(odtBytes)
|
|
56
|
+
});
|
|
41
57
|
//#endregion
|
|
42
|
-
export { docxPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec };
|
|
58
|
+
export { docxPdfCodec, markdownDocxCodec, markdownOdtCodec, markdownPdfCodec, odgPdfCodec, odpPdfCodec, odpPptxCodec, odsPdfCodec, odsXlsxCodec, odtDocxCodec, odtPdfCodec, pptxPdfCodec, xlsxPdfCodec };
|