ooxml-core 0.12.0 → 0.13.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/crypto/index.cjs +118 -31
- package/dist/crypto/index.mjs +118 -31
- package/dist/docx/load/index.cjs +1273 -110
- package/dist/docx/load/index.mjs +1273 -110
- package/dist/docx/load/legacy-doc.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +1479 -304
- package/dist/pptx/automation/index.d.ts +1 -1
- package/dist/pptx/automation/index.mjs +1479 -304
- package/dist/pptx/chunks/{index-LoCVDu8Z.d.ts → index-CT9y69AZ.d.ts} +22 -12
- package/dist/pptx/chunks/index-CT9y69AZ.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +307 -152
- package/dist/pptx/cli/index.mjs +307 -152
- package/dist/pptx/index.cjs +1479 -304
- package/dist/pptx/index.d.ts +1 -1
- package/dist/pptx/index.mjs +1479 -304
- package/dist/visio/index.cjs +7498 -127
- package/dist/visio/index.d.ts +3 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +7497 -128
- package/dist/visio/legacy.d.ts +10 -0
- package/dist/visio/legacy.d.ts.map +1 -0
- package/dist/visio/load.d.ts +5 -0
- package/dist/visio/load.d.ts.map +1 -0
- package/dist/visio/model.d.ts +1 -1
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +144 -52
- package/dist/xlsx/load/index.mjs +144 -52
- package/package.json +2 -2
- package/dist/pptx/chunks/index-LoCVDu8Z.d.ts.map +0 -1
package/dist/xlsx/load/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function isOoxmlCryptoError(error) {
|
|
|
29
29
|
return code === "password-required" || code === "incorrect-password" || code === "data-integrity";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
32
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-parser-types.js
|
|
33
33
|
var OLE_MAGIC = new Uint8Array([208, 207, 17, 224, 161, 177, 26, 225]);
|
|
34
34
|
var ENDOFCHAIN = 4294967294;
|
|
35
35
|
var FREESECT = 4294967295;
|
|
@@ -47,10 +47,13 @@ var Ole2ParseError = class extends Error {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
50
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-parser-read.js
|
|
51
51
|
function parseOle2(buffer) {
|
|
52
52
|
const data = new Uint8Array(buffer);
|
|
53
53
|
const view = new DataView(buffer);
|
|
54
|
+
if (data.length < 512) {
|
|
55
|
+
throw new Ole2ParseError("Truncated OLE2 compound file header");
|
|
56
|
+
}
|
|
54
57
|
for (let i = 0; i < OLE_MAGIC.length; i++) {
|
|
55
58
|
if (data[i] !== OLE_MAGIC[i]) {
|
|
56
59
|
throw new Ole2ParseError("Not a valid OLE2 compound file");
|
|
@@ -64,8 +67,15 @@ function parseOle2(buffer) {
|
|
|
64
67
|
}
|
|
65
68
|
const sectorSizePower = view.getUint16(30, true);
|
|
66
69
|
const miniSectorSizePower = view.getUint16(32, true);
|
|
70
|
+
if (majorVersion !== 3 && majorVersion !== 4 || sectorSizePower !== (majorVersion === 3 ? 9 : 12) || miniSectorSizePower !== 6) {
|
|
71
|
+
throw new Ole2ParseError("Unsupported OLE2 version or sector size");
|
|
72
|
+
}
|
|
67
73
|
const sectorSize = 1 << sectorSizePower;
|
|
68
74
|
const miniSectorSize = 1 << miniSectorSizePower;
|
|
75
|
+
if (data.length < sectorSize || data.length % sectorSize !== 0) {
|
|
76
|
+
throw new Ole2ParseError("Truncated OLE2 sector");
|
|
77
|
+
}
|
|
78
|
+
const sectorCount = data.length / sectorSize - 1;
|
|
69
79
|
const totalFATSectors = view.getUint32(44, true);
|
|
70
80
|
const firstDirectorySector = view.getUint32(48, true);
|
|
71
81
|
const miniStreamCutoff = view.getUint32(56, true);
|
|
@@ -73,6 +83,9 @@ function parseOle2(buffer) {
|
|
|
73
83
|
const totalMiniFATSectors = view.getUint32(64, true);
|
|
74
84
|
const firstDIFATSector = view.getUint32(68, true);
|
|
75
85
|
const totalDIFATSectors = view.getUint32(72, true);
|
|
86
|
+
if (totalFATSectors > sectorCount || totalMiniFATSectors > sectorCount || totalDIFATSectors > sectorCount) {
|
|
87
|
+
throw new Ole2ParseError("Allocation table count exceeds file size");
|
|
88
|
+
}
|
|
76
89
|
function sectorOffset(sector) {
|
|
77
90
|
return (sector + 1) * sectorSize;
|
|
78
91
|
}
|
|
@@ -91,7 +104,11 @@ function parseOle2(buffer) {
|
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
let difatSector = firstDIFATSector;
|
|
107
|
+
const difatSeen = /* @__PURE__ */ new Set();
|
|
94
108
|
for (let d = 0; d < totalDIFATSectors && difatSector <= MAXREGSECT; d++) {
|
|
109
|
+
if (difatSeen.has(difatSector))
|
|
110
|
+
throw new Ole2ParseError("Circular DIFAT chain");
|
|
111
|
+
difatSeen.add(difatSector);
|
|
95
112
|
const difatData = readSector(difatSector);
|
|
96
113
|
const difatView = new DataView(difatData.buffer, difatData.byteOffset, difatData.byteLength);
|
|
97
114
|
const entriesPerSector = (sectorSize - 4) / 4;
|
|
@@ -103,11 +120,14 @@ function parseOle2(buffer) {
|
|
|
103
120
|
}
|
|
104
121
|
difatSector = difatView.getUint32(sectorSize - 4, true);
|
|
105
122
|
}
|
|
123
|
+
if (difatSeen.size !== totalDIFATSectors || fatSectors.length !== totalFATSectors || new Set(fatSectors).size !== fatSectors.length || fatSectors.some((id) => difatSeen.has(id))) {
|
|
124
|
+
throw new Ole2ParseError("Invalid DIFAT allocation table");
|
|
125
|
+
}
|
|
106
126
|
const fatEntries = [];
|
|
107
127
|
for (const fatSector of fatSectors) {
|
|
108
128
|
const fatData = readSector(fatSector);
|
|
109
129
|
const fatView = new DataView(fatData.buffer, fatData.byteOffset, fatData.byteLength);
|
|
110
|
-
for (let i = 0; i < sectorSize / 4; i++) {
|
|
130
|
+
for (let i = 0; i < sectorSize / 4 && fatEntries.length < sectorCount; i++) {
|
|
111
131
|
fatEntries.push(fatView.getUint32(i * 4, true));
|
|
112
132
|
}
|
|
113
133
|
}
|
|
@@ -121,8 +141,12 @@ function parseOle2(buffer) {
|
|
|
121
141
|
}
|
|
122
142
|
visited.add(current);
|
|
123
143
|
sectors.push(readSector(current));
|
|
124
|
-
|
|
144
|
+
if (fatEntries[current] === void 0)
|
|
145
|
+
throw new Ole2ParseError("Missing FAT chain entry");
|
|
146
|
+
current = fatEntries[current];
|
|
125
147
|
}
|
|
148
|
+
if (current !== ENDOFCHAIN)
|
|
149
|
+
throw new Ole2ParseError("Invalid FAT chain terminator");
|
|
126
150
|
const totalLength = sectors.length * sectorSize;
|
|
127
151
|
const result2 = new Uint8Array(totalLength);
|
|
128
152
|
let offset2 = 0;
|
|
@@ -133,16 +157,14 @@ function parseOle2(buffer) {
|
|
|
133
157
|
return result2;
|
|
134
158
|
}
|
|
135
159
|
function readStream(startSector, size) {
|
|
160
|
+
if (size === 0)
|
|
161
|
+
return new Uint8Array(0);
|
|
162
|
+
if (size > sectorCount * sectorSize)
|
|
163
|
+
throw new Ole2ParseError("Stream size exceeds file size");
|
|
136
164
|
const raw = readSectorChain(startSector);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (firstMiniFATSector <= MAXREGSECT && totalMiniFATSectors > 0) {
|
|
141
|
-
const miniFatRaw = readSectorChain(firstMiniFATSector);
|
|
142
|
-
const miniFatView = new DataView(miniFatRaw.buffer, miniFatRaw.byteOffset, miniFatRaw.byteLength);
|
|
143
|
-
for (let i = 0; i < miniFatRaw.length / 4; i++) {
|
|
144
|
-
miniFatEntries.push(miniFatView.getUint32(i * 4, true));
|
|
145
|
-
}
|
|
165
|
+
if (raw.length < size)
|
|
166
|
+
throw new Ole2ParseError("Truncated stream sector chain");
|
|
167
|
+
return raw.subarray(0, size);
|
|
146
168
|
}
|
|
147
169
|
const dirRaw = readSectorChain(firstDirectorySector);
|
|
148
170
|
const numEntries = Math.floor(dirRaw.length / DIR_ENTRY_SIZE);
|
|
@@ -155,6 +177,9 @@ function parseOle2(buffer) {
|
|
|
155
177
|
if (objectType === ENTRY_TYPE_EMPTY) {
|
|
156
178
|
continue;
|
|
157
179
|
}
|
|
180
|
+
if (nameLen < 2 || nameLen > 64 || nameLen % 2 !== 0 || entryView.getUint16(nameLen - 2, true) !== 0) {
|
|
181
|
+
throw new Ole2ParseError("Invalid directory entry name");
|
|
182
|
+
}
|
|
158
183
|
const nameBytes = Math.max(0, nameLen - 2);
|
|
159
184
|
let name = "";
|
|
160
185
|
for (let j = 0; j < nameBytes; j += 2) {
|
|
@@ -168,8 +193,11 @@ function parseOle2(buffer) {
|
|
|
168
193
|
const sizeLow = entryView.getUint32(120, true);
|
|
169
194
|
let size = sizeLow;
|
|
170
195
|
if (majorVersion === 4) {
|
|
171
|
-
entryView.getUint32(124, true);
|
|
172
|
-
size = sizeLow;
|
|
196
|
+
const sizeHigh = entryView.getUint32(124, true);
|
|
197
|
+
size = sizeLow + sizeHigh * 4294967296;
|
|
198
|
+
if (!Number.isSafeInteger(size) || size > sectorCount * sectorSize) {
|
|
199
|
+
throw new Ole2ParseError("Stream size exceeds supported file bounds");
|
|
200
|
+
}
|
|
173
201
|
}
|
|
174
202
|
entries.push({
|
|
175
203
|
name,
|
|
@@ -183,11 +211,28 @@ function parseOle2(buffer) {
|
|
|
183
211
|
});
|
|
184
212
|
}
|
|
185
213
|
const rootEntry = entries.find((e) => e.type === ENTRY_TYPE_ROOT);
|
|
214
|
+
if (!rootEntry || entries.filter((e) => e.type === ENTRY_TYPE_ROOT).length !== 1) {
|
|
215
|
+
throw new Ole2ParseError("Invalid root directory entry");
|
|
216
|
+
}
|
|
186
217
|
let miniStreamData;
|
|
187
218
|
if (rootEntry && rootEntry.startSector <= MAXREGSECT) {
|
|
188
|
-
miniStreamData =
|
|
219
|
+
miniStreamData = readStream(rootEntry.startSector, rootEntry.size);
|
|
220
|
+
}
|
|
221
|
+
const miniFatEntries = [];
|
|
222
|
+
if (firstMiniFATSector <= MAXREGSECT && totalMiniFATSectors > 0) {
|
|
223
|
+
const miniFatRaw = readSectorChain(firstMiniFATSector);
|
|
224
|
+
if (miniFatRaw.length !== totalMiniFATSectors * sectorSize) {
|
|
225
|
+
throw new Ole2ParseError("Unexpected mini FAT chain length");
|
|
226
|
+
}
|
|
227
|
+
const miniFatView = new DataView(miniFatRaw.buffer, miniFatRaw.byteOffset, miniFatRaw.byteLength);
|
|
228
|
+
const miniCapacity = Math.floor((miniStreamData?.length ?? 0) / miniSectorSize);
|
|
229
|
+
for (let i = 0; i < miniFatRaw.length / 4 && i < miniCapacity; i++) {
|
|
230
|
+
miniFatEntries.push(miniFatView.getUint32(i * 4, true));
|
|
231
|
+
}
|
|
189
232
|
}
|
|
190
233
|
function readMiniStream(startSector, size) {
|
|
234
|
+
if (size === 0)
|
|
235
|
+
return new Uint8Array(0);
|
|
191
236
|
if (!miniStreamData) {
|
|
192
237
|
throw new Ole2ParseError("Mini stream container not found");
|
|
193
238
|
}
|
|
@@ -200,17 +245,24 @@ function parseOle2(buffer) {
|
|
|
200
245
|
}
|
|
201
246
|
visited.add(current);
|
|
202
247
|
const offset3 = current * miniSectorSize;
|
|
248
|
+
if (offset3 + miniSectorSize > miniStreamData.length || miniFatEntries[current] === void 0) {
|
|
249
|
+
throw new Ole2ParseError("Mini stream sector exceeds allocation bounds");
|
|
250
|
+
}
|
|
203
251
|
sectors.push(miniStreamData.subarray(offset3, offset3 + miniSectorSize));
|
|
204
|
-
current = miniFatEntries[current]
|
|
252
|
+
current = miniFatEntries[current];
|
|
205
253
|
}
|
|
254
|
+
if (current !== ENDOFCHAIN)
|
|
255
|
+
throw new Ole2ParseError("Invalid mini FAT chain terminator");
|
|
206
256
|
const totalLength = sectors.length * miniSectorSize;
|
|
257
|
+
if (totalLength < size)
|
|
258
|
+
throw new Ole2ParseError("Truncated mini stream sector chain");
|
|
207
259
|
const result2 = new Uint8Array(totalLength);
|
|
208
260
|
let offset2 = 0;
|
|
209
261
|
for (const sector of sectors) {
|
|
210
262
|
result2.set(sector, offset2);
|
|
211
263
|
offset2 += miniSectorSize;
|
|
212
264
|
}
|
|
213
|
-
return result2.subarray(0,
|
|
265
|
+
return result2.subarray(0, size);
|
|
214
266
|
}
|
|
215
267
|
function getStream(name) {
|
|
216
268
|
const entry = entries.find((e) => (e.type === ENTRY_TYPE_STREAM || e.type === ENTRY_TYPE_ROOT) && e.name === name);
|
|
@@ -225,7 +277,7 @@ function parseOle2(buffer) {
|
|
|
225
277
|
return { entries, getStream };
|
|
226
278
|
}
|
|
227
279
|
|
|
228
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
280
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/utils/ooxml-crypto-primitives.js
|
|
229
281
|
function getSubtle() {
|
|
230
282
|
if (typeof globalThis.crypto !== "undefined" && globalThis.crypto.subtle) {
|
|
231
283
|
return globalThis.crypto.subtle;
|
|
@@ -1111,13 +1163,16 @@ function isEncryptedOoxmlPackage(input) {
|
|
|
1111
1163
|
}
|
|
1112
1164
|
}
|
|
1113
1165
|
|
|
1114
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
1166
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-helpers.js
|
|
1115
1167
|
function compareDirEntryNames(a, b) {
|
|
1168
|
+
const ua = a.toUpperCase();
|
|
1169
|
+
const ub = b.toUpperCase();
|
|
1170
|
+
if (ua.length !== a.length || ub.length !== b.length) {
|
|
1171
|
+
throw new Error("CFB stream names with expanding uppercase mappings are unsupported");
|
|
1172
|
+
}
|
|
1116
1173
|
if (a.length !== b.length) {
|
|
1117
1174
|
return a.length - b.length;
|
|
1118
1175
|
}
|
|
1119
|
-
const ua = a.toUpperCase();
|
|
1120
|
-
const ub = b.toUpperCase();
|
|
1121
1176
|
for (let i = 0; i < ua.length; i++) {
|
|
1122
1177
|
const diff = ua.charCodeAt(i) - ub.charCodeAt(i);
|
|
1123
1178
|
if (diff !== 0) {
|
|
@@ -1134,6 +1189,24 @@ function encodeName(name) {
|
|
|
1134
1189
|
}
|
|
1135
1190
|
return bytes;
|
|
1136
1191
|
}
|
|
1192
|
+
function buildDirectoryTree(entryCount) {
|
|
1193
|
+
const links = /* @__PURE__ */ new Map();
|
|
1194
|
+
let redLevel = 0;
|
|
1195
|
+
for (let remaining = entryCount - 2; remaining >= 0; remaining = Math.floor(remaining / 2) - 1)
|
|
1196
|
+
redLevel++;
|
|
1197
|
+
const build = (low, high, level) => {
|
|
1198
|
+
if (low > high)
|
|
1199
|
+
return 4294967295;
|
|
1200
|
+
const id = Math.floor((low + high) / 2);
|
|
1201
|
+
links.set(id, {
|
|
1202
|
+
left: build(low, id - 1, level + 1),
|
|
1203
|
+
right: build(id + 1, high, level + 1),
|
|
1204
|
+
color: level === redLevel ? 0 : 1
|
|
1205
|
+
});
|
|
1206
|
+
return id;
|
|
1207
|
+
};
|
|
1208
|
+
return { root: build(1, entryCount - 1, 0), links };
|
|
1209
|
+
}
|
|
1137
1210
|
function writeFatChain(fat, chain2) {
|
|
1138
1211
|
for (let i = 0; i < chain2.sectors.length; i++) {
|
|
1139
1212
|
fat[chain2.sectors[i]] = i < chain2.sectors.length - 1 ? chain2.sectors[i + 1] : ENDOFCHAIN;
|
|
@@ -1157,7 +1230,7 @@ function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorS
|
|
|
1157
1230
|
}
|
|
1158
1231
|
}
|
|
1159
1232
|
|
|
1160
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
1233
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-parser-write-serialize.js
|
|
1161
1234
|
function writeHeader(outView, outBytes, params) {
|
|
1162
1235
|
outBytes.set(OLE_MAGIC, 0);
|
|
1163
1236
|
outView.setUint16(24, 62, true);
|
|
@@ -1215,6 +1288,7 @@ function writeDifatSectors(outView, params) {
|
|
|
1215
1288
|
function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
|
|
1216
1289
|
const dirData = new Uint8Array(numDirSectors * sectorSize);
|
|
1217
1290
|
const dirView = new DataView(dirData.buffer);
|
|
1291
|
+
const tree = buildDirectoryTree(dirEntries.length);
|
|
1218
1292
|
for (let i = 0; i < dirEntries.length; i++) {
|
|
1219
1293
|
const entry = dirEntries[i];
|
|
1220
1294
|
const entryOffset = i * DIR_ENTRY_SIZE;
|
|
@@ -1222,17 +1296,17 @@ function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
|
|
|
1222
1296
|
dirData.set(nameBytes.subarray(0, Math.min(nameBytes.length, 64)), entryOffset);
|
|
1223
1297
|
dirView.setUint16(entryOffset + 64, Math.min((entry.name.length + 1) * 2, 64), true);
|
|
1224
1298
|
dirData[entryOffset + 66] = entry.type;
|
|
1225
|
-
dirData[entryOffset + 67] = 1;
|
|
1299
|
+
dirData[entryOffset + 67] = i === 0 ? 1 : tree.links.get(i).color;
|
|
1226
1300
|
if (entry.clsid) {
|
|
1227
1301
|
dirData.set(entry.clsid.subarray(0, 16), entryOffset + 80);
|
|
1228
1302
|
}
|
|
1229
1303
|
if (i === 0) {
|
|
1230
1304
|
dirView.setUint32(entryOffset + 68, 4294967295, true);
|
|
1231
1305
|
dirView.setUint32(entryOffset + 72, 4294967295, true);
|
|
1232
|
-
dirView.setUint32(entryOffset + 76,
|
|
1306
|
+
dirView.setUint32(entryOffset + 76, tree.root, true);
|
|
1233
1307
|
} else {
|
|
1234
|
-
dirView.setUint32(entryOffset + 68,
|
|
1235
|
-
dirView.setUint32(entryOffset + 72, i
|
|
1308
|
+
dirView.setUint32(entryOffset + 68, tree.links.get(i).left, true);
|
|
1309
|
+
dirView.setUint32(entryOffset + 72, tree.links.get(i).right, true);
|
|
1236
1310
|
dirView.setUint32(entryOffset + 76, 4294967295, true);
|
|
1237
1311
|
}
|
|
1238
1312
|
dirView.setUint32(entryOffset + 116, entry.startSector, true);
|
|
@@ -1249,10 +1323,25 @@ function writeStreamSectors(outBytes, streamData, chain2, sectorSize) {
|
|
|
1249
1323
|
}
|
|
1250
1324
|
}
|
|
1251
1325
|
|
|
1252
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
1326
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-parser-write.js
|
|
1253
1327
|
function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
1254
1328
|
const sectorSize = 512;
|
|
1255
1329
|
const miniSectorSize = 64;
|
|
1330
|
+
if (rootClsid && rootClsid.length !== 16)
|
|
1331
|
+
throw new Error("Root CLSID must contain 16 bytes");
|
|
1332
|
+
const names = [...streams2.keys()].sort(compareDirEntryNames);
|
|
1333
|
+
for (let i = 0; i < names.length; i++) {
|
|
1334
|
+
const name = names[i];
|
|
1335
|
+
if (name.toUpperCase().length !== name.length) {
|
|
1336
|
+
throw new Error("CFB stream names with expanding uppercase mappings are unsupported");
|
|
1337
|
+
}
|
|
1338
|
+
if (!name.length || name.length > 31 || /[\x00\\/:!]/.test(name)) {
|
|
1339
|
+
throw new Error("CFB stream names must be 1-31 UTF-16 code units without NUL, \\, /, :, or !");
|
|
1340
|
+
}
|
|
1341
|
+
if (i > 0 && compareDirEntryNames(names[i - 1], name) === 0) {
|
|
1342
|
+
throw new Error("Duplicate CFB stream names");
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1256
1345
|
const regularStreams = [];
|
|
1257
1346
|
const miniStreams = [];
|
|
1258
1347
|
for (const [name, data] of streams2) {
|
|
@@ -1270,7 +1359,7 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1270
1359
|
for (let i = 0; i < numSectors; i++) {
|
|
1271
1360
|
sectors.push(nextSector++);
|
|
1272
1361
|
}
|
|
1273
|
-
fatChains.set(stream.name, { start: sectors[0] ??
|
|
1362
|
+
fatChains.set(stream.name, { start: sectors[0] ?? ENDOFCHAIN, sectors });
|
|
1274
1363
|
}
|
|
1275
1364
|
let miniStreamContainer = new Uint8Array(0);
|
|
1276
1365
|
const miniFatChains = /* @__PURE__ */ new Map();
|
|
@@ -1293,7 +1382,7 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1293
1382
|
miniOffset += miniSectorSize;
|
|
1294
1383
|
}
|
|
1295
1384
|
miniFatChains.set(stream.name, {
|
|
1296
|
-
start: miniSectors[0] ??
|
|
1385
|
+
start: miniSectors[0] ?? ENDOFCHAIN,
|
|
1297
1386
|
sectors: miniSectors
|
|
1298
1387
|
});
|
|
1299
1388
|
}
|
|
@@ -1341,7 +1430,7 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1341
1430
|
nextSector += numDirSectors;
|
|
1342
1431
|
let firstMiniFATSector = ENDOFCHAIN;
|
|
1343
1432
|
let numMiniFATSectors = 0;
|
|
1344
|
-
if (
|
|
1433
|
+
if (nextMiniSector > 0) {
|
|
1345
1434
|
numMiniFATSectors = Math.ceil(nextMiniSector * 4 / sectorSize);
|
|
1346
1435
|
firstMiniFATSector = nextSector;
|
|
1347
1436
|
nextSector += numMiniFATSectors;
|
|
@@ -17109,7 +17198,7 @@ var xlsbUnsupported = () => new UnsupportedWorkbookError(
|
|
|
17109
17198
|
"Excel Binary Workbook (.xlsb) files are not supported; save as .xlsx in Excel."
|
|
17110
17199
|
);
|
|
17111
17200
|
|
|
17112
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17201
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole2-stream-edit.js
|
|
17113
17202
|
var END = 4294967294;
|
|
17114
17203
|
var MAX = 4294967290;
|
|
17115
17204
|
var NIL = 4294967295;
|
|
@@ -17192,7 +17281,7 @@ function processCompoundFileStream(input, path, replacement) {
|
|
|
17192
17281
|
const fat = [];
|
|
17193
17282
|
for (const id of fatIds) {
|
|
17194
17283
|
const bytes = sector(id), dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
17195
|
-
for (let j = 0; j < sectorSize / 4; j++)
|
|
17284
|
+
for (let j = 0; j < sectorSize / 4 && fat.length < sectorCount; j++)
|
|
17196
17285
|
fat.push(dv.getUint32(j * 4, true));
|
|
17197
17286
|
}
|
|
17198
17287
|
const exactChain = (table, start, bytes, unit) => chain(table, start, Math.ceil(bytes / unit));
|
|
@@ -17289,9 +17378,10 @@ function processCompoundFileStream(input, path, replacement) {
|
|
|
17289
17378
|
if (new Set(metadataSectors).size !== metadataSectors.length)
|
|
17290
17379
|
return reject();
|
|
17291
17380
|
const miniFat = [];
|
|
17381
|
+
const miniCapacity = Math.floor(Math.min(root.size, sectorCount * sectorSize) / miniSize);
|
|
17292
17382
|
for (const id of miniFatSectors) {
|
|
17293
17383
|
const bytes = sector(id), dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
17294
|
-
for (let j = 0; j < sectorSize / 4; j++)
|
|
17384
|
+
for (let j = 0; j < sectorSize / 4 && miniFat.length < miniCapacity; j++)
|
|
17295
17385
|
miniFat.push(dv.getUint32(j * 4, true));
|
|
17296
17386
|
}
|
|
17297
17387
|
const reserved = /* @__PURE__ */ new Set([...fatIds, ...difatIds, ...dirSectors, ...miniFatSectors]);
|
|
@@ -17315,7 +17405,7 @@ function processCompoundFileStream(input, path, replacement) {
|
|
|
17315
17405
|
continue;
|
|
17316
17406
|
const ids = exactChain(miniFat, entry.start, entry.size, miniSize);
|
|
17317
17407
|
for (const id of ids) {
|
|
17318
|
-
if (id * miniSize
|
|
17408
|
+
if ((id + 1) * miniSize > rootMini.size || miniUsed.has(id))
|
|
17319
17409
|
return reject();
|
|
17320
17410
|
miniUsed.add(id);
|
|
17321
17411
|
}
|
|
@@ -17340,6 +17430,8 @@ function processCompoundFileStream(input, path, replacement) {
|
|
|
17340
17430
|
});
|
|
17341
17431
|
return result2.slice(0, target.size);
|
|
17342
17432
|
}
|
|
17433
|
+
if (replacement.length === 0)
|
|
17434
|
+
return input.slice();
|
|
17343
17435
|
const output = input.slice();
|
|
17344
17436
|
if (target.size >= miniCutoff) {
|
|
17345
17437
|
const sectors = exactChain(fat, target.start, target.size, sectorSize);
|
|
@@ -17379,7 +17471,7 @@ function replaceCompoundFileStream(input, path, replacement) {
|
|
|
17379
17471
|
return processCompoundFileStream(input, path, replacement) ?? input;
|
|
17380
17472
|
}
|
|
17381
17473
|
|
|
17382
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17474
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-cfb.js
|
|
17383
17475
|
var WORKBOOK_STREAM_NAMES = ["workbook", "book"];
|
|
17384
17476
|
function unwrapXlsBytes(bytes) {
|
|
17385
17477
|
if (!isCfb(bytes)) {
|
|
@@ -17446,7 +17538,7 @@ function isCfb(bytes) {
|
|
|
17446
17538
|
return OLE_MAGIC.every((value, index2) => bytes[index2] === value);
|
|
17447
17539
|
}
|
|
17448
17540
|
|
|
17449
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17541
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-functions.js
|
|
17450
17542
|
var TABLE = `0 COUNT -1|1 IF -1|2 ISNA 1|3 ISERROR 1|4 SUM -1|5 AVERAGE -1|6 MIN -1|7 MAX -1|8 ROW -1|9 COLUMN -1|10 NA 0|11 NPV -1|12 STDEV -1|13 DOLLAR -1|14 FIXED -1|15 SIN 1|16 COS 1|17 TAN 1|18 ATAN 1|19 PI 0|20 SQRT 1|21 EXP 1|22 LN 1|23 LOG10 1|24 ABS 1|25 INT 1|26 SIGN 1|27 ROUND 2|28 LOOKUP -1|29 INDEX -1|30 REPT 2|31 MID 3|32 LEN 1|33 VALUE 1|34 TRUE 0|35 FALSE 0|36 AND -1|37 OR -1|38 NOT 1|39 MOD 2|40 DCOUNT 3|41 DSUM 3|42 DAVERAGE 3|43 DMIN 3|44 DMAX 3|45 DSTDEV 3|46 VAR -1|47 DVAR 3|48 TEXT 2|49 LINEST -1|50 TREND -1|51 LOGEST -1|52 GROWTH -1|56 PV -1|57 FV -1|58 NPER -1|59 PMT -1|60 RATE -1|61 MIRR 3|62 IRR -1|63 RAND 0|64 MATCH -1|65 DATE 3|66 TIME 3|67 DAY 1|68 MONTH 1|69 YEAR 1|70 WEEKDAY -1|71 HOUR 1|72 MINUTE 1|73 SECOND 1|74 NOW 0|75 AREAS 1|76 ROWS 1|77 COLUMNS 1|78 OFFSET -1|82 SEARCH -1|83 TRANSPOSE 1|86 TYPE 1|97 ATAN2 2|98 ASIN 1|99 ACOS 1|100 CHOOSE -1|101 HLOOKUP -1|102 VLOOKUP -1|105 ISREF 1|109 LOG -1|111 CHAR 1|112 LOWER 1|113 UPPER 1|114 PROPER 1|115 LEFT -1|116 RIGHT -1|117 EXACT 2|118 TRIM 1|119 REPLACE 4|120 SUBSTITUTE -1|121 CODE 1|124 FIND -1|125 CELL -1|126 ISERR 1|127 ISTEXT 1|128 ISNUMBER 1|129 ISBLANK 1|130 T 1|131 N 1|140 DATEVALUE 1|141 TIMEVALUE 1|142 SLN 3|143 SYD 4|144 DDB -1|148 INDIRECT -1|150 CALL -1|162 CLEAN 1|163 MDETERM 1|164 MINVERSE 1|165 MMULT 2|167 IPMT -1|168 PPMT -1|169 COUNTA -1|183 PRODUCT -1|184 FACT 1|189 DPRODUCT 3|190 ISNONTEXT 1|193 STDEVP -1|194 VARP -1|195 DSTDEVP 3|196 DVARP 3|197 TRUNC -1|198 ISLOGICAL 1|199 DCOUNTA 3|204 USDOLLAR -1|205 FINDB -1|206 SEARCHB -1|207 REPLACEB 4|208 LEFTB -1|209 RIGHTB -1|210 MIDB 3|211 LENB 1|212 ROUNDUP 2|213 ROUNDDOWN 2|214 ASC 1|215 DBCS 1|216 RANK -1|219 ADDRESS -1|220 DAYS360 -1|221 TODAY 0|222 VDB -1|227 MEDIAN -1|228 SUMPRODUCT -1|229 SINH 1|230 COSH 1|231 TANH 1|232 ASINH 1|233 ACOSH 1|234 ATANH 1|235 DGET 3|244 INFO 1|247 DB -1|252 FREQUENCY 2|261 ERROR.TYPE 1|269 AVEDEV -1|270 BETADIST -1|271 GAMMALN 1|272 BETAINV -1|273 BINOMDIST 4|274 CHIDIST 2|275 CHIINV 2|276 COMBIN 2|277 CONFIDENCE 3|278 CRITBINOM 3|279 EVEN 1|280 EXPONDIST 3|281 FDIST 3|282 FINV 3|283 FISHER 1|284 FISHERINV 1|285 FLOOR 2|286 GAMMADIST 4|287 GAMMAINV 3|288 CEILING 2|289 HYPGEOMDIST 4|290 LOGNORMDIST 3|291 LOGINV 3|292 NEGBINOMDIST 3|293 NORMDIST 4|294 NORMSDIST 1|295 NORMINV 3|296 NORMSINV 1|297 STANDARDIZE 3|298 ODD 1|299 PERMUT 2|300 POISSON 3|301 TDIST 3|302 WEIBULL 4|303 SUMXMY2 2|304 SUMX2MY2 2|305 SUMX2PY2 2|306 CHITEST 2|307 CORREL 2|308 COVAR 2|309 FORECAST 3|310 FTEST 2|311 INTERCEPT 2|312 PEARSON 2|313 RSQ 2|314 STEYX 2|315 SLOPE 2|316 TTEST 4|317 PROB -1|318 DEVSQ -1|319 GEOMEAN -1|320 HARMEAN -1|321 SUMSQ -1|322 KURT -1|323 SKEW -1|324 ZTEST -1|325 LARGE 2|326 SMALL 2|327 QUARTILE 2|328 PERCENTILE 2|329 PERCENTRANK -1|330 MODE -1|331 TRIMMEAN 2|332 TINV 2|336 CONCATENATE -1|337 POWER 2|342 RADIANS 1|343 DEGREES 1|344 SUBTOTAL -1|345 SUMIF -1|346 COUNTIF 2|347 COUNTBLANK 1|350 ISPMT 4|351 DATEDIF 3|352 DATESTRING 1|353 NUMBERSTRING 2|354 ROMAN -1|358 GETPIVOTDATA -1|359 HYPERLINK -1|360 PHONETIC 1|361 AVERAGEA -1|362 MAXA -1|363 MINA -1|364 STDEVPA -1|365 VARPA -1|366 STDEVA -1|367 VARA -1|368 BAHTTEXT 1`;
|
|
17451
17543
|
var XLS_FUNCTIONS = new Map(TABLE.split("|").map((entry) => {
|
|
17452
17544
|
const [id, name, argc] = entry.split(" ");
|
|
@@ -17454,7 +17546,7 @@ var XLS_FUNCTIONS = new Map(TABLE.split("|").map((entry) => {
|
|
|
17454
17546
|
}));
|
|
17455
17547
|
var XLS_USER_FUNCTION_ID = 255;
|
|
17456
17548
|
|
|
17457
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17549
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg-text.js
|
|
17458
17550
|
var BIFF_ERRORS = {
|
|
17459
17551
|
0: "#NULL!",
|
|
17460
17552
|
7: "#DIV/0!",
|
|
@@ -17549,7 +17641,7 @@ function readArrayConstant(extra) {
|
|
|
17549
17641
|
return `{${lines.join(";")}}`;
|
|
17550
17642
|
}
|
|
17551
17643
|
|
|
17552
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17644
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-records.js
|
|
17553
17645
|
var RT_CONTINUE = 60;
|
|
17554
17646
|
function readXlsRecords(bytes, start = 0, end = bytes.length) {
|
|
17555
17647
|
const records = [];
|
|
@@ -17715,7 +17807,7 @@ function joinedData(record) {
|
|
|
17715
17807
|
return out;
|
|
17716
17808
|
}
|
|
17717
17809
|
|
|
17718
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
17810
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-ptg.js
|
|
17719
17811
|
function decodeFormula(rgce, extra, context, options) {
|
|
17720
17812
|
try {
|
|
17721
17813
|
return decode(rgce, new ByteReader(extra), context, options);
|
|
@@ -17946,7 +18038,7 @@ function readAttr(reader, stack2, whitespace) {
|
|
|
17946
18038
|
}
|
|
17947
18039
|
}
|
|
17948
18040
|
|
|
17949
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18041
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sst.js
|
|
17950
18042
|
function parseSharedStrings2(record) {
|
|
17951
18043
|
const reader = SegmentReader.of(record);
|
|
17952
18044
|
reader.u32();
|
|
@@ -17963,7 +18055,7 @@ function parseSharedStrings2(record) {
|
|
|
17963
18055
|
return strings;
|
|
17964
18056
|
}
|
|
17965
18057
|
|
|
17966
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18058
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-styles.js
|
|
17967
18059
|
var DEFAULT_XLS_PALETTE = "000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 800000 008000 000080 808000 800080 008080 C0C0C0 808080 9999FF 993366 FFFFCC CCFFFF 660066 FF8080 0066CC CCCCFF 000080 FF00FF FFFF00 00FFFF 800080 800000 008080 0000FF 00CCFF CCFFFF CCFFCC FFFF99 99CCFF FF99CC CC99FF FFCC99 3366FF 33CCCC 99CC00 FFCC00 FF9900 FF6600 666699 969696 003366 339966 003300 333300 993300 993366 333399 333333".split(" ");
|
|
17968
18060
|
var XLS_BUILTIN_FORMATS = {
|
|
17969
18061
|
0: "General",
|
|
@@ -18220,7 +18312,7 @@ function applyXfExt(data, xfs, palette) {
|
|
|
18220
18312
|
}
|
|
18221
18313
|
}
|
|
18222
18314
|
|
|
18223
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18315
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-types.js
|
|
18224
18316
|
var XlsReadError = class extends Error {
|
|
18225
18317
|
code;
|
|
18226
18318
|
constructor(code, message) {
|
|
@@ -18230,7 +18322,7 @@ var XlsReadError = class extends Error {
|
|
|
18230
18322
|
}
|
|
18231
18323
|
};
|
|
18232
18324
|
|
|
18233
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18325
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-globals.js
|
|
18234
18326
|
var RT = {
|
|
18235
18327
|
BOF: 2057,
|
|
18236
18328
|
EOF: 10,
|
|
@@ -18468,7 +18560,7 @@ function parseGlobals(records) {
|
|
|
18468
18560
|
return out;
|
|
18469
18561
|
}
|
|
18470
18562
|
|
|
18471
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18563
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-biff8.js
|
|
18472
18564
|
function decodeRk(rk) {
|
|
18473
18565
|
const isInt = (rk & 2) !== 0;
|
|
18474
18566
|
const isDiv100 = (rk & 1) !== 0;
|
|
@@ -18485,7 +18577,7 @@ function decodeRk(rk) {
|
|
|
18485
18577
|
return isDiv100 ? value / 100 : value;
|
|
18486
18578
|
}
|
|
18487
18579
|
|
|
18488
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18580
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-formulas.js
|
|
18489
18581
|
function readRefU(r) {
|
|
18490
18582
|
return { firstRow: r.u16(), lastRow: r.u16(), firstCol: r.u8(), lastCol: r.u8() };
|
|
18491
18583
|
}
|
|
@@ -18543,7 +18635,7 @@ function resolveFormulas(formulas, shared, arrays, globals) {
|
|
|
18543
18635
|
}
|
|
18544
18636
|
}
|
|
18545
18637
|
|
|
18546
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18638
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet-extras.js
|
|
18547
18639
|
function parseMergedCells(data) {
|
|
18548
18640
|
const r = new ByteReader(data);
|
|
18549
18641
|
const count2 = r.u16();
|
|
@@ -18738,7 +18830,7 @@ function parseNote(data) {
|
|
|
18738
18830
|
return { row, col, visible: (flags & 2) !== 0, id, author: r.xlString() };
|
|
18739
18831
|
}
|
|
18740
18832
|
|
|
18741
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
18833
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-sheet.js
|
|
18742
18834
|
var UNSUPPORTED = {
|
|
18743
18835
|
432: "conditional formatting",
|
|
18744
18836
|
2169: "conditional formatting",
|
|
@@ -18994,7 +19086,7 @@ function parseSheet(bound, records, start, globals) {
|
|
|
18994
19086
|
return sheet;
|
|
18995
19087
|
}
|
|
18996
19088
|
|
|
18997
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
19089
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook.js
|
|
18998
19090
|
function compoundStreamNames(bytes) {
|
|
18999
19091
|
if (!OLE_MAGIC.every((value, index2) => bytes[index2] === value))
|
|
19000
19092
|
return [];
|
|
@@ -19064,7 +19156,7 @@ function readXlsWorkbook(bytes) {
|
|
|
19064
19156
|
};
|
|
19065
19157
|
}
|
|
19066
19158
|
|
|
19067
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
19159
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole-document-doc-cp1252.js
|
|
19068
19160
|
var CP1252_HIGH_BLOCK = [
|
|
19069
19161
|
8364,
|
|
19070
19162
|
129,
|
|
@@ -19114,7 +19206,7 @@ function decodeCp1252(bytes) {
|
|
|
19114
19206
|
return out;
|
|
19115
19207
|
}
|
|
19116
19208
|
|
|
19117
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
19209
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/ole-summary-properties.js
|
|
19118
19210
|
var SUMMARY_STREAM_NAME = "SummaryInformation";
|
|
19119
19211
|
var SUMMARY_TEXT_PROPERTIES = {
|
|
19120
19212
|
title: 2,
|
|
@@ -19229,7 +19321,7 @@ function readSummaryProperties(bytes) {
|
|
|
19229
19321
|
return result2;
|
|
19230
19322
|
}
|
|
19231
19323
|
|
|
19232
|
-
// node_modules/.bun/@christophervr+ole2@0.
|
|
19324
|
+
// node_modules/.bun/@christophervr+ole2@0.8.0/node_modules/@christophervr/ole2/dist/legacy-office-metadata.js
|
|
19233
19325
|
function summaryStream(bytes) {
|
|
19234
19326
|
return readCompoundFileStream(bytes, [SUMMARY_STREAM_NAME]);
|
|
19235
19327
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ooxml-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Shared OOXML logic for the Word, PowerPoint and Excel viewers: everything except the UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"charts",
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
"yjs": "^13.6.32"
|
|
217
217
|
},
|
|
218
218
|
"devDependencies": {
|
|
219
|
-
"@christophervr/ole2": "0.
|
|
219
|
+
"@christophervr/ole2": "0.8.0",
|
|
220
220
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
221
221
|
"@napi-rs/canvas": "^1.0.9",
|
|
222
222
|
"@types/node": "^22.0.0",
|