@loaders.gl/i3s 4.0.0-alpha.14 → 4.0.0-alpha.16
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.min.js +329 -211
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js +1 -1
- package/dist/es5/i3s-loader.js +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/i3s-slpk-loader.js +30 -2
- package/dist/es5/i3s-slpk-loader.js.map +1 -1
- package/dist/es5/index.js +7 -7
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +14 -15
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +101 -76
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +54 -34
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +76 -39
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/data-view-file-provider.js +129 -0
- package/dist/es5/lib/parsers/parse-zip/data-view-file-provider.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/end-of-central-directory.js +100 -0
- package/dist/es5/lib/parsers/parse-zip/end-of-central-directory.js.map +1 -0
- package/dist/es5/lib/parsers/parse-zip/file-provider.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js +55 -14
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/search-from-the-end.js +69 -0
- package/dist/es5/lib/parsers/parse-zip/search-from-the-end.js.map +1 -0
- package/dist/es5/types.js +1 -14
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-slpk-loader.js +8 -2
- package/dist/esm/i3s-slpk-loader.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +14 -15
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +50 -35
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +38 -22
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js +30 -22
- package/dist/esm/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-zip/data-view-file-provider.js +32 -0
- package/dist/esm/lib/parsers/parse-zip/data-view-file-provider.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/end-of-central-directory.js +33 -0
- package/dist/esm/lib/parsers/parse-zip/end-of-central-directory.js.map +1 -0
- package/dist/esm/lib/parsers/parse-zip/file-provider.js.map +1 -1
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js +25 -10
- package/dist/esm/lib/parsers/parse-zip/local-file-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-zip/search-from-the-end.js +16 -0
- package/dist/esm/lib/parsers/parse-zip/search-from-the-end.js.map +1 -0
- package/dist/esm/types.js +0 -12
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-worker-node.js +47 -47
- package/dist/i3s-content-worker-node.js.map +2 -2
- package/dist/i3s-content-worker.js +22 -34
- package/dist/i3s-slpk-loader.d.ts +3 -0
- package/dist/i3s-slpk-loader.d.ts.map +1 -1
- package/dist/i3s-slpk-loader.js +11 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/parsers/constants.d.ts.map +1 -1
- package/dist/lib/parsers/constants.js +14 -15
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts +9 -3
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.js +65 -42
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +22 -10
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -1
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +56 -28
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts +9 -5
- package/dist/lib/parsers/parse-zip/cd-file-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-zip/cd-file-header.js +32 -25
- package/dist/lib/parsers/parse-zip/{buffer-file-provider.d.ts → data-view-file-provider.d.ts} +15 -16
- package/dist/lib/parsers/parse-zip/data-view-file-provider.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/{buffer-file-provider.js → data-view-file-provider.js} +28 -14
- package/dist/lib/parsers/parse-zip/end-of-central-directory.d.ts +18 -0
- package/dist/lib/parsers/parse-zip/end-of-central-directory.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/end-of-central-directory.js +41 -0
- package/dist/lib/parsers/parse-zip/file-provider.d.ts +10 -5
- package/dist/lib/parsers/parse-zip/file-provider.d.ts.map +1 -1
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts +5 -3
- package/dist/lib/parsers/parse-zip/local-file-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-zip/local-file-header.js +30 -11
- package/dist/lib/parsers/parse-zip/search-from-the-end.d.ts +11 -0
- package/dist/lib/parsers/parse-zip/search-from-the-end.d.ts.map +1 -0
- package/dist/lib/parsers/parse-zip/search-from-the-end.js +31 -0
- package/dist/types.d.ts +17 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -13
- package/package.json +9 -9
- package/src/i3s-slpk-loader.ts +19 -1
- package/src/index.ts +2 -2
- package/src/lib/parsers/constants.ts +14 -15
- package/src/lib/parsers/parse-slpk/parse-slpk.ts +83 -58
- package/src/lib/parsers/parse-slpk/slpk-archieve.ts +59 -44
- package/src/lib/parsers/parse-zip/cd-file-header.ts +52 -32
- package/src/lib/parsers/parse-zip/data-view-file-provider.ts +69 -0
- package/src/lib/parsers/parse-zip/end-of-central-directory.ts +78 -0
- package/src/lib/parsers/parse-zip/file-provider.ts +11 -5
- package/src/lib/parsers/parse-zip/local-file-header.ts +45 -19
- package/src/lib/parsers/parse-zip/search-from-the-end.ts +38 -0
- package/src/types.ts +25 -40
- package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js +0 -46
- package/dist/es5/lib/parsers/parse-zip/buffer-file-provider.js.map +0 -1
- package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js +0 -23
- package/dist/esm/lib/parsers/parse-zip/buffer-file-provider.js.map +0 -1
- package/dist/lib/parsers/parse-zip/buffer-file-provider.d.ts.map +0 -1
- package/src/lib/parsers/parse-zip/buffer-file-provider.ts +0 -55
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseZipCDFileHeader = void 0;
|
|
3
|
+
exports.parseZipCDFileHeader = exports.signature = void 0;
|
|
4
|
+
const offsets = {
|
|
5
|
+
CD_COMPRESSED_SIZE_OFFSET: 20n,
|
|
6
|
+
CD_UNCOMPRESSED_SIZE_OFFSET: 24n,
|
|
7
|
+
CD_FILE_NAME_LENGTH_OFFSET: 28n,
|
|
8
|
+
CD_EXTRA_FIELD_LENGTH_OFFSET: 30n,
|
|
9
|
+
CD_LOCAL_HEADER_OFFSET_OFFSET: 42n,
|
|
10
|
+
CD_FILE_NAME_OFFSET: 46n
|
|
11
|
+
};
|
|
12
|
+
exports.signature = [0x50, 0x4b, 0x01, 0x02];
|
|
4
13
|
/**
|
|
5
14
|
* Parses central directory file header of zip file
|
|
6
15
|
* @param headerOffset - offset in the archive where header starts
|
|
@@ -8,37 +17,35 @@ exports.parseZipCDFileHeader = void 0;
|
|
|
8
17
|
* @returns Info from the header
|
|
9
18
|
*/
|
|
10
19
|
const parseZipCDFileHeader = async (headerOffset, buffer) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
CD_FILE_NAME_OFFSET: 46
|
|
18
|
-
};
|
|
19
|
-
const compressedSize = await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET);
|
|
20
|
-
const uncompressedSize = await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET);
|
|
20
|
+
if (Buffer.from(await buffer.slice(headerOffset, headerOffset + 4n)).compare(Buffer.from(exports.signature)) !== 0) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
let compressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.CD_COMPRESSED_SIZE_OFFSET));
|
|
24
|
+
let uncompressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.CD_UNCOMPRESSED_SIZE_OFFSET));
|
|
25
|
+
const extraFieldLength = await buffer.getUint16(headerOffset + offsets.CD_EXTRA_FIELD_LENGTH_OFFSET);
|
|
21
26
|
const fileNameLength = await buffer.getUint16(headerOffset + offsets.CD_FILE_NAME_LENGTH_OFFSET);
|
|
22
|
-
const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength));
|
|
23
|
-
const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + fileNameLength;
|
|
27
|
+
const fileName = new TextDecoder().decode(await buffer.slice(headerOffset + offsets.CD_FILE_NAME_OFFSET, headerOffset + offsets.CD_FILE_NAME_OFFSET + BigInt(fileNameLength)));
|
|
28
|
+
const extraOffset = headerOffset + offsets.CD_FILE_NAME_OFFSET + BigInt(fileNameLength);
|
|
24
29
|
const oldFormatOffset = await buffer.getUint32(headerOffset + offsets.CD_LOCAL_HEADER_OFFSET_OFFSET);
|
|
25
|
-
let fileDataOffset = oldFormatOffset;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
let fileDataOffset = BigInt(oldFormatOffset);
|
|
31
|
+
let offsetInZip64Data = 4n;
|
|
32
|
+
// looking for info that might be also be in zip64 extra field
|
|
33
|
+
if (uncompressedSize === BigInt(0xffffffff)) {
|
|
34
|
+
uncompressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
|
|
35
|
+
offsetInZip64Data += 8n;
|
|
36
|
+
}
|
|
37
|
+
if (compressedSize === BigInt(0xffffffff)) {
|
|
38
|
+
compressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
|
|
39
|
+
offsetInZip64Data += 8n;
|
|
40
|
+
}
|
|
41
|
+
if (fileDataOffset === BigInt(0xffffffff)) {
|
|
42
|
+
fileDataOffset = await buffer.getBigUint64(extraOffset + offsetInZip64Data); // setting it to the one from zip64
|
|
37
43
|
}
|
|
38
44
|
const localHeaderOffset = fileDataOffset;
|
|
39
45
|
return {
|
|
40
46
|
compressedSize,
|
|
41
47
|
uncompressedSize,
|
|
48
|
+
extraFieldLength,
|
|
42
49
|
fileNameLength,
|
|
43
50
|
fileName,
|
|
44
51
|
extraOffset,
|
package/dist/lib/parsers/parse-zip/{buffer-file-provider.d.ts → data-view-file-provider.d.ts}
RENAMED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { FileProvider } from './file-provider';
|
|
2
|
-
/**
|
|
3
|
-
* Provides file data using DataView
|
|
4
|
-
*/
|
|
2
|
+
/** Provides file data using DataView */
|
|
5
3
|
export declare class DataViewFileProvider implements FileProvider {
|
|
6
|
-
/**
|
|
7
|
-
* The DataView from which data is provided
|
|
8
|
-
*/
|
|
4
|
+
/** The DataView from which data is provided */
|
|
9
5
|
private file;
|
|
10
6
|
constructor(file: DataView);
|
|
11
7
|
/**
|
|
12
8
|
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
13
9
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
14
10
|
*/
|
|
15
|
-
getUint8(offset:
|
|
11
|
+
getUint8(offset: bigint): Promise<number>;
|
|
16
12
|
/**
|
|
17
|
-
* Gets an unsigned 16-bit
|
|
13
|
+
* Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
|
|
18
14
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
19
15
|
*/
|
|
20
|
-
getUint16(offset:
|
|
16
|
+
getUint16(offset: bigint): Promise<number>;
|
|
21
17
|
/**
|
|
22
18
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
23
19
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
24
20
|
*/
|
|
25
|
-
getUint32(offset:
|
|
21
|
+
getUint32(offset: bigint): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
|
|
24
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
25
|
+
*/
|
|
26
|
+
getBigUint64(offset: bigint): Promise<bigint>;
|
|
26
27
|
/**
|
|
27
28
|
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
28
29
|
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
29
30
|
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
30
31
|
*/
|
|
31
|
-
slice(startOffset:
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
get length(): number;
|
|
32
|
+
slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
|
|
33
|
+
/** the length (in bytes) of the data. */
|
|
34
|
+
get length(): bigint;
|
|
36
35
|
}
|
|
37
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=data-view-file-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-view-file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/data-view-file-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAc7C,wCAAwC;AACxC,qBAAa,oBAAqB,YAAW,YAAY;IACvD,+CAA+C;IAC/C,OAAO,CAAC,IAAI,CAAW;gBAEX,IAAI,EAAE,QAAQ;IAI1B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD;;;;OAIG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,yCAAyC;IACzC,IAAI,MAAM,WAET;CACF"}
|
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataViewFileProvider = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Checks if bigint can be converted to number and convert it if possible
|
|
6
|
+
* @param bigint bigint to be converted
|
|
7
|
+
* @returns number
|
|
6
8
|
*/
|
|
9
|
+
const toNumber = (bigint) => {
|
|
10
|
+
if (bigint > Number.MAX_SAFE_INTEGER) {
|
|
11
|
+
throw new Error('Offset is out of bounds');
|
|
12
|
+
}
|
|
13
|
+
return Number(bigint);
|
|
14
|
+
};
|
|
15
|
+
/** Provides file data using DataView */
|
|
7
16
|
class DataViewFileProvider {
|
|
8
17
|
constructor(file) {
|
|
9
18
|
this.file = file;
|
|
@@ -12,36 +21,41 @@ class DataViewFileProvider {
|
|
|
12
21
|
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
13
22
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
14
23
|
*/
|
|
15
|
-
getUint8(offset) {
|
|
16
|
-
return
|
|
24
|
+
async getUint8(offset) {
|
|
25
|
+
return this.file.getUint8(toNumber(offset));
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
|
-
* Gets an unsigned 16-bit
|
|
28
|
+
* Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
|
|
20
29
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
21
30
|
*/
|
|
22
|
-
getUint16(offset) {
|
|
23
|
-
return
|
|
31
|
+
async getUint16(offset) {
|
|
32
|
+
return this.file.getUint16(toNumber(offset), true);
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
35
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
27
36
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
28
37
|
*/
|
|
29
|
-
getUint32(offset) {
|
|
30
|
-
return
|
|
38
|
+
async getUint32(offset) {
|
|
39
|
+
return this.file.getUint32(toNumber(offset), true);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
|
|
43
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
44
|
+
*/
|
|
45
|
+
async getBigUint64(offset) {
|
|
46
|
+
return this.file.getBigUint64(toNumber(offset), true);
|
|
31
47
|
}
|
|
32
48
|
/**
|
|
33
49
|
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
34
50
|
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
35
51
|
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
36
52
|
*/
|
|
37
|
-
slice(startOffset, endOffset) {
|
|
38
|
-
return
|
|
53
|
+
async slice(startOffset, endOffset) {
|
|
54
|
+
return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
|
|
39
55
|
}
|
|
40
|
-
/**
|
|
41
|
-
* the length (in bytes) of the data.
|
|
42
|
-
*/
|
|
56
|
+
/** the length (in bytes) of the data. */
|
|
43
57
|
get length() {
|
|
44
|
-
return this.file.byteLength;
|
|
58
|
+
return BigInt(this.file.byteLength);
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
61
|
exports.DataViewFileProvider = DataViewFileProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FileProvider } from './file-provider';
|
|
2
|
+
/**
|
|
3
|
+
* End of central directory info
|
|
4
|
+
* according to https://en.wikipedia.org/wiki/ZIP_(file_format)
|
|
5
|
+
*/
|
|
6
|
+
export type ZipEoCDRecord = {
|
|
7
|
+
/** Relative offset of local file header */
|
|
8
|
+
cdStartOffset: bigint;
|
|
9
|
+
/** Relative offset of local file header */
|
|
10
|
+
cdRecordsNumber: bigint;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Parses end of central directory record of zip file
|
|
14
|
+
* @param fileProvider - FileProvider instance
|
|
15
|
+
* @returns Info from the header
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseEoCDRecord: (fileProvider: FileProvider) => Promise<ZipEoCDRecord>;
|
|
18
|
+
//# sourceMappingURL=end-of-central-directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-of-central-directory.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/end-of-central-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAgBF;;;;GAIG;AACH,eAAO,MAAM,eAAe,iBAAwB,YAAY,KAAG,QAAQ,aAAa,CA4CvF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseEoCDRecord = void 0;
|
|
4
|
+
const search_from_the_end_1 = require("./search-from-the-end");
|
|
5
|
+
const eoCDSignature = [0x50, 0x4b, 0x05, 0x06];
|
|
6
|
+
const zip64EoCDLocatorSignature = Buffer.from([0x50, 0x4b, 0x06, 0x07]);
|
|
7
|
+
const zip64EoCDSignature = Buffer.from([0x50, 0x4b, 0x06, 0x06]);
|
|
8
|
+
const offsets = {
|
|
9
|
+
CD_RECORDS_NUMBER_OFFSET: 8n,
|
|
10
|
+
CD_START_OFFSET_OFFSET: 16n,
|
|
11
|
+
ZIP64_EOCD_START_OFFSET_OFFSET: 8n,
|
|
12
|
+
ZIP64_CD_RECORDS_NUMBER_OFFSET: 24n,
|
|
13
|
+
ZIP64_CD_START_OFFSET_OFFSET: 48n
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Parses end of central directory record of zip file
|
|
17
|
+
* @param fileProvider - FileProvider instance
|
|
18
|
+
* @returns Info from the header
|
|
19
|
+
*/
|
|
20
|
+
const parseEoCDRecord = async (fileProvider) => {
|
|
21
|
+
const zipEoCDOffset = await (0, search_from_the_end_1.searchFromTheEnd)(fileProvider, eoCDSignature);
|
|
22
|
+
let cdRecordsNumber = BigInt(await fileProvider.getUint16(zipEoCDOffset + offsets.CD_RECORDS_NUMBER_OFFSET));
|
|
23
|
+
let cdStartOffset = BigInt(await fileProvider.getUint32(zipEoCDOffset + offsets.CD_START_OFFSET_OFFSET));
|
|
24
|
+
if (cdStartOffset === BigInt(0xffffffff) || cdRecordsNumber === BigInt(0xffffffff)) {
|
|
25
|
+
const zip64EoCDLocatorOffset = zipEoCDOffset - 20n;
|
|
26
|
+
if (Buffer.from(await fileProvider.slice(zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n)).compare(zip64EoCDLocatorSignature) !== 0) {
|
|
27
|
+
throw new Error('zip64 EoCD locator not found');
|
|
28
|
+
}
|
|
29
|
+
const zip64EoCDOffset = await fileProvider.getBigUint64(zip64EoCDLocatorOffset + offsets.ZIP64_EOCD_START_OFFSET_OFFSET);
|
|
30
|
+
if (Buffer.from(await fileProvider.slice(zip64EoCDOffset, zip64EoCDOffset + 4n)).compare(zip64EoCDSignature) !== 0) {
|
|
31
|
+
throw new Error('zip64 EoCD not found');
|
|
32
|
+
}
|
|
33
|
+
cdRecordsNumber = await fileProvider.getBigUint64(zip64EoCDOffset + offsets.ZIP64_CD_RECORDS_NUMBER_OFFSET);
|
|
34
|
+
cdStartOffset = await fileProvider.getBigUint64(zip64EoCDOffset + offsets.ZIP64_CD_START_OFFSET_OFFSET);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
cdRecordsNumber,
|
|
38
|
+
cdStartOffset
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.parseEoCDRecord = parseEoCDRecord;
|
|
@@ -6,26 +6,31 @@ export interface FileProvider {
|
|
|
6
6
|
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
7
7
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
8
8
|
*/
|
|
9
|
-
getUint8(offset:
|
|
9
|
+
getUint8(offset: bigint): Promise<number>;
|
|
10
10
|
/**
|
|
11
11
|
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
12
12
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
13
13
|
*/
|
|
14
|
-
getUint16(offset:
|
|
14
|
+
getUint16(offset: bigint): Promise<number>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
17
17
|
* @param offset The offset, in bytes, from the file of the view where to read the data.
|
|
18
18
|
*/
|
|
19
|
-
getUint32(offset:
|
|
19
|
+
getUint32(offset: bigint): Promise<number>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
22
|
+
* @param offset The offset, in byte, from the file of the view where to read the data.
|
|
23
|
+
*/
|
|
24
|
+
getBigUint64(offset: bigint): Promise<bigint>;
|
|
20
25
|
/**
|
|
21
26
|
* returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
|
|
22
27
|
* @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
|
|
23
28
|
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
24
29
|
*/
|
|
25
|
-
slice(startOffset:
|
|
30
|
+
slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
|
|
26
31
|
/**
|
|
27
32
|
* the length (in bytes) of the data.
|
|
28
33
|
*/
|
|
29
|
-
length:
|
|
34
|
+
length: bigint;
|
|
30
35
|
}
|
|
31
36
|
//# sourceMappingURL=file-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/file-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
1
|
+
{"version":3,"file":"file-provider.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/file-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9C;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { FileProvider } from './file-provider';
|
|
2
3
|
/**
|
|
3
4
|
* zip local file header info
|
|
@@ -11,15 +12,16 @@ export type ZipLocalFileHeader = {
|
|
|
11
12
|
/** Extra field length */
|
|
12
13
|
extraFieldLength: number;
|
|
13
14
|
/** Offset of the file data */
|
|
14
|
-
fileDataOffset:
|
|
15
|
+
fileDataOffset: bigint;
|
|
15
16
|
/** Compressed size */
|
|
16
|
-
compressedSize:
|
|
17
|
+
compressedSize: bigint;
|
|
17
18
|
};
|
|
19
|
+
export declare const signature: Buffer;
|
|
18
20
|
/**
|
|
19
21
|
* Parses local file header of zip file
|
|
20
22
|
* @param headerOffset - offset in the archive where header starts
|
|
21
23
|
* @param buffer - buffer containing whole array
|
|
22
24
|
* @returns Info from the header
|
|
23
25
|
*/
|
|
24
|
-
export declare const parseZipLocalFileHeader: (headerOffset:
|
|
26
|
+
export declare const parseZipLocalFileHeader: (headerOffset: bigint, buffer: FileProvider) => Promise<ZipLocalFileHeader | null>;
|
|
25
27
|
//# sourceMappingURL=local-file-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/local-file-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-file-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/local-file-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAUF,eAAO,MAAM,SAAS,QAAwC,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,iBACpB,MAAM,UACZ,YAAY,KACnB,QAAQ,kBAAkB,GAAG,IAAI,CAoDnC,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseZipLocalFileHeader = void 0;
|
|
3
|
+
exports.parseZipLocalFileHeader = exports.signature = void 0;
|
|
4
4
|
const offsets = {
|
|
5
|
-
COMPRESSED_SIZE_OFFSET:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
COMPRESSED_SIZE_OFFSET: 18n,
|
|
6
|
+
UNCOMPRESSED_SIZE_OFFSET: 22n,
|
|
7
|
+
FILE_NAME_LENGTH_OFFSET: 26n,
|
|
8
|
+
EXTRA_FIELD_LENGTH_OFFSET: 28n,
|
|
9
|
+
FILE_NAME_OFFSET: 30n
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
exports.signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);
|
|
11
12
|
/**
|
|
12
13
|
* Parses local file header of zip file
|
|
13
14
|
* @param headerOffset - offset in the archive where header starts
|
|
@@ -15,14 +16,32 @@ const signature = Buffer.from([0x50, 0x4b, 0x03, 0x04]);
|
|
|
15
16
|
* @returns Info from the header
|
|
16
17
|
*/
|
|
17
18
|
const parseZipLocalFileHeader = async (headerOffset, buffer) => {
|
|
18
|
-
if (Buffer.from(await buffer.slice(headerOffset, headerOffset +
|
|
19
|
-
return
|
|
19
|
+
if (Buffer.from(await buffer.slice(headerOffset, headerOffset + 4n)).compare(exports.signature) !== 0) {
|
|
20
|
+
return null;
|
|
20
21
|
}
|
|
21
22
|
const fileNameLength = await buffer.getUint16(headerOffset + offsets.FILE_NAME_LENGTH_OFFSET);
|
|
22
|
-
const fileName = new TextDecoder()
|
|
23
|
+
const fileName = new TextDecoder()
|
|
24
|
+
.decode(await buffer.slice(headerOffset + offsets.FILE_NAME_OFFSET, headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength)))
|
|
25
|
+
.split('\\')
|
|
26
|
+
.join('/');
|
|
23
27
|
const extraFieldLength = await buffer.getUint16(headerOffset + offsets.EXTRA_FIELD_LENGTH_OFFSET);
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
let fileDataOffset = headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength);
|
|
29
|
+
let compressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.COMPRESSED_SIZE_OFFSET)); // add zip 64 logic
|
|
30
|
+
let uncompressedSize = BigInt(await buffer.getUint32(headerOffset + offsets.UNCOMPRESSED_SIZE_OFFSET)); // add zip 64 logic
|
|
31
|
+
const extraOffset = headerOffset + offsets.FILE_NAME_OFFSET + BigInt(fileNameLength);
|
|
32
|
+
let offsetInZip64Data = 4n;
|
|
33
|
+
// looking for info that might be also be in zip64 extra field
|
|
34
|
+
if (uncompressedSize === BigInt(0xffffffff)) {
|
|
35
|
+
uncompressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
|
|
36
|
+
offsetInZip64Data += 8n;
|
|
37
|
+
}
|
|
38
|
+
if (compressedSize === BigInt(0xffffffff)) {
|
|
39
|
+
compressedSize = await buffer.getBigUint64(extraOffset + offsetInZip64Data);
|
|
40
|
+
offsetInZip64Data += 8n;
|
|
41
|
+
}
|
|
42
|
+
if (fileDataOffset === BigInt(0xffffffff)) {
|
|
43
|
+
fileDataOffset = await buffer.getBigUint64(extraOffset + offsetInZip64Data); // setting it to the one from zip64
|
|
44
|
+
}
|
|
26
45
|
return {
|
|
27
46
|
fileNameLength,
|
|
28
47
|
fileName,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FileProvider } from 'modules/i3s/src/lib/parsers/parse-zip/file-provider';
|
|
2
|
+
/** Description of zip signature type */
|
|
3
|
+
export type ZipSignature = [number, number, number, number];
|
|
4
|
+
/**
|
|
5
|
+
* looking for the last occurrence of the provided
|
|
6
|
+
* @param file
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const searchFromTheEnd: (file: FileProvider, target: ZipSignature) => Promise<bigint>;
|
|
11
|
+
//# sourceMappingURL=search-from-the-end.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-from-the-end.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/parse-zip/search-from-the-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,qDAAqD,CAAC;AAEjF,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SACrB,YAAY,2BAEjB,QAAQ,MAAM,CAuBhB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchFromTheEnd = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* looking for the last occurrence of the provided
|
|
6
|
+
* @param file
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
const searchFromTheEnd = async (file, target) => {
|
|
11
|
+
const searchWindow = [
|
|
12
|
+
await file.getUint8(file.length - 1n),
|
|
13
|
+
await file.getUint8(file.length - 2n),
|
|
14
|
+
await file.getUint8(file.length - 3n),
|
|
15
|
+
undefined
|
|
16
|
+
];
|
|
17
|
+
let targetOffset = 0n;
|
|
18
|
+
// looking for the last record in the central directory
|
|
19
|
+
for (let i = file.length - 4n; i > -1; i--) {
|
|
20
|
+
searchWindow[3] = searchWindow[2];
|
|
21
|
+
searchWindow[2] = searchWindow[1];
|
|
22
|
+
searchWindow[1] = searchWindow[0];
|
|
23
|
+
searchWindow[0] = await file.getUint8(i);
|
|
24
|
+
if (searchWindow.every((val, index) => val === target[index])) {
|
|
25
|
+
targetOffset = i;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return targetOffset;
|
|
30
|
+
};
|
|
31
|
+
exports.searchFromTheEnd = searchFromTheEnd;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import type { Matrix4, Quaternion, Vector3 } from '@math.gl/core';
|
|
2
2
|
import type { TypedArray, MeshAttribute, TextureLevel } from '@loaders.gl/schema';
|
|
3
3
|
import { Tile3D, Tileset3D } from '@loaders.gl/tiles';
|
|
4
|
-
export declare enum DATA_TYPE {
|
|
5
|
-
UInt8 = "UInt8",
|
|
6
|
-
UInt16 = "UInt16",
|
|
7
|
-
UInt32 = "UInt32",
|
|
8
|
-
UInt64 = "UInt64",
|
|
9
|
-
Int16 = "Int16",
|
|
10
|
-
Int32 = "Int32",
|
|
11
|
-
Int64 = "Int64",
|
|
12
|
-
Float32 = "Float32",
|
|
13
|
-
Float64 = "Float64"
|
|
14
|
-
}
|
|
15
4
|
export type COLOR = [number, number, number, number];
|
|
16
5
|
/**
|
|
17
6
|
* spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/3DSceneLayer.cmn.md
|
|
@@ -647,20 +636,24 @@ type Domain = {
|
|
|
647
636
|
* spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/store.cmn.md
|
|
648
637
|
*/
|
|
649
638
|
type Store = {
|
|
650
|
-
id
|
|
639
|
+
id?: string | number;
|
|
651
640
|
profile: string;
|
|
652
641
|
version: number | string;
|
|
653
|
-
resourcePattern
|
|
654
|
-
rootNode
|
|
655
|
-
extent
|
|
656
|
-
indexCRS
|
|
657
|
-
vertexCRS
|
|
658
|
-
normalReferenceFrame
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
lodType: string;
|
|
662
|
-
lodModel: string;
|
|
642
|
+
resourcePattern?: string[];
|
|
643
|
+
rootNode?: string;
|
|
644
|
+
extent?: number[];
|
|
645
|
+
indexCRS?: string;
|
|
646
|
+
vertexCRS?: string;
|
|
647
|
+
normalReferenceFrame?: string;
|
|
648
|
+
lodType?: string;
|
|
649
|
+
lodModel?: string;
|
|
663
650
|
defaultGeometrySchema: DefaultGeometrySchema;
|
|
651
|
+
nidEncoding?: string;
|
|
652
|
+
textureEncoding?: string[];
|
|
653
|
+
featureEncoding?: string;
|
|
654
|
+
geometryEncoding?: string;
|
|
655
|
+
attributeEncoding?: string;
|
|
656
|
+
indexingScheme?: string;
|
|
664
657
|
};
|
|
665
658
|
/**
|
|
666
659
|
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md
|
|
@@ -681,7 +674,7 @@ type DefaultGeometrySchema = {
|
|
|
681
674
|
*/
|
|
682
675
|
export type HeaderAttribute = {
|
|
683
676
|
property: HeaderAttributeProperty.vertexCount | HeaderAttributeProperty.featureCount | string;
|
|
684
|
-
type:
|
|
677
|
+
type: 'UInt8' | 'UInt16' | 'UInt32' | 'UInt64' | 'Int16' | 'Int32' | 'Int64' | 'Float32' | 'Float64';
|
|
685
678
|
};
|
|
686
679
|
export declare enum HeaderAttributeProperty {
|
|
687
680
|
vertexCount = "vertexCount",
|
|
@@ -696,7 +689,7 @@ export type VertexAttribute = {
|
|
|
696
689
|
};
|
|
697
690
|
export type GeometryAttribute = {
|
|
698
691
|
byteOffset?: number;
|
|
699
|
-
valueType:
|
|
692
|
+
valueType: 'UInt8' | 'UInt16' | 'Int16' | 'Int32' | 'Int64' | 'Float32' | 'Float64';
|
|
700
693
|
valuesPerElement: number;
|
|
701
694
|
};
|
|
702
695
|
export type I3SMeshAttributes = {
|