@stll/docx-core 0.45.0 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{archive-yBR7X-Qc.js → archive-D5kFLipm.js} +1 -1
- package/dist/{format-DXPXB02u.js → format-DKTCMfac.js} +36 -10
- package/dist/index.js +4 -141
- package/dist/ops/documentOps.d.ts +18 -0
- package/dist/ops/documentOps.js +173 -48
- package/dist/schemaAttributes-e8whSQjO.js +142 -0
- package/dist/zip/archive.js +2 -2
- package/dist/zip/stream.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ZipError, a as UINT16_SENTINEL, d as encodeEndOfCentralDirectory, f as encodeEntryName, g as toDosDateTime, h as isSafeZipPath, l as encodeCentralHeader, m as fromDosDateTime, p as encodeLocalHeader, r as FIXED_DOS_DATE_TIME, v as copyBytes, y as platformZipCodec } from "./format-
|
|
1
|
+
import { _ as ZipError, a as UINT16_SENTINEL, d as encodeEndOfCentralDirectory, f as encodeEntryName, g as toDosDateTime, h as isSafeZipPath, l as encodeCentralHeader, m as fromDosDateTime, p as encodeLocalHeader, r as FIXED_DOS_DATE_TIME, v as copyBytes, y as platformZipCodec } from "./format-DKTCMfac.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
3
|
import { decodeText, encodeUtf8 } from "@stll/utf8-boundaries";
|
|
4
4
|
// src/zip/read.ts
|
|
@@ -43,19 +43,45 @@ const exactBytes = (bytes) => {
|
|
|
43
43
|
const { buffer } = bytes;
|
|
44
44
|
return buffer instanceof ArrayBuffer && bytes.byteOffset === 0 && bytes.byteLength === buffer.byteLength ? new Uint8Array(buffer) : copyBytes(bytes);
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Eight 256-entry CRC-32 tables, one after another: table 0 is the classic
|
|
48
|
+
* byte table, and table `k` advances a byte's contribution by `k` more bytes.
|
|
49
|
+
*/
|
|
50
|
+
let crcTables = null;
|
|
51
|
+
const buildCrcTables = () => {
|
|
52
|
+
const tables = /* @__PURE__ */ new Uint32Array(2048);
|
|
53
|
+
for (let index = 0; index < 256; index++) {
|
|
54
|
+
let value = index;
|
|
55
|
+
for (let bit = 0; bit < 8; bit++) value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
|
|
56
|
+
tables[index] = value >>> 0;
|
|
57
|
+
}
|
|
58
|
+
for (let index = 0; index < 256; index++) {
|
|
59
|
+
let value = tables[index];
|
|
60
|
+
for (let table = 1; table < 8; table++) {
|
|
61
|
+
value = tables[value & 255] ^ value >>> 8;
|
|
62
|
+
tables[table * 256 + index] = value >>> 0;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
|
-
|
|
65
|
+
return tables;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* CRC-32 where the runtime offers none (browsers): eight bytes per step over
|
|
69
|
+
* eight tables, then byte by byte. The loops index the array; iterating a
|
|
70
|
+
* typed array with `for…of` runs an order of magnitude slower, and every
|
|
71
|
+
* entry an archive inflates is checked through here.
|
|
72
|
+
*/
|
|
73
|
+
const tableCrc32 = (data, previous = 0) => {
|
|
74
|
+
crcTables ??= buildCrcTables();
|
|
75
|
+
const t = crcTables;
|
|
57
76
|
let crc = ~previous >>> 0;
|
|
58
|
-
|
|
77
|
+
const length = data.length;
|
|
78
|
+
const whole = length - length % 8;
|
|
79
|
+
let index = 0;
|
|
80
|
+
for (; index < whole; index += 8) {
|
|
81
|
+
const low = (crc ^ (data[index] | data[index + 1] << 8 | data[index + 2] << 16 | data[index + 3] << 24)) >>> 0;
|
|
82
|
+
crc = t[1792 + (low & 255)] ^ t[1536 + (low >>> 8 & 255)] ^ t[1280 + (low >>> 16 & 255)] ^ t[1024 + (low >>> 24)] ^ t[768 + data[index + 4]] ^ t[512 + data[index + 5]] ^ t[256 + data[index + 6]] ^ t[data[index + 7]];
|
|
83
|
+
}
|
|
84
|
+
for (; index < length; index++) crc = t[(crc ^ data[index]) & 255] ^ crc >>> 8;
|
|
59
85
|
return ~crc >>> 0;
|
|
60
86
|
};
|
|
61
87
|
const BUFFER_TOO_LARGE = "ERR_BUFFER_TOO_LARGE";
|