js.documents 4.0.20 → 4.4.5
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 +43 -29
- package/dist/cell-typing-CEWlywIc.d.cts +22 -0
- package/dist/cell-typing-CEWlywIc.d.ts +22 -0
- package/dist/codecs/read.cjs +66 -0
- package/dist/codecs/read.d.cts +15 -0
- package/dist/codecs/read.d.ts +15 -0
- package/dist/codecs/read.js +64 -0
- package/dist/codecs/registry.cjs +13 -59
- package/dist/codecs/registry.d.cts +2 -8
- package/dist/codecs/registry.d.ts +2 -8
- package/dist/codecs/registry.js +20 -64
- package/dist/convert/codec.cjs +11 -10
- package/dist/convert/codec.js +2 -1
- package/dist/convert/composition-to-pdf.cjs +133 -0
- package/dist/convert/composition-to-pdf.d.cts +7 -0
- package/dist/convert/composition-to-pdf.d.ts +7 -0
- package/dist/convert/composition-to-pdf.js +131 -0
- package/dist/convert/composition.cjs +31 -129
- package/dist/convert/composition.d.cts +14 -4
- package/dist/convert/composition.d.ts +14 -4
- package/dist/convert/composition.js +25 -128
- package/dist/convert/convert.cjs +35 -75
- package/dist/convert/convert.d.cts +5 -20
- package/dist/convert/convert.d.ts +5 -20
- package/dist/convert/convert.js +2 -32
- package/dist/convert/from-package.cjs +2 -1
- package/dist/convert/from-package.js +2 -1
- package/dist/convert/from-pdf.cjs +50 -0
- package/dist/convert/from-pdf.d.cts +26 -0
- package/dist/convert/from-pdf.d.ts +26 -0
- package/dist/convert/from-pdf.js +39 -0
- package/dist/convert/local.cjs +2 -1
- package/dist/convert/local.js +2 -1
- package/dist/convert/pdf-package-tables.cjs +76 -0
- package/dist/convert/pdf-package-tables.d.cts +6 -0
- package/dist/convert/pdf-package-tables.d.ts +6 -0
- package/dist/convert/pdf-package-tables.js +75 -0
- package/dist/csv/read.d.cts +1 -1
- package/dist/csv/read.d.ts +1 -1
- package/dist/diagnostics-DVAXKgcf.d.cts +10 -0
- package/dist/diagnostics-DVAXKgcf.d.ts +10 -0
- package/dist/edit/docx/content.cjs +1 -0
- package/dist/edit/docx/content.js +1 -0
- package/dist/edit/docx/paragraph.cjs +18 -1
- package/dist/edit/docx/paragraph.d.cts +3 -0
- package/dist/edit/docx/paragraph.d.ts +3 -0
- package/dist/edit/docx/paragraph.js +18 -1
- package/dist/edit/docx/props.cjs +1 -0
- package/dist/edit/docx/props.js +1 -0
- package/dist/edit/markdown/editor.cjs +1 -1
- package/dist/edit/markdown/editor.js +1 -1
- package/dist/edit/pdf/item.cjs +42 -1
- package/dist/edit/pdf/item.d.cts +2 -2
- package/dist/edit/pdf/item.d.ts +2 -2
- package/dist/edit/pdf/item.js +42 -2
- package/dist/edit/pdf/page.d.cts +1 -1
- package/dist/edit/pdf/page.d.ts +1 -1
- package/dist/fonts/registry.d.cts +1 -19
- package/dist/fonts/registry.d.ts +1 -19
- 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 +1 -24
- package/dist/hsqldb/rowformat.d.ts +1 -24
- package/dist/index.cjs +17 -16
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +8 -7
- package/dist/{item-D9vQKT0T.d.cts → item-DhXpJNAQ.d.cts} +17 -3
- package/dist/{item-D9vQKT0T.d.ts → item-DhXpJNAQ.d.ts} +17 -3
- package/dist/layout/cell-typing.d.cts +1 -21
- package/dist/layout/cell-typing.d.ts +1 -21
- package/dist/layout/reconstruct.cjs +177 -14
- package/dist/layout/reconstruct.d.cts +1 -1
- package/dist/layout/reconstruct.d.ts +1 -1
- package/dist/layout/reconstruct.js +175 -12
- package/dist/layout/shared.cjs +2 -2
- package/dist/layout/shared.js +1 -1
- package/dist/markdown/math.cjs +5 -7
- package/dist/markdown/math.js +5 -7
- package/dist/markdown/read.cjs +15 -1
- package/dist/markdown/read.js +16 -2
- package/dist/markdown/write.cjs +7 -10
- package/dist/markdown/write.d.cts +3 -6
- package/dist/markdown/write.d.ts +3 -6
- package/dist/markdown/write.js +8 -11
- package/dist/metadata/write.cjs +2 -1
- package/dist/metadata/write.js +2 -1
- package/dist/model/bytes.cjs +8 -0
- package/dist/model/bytes.d.cts +2 -1
- package/dist/model/bytes.d.ts +2 -1
- package/dist/model/bytes.js +8 -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/dist/odf/odt/read.cjs +1 -1
- package/dist/odf/odt/read.js +1 -1
- package/dist/registry-BcBT-bnX.d.cts +20 -0
- package/dist/registry-D1Pu5XxB.d.ts +20 -0
- package/dist/rowformat-Cl2exlEh.d.cts +25 -0
- package/dist/rowformat-Cl2exlEh.d.ts +25 -0
- package/dist/svg/diagnostics.d.cts +1 -9
- package/dist/svg/diagnostics.d.ts +1 -9
- package/dist/svg/read.d.cts +1 -1
- package/dist/svg/read.d.ts +1 -1
- package/dist/svg/write.d.cts +1 -1
- package/dist/svg/write.d.ts +1 -1
- package/package.json +27 -10
- package/dist/metadata/read.cjs +0 -15
- package/dist/metadata/read.d.cts +0 -9
- package/dist/metadata/read.d.ts +0 -9
- package/dist/metadata/read.js +0 -14
package/dist/markdown/math.js
CHANGED
|
@@ -2,7 +2,6 @@ import { buildFormulaBlock } from "../model/formula.js";
|
|
|
2
2
|
import { extractSymbolDefinitionsFromProse } from "../latex/symbols.js";
|
|
3
3
|
import { latexToFormula } from "../latex/lower.js";
|
|
4
4
|
//#region src/markdown/math.ts
|
|
5
|
-
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
6
5
|
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
7
6
|
const STAND_IN_FRAME = {
|
|
8
7
|
xPt: 0,
|
|
@@ -61,14 +60,13 @@ function lowerMarkdownMath(document, options) {
|
|
|
61
60
|
});
|
|
62
61
|
continue;
|
|
63
62
|
}
|
|
64
|
-
if (block.kind
|
|
65
|
-
|
|
63
|
+
if (block.kind === "embeddedObject" && block.objectKind === "formula" && block.document.kind === "formula" && block.document.formula.presentation !== void 0) {
|
|
64
|
+
const formulaBlock = lowerOne(block.document.formula.presentation.latex, MATH_BLOCK_SOURCE);
|
|
65
|
+
out.push(formulaBlock ?? block);
|
|
66
66
|
continue;
|
|
67
67
|
}
|
|
68
|
-
if (block.
|
|
69
|
-
|
|
70
|
-
const formulaBlock = lowerOne(latex, MATH_BLOCK_SOURCE);
|
|
71
|
-
out.push(formulaBlock ?? block);
|
|
68
|
+
if (block.kind !== "paragraph") {
|
|
69
|
+
out.push(block);
|
|
72
70
|
continue;
|
|
73
71
|
}
|
|
74
72
|
const extraction = extractInlineMath(block.runs);
|
package/dist/markdown/read.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_markdown_math = require("./math.cjs");
|
|
3
|
+
require("./write.cjs");
|
|
3
4
|
let markdown_codec = require("markdown-codec");
|
|
4
5
|
//#region src/markdown/read.ts
|
|
5
6
|
function readMarkdownContent(text, options, math) {
|
|
@@ -8,7 +9,20 @@ function readMarkdownContent(text, options, math) {
|
|
|
8
9
|
...options
|
|
9
10
|
});
|
|
10
11
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
11
|
-
return require_markdown_math.lowerMarkdownMath(document, math);
|
|
12
|
+
return require_markdown_math.lowerMarkdownMath(promotePageBreakMarkers(document), math);
|
|
13
|
+
}
|
|
14
|
+
function promotePageBreakMarkers(document) {
|
|
15
|
+
return {
|
|
16
|
+
...document,
|
|
17
|
+
sections: document.sections.map((section) => ({
|
|
18
|
+
...section,
|
|
19
|
+
blocks: section.blocks.map(promoteBlock)
|
|
20
|
+
}))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function promoteBlock(block) {
|
|
24
|
+
if (block.kind !== "paragraph" || block.styleId !== markdown_codec.HTML_PREFORMATTED_STYLE_ID) return block;
|
|
25
|
+
return block.runs.map((run) => run.text).join("") === "<!-- page break -->" ? { kind: "pageBreak" } : block;
|
|
12
26
|
}
|
|
13
27
|
//#endregion
|
|
14
28
|
exports.readMarkdownContent = readMarkdownContent;
|
package/dist/markdown/read.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { lowerMarkdownMath } from "./math.js";
|
|
2
|
-
import
|
|
2
|
+
import "./write.js";
|
|
3
|
+
import { HTML_PREFORMATTED_STYLE_ID, readMarkdownContent as readMarkdownContent$1 } from "markdown-codec";
|
|
3
4
|
//#region src/markdown/read.ts
|
|
4
5
|
function readMarkdownContent(text, options, math) {
|
|
5
6
|
const { document } = readMarkdownContent$1(text, {
|
|
@@ -7,7 +8,20 @@ function readMarkdownContent(text, options, math) {
|
|
|
7
8
|
...options
|
|
8
9
|
});
|
|
9
10
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
10
|
-
return lowerMarkdownMath(document, math);
|
|
11
|
+
return lowerMarkdownMath(promotePageBreakMarkers(document), math);
|
|
12
|
+
}
|
|
13
|
+
function promotePageBreakMarkers(document) {
|
|
14
|
+
return {
|
|
15
|
+
...document,
|
|
16
|
+
sections: document.sections.map((section) => ({
|
|
17
|
+
...section,
|
|
18
|
+
blocks: section.blocks.map(promoteBlock)
|
|
19
|
+
}))
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function promoteBlock(block) {
|
|
23
|
+
if (block.kind !== "paragraph" || block.styleId !== HTML_PREFORMATTED_STYLE_ID) return block;
|
|
24
|
+
return block.runs.map((run) => run.text).join("") === "<!-- page break -->" ? { kind: "pageBreak" } : block;
|
|
11
25
|
}
|
|
12
26
|
//#endregion
|
|
13
27
|
export { readMarkdownContent };
|
package/dist/markdown/write.cjs
CHANGED
|
@@ -2,17 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_model_formula = require("../model/formula.cjs");
|
|
3
3
|
let markdown_codec = require("markdown-codec");
|
|
4
4
|
//#region src/markdown/write.ts
|
|
5
|
-
var MarkdownConstructUnsupportedError = class extends Error {
|
|
6
|
-
descriptorKind;
|
|
7
|
-
constructor(block) {
|
|
8
|
-
super(block.kind === "constructStart" ? `buildMarkdownText: a construct marker (descriptor kind '${block.descriptor.kind}') has no CommonMark/GFM representation -- markdown-codec's own writer has no arm for the constructStart/constructEnd block kinds` : `buildMarkdownText: a construct marker has no CommonMark/GFM representation -- markdown-codec's own writer has no arm for the constructStart/constructEnd block kinds`);
|
|
9
|
-
this.name = "MarkdownConstructUnsupportedError";
|
|
10
|
-
this.descriptorKind = block.kind === "constructStart" ? block.descriptor.kind : void 0;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
5
|
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
14
6
|
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
15
7
|
const MATH_INLINE_SOURCE = "markdown:math-inline";
|
|
8
|
+
const PAGE_BREAK_MARKER = "<!-- page break -->";
|
|
16
9
|
function formulaParagraph(formula) {
|
|
17
10
|
const latex = formula.presentation?.latex;
|
|
18
11
|
if (latex === void 0) return {
|
|
@@ -33,7 +26,11 @@ function formulaParagraph(formula) {
|
|
|
33
26
|
};
|
|
34
27
|
}
|
|
35
28
|
function markdownBlock(block) {
|
|
36
|
-
if (block.kind === "
|
|
29
|
+
if (block.kind === "pageBreak") return {
|
|
30
|
+
kind: "paragraph",
|
|
31
|
+
runs: [{ text: PAGE_BREAK_MARKER }],
|
|
32
|
+
styleId: markdown_codec.HTML_PREFORMATTED_STYLE_ID
|
|
33
|
+
};
|
|
37
34
|
if (block.kind === "table") return {
|
|
38
35
|
...block,
|
|
39
36
|
rows: block.rows.map((row) => ({
|
|
@@ -66,5 +63,5 @@ function buildMarkdownText(document, options) {
|
|
|
66
63
|
}, options);
|
|
67
64
|
}
|
|
68
65
|
//#endregion
|
|
69
|
-
exports.
|
|
66
|
+
exports.PAGE_BREAK_MARKER = PAGE_BREAK_MARKER;
|
|
70
67
|
exports.buildMarkdownText = buildMarkdownText;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentDocument } from "document-schema.js";
|
|
2
2
|
import { WriteMarkdownOptions } from "markdown-codec";
|
|
3
3
|
//#region src/markdown/write.d.ts
|
|
4
|
-
declare
|
|
5
|
-
readonly descriptorKind: ContentConstructStart['descriptor']['kind'] | undefined;
|
|
6
|
-
constructor(block: ContentConstructStart | ContentConstructEnd);
|
|
7
|
-
}
|
|
4
|
+
declare const PAGE_BREAK_MARKER = "<!-- page break -->";
|
|
8
5
|
declare function buildMarkdownText(document: ContentDocument, options?: WriteMarkdownOptions): string;
|
|
9
6
|
//#endregion
|
|
10
|
-
export {
|
|
7
|
+
export { PAGE_BREAK_MARKER, buildMarkdownText };
|
package/dist/markdown/write.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentDocument } from "document-schema.js";
|
|
2
2
|
import { WriteMarkdownOptions } from "markdown-codec";
|
|
3
3
|
//#region src/markdown/write.d.ts
|
|
4
|
-
declare
|
|
5
|
-
readonly descriptorKind: ContentConstructStart['descriptor']['kind'] | undefined;
|
|
6
|
-
constructor(block: ContentConstructStart | ContentConstructEnd);
|
|
7
|
-
}
|
|
4
|
+
declare const PAGE_BREAK_MARKER = "<!-- page break -->";
|
|
8
5
|
declare function buildMarkdownText(document: ContentDocument, options?: WriteMarkdownOptions): string;
|
|
9
6
|
//#endregion
|
|
10
|
-
export {
|
|
7
|
+
export { PAGE_BREAK_MARKER, buildMarkdownText };
|
package/dist/markdown/write.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
|
|
2
|
-
import { MarkdownUnsupportedDocumentKindError, writeMarkdownContent } from "markdown-codec";
|
|
2
|
+
import { HTML_PREFORMATTED_STYLE_ID, MarkdownUnsupportedDocumentKindError, writeMarkdownContent } from "markdown-codec";
|
|
3
3
|
//#region src/markdown/write.ts
|
|
4
|
-
var MarkdownConstructUnsupportedError = class extends Error {
|
|
5
|
-
descriptorKind;
|
|
6
|
-
constructor(block) {
|
|
7
|
-
super(block.kind === "constructStart" ? `buildMarkdownText: a construct marker (descriptor kind '${block.descriptor.kind}') has no CommonMark/GFM representation -- markdown-codec's own writer has no arm for the constructStart/constructEnd block kinds` : `buildMarkdownText: a construct marker has no CommonMark/GFM representation -- markdown-codec's own writer has no arm for the constructStart/constructEnd block kinds`);
|
|
8
|
-
this.name = "MarkdownConstructUnsupportedError";
|
|
9
|
-
this.descriptorKind = block.kind === "constructStart" ? block.descriptor.kind : void 0;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
4
|
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
13
5
|
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
14
6
|
const MATH_INLINE_SOURCE = "markdown:math-inline";
|
|
7
|
+
const PAGE_BREAK_MARKER = "<!-- page break -->";
|
|
15
8
|
function formulaParagraph(formula) {
|
|
16
9
|
const latex = formula.presentation?.latex;
|
|
17
10
|
if (latex === void 0) return {
|
|
@@ -32,7 +25,11 @@ function formulaParagraph(formula) {
|
|
|
32
25
|
};
|
|
33
26
|
}
|
|
34
27
|
function markdownBlock(block) {
|
|
35
|
-
if (block.kind === "
|
|
28
|
+
if (block.kind === "pageBreak") return {
|
|
29
|
+
kind: "paragraph",
|
|
30
|
+
runs: [{ text: PAGE_BREAK_MARKER }],
|
|
31
|
+
styleId: HTML_PREFORMATTED_STYLE_ID
|
|
32
|
+
};
|
|
36
33
|
if (block.kind === "table") return {
|
|
37
34
|
...block,
|
|
38
35
|
rows: block.rows.map((row) => ({
|
|
@@ -65,4 +62,4 @@ function buildMarkdownText(document, options) {
|
|
|
65
62
|
}, options);
|
|
66
63
|
}
|
|
67
64
|
//#endregion
|
|
68
|
-
export {
|
|
65
|
+
export { PAGE_BREAK_MARKER, buildMarkdownText };
|
package/dist/metadata/write.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_bytes = require("../model/bytes.cjs");
|
|
2
3
|
const require_ports_abort = require("../ports/abort.cjs");
|
|
3
4
|
const require_codecs_registry = require("../codecs/registry.cjs");
|
|
4
5
|
let pdf_codec = require("pdf-codec");
|
|
@@ -24,7 +25,7 @@ function readContentForFormat(format, bytes, options) {
|
|
|
24
25
|
function buildBytesForRebuildFormat(format, content) {
|
|
25
26
|
const codec = require_codecs_registry.DOCUMENT_FORMAT_CODECS[format].content;
|
|
26
27
|
if (!codec?.write) throw new Error(`RebuildFormat '${format}' has no content.write codec in DOCUMENT_FORMAT_CODECS -- this is an internal invariant violation, not a caller error`);
|
|
27
|
-
return
|
|
28
|
+
return require_model_bytes.requireArrayBufferBytes(codec.write(content));
|
|
28
29
|
}
|
|
29
30
|
function mergeMetadata(current, overrides) {
|
|
30
31
|
return {
|
package/dist/metadata/write.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { requireArrayBufferBytes } from "../model/bytes.js";
|
|
1
2
|
import { throwIfAborted } from "../ports/abort.js";
|
|
2
|
-
import { DOCUMENT_FORMAT_CODECS
|
|
3
|
+
import { DOCUMENT_FORMAT_CODECS } from "../codecs/registry.js";
|
|
3
4
|
import { readPdf, writePdf } from "pdf-codec";
|
|
4
5
|
//#region src/metadata/write.ts
|
|
5
6
|
const REBUILD_FORMATS = {
|
package/dist/model/bytes.cjs
CHANGED
|
@@ -94,6 +94,13 @@ const SvgBytesSchema = zod.z.instanceof(Uint8Array).refine((bytes) => {
|
|
|
94
94
|
if (!isWellFormedUtf8Text(bytes)) return false;
|
|
95
95
|
return new TextDecoder().decode(bytes).toLowerCase().includes("<svg");
|
|
96
96
|
}, { message: "not a valid SVG file: not well-formed UTF-8 text containing an <svg root element" });
|
|
97
|
+
function isArrayBufferBacked(bytes) {
|
|
98
|
+
return bytes.buffer instanceof ArrayBuffer;
|
|
99
|
+
}
|
|
100
|
+
function requireArrayBufferBytes(bytes) {
|
|
101
|
+
if (!isArrayBufferBacked(bytes)) throw new TypeError("expected an ArrayBuffer-backed Uint8Array, received one backed by a SharedArrayBuffer");
|
|
102
|
+
return bytes;
|
|
103
|
+
}
|
|
97
104
|
//#endregion
|
|
98
105
|
exports.CsvBytesSchema = CsvBytesSchema;
|
|
99
106
|
exports.DocxBytesSchema = DocxBytesSchema;
|
|
@@ -106,3 +113,4 @@ exports.PdfBytesSchema = PdfBytesSchema;
|
|
|
106
113
|
exports.PptxBytesSchema = PptxBytesSchema;
|
|
107
114
|
exports.SvgBytesSchema = SvgBytesSchema;
|
|
108
115
|
exports.XlsxBytesSchema = XlsxBytesSchema;
|
|
116
|
+
exports.requireArrayBufferBytes = requireArrayBufferBytes;
|
package/dist/model/bytes.d.cts
CHANGED
|
@@ -11,5 +11,6 @@ declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
|
|
|
11
11
|
declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
12
12
|
declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
13
|
declare const SvgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
14
|
+
declare function requireArrayBufferBytes(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
14
15
|
//#endregion
|
|
15
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
|
16
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema, requireArrayBufferBytes };
|
package/dist/model/bytes.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
|
|
|
11
11
|
declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
12
12
|
declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
13
|
declare const SvgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
14
|
+
declare function requireArrayBufferBytes(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
14
15
|
//#endregion
|
|
15
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
|
16
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema, requireArrayBufferBytes };
|
package/dist/model/bytes.js
CHANGED
|
@@ -93,5 +93,12 @@ const SvgBytesSchema = z.instanceof(Uint8Array).refine((bytes) => {
|
|
|
93
93
|
if (!isWellFormedUtf8Text(bytes)) return false;
|
|
94
94
|
return new TextDecoder().decode(bytes).toLowerCase().includes("<svg");
|
|
95
95
|
}, { message: "not a valid SVG file: not well-formed UTF-8 text containing an <svg root element" });
|
|
96
|
+
function isArrayBufferBacked(bytes) {
|
|
97
|
+
return bytes.buffer instanceof ArrayBuffer;
|
|
98
|
+
}
|
|
99
|
+
function requireArrayBufferBytes(bytes) {
|
|
100
|
+
if (!isArrayBufferBacked(bytes)) throw new TypeError("expected an ArrayBuffer-backed Uint8Array, received one backed by a SharedArrayBuffer");
|
|
101
|
+
return bytes;
|
|
102
|
+
}
|
|
96
103
|
//#endregion
|
|
97
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
|
104
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema, requireArrayBufferBytes };
|
package/dist/odb/read.d.cts
CHANGED
package/dist/odb/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HsqldbDecodeOptions } from "../../
|
|
1
|
+
import { n as HsqldbDecodeOptions } from "../../rowformat-Cl2exlEh.cjs";
|
|
2
2
|
import { ContentDocument } from "document-schema.js";
|
|
3
3
|
import { Package } from "odf.js";
|
|
4
4
|
//#region src/odb/report/content.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HsqldbDecodeOptions } from "../../
|
|
1
|
+
import { n as HsqldbDecodeOptions } from "../../rowformat-Cl2exlEh.cjs";
|
|
2
2
|
import { t as SqlResultSet } from "../../evaluate-BhMXY6DM.cjs";
|
|
3
3
|
import { OdbQueryInfo, OdbReport, Package } from "odf.js";
|
|
4
4
|
//#region src/odb/report/source.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HsqldbDecodeOptions } from "../../
|
|
1
|
+
import { n as HsqldbDecodeOptions } from "../../rowformat-Cl2exlEh.js";
|
|
2
2
|
import { t as SqlResultSet } from "../../evaluate-BU5N1Jk1.js";
|
|
3
3
|
import { OdbQueryInfo, OdbReport, Package } from "odf.js";
|
|
4
4
|
//#region src/odb/report/source.d.ts
|
package/dist/odf/odt/read.cjs
CHANGED
|
@@ -8,7 +8,7 @@ const require_odf_vector_detect = require("../vector/detect.cjs");
|
|
|
8
8
|
let odf_js = require("odf.js");
|
|
9
9
|
//#region src/odf/odt/read.ts
|
|
10
10
|
function readOdtContent(pkg) {
|
|
11
|
-
const odtDoc = (0, odf_js.readOdtContent)(pkg);
|
|
11
|
+
const odtDoc = (0, odf_js.readOdtContent)(pkg, { frames: "none" });
|
|
12
12
|
const contentPart = pkg.parts["content.xml"];
|
|
13
13
|
if (contentPart?.kind === "xml" && odtDoc.sections.length === 1) {
|
|
14
14
|
const root = (0, odf_js.rootElement)(contentPart.nodes);
|
package/dist/odf/odt/read.js
CHANGED
|
@@ -7,7 +7,7 @@ import { collectContainerVectors, isVectorElementTag } from "../vector/detect.js
|
|
|
7
7
|
import { findChildElement, readOdtContent as readOdtContent$1, rootElement } from "odf.js";
|
|
8
8
|
//#region src/odf/odt/read.ts
|
|
9
9
|
function readOdtContent(pkg) {
|
|
10
|
-
const odtDoc = readOdtContent$1(pkg);
|
|
10
|
+
const odtDoc = readOdtContent$1(pkg, { frames: "none" });
|
|
11
11
|
const contentPart = pkg.parts["content.xml"];
|
|
12
12
|
if (contentPart?.kind === "xml" && odtDoc.sections.length === 1) {
|
|
13
13
|
const root = rootElement(contentPart.nodes);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FontSubstitution, ProvidedFont } from "document-schema.js";
|
|
2
|
+
import { FontRegistry } from "pdf-codec";
|
|
3
|
+
import { Package } from "ooxml.js";
|
|
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
|
|
20
|
+
export { extractSourceFonts as i, FontSourcePackage as n, createDocumentFontRegistry as r, DocumentFontRegistryOptions as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Package } from "ooxml.js";
|
|
2
|
+
import { FontSubstitution, ProvidedFont } from "document-schema.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
|
|
20
|
+
export { extractSourceFonts as i, FontSourcePackage as n, createDocumentFontRegistry as r, DocumentFontRegistryOptions as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
25
|
+
export { readModifiedUtf8 as a, readHsqldbColumnValue as i, HsqldbDecodeOptions as n, resolveHsqldbTypeCode as o, HsqldbRowFormatError as r, HsqldbDataCursor as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
25
|
+
export { readModifiedUtf8 as a, readHsqldbColumnValue as i, HsqldbDecodeOptions as n, resolveHsqldbTypeCode as o, HsqldbRowFormatError as r, HsqldbDataCursor as t };
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const SVG_DIAGNOSTIC_CODES: readonly ["svg/text-unsupported", "svg/image-unsupported", "svg/use-unsupported", "svg/gradient-unsupported", "svg/element-unsupported", "svg/element-skipped", "svg/css-style-ignored", "svg/paint-unsupported", "svg/opacity-ignored", "svg/preserve-aspect-ratio-stretched", "svg/default-size-assumed", "svg/shape-unsupported", "svg/stroke-style-unsupported"];
|
|
3
|
-
type SvgDiagnosticCode = (typeof SVG_DIAGNOSTIC_CODES)[number];
|
|
4
|
-
interface SvgDiagnostic {
|
|
5
|
-
readonly code: SvgDiagnosticCode;
|
|
6
|
-
readonly detail?: string;
|
|
7
|
-
}
|
|
8
|
-
type SvgDiagnosticSink = (diagnostic: SvgDiagnostic) => void;
|
|
9
|
-
//#endregion
|
|
1
|
+
import { i as SvgDiagnosticSink, n as SvgDiagnostic, r as SvgDiagnosticCode, t as SVG_DIAGNOSTIC_CODES } from "../diagnostics-DVAXKgcf.cjs";
|
|
10
2
|
export { SVG_DIAGNOSTIC_CODES, SvgDiagnostic, SvgDiagnosticCode, SvgDiagnosticSink };
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const SVG_DIAGNOSTIC_CODES: readonly ["svg/text-unsupported", "svg/image-unsupported", "svg/use-unsupported", "svg/gradient-unsupported", "svg/element-unsupported", "svg/element-skipped", "svg/css-style-ignored", "svg/paint-unsupported", "svg/opacity-ignored", "svg/preserve-aspect-ratio-stretched", "svg/default-size-assumed", "svg/shape-unsupported", "svg/stroke-style-unsupported"];
|
|
3
|
-
type SvgDiagnosticCode = (typeof SVG_DIAGNOSTIC_CODES)[number];
|
|
4
|
-
interface SvgDiagnostic {
|
|
5
|
-
readonly code: SvgDiagnosticCode;
|
|
6
|
-
readonly detail?: string;
|
|
7
|
-
}
|
|
8
|
-
type SvgDiagnosticSink = (diagnostic: SvgDiagnostic) => void;
|
|
9
|
-
//#endregion
|
|
1
|
+
import { i as SvgDiagnosticSink, n as SvgDiagnostic, r as SvgDiagnosticCode, t as SVG_DIAGNOSTIC_CODES } from "../diagnostics-DVAXKgcf.js";
|
|
10
2
|
export { SVG_DIAGNOSTIC_CODES, SvgDiagnostic, SvgDiagnosticCode, SvgDiagnosticSink };
|
package/dist/svg/read.d.cts
CHANGED
package/dist/svg/read.d.ts
CHANGED
package/dist/svg/write.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SvgDiagnosticSink } from "
|
|
1
|
+
import { i as SvgDiagnosticSink } from "../diagnostics-DVAXKgcf.cjs";
|
|
2
2
|
import { ContentDocument } from "document-schema.js";
|
|
3
3
|
//#region src/svg/write.d.ts
|
|
4
4
|
declare class SvgUnsupportedDocumentKindError extends Error {
|
package/dist/svg/write.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SvgDiagnosticSink } from "
|
|
1
|
+
import { i as SvgDiagnosticSink } from "../diagnostics-DVAXKgcf.js";
|
|
2
2
|
import { ContentDocument } from "document-schema.js";
|
|
3
3
|
//#region src/svg/write.d.ts
|
|
4
4
|
declare class SvgUnsupportedDocumentKindError extends Error {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.5",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/ExaDev/documents.js.git"
|
|
8
|
+
"url": "git+https://github.com/ExaDev/documents.js.git",
|
|
9
|
+
"directory": "packages/documents.js"
|
|
9
10
|
},
|
|
10
11
|
"homepage": "https://github.com/ExaDev/documents.js#readme",
|
|
11
12
|
"bugs": {
|
|
@@ -20,6 +21,14 @@
|
|
|
20
21
|
"import": "./dist/index.js",
|
|
21
22
|
"require": "./dist/index.cjs"
|
|
22
23
|
},
|
|
24
|
+
"./read": {
|
|
25
|
+
"types": {
|
|
26
|
+
"import": "./dist/convert/from-pdf.d.ts",
|
|
27
|
+
"require": "./dist/convert/from-pdf.d.cts"
|
|
28
|
+
},
|
|
29
|
+
"import": "./dist/convert/from-pdf.js",
|
|
30
|
+
"require": "./dist/convert/from-pdf.cjs"
|
|
31
|
+
},
|
|
23
32
|
"./*": {
|
|
24
33
|
"types": {
|
|
25
34
|
"import": "./dist/*.d.ts",
|
|
@@ -32,6 +41,13 @@
|
|
|
32
41
|
"main": "./dist/index.cjs",
|
|
33
42
|
"module": "./dist/index.js",
|
|
34
43
|
"types": "./dist/index.d.ts",
|
|
44
|
+
"typesVersions": {
|
|
45
|
+
"*": {
|
|
46
|
+
"read": [
|
|
47
|
+
"./dist/convert/from-pdf.d.ts"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
35
51
|
"bin": {
|
|
36
52
|
"documents.js": "./dist/bin.js"
|
|
37
53
|
},
|
|
@@ -61,13 +77,13 @@
|
|
|
61
77
|
],
|
|
62
78
|
"license": "MIT",
|
|
63
79
|
"dependencies": {
|
|
64
|
-
"byte-codec": "^1.1.
|
|
65
|
-
"document-schema.js": "^4.
|
|
80
|
+
"byte-codec": "^1.1.13",
|
|
81
|
+
"document-schema.js": "^4.8.0",
|
|
66
82
|
"fflate": "^0.8.3",
|
|
67
|
-
"markdown-codec": "^4.
|
|
68
|
-
"odf.js": "^5.
|
|
69
|
-
"ooxml.js": "^4.0
|
|
70
|
-
"pdf-codec": "^3.0
|
|
83
|
+
"markdown-codec": "^4.1.1",
|
|
84
|
+
"odf.js": "^5.1.2",
|
|
85
|
+
"ooxml.js": "^4.5.0",
|
|
86
|
+
"pdf-codec": "^3.3.0",
|
|
71
87
|
"temml": "0.13.4",
|
|
72
88
|
"zod": "^4.4.3"
|
|
73
89
|
},
|
|
@@ -99,9 +115,10 @@
|
|
|
99
115
|
"_build": "tsdown",
|
|
100
116
|
"lint": "turbo run _lint",
|
|
101
117
|
"_lint": "eslint . --fix --cache --max-warnings 0",
|
|
102
|
-
"typecheck": "turbo run _typecheck _typecheck:node",
|
|
118
|
+
"typecheck": "turbo run _typecheck _typecheck:node _typecheck:attw",
|
|
103
119
|
"_typecheck": "tsc -p tsconfig.json",
|
|
104
120
|
"_typecheck:node": "tsc -p tsconfig.node.json",
|
|
121
|
+
"_typecheck:attw": "attw --pack",
|
|
105
122
|
"test": "turbo run _test",
|
|
106
123
|
"_test": "vitest run --project unit",
|
|
107
124
|
"test:workers": "turbo run _test:workers",
|
|
@@ -110,7 +127,7 @@
|
|
|
110
127
|
"test:coverage": "turbo run _test:coverage",
|
|
111
128
|
"_test:coverage": "vitest run --project unit --coverage",
|
|
112
129
|
"test:smoke": "turbo run _test:smoke",
|
|
113
|
-
"_test:smoke": "
|
|
130
|
+
"_test:smoke": "vitest run --project smoke",
|
|
114
131
|
"release": "semantic-release"
|
|
115
132
|
}
|
|
116
133
|
}
|
package/dist/metadata/read.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_convert_convert = require("../convert/convert.cjs");
|
|
3
|
-
const require_codecs_registry = require("../codecs/registry.cjs");
|
|
4
|
-
let pdf_codec = require("pdf-codec");
|
|
5
|
-
//#region src/metadata/read.ts
|
|
6
|
-
function readDocumentMetadata(format, bytes, options) {
|
|
7
|
-
const signal = options?.signal;
|
|
8
|
-
if (format === "xlsx") return (0, pdf_codec.readPdf)(require_convert_convert.xlsxToPdf(bytes, { signal }), { signal }).metadata;
|
|
9
|
-
const codecs = require_codecs_registry.DOCUMENT_FORMAT_CODECS[format];
|
|
10
|
-
if (codecs.content) return codecs.content.read(bytes, { signal }).metadata;
|
|
11
|
-
if (codecs.layout) return codecs.layout.read(bytes, { signal }).metadata;
|
|
12
|
-
throw new Error(`DocumentFormat '${format}' has neither a content nor a layout codec in DOCUMENT_FORMAT_CODECS, and is not 'xlsx' -- this is an internal invariant violation, not a caller error`);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
exports.readDocumentMetadata = readDocumentMetadata;
|
package/dist/metadata/read.d.cts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DocumentFormat } from "../convert/port.cjs";
|
|
2
|
-
import { LayoutMetadata } from "document-schema.js";
|
|
3
|
-
//#region src/metadata/read.d.ts
|
|
4
|
-
interface ReadDocumentMetadataOptions {
|
|
5
|
-
readonly signal?: AbortSignal;
|
|
6
|
-
}
|
|
7
|
-
declare function readDocumentMetadata(format: DocumentFormat, bytes: Uint8Array<ArrayBuffer>, options?: ReadDocumentMetadataOptions): LayoutMetadata;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ReadDocumentMetadataOptions, readDocumentMetadata };
|
package/dist/metadata/read.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DocumentFormat } from "../convert/port.js";
|
|
2
|
-
import { LayoutMetadata } from "document-schema.js";
|
|
3
|
-
//#region src/metadata/read.d.ts
|
|
4
|
-
interface ReadDocumentMetadataOptions {
|
|
5
|
-
readonly signal?: AbortSignal;
|
|
6
|
-
}
|
|
7
|
-
declare function readDocumentMetadata(format: DocumentFormat, bytes: Uint8Array<ArrayBuffer>, options?: ReadDocumentMetadataOptions): LayoutMetadata;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ReadDocumentMetadataOptions, readDocumentMetadata };
|
package/dist/metadata/read.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { xlsxToPdf } from "../convert/convert.js";
|
|
2
|
-
import { DOCUMENT_FORMAT_CODECS } from "../codecs/registry.js";
|
|
3
|
-
import { readPdf } from "pdf-codec";
|
|
4
|
-
//#region src/metadata/read.ts
|
|
5
|
-
function readDocumentMetadata(format, bytes, options) {
|
|
6
|
-
const signal = options?.signal;
|
|
7
|
-
if (format === "xlsx") return readPdf(xlsxToPdf(bytes, { signal }), { signal }).metadata;
|
|
8
|
-
const codecs = DOCUMENT_FORMAT_CODECS[format];
|
|
9
|
-
if (codecs.content) return codecs.content.read(bytes, { signal }).metadata;
|
|
10
|
-
if (codecs.layout) return codecs.layout.read(bytes, { signal }).metadata;
|
|
11
|
-
throw new Error(`DocumentFormat '${format}' has neither a content nor a layout codec in DOCUMENT_FORMAT_CODECS, and is not 'xlsx' -- this is an internal invariant violation, not a caller error`);
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { readDocumentMetadata };
|