@loaders.gl/zip 4.1.0-alpha.1 → 4.1.0-alpha.11
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/dist.dev.js +875 -64
- package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
- package/dist/filesystems/zip-filesystem.js.map +1 -1
- package/dist/hash-file-utility.d.ts +19 -0
- package/dist/hash-file-utility.d.ts.map +1 -1
- package/dist/hash-file-utility.js +30 -0
- package/dist/hash-file-utility.js.map +1 -1
- package/dist/index.cjs +542 -56
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/tar/header.d.ts.map +1 -1
- package/dist/lib/tar/header.js.map +1 -1
- package/dist/lib/tar/tar.d.ts.map +1 -1
- package/dist/lib/tar/tar.js.map +1 -1
- package/dist/lib/tar/types.d.ts.map +1 -1
- package/dist/lib/tar/types.js.map +1 -1
- package/dist/lib/tar/utils.d.ts.map +1 -1
- package/dist/lib/tar/utils.js.map +1 -1
- package/dist/parse-zip/cd-file-header.d.ts +1 -1
- package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
- package/dist/parse-zip/cd-file-header.js +4 -4
- package/dist/parse-zip/cd-file-header.js.map +1 -1
- package/dist/parse-zip/end-of-central-directory.d.ts +35 -0
- package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -1
- package/dist/parse-zip/end-of-central-directory.js +161 -9
- package/dist/parse-zip/end-of-central-directory.js.map +1 -1
- package/dist/parse-zip/local-file-header.d.ts +16 -0
- package/dist/parse-zip/local-file-header.d.ts.map +1 -1
- package/dist/parse-zip/local-file-header.js +73 -1
- package/dist/parse-zip/local-file-header.js.map +1 -1
- package/dist/parse-zip/search-from-the-end.d.ts.map +1 -1
- package/dist/parse-zip/search-from-the-end.js.map +1 -1
- package/dist/parse-zip/zip-composition.d.ts +38 -0
- package/dist/parse-zip/zip-composition.d.ts.map +1 -0
- package/dist/parse-zip/zip-composition.js +115 -0
- package/dist/parse-zip/zip-composition.js.map +1 -0
- package/dist/parse-zip/zip64-info-generation.d.ts +5 -8
- package/dist/parse-zip/zip64-info-generation.d.ts.map +1 -1
- package/dist/parse-zip/zip64-info-generation.js +6 -3
- package/dist/parse-zip/zip64-info-generation.js.map +1 -1
- package/dist/tar-builder.d.ts.map +1 -1
- package/dist/tar-builder.js.map +1 -1
- package/dist/zip-loader.d.ts.map +1 -1
- package/dist/zip-loader.js +1 -1
- package/dist/zip-loader.js.map +1 -1
- package/dist/zip-writer.d.ts +2 -2
- package/dist/zip-writer.d.ts.map +1 -1
- package/dist/zip-writer.js +22 -7
- package/dist/zip-writer.js.map +1 -1
- package/package.json +7 -7
- package/src/filesystems/zip-filesystem.ts +2 -1
- package/src/hash-file-utility.ts +84 -3
- package/src/index.ts +6 -3
- package/src/lib/tar/header.ts +2 -1
- package/src/lib/tar/tar.ts +2 -1
- package/src/lib/tar/types.ts +2 -1
- package/src/lib/tar/utils.ts +2 -1
- package/src/parse-zip/cd-file-header.ts +8 -6
- package/src/parse-zip/end-of-central-directory.ts +338 -10
- package/src/parse-zip/local-file-header.ts +128 -2
- package/src/parse-zip/search-from-the-end.ts +2 -1
- package/src/parse-zip/zip-composition.ts +235 -0
- package/src/parse-zip/zip64-info-generation.ts +21 -5
- package/src/tar-builder.ts +2 -1
- package/src/zip-loader.ts +2 -1
- package/src/zip-writer.ts +24 -10
package/dist/zip-writer.js
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
import JSZip from 'jszip';
|
|
2
|
+
const VERSION = typeof "4.1.0-alpha.11" !== 'undefined' ? "4.1.0-alpha.11" : 'latest';
|
|
2
3
|
export const ZipWriter = {
|
|
3
4
|
name: 'Zip Archive',
|
|
5
|
+
id: 'zip',
|
|
6
|
+
module: 'zip',
|
|
7
|
+
version: VERSION,
|
|
4
8
|
extensions: ['zip'],
|
|
5
9
|
category: 'archive',
|
|
6
10
|
mimeTypes: ['application/zip'],
|
|
11
|
+
options: {
|
|
12
|
+
zip: {
|
|
13
|
+
onUpdate: () => {}
|
|
14
|
+
},
|
|
15
|
+
jszip: {}
|
|
16
|
+
},
|
|
7
17
|
encode: encodeZipAsync
|
|
8
18
|
};
|
|
9
19
|
async function encodeZipAsync(fileMap) {
|
|
20
|
+
var _ZipWriter$options;
|
|
10
21
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
11
22
|
const jsZip = new JSZip();
|
|
12
23
|
for (const subFileName in fileMap) {
|
|
13
24
|
const subFileData = fileMap[subFileName];
|
|
14
25
|
jsZip.file(subFileName, subFileData, (options === null || options === void 0 ? void 0 : options.jszip) || {});
|
|
15
26
|
}
|
|
27
|
+
const zipOptions = {
|
|
28
|
+
...ZipWriter.options.zip,
|
|
29
|
+
...(options === null || options === void 0 ? void 0 : options.zip)
|
|
30
|
+
};
|
|
16
31
|
const jszipOptions = {
|
|
17
|
-
...(options === null || options === void 0 ? void 0 : options.jszip),
|
|
18
|
-
|
|
32
|
+
...((_ZipWriter$options = ZipWriter.options) === null || _ZipWriter$options === void 0 ? void 0 : _ZipWriter$options.jszip),
|
|
33
|
+
...options.jszip
|
|
19
34
|
};
|
|
20
|
-
const {
|
|
21
|
-
onUpdate = () => {}
|
|
22
|
-
} = options;
|
|
23
35
|
try {
|
|
24
|
-
return await jsZip.generateAsync(
|
|
36
|
+
return await jsZip.generateAsync({
|
|
37
|
+
...jszipOptions,
|
|
38
|
+
type: 'arraybuffer'
|
|
39
|
+
}, zipOptions.onUpdate);
|
|
25
40
|
} catch (error) {
|
|
26
|
-
options.log.error(`Unable to
|
|
41
|
+
options.log.error(`Unable to encode zip archive: ${error}`);
|
|
27
42
|
throw error;
|
|
28
43
|
}
|
|
29
44
|
}
|
package/dist/zip-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-writer.js","names":["JSZip","ZipWriter","name","extensions","category","mimeTypes","encode","encodeZipAsync","fileMap","options","arguments","length","undefined","jsZip","subFileName","subFileData","file","
|
|
1
|
+
{"version":3,"file":"zip-writer.js","names":["JSZip","VERSION","ZipWriter","name","id","module","version","extensions","category","mimeTypes","options","zip","onUpdate","jszip","encode","encodeZipAsync","fileMap","_ZipWriter$options","arguments","length","undefined","jsZip","subFileName","subFileData","file","zipOptions","jszipOptions","generateAsync","type","error","log"],"sources":["../src/zip-writer.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';\nimport JSZip, {JSZipGeneratorOptions} from 'jszip';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ZipWriterOptions = WriterOptions & {\n zip?: {\n onUpdate?: (metadata: {percent: number}) => void;\n };\n /** Passthrough options to jszip */\n jszip?: JSZipGeneratorOptions;\n};\n\n/**\n * Zip exporter\n */\nexport const ZipWriter: WriterWithEncoder<Record<string, ArrayBuffer>, never, ZipWriterOptions> = {\n name: 'Zip Archive',\n id: 'zip',\n module: 'zip',\n version: VERSION,\n extensions: ['zip'],\n category: 'archive',\n mimeTypes: ['application/zip'],\n options: {\n zip: {\n onUpdate: () => {}\n },\n jszip: {}\n },\n encode: encodeZipAsync\n};\n\nasync function encodeZipAsync(\n fileMap: Record<string, ArrayBuffer>,\n options: ZipWriterOptions = {}\n): Promise<ArrayBuffer> {\n const jsZip = new JSZip();\n // add files to the zip\n for (const subFileName in fileMap) {\n const subFileData = fileMap[subFileName];\n\n // jszip supports both arraybuffer and string data (the main loaders.gl types)\n // https://stuk.github.io/jszip/documentation/api_zipobject/async.html\n jsZip.file(subFileName, subFileData, options?.jszip || {});\n }\n\n const zipOptions = {...ZipWriter.options.zip, ...options?.zip};\n const jszipOptions: JSZipGeneratorOptions = {...ZipWriter.options?.jszip, ...options.jszip};\n\n try {\n return await jsZip.generateAsync(\n {...jszipOptions, type: 'arraybuffer'}, // generate an arraybuffer\n zipOptions.onUpdate\n );\n } catch (error) {\n options.log.error(`Unable to encode zip archive: ${error}`);\n throw error;\n }\n}\n"],"mappings":"AAKA,OAAOA,KAAK,MAA+B,OAAO;AAGlD,MAAMC,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAa3E,OAAO,MAAMC,SAAkF,GAAG;EAChGC,IAAI,EAAE,aAAa;EACnBC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,QAAQ,EAAE,SAAS;EACnBC,SAAS,EAAE,CAAC,iBAAiB,CAAC;EAC9BC,OAAO,EAAE;IACPC,GAAG,EAAE;MACHC,QAAQ,EAAEA,CAAA,KAAM,CAAC;IACnB,CAAC;IACDC,KAAK,EAAE,CAAC;EACV,CAAC;EACDC,MAAM,EAAEC;AACV,CAAC;AAED,eAAeA,cAAcA,CAC3BC,OAAoC,EAEd;EAAA,IAAAC,kBAAA;EAAA,IADtBP,OAAyB,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9B,MAAMG,KAAK,GAAG,IAAIrB,KAAK,CAAC,CAAC;EAEzB,KAAK,MAAMsB,WAAW,IAAIN,OAAO,EAAE;IACjC,MAAMO,WAAW,GAAGP,OAAO,CAACM,WAAW,CAAC;IAIxCD,KAAK,CAACG,IAAI,CAACF,WAAW,EAAEC,WAAW,EAAE,CAAAb,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,KAAK,KAAI,CAAC,CAAC,CAAC;EAC5D;EAEA,MAAMY,UAAU,GAAG;IAAC,GAAGvB,SAAS,CAACQ,OAAO,CAACC,GAAG;IAAE,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EAAA,CAAC;EAC9D,MAAMe,YAAmC,GAAG;IAAC,KAAAT,kBAAA,GAAGf,SAAS,CAACQ,OAAO,cAAAO,kBAAA,uBAAjBA,kBAAA,CAAmBJ,KAAK;IAAE,GAAGH,OAAO,CAACG;EAAK,CAAC;EAE3F,IAAI;IACF,OAAO,MAAMQ,KAAK,CAACM,aAAa,CAC9B;MAAC,GAAGD,YAAY;MAAEE,IAAI,EAAE;IAAa,CAAC,EACtCH,UAAU,CAACb,QACb,CAAC;EACH,CAAC,CAAC,OAAOiB,KAAK,EAAE;IACdnB,OAAO,CAACoB,GAAG,CAACD,KAAK,CAAE,iCAAgCA,KAAM,EAAC,CAAC;IAC3D,MAAMA,KAAK;EACb;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/zip",
|
|
3
|
-
"version": "4.1.0-alpha.
|
|
3
|
+
"version": "4.1.0-alpha.11",
|
|
4
4
|
"description": "Zip Archive Loader",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"module": "dist/index.js",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
25
26
|
"import": "./dist/index.js",
|
|
26
|
-
"require": "./dist/index.cjs"
|
|
27
|
-
"types": "./dist/index.d.ts"
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"sideEffects": false,
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"build-bundle": "ocular-bundle ./src/index.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@loaders.gl/compression": "4.1.0-alpha.
|
|
42
|
-
"@loaders.gl/crypto": "4.1.0-alpha.
|
|
43
|
-
"@loaders.gl/loader-utils": "4.1.0-alpha.
|
|
41
|
+
"@loaders.gl/compression": "4.1.0-alpha.11",
|
|
42
|
+
"@loaders.gl/crypto": "4.1.0-alpha.11",
|
|
43
|
+
"@loaders.gl/loader-utils": "4.1.0-alpha.11",
|
|
44
44
|
"jszip": "^3.1.5",
|
|
45
45
|
"md5": "^2.3.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5d3e23bf93762b48c8c1d6d926ede7a97fe43ab0"
|
|
48
48
|
}
|
package/src/hash-file-utility.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {MD5Hash} from '@loaders.gl/crypto';
|
|
5
|
-
import {
|
|
6
|
-
|
|
6
|
+
import {
|
|
7
|
+
FileProvider,
|
|
8
|
+
concatenateArrayBuffers,
|
|
9
|
+
concatenateArrayBuffersFromArray
|
|
10
|
+
} from '@loaders.gl/loader-utils';
|
|
11
|
+
import {ZipCDFileHeader, makeZipCDHeaderIterator} from './parse-zip/cd-file-header';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Reads hash file from buffer and returns it in ready-to-use form
|
|
@@ -40,6 +45,17 @@ export async function makeHashTableFromZipHeaders(
|
|
|
40
45
|
fileProvider: FileProvider
|
|
41
46
|
): Promise<Record<string, bigint>> {
|
|
42
47
|
const zipCDIterator = makeZipCDHeaderIterator(fileProvider);
|
|
48
|
+
return getHashTable(zipCDIterator);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* creates hash table from file offset iterator
|
|
53
|
+
* @param zipCDIterator iterator to use
|
|
54
|
+
* @returns hash table
|
|
55
|
+
*/
|
|
56
|
+
export async function getHashTable(
|
|
57
|
+
zipCDIterator: AsyncIterable<ZipCDFileHeader>
|
|
58
|
+
): Promise<Record<string, bigint>> {
|
|
43
59
|
const md5Hash = new MD5Hash();
|
|
44
60
|
const textEncoder = new TextEncoder();
|
|
45
61
|
|
|
@@ -54,3 +70,68 @@ export async function makeHashTableFromZipHeaders(
|
|
|
54
70
|
|
|
55
71
|
return hashTable;
|
|
56
72
|
}
|
|
73
|
+
|
|
74
|
+
/** item of the file offset list */
|
|
75
|
+
type FileListItem = {
|
|
76
|
+
fileName: string;
|
|
77
|
+
localHeaderOffset: bigint;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* creates hash file that later can be added to the SLPK archive
|
|
82
|
+
* @param zipCDIterator iterator to use
|
|
83
|
+
* @returns ArrayBuffer containing hash file
|
|
84
|
+
*/
|
|
85
|
+
export async function composeHashFile(
|
|
86
|
+
zipCDIterator: AsyncIterable<FileListItem> | Iterable<FileListItem>
|
|
87
|
+
): Promise<ArrayBuffer> {
|
|
88
|
+
const md5Hash = new MD5Hash();
|
|
89
|
+
const textEncoder = new TextEncoder();
|
|
90
|
+
|
|
91
|
+
const hashArray: ArrayBuffer[] = [];
|
|
92
|
+
|
|
93
|
+
for await (const cdHeader of zipCDIterator) {
|
|
94
|
+
const filename = cdHeader.fileName.split('\\').join('/').toLocaleLowerCase();
|
|
95
|
+
const arrayBuffer = textEncoder.encode(filename).buffer;
|
|
96
|
+
const md5 = await md5Hash.hash(arrayBuffer, 'hex');
|
|
97
|
+
hashArray.push(
|
|
98
|
+
concatenateArrayBuffers(hexStringToBuffer(md5), bigintToBuffer(cdHeader.localHeaderOffset))
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const bufferArray = hashArray.sort(compareHashes);
|
|
103
|
+
|
|
104
|
+
return concatenateArrayBuffersFromArray(bufferArray);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Function to compare md5 hashes according to https://github.com/Esri/i3s-spec/blob/master/docs/2.0/slpk_hashtable.pcsl.md
|
|
109
|
+
* @param arrA first hash to compare
|
|
110
|
+
* @param arrB second hash to compare
|
|
111
|
+
* @returns 0 if equal, negative number if a<b, pozitive if a>b
|
|
112
|
+
*/
|
|
113
|
+
function compareHashes(arrA: ArrayBuffer, arrB: ArrayBuffer): number {
|
|
114
|
+
const a = new BigUint64Array(arrA);
|
|
115
|
+
const b = new BigUint64Array(arrB);
|
|
116
|
+
|
|
117
|
+
return Number(a[0] === b[0] ? a[1] - b[1] : a[0] - b[0]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* converts hex string to buffer
|
|
122
|
+
* @param str hex string to convert
|
|
123
|
+
* @returns conversion result
|
|
124
|
+
*/
|
|
125
|
+
function hexStringToBuffer(str: string): ArrayBuffer {
|
|
126
|
+
const byteArray = str.match(/../g)?.map((h) => parseInt(h, 16));
|
|
127
|
+
return new Uint8Array(byteArray ?? new Array(16)).buffer;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* converts bigint to buffer
|
|
132
|
+
* @param n bigint to convert
|
|
133
|
+
* @returns convertion result
|
|
134
|
+
*/
|
|
135
|
+
function bigintToBuffer(n: bigint): ArrayBuffer {
|
|
136
|
+
return new BigUint64Array([n]).buffer;
|
|
137
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
export {ZipLoader} from './zip-loader';
|
|
@@ -13,12 +14,14 @@ export {
|
|
|
13
14
|
} from './parse-zip/cd-file-header';
|
|
14
15
|
export {
|
|
15
16
|
parseZipLocalFileHeader,
|
|
16
|
-
signature as localHeaderSignature
|
|
17
|
+
signature as localHeaderSignature,
|
|
18
|
+
generateLocalHeader
|
|
17
19
|
} from './parse-zip/local-file-header';
|
|
18
20
|
export {parseEoCDRecord} from './parse-zip/end-of-central-directory';
|
|
19
21
|
export {searchFromTheEnd} from './parse-zip/search-from-the-end';
|
|
22
|
+
export {addOneFile, createZip} from './parse-zip/zip-composition';
|
|
20
23
|
|
|
21
24
|
// export type {HashElement} from './hash-file-utility';
|
|
22
|
-
export {parseHashTable, makeHashTableFromZipHeaders} from './hash-file-utility';
|
|
25
|
+
export {parseHashTable, makeHashTableFromZipHeaders, composeHashFile} from './hash-file-utility';
|
|
23
26
|
|
|
24
27
|
export {ZipFileSystem} from './filesystems/zip-filesystem';
|
package/src/lib/tar/header.ts
CHANGED
package/src/lib/tar/tar.ts
CHANGED
package/src/lib/tar/types.ts
CHANGED
package/src/lib/tar/utils.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {FileProvider, compareArrayBuffers, concatenateArrayBuffers} from '@loaders.gl/loader-utils';
|
|
5
6
|
import {parseEoCDRecord} from './end-of-central-directory';
|
|
6
7
|
import {ZipSignature} from './search-from-the-end';
|
|
7
|
-
import {createZip64Info,
|
|
8
|
+
import {createZip64Info, setFieldToNumber} from './zip64-info-generation';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* zip central directory file header info
|
|
@@ -199,7 +200,7 @@ type GenerateCDOptions = {
|
|
|
199
200
|
/** File size */
|
|
200
201
|
length: number;
|
|
201
202
|
/** Relative offset of local file header */
|
|
202
|
-
offset:
|
|
203
|
+
offset: bigint;
|
|
203
204
|
};
|
|
204
205
|
|
|
205
206
|
/**
|
|
@@ -219,7 +220,7 @@ export function generateCDHeader(options: GenerateCDOptions): ArrayBuffer {
|
|
|
219
220
|
const optionsToZip64: any = {};
|
|
220
221
|
if (optionsToUse.offset >= 0xffffffff) {
|
|
221
222
|
optionsToZip64.offset = optionsToUse.offset;
|
|
222
|
-
optionsToUse.offset = 0xffffffff;
|
|
223
|
+
optionsToUse.offset = BigInt(0xffffffff);
|
|
223
224
|
}
|
|
224
225
|
if (optionsToUse.length >= 0xffffffff) {
|
|
225
226
|
optionsToZip64.size = optionsToUse.length;
|
|
@@ -230,11 +231,12 @@ export function generateCDHeader(options: GenerateCDOptions): ArrayBuffer {
|
|
|
230
231
|
zip64header = createZip64Info(optionsToZip64);
|
|
231
232
|
optionsToUse.extraLength = zip64header.byteLength;
|
|
232
233
|
}
|
|
233
|
-
const header = new DataView(new ArrayBuffer(
|
|
234
|
+
const header = new DataView(new ArrayBuffer(Number(CD_FILE_NAME_OFFSET)));
|
|
234
235
|
|
|
235
236
|
for (const field of ZIP_HEADER_FIELDS) {
|
|
236
|
-
|
|
237
|
+
setFieldToNumber(
|
|
237
238
|
header,
|
|
239
|
+
field.size,
|
|
238
240
|
field.offset,
|
|
239
241
|
optionsToUse[field.name ?? ''] ?? field.default ?? 0
|
|
240
242
|
);
|