frond-js 0.4.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +247 -0
  3. package/README.md +211 -0
  4. package/dist/abort-BY8vBk0v.d.cts +99 -0
  5. package/dist/abort-BY8vBk0v.d.ts +99 -0
  6. package/dist/adapter-3G46J3CA.cjs +503 -0
  7. package/dist/adapter-3ONQWJVQ.js +501 -0
  8. package/dist/adapter-55QHWRSE.js +124 -0
  9. package/dist/adapter-DF34GBWJ.cjs +19 -0
  10. package/dist/adapter-EXTNILTC.cjs +126 -0
  11. package/dist/adapter-GOFC7TMC.js +284 -0
  12. package/dist/adapter-LRJTQ47I.cjs +286 -0
  13. package/dist/adapter-TWWZML4A.js +17 -0
  14. package/dist/adapter-ZM5FQTJT.js +1415 -0
  15. package/dist/adapter-ZRNSDQUV.cjs +1417 -0
  16. package/dist/chunk-2SUG7YFZ.cjs +108 -0
  17. package/dist/chunk-B2L2YVXD.js +89 -0
  18. package/dist/chunk-D4KWSEZD.js +393 -0
  19. package/dist/chunk-EZTIZO6R.cjs +430 -0
  20. package/dist/chunk-G7DLWGBW.cjs +103 -0
  21. package/dist/chunk-GTGLDLJD.cjs +479 -0
  22. package/dist/chunk-IIV6VIUJ.cjs +83 -0
  23. package/dist/chunk-JDTHZQUK.js +102 -0
  24. package/dist/chunk-JJVXT3AC.js +30 -0
  25. package/dist/chunk-LIXRYQL2.js +473 -0
  26. package/dist/chunk-NABYHI6X.cjs +400 -0
  27. package/dist/chunk-SJVOYNTF.js +425 -0
  28. package/dist/chunk-SLI2YL25.cjs +252 -0
  29. package/dist/chunk-U4264IQH.js +78 -0
  30. package/dist/chunk-UY2YRCFC.js +250 -0
  31. package/dist/chunk-WCZTTQ7Z.cjs +32 -0
  32. package/dist/core/index.cjs +162 -0
  33. package/dist/core/index.d.cts +321 -0
  34. package/dist/core/index.d.ts +321 -0
  35. package/dist/core/index.js +49 -0
  36. package/dist/default-DRLIJX73.js +1183 -0
  37. package/dist/default-UK52WOO5.cjs +1192 -0
  38. package/dist/formats/epub/index.cjs +29 -0
  39. package/dist/formats/epub/index.d.cts +286 -0
  40. package/dist/formats/epub/index.d.ts +286 -0
  41. package/dist/formats/epub/index.js +11 -0
  42. package/dist/index.cjs +655 -0
  43. package/dist/index.d.cts +335 -0
  44. package/dist/index.d.ts +335 -0
  45. package/dist/index.js +600 -0
  46. package/dist/render/index.cjs +2 -0
  47. package/dist/render/index.d.cts +116 -0
  48. package/dist/render/index.d.ts +116 -0
  49. package/dist/render/index.js +1 -0
  50. package/dist/types-B76GOMxj.d.ts +129 -0
  51. package/dist/types-B7mslPBY.d.cts +166 -0
  52. package/dist/types-B7mslPBY.d.ts +166 -0
  53. package/dist/types-BH88rUYt.d.cts +129 -0
  54. package/dist/types-C-5eHSRH.d.ts +379 -0
  55. package/dist/types-CPUqTEPW.d.cts +379 -0
  56. package/dist/types-DQYmArgv.d.cts +17 -0
  57. package/dist/types-DQYmArgv.d.ts +17 -0
  58. package/package.json +115 -0
@@ -0,0 +1,78 @@
1
+ import { FormatError } from './chunk-B2L2YVXD.js';
2
+
3
+ // src/core/archive-path.ts
4
+ var DEFAULT_LABEL = "\u5F52\u6863\u8DEF\u5F84";
5
+ var UNKNOWN_SOURCE = "<unknown>";
6
+ function formatError(suffix, options) {
7
+ const label = options.label ?? DEFAULT_LABEL;
8
+ const source = options.source ?? UNKNOWN_SOURCE;
9
+ return new FormatError(`${label}${suffix}\uFF08\u6E90: ${source}\uFF09`);
10
+ }
11
+ function hasControlCharacter(value) {
12
+ for (let index = 0; index < value.length; index += 1) {
13
+ const code = value.charCodeAt(index);
14
+ if (code <= 31 || code === 127) return true;
15
+ }
16
+ return false;
17
+ }
18
+ function namesNoEntry(value) {
19
+ for (const segment of value.replace(/\\/g, "/").split("/")) {
20
+ if (segment !== "" && segment !== "." && segment !== "..") return false;
21
+ }
22
+ return true;
23
+ }
24
+ var SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
25
+ function classifyReference(rawValue) {
26
+ const value = rawValue.trim();
27
+ if (value === "") return "empty";
28
+ if (value.startsWith("#")) return "fragment";
29
+ if (value.startsWith("//")) return "protocol-relative";
30
+ if (SCHEME_PATTERN.test(value)) return "absolute";
31
+ return "archive";
32
+ }
33
+ function normalizeArchivePath(rawPath, options = {}) {
34
+ if (rawPath === "") {
35
+ throw formatError(" \u4E3A\u7A7A", options);
36
+ }
37
+ if (hasControlCharacter(rawPath)) {
38
+ throw formatError(" \u542B\u63A7\u5236\u5B57\u7B26", options);
39
+ }
40
+ const segments = [];
41
+ for (const segment of rawPath.replace(/\\/g, "/").split("/")) {
42
+ if (segment === "" || segment === ".") continue;
43
+ if (segment === "..") {
44
+ if (segments.length === 0) {
45
+ throw formatError(` \u8D8A\u51FA\u5F52\u6863\u6839\u76EE\u5F55\uFF1A"${rawPath}"`, options);
46
+ }
47
+ segments.pop();
48
+ continue;
49
+ }
50
+ segments.push(segment);
51
+ }
52
+ if (segments.length === 0) {
53
+ throw formatError(` \u89C4\u8303\u5316\u540E\u4E3A\u7A7A\uFF1A"${rawPath}"`, options);
54
+ }
55
+ return segments.join("/");
56
+ }
57
+ function resolveArchivePath(basePath, href, options = {}) {
58
+ if (namesNoEntry(href)) {
59
+ throw formatError(` \u672A\u6307\u5411\u4EFB\u4F55\u6761\u76EE\uFF1A"${href}"`, options);
60
+ }
61
+ const kind = classifyReference(href);
62
+ if (kind !== "archive") {
63
+ throw formatError(
64
+ ` \u4E0D\u662F\u76F8\u5BF9\u5F15\u7528\uFF1A"${href.trim()}"\uFF08\u5E26 scheme\u3001\u534F\u8BAE\u76F8\u5BF9 // \u6216\u7EAF fragment \u90FD\u4E0D\u6307\u5411\u5F52\u6863\u5185\u7684\u6761\u76EE\uFF09`,
65
+ options
66
+ );
67
+ }
68
+ if (href.startsWith("/")) {
69
+ return normalizeArchivePath(href, options);
70
+ }
71
+ return normalizeArchivePath(basePath === "" ? href : `${basePath}/${href}`, options);
72
+ }
73
+ function directoryOf(archivePath) {
74
+ const index = archivePath.lastIndexOf("/");
75
+ return index === -1 ? "" : archivePath.slice(0, index);
76
+ }
77
+
78
+ export { classifyReference, directoryOf, normalizeArchivePath, resolveArchivePath };
@@ -0,0 +1,250 @@
1
+ import { normalizeArchivePath } from './chunk-U4264IQH.js';
2
+ import { FormatError, ParseError, throwIfAborted, isFrondError } from './chunk-B2L2YVXD.js';
3
+
4
+ // src/core/zip/inflate.ts
5
+ var CRC_TABLE = (() => {
6
+ const table = new Uint32Array(256);
7
+ for (let index = 0; index < 256; index += 1) {
8
+ let value = index;
9
+ for (let bit = 0; bit < 8; bit += 1) {
10
+ value = (value & 1) !== 0 ? 3988292384 ^ value >>> 1 : value >>> 1;
11
+ }
12
+ table[index] = value >>> 0;
13
+ }
14
+ return new DataView(table.buffer);
15
+ })();
16
+ function crc32(data) {
17
+ let crc = 4294967295;
18
+ for (const byte of data) {
19
+ crc = crc >>> 8 ^ CRC_TABLE.getUint32(((crc ^ byte) & 255) << 2, true);
20
+ }
21
+ return (crc ^ 4294967295) >>> 0;
22
+ }
23
+ async function inflateRaw(data, label, maxOutputBytes) {
24
+ const chunks = [];
25
+ let total = 0;
26
+ try {
27
+ const view = data.buffer instanceof ArrayBuffer ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
28
+ const stream = new Blob([view]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
29
+ const reader = stream.getReader();
30
+ for (; ; ) {
31
+ const { done, value } = await reader.read();
32
+ if (done) break;
33
+ total += value.byteLength;
34
+ if (total > maxOutputBytes) {
35
+ await reader.cancel();
36
+ throw new ParseError(
37
+ `deflate \u89E3\u538B\u4EA7\u7269\u8D85\u8FC7\u4E0A\u9650 ${String(maxOutputBytes)} \u5B57\u8282\uFF08\u6E90: ${label}\uFF09\uFF0C\u5DF2\u4EA7\u51FA ${String(total)} \u5B57\u8282\u5373\u4E2D\u6B62`
38
+ );
39
+ }
40
+ chunks.push(value);
41
+ }
42
+ } catch (error) {
43
+ if (isFrondError(error)) throw error;
44
+ throw new ParseError(`deflate \u89E3\u538B\u5931\u8D25\uFF08\u6E90: ${label}\uFF09`, { cause: error });
45
+ }
46
+ const out = new Uint8Array(total);
47
+ let pos = 0;
48
+ for (const chunk of chunks) {
49
+ out.set(chunk, pos);
50
+ pos += chunk.byteLength;
51
+ }
52
+ return out;
53
+ }
54
+
55
+ // src/core/zip/parse.ts
56
+ var SIGNATURE_EOCD = 101010256;
57
+ var SIGNATURE_CENTRAL = 33639248;
58
+ var SIGNATURE_LOCAL = 67324752;
59
+ var EOCD_SIZE = 22;
60
+ var EOCD_MAX_COMMENT = 65535;
61
+ var CENTRAL_HEADER_SIZE = 46;
62
+ var LOCAL_HEADER_SIZE = 30;
63
+ var ZIP64_EXTRA_ID = 1;
64
+ var FLAG_ENCRYPTED = 1;
65
+ var METHOD_STORED = 0;
66
+ var METHOD_DEFLATE = 8;
67
+ var SENTINEL_16 = 65535;
68
+ var SENTINEL_32 = 4294967295;
69
+ var DEFAULT_MAX_ENTRY_SIZE_BYTES = 64 * 1024 * 1024;
70
+ var textDecoder = new TextDecoder("utf-8");
71
+ function fail(reason, offset, label) {
72
+ throw new ParseError(`ZIP \u89E3\u6790\u5931\u8D25\uFF1A${reason}\uFF08\u6E90: ${label}\uFF0C\u504F\u79FB ${String(offset)}\uFF09`);
73
+ }
74
+ function formatFail(reason, label) {
75
+ throw new FormatError(`ZIP \u683C\u5F0F\u4E0D\u53D7\u652F\u6301\uFF1A${reason}\uFF08\u6E90: ${label}\uFF09`);
76
+ }
77
+ function toMethod(value, name, label) {
78
+ if (value === METHOD_STORED) return METHOD_STORED;
79
+ if (value === METHOD_DEFLATE) return METHOD_DEFLATE;
80
+ return formatFail(`\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u6CD5 ${String(value)}\uFF0C\u6761\u76EE "${name}"`, label);
81
+ }
82
+ function hasZip64Extra(view, offset, length) {
83
+ let cursor = offset;
84
+ const end = offset + length;
85
+ while (cursor + 4 <= end) {
86
+ if (view.getUint16(cursor, true) === ZIP64_EXTRA_ID) return true;
87
+ cursor += 4 + view.getUint16(cursor + 2, true);
88
+ }
89
+ return false;
90
+ }
91
+ function canonicalEntryName(rawName, label) {
92
+ return normalizeArchivePath(rawName, { source: label, label: "\u6761\u76EE\u540D" });
93
+ }
94
+ function lookupKey(name) {
95
+ try {
96
+ return normalizeArchivePath(name);
97
+ } catch {
98
+ return void 0;
99
+ }
100
+ }
101
+ function findEocd(view, length, label) {
102
+ if (length < EOCD_SIZE) fail("\u6587\u4EF6\u8FC7\u5C0F\uFF0C\u4E0D\u53EF\u80FD\u662F ZIP", length, label);
103
+ const floor = Math.max(0, length - EOCD_SIZE - EOCD_MAX_COMMENT);
104
+ for (let index = length - EOCD_SIZE; index >= floor; index -= 1) {
105
+ if (view.getUint32(index, true) !== SIGNATURE_EOCD) continue;
106
+ const commentLength = view.getUint16(index + 20, true);
107
+ if (index + EOCD_SIZE + commentLength === length) return index;
108
+ }
109
+ return fail("\u672A\u627E\u5230 EOCD \u8BB0\u5F55", length, label);
110
+ }
111
+ function readCentralDirectory(bytes, view, eocd, label) {
112
+ const totalEntries = view.getUint16(eocd + 10, true);
113
+ const centralSize = view.getUint32(eocd + 12, true);
114
+ const centralOffset = view.getUint32(eocd + 16, true);
115
+ if (totalEntries === SENTINEL_16 || centralSize === SENTINEL_32 || centralOffset === SENTINEL_32) {
116
+ return formatFail("\u5F52\u6863\u4E3A ZIP64\uFF0C\u4E0D\u53D7\u652F\u6301", label);
117
+ }
118
+ if (centralOffset + centralSize > eocd) {
119
+ fail("\u4E2D\u592E\u76EE\u5F55\u8303\u56F4\u8D8A\u754C", centralOffset, label);
120
+ }
121
+ const records = [];
122
+ const foldedFrom = /* @__PURE__ */ new Map();
123
+ let cursor = centralOffset;
124
+ for (let index = 0; index < totalEntries; index += 1) {
125
+ if (cursor + CENTRAL_HEADER_SIZE > bytes.length) fail("\u4E2D\u592E\u76EE\u5F55\u88AB\u622A\u65AD", cursor, label);
126
+ if (view.getUint32(cursor, true) !== SIGNATURE_CENTRAL) {
127
+ fail("\u4E2D\u592E\u76EE\u5F55\u5934\u7B7E\u540D\u65E0\u6548", cursor, label);
128
+ }
129
+ const flags = view.getUint16(cursor + 8, true);
130
+ const rawMethod = view.getUint16(cursor + 10, true);
131
+ const crc = view.getUint32(cursor + 16, true);
132
+ const compressedSize = view.getUint32(cursor + 20, true);
133
+ const uncompressedSize = view.getUint32(cursor + 24, true);
134
+ const nameLength = view.getUint16(cursor + 28, true);
135
+ const extraLength = view.getUint16(cursor + 30, true);
136
+ const commentLength = view.getUint16(cursor + 32, true);
137
+ const localOffset = view.getUint32(cursor + 42, true);
138
+ const nameStart = cursor + CENTRAL_HEADER_SIZE;
139
+ const nameEnd = nameStart + nameLength;
140
+ if (nameEnd > bytes.length) fail("\u6761\u76EE\u540D\u8D8A\u754C", nameStart, label);
141
+ if (nameEnd + extraLength + commentLength > bytes.length) {
142
+ fail("\u4E2D\u592E\u76EE\u5F55\u8BB0\u5F55\u957F\u5EA6\u8D8A\u754C", cursor, label);
143
+ }
144
+ const rawName = textDecoder.decode(bytes.subarray(nameStart, nameEnd)).replace(/\\/g, "/");
145
+ const isDirectory = rawName.endsWith("/");
146
+ const canonical = canonicalEntryName(rawName, label);
147
+ const previous = foldedFrom.get(canonical);
148
+ if (previous !== void 0 && previous !== rawName) {
149
+ throw new FormatError(
150
+ `\u6761\u76EE\u540D\u5F52\u4E00\u5316\u540E\u6B67\u4E49\uFF1A"${previous}" \u4E0E "${rawName}" \u90FD\u6307\u5411 "${canonical}"\uFF08\u6E90: ${label}\uFF09`
151
+ );
152
+ }
153
+ foldedFrom.set(canonical, rawName);
154
+ const name = isDirectory ? `${canonical}/` : canonical;
155
+ if ((flags & FLAG_ENCRYPTED) !== 0) {
156
+ formatFail(`\u6761\u76EE "${name}" \u5DF2\u52A0\u5BC6`, label);
157
+ }
158
+ if (hasZip64Extra(view, nameEnd, extraLength)) {
159
+ formatFail(`\u6761\u76EE "${name}" \u4F7F\u7528 ZIP64 \u6269\u5C55\u4FE1\u606F`, label);
160
+ }
161
+ records.push({
162
+ entry: {
163
+ name,
164
+ method: toMethod(rawMethod, name, label),
165
+ compressedSize,
166
+ uncompressedSize,
167
+ crc32: crc,
168
+ isDirectory
169
+ },
170
+ localOffset
171
+ });
172
+ cursor = nameEnd + extraLength + commentLength;
173
+ }
174
+ return records;
175
+ }
176
+ async function readEntry(bytes, record, label, maxEntrySizeBytes) {
177
+ const { entry, localOffset } = record;
178
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
179
+ if (localOffset + LOCAL_HEADER_SIZE > bytes.length) fail("local header \u8D8A\u754C", localOffset, label);
180
+ if (view.getUint32(localOffset, true) !== SIGNATURE_LOCAL) {
181
+ fail("local header \u7B7E\u540D\u65E0\u6548", localOffset, label);
182
+ }
183
+ if (entry.method === METHOD_DEFLATE && entry.uncompressedSize > maxEntrySizeBytes) {
184
+ fail(
185
+ `\u6761\u76EE "${entry.name}" \u58F0\u660E\u7684\u89E3\u538B\u5C3A\u5BF8 ${String(entry.uncompressedSize)} \u5B57\u8282\u8D85\u8FC7\u4E0A\u9650 ${String(maxEntrySizeBytes)} \u5B57\u8282`,
186
+ localOffset,
187
+ label
188
+ );
189
+ }
190
+ const nameLength = view.getUint16(localOffset + 26, true);
191
+ const extraLength = view.getUint16(localOffset + 28, true);
192
+ const dataStart = localOffset + LOCAL_HEADER_SIZE + nameLength + extraLength;
193
+ const dataEnd = dataStart + entry.compressedSize;
194
+ if (dataEnd > bytes.length) fail("\u6761\u76EE\u6570\u636E\u8D8A\u754C", dataStart, label);
195
+ const compressed = bytes.subarray(dataStart, dataEnd);
196
+ const raw = entry.method === METHOD_STORED ? compressed : await inflateRaw(compressed, label, maxEntrySizeBytes);
197
+ if (raw.length !== entry.uncompressedSize) {
198
+ fail(
199
+ `\u6761\u76EE "${entry.name}" \u957F\u5EA6\u4E0D\u7B26\uFF1A\u671F\u671B ${String(entry.uncompressedSize)}\uFF0C\u5B9E\u9645 ${String(raw.length)}`,
200
+ dataStart,
201
+ label
202
+ );
203
+ }
204
+ const actualCrc = crc32(raw);
205
+ if (actualCrc !== entry.crc32) {
206
+ fail(
207
+ `\u6761\u76EE "${entry.name}" CRC-32 \u6821\u9A8C\u5931\u8D25\uFF1A\u671F\u671B ${String(entry.crc32)}\uFF0C\u5B9E\u9645 ${String(actualCrc)}`,
208
+ dataStart,
209
+ label
210
+ );
211
+ }
212
+ return entry.method === METHOD_STORED ? new Uint8Array(raw) : raw;
213
+ }
214
+ function createArchive(bytes, records, label, maxEntrySizeBytes) {
215
+ const byKey = /* @__PURE__ */ new Map();
216
+ for (const record of records) byKey.set(normalizeArchivePath(record.entry.name), record);
217
+ const find = (name) => {
218
+ const key = lookupKey(name);
219
+ return key === void 0 ? void 0 : byKey.get(key);
220
+ };
221
+ const archive = {
222
+ entries: records.map((record) => record.entry),
223
+ entry(name) {
224
+ return find(name)?.entry;
225
+ },
226
+ async read(name, options) {
227
+ throwIfAborted(options?.signal);
228
+ const record = find(name);
229
+ if (record === void 0) formatFail(`\u6761\u76EE\u4E0D\u5B58\u5728 "${name}"`, label);
230
+ if (record.entry.isDirectory) formatFail(`\u6761\u76EE "${name}" \u662F\u76EE\u5F55\uFF0C\u65E0\u5185\u5BB9`, label);
231
+ const data = await readEntry(bytes, record, label, maxEntrySizeBytes);
232
+ return data;
233
+ },
234
+ async readText(name, options) {
235
+ const data = await archive.read(name, options);
236
+ return textDecoder.decode(data);
237
+ }
238
+ };
239
+ return archive;
240
+ }
241
+ function parseZip(bytes, options) {
242
+ const label = options?.source ?? "<anonymous>";
243
+ const maxEntrySizeBytes = options?.maxEntrySizeBytes ?? DEFAULT_MAX_ENTRY_SIZE_BYTES;
244
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
245
+ const eocd = findEocd(view, bytes.length, label);
246
+ const records = readCentralDirectory(bytes, view, eocd, label);
247
+ return createArchive(bytes, records, label, maxEntrySizeBytes);
248
+ }
249
+
250
+ export { parseZip };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var chunkG7DLWGBW_cjs = require('./chunk-G7DLWGBW.cjs');
4
+
5
+ // src/core/formats/bytes.ts
6
+ function isBookBytes(value) {
7
+ return ArrayBuffer.isView(value);
8
+ }
9
+ async function resolveBookBytes(source, options = {}) {
10
+ if (isBookBytes(source)) return source;
11
+ const label = options.source ?? "<anonymous>";
12
+ const { size } = source;
13
+ if (size === null) {
14
+ throw new chunkG7DLWGBW_cjs.FormatError(
15
+ `\u65E0\u6CD5\u6253\u5F00\u4E66\u7C4D\uFF1A\u5B57\u8282\u6E90\u672A\u63D0\u4F9B\u603B\u957F\uFF08size \u4E3A null\uFF09\uFF0C\u4E00\u6B21\u6027\u8BFB\u53D6\u9700\u8981\u5DF2\u77E5\u957F\u5EA6\uFF08\u6E90: ${label}\uFF09`
16
+ );
17
+ }
18
+ if (!Number.isInteger(size) || size < 0) {
19
+ throw new chunkG7DLWGBW_cjs.FormatError(
20
+ `\u65E0\u6CD5\u6253\u5F00\u4E66\u7C4D\uFF1A\u5B57\u8282\u6E90\u62A5\u544A\u7684\u603B\u957F\u975E\u6CD5\uFF08size = ${String(size)}\uFF09\uFF08\u6E90: ${label}\uFF09`
21
+ );
22
+ }
23
+ const bytes = await source.read({ start: 0, end: size }, options);
24
+ if (bytes.byteLength !== size) {
25
+ throw new chunkG7DLWGBW_cjs.FormatError(
26
+ `\u65E0\u6CD5\u6253\u5F00\u4E66\u7C4D\uFF1A\u5B57\u8282\u6E90\u8FD4\u56DE ${String(bytes.byteLength)} \u5B57\u8282\uFF0C\u4E0E\u62A5\u544A\u7684\u603B\u957F ${String(size)} \u4E0D\u7B26\uFF08\u6E90: ${label}\uFF09`
27
+ );
28
+ }
29
+ return bytes;
30
+ }
31
+
32
+ exports.resolveBookBytes = resolveBookBytes;
@@ -0,0 +1,162 @@
1
+ 'use strict';
2
+
3
+ var chunkGTGLDLJD_cjs = require('../chunk-GTGLDLJD.cjs');
4
+ var chunkNABYHI6X_cjs = require('../chunk-NABYHI6X.cjs');
5
+ var chunkSLI2YL25_cjs = require('../chunk-SLI2YL25.cjs');
6
+ var chunkIIV6VIUJ_cjs = require('../chunk-IIV6VIUJ.cjs');
7
+ var chunkG7DLWGBW_cjs = require('../chunk-G7DLWGBW.cjs');
8
+
9
+ // src/core/io.ts
10
+ function assertRange(start, end, size, label) {
11
+ if (!Number.isInteger(start) || !Number.isInteger(end)) {
12
+ throw new chunkG7DLWGBW_cjs.FormatError(
13
+ `\u8BFB\u53D6\u533A\u95F4\u5FC5\u987B\u662F\u6574\u6570\uFF1A\u6536\u5230 [${String(start)}, ${String(end)})\uFF08\u6E90: ${label}\uFF09`
14
+ );
15
+ }
16
+ if (start < 0) {
17
+ throw new chunkG7DLWGBW_cjs.FormatError(`\u8BFB\u53D6\u8D77\u70B9\u4E3A\u8D1F\uFF1A${String(start)}\uFF08\u6E90: ${label}\uFF09`);
18
+ }
19
+ if (end > size) {
20
+ throw new chunkG7DLWGBW_cjs.FormatError(
21
+ `\u8BFB\u53D6\u7EC8\u70B9\u8D8A\u754C\uFF1A${String(end)} \u8D85\u51FA\u5B57\u8282\u6E90\u603B\u957F ${String(size)}\uFF08\u6E90: ${label}\uFF09`
22
+ );
23
+ }
24
+ if (start > end) {
25
+ throw new chunkG7DLWGBW_cjs.FormatError(`\u8BFB\u53D6\u533A\u95F4\u8D77\u6B62\u5012\u7F6E\uFF1A[${String(start)}, ${String(end)})\uFF08\u6E90: ${label}\uFF09`);
26
+ }
27
+ }
28
+ function createMemoryBookSource(bytes, options = {}) {
29
+ const label = options.source ?? "<anonymous>";
30
+ const size = bytes.byteLength;
31
+ let closed = false;
32
+ return {
33
+ size,
34
+ read(range, readOptions) {
35
+ return Promise.resolve().then(() => {
36
+ chunkG7DLWGBW_cjs.throwIfAborted(readOptions?.signal);
37
+ if (closed) {
38
+ throw new chunkG7DLWGBW_cjs.StateError(`\u5B57\u8282\u6E90\u5DF2\u5173\u95ED\uFF0C\u65E0\u6CD5\u8BFB\u53D6\uFF08\u6E90: ${label}\uFF09`);
39
+ }
40
+ assertRange(range.start, range.end, size, label);
41
+ return bytes.subarray(range.start, range.end);
42
+ });
43
+ },
44
+ close() {
45
+ closed = true;
46
+ }
47
+ };
48
+ }
49
+
50
+ Object.defineProperty(exports, "collapseCfi", {
51
+ enumerable: true,
52
+ get: function () { return chunkGTGLDLJD_cjs.collapseCfi; }
53
+ });
54
+ Object.defineProperty(exports, "isCfi", {
55
+ enumerable: true,
56
+ get: function () { return chunkGTGLDLJD_cjs.isCfi; }
57
+ });
58
+ Object.defineProperty(exports, "isCfiString", {
59
+ enumerable: true,
60
+ get: function () { return chunkGTGLDLJD_cjs.isCfiString; }
61
+ });
62
+ Object.defineProperty(exports, "parseCfi", {
63
+ enumerable: true,
64
+ get: function () { return chunkGTGLDLJD_cjs.parseCfi; }
65
+ });
66
+ Object.defineProperty(exports, "serializeCfi", {
67
+ enumerable: true,
68
+ get: function () { return chunkGTGLDLJD_cjs.serializeCfi; }
69
+ });
70
+ Object.defineProperty(exports, "findAll", {
71
+ enumerable: true,
72
+ get: function () { return chunkNABYHI6X_cjs.findAll; }
73
+ });
74
+ Object.defineProperty(exports, "findFirst", {
75
+ enumerable: true,
76
+ get: function () { return chunkNABYHI6X_cjs.findFirst; }
77
+ });
78
+ Object.defineProperty(exports, "getAttribute", {
79
+ enumerable: true,
80
+ get: function () { return chunkNABYHI6X_cjs.getAttribute; }
81
+ });
82
+ Object.defineProperty(exports, "getText", {
83
+ enumerable: true,
84
+ get: function () { return chunkNABYHI6X_cjs.getText; }
85
+ });
86
+ Object.defineProperty(exports, "isElement", {
87
+ enumerable: true,
88
+ get: function () { return chunkNABYHI6X_cjs.isElement; }
89
+ });
90
+ Object.defineProperty(exports, "parseXml", {
91
+ enumerable: true,
92
+ get: function () { return chunkNABYHI6X_cjs.parseXml; }
93
+ });
94
+ Object.defineProperty(exports, "parseZip", {
95
+ enumerable: true,
96
+ get: function () { return chunkSLI2YL25_cjs.parseZip; }
97
+ });
98
+ Object.defineProperty(exports, "directoryOf", {
99
+ enumerable: true,
100
+ get: function () { return chunkIIV6VIUJ_cjs.directoryOf; }
101
+ });
102
+ Object.defineProperty(exports, "normalizeArchivePath", {
103
+ enumerable: true,
104
+ get: function () { return chunkIIV6VIUJ_cjs.normalizeArchivePath; }
105
+ });
106
+ Object.defineProperty(exports, "resolveArchivePath", {
107
+ enumerable: true,
108
+ get: function () { return chunkIIV6VIUJ_cjs.resolveArchivePath; }
109
+ });
110
+ Object.defineProperty(exports, "AbortError", {
111
+ enumerable: true,
112
+ get: function () { return chunkG7DLWGBW_cjs.AbortError; }
113
+ });
114
+ Object.defineProperty(exports, "FormatError", {
115
+ enumerable: true,
116
+ get: function () { return chunkG7DLWGBW_cjs.FormatError; }
117
+ });
118
+ Object.defineProperty(exports, "FrondError", {
119
+ enumerable: true,
120
+ get: function () { return chunkG7DLWGBW_cjs.FrondError; }
121
+ });
122
+ Object.defineProperty(exports, "NetworkError", {
123
+ enumerable: true,
124
+ get: function () { return chunkG7DLWGBW_cjs.NetworkError; }
125
+ });
126
+ Object.defineProperty(exports, "ParseError", {
127
+ enumerable: true,
128
+ get: function () { return chunkG7DLWGBW_cjs.ParseError; }
129
+ });
130
+ Object.defineProperty(exports, "SecurityError", {
131
+ enumerable: true,
132
+ get: function () { return chunkG7DLWGBW_cjs.SecurityError; }
133
+ });
134
+ Object.defineProperty(exports, "StateError", {
135
+ enumerable: true,
136
+ get: function () { return chunkG7DLWGBW_cjs.StateError; }
137
+ });
138
+ Object.defineProperty(exports, "createAbortError", {
139
+ enumerable: true,
140
+ get: function () { return chunkG7DLWGBW_cjs.createAbortError; }
141
+ });
142
+ Object.defineProperty(exports, "isAbortError", {
143
+ enumerable: true,
144
+ get: function () { return chunkG7DLWGBW_cjs.isAbortError; }
145
+ });
146
+ Object.defineProperty(exports, "isFrondError", {
147
+ enumerable: true,
148
+ get: function () { return chunkG7DLWGBW_cjs.isFrondError; }
149
+ });
150
+ Object.defineProperty(exports, "linkSignals", {
151
+ enumerable: true,
152
+ get: function () { return chunkG7DLWGBW_cjs.linkSignals; }
153
+ });
154
+ Object.defineProperty(exports, "onAbort", {
155
+ enumerable: true,
156
+ get: function () { return chunkG7DLWGBW_cjs.onAbort; }
157
+ });
158
+ Object.defineProperty(exports, "throwIfAborted", {
159
+ enumerable: true,
160
+ get: function () { return chunkG7DLWGBW_cjs.throwIfAborted; }
161
+ });
162
+ exports.createMemoryBookSource = createMemoryBookSource;