js.documents 1.80.2 → 1.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/codecs/registry.cjs
CHANGED
|
@@ -17,6 +17,7 @@ const require_odf_odg_read = require("../odf/odg/read.cjs");
|
|
|
17
17
|
const require_markdown_text = require("../markdown/text.cjs");
|
|
18
18
|
const require_ports_abort = require("../ports/abort.cjs");
|
|
19
19
|
const require_package_codec = require("../package-codec.cjs");
|
|
20
|
+
let ooxml_js = require("ooxml.js");
|
|
20
21
|
let pdf_codec = require("pdf-codec");
|
|
21
22
|
//#region src/codecs/registry.ts
|
|
22
23
|
function isArrayBufferBacked(bytes) {
|
|
@@ -81,7 +82,13 @@ const DOCUMENT_FORMAT_CODECS = {
|
|
|
81
82
|
read: (bytes, options) => (0, pdf_codec.readPdf)(requireArrayBufferBytes(bytes), { signal: options?.signal }),
|
|
82
83
|
write: (layout, options) => (0, pdf_codec.writePdf)(layout, { signal: options?.signal })
|
|
83
84
|
} },
|
|
84
|
-
xlsx: {
|
|
85
|
+
xlsx: { content: {
|
|
86
|
+
read: (bytes, options) => {
|
|
87
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
88
|
+
return (0, ooxml_js.readXlsxContent)(require_package_codec.decodeDocumentPackage("xlsx", requireArrayBufferBytes(bytes)));
|
|
89
|
+
},
|
|
90
|
+
write: (content) => require_package_codec.encodeDocumentPackage("xlsx", (0, ooxml_js.buildXlsxPackage)(content))
|
|
91
|
+
} }
|
|
85
92
|
};
|
|
86
93
|
//#endregion
|
|
87
94
|
exports.DOCUMENT_FORMAT_CODECS = DOCUMENT_FORMAT_CODECS;
|
package/dist/codecs/registry.js
CHANGED
|
@@ -16,6 +16,7 @@ import { readOdgContent } from "../odf/odg/read.js";
|
|
|
16
16
|
import { decodeMarkdownText, encodeMarkdownText } from "../markdown/text.js";
|
|
17
17
|
import { throwIfAborted } from "../ports/abort.js";
|
|
18
18
|
import { decodeDocumentPackage, encodeDocumentPackage } from "../package-codec.js";
|
|
19
|
+
import { buildXlsxPackage, readXlsxContent } from "ooxml.js";
|
|
19
20
|
import { readPdf, writePdf } from "pdf-codec";
|
|
20
21
|
//#region src/codecs/registry.ts
|
|
21
22
|
function isArrayBufferBacked(bytes) {
|
|
@@ -80,7 +81,13 @@ const DOCUMENT_FORMAT_CODECS = {
|
|
|
80
81
|
read: (bytes, options) => readPdf(requireArrayBufferBytes(bytes), { signal: options?.signal }),
|
|
81
82
|
write: (layout, options) => writePdf(layout, { signal: options?.signal })
|
|
82
83
|
} },
|
|
83
|
-
xlsx: {
|
|
84
|
+
xlsx: { content: {
|
|
85
|
+
read: (bytes, options) => {
|
|
86
|
+
throwIfAborted(options?.signal);
|
|
87
|
+
return readXlsxContent(decodeDocumentPackage("xlsx", requireArrayBufferBytes(bytes)));
|
|
88
|
+
},
|
|
89
|
+
write: (content) => encodeDocumentPackage("xlsx", buildXlsxPackage(content))
|
|
90
|
+
} }
|
|
84
91
|
};
|
|
85
92
|
//#endregion
|
|
86
93
|
export { DOCUMENT_FORMAT_CODECS, isArrayBufferBacked, requireArrayBufferBytes };
|
|
@@ -7,10 +7,9 @@ function buildDocumentBytes(pkg, target) {
|
|
|
7
7
|
if (pkg.layout === void 0) throw new Error("this DocumentPackage has no layout -- only a package dumped from a <format>-to-pdf or pdf-to-<format> conversion carries one; a bridge conversion's own dump (e.g. odt-to-docx) never does, so 'pdf' is not a reachable target from it");
|
|
8
8
|
return (0, pdf_codec.writePdf)(pkg.layout);
|
|
9
9
|
}
|
|
10
|
-
if (target === "xlsx") throw new Error("'xlsx' cannot be built from a DocumentPackage directly -- this package does not re-export a ContentDocument-to-xlsx builder; convert to 'ods' here, then call odsToXlsx on the result instead");
|
|
11
10
|
if (target === "odf") throw new Error("'odf' (a standalone formula document) cannot be built from a DocumentPackage -- there is no ContentDocument-to-odf builder");
|
|
12
11
|
const content = require_codecs_registry.DOCUMENT_FORMAT_CODECS[target].content;
|
|
13
|
-
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, and is not 'pdf'/'
|
|
12
|
+
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, and is not 'pdf'/'odf' -- this is an internal invariant violation, not a caller error`);
|
|
14
13
|
return require_codecs_registry.requireArrayBufferBytes(content.write(pkg.content));
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
@@ -6,10 +6,9 @@ function buildDocumentBytes(pkg, target) {
|
|
|
6
6
|
if (pkg.layout === void 0) throw new Error("this DocumentPackage has no layout -- only a package dumped from a <format>-to-pdf or pdf-to-<format> conversion carries one; a bridge conversion's own dump (e.g. odt-to-docx) never does, so 'pdf' is not a reachable target from it");
|
|
7
7
|
return writePdf(pkg.layout);
|
|
8
8
|
}
|
|
9
|
-
if (target === "xlsx") throw new Error("'xlsx' cannot be built from a DocumentPackage directly -- this package does not re-export a ContentDocument-to-xlsx builder; convert to 'ods' here, then call odsToXlsx on the result instead");
|
|
10
9
|
if (target === "odf") throw new Error("'odf' (a standalone formula document) cannot be built from a DocumentPackage -- there is no ContentDocument-to-odf builder");
|
|
11
10
|
const content = DOCUMENT_FORMAT_CODECS[target].content;
|
|
12
|
-
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, and is not 'pdf'/'
|
|
11
|
+
if (!content?.write) throw new Error(`DocumentFormat '${target}' has no content.write codec in DOCUMENT_FORMAT_CODECS, and is not 'pdf'/'odf' -- this is an internal invariant violation, not a caller error`);
|
|
13
12
|
return requireArrayBufferBytes(content.write(pkg.content));
|
|
14
13
|
}
|
|
15
14
|
//#endregion
|
package/dist/metadata/write.cjs
CHANGED
|
@@ -10,7 +10,8 @@ const REBUILD_FORMATS = {
|
|
|
10
10
|
odp: true,
|
|
11
11
|
ods: true,
|
|
12
12
|
odg: true,
|
|
13
|
-
markdown: true
|
|
13
|
+
markdown: true,
|
|
14
|
+
xlsx: true
|
|
14
15
|
};
|
|
15
16
|
function isRebuildFormat(format) {
|
|
16
17
|
return format in REBUILD_FORMATS;
|
|
@@ -36,7 +37,6 @@ function mergeMetadata(current, overrides) {
|
|
|
36
37
|
}
|
|
37
38
|
function classifyWritePath(source, target) {
|
|
38
39
|
if (source === "pdf" && target === "pdf") return { kind: "pdf" };
|
|
39
|
-
if (target === "xlsx" || source === "xlsx") return { errorMessage: "'xlsx' is not a supported setDocumentMetadata source or target -- this package does not re-export a ContentDocument-to-xlsx builder or a readXlsxContent from its own public surface (see the README's Architecture section); convert via xlsxToOds/odsToXlsx first, then set metadata on the ods" };
|
|
40
40
|
if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
|
|
41
41
|
if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
|
|
42
42
|
if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
|
package/dist/metadata/write.js
CHANGED
|
@@ -9,7 +9,8 @@ const REBUILD_FORMATS = {
|
|
|
9
9
|
odp: true,
|
|
10
10
|
ods: true,
|
|
11
11
|
odg: true,
|
|
12
|
-
markdown: true
|
|
12
|
+
markdown: true,
|
|
13
|
+
xlsx: true
|
|
13
14
|
};
|
|
14
15
|
function isRebuildFormat(format) {
|
|
15
16
|
return format in REBUILD_FORMATS;
|
|
@@ -35,7 +36,6 @@ function mergeMetadata(current, overrides) {
|
|
|
35
36
|
}
|
|
36
37
|
function classifyWritePath(source, target) {
|
|
37
38
|
if (source === "pdf" && target === "pdf") return { kind: "pdf" };
|
|
38
|
-
if (target === "xlsx" || source === "xlsx") return { errorMessage: "'xlsx' is not a supported setDocumentMetadata source or target -- this package does not re-export a ContentDocument-to-xlsx builder or a readXlsxContent from its own public surface (see the README's Architecture section); convert via xlsxToOds/odsToXlsx first, then set metadata on the ods" };
|
|
39
39
|
if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
|
|
40
40
|
if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
|
|
41
41
|
if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.81.0",
|
|
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": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"document-schema.js": "^2.3.1",
|
|
62
62
|
"fflate": "^0.8.3",
|
|
63
|
-
"markdown-codec": "^1.1.
|
|
64
|
-
"odf.js": "^2.3.
|
|
65
|
-
"ooxml.js": "^2.6.
|
|
66
|
-
"pdf-codec": "^1.11.
|
|
63
|
+
"markdown-codec": "^1.1.2",
|
|
64
|
+
"odf.js": "^2.3.3",
|
|
65
|
+
"ooxml.js": "^2.6.13",
|
|
66
|
+
"pdf-codec": "^1.11.3",
|
|
67
67
|
"zod": "^4.4.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|