@loaders.gl/zip 4.3.0-alpha.2 → 4.3.0-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/zip",
3
- "version": "4.3.0-alpha.2",
3
+ "version": "4.3.0-alpha.4",
4
4
  "description": "Zip Archive Loader",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,14 +39,14 @@
39
39
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
40
40
  },
41
41
  "dependencies": {
42
- "@loaders.gl/compression": "4.3.0-alpha.2",
43
- "@loaders.gl/crypto": "4.3.0-alpha.2",
44
- "@loaders.gl/loader-utils": "4.3.0-alpha.2",
42
+ "@loaders.gl/compression": "4.3.0-alpha.4",
43
+ "@loaders.gl/crypto": "4.3.0-alpha.4",
44
+ "@loaders.gl/loader-utils": "4.3.0-alpha.4",
45
45
  "jszip": "^3.1.5",
46
46
  "md5": "^2.3.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@loaders.gl/core": "^4.0.0"
50
50
  },
51
- "gitHead": "77a3cb538ab7a1fbf74245f25590210451689f5c"
51
+ "gitHead": "4900ac4c4de20366c050b80cef04dc5b52d167af"
52
52
  }
@@ -1,4 +1,4 @@
1
- import {FileProvider} from '@loaders.gl/loader-utils';
1
+ import {FileProviderInterface} from '@loaders.gl/loader-utils';
2
2
  import {ZipFileSystem} from './zip-filesystem';
3
3
 
4
4
  /**
@@ -6,7 +6,7 @@ import {ZipFileSystem} from './zip-filesystem';
6
6
  * a hash file inside that allows to increase reading speed
7
7
  */
8
8
  export abstract class IndexedArchive {
9
- public fileProvider: FileProvider;
9
+ public fileProvider: FileProviderInterface;
10
10
  public fileName?: string;
11
11
 
12
12
  /**
@@ -15,7 +15,11 @@ export abstract class IndexedArchive {
15
15
  * @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
16
16
  * @param fileName - name of the archive. It is used to add to an URL of a loader context
17
17
  */
18
- constructor(fileProvider: FileProvider, hashTable?: Record<string, bigint>, fileName?: string) {
18
+ constructor(
19
+ fileProvider: FileProviderInterface,
20
+ hashTable?: Record<string, bigint>,
21
+ fileName?: string
22
+ ) {
19
23
  this.fileProvider = fileProvider;
20
24
  this.fileName = fileName;
21
25
  }
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {FileSystem, isBrowser} from '@loaders.gl/loader-utils';
6
- import {FileProvider, isFileProvider} from '@loaders.gl/loader-utils';
6
+ import {FileProviderInterface, isFileProvider} from '@loaders.gl/loader-utils';
7
7
  import {FileHandleFile} from '@loaders.gl/loader-utils';
8
8
  import {ZipCDFileHeader, makeZipCDHeaderIterator} from '../parse-zip/cd-file-header';
9
9
  import {parseZipLocalFileHeader} from '../parse-zip/local-file-header';
@@ -29,7 +29,7 @@ export const ZIP_COMPRESSION_HANDLERS: {[key: number]: CompressionHandler} = {
29
29
  */
30
30
  export class ZipFileSystem implements FileSystem {
31
31
  /** FileProvider instance promise */
32
- public fileProvider: FileProvider | null = null;
32
+ public fileProvider: FileProviderInterface | null = null;
33
33
  public fileName?: string;
34
34
  public archive: IndexedArchive | null = null;
35
35
 
@@ -37,7 +37,7 @@ export class ZipFileSystem implements FileSystem {
37
37
  * Constructor
38
38
  * @param file - instance of FileProvider or file path string
39
39
  */
40
- constructor(file: FileProvider | IndexedArchive | string) {
40
+ constructor(file: FileProviderInterface | IndexedArchive | string) {
41
41
  // Try to open file in NodeJS
42
42
  if (typeof file === 'string') {
43
43
  this.fileName = file;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {MD5Hash} from '@loaders.gl/crypto';
6
6
  import {
7
- FileProvider,
7
+ FileProviderInterface,
8
8
  concatenateArrayBuffers,
9
9
  concatenateArrayBuffersFromArray
10
10
  } from '@loaders.gl/loader-utils';
@@ -42,7 +42,7 @@ function bufferToHex(buffer: ArrayBuffer, start: number, length: number): string
42
42
  * @returns ready to use hash info
43
43
  */
44
44
  export async function makeHashTableFromZipHeaders(
45
- fileProvider: FileProvider
45
+ fileProvider: FileProviderInterface
46
46
  ): Promise<Record<string, bigint>> {
47
47
  const zipCDIterator = makeZipCDHeaderIterator(fileProvider);
48
48
  return getHashTable(zipCDIterator);
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {
6
6
  DataViewFile,
7
- FileProvider,
7
+ FileProviderInterface,
8
8
  compareArrayBuffers,
9
9
  concatenateArrayBuffers
10
10
  } from '@loaders.gl/loader-utils';
@@ -66,7 +66,7 @@ export const signature: ZipSignature = new Uint8Array([0x50, 0x4b, 0x01, 0x02]);
66
66
  */
67
67
  export const parseZipCDFileHeader = async (
68
68
  headerOffset: bigint,
69
- file: FileProvider
69
+ file: FileProviderInterface
70
70
  ): Promise<ZipCDFileHeader | null> => {
71
71
  if (headerOffset >= file.length) {
72
72
  return null;
@@ -127,7 +127,7 @@ export const parseZipCDFileHeader = async (
127
127
  * @param fileProvider - file provider that provider random access to the file
128
128
  */
129
129
  export async function* makeZipCDHeaderIterator(
130
- fileProvider: FileProvider
130
+ fileProvider: FileProviderInterface
131
131
  ): AsyncIterable<ZipCDFileHeader> {
132
132
  const {cdStartOffset, cdByteSize} = await parseEoCDRecord(fileProvider);
133
133
  const centralDirectory = new DataViewFile(
@@ -2,7 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {FileProvider, compareArrayBuffers, concatenateArrayBuffers} from '@loaders.gl/loader-utils';
5
+ import {
6
+ FileProviderInterface,
7
+ compareArrayBuffers,
8
+ concatenateArrayBuffers
9
+ } from '@loaders.gl/loader-utils';
6
10
  import {ZipSignature, searchFromTheEnd} from './search-from-the-end';
7
11
  import {setFieldToNumber} from './zip64-info-generation';
8
12
 
@@ -64,7 +68,7 @@ const ZIP64_COMMENT_OFFSET = 56n;
64
68
  * @param file - FileProvider instance
65
69
  * @returns Info from the header
66
70
  */
67
- export const parseEoCDRecord = async (file: FileProvider): Promise<ZipEoCDRecord> => {
71
+ export const parseEoCDRecord = async (file: FileProviderInterface): Promise<ZipEoCDRecord> => {
68
72
  const zipEoCDOffset = await searchFromTheEnd(file, eoCDSignature);
69
73
 
70
74
  let cdRecordsNumber = BigInt(await file.getUint16(zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
@@ -2,7 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {FileProvider, compareArrayBuffers, concatenateArrayBuffers} from '@loaders.gl/loader-utils';
5
+ import {
6
+ FileProviderInterface,
7
+ compareArrayBuffers,
8
+ concatenateArrayBuffers
9
+ } from '@loaders.gl/loader-utils';
6
10
  import {ZipSignature} from './search-from-the-end';
7
11
  import {createZip64Info, setFieldToNumber} from './zip64-info-generation';
8
12
 
@@ -43,7 +47,7 @@ export const signature: ZipSignature = new Uint8Array([0x50, 0x4b, 0x03, 0x04]);
43
47
  */
44
48
  export const parseZipLocalFileHeader = async (
45
49
  headerOffset: bigint,
46
- file: FileProvider
50
+ file: FileProviderInterface
47
51
  ): Promise<ZipLocalFileHeader | null> => {
48
52
  const mainHeader = new DataView(await file.slice(headerOffset, headerOffset + FILE_NAME_OFFSET));
49
53
 
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {FileProvider} from '@loaders.gl/loader-utils';
5
+ import {FileProviderInterface} from '@loaders.gl/loader-utils';
6
6
 
7
7
  /** Description of zip signature type */
8
8
  export type ZipSignature = Uint8Array;
@@ -16,7 +16,7 @@ const buffLength = 1024;
16
16
  * @returns
17
17
  */
18
18
  export const searchFromTheEnd = async (
19
- file: FileProvider,
19
+ file: FileProviderInterface,
20
20
  target: ZipSignature
21
21
  ): Promise<bigint> => {
22
22
  const searchWindow = [