documents.js 1.97.11 → 1.98.1
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
package/dist/convert/convert.js
CHANGED
|
@@ -1,2 +1,310 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { flipY } from "../model/geometry.js";
|
|
2
|
+
import { resolveMetadataTimestamps } from "../model/metadata.js";
|
|
3
|
+
import { buildDocxPackage } from "../edit/docx/content.js";
|
|
4
|
+
import { buildOdtPackage } from "../edit/odt/content.js";
|
|
5
|
+
import { extractSourceFonts } from "../fonts/registry.js";
|
|
6
|
+
import { layoutFormula } from "../mathml/layout.js";
|
|
7
|
+
import { readOdfFormulaContent } from "../odf/formula/read.js";
|
|
8
|
+
import { readOdtContent } from "../odf/odt/read.js";
|
|
9
|
+
import { convertWordprocessingToLayout } from "../layout/engine.js";
|
|
10
|
+
import { throwIfAborted } from "../ports/abort.js";
|
|
11
|
+
import { buildOdbTableCsv } from "../odb/csv.js";
|
|
12
|
+
import { readOdbTables } from "../odb/read.js";
|
|
13
|
+
import { odbTablesToSpreadsheetDocument } from "../odb/spreadsheet.js";
|
|
14
|
+
import { convertDocument } from "./composition.js";
|
|
15
|
+
import { buildXlsxPackage, encodePackage } from "ooxml.js";
|
|
16
|
+
import { COLOR_BLACK, CONTENT_FORMAT_VERSION, DOCUMENT_PACKAGE_FORMAT_VERSION, LAYOUT_FORMAT_VERSION, PAGE_SIZE_A4 } from "document-schema.js";
|
|
17
|
+
import { decodePackage as decodePackage$1, encodePackage as encodePackage$1, readOdfMetadata, readOdfParagraph, readOdfTable, readOdm } from "odf.js";
|
|
18
|
+
import { createFontMeasurer, createFontRegistry, loadMathFont, writePdf } from "pdf-codec";
|
|
19
|
+
//#region src/convert/convert.ts
|
|
20
|
+
const mathMetricsAt = (sizePt) => loadMathFont().metricsAt(sizePt);
|
|
21
|
+
function docxToPdf(bytes, options) {
|
|
22
|
+
return convertDocument("docx", "pdf", bytes, options);
|
|
23
|
+
}
|
|
24
|
+
function odtToPdf(bytes, options) {
|
|
25
|
+
return convertDocument("odt", "pdf", bytes, options);
|
|
26
|
+
}
|
|
27
|
+
function pptxToPdf(bytes, options) {
|
|
28
|
+
return convertDocument("pptx", "pdf", bytes, options);
|
|
29
|
+
}
|
|
30
|
+
function odpToPdf(bytes, options) {
|
|
31
|
+
return convertDocument("odp", "pdf", bytes, options);
|
|
32
|
+
}
|
|
33
|
+
function odsToPdf(bytes, options) {
|
|
34
|
+
return convertDocument("ods", "pdf", bytes, options);
|
|
35
|
+
}
|
|
36
|
+
function odgToPdf(bytes, options) {
|
|
37
|
+
return convertDocument("odg", "pdf", bytes, options);
|
|
38
|
+
}
|
|
39
|
+
function markdownToPdf(bytes, options) {
|
|
40
|
+
return convertDocument("markdown", "pdf", bytes, options);
|
|
41
|
+
}
|
|
42
|
+
const STANDALONE_FORMULA_SIZE_PT = 18;
|
|
43
|
+
const STANDALONE_FORMULA_MARGIN_PT = 72;
|
|
44
|
+
function odfToPdf(bytes, options) {
|
|
45
|
+
throwIfAborted(options?.signal);
|
|
46
|
+
const pkg = decodePackage$1(bytes);
|
|
47
|
+
const read = readOdfFormulaContent(pkg);
|
|
48
|
+
if (read.kind !== "formula") throw new Error("readOdfFormulaContent returned a non-formula ContentDocument");
|
|
49
|
+
const content = {
|
|
50
|
+
...read,
|
|
51
|
+
metadata: resolveMetadataTimestamps(read.metadata, options?.clock)
|
|
52
|
+
};
|
|
53
|
+
const metrics = loadMathFont().metricsAt(STANDALONE_FORMULA_SIZE_PT);
|
|
54
|
+
const { box } = layoutFormula(content.formula.mathml, {
|
|
55
|
+
metrics,
|
|
56
|
+
sizePt: STANDALONE_FORMULA_SIZE_PT,
|
|
57
|
+
color: COLOR_BLACK
|
|
58
|
+
});
|
|
59
|
+
const flipped = flipY({
|
|
60
|
+
xPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
61
|
+
yPt: STANDALONE_FORMULA_MARGIN_PT,
|
|
62
|
+
widthPt: box.widthPt,
|
|
63
|
+
heightPt: box.heightPt
|
|
64
|
+
}, PAGE_SIZE_A4.heightPt);
|
|
65
|
+
const layout = {
|
|
66
|
+
formatVersion: LAYOUT_FORMAT_VERSION,
|
|
67
|
+
metadata: content.metadata,
|
|
68
|
+
pages: [{
|
|
69
|
+
widthPt: PAGE_SIZE_A4.widthPt,
|
|
70
|
+
heightPt: PAGE_SIZE_A4.heightPt,
|
|
71
|
+
items: []
|
|
72
|
+
}],
|
|
73
|
+
images: {}
|
|
74
|
+
};
|
|
75
|
+
options?.onDocument?.({
|
|
76
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
77
|
+
content,
|
|
78
|
+
layout
|
|
79
|
+
});
|
|
80
|
+
throwIfAborted(options?.signal);
|
|
81
|
+
return writePdf(layout, {
|
|
82
|
+
signal: options?.signal,
|
|
83
|
+
formulas: [{
|
|
84
|
+
pageIndex: 0,
|
|
85
|
+
xPt: flipped.xPt,
|
|
86
|
+
yPt: flipped.yPt,
|
|
87
|
+
box
|
|
88
|
+
}]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function pdfToDocx(bytes, options) {
|
|
92
|
+
return convertDocument("pdf", "docx", bytes, options);
|
|
93
|
+
}
|
|
94
|
+
function pdfToPptx(bytes, options) {
|
|
95
|
+
return convertDocument("pdf", "pptx", bytes, options);
|
|
96
|
+
}
|
|
97
|
+
function pdfToOdt(bytes, options) {
|
|
98
|
+
return convertDocument("pdf", "odt", bytes, options);
|
|
99
|
+
}
|
|
100
|
+
function pdfToOdp(bytes, options) {
|
|
101
|
+
return convertDocument("pdf", "odp", bytes, options);
|
|
102
|
+
}
|
|
103
|
+
function pdfToOdg(bytes, options) {
|
|
104
|
+
return convertDocument("pdf", "odg", bytes, options);
|
|
105
|
+
}
|
|
106
|
+
function pdfToOds(bytes, options) {
|
|
107
|
+
return convertDocument("pdf", "ods", bytes, options);
|
|
108
|
+
}
|
|
109
|
+
function pdfToMarkdown(bytes, options) {
|
|
110
|
+
return convertDocument("pdf", "markdown", bytes, options);
|
|
111
|
+
}
|
|
112
|
+
function odtToDocx(bytes, options) {
|
|
113
|
+
return convertDocument("odt", "docx", bytes, options);
|
|
114
|
+
}
|
|
115
|
+
function docxToOdt(bytes, options) {
|
|
116
|
+
return convertDocument("docx", "odt", bytes, options);
|
|
117
|
+
}
|
|
118
|
+
function odpToPptx(bytes, options) {
|
|
119
|
+
return convertDocument("odp", "pptx", bytes, options);
|
|
120
|
+
}
|
|
121
|
+
function pptxToOdp(bytes, options) {
|
|
122
|
+
return convertDocument("pptx", "odp", bytes, options);
|
|
123
|
+
}
|
|
124
|
+
function odsToXlsx(bytes, options) {
|
|
125
|
+
return convertDocument("ods", "xlsx", bytes, options);
|
|
126
|
+
}
|
|
127
|
+
function xlsxToOds(bytes, options) {
|
|
128
|
+
return convertDocument("xlsx", "ods", bytes, options);
|
|
129
|
+
}
|
|
130
|
+
function markdownToDocx(bytes, options) {
|
|
131
|
+
return convertDocument("markdown", "docx", bytes, options);
|
|
132
|
+
}
|
|
133
|
+
function docxToMarkdown(bytes, options) {
|
|
134
|
+
return convertDocument("docx", "markdown", bytes, options);
|
|
135
|
+
}
|
|
136
|
+
function markdownToOdt(bytes, options) {
|
|
137
|
+
return convertDocument("markdown", "odt", bytes, options);
|
|
138
|
+
}
|
|
139
|
+
function odtToMarkdown(bytes, options) {
|
|
140
|
+
return convertDocument("odt", "markdown", bytes, options);
|
|
141
|
+
}
|
|
142
|
+
function docxToPptx(bytes, options) {
|
|
143
|
+
return convertDocument("docx", "pptx", bytes, options);
|
|
144
|
+
}
|
|
145
|
+
function pptxToDocx(bytes, options) {
|
|
146
|
+
return convertDocument("pptx", "docx", bytes, options);
|
|
147
|
+
}
|
|
148
|
+
function odtToOdp(bytes, options) {
|
|
149
|
+
return convertDocument("odt", "odp", bytes, options);
|
|
150
|
+
}
|
|
151
|
+
function odpToOdt(bytes, options) {
|
|
152
|
+
return convertDocument("odp", "odt", bytes, options);
|
|
153
|
+
}
|
|
154
|
+
function xlsxToPdf(bytes, options) {
|
|
155
|
+
return convertDocument("xlsx", "pdf", bytes, options);
|
|
156
|
+
}
|
|
157
|
+
function pdfToXlsx(bytes, options) {
|
|
158
|
+
return convertDocument("pdf", "xlsx", bytes, options);
|
|
159
|
+
}
|
|
160
|
+
function xlsxToMarkdown(bytes, options) {
|
|
161
|
+
return convertDocument("xlsx", "markdown", bytes, options);
|
|
162
|
+
}
|
|
163
|
+
function markdownToXlsx(bytes, options) {
|
|
164
|
+
return convertDocument("markdown", "xlsx", bytes, options);
|
|
165
|
+
}
|
|
166
|
+
var OdmUnresolvedSectionError = class extends Error {
|
|
167
|
+
hrefs;
|
|
168
|
+
constructor(hrefs) {
|
|
169
|
+
super(`odmToPdf: ${hrefs.length} chapter section(s) could not be resolved -- no inline content and no resolveSubDocument result for: ${hrefs.join(", ")}`);
|
|
170
|
+
this.name = "OdmUnresolvedSectionError";
|
|
171
|
+
this.hrefs = hrefs;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const INLINE_SECTION_MARGIN_PT = 56.69291338582677;
|
|
175
|
+
const INLINE_SECTION_MARGINS = {
|
|
176
|
+
topPt: INLINE_SECTION_MARGIN_PT,
|
|
177
|
+
rightPt: INLINE_SECTION_MARGIN_PT,
|
|
178
|
+
bottomPt: INLINE_SECTION_MARGIN_PT,
|
|
179
|
+
leftPt: INLINE_SECTION_MARGIN_PT
|
|
180
|
+
};
|
|
181
|
+
function inlineOdmSectionToContentSection(section, pkg) {
|
|
182
|
+
const blocks = [];
|
|
183
|
+
for (const node of section.inlineContent ?? []) {
|
|
184
|
+
if (node.type !== "element") continue;
|
|
185
|
+
if (node.tag === "text:p" || node.tag === "text:h") blocks.push(readOdfParagraph(node, pkg));
|
|
186
|
+
else if (node.tag === "table:table") blocks.push(readOdfTable(node, pkg));
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
pageSize: PAGE_SIZE_A4,
|
|
190
|
+
margins: INLINE_SECTION_MARGINS,
|
|
191
|
+
blocks
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function withLeadingChapterBreak(section) {
|
|
195
|
+
const pageBreak = { kind: "pageBreak" };
|
|
196
|
+
return {
|
|
197
|
+
...section,
|
|
198
|
+
blocks: [pageBreak, ...section.blocks]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function odmToPdf(bytes, options) {
|
|
202
|
+
throwIfAborted(options?.signal);
|
|
203
|
+
const pkg = decodePackage$1(bytes);
|
|
204
|
+
const odm = readOdm(pkg);
|
|
205
|
+
const unresolvedHrefs = [];
|
|
206
|
+
const chapterSections = [];
|
|
207
|
+
const sourceFonts = extractSourceFonts({
|
|
208
|
+
kind: "odf",
|
|
209
|
+
package: pkg
|
|
210
|
+
});
|
|
211
|
+
for (const section of odm.sections) {
|
|
212
|
+
throwIfAborted(options?.signal);
|
|
213
|
+
if (section.inlineContent !== void 0) {
|
|
214
|
+
chapterSections.push([inlineOdmSectionToContentSection(section, pkg)]);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const chapterBytes = options?.resolveSubDocument?.(section.href);
|
|
218
|
+
if (chapterBytes === void 0) {
|
|
219
|
+
unresolvedHrefs.push(section.href);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const chapterPkg = decodePackage$1(chapterBytes);
|
|
223
|
+
sourceFonts.push(...extractSourceFonts({
|
|
224
|
+
kind: "odf",
|
|
225
|
+
package: chapterPkg
|
|
226
|
+
}));
|
|
227
|
+
const chapterContent = readOdtContent(chapterPkg);
|
|
228
|
+
if (chapterContent.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
229
|
+
chapterSections.push(chapterContent.sections);
|
|
230
|
+
}
|
|
231
|
+
if (unresolvedHrefs.length > 0) throw new OdmUnresolvedSectionError(unresolvedHrefs);
|
|
232
|
+
const combinedSections = [];
|
|
233
|
+
chapterSections.forEach((sections, chapterIndex) => {
|
|
234
|
+
if (chapterIndex === 0) {
|
|
235
|
+
combinedSections.push(...sections);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
combinedSections.push(...sections.map((section, sectionIndex) => sectionIndex === 0 ? withLeadingChapterBreak(section) : section));
|
|
239
|
+
});
|
|
240
|
+
throwIfAborted(options?.signal);
|
|
241
|
+
const content = {
|
|
242
|
+
kind: "wordprocessing",
|
|
243
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
244
|
+
metadata: resolveMetadataTimestamps(readOdfMetadata(pkg), options?.clock),
|
|
245
|
+
sections: combinedSections
|
|
246
|
+
};
|
|
247
|
+
const fonts = createFontRegistry({
|
|
248
|
+
sourceFonts,
|
|
249
|
+
fonts: options?.fonts,
|
|
250
|
+
onSubstitution: options?.onFontSubstitution
|
|
251
|
+
});
|
|
252
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
253
|
+
measurer: createFontMeasurer(fonts),
|
|
254
|
+
mathMetricsAt
|
|
255
|
+
});
|
|
256
|
+
return writePdf(layout, {
|
|
257
|
+
signal: options?.signal,
|
|
258
|
+
onSubstitution: options?.onSubstitution,
|
|
259
|
+
formulas,
|
|
260
|
+
fonts
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function odbToXlsx(bytes, options) {
|
|
264
|
+
throwIfAborted(options?.signal);
|
|
265
|
+
const pkg = decodePackage$1(bytes);
|
|
266
|
+
const tables = readOdbTables(pkg, { timeZone: options?.timeZone });
|
|
267
|
+
throwIfAborted(options?.signal);
|
|
268
|
+
const content = odbTablesToSpreadsheetDocument(tables);
|
|
269
|
+
return encodePackage(buildXlsxPackage(content));
|
|
270
|
+
}
|
|
271
|
+
function odbToCsv(bytes, options) {
|
|
272
|
+
throwIfAborted(options?.signal);
|
|
273
|
+
const pkg = decodePackage$1(bytes);
|
|
274
|
+
const tables = readOdbTables(pkg, { timeZone: options?.timeZone });
|
|
275
|
+
throwIfAborted(options?.signal);
|
|
276
|
+
return buildOdbTableCsv(tables, options?.table);
|
|
277
|
+
}
|
|
278
|
+
function odbReportToDocx(content, options) {
|
|
279
|
+
throwIfAborted(options?.signal);
|
|
280
|
+
return encodePackage(buildDocxPackage(content, { onMathDiagnostic: options?.onMathDiagnostic }));
|
|
281
|
+
}
|
|
282
|
+
function odbReportToOdt(content, options) {
|
|
283
|
+
throwIfAborted(options?.signal);
|
|
284
|
+
return encodePackage$1(buildOdtPackage(content));
|
|
285
|
+
}
|
|
286
|
+
function odbReportToPdf(content, options) {
|
|
287
|
+
throwIfAborted(options?.signal);
|
|
288
|
+
if (content.kind !== "wordprocessing") throw new Error("odbReportToPdf requires a wordprocessing ContentDocument");
|
|
289
|
+
const fonts = createFontRegistry({
|
|
290
|
+
fonts: options?.fonts,
|
|
291
|
+
onSubstitution: options?.onFontSubstitution
|
|
292
|
+
});
|
|
293
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
294
|
+
measurer: createFontMeasurer(fonts),
|
|
295
|
+
mathMetricsAt
|
|
296
|
+
});
|
|
297
|
+
options?.onDocument?.({
|
|
298
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
299
|
+
content,
|
|
300
|
+
layout
|
|
301
|
+
});
|
|
302
|
+
return writePdf(layout, {
|
|
303
|
+
signal: options?.signal,
|
|
304
|
+
onSubstitution: options?.onSubstitution,
|
|
305
|
+
formulas,
|
|
306
|
+
fonts
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
2
310
|
export { OdmUnresolvedSectionError, docxToMarkdown, docxToOdt, docxToPdf, docxToPptx, inlineOdmSectionToContentSection, markdownToDocx, markdownToOdt, markdownToPdf, markdownToXlsx, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToOdt, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToOdp, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToDocx, pptxToOdp, pptxToPdf, xlsxToMarkdown, xlsxToOds, xlsxToPdf };
|
package/dist/convert/local.cjs
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_convert_capability = require("./capability.cjs");
|
|
3
|
+
const require_convert_port = require("./port.cjs");
|
|
4
|
+
const require_convert_composition = require("./composition.cjs");
|
|
5
|
+
const require_convert_convert = require("./convert.cjs");
|
|
3
6
|
//#region src/convert/local.ts
|
|
4
|
-
const SUPPORTED_CONVERSIONS =
|
|
5
|
-
|
|
6
|
-
target
|
|
7
|
-
|
|
7
|
+
const SUPPORTED_CONVERSIONS = (() => {
|
|
8
|
+
const pairs = [];
|
|
9
|
+
for (const source of require_convert_port.DOCUMENT_FORMATS) for (const target of require_convert_port.DOCUMENT_FORMATS) {
|
|
10
|
+
if (source === target) continue;
|
|
11
|
+
if (require_convert_composition.resolveCompositionPlan(source, target) !== void 0) pairs.push({
|
|
12
|
+
source,
|
|
13
|
+
target
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
pairs.push({
|
|
17
|
+
source: "odf",
|
|
18
|
+
target: "pdf"
|
|
19
|
+
});
|
|
20
|
+
pairs.sort((a, b) => a.source.localeCompare(b.source) || a.target.localeCompare(b.target));
|
|
21
|
+
return pairs;
|
|
22
|
+
})();
|
|
8
23
|
function substitutionDiagnostic(substitution, context) {
|
|
9
24
|
return {
|
|
10
25
|
severity: "info",
|
|
@@ -44,7 +59,7 @@ function createLocalDocumentConverter() {
|
|
|
44
59
|
options.onFontSubstitution?.(substitution);
|
|
45
60
|
};
|
|
46
61
|
if (source.format === "odf" && targetFormat === "pdf") {
|
|
47
|
-
const bytes =
|
|
62
|
+
const bytes = require_convert_convert.odfToPdf(source.bytes, {
|
|
48
63
|
signal: options.signal,
|
|
49
64
|
fonts: options.fonts,
|
|
50
65
|
onFontSubstitution
|
|
@@ -58,8 +73,8 @@ function createLocalDocumentConverter() {
|
|
|
58
73
|
package: documentPackage
|
|
59
74
|
});
|
|
60
75
|
}
|
|
61
|
-
if (
|
|
62
|
-
const bytes =
|
|
76
|
+
if (require_convert_composition.resolveCompositionPlan(source.format, targetFormat) === void 0) return Promise.reject(new require_convert_capability.UnsupportedConversionError(source.format, targetFormat));
|
|
77
|
+
const bytes = require_convert_composition.convertDocument(source.format, targetFormat, source.bytes, {
|
|
63
78
|
signal: options.signal,
|
|
64
79
|
fonts: options.fonts,
|
|
65
80
|
onFontSubstitution,
|
package/dist/convert/local.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnsupportedConversionError } from "./capability.js";
|
|
2
|
+
import { DOCUMENT_FORMATS } from "./port.js";
|
|
3
|
+
import { convertDocument, resolveCompositionPlan } from "./composition.js";
|
|
4
|
+
import { odfToPdf } from "./convert.js";
|
|
2
5
|
//#region src/convert/local.ts
|
|
3
|
-
const SUPPORTED_CONVERSIONS =
|
|
4
|
-
|
|
5
|
-
target
|
|
6
|
-
|
|
6
|
+
const SUPPORTED_CONVERSIONS = (() => {
|
|
7
|
+
const pairs = [];
|
|
8
|
+
for (const source of DOCUMENT_FORMATS) for (const target of DOCUMENT_FORMATS) {
|
|
9
|
+
if (source === target) continue;
|
|
10
|
+
if (resolveCompositionPlan(source, target) !== void 0) pairs.push({
|
|
11
|
+
source,
|
|
12
|
+
target
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
pairs.push({
|
|
16
|
+
source: "odf",
|
|
17
|
+
target: "pdf"
|
|
18
|
+
});
|
|
19
|
+
pairs.sort((a, b) => a.source.localeCompare(b.source) || a.target.localeCompare(b.target));
|
|
20
|
+
return pairs;
|
|
21
|
+
})();
|
|
7
22
|
function substitutionDiagnostic(substitution, context) {
|
|
8
23
|
return {
|
|
9
24
|
severity: "info",
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FontSubstitution, ProvidedFont } from "document-schema.js";
|
|
2
|
+
import { Package } from "ooxml.js";
|
|
3
|
+
import { FontRegistry } from "pdf-codec";
|
|
4
|
+
import { Package as Package$1 } from "odf.js";
|
|
5
|
+
//#region src/fonts/registry.d.ts
|
|
6
|
+
type FontSourcePackage = {
|
|
7
|
+
readonly kind: 'docx' | 'pptx';
|
|
8
|
+
readonly package: Package;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'odf';
|
|
11
|
+
readonly package: Package$1;
|
|
12
|
+
};
|
|
13
|
+
interface DocumentFontRegistryOptions {
|
|
14
|
+
readonly fonts?: readonly ProvidedFont[];
|
|
15
|
+
readonly onFontSubstitution?: (substitution: FontSubstitution) => void;
|
|
16
|
+
}
|
|
17
|
+
declare function extractSourceFonts(source: FontSourcePackage): ProvidedFont[];
|
|
18
|
+
declare function createDocumentFontRegistry(source: FontSourcePackage, options?: DocumentFontRegistryOptions): FontRegistry;
|
|
19
|
+
//#endregion
|
|
2
20
|
export { DocumentFontRegistryOptions, FontSourcePackage, createDocumentFontRegistry, extractSourceFonts };
|
package/dist/fonts/registry.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Package } from "ooxml.js";
|
|
2
|
+
import { FontSubstitution, ProvidedFont } from "document-schema.js";
|
|
3
|
+
import { Package as Package$1 } from "odf.js";
|
|
4
|
+
import { FontRegistry } from "pdf-codec";
|
|
5
|
+
//#region src/fonts/registry.d.ts
|
|
6
|
+
type FontSourcePackage = {
|
|
7
|
+
readonly kind: 'docx' | 'pptx';
|
|
8
|
+
readonly package: Package;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'odf';
|
|
11
|
+
readonly package: Package$1;
|
|
12
|
+
};
|
|
13
|
+
interface DocumentFontRegistryOptions {
|
|
14
|
+
readonly fonts?: readonly ProvidedFont[];
|
|
15
|
+
readonly onFontSubstitution?: (substitution: FontSubstitution) => void;
|
|
16
|
+
}
|
|
17
|
+
declare function extractSourceFonts(source: FontSourcePackage): ProvidedFont[];
|
|
18
|
+
declare function createDocumentFontRegistry(source: FontSourcePackage, options?: DocumentFontRegistryOptions): FontRegistry;
|
|
19
|
+
//#endregion
|
|
2
20
|
export { DocumentFontRegistryOptions, FontSourcePackage, createDocumentFontRegistry, extractSourceFonts };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HsqldbDecodeOptions } from "./rowformat.cjs";
|
|
2
2
|
import { r as HsqldbTable } from "../script-DsGGIzGU.cjs";
|
|
3
3
|
//#region src/hsqldb/binary-script.d.ts
|
|
4
4
|
declare class HsqldbBinaryScriptParseError extends Error {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HsqldbDecodeOptions } from "./rowformat.js";
|
|
2
2
|
import { r as HsqldbTable } from "../script-DsGGIzGU.js";
|
|
3
3
|
//#region src/hsqldb/binary-script.d.ts
|
|
4
4
|
declare class HsqldbBinaryScriptParseError extends Error {
|
package/dist/hsqldb/cache.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HsqldbDecodeOptions } from "./rowformat.cjs";
|
|
2
2
|
import { r as HsqldbTable, t as HsqldbColumn } from "../script-DsGGIzGU.cjs";
|
|
3
3
|
import { ContentCellValue } from "document-schema.js";
|
|
4
4
|
//#region src/hsqldb/cache.d.ts
|
package/dist/hsqldb/cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HsqldbDecodeOptions } from "./rowformat.js";
|
|
2
2
|
import { r as HsqldbTable, t as HsqldbColumn } from "../script-DsGGIzGU.js";
|
|
3
3
|
import { ContentCellValue } from "document-schema.js";
|
|
4
4
|
//#region src/hsqldb/cache.d.ts
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentCellValue } from "document-schema.js";
|
|
2
|
+
//#region src/hsqldb/rowformat.d.ts
|
|
3
|
+
declare class HsqldbRowFormatError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
declare function resolveHsqldbTypeCode(declaredType: string): number;
|
|
7
|
+
declare class HsqldbDataCursor {
|
|
8
|
+
private readonly bytes;
|
|
9
|
+
private readonly view;
|
|
10
|
+
position: number;
|
|
11
|
+
constructor(bytes: Uint8Array<ArrayBuffer>, offset?: number);
|
|
12
|
+
readUint8(): number;
|
|
13
|
+
readInt16(): number;
|
|
14
|
+
readInt32(): number;
|
|
15
|
+
readBigInt64(): bigint;
|
|
16
|
+
readFloat64(): number;
|
|
17
|
+
readBytes(length: number): Uint8Array<ArrayBuffer>;
|
|
18
|
+
}
|
|
19
|
+
declare function readModifiedUtf8(bytes: Uint8Array<ArrayBuffer>): string;
|
|
20
|
+
interface HsqldbDecodeOptions {
|
|
21
|
+
readonly timeZone?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function readHsqldbColumnValue(cursor: HsqldbDataCursor, typeCode: number, options?: HsqldbDecodeOptions): ContentCellValue;
|
|
24
|
+
//#endregion
|
|
2
25
|
export { HsqldbDataCursor, HsqldbDecodeOptions, HsqldbRowFormatError, readHsqldbColumnValue, readModifiedUtf8, resolveHsqldbTypeCode };
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentCellValue } from "document-schema.js";
|
|
2
|
+
//#region src/hsqldb/rowformat.d.ts
|
|
3
|
+
declare class HsqldbRowFormatError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
declare function resolveHsqldbTypeCode(declaredType: string): number;
|
|
7
|
+
declare class HsqldbDataCursor {
|
|
8
|
+
private readonly bytes;
|
|
9
|
+
private readonly view;
|
|
10
|
+
position: number;
|
|
11
|
+
constructor(bytes: Uint8Array<ArrayBuffer>, offset?: number);
|
|
12
|
+
readUint8(): number;
|
|
13
|
+
readInt16(): number;
|
|
14
|
+
readInt32(): number;
|
|
15
|
+
readBigInt64(): bigint;
|
|
16
|
+
readFloat64(): number;
|
|
17
|
+
readBytes(length: number): Uint8Array<ArrayBuffer>;
|
|
18
|
+
}
|
|
19
|
+
declare function readModifiedUtf8(bytes: Uint8Array<ArrayBuffer>): string;
|
|
20
|
+
interface HsqldbDecodeOptions {
|
|
21
|
+
readonly timeZone?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function readHsqldbColumnValue(cursor: HsqldbDataCursor, typeCode: number, options?: HsqldbDecodeOptions): ContentCellValue;
|
|
24
|
+
//#endregion
|
|
2
25
|
export { HsqldbDataCursor, HsqldbDecodeOptions, HsqldbRowFormatError, readHsqldbColumnValue, readModifiedUtf8, resolveHsqldbTypeCode };
|