js.documents 13.0.0 → 14.0.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/README.md +1 -1
- package/dist/codecs/read.cjs +1 -1
- package/dist/codecs/read.js +1 -1
- package/dist/codecs/registry.cjs +1 -1
- package/dist/codecs/registry.js +1 -1
- package/dist/convert/composition.cjs +1 -1
- package/dist/convert/composition.js +1 -1
- package/dist/edit/docx/content.cjs +1 -0
- package/dist/edit/docx/content.js +1 -0
- package/dist/edit/docx/table.cjs +14 -0
- package/dist/edit/docx/table.d.cts +2 -0
- package/dist/edit/docx/table.d.ts +2 -0
- package/dist/edit/docx/table.js +14 -0
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +1 -1
- package/dist/edit/odt/content.cjs +2 -0
- package/dist/edit/odt/content.d.cts +1 -1
- package/dist/edit/odt/content.d.ts +1 -1
- package/dist/edit/odt/content.js +2 -0
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +59 -6
- package/dist/edit/odt/table.d.cts +1 -1
- package/dist/edit/odt/table.d.ts +1 -1
- package/dist/edit/odt/table.js +59 -6
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/model/bytes.cjs +5 -8
- package/dist/model/bytes.js +5 -8
- package/dist/svg/text.cjs +41 -8
- package/dist/svg/text.d.cts +25 -3
- package/dist/svg/text.d.ts +25 -3
- package/dist/svg/text.js +40 -8
- package/dist/svg/xml-encoding.cjs +91 -0
- package/dist/svg/xml-encoding.d.cts +32 -0
- package/dist/svg/xml-encoding.d.ts +32 -0
- package/dist/svg/xml-encoding.js +88 -0
- package/dist/{table-BT3wN3Hd.d.cts → table-Bt9ahRyh.d.cts} +2 -0
- package/dist/{table-DhTy5Re7.d.ts → table-Cou5rKOo.d.ts} +2 -0
- package/package.json +14 -14
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { detectByteOrderMark } from "byte-codec";
|
|
2
|
+
//#region src/svg/xml-encoding.ts
|
|
3
|
+
const XML_ENCODING_ALIASES = {
|
|
4
|
+
"utf-8": "utf-8",
|
|
5
|
+
utf8: "utf-8",
|
|
6
|
+
"unicode-1-1-utf-8": "utf-8",
|
|
7
|
+
unicode11utf8: "utf-8",
|
|
8
|
+
unicode20utf8: "utf-8",
|
|
9
|
+
"x-unicode20utf8": "utf-8",
|
|
10
|
+
"utf-16le": "utf-16le",
|
|
11
|
+
"utf-16": "utf-16le",
|
|
12
|
+
"ucs-2": "utf-16le",
|
|
13
|
+
unicode: "utf-16le",
|
|
14
|
+
unicodefeff: "utf-16le",
|
|
15
|
+
csunicode: "utf-16le",
|
|
16
|
+
"iso-10646-ucs-2": "utf-16le",
|
|
17
|
+
"utf-16be": "utf-16be",
|
|
18
|
+
unicodefffe: "utf-16be",
|
|
19
|
+
"utf-32le": "utf-32le",
|
|
20
|
+
"utf-32be": "utf-32be",
|
|
21
|
+
"windows-1252": "windows-1252",
|
|
22
|
+
cp1252: "windows-1252",
|
|
23
|
+
"x-cp1252": "windows-1252",
|
|
24
|
+
"iso-8859-1": "windows-1252",
|
|
25
|
+
"iso8859-1": "windows-1252",
|
|
26
|
+
"iso_8859-1": "windows-1252",
|
|
27
|
+
"iso_8859-1:1987": "windows-1252",
|
|
28
|
+
"iso-ir-100": "windows-1252",
|
|
29
|
+
csisolatin1: "windows-1252",
|
|
30
|
+
l1: "windows-1252",
|
|
31
|
+
latin1: "windows-1252",
|
|
32
|
+
cp819: "windows-1252",
|
|
33
|
+
ibm819: "windows-1252",
|
|
34
|
+
"us-ascii": "windows-1252",
|
|
35
|
+
ascii: "windows-1252",
|
|
36
|
+
"ansi_x3.4-1968": "windows-1252"
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Maps a name from an XML encoding declaration onto the encoding byte-codec's decodeText would decode it under, matched case-insensitively against the WHATWG Encoding Standard's own label table (restricted to the six encodings decodeText supports).
|
|
40
|
+
* @param label - The declaration's raw `encoding` value, exactly as written.
|
|
41
|
+
* @returns The matching {@link TextEncodingLabel}, or `undefined` when the name is outside decodeText's own bounded set (ExaDev/documents.js#1361).
|
|
42
|
+
*/
|
|
43
|
+
function mapXmlEncodingLabel(label) {
|
|
44
|
+
return XML_ENCODING_ALIASES[label.toLowerCase()];
|
|
45
|
+
}
|
|
46
|
+
const XML_DECLARATION_SEARCH_WINDOW = 512;
|
|
47
|
+
const XML_DECLARATION_START = "<?xml";
|
|
48
|
+
const XML_ENCODING_DECL_PATTERN = /\bencoding\s*=\s*(["'])([A-Za-z][A-Za-z0-9._-]*)\1/;
|
|
49
|
+
/**
|
|
50
|
+
* Reads the raw encoding label out of an `<?xml ...?>` declaration's own leading bytes, without decoding anything.
|
|
51
|
+
*
|
|
52
|
+
* Safe ahead of any real decode because the declaration's own grammar restricts every character in it to ASCII: XML mandates that a declaration, if present, start at the very first byte (a byte order mark aside), so bytes not beginning with the literal ASCII sequence `<?xml` carry no declaration to read, and bytes that do keep writing ASCII up to and including the encoding name itself, whatever that name turns out to be.
|
|
53
|
+
* @param bytes - The document's own leading bytes.
|
|
54
|
+
* @returns The declaration's raw `encoding` value, exactly as written, or `undefined` when the leading bytes carry no `<?xml ...?>` declaration, or that declaration names no encoding.
|
|
55
|
+
*/
|
|
56
|
+
function readXmlEncodingDeclarationLabel(bytes) {
|
|
57
|
+
const windowLength = Math.min(bytes.length, XML_DECLARATION_SEARCH_WINDOW);
|
|
58
|
+
let window = "";
|
|
59
|
+
for (let index = 0; index < windowLength; index += 1) window += String.fromCharCode(bytes[index]);
|
|
60
|
+
if (!window.startsWith(XML_DECLARATION_START)) return;
|
|
61
|
+
const declarationEnd = window.indexOf("?>");
|
|
62
|
+
const declaration = declarationEnd === -1 ? window : window.slice(0, declarationEnd);
|
|
63
|
+
return XML_ENCODING_DECL_PATTERN.exec(declaration)?.[2];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Detects the encoding SVG's own XML prolog declares, per XML 1.0's own external-encoding-detection algorithm: a byte order mark first, since it needs no decoding to trust, then the `<?xml ... encoding="..."?>` declaration.
|
|
67
|
+
* @param bytes - The document's own leading bytes.
|
|
68
|
+
* @returns How the encoding was settled, or `undefined` when the leading bytes carry neither a byte order mark nor a declared encoding. XML's own default of UTF-8 applies in that case, left for the caller to decode strictly rather than through decodeText's own guessing.
|
|
69
|
+
*/
|
|
70
|
+
function detectSvgEncoding(bytes) {
|
|
71
|
+
const bom = detectByteOrderMark(bytes);
|
|
72
|
+
if (bom !== void 0) return {
|
|
73
|
+
kind: "resolved",
|
|
74
|
+
encoding: bom.encoding
|
|
75
|
+
};
|
|
76
|
+
const label = readXmlEncodingDeclarationLabel(bytes);
|
|
77
|
+
if (label === void 0) return;
|
|
78
|
+
const encoding = mapXmlEncodingLabel(label);
|
|
79
|
+
return encoding === void 0 ? {
|
|
80
|
+
kind: "unsupported",
|
|
81
|
+
label
|
|
82
|
+
} : {
|
|
83
|
+
kind: "resolved",
|
|
84
|
+
encoding
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { detectSvgEncoding, mapXmlEncodingLabel, readXmlEncodingDeclarationLabel };
|
|
@@ -60,6 +60,8 @@ declare class OdtTable {
|
|
|
60
60
|
constructor(container: XmlNode[], node: XmlElement, pkg: Package);
|
|
61
61
|
private live;
|
|
62
62
|
rows(): OdtTableRow[];
|
|
63
|
+
headerRows(): boolean[];
|
|
64
|
+
setHeaderRows(flags: readonly boolean[]): void;
|
|
63
65
|
gridRows(): TableGridRows<OdtTableCell>;
|
|
64
66
|
gridColumnCount(): number;
|
|
65
67
|
private grid;
|
|
@@ -60,6 +60,8 @@ declare class OdtTable {
|
|
|
60
60
|
constructor(container: XmlNode[], node: XmlElement, pkg: Package);
|
|
61
61
|
private live;
|
|
62
62
|
rows(): OdtTableRow[];
|
|
63
|
+
headerRows(): boolean[];
|
|
64
|
+
setHeaderRows(flags: readonly boolean[]): void;
|
|
63
65
|
gridRows(): TableGridRows<OdtTableCell>;
|
|
64
66
|
gridColumnCount(): number;
|
|
65
67
|
private grid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
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": {
|
|
@@ -77,21 +77,21 @@
|
|
|
77
77
|
],
|
|
78
78
|
"license": "MIT",
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"archive-codec": "1.11.
|
|
81
|
-
"byte-codec": "1.
|
|
82
|
-
"doc-codec": "
|
|
83
|
-
"document-schema.js": "7.
|
|
84
|
-
"epub-codec": "
|
|
80
|
+
"archive-codec": "1.11.10",
|
|
81
|
+
"byte-codec": "1.8.0",
|
|
82
|
+
"doc-codec": "6.0.0",
|
|
83
|
+
"document-schema.js": "7.14.0",
|
|
84
|
+
"epub-codec": "5.0.1",
|
|
85
85
|
"fflate": "0.8.3",
|
|
86
|
-
"markdown-codec": "
|
|
87
|
-
"odf.js": "
|
|
88
|
-
"ooxml.js": "
|
|
89
|
-
"pdf-codec": "5.2.
|
|
90
|
-
"ppt-codec": "2.0
|
|
91
|
-
"rtf-codec": "
|
|
86
|
+
"markdown-codec": "11.0.0",
|
|
87
|
+
"odf.js": "11.0.0",
|
|
88
|
+
"ooxml.js": "12.0.0",
|
|
89
|
+
"pdf-codec": "5.2.4",
|
|
90
|
+
"ppt-codec": "2.1.0",
|
|
91
|
+
"rtf-codec": "8.0.0",
|
|
92
92
|
"temml": "0.13.4",
|
|
93
|
-
"wpd-codec": "5.0
|
|
94
|
-
"xls-codec": "4.15.
|
|
93
|
+
"wpd-codec": "5.1.0",
|
|
94
|
+
"xls-codec": "4.15.16",
|
|
95
95
|
"zod": "4.4.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|