doc-codec 2.4.3 → 2.6.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 +53 -20
- package/dist/chp-B6AOh85P.d.ts +18 -0
- package/dist/chp-BpCqpb7V.d.cts +18 -0
- package/dist/detect.cjs +3 -0
- package/dist/detect.d.cts +3 -1
- package/dist/detect.d.ts +3 -1
- package/dist/detect.js +3 -1
- package/dist/encryption.cjs +44 -10
- package/dist/encryption.d.cts +2 -2
- package/dist/encryption.d.ts +2 -2
- package/dist/encryption.js +45 -11
- package/dist/fib/fib.cjs +14 -0
- package/dist/fib/fib.d.cts +1 -1
- package/dist/fib/fib.d.ts +1 -1
- package/dist/fib/fib.js +14 -0
- package/dist/fib/offsets.cjs +14 -0
- package/dist/fib/offsets.d.cts +14 -0
- package/dist/fib/offsets.d.ts +14 -0
- package/dist/fib/offsets.js +14 -0
- package/dist/{fib-DWFta19r.d.cts → fib-6BFIx153.d.cts} +14 -0
- package/dist/{fib-DWFta19r.d.ts → fib-6BFIx153.d.ts} +14 -0
- package/dist/fkp-I-laf-8y.d.cts +33 -0
- package/dist/fkp-I-laf-8y.d.ts +33 -0
- package/dist/headers-footers.cjs +34 -0
- package/dist/headers-footers.d.cts +16 -0
- package/dist/headers-footers.d.ts +16 -0
- package/dist/headers-footers.js +33 -0
- package/dist/index.cjs +20 -9
- package/dist/index.d.cts +16 -12
- package/dist/index.d.ts +16 -12
- package/dist/index.js +15 -11
- package/dist/list/numbering-write.d.cts +1 -1
- package/dist/list/numbering-write.d.ts +1 -1
- package/dist/list/numbering.d.cts +23 -1
- package/dist/list/numbering.d.ts +23 -1
- package/dist/notes.cjs +26 -0
- package/dist/notes.d.cts +20 -0
- package/dist/notes.d.ts +20 -0
- package/dist/notes.js +25 -0
- package/dist/{pap-BT1p0uzu.d.cts → pap-BQ2E17K9.d.cts} +5 -3
- package/dist/{pap-DOFLMWcG.d.ts → pap-iWFIpCdo.d.ts} +5 -3
- package/dist/paragraphs-DQUp8_HB.d.cts +31 -0
- package/dist/paragraphs-s2lJ6w2I.d.ts +31 -0
- package/dist/pictures.cjs +93 -0
- package/dist/pictures.d.cts +6 -0
- package/dist/pictures.d.ts +6 -0
- package/dist/pictures.js +92 -0
- package/dist/piece-table-CA18mhjv.d.cts +28 -0
- package/dist/piece-table-CA18mhjv.d.ts +28 -0
- package/dist/prop/chp.d.cts +1 -17
- package/dist/prop/chp.d.ts +1 -17
- package/dist/prop/fkp.d.cts +1 -32
- package/dist/prop/fkp.d.ts +1 -32
- package/dist/prop/pap.cjs +4 -2
- package/dist/prop/pap.d.cts +1 -1
- package/dist/prop/pap.d.ts +1 -1
- package/dist/prop/pap.js +4 -2
- package/dist/prop/sep.cjs +20 -10
- package/dist/prop/sep.d.cts +8 -4
- package/dist/prop/sep.d.ts +8 -4
- package/dist/prop/sep.js +20 -10
- package/dist/read.cjs +48 -153
- package/dist/read.d.cts +13 -15
- package/dist/read.d.ts +13 -15
- package/dist/read.js +51 -156
- package/dist/stsh-Bj0YSEOp.d.ts +40 -0
- package/dist/stsh-CK59x6XG.d.cts +40 -0
- package/dist/style/stsh.d.cts +1 -39
- package/dist/style/stsh.d.ts +1 -39
- package/dist/subdocument.cjs +20 -0
- package/dist/subdocument.d.cts +8 -0
- package/dist/subdocument.d.ts +8 -0
- package/dist/subdocument.js +18 -0
- package/dist/table/read.cjs +31 -17
- package/dist/table/read.d.cts +1 -1
- package/dist/table/read.d.ts +1 -1
- package/dist/table/read.js +32 -18
- package/dist/text/characters.d.cts +1 -1
- package/dist/text/characters.d.ts +1 -1
- package/dist/text/paragraphs.cjs +189 -0
- package/dist/text/paragraphs.d.cts +2 -0
- package/dist/text/paragraphs.d.ts +2 -0
- package/dist/text/paragraphs.js +187 -0
- package/dist/text/piece-table.d.cts +1 -27
- package/dist/text/piece-table.d.ts +1 -27
- package/dist/write.cjs +3 -3
- package/dist/write.js +3 -3
- package/package.json +2 -2
- package/dist/numbering-DSpm9w6y.d.cts +0 -24
- package/dist/numbering-DayjnHXY.d.ts +0 -24
package/dist/list/numbering.d.ts
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as Fib } from "../fib-6BFIx153.js";
|
|
2
|
+
//#region src/list/numbering.d.ts
|
|
3
|
+
/** MSONFC ([MS-OSHARED] 2.2.1.3), mapped to its own documented ST_NumberFormat equivalent -- the identical vocabulary ooxml.js's NumberingLevel.format carries verbatim from word/numbering.xml's own w:numFmt/@w:val. Every member through msonfcUCRus (0x3B) is a real numbered/lettered/ideograph format; 0x17 (msonfcBullet) is handled separately below since PlfLfo also treats it as the "no number sequence, but has bullets" case LVLF's own field text calls out by name. */
|
|
4
|
+
declare const NUMBER_FORMAT_BY_NFC: Readonly<Record<number, string>>;
|
|
5
|
+
interface NumberingLevel {
|
|
6
|
+
/** The ST_NumberFormat-equivalent string MSONFC's own value maps to ("decimal", "upperRoman", "bullet", ...), or "none" for a level with no number sequence at all ([MS-DOC] 2.9.150's own nfc field text: "If this is equal to 0xFF..., this level does not have a number sequence"). */
|
|
7
|
+
readonly format: string;
|
|
8
|
+
/** The level's own text template: a placeholder pattern like '%1.' or '%2)' for a numbered format (the digit names which zero-based level's own counter substitutes at that position, one-based in the placeholder itself) -- the identical convention ooxml.js's own NumberingLevel.text carries verbatim from w:lvlText/@w:val -- or a literal bullet glyph string for format 'bullet'. Decoded from the level's own Xst (a raw UTF-16 string) plus its rgbxchNums array, which names which character POSITIONS in that string are placeholders rather than literal text -- see readLevelText below. */
|
|
9
|
+
readonly text: string;
|
|
10
|
+
/** iStartAt: the value this level's counter begins from. Meaningless (and not read as anything but 1) for a level with no number sequence. */
|
|
11
|
+
readonly startAt: number;
|
|
12
|
+
/** ilvlRestartLim ([MS-DOC] 2.9.150), only when fNoRestart is set: the first (most-significant) zero-based level after which this level's own number sequence does NOT restart. Absent (undefined) is the spec's own default behaviour -- "restarts when a more significant level is encountered" -- not "never restarts". */
|
|
13
|
+
readonly restart?: number;
|
|
14
|
+
}
|
|
15
|
+
interface NumberingDefinition {
|
|
16
|
+
/** Keyed by the level's own zero-based ilvl, stringified -- the identical zero-based numbering ContentListMembership.level already uses, so `definitions[membership.numId]?.levels[String(membership.level)]` is the direct lookup path from a paragraph's own membership to its rendering definition. A record rather than a fixed-length array/tuple: a simple (fSimpleList) LSTF states only level 0. */
|
|
17
|
+
readonly levels: Readonly<Record<string, NumberingLevel>>;
|
|
18
|
+
}
|
|
19
|
+
/** Keyed by a paragraph's own listId (ContentListMembership.numId, stringified) -- prop/pap.ts's own sprmPIlfo, a one-based index into PlfLfo.rgLfo. */
|
|
20
|
+
type NumberingDefinitions = Readonly<Record<string, NumberingDefinition>>;
|
|
21
|
+
/** Resolves PlfLst and PlfLfo into NumberingDefinitions, keyed by the one-based ilfo every listId already is (prop/pap.ts's own Math.abs(ilfo)) -- absent entirely when the file carries neither (fcPlfLst/fcPlfLfo both 0, a document with no lists at all, the common case this reader must not fail on). */
|
|
22
|
+
declare function readNumberingDefinitions(table: Uint8Array, fib: Fib): NumberingDefinitions;
|
|
23
|
+
//#endregion
|
|
2
24
|
export { NUMBER_FORMAT_BY_NFC, NumberingDefinition, NumberingDefinitions, NumberingLevel, readNumberingDefinitions };
|
package/dist/notes.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_subdocument = require("./subdocument.cjs");
|
|
3
|
+
//#region src/notes.ts
|
|
4
|
+
function readNoteBodies(wordDocument, table, pieceTable, context, fib) {
|
|
5
|
+
const footnoteStartCp = fib.ccpText;
|
|
6
|
+
const commentStartCp = footnoteStartCp + fib.ccpFtn + fib.ccpHdd;
|
|
7
|
+
const endnoteStartCp = commentStartCp + fib.ccpAtn;
|
|
8
|
+
const footnotes = require_subdocument.readSubdocumentStories(wordDocument, table, pieceTable, context, footnoteStartCp, fib.ccpFtn, fib.fcPlcffndTxt, fib.lcbPlcffndTxt, "PlcffndTxt").map((entries, index) => ({
|
|
9
|
+
id: String(index + 1),
|
|
10
|
+
text: require_subdocument.storyText(entries)
|
|
11
|
+
}));
|
|
12
|
+
const comments = require_subdocument.readSubdocumentStories(wordDocument, table, pieceTable, context, commentStartCp, fib.ccpAtn, fib.fcPlcfandTxt, fib.lcbPlcfandTxt, "PlcfandTxt").map((entries, index) => ({
|
|
13
|
+
id: String(index + 1),
|
|
14
|
+
text: require_subdocument.storyText(entries)
|
|
15
|
+
}));
|
|
16
|
+
return {
|
|
17
|
+
footnotes,
|
|
18
|
+
endnotes: require_subdocument.readSubdocumentStories(wordDocument, table, pieceTable, context, endnoteStartCp, fib.ccpEdn, fib.fcPlcfendTxt, fib.lcbPlcfendTxt, "PlcfendTxt").map((entries, index) => ({
|
|
19
|
+
id: String(index + 1),
|
|
20
|
+
text: require_subdocument.storyText(entries)
|
|
21
|
+
})),
|
|
22
|
+
comments
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.readNoteBodies = readNoteBodies;
|
package/dist/notes.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as Fib } from "./fib-6BFIx153.cjs";
|
|
2
|
+
import { n as ReadContext } from "./paragraphs-DQUp8_HB.cjs";
|
|
3
|
+
import { n as PieceTable } from "./piece-table-CA18mhjv.cjs";
|
|
4
|
+
//#region src/notes.d.ts
|
|
5
|
+
interface Footnote {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
interface Comment {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
interface NoteBodies {
|
|
14
|
+
readonly footnotes: readonly Footnote[];
|
|
15
|
+
readonly endnotes: readonly Footnote[];
|
|
16
|
+
readonly comments: readonly Comment[];
|
|
17
|
+
}
|
|
18
|
+
declare function readNoteBodies(wordDocument: Uint8Array, table: Uint8Array, pieceTable: PieceTable, context: ReadContext, fib: Fib): NoteBodies;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Comment, Footnote, NoteBodies, readNoteBodies };
|
package/dist/notes.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as Fib } from "./fib-6BFIx153.js";
|
|
2
|
+
import { n as ReadContext } from "./paragraphs-s2lJ6w2I.js";
|
|
3
|
+
import { n as PieceTable } from "./piece-table-CA18mhjv.js";
|
|
4
|
+
//#region src/notes.d.ts
|
|
5
|
+
interface Footnote {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
interface Comment {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
interface NoteBodies {
|
|
14
|
+
readonly footnotes: readonly Footnote[];
|
|
15
|
+
readonly endnotes: readonly Footnote[];
|
|
16
|
+
readonly comments: readonly Comment[];
|
|
17
|
+
}
|
|
18
|
+
declare function readNoteBodies(wordDocument: Uint8Array, table: Uint8Array, pieceTable: PieceTable, context: ReadContext, fib: Fib): NoteBodies;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Comment, Footnote, NoteBodies, readNoteBodies };
|
package/dist/notes.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readSubdocumentStories, storyText } from "./subdocument.js";
|
|
2
|
+
//#region src/notes.ts
|
|
3
|
+
function readNoteBodies(wordDocument, table, pieceTable, context, fib) {
|
|
4
|
+
const footnoteStartCp = fib.ccpText;
|
|
5
|
+
const commentStartCp = footnoteStartCp + fib.ccpFtn + fib.ccpHdd;
|
|
6
|
+
const endnoteStartCp = commentStartCp + fib.ccpAtn;
|
|
7
|
+
const footnotes = readSubdocumentStories(wordDocument, table, pieceTable, context, footnoteStartCp, fib.ccpFtn, fib.fcPlcffndTxt, fib.lcbPlcffndTxt, "PlcffndTxt").map((entries, index) => ({
|
|
8
|
+
id: String(index + 1),
|
|
9
|
+
text: storyText(entries)
|
|
10
|
+
}));
|
|
11
|
+
const comments = readSubdocumentStories(wordDocument, table, pieceTable, context, commentStartCp, fib.ccpAtn, fib.fcPlcfandTxt, fib.lcbPlcfandTxt, "PlcfandTxt").map((entries, index) => ({
|
|
12
|
+
id: String(index + 1),
|
|
13
|
+
text: storyText(entries)
|
|
14
|
+
}));
|
|
15
|
+
return {
|
|
16
|
+
footnotes,
|
|
17
|
+
endnotes: readSubdocumentStories(wordDocument, table, pieceTable, context, endnoteStartCp, fib.ccpEdn, fib.fcPlcfendTxt, fib.lcbPlcfendTxt, "PlcfendTxt").map((entries, index) => ({
|
|
18
|
+
id: String(index + 1),
|
|
19
|
+
text: storyText(entries)
|
|
20
|
+
})),
|
|
21
|
+
comments
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { readNoteBodies };
|
|
@@ -19,10 +19,12 @@ interface ParagraphProperties {
|
|
|
19
19
|
listLevel?: number;
|
|
20
20
|
/** The list identifier (sprmPIlfo), present only when the paragraph is in a list at all. */
|
|
21
21
|
listId?: number;
|
|
22
|
-
/** sprmPItap's own table depth, present only when the sprm is; a value greater than 1 marks a table nested inside a table cell. */
|
|
22
|
+
/** sprmPItap's own table depth, present only when the sprm is; a value greater than 1 marks a paragraph belonging to a table nested inside a table cell. */
|
|
23
23
|
tableDepth?: number;
|
|
24
|
-
/** True
|
|
25
|
-
|
|
24
|
+
/** True on a nested table's (depth greater than 1) own cell-ending paragraph mark -- the sprmPFInnerTableCell analogue of sprmPFInTable's own cell-mark boundary at depth 1. */
|
|
25
|
+
innerTableCellMark?: boolean;
|
|
26
|
+
/** True on a nested table's (depth greater than 1) own row-ending paragraph mark -- the sprmPFInnerTtp analogue of sprmPFTtp's own row-mark boundary at depth 1. */
|
|
27
|
+
innerTtpMark?: boolean;
|
|
26
28
|
}
|
|
27
29
|
declare function applyParagraphSprms(prls: readonly Prl[], into: ParagraphProperties): ParagraphProperties;
|
|
28
30
|
//#endregion
|
|
@@ -19,10 +19,12 @@ interface ParagraphProperties {
|
|
|
19
19
|
listLevel?: number;
|
|
20
20
|
/** The list identifier (sprmPIlfo), present only when the paragraph is in a list at all. */
|
|
21
21
|
listId?: number;
|
|
22
|
-
/** sprmPItap's own table depth, present only when the sprm is; a value greater than 1 marks a table nested inside a table cell. */
|
|
22
|
+
/** sprmPItap's own table depth, present only when the sprm is; a value greater than 1 marks a paragraph belonging to a table nested inside a table cell. */
|
|
23
23
|
tableDepth?: number;
|
|
24
|
-
/** True
|
|
25
|
-
|
|
24
|
+
/** True on a nested table's (depth greater than 1) own cell-ending paragraph mark -- the sprmPFInnerTableCell analogue of sprmPFInTable's own cell-mark boundary at depth 1. */
|
|
25
|
+
innerTableCellMark?: boolean;
|
|
26
|
+
/** True on a nested table's (depth greater than 1) own row-ending paragraph mark -- the sprmPFInnerTtp analogue of sprmPFTtp's own row-mark boundary at depth 1. */
|
|
27
|
+
innerTtpMark?: boolean;
|
|
26
28
|
}
|
|
27
29
|
declare function applyParagraphSprms(prls: readonly Prl[], into: ParagraphProperties): ParagraphProperties;
|
|
28
30
|
//#endregion
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { o as PropertyBinTable } from "./fkp-I-laf-8y.cjs";
|
|
2
|
+
import { t as Prl } from "./sprm-DEyvdOo0.cjs";
|
|
3
|
+
import { t as CharacterProperties } from "./chp-BpCqpb7V.cjs";
|
|
4
|
+
import { t as ParagraphProperties } from "./pap-BQ2E17K9.cjs";
|
|
5
|
+
import { a as StyleSheet } from "./stsh-CK59x6XG.cjs";
|
|
6
|
+
import { ContentBlock } from "document-schema.js";
|
|
7
|
+
//#region src/text/paragraphs.d.ts
|
|
8
|
+
interface ReadContext {
|
|
9
|
+
readonly chpxTable: PropertyBinTable;
|
|
10
|
+
readonly papxTable: PropertyBinTable;
|
|
11
|
+
readonly styles: StyleSheet | undefined;
|
|
12
|
+
/** The font names sprmCRgFtc0's operand indexes into, or undefined when the document carries no SttbfFfn at all. */
|
|
13
|
+
readonly fonts: readonly string[] | undefined;
|
|
14
|
+
readonly characterProperties: Map<string, CharacterProperties>;
|
|
15
|
+
/** The "Data" stream's own bytes, or undefined when the container carries none -- a valid Word Binary File with no pictures need not have one at all. sprmCPicLocation's operand is an offset into this stream (pictures.ts's readInlinePicture). */
|
|
16
|
+
readonly dataStream: Uint8Array | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** One paragraph/cell/row-ending mark, still flat -- table/read.ts's assembleBlocks is what folds a run of these into a real ContentTable. `properties` and `grpprl` are carried alongside the already-built `blocks` because table grouping needs sprmPFInTable/sprmPFTtp/sprmPItap (properties) and, on a row's own mark, its table-defining sgc-5 sprms (grpprl) -- neither of which survives onto a plain ContentParagraph. `blocks` is more than one paragraph exactly when an inline picture anchor split this paragraph's own text around it (buildParagraphBlocks) -- ordinarily a single-element array holding the one ContentParagraph this mark closes. */
|
|
19
|
+
interface ParagraphEntry {
|
|
20
|
+
readonly blocks: readonly ContentBlock[];
|
|
21
|
+
readonly properties: ParagraphProperties;
|
|
22
|
+
readonly grpprl: readonly Prl[];
|
|
23
|
+
/** The character that terminated this paragraph in the text stream: PARAGRAPH_MARK, CELL_MARK, or SECTION_MARK. */
|
|
24
|
+
readonly terminator: number;
|
|
25
|
+
/** The character position immediately after this paragraph's own terminator (or, for the trailing no-mark case, the text's own length) -- comparable directly to a boundary plex's own CPs (PlcfSed.aCp, PlcffndTxt.aCp, Plcfhdd's aCp, ...) as long as `text` was itself read starting from that plex's own CP 0. read.ts's splitIntoSections and notes.ts/headers-footers.ts's own splitting use it to locate a story's real boundary. */
|
|
26
|
+
readonly endCp: number;
|
|
27
|
+
}
|
|
28
|
+
declare function readParagraphs(text: string, fcs: readonly number[], context: ReadContext): ParagraphEntry[];
|
|
29
|
+
declare function splitEntriesByBoundaries(entries: readonly ParagraphEntry[], boundaries: readonly number[]): ParagraphEntry[][];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { splitEntriesByBoundaries as i, ReadContext as n, readParagraphs as r, ParagraphEntry as t };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { o as PropertyBinTable } from "./fkp-I-laf-8y.js";
|
|
2
|
+
import { t as Prl } from "./sprm-DEyvdOo0.js";
|
|
3
|
+
import { t as CharacterProperties } from "./chp-B6AOh85P.js";
|
|
4
|
+
import { t as ParagraphProperties } from "./pap-iWFIpCdo.js";
|
|
5
|
+
import { a as StyleSheet } from "./stsh-Bj0YSEOp.js";
|
|
6
|
+
import { ContentBlock } from "document-schema.js";
|
|
7
|
+
//#region src/text/paragraphs.d.ts
|
|
8
|
+
interface ReadContext {
|
|
9
|
+
readonly chpxTable: PropertyBinTable;
|
|
10
|
+
readonly papxTable: PropertyBinTable;
|
|
11
|
+
readonly styles: StyleSheet | undefined;
|
|
12
|
+
/** The font names sprmCRgFtc0's operand indexes into, or undefined when the document carries no SttbfFfn at all. */
|
|
13
|
+
readonly fonts: readonly string[] | undefined;
|
|
14
|
+
readonly characterProperties: Map<string, CharacterProperties>;
|
|
15
|
+
/** The "Data" stream's own bytes, or undefined when the container carries none -- a valid Word Binary File with no pictures need not have one at all. sprmCPicLocation's operand is an offset into this stream (pictures.ts's readInlinePicture). */
|
|
16
|
+
readonly dataStream: Uint8Array | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** One paragraph/cell/row-ending mark, still flat -- table/read.ts's assembleBlocks is what folds a run of these into a real ContentTable. `properties` and `grpprl` are carried alongside the already-built `blocks` because table grouping needs sprmPFInTable/sprmPFTtp/sprmPItap (properties) and, on a row's own mark, its table-defining sgc-5 sprms (grpprl) -- neither of which survives onto a plain ContentParagraph. `blocks` is more than one paragraph exactly when an inline picture anchor split this paragraph's own text around it (buildParagraphBlocks) -- ordinarily a single-element array holding the one ContentParagraph this mark closes. */
|
|
19
|
+
interface ParagraphEntry {
|
|
20
|
+
readonly blocks: readonly ContentBlock[];
|
|
21
|
+
readonly properties: ParagraphProperties;
|
|
22
|
+
readonly grpprl: readonly Prl[];
|
|
23
|
+
/** The character that terminated this paragraph in the text stream: PARAGRAPH_MARK, CELL_MARK, or SECTION_MARK. */
|
|
24
|
+
readonly terminator: number;
|
|
25
|
+
/** The character position immediately after this paragraph's own terminator (or, for the trailing no-mark case, the text's own length) -- comparable directly to a boundary plex's own CPs (PlcfSed.aCp, PlcffndTxt.aCp, Plcfhdd's aCp, ...) as long as `text` was itself read starting from that plex's own CP 0. read.ts's splitIntoSections and notes.ts/headers-footers.ts's own splitting use it to locate a story's real boundary. */
|
|
26
|
+
readonly endCp: number;
|
|
27
|
+
}
|
|
28
|
+
declare function readParagraphs(text: string, fcs: readonly number[], context: ReadContext): ParagraphEntry[];
|
|
29
|
+
declare function splitEntriesByBoundaries(entries: readonly ParagraphEntry[], boundaries: readonly number[]): ParagraphEntry[][];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { splitEntriesByBoundaries as i, ReadContext as n, readParagraphs as r, ParagraphEntry as t };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_bytes = require("./bytes.cjs");
|
|
3
|
+
//#region src/pictures.ts
|
|
4
|
+
const PICF_SIZE = 68;
|
|
5
|
+
const PICF_MM_OFFSET = 6;
|
|
6
|
+
const PICF_DXA_GOAL_OFFSET = 28;
|
|
7
|
+
const PICF_DYA_GOAL_OFFSET = 30;
|
|
8
|
+
const PICF_MX_OFFSET = 32;
|
|
9
|
+
const PICF_MY_OFFSET = 34;
|
|
10
|
+
/** MFPF.mm's MM_SHAPEFILE value, [MS-DOC] 2.9.181 -- the one case PICFAndOfficeArtData carries an extra cchPicName/stPicName pair (the picture's own source file name) before `picture` begins. */
|
|
11
|
+
const MM_SHAPEFILE = 102;
|
|
12
|
+
const RECORD_HEADER_SIZE = 8;
|
|
13
|
+
/** OfficeArtBlipJPEG, [MS-ODRAW] 2.2.27. */
|
|
14
|
+
const BLIP_JPEG = 61469;
|
|
15
|
+
/** OfficeArtBlipPNG, [MS-ODRAW] 2.2.28. */
|
|
16
|
+
const BLIP_PNG = 61470;
|
|
17
|
+
/** rh.recInstance values naming a single rgbUid (16 bytes) rather than two (32 bytes) -- [MS-ODRAW] 2.2.27's own table for JPEG (RGB and CMYK) and 2.2.28's for PNG. */
|
|
18
|
+
const ONE_UID_INSTANCES = /* @__PURE__ */ new Set([
|
|
19
|
+
1130,
|
|
20
|
+
1762,
|
|
21
|
+
1760
|
|
22
|
+
]);
|
|
23
|
+
const TWO_UID_INSTANCES = /* @__PURE__ */ new Set([
|
|
24
|
+
1131,
|
|
25
|
+
1763,
|
|
26
|
+
1761
|
|
27
|
+
]);
|
|
28
|
+
/** The one byte following rgbUid(1|2) in every OfficeArtBlip variant this module reads, before the raw file bytes themselves. */
|
|
29
|
+
const BLIP_TAG_SIZE = 1;
|
|
30
|
+
const TWIPS_PER_POINT = 20;
|
|
31
|
+
/** mx/my, [MS-DOC] PICMID: "the ratio, measured in tenths of a percent, between the final display width/height and the initial picture width/height". */
|
|
32
|
+
const SCALE_DENOMINATOR = 1e3;
|
|
33
|
+
function readRecordHeader(data, offset) {
|
|
34
|
+
return {
|
|
35
|
+
recInstance: require_bytes.readUint16LE(data, offset) >> 4 & 4095,
|
|
36
|
+
recType: require_bytes.readUint16LE(data, offset + 2),
|
|
37
|
+
recLen: require_bytes.readUint32LE(data, offset + 4)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Resolves one inline picture character's own sprmCPicLocation offset into a ContentImageBlock, or undefined when the picture's own blip is a format this package does not decode (see this module's own top comment) -- never thrown, since an unsupported picture format is exactly the kind of absence the rest of this reader already treats as "read with fewer properties than it states" rather than a document-level failure. */
|
|
41
|
+
function readInlinePicture(dataStream, picLocation) {
|
|
42
|
+
const picf = require_bytes.slice(dataStream, picLocation, PICF_SIZE, "PICF in the Data stream");
|
|
43
|
+
const mm = require_bytes.readUint16LE(picf, PICF_MM_OFFSET);
|
|
44
|
+
const dxaGoal = require_bytes.readInt16LE(picf, PICF_DXA_GOAL_OFFSET);
|
|
45
|
+
const dyaGoal = require_bytes.readInt16LE(picf, PICF_DYA_GOAL_OFFSET);
|
|
46
|
+
const mx = require_bytes.readUint16LE(picf, PICF_MX_OFFSET);
|
|
47
|
+
const my = require_bytes.readUint16LE(picf, PICF_MY_OFFSET);
|
|
48
|
+
let cursor = picLocation + PICF_SIZE;
|
|
49
|
+
if (mm === MM_SHAPEFILE) {
|
|
50
|
+
const cchPicName = require_bytes.readUint8(dataStream, cursor);
|
|
51
|
+
cursor += 1 + cchPicName;
|
|
52
|
+
}
|
|
53
|
+
const shapeHeader = readRecordHeader(dataStream, cursor);
|
|
54
|
+
cursor += RECORD_HEADER_SIZE + shapeHeader.recLen;
|
|
55
|
+
const blipHeader = readRecordHeader(dataStream, cursor);
|
|
56
|
+
const format = blipFormat(blipHeader.recType);
|
|
57
|
+
if (format === void 0) return void 0;
|
|
58
|
+
const uidBytes = ONE_UID_INSTANCES.has(blipHeader.recInstance) ? 16 : TWO_UID_INSTANCES.has(blipHeader.recInstance) ? 32 : void 0;
|
|
59
|
+
if (uidBytes === void 0) return void 0;
|
|
60
|
+
const blipDataStart = cursor + RECORD_HEADER_SIZE + uidBytes + BLIP_TAG_SIZE;
|
|
61
|
+
const blipDataLength = blipHeader.recLen - uidBytes - BLIP_TAG_SIZE;
|
|
62
|
+
return {
|
|
63
|
+
kind: "image",
|
|
64
|
+
format,
|
|
65
|
+
base64: bytesToBase64(require_bytes.slice(dataStream, blipDataStart, blipDataLength, "OfficeArtBlip file data in the Data stream")),
|
|
66
|
+
widthPt: dxaGoal * mx / SCALE_DENOMINATOR / TWIPS_PER_POINT,
|
|
67
|
+
heightPt: dyaGoal * my / SCALE_DENOMINATOR / TWIPS_PER_POINT
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function blipFormat(recType) {
|
|
71
|
+
switch (recType) {
|
|
72
|
+
case BLIP_JPEG: return "jpeg";
|
|
73
|
+
case BLIP_PNG: return "png";
|
|
74
|
+
default: return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
78
|
+
function bytesToBase64(bytes) {
|
|
79
|
+
let out = "";
|
|
80
|
+
const len = bytes.length;
|
|
81
|
+
for (let index = 0; index < len; index += 3) {
|
|
82
|
+
const b0 = bytes[index] ?? 0;
|
|
83
|
+
const b1 = index + 1 < len ? bytes[index + 1] ?? 0 : 0;
|
|
84
|
+
const b2 = index + 2 < len ? bytes[index + 2] ?? 0 : 0;
|
|
85
|
+
out += BASE64_TABLE.charAt(b0 >> 2);
|
|
86
|
+
out += BASE64_TABLE.charAt((b0 & 3) << 4 | b1 >> 4);
|
|
87
|
+
out += index + 1 < len ? BASE64_TABLE.charAt((b1 & 15) << 2 | b2 >> 6) : "=";
|
|
88
|
+
out += index + 2 < len ? BASE64_TABLE.charAt(b2 & 63) : "=";
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.readInlinePicture = readInlinePicture;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentImageBlock } from "document-schema.js";
|
|
2
|
+
//#region src/pictures.d.ts
|
|
3
|
+
/** Resolves one inline picture character's own sprmCPicLocation offset into a ContentImageBlock, or undefined when the picture's own blip is a format this package does not decode (see this module's own top comment) -- never thrown, since an unsupported picture format is exactly the kind of absence the rest of this reader already treats as "read with fewer properties than it states" rather than a document-level failure. */
|
|
4
|
+
declare function readInlinePicture(dataStream: Uint8Array, picLocation: number): ContentImageBlock | undefined;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { readInlinePicture };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentImageBlock } from "document-schema.js";
|
|
2
|
+
//#region src/pictures.d.ts
|
|
3
|
+
/** Resolves one inline picture character's own sprmCPicLocation offset into a ContentImageBlock, or undefined when the picture's own blip is a format this package does not decode (see this module's own top comment) -- never thrown, since an unsupported picture format is exactly the kind of absence the rest of this reader already treats as "read with fewer properties than it states" rather than a document-level failure. */
|
|
4
|
+
declare function readInlinePicture(dataStream: Uint8Array, picLocation: number): ContentImageBlock | undefined;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { readInlinePicture };
|
package/dist/pictures.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { readInt16LE, readUint16LE, readUint32LE, readUint8, slice } from "./bytes.js";
|
|
2
|
+
//#region src/pictures.ts
|
|
3
|
+
const PICF_SIZE = 68;
|
|
4
|
+
const PICF_MM_OFFSET = 6;
|
|
5
|
+
const PICF_DXA_GOAL_OFFSET = 28;
|
|
6
|
+
const PICF_DYA_GOAL_OFFSET = 30;
|
|
7
|
+
const PICF_MX_OFFSET = 32;
|
|
8
|
+
const PICF_MY_OFFSET = 34;
|
|
9
|
+
/** MFPF.mm's MM_SHAPEFILE value, [MS-DOC] 2.9.181 -- the one case PICFAndOfficeArtData carries an extra cchPicName/stPicName pair (the picture's own source file name) before `picture` begins. */
|
|
10
|
+
const MM_SHAPEFILE = 102;
|
|
11
|
+
const RECORD_HEADER_SIZE = 8;
|
|
12
|
+
/** OfficeArtBlipJPEG, [MS-ODRAW] 2.2.27. */
|
|
13
|
+
const BLIP_JPEG = 61469;
|
|
14
|
+
/** OfficeArtBlipPNG, [MS-ODRAW] 2.2.28. */
|
|
15
|
+
const BLIP_PNG = 61470;
|
|
16
|
+
/** rh.recInstance values naming a single rgbUid (16 bytes) rather than two (32 bytes) -- [MS-ODRAW] 2.2.27's own table for JPEG (RGB and CMYK) and 2.2.28's for PNG. */
|
|
17
|
+
const ONE_UID_INSTANCES = /* @__PURE__ */ new Set([
|
|
18
|
+
1130,
|
|
19
|
+
1762,
|
|
20
|
+
1760
|
|
21
|
+
]);
|
|
22
|
+
const TWO_UID_INSTANCES = /* @__PURE__ */ new Set([
|
|
23
|
+
1131,
|
|
24
|
+
1763,
|
|
25
|
+
1761
|
|
26
|
+
]);
|
|
27
|
+
/** The one byte following rgbUid(1|2) in every OfficeArtBlip variant this module reads, before the raw file bytes themselves. */
|
|
28
|
+
const BLIP_TAG_SIZE = 1;
|
|
29
|
+
const TWIPS_PER_POINT = 20;
|
|
30
|
+
/** mx/my, [MS-DOC] PICMID: "the ratio, measured in tenths of a percent, between the final display width/height and the initial picture width/height". */
|
|
31
|
+
const SCALE_DENOMINATOR = 1e3;
|
|
32
|
+
function readRecordHeader(data, offset) {
|
|
33
|
+
return {
|
|
34
|
+
recInstance: readUint16LE(data, offset) >> 4 & 4095,
|
|
35
|
+
recType: readUint16LE(data, offset + 2),
|
|
36
|
+
recLen: readUint32LE(data, offset + 4)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Resolves one inline picture character's own sprmCPicLocation offset into a ContentImageBlock, or undefined when the picture's own blip is a format this package does not decode (see this module's own top comment) -- never thrown, since an unsupported picture format is exactly the kind of absence the rest of this reader already treats as "read with fewer properties than it states" rather than a document-level failure. */
|
|
40
|
+
function readInlinePicture(dataStream, picLocation) {
|
|
41
|
+
const picf = slice(dataStream, picLocation, PICF_SIZE, "PICF in the Data stream");
|
|
42
|
+
const mm = readUint16LE(picf, PICF_MM_OFFSET);
|
|
43
|
+
const dxaGoal = readInt16LE(picf, PICF_DXA_GOAL_OFFSET);
|
|
44
|
+
const dyaGoal = readInt16LE(picf, PICF_DYA_GOAL_OFFSET);
|
|
45
|
+
const mx = readUint16LE(picf, PICF_MX_OFFSET);
|
|
46
|
+
const my = readUint16LE(picf, PICF_MY_OFFSET);
|
|
47
|
+
let cursor = picLocation + PICF_SIZE;
|
|
48
|
+
if (mm === MM_SHAPEFILE) {
|
|
49
|
+
const cchPicName = readUint8(dataStream, cursor);
|
|
50
|
+
cursor += 1 + cchPicName;
|
|
51
|
+
}
|
|
52
|
+
const shapeHeader = readRecordHeader(dataStream, cursor);
|
|
53
|
+
cursor += RECORD_HEADER_SIZE + shapeHeader.recLen;
|
|
54
|
+
const blipHeader = readRecordHeader(dataStream, cursor);
|
|
55
|
+
const format = blipFormat(blipHeader.recType);
|
|
56
|
+
if (format === void 0) return void 0;
|
|
57
|
+
const uidBytes = ONE_UID_INSTANCES.has(blipHeader.recInstance) ? 16 : TWO_UID_INSTANCES.has(blipHeader.recInstance) ? 32 : void 0;
|
|
58
|
+
if (uidBytes === void 0) return void 0;
|
|
59
|
+
const blipDataStart = cursor + RECORD_HEADER_SIZE + uidBytes + BLIP_TAG_SIZE;
|
|
60
|
+
const blipDataLength = blipHeader.recLen - uidBytes - BLIP_TAG_SIZE;
|
|
61
|
+
return {
|
|
62
|
+
kind: "image",
|
|
63
|
+
format,
|
|
64
|
+
base64: bytesToBase64(slice(dataStream, blipDataStart, blipDataLength, "OfficeArtBlip file data in the Data stream")),
|
|
65
|
+
widthPt: dxaGoal * mx / SCALE_DENOMINATOR / TWIPS_PER_POINT,
|
|
66
|
+
heightPt: dyaGoal * my / SCALE_DENOMINATOR / TWIPS_PER_POINT
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function blipFormat(recType) {
|
|
70
|
+
switch (recType) {
|
|
71
|
+
case BLIP_JPEG: return "jpeg";
|
|
72
|
+
case BLIP_PNG: return "png";
|
|
73
|
+
default: return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
77
|
+
function bytesToBase64(bytes) {
|
|
78
|
+
let out = "";
|
|
79
|
+
const len = bytes.length;
|
|
80
|
+
for (let index = 0; index < len; index += 3) {
|
|
81
|
+
const b0 = bytes[index] ?? 0;
|
|
82
|
+
const b1 = index + 1 < len ? bytes[index + 1] ?? 0 : 0;
|
|
83
|
+
const b2 = index + 2 < len ? bytes[index + 2] ?? 0 : 0;
|
|
84
|
+
out += BASE64_TABLE.charAt(b0 >> 2);
|
|
85
|
+
out += BASE64_TABLE.charAt((b0 & 3) << 4 | b1 >> 4);
|
|
86
|
+
out += index + 1 < len ? BASE64_TABLE.charAt((b1 & 15) << 2 | b2 >> 6) : "=";
|
|
87
|
+
out += index + 2 < len ? BASE64_TABLE.charAt(b2 & 63) : "=";
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { readInlinePicture };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/text/piece-table.d.ts
|
|
2
|
+
interface Piece {
|
|
3
|
+
/** The first character position this piece supplies, PlcPcd.aCp[i]. */
|
|
4
|
+
readonly cpStart: number;
|
|
5
|
+
/** One past the last character position this piece supplies, PlcPcd.aCp[i + 1]. */
|
|
6
|
+
readonly cpEnd: number;
|
|
7
|
+
/** FcCompressed's 30-bit offset field as stored -- NOT yet halved for a compressed piece. Use characterOffset() rather than this directly. */
|
|
8
|
+
readonly fc: number;
|
|
9
|
+
/** True when the piece's characters occupy one byte each and its real byte offset is `fc / 2`. */
|
|
10
|
+
readonly compressed: boolean;
|
|
11
|
+
/** Pcd's fNoParaLast: "If this bit is 1, the text MUST NOT contain a paragraph mark." */
|
|
12
|
+
readonly noParaLast: boolean;
|
|
13
|
+
/** Pcd.Prm, [MS-DOC] 2.8.36 -- further property modifications for this piece's text, carried verbatim and not yet applied (see README's scope note). */
|
|
14
|
+
readonly prm: number;
|
|
15
|
+
}
|
|
16
|
+
interface PieceTable {
|
|
17
|
+
readonly pieces: readonly Piece[];
|
|
18
|
+
/** PlcPcd.aCp itself: one more entry than there are pieces, so a lookup can bracket every piece and terminate at the document's end. */
|
|
19
|
+
readonly cpKeys: readonly number[];
|
|
20
|
+
/** The final aCp entry, one past the last character position the document defines. */
|
|
21
|
+
readonly lastCp: number;
|
|
22
|
+
}
|
|
23
|
+
declare function parseClx(clx: Uint8Array): PieceTable;
|
|
24
|
+
declare function characterOffset(piece: Piece, cp: number): number;
|
|
25
|
+
/** The number of bytes one character occupies in this piece: one for a compressed (8-bit) piece, two for an uncompressed (16-bit) one. */
|
|
26
|
+
declare function characterSize(piece: Piece): 1 | 2;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { parseClx as a, characterSize as i, PieceTable as n, characterOffset as r, Piece as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/text/piece-table.d.ts
|
|
2
|
+
interface Piece {
|
|
3
|
+
/** The first character position this piece supplies, PlcPcd.aCp[i]. */
|
|
4
|
+
readonly cpStart: number;
|
|
5
|
+
/** One past the last character position this piece supplies, PlcPcd.aCp[i + 1]. */
|
|
6
|
+
readonly cpEnd: number;
|
|
7
|
+
/** FcCompressed's 30-bit offset field as stored -- NOT yet halved for a compressed piece. Use characterOffset() rather than this directly. */
|
|
8
|
+
readonly fc: number;
|
|
9
|
+
/** True when the piece's characters occupy one byte each and its real byte offset is `fc / 2`. */
|
|
10
|
+
readonly compressed: boolean;
|
|
11
|
+
/** Pcd's fNoParaLast: "If this bit is 1, the text MUST NOT contain a paragraph mark." */
|
|
12
|
+
readonly noParaLast: boolean;
|
|
13
|
+
/** Pcd.Prm, [MS-DOC] 2.8.36 -- further property modifications for this piece's text, carried verbatim and not yet applied (see README's scope note). */
|
|
14
|
+
readonly prm: number;
|
|
15
|
+
}
|
|
16
|
+
interface PieceTable {
|
|
17
|
+
readonly pieces: readonly Piece[];
|
|
18
|
+
/** PlcPcd.aCp itself: one more entry than there are pieces, so a lookup can bracket every piece and terminate at the document's end. */
|
|
19
|
+
readonly cpKeys: readonly number[];
|
|
20
|
+
/** The final aCp entry, one past the last character position the document defines. */
|
|
21
|
+
readonly lastCp: number;
|
|
22
|
+
}
|
|
23
|
+
declare function parseClx(clx: Uint8Array): PieceTable;
|
|
24
|
+
declare function characterOffset(piece: Piece, cp: number): number;
|
|
25
|
+
/** The number of bytes one character occupies in this piece: one for a compressed (8-bit) piece, two for an uncompressed (16-bit) one. */
|
|
26
|
+
declare function characterSize(piece: Piece): 1 | 2;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { parseClx as a, characterSize as i, PieceTable as n, characterOffset as r, Piece as t };
|
package/dist/prop/chp.d.cts
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { Color } from "document-schema.js";
|
|
3
|
-
//#region src/prop/chp.d.ts
|
|
4
|
-
interface CharacterProperties {
|
|
5
|
-
bold?: boolean;
|
|
6
|
-
italic?: boolean;
|
|
7
|
-
underline?: boolean;
|
|
8
|
-
strike?: boolean;
|
|
9
|
-
sizePt?: number;
|
|
10
|
-
color?: Color;
|
|
11
|
-
fontFamily?: string;
|
|
12
|
-
/** The istd of a character style applied by sprmCIstd, carried so a caller can resolve the style's own name. */
|
|
13
|
-
istd?: number;
|
|
14
|
-
}
|
|
15
|
-
declare function applyCharacterSprms(prls: readonly Prl[], into: CharacterProperties, fonts?: readonly string[]): CharacterProperties;
|
|
16
|
-
declare function characterIstdFromGrpprl(prls: readonly Prl[]): number | undefined;
|
|
17
|
-
//#endregion
|
|
1
|
+
import { n as applyCharacterSprms, r as characterIstdFromGrpprl, t as CharacterProperties } from "../chp-BpCqpb7V.cjs";
|
|
18
2
|
export { CharacterProperties, applyCharacterSprms, characterIstdFromGrpprl };
|
package/dist/prop/chp.d.ts
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { Color } from "document-schema.js";
|
|
3
|
-
//#region src/prop/chp.d.ts
|
|
4
|
-
interface CharacterProperties {
|
|
5
|
-
bold?: boolean;
|
|
6
|
-
italic?: boolean;
|
|
7
|
-
underline?: boolean;
|
|
8
|
-
strike?: boolean;
|
|
9
|
-
sizePt?: number;
|
|
10
|
-
color?: Color;
|
|
11
|
-
fontFamily?: string;
|
|
12
|
-
/** The istd of a character style applied by sprmCIstd, carried so a caller can resolve the style's own name. */
|
|
13
|
-
istd?: number;
|
|
14
|
-
}
|
|
15
|
-
declare function applyCharacterSprms(prls: readonly Prl[], into: CharacterProperties, fonts?: readonly string[]): CharacterProperties;
|
|
16
|
-
declare function characterIstdFromGrpprl(prls: readonly Prl[]): number | undefined;
|
|
17
|
-
//#endregion
|
|
1
|
+
import { n as applyCharacterSprms, r as characterIstdFromGrpprl, t as CharacterProperties } from "../chp-B6AOh85P.js";
|
|
18
2
|
export { CharacterProperties, applyCharacterSprms, characterIstdFromGrpprl };
|
package/dist/prop/fkp.d.cts
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Every FKP is exactly one 512-byte page, whatever the compound file's own sector size. */
|
|
3
|
-
declare const FKP_PAGE_SIZE = 512;
|
|
4
|
-
interface ChpxFkp {
|
|
5
|
-
readonly rgfc: readonly number[];
|
|
6
|
-
/** The Chpx's grpprl for run `index`, or undefined when the run's rgb entry is zero and it carries no exception. */
|
|
7
|
-
grpprl(index: number): Uint8Array | undefined;
|
|
8
|
-
}
|
|
9
|
-
interface PapxRecord {
|
|
10
|
-
readonly istd: number;
|
|
11
|
-
readonly grpprl: Uint8Array;
|
|
12
|
-
}
|
|
13
|
-
interface PapxFkp {
|
|
14
|
-
readonly rgfc: readonly number[];
|
|
15
|
-
/** The PapxInFkp for paragraph `index`, or undefined when its BxPap.bOffset is zero and the paragraph takes the defaults. */
|
|
16
|
-
papx(index: number): PapxRecord | undefined;
|
|
17
|
-
}
|
|
18
|
-
declare function parseChpxFkp(page: Uint8Array): ChpxFkp;
|
|
19
|
-
declare function parsePapxFkp(page: Uint8Array): PapxFkp;
|
|
20
|
-
interface PapxLookup extends PapxRecord {
|
|
21
|
-
/** The byte offset one past the end of the paragraph this record covers -- PapxFkp.rgfc[k + 1], the paragraph boundary [MS-DOC] 2.4.2 derives its own from. */
|
|
22
|
-
readonly fcLim: number;
|
|
23
|
-
}
|
|
24
|
-
declare class PropertyBinTable {
|
|
25
|
-
#private;
|
|
26
|
-
constructor(wordDocument: Uint8Array, plc: Uint8Array, what: string);
|
|
27
|
-
/** The direct character-formatting grpprl covering `fc`, or undefined when the offset is outside the table or its run carries no exception. */
|
|
28
|
-
chpxGrpprl(fc: number): Uint8Array | undefined;
|
|
29
|
-
/** The direct paragraph-formatting record covering `fc`, or undefined when the offset is outside the table or its paragraph carries no exception. */
|
|
30
|
-
papx(fc: number): PapxLookup | undefined;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
1
|
+
import { a as PapxRecord, c as parsePapxFkp, i as PapxLookup, n as FKP_PAGE_SIZE, o as PropertyBinTable, r as PapxFkp, s as parseChpxFkp, t as ChpxFkp } from "../fkp-I-laf-8y.cjs";
|
|
33
2
|
export { ChpxFkp, FKP_PAGE_SIZE, PapxFkp, PapxLookup, PapxRecord, PropertyBinTable, parseChpxFkp, parsePapxFkp };
|
package/dist/prop/fkp.d.ts
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Every FKP is exactly one 512-byte page, whatever the compound file's own sector size. */
|
|
3
|
-
declare const FKP_PAGE_SIZE = 512;
|
|
4
|
-
interface ChpxFkp {
|
|
5
|
-
readonly rgfc: readonly number[];
|
|
6
|
-
/** The Chpx's grpprl for run `index`, or undefined when the run's rgb entry is zero and it carries no exception. */
|
|
7
|
-
grpprl(index: number): Uint8Array | undefined;
|
|
8
|
-
}
|
|
9
|
-
interface PapxRecord {
|
|
10
|
-
readonly istd: number;
|
|
11
|
-
readonly grpprl: Uint8Array;
|
|
12
|
-
}
|
|
13
|
-
interface PapxFkp {
|
|
14
|
-
readonly rgfc: readonly number[];
|
|
15
|
-
/** The PapxInFkp for paragraph `index`, or undefined when its BxPap.bOffset is zero and the paragraph takes the defaults. */
|
|
16
|
-
papx(index: number): PapxRecord | undefined;
|
|
17
|
-
}
|
|
18
|
-
declare function parseChpxFkp(page: Uint8Array): ChpxFkp;
|
|
19
|
-
declare function parsePapxFkp(page: Uint8Array): PapxFkp;
|
|
20
|
-
interface PapxLookup extends PapxRecord {
|
|
21
|
-
/** The byte offset one past the end of the paragraph this record covers -- PapxFkp.rgfc[k + 1], the paragraph boundary [MS-DOC] 2.4.2 derives its own from. */
|
|
22
|
-
readonly fcLim: number;
|
|
23
|
-
}
|
|
24
|
-
declare class PropertyBinTable {
|
|
25
|
-
#private;
|
|
26
|
-
constructor(wordDocument: Uint8Array, plc: Uint8Array, what: string);
|
|
27
|
-
/** The direct character-formatting grpprl covering `fc`, or undefined when the offset is outside the table or its run carries no exception. */
|
|
28
|
-
chpxGrpprl(fc: number): Uint8Array | undefined;
|
|
29
|
-
/** The direct paragraph-formatting record covering `fc`, or undefined when the offset is outside the table or its paragraph carries no exception. */
|
|
30
|
-
papx(fc: number): PapxLookup | undefined;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
1
|
+
import { a as PapxRecord, c as parsePapxFkp, i as PapxLookup, n as FKP_PAGE_SIZE, o as PropertyBinTable, r as PapxFkp, s as parseChpxFkp, t as ChpxFkp } from "../fkp-I-laf-8y.js";
|
|
33
2
|
export { ChpxFkp, FKP_PAGE_SIZE, PapxFkp, PapxLookup, PapxRecord, PropertyBinTable, parseChpxFkp, parsePapxFkp };
|
package/dist/prop/pap.cjs
CHANGED
|
@@ -36,7 +36,7 @@ const SPRM_P_ILVL = 9738;
|
|
|
36
36
|
const SPRM_P_ILFO = 17931;
|
|
37
37
|
/** sprmPItap: the paragraph's own table depth -- read only far enough to detect a depth greater than 1 (a table nested inside a table cell), which this package refuses rather than mis-reads. */
|
|
38
38
|
const SPRM_P_ITAP = 26185;
|
|
39
|
-
/** sprmPFInnerTableCell / sprmPFInnerTtp: a nested table's own cell-ending or row-ending mark
|
|
39
|
+
/** sprmPFInnerTableCell / sprmPFInnerTtp: a nested table's (table depth greater than 1) own cell-ending or row-ending mark, [MS-DOC] 2.4.3's Overview of Tables -- the paragraph-mark (0x000D) analogues of sprmPFInTable's cell-mark (0x0007) boundary and sprmPFTtp's row-mark at depth 1. */
|
|
40
40
|
const SPRM_P_F_INNER_TABLE_CELL = 9291;
|
|
41
41
|
const SPRM_P_F_INNER_TTP = 9292;
|
|
42
42
|
const TWIPS_PER_POINT = 20;
|
|
@@ -135,7 +135,9 @@ function applyParagraphSprms(prls, into) {
|
|
|
135
135
|
into.tableDepth = require_bytes.readUint32LE(prl.operand, 0);
|
|
136
136
|
break;
|
|
137
137
|
case SPRM_P_F_INNER_TABLE_CELL:
|
|
138
|
-
|
|
138
|
+
into.innerTableCellMark = require_bytes.readUint8(prl.operand, 0) !== 0;
|
|
139
|
+
break;
|
|
140
|
+
case SPRM_P_F_INNER_TTP: into.innerTtpMark = require_bytes.readUint8(prl.operand, 0) !== 0;
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
return into;
|
package/dist/prop/pap.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as applyParagraphSprms, t as ParagraphProperties } from "../pap-
|
|
1
|
+
import { n as applyParagraphSprms, t as ParagraphProperties } from "../pap-BQ2E17K9.cjs";
|
|
2
2
|
export { ParagraphProperties, applyParagraphSprms };
|
package/dist/prop/pap.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as applyParagraphSprms, t as ParagraphProperties } from "../pap-
|
|
1
|
+
import { n as applyParagraphSprms, t as ParagraphProperties } from "../pap-iWFIpCdo.js";
|
|
2
2
|
export { ParagraphProperties, applyParagraphSprms };
|