@unisim/doc 0.1.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 +91 -0
- package/dist/convert.d.ts +54 -0
- package/dist/convert.d.ts.map +1 -0
- package/dist/convert.js +216 -0
- package/dist/convert.js.map +1 -0
- package/dist/image.d.ts +17 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +66 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/merge.d.ts +14 -0
- package/dist/merge.d.ts.map +1 -0
- package/dist/merge.js +51 -0
- package/dist/merge.js.map +1 -0
- package/dist/metrics.d.ts +19 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +151 -0
- package/dist/metrics.js.map +1 -0
- package/dist/model.d.ts +114 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +121 -0
- package/dist/model.js.map +1 -0
- package/dist/pdfcore.d.ts +118 -0
- package/dist/pdfcore.d.ts.map +1 -0
- package/dist/pdfcore.js +398 -0
- package/dist/pdfcore.js.map +1 -0
- package/dist/read/csv.d.ts +17 -0
- package/dist/read/csv.d.ts.map +1 -0
- package/dist/read/csv.js +167 -0
- package/dist/read/csv.js.map +1 -0
- package/dist/read/doc.d.ts +3 -0
- package/dist/read/doc.d.ts.map +1 -0
- package/dist/read/doc.js +360 -0
- package/dist/read/doc.js.map +1 -0
- package/dist/read/docx.d.ts +3 -0
- package/dist/read/docx.d.ts.map +1 -0
- package/dist/read/docx.js +455 -0
- package/dist/read/docx.js.map +1 -0
- package/dist/read/html.d.ts +4 -0
- package/dist/read/html.d.ts.map +1 -0
- package/dist/read/html.js +236 -0
- package/dist/read/html.js.map +1 -0
- package/dist/read/json.d.ts +9 -0
- package/dist/read/json.d.ts.map +1 -0
- package/dist/read/json.js +105 -0
- package/dist/read/json.js.map +1 -0
- package/dist/read/markdown.d.ts +4 -0
- package/dist/read/markdown.d.ts.map +1 -0
- package/dist/read/markdown.js +247 -0
- package/dist/read/markdown.js.map +1 -0
- package/dist/read/odt.d.ts +3 -0
- package/dist/read/odt.d.ts.map +1 -0
- package/dist/read/odt.js +359 -0
- package/dist/read/odt.js.map +1 -0
- package/dist/read/rtf.d.ts +3 -0
- package/dist/read/rtf.d.ts.map +1 -0
- package/dist/read/rtf.js +341 -0
- package/dist/read/rtf.js.map +1 -0
- package/dist/read/text.d.ts +4 -0
- package/dist/read/text.d.ts.map +1 -0
- package/dist/read/text.js +62 -0
- package/dist/read/text.js.map +1 -0
- package/dist/unzip.d.ts +23 -0
- package/dist/unzip.d.ts.map +1 -0
- package/dist/unzip.js +152 -0
- package/dist/unzip.js.map +1 -0
- package/dist/write/data.d.ts +16 -0
- package/dist/write/data.d.ts.map +1 -0
- package/dist/write/data.js +89 -0
- package/dist/write/data.js.map +1 -0
- package/dist/write/pdf.d.ts +10 -0
- package/dist/write/pdf.d.ts.map +1 -0
- package/dist/write/pdf.js +696 -0
- package/dist/write/pdf.js.map +1 -0
- package/dist/write/pdfSettings.d.ts +13 -0
- package/dist/write/pdfSettings.d.ts.map +1 -0
- package/dist/write/pdfSettings.js +26 -0
- package/dist/write/pdfSettings.js.map +1 -0
- package/dist/write/text.d.ts +5 -0
- package/dist/write/text.d.ts.map +1 -0
- package/dist/write/text.js +341 -0
- package/dist/write/text.js.map +1 -0
- package/dist/xml.d.ts +22 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +83 -0
- package/dist/xml.js.map +1 -0
- package/package.json +31 -0
package/dist/read/doc.js
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// DOC (Word 97–2003) → RichDoc, as TEXT ONLY. That limit is the whole story.
|
|
3
|
+
//
|
|
4
|
+
// A .doc is not an older .docx. It is a Microsoft Compound File — a FAT
|
|
5
|
+
// filesystem in a file, with directories and a sector allocation table — and
|
|
6
|
+
// inside it the `WordDocument` stream is a C struct dump from 1997. The text is
|
|
7
|
+
// not in one place and not in one encoding: a PIECE TABLE maps ranges of the
|
|
8
|
+
// document onto byte ranges of the stream, each piece independently either
|
|
9
|
+
// CP1252 or UTF-16, and the pieces are in storage order rather than reading
|
|
10
|
+
// order. Recovering the words means walking that table. Recovering the
|
|
11
|
+
// FORMATTING means also walking the CHPX/PAPX binary property exception runs
|
|
12
|
+
// through a two-level page tree of 512-byte bins — a second machine of similar
|
|
13
|
+
// size, for bold and headings.
|
|
14
|
+
//
|
|
15
|
+
// So: this reads the words, in the right order, in the right encoding, and
|
|
16
|
+
// stops. Paragraph breaks are kept; bold, headings, tables, lists and pictures
|
|
17
|
+
// are not, and the UI says so BEFORE the button is pressed rather than leaving
|
|
18
|
+
// somebody to notice their headings vanished on page three.
|
|
19
|
+
//
|
|
20
|
+
// The honest alternative is telling people to open it in Word and save as
|
|
21
|
+
// .docx, which the notice does — but a .doc you are handed and cannot open
|
|
22
|
+
// still converts to something readable here, and that is worth having.
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
import { addNotice, tidy } from '../model.js';
|
|
25
|
+
/** The compound-file signature: D0 CF 11 E0 A1 B1 1A E1. */
|
|
26
|
+
const OLE_SIGNATURE = [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1];
|
|
27
|
+
export async function readDoc(file) {
|
|
28
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
29
|
+
if (!OLE_SIGNATURE.every((b, i) => bytes[i] === b)) {
|
|
30
|
+
// RTF and DOCX both get saved with a .doc extension often enough to be
|
|
31
|
+
// worth naming rather than failing as "damaged".
|
|
32
|
+
if (bytes[0] === 0x7b && bytes[1] === 0x5c) {
|
|
33
|
+
throw new Error('This is really an RTF file with a .doc name — rename it to .rtf and it will convert.');
|
|
34
|
+
}
|
|
35
|
+
if (bytes[0] === 0x50 && bytes[1] === 0x4b) {
|
|
36
|
+
throw new Error('This is really a .docx with a .doc name — rename it to .docx and it will convert in full.');
|
|
37
|
+
}
|
|
38
|
+
throw new Error('This doesn’t look like a Word document inside.');
|
|
39
|
+
}
|
|
40
|
+
const cfb = new CompoundFile(bytes);
|
|
41
|
+
const stream = cfb.read('WordDocument');
|
|
42
|
+
if (!stream)
|
|
43
|
+
throw new Error('This compound file has no Word document in it.');
|
|
44
|
+
const doc = { blocks: [], notices: [] };
|
|
45
|
+
const text = extractText(stream, cfb);
|
|
46
|
+
for (const piece of splitParagraphs(text)) {
|
|
47
|
+
doc.blocks.push(piece.kind === 'break'
|
|
48
|
+
? { kind: 'pagebreak' }
|
|
49
|
+
: { kind: 'paragraph', runs: [{ text: piece.text }] });
|
|
50
|
+
}
|
|
51
|
+
if (!doc.blocks.length)
|
|
52
|
+
throw new Error('No readable text was found in this .doc.');
|
|
53
|
+
addNotice(doc, 'This is the old Word format, so only its TEXT could be read — bold, headings, lists, tables, page breaks and pictures are not in the result. Opening it in Word and saving as .docx keeps all of that.');
|
|
54
|
+
// ⚠️ Said separately, and said even though it will not apply to most files,
|
|
55
|
+
// because it is the one loss here that can EMBARRASS somebody rather than
|
|
56
|
+
// merely disappoint them. A .doc's deleted text is stored as ordinary text in
|
|
57
|
+
// the piece table with a revision flag hung off it in the CHPX runs, and this
|
|
58
|
+
// reader does not walk those — so a document with tracked changes turned on
|
|
59
|
+
// converts with the deletions still in it, reading as though they were never
|
|
60
|
+
// made. Detecting it properly needs the whole property-exception machine that
|
|
61
|
+
// the header explains is out of scope, so it is disclosed instead of guessed
|
|
62
|
+
// at. It sits beside the file on the row, before anyone sends it on.
|
|
63
|
+
addNotice(doc, 'If this document had tracked changes in it, text that was deleted may still appear — the old format stores deletions as ordinary text, and only Word can tell them apart. Check the result before sending it on.');
|
|
64
|
+
doc.title = file.name.replace(/\.docx?$/i, '');
|
|
65
|
+
return tidy(doc);
|
|
66
|
+
}
|
|
67
|
+
// ── The piece table ──────────────────────────────────────────────────────────
|
|
68
|
+
/**
|
|
69
|
+
* Walk the FIB and the piece table to reassemble the document text.
|
|
70
|
+
*
|
|
71
|
+
* The route, which is not guessable from the bytes:
|
|
72
|
+
* 1. The FIB at offset 0 says which stream the text lives in (`fWhichTblStm`
|
|
73
|
+
* picks `1Table` or `0Table`) and where the CLX is inside it.
|
|
74
|
+
* 2. The CLX is a list of properties followed by ONE `Pcdt` (type 0x02),
|
|
75
|
+
* which holds the piece table.
|
|
76
|
+
* 3. The piece table is a PLCF: n+1 character positions, then n 8-byte
|
|
77
|
+
* descriptors. Descriptor bytes 2–5 are an `fc` whose BIT 30 means
|
|
78
|
+
* "this piece is CP1252, and the real offset is fc/2".
|
|
79
|
+
*/
|
|
80
|
+
function extractText(wordStream, cfb) {
|
|
81
|
+
const view = new DataView(wordStream.buffer, wordStream.byteOffset, wordStream.byteLength);
|
|
82
|
+
const flags = view.getUint16(0x000a, true);
|
|
83
|
+
const useTable1 = (flags & 0x0200) !== 0;
|
|
84
|
+
const table = cfb.read(useTable1 ? '1Table' : '0Table') ?? cfb.read('0Table') ?? cfb.read('1Table');
|
|
85
|
+
if (!table) {
|
|
86
|
+
// Word 6/95 had no table stream at all and stored text unpiece-tabled.
|
|
87
|
+
return decodeCp1252(wordStream.subarray(view.getUint32(0x0018, true), view.getUint32(0x001c, true)));
|
|
88
|
+
}
|
|
89
|
+
const clxOffset = view.getUint32(0x01a2, true);
|
|
90
|
+
const clxLength = view.getUint32(0x01a6, true);
|
|
91
|
+
if (clxOffset + clxLength > table.length || clxLength < 5) {
|
|
92
|
+
throw new Error('This .doc’s index is damaged — the text can’t be located.');
|
|
93
|
+
}
|
|
94
|
+
const clx = table.subarray(clxOffset, clxOffset + clxLength);
|
|
95
|
+
// Skip the leading Prc blocks (type 0x01, each with a 2-byte length) to find
|
|
96
|
+
// the one Pcdt (type 0x02) that follows them.
|
|
97
|
+
let at = 0;
|
|
98
|
+
while (at < clx.length && clx[at] === 0x01) {
|
|
99
|
+
const size = new DataView(clx.buffer, clx.byteOffset + at + 1, 2).getUint16(0, true);
|
|
100
|
+
at += 3 + size;
|
|
101
|
+
}
|
|
102
|
+
if (clx[at] !== 0x02)
|
|
103
|
+
throw new Error('This .doc’s piece table is missing.');
|
|
104
|
+
const clxView = new DataView(clx.buffer, clx.byteOffset, clx.byteLength);
|
|
105
|
+
const pieceTableSize = clxView.getUint32(at + 1, true);
|
|
106
|
+
const pieces = clx.subarray(at + 5, at + 5 + pieceTableSize);
|
|
107
|
+
const pieceView = new DataView(pieces.buffer, pieces.byteOffset, pieces.byteLength);
|
|
108
|
+
// n pieces means n+1 positions (4 bytes each) and n descriptors (8 each).
|
|
109
|
+
const count = Math.floor((pieces.length - 4) / 12);
|
|
110
|
+
if (count <= 0)
|
|
111
|
+
throw new Error('This .doc’s piece table is empty.');
|
|
112
|
+
let out = '';
|
|
113
|
+
for (let i = 0; i < count; i += 1) {
|
|
114
|
+
const start = pieceView.getUint32(i * 4, true);
|
|
115
|
+
const end = pieceView.getUint32((i + 1) * 4, true);
|
|
116
|
+
const descriptor = 4 * (count + 1) + i * 8;
|
|
117
|
+
const fc = pieceView.getUint32(descriptor + 2, true);
|
|
118
|
+
// Bit 30 is the compression flag, and it is the crux of the whole format.
|
|
119
|
+
const compressed = (fc & 0x40000000) !== 0;
|
|
120
|
+
const offset = compressed ? (fc & 0x3fffffff) / 2 : fc & 0x3fffffff;
|
|
121
|
+
const characters = end - start;
|
|
122
|
+
if (characters <= 0)
|
|
123
|
+
continue;
|
|
124
|
+
const byteLength = compressed ? characters : characters * 2;
|
|
125
|
+
const slice = wordStream.subarray(offset, offset + byteLength);
|
|
126
|
+
out += compressed ? decodeCp1252(slice) : decodeUtf16(slice);
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Windows-1252, which is what "compressed" means here — one byte per character,
|
|
132
|
+
* NOT ASCII. `TextDecoder('windows-1252')` is in every browser and gets the
|
|
133
|
+
* 0x80–0x9F block (smart quotes, dashes) right, which is exactly the range a
|
|
134
|
+
* Word document is full of and the range a naive `String.fromCharCode` mangles.
|
|
135
|
+
*/
|
|
136
|
+
function decodeCp1252(bytes) {
|
|
137
|
+
return new TextDecoder('windows-1252').decode(bytes);
|
|
138
|
+
}
|
|
139
|
+
function decodeUtf16(bytes) {
|
|
140
|
+
return new TextDecoder('utf-16le').decode(bytes);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Word's control characters, turned back into paragraphs.
|
|
144
|
+
*
|
|
145
|
+
* \r is the paragraph mark — NOT \n, which does not appear. \x07 ends a table
|
|
146
|
+
* cell and a table row; \x0c is a page break; \x0b a line break within a
|
|
147
|
+
* paragraph; \x13–\x15 wrap field instructions, whose contents are code
|
|
148
|
+
* (`HYPERLINK "…"`, `PAGE \\* MERGEFORMAT`) rather than text and would
|
|
149
|
+
* otherwise appear inline as gibberish.
|
|
150
|
+
*/
|
|
151
|
+
function splitParagraphs(text) {
|
|
152
|
+
const pieces = [];
|
|
153
|
+
let cleaned = '';
|
|
154
|
+
let inFieldInstruction = false;
|
|
155
|
+
/** Turn whatever text has accumulated into paragraph pieces. */
|
|
156
|
+
const flush = () => {
|
|
157
|
+
const paragraphs = cleaned
|
|
158
|
+
.split('\r')
|
|
159
|
+
// A literal NUL pads the tail of the last piece in a great many files.
|
|
160
|
+
// Left in, it draws as a hollow box in the PDF rather than as nothing.
|
|
161
|
+
.map((p) => p.replace(/\t/g, ' ').replace(/\0/g, '').trim())
|
|
162
|
+
.filter((p, i, all) => p.length > 0 || (i > 0 && all[i - 1].length > 0));
|
|
163
|
+
for (const text of paragraphs)
|
|
164
|
+
pieces.push({ kind: 'text', text });
|
|
165
|
+
cleaned = '';
|
|
166
|
+
};
|
|
167
|
+
for (const ch of text) {
|
|
168
|
+
const code = ch.charCodeAt(0);
|
|
169
|
+
if (code === 0x13) {
|
|
170
|
+
inFieldInstruction = true;
|
|
171
|
+
continue;
|
|
172
|
+
} // field begin
|
|
173
|
+
if (code === 0x14) {
|
|
174
|
+
inFieldInstruction = false;
|
|
175
|
+
continue;
|
|
176
|
+
} // separator: result follows
|
|
177
|
+
if (code === 0x15) {
|
|
178
|
+
inFieldInstruction = false;
|
|
179
|
+
continue;
|
|
180
|
+
} // field end
|
|
181
|
+
if (inFieldInstruction)
|
|
182
|
+
continue;
|
|
183
|
+
if (code === 0x07) {
|
|
184
|
+
cleaned += '\r';
|
|
185
|
+
continue;
|
|
186
|
+
} // cell/row end
|
|
187
|
+
if (code === 0x0b) {
|
|
188
|
+
cleaned += '\n';
|
|
189
|
+
continue;
|
|
190
|
+
} // line break
|
|
191
|
+
// An explicit page-break character — what Word writes for Ctrl+Enter. It
|
|
192
|
+
// becomes a real break rather than a paragraph mark, because a .doc whose
|
|
193
|
+
// author broke each section by hand otherwise arrives as one unbroken run.
|
|
194
|
+
//
|
|
195
|
+
// ⚠️ THIS CATCHES ONLY ONE OF THE TWO WAYS A .doc HOLDS A PAGE BREAK. The
|
|
196
|
+
// other is a paragraph PROPERTY in the PAPX runs — which is what
|
|
197
|
+
// LibreOffice writes, and what the file header explains this reader does
|
|
198
|
+
// not walk. So some page breaks survive and some do not, and the notice on
|
|
199
|
+
// the row lists page breaks among what the old format loses.
|
|
200
|
+
if (code === 0x0c) {
|
|
201
|
+
flush();
|
|
202
|
+
pieces.push({ kind: 'break' });
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (code === 0x1e) {
|
|
206
|
+
cleaned += '-';
|
|
207
|
+
continue;
|
|
208
|
+
} // non-breaking hyphen
|
|
209
|
+
if (code === 0x1f)
|
|
210
|
+
continue; // optional hyphen
|
|
211
|
+
if (code === 0x02)
|
|
212
|
+
continue; // footnote mark
|
|
213
|
+
if (code < 0x20 && code !== 0x09 && code !== 0x0d)
|
|
214
|
+
continue;
|
|
215
|
+
cleaned += ch;
|
|
216
|
+
}
|
|
217
|
+
flush();
|
|
218
|
+
return pieces;
|
|
219
|
+
}
|
|
220
|
+
// ── The compound file ────────────────────────────────────────────────────────
|
|
221
|
+
/**
|
|
222
|
+
* Enough of the Microsoft Compound File format to pull two named streams out.
|
|
223
|
+
*
|
|
224
|
+
* It is a filesystem: a header, a FAT of sector chains, a directory of entries,
|
|
225
|
+
* and — for anything under 4096 bytes — a second miniature allocation inside a
|
|
226
|
+
* ministream, because the designers did not want a 64-byte stream costing a
|
|
227
|
+
* 512-byte sector. Both paths are needed: `1Table` is routinely large and
|
|
228
|
+
* `WordDocument` always is, but a small document puts one of them in the mini
|
|
229
|
+
* FAT and reading it as a normal chain returns garbage.
|
|
230
|
+
*/
|
|
231
|
+
class CompoundFile {
|
|
232
|
+
bytes;
|
|
233
|
+
view;
|
|
234
|
+
sectorSize;
|
|
235
|
+
miniSectorSize;
|
|
236
|
+
fat = [];
|
|
237
|
+
miniFat = [];
|
|
238
|
+
directory = [];
|
|
239
|
+
miniStream = new Uint8Array(0);
|
|
240
|
+
constructor(bytes) {
|
|
241
|
+
this.bytes = bytes;
|
|
242
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
243
|
+
this.sectorSize = 1 << this.view.getUint16(0x1e, true);
|
|
244
|
+
this.miniSectorSize = 1 << this.view.getUint16(0x20, true);
|
|
245
|
+
this.readFat();
|
|
246
|
+
this.readDirectory();
|
|
247
|
+
}
|
|
248
|
+
read(name) {
|
|
249
|
+
const entry = this.directory.find((e) => e.name === name);
|
|
250
|
+
if (!entry || entry.size === 0)
|
|
251
|
+
return null;
|
|
252
|
+
return entry.size < 4096 && this.miniStream.length
|
|
253
|
+
? this.readChain(entry.start, entry.size, this.miniFat, this.miniSectorSize, this.miniStream)
|
|
254
|
+
: this.readChain(entry.start, entry.size, this.fat, this.sectorSize, null);
|
|
255
|
+
}
|
|
256
|
+
sectorAt(index) {
|
|
257
|
+
return (index + 1) * this.sectorSize;
|
|
258
|
+
}
|
|
259
|
+
readFat() {
|
|
260
|
+
const difatCount = this.view.getUint32(0x48, true);
|
|
261
|
+
const sectors = [];
|
|
262
|
+
// The first 109 FAT sector numbers are in the header itself; anything
|
|
263
|
+
// beyond that continues in DIFAT sectors, which only very large files need.
|
|
264
|
+
for (let i = 0; i < 109; i += 1) {
|
|
265
|
+
const sector = this.view.getUint32(0x4c + i * 4, true);
|
|
266
|
+
if (sector === 0xffffffff)
|
|
267
|
+
break;
|
|
268
|
+
sectors.push(sector);
|
|
269
|
+
}
|
|
270
|
+
let difat = this.view.getUint32(0x44, true);
|
|
271
|
+
for (let n = 0; n < difatCount && difat !== 0xffffffff && difat !== 0xfffffffe; n += 1) {
|
|
272
|
+
const base = this.sectorAt(difat);
|
|
273
|
+
const perSector = this.sectorSize / 4 - 1;
|
|
274
|
+
for (let i = 0; i < perSector; i += 1) {
|
|
275
|
+
const sector = this.view.getUint32(base + i * 4, true);
|
|
276
|
+
if (sector === 0xffffffff)
|
|
277
|
+
break;
|
|
278
|
+
sectors.push(sector);
|
|
279
|
+
}
|
|
280
|
+
difat = this.view.getUint32(base + perSector * 4, true);
|
|
281
|
+
}
|
|
282
|
+
for (const sector of sectors) {
|
|
283
|
+
const base = this.sectorAt(sector);
|
|
284
|
+
if (base + this.sectorSize > this.bytes.length)
|
|
285
|
+
break;
|
|
286
|
+
for (let i = 0; i < this.sectorSize / 4; i += 1) {
|
|
287
|
+
this.fat.push(this.view.getUint32(base + i * 4, true));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
let miniFatSector = this.view.getUint32(0x3c, true);
|
|
291
|
+
const miniFatCount = this.view.getUint32(0x40, true);
|
|
292
|
+
for (let n = 0; n < miniFatCount && miniFatSector < 0xfffffffa; n += 1) {
|
|
293
|
+
const base = this.sectorAt(miniFatSector);
|
|
294
|
+
if (base + this.sectorSize > this.bytes.length)
|
|
295
|
+
break;
|
|
296
|
+
for (let i = 0; i < this.sectorSize / 4; i += 1) {
|
|
297
|
+
this.miniFat.push(this.view.getUint32(base + i * 4, true));
|
|
298
|
+
}
|
|
299
|
+
miniFatSector = this.fat[miniFatSector] ?? 0xfffffffe;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
readDirectory() {
|
|
303
|
+
const first = this.view.getUint32(0x30, true);
|
|
304
|
+
const raw = this.readChain(first, Number.MAX_SAFE_INTEGER, this.fat, this.sectorSize, null);
|
|
305
|
+
const view = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);
|
|
306
|
+
for (let at = 0; at + 128 <= raw.length; at += 128) {
|
|
307
|
+
const nameLength = view.getUint16(at + 64, true);
|
|
308
|
+
if (nameLength < 2 || nameLength > 64)
|
|
309
|
+
continue;
|
|
310
|
+
// The name is UTF-16 and the length INCLUDES its terminator, which is why
|
|
311
|
+
// this is `nameLength - 2` and not `nameLength`.
|
|
312
|
+
const name = new TextDecoder('utf-16le').decode(raw.subarray(at, at + nameLength - 2));
|
|
313
|
+
const type = raw[at + 66];
|
|
314
|
+
const start = view.getUint32(at + 116, true);
|
|
315
|
+
const size = view.getUint32(at + 120, true);
|
|
316
|
+
this.directory.push({ name, type, start, size });
|
|
317
|
+
}
|
|
318
|
+
// Entry 0 is the root, and its "stream" is the ministream that every small
|
|
319
|
+
// stream is carved out of.
|
|
320
|
+
const root = this.directory[0];
|
|
321
|
+
if (root && root.size > 0) {
|
|
322
|
+
this.miniStream = this.readChain(root.start, root.size, this.fat, this.sectorSize, null);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Follow a sector chain.
|
|
327
|
+
*
|
|
328
|
+
* The guard on `seen` is not paranoia about hostile files: a truncated
|
|
329
|
+
* download produces a FAT whose chain loops back on itself, and without it
|
|
330
|
+
* this allocates until the tab dies.
|
|
331
|
+
*/
|
|
332
|
+
readChain(start, size, fat, sectorSize, container) {
|
|
333
|
+
const parts = [];
|
|
334
|
+
const seen = new Set();
|
|
335
|
+
let sector = start;
|
|
336
|
+
let remaining = size;
|
|
337
|
+
while (sector < 0xfffffffa && remaining > 0) {
|
|
338
|
+
if (seen.has(sector))
|
|
339
|
+
break;
|
|
340
|
+
seen.add(sector);
|
|
341
|
+
const base = container ? sector * sectorSize : this.sectorAt(sector);
|
|
342
|
+
const source = container ?? this.bytes;
|
|
343
|
+
if (base >= source.length)
|
|
344
|
+
break;
|
|
345
|
+
const take = Math.min(sectorSize, remaining, source.length - base);
|
|
346
|
+
parts.push(source.subarray(base, base + take));
|
|
347
|
+
remaining -= take;
|
|
348
|
+
sector = fat[sector] ?? 0xfffffffe;
|
|
349
|
+
}
|
|
350
|
+
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
351
|
+
const out = new Uint8Array(total);
|
|
352
|
+
let at = 0;
|
|
353
|
+
for (const part of parts) {
|
|
354
|
+
out.set(part, at);
|
|
355
|
+
at += part.length;
|
|
356
|
+
}
|
|
357
|
+
return out;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/read/doc.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,uEAAuE;AACvE,6EAA6E;AAC7E,+EAA+E;AAC/E,+BAA+B;AAC/B,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,+EAA+E;AAC/E,4DAA4D;AAC5D,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,uEAAuE;AACvE,8EAA8E;AAE9E,OAAO,EAAE,SAAS,EAAE,IAAI,EAA4B,MAAM,aAAa,CAAA;AAEvE,4DAA4D;AAC5D,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AActE,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,I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