@loaders.gl/zip 4.0.0-beta.3 → 4.0.0-beta.5

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 (2) hide show
  1. package/dist/dist.dev.js +2 -110
  2. package/package.json +5 -5
package/dist/dist.dev.js CHANGED
@@ -7018,7 +7018,6 @@ var __exports__ = (() => {
7018
7018
  extensions: ["zip"],
7019
7019
  category: "archive",
7020
7020
  mimeTypes: ["application/zip"],
7021
- // @ts-ignore
7022
7021
  encode: encodeZipAsync
7023
7022
  };
7024
7023
  async function encodeZipAsync(fileMap, options = {}) {
@@ -7113,9 +7112,6 @@ var __exports__ = (() => {
7113
7112
  var recordSize = 512;
7114
7113
  var Tar = class {
7115
7114
  blocks = [];
7116
- /**
7117
- * @param [recordsPerBlock]
7118
- */
7119
7115
  constructor(recordsPerBlock) {
7120
7116
  this.written = 0;
7121
7117
  blockSize = (recordsPerBlock || 20) * recordSize;
@@ -7126,13 +7122,6 @@ var __exports__ = (() => {
7126
7122
  this.clear = this.clear.bind(this);
7127
7123
  this.append = this.append.bind(this);
7128
7124
  }
7129
- /**
7130
- * Append a file to the tar archive
7131
- * @param filepath
7132
- * @param input
7133
- * @param [opts]
7134
- */
7135
- // eslint-disable-next-line complexity
7136
7125
  append(filepath, input, opts) {
7137
7126
  let checksum;
7138
7127
  if (typeof input === "string") {
@@ -7156,7 +7145,6 @@ var __exports__ = (() => {
7156
7145
  fileSize: pad(input.length, 11),
7157
7146
  mtime: pad(mtime, 11),
7158
7147
  checksum: " ",
7159
- // 0 = just a file
7160
7148
  type: "0",
7161
7149
  ustar: "ustar ",
7162
7150
  owner: opts.owner || "",
@@ -7182,10 +7170,6 @@ var __exports__ = (() => {
7182
7170
  inputLength
7183
7171
  });
7184
7172
  }
7185
- /**
7186
- * Compiling data to a Blob object
7187
- * @returns {Blob}
7188
- */
7189
7173
  save() {
7190
7174
  const buffers = [];
7191
7175
  const chunks = new Array();
@@ -7224,9 +7208,6 @@ var __exports__ = (() => {
7224
7208
  type: "octet/stream"
7225
7209
  });
7226
7210
  }
7227
- /**
7228
- * Clear the data by its blocksize
7229
- */
7230
7211
  clear() {
7231
7212
  this.written = 0;
7232
7213
  this.out = clean(blockSize);
@@ -7257,7 +7238,6 @@ var __exports__ = (() => {
7257
7238
  };
7258
7239
  this.tape = new tar_default(this.options.recordsPerBlock);
7259
7240
  }
7260
- /** Adds a file to the archive. */
7261
7241
  addFile(filename, buffer) {
7262
7242
  this.tape.append(filename, new Uint8Array(buffer));
7263
7243
  this.count++;
@@ -7278,10 +7258,7 @@ var __exports__ = (() => {
7278
7258
  var window_ = globals.window || globals.self || globals.global || {};
7279
7259
  var global_ = globals.global || globals.self || globals.window || {};
7280
7260
  var document_ = globals.document || {};
7281
- var isBrowser = (
7282
- // @ts-ignore process does not exist on browser
7283
- Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
7284
- );
7261
+ var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
7285
7262
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
7286
7263
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
7287
7264
 
@@ -7374,19 +7351,15 @@ var __exports__ = (() => {
7374
7351
  }
7375
7352
  throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
7376
7353
  }
7377
- /** Read data */
7378
7354
  async read(start, end) {
7379
7355
  throw NOT_IMPLEMENTED;
7380
7356
  }
7381
- /** Write to file. The number of bytes written will be returned */
7382
7357
  async write(arrayBuffer, offset, length) {
7383
7358
  throw NOT_IMPLEMENTED;
7384
7359
  }
7385
- /** Get information about file */
7386
7360
  async stat() {
7387
7361
  throw NOT_IMPLEMENTED;
7388
7362
  }
7389
- /** Close the file */
7390
7363
  async close() {
7391
7364
  }
7392
7365
  };
@@ -7398,21 +7371,13 @@ var __exports__ = (() => {
7398
7371
 
7399
7372
  // ../loader-utils/src/lib/file-provider/file-handle-file.ts
7400
7373
  var FileHandleFile = class {
7401
- /** The FileHandle from which data is provided */
7402
- /** The file length in bytes */
7403
- /** Create a new FileHandleFile */
7404
7374
  constructor(path) {
7405
7375
  this.file = new NodeFileFacade(path, "r");
7406
7376
  this.size = this.file.bigsize;
7407
7377
  }
7408
- /** Close file */
7409
7378
  async destroy() {
7410
7379
  await this.file.close();
7411
7380
  }
7412
- /**
7413
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
7414
- * @param offset The offset, in bytes, from the start of the file where to read the data.
7415
- */
7416
7381
  async getUint8(offset) {
7417
7382
  const arrayBuffer = await this.file.read(offset, 1);
7418
7383
  const val = new Uint8Array(arrayBuffer).at(0);
@@ -7421,10 +7386,6 @@ var __exports__ = (() => {
7421
7386
  }
7422
7387
  return val;
7423
7388
  }
7424
- /**
7425
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
7426
- * @param offset The offset, in bytes, from the start of the file where to read the data.
7427
- */
7428
7389
  async getUint16(offset) {
7429
7390
  const arrayBuffer = await this.file.read(offset, 2);
7430
7391
  const val = new Uint16Array(arrayBuffer).at(0);
@@ -7433,10 +7394,6 @@ var __exports__ = (() => {
7433
7394
  }
7434
7395
  return val;
7435
7396
  }
7436
- /**
7437
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
7438
- * @param offset The offset, in bytes, from the start of the file where to read the data.
7439
- */
7440
7397
  async getUint32(offset) {
7441
7398
  const arrayBuffer = await this.file.read(offset, 4);
7442
7399
  const val = new Uint32Array(arrayBuffer).at(0);
@@ -7445,10 +7402,6 @@ var __exports__ = (() => {
7445
7402
  }
7446
7403
  return val;
7447
7404
  }
7448
- /**
7449
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
7450
- * @param offset The offset, in bytes, from the start of the file where to read the data.
7451
- */
7452
7405
  async getBigUint64(offset) {
7453
7406
  const arrayBuffer = await this.file.read(offset, 8);
7454
7407
  const val = new BigInt64Array(arrayBuffer).at(0);
@@ -7457,11 +7410,6 @@ var __exports__ = (() => {
7457
7410
  }
7458
7411
  return val;
7459
7412
  }
7460
- /**
7461
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
7462
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
7463
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
7464
- */
7465
7413
  async slice(startOffset, endOffset) {
7466
7414
  const bigLength = endOffset - startOffset;
7467
7415
  if (bigLength > Number.MAX_SAFE_INTEGER) {
@@ -7470,9 +7418,6 @@ var __exports__ = (() => {
7470
7418
  const length = Number(bigLength);
7471
7419
  return await this.file.read(startOffset, length);
7472
7420
  }
7473
- /**
7474
- * the length (in bytes) of the data.
7475
- */
7476
7421
  get length() {
7477
7422
  return this.size;
7478
7423
  }
@@ -7647,7 +7592,6 @@ var __exports__ = (() => {
7647
7592
  hash
7648
7593
  });
7649
7594
  }
7650
- // HELPERS
7651
7595
  async concatenate(asyncIterator) {
7652
7596
  return await concatenateArrayBuffersAsync(asyncIterator);
7653
7597
  }
@@ -8139,15 +8083,8 @@ var __exports__ = (() => {
8139
8083
  super();
8140
8084
  this.options = options;
8141
8085
  }
8142
- /**
8143
- * Atomic hash calculation
8144
- * @returns base64 encoded hash
8145
- */
8146
8086
  async hash(input, encoding) {
8147
- const md5Promise = new Promise((resolve, reject) => (
8148
- // @ts-expect-error
8149
- md5WASM(input).then(resolve).catch(reject)
8150
- ));
8087
+ const md5Promise = new Promise((resolve, reject) => md5WASM(input).then(resolve).catch(reject));
8151
8088
  const hex = await md5Promise;
8152
8089
  return encodeHex(hex, encoding);
8153
8090
  }
@@ -8187,39 +8124,31 @@ var __exports__ = (() => {
8187
8124
  this.compressBatches = this.compressBatches.bind(this);
8188
8125
  this.decompressBatches = this.decompressBatches.bind(this);
8189
8126
  }
8190
- /** Preloads any dynamic libraries. May enable sync functions */
8191
8127
  async preload() {
8192
8128
  return;
8193
8129
  }
8194
- /** Asynchronously compress data */
8195
8130
  async compress(input) {
8196
8131
  await this.preload();
8197
8132
  return this.compressSync(input);
8198
8133
  }
8199
- /** Asynchronously decompress data */
8200
8134
  async decompress(input, size) {
8201
8135
  await this.preload();
8202
8136
  return this.decompressSync(input, size);
8203
8137
  }
8204
- /** Synchronously compress data */
8205
8138
  compressSync(input) {
8206
8139
  throw new Error(`${this.name}: sync compression not supported`);
8207
8140
  }
8208
- /** Synchronously compress data */
8209
8141
  decompressSync(input, size) {
8210
8142
  throw new Error(`${this.name}: sync decompression not supported`);
8211
8143
  }
8212
- /** Compress batches */
8213
8144
  async *compressBatches(asyncIterator) {
8214
8145
  const input = await this.concatenate(asyncIterator);
8215
8146
  yield this.compress(input);
8216
8147
  }
8217
- /** Decompress batches */
8218
8148
  async *decompressBatches(asyncIterator) {
8219
8149
  const input = await this.concatenate(asyncIterator);
8220
8150
  yield this.decompress(input);
8221
8151
  }
8222
- // HELPERS
8223
8152
  concatenate(asyncIterator) {
8224
8153
  return concatenateArrayBuffersAsync(asyncIterator);
8225
8154
  }
@@ -8320,26 +8249,16 @@ var __exports__ = (() => {
8320
8249
  this._chunks = [];
8321
8250
  return chunks;
8322
8251
  }
8323
- // TODO - For some reason we don't get the error message from pako in _onEnd?
8324
8252
  _getError(code = 0) {
8325
8253
  const MESSAGES = {
8326
- /* Z_NEED_DICT 2 */
8327
8254
  2: "need dictionary",
8328
- /* Z_STREAM_END 1 */
8329
8255
  1: "stream end",
8330
- /* Z_OK 0 */
8331
8256
  0: "",
8332
- /* Z_ERRNO (-1) */
8333
8257
  "-1": "file error",
8334
- /* Z_STREAM_ERROR (-2) */
8335
8258
  "-2": "stream error",
8336
- /* Z_DATA_ERROR (-3) */
8337
8259
  "-3": "data error",
8338
- /* Z_MEM_ERROR (-4) */
8339
8260
  "-4": "insufficient memory",
8340
- /* Z_BUF_ERROR (-5) */
8341
8261
  "-5": "buffer error",
8342
- /* Z_VERSION_ERROR (-6) */
8343
8262
  "-6": "incompatible version"
8344
8263
  };
8345
8264
  return `${this.name}: ${MESSAGES[code]}`;
@@ -8348,9 +8267,7 @@ var __exports__ = (() => {
8348
8267
 
8349
8268
  // src/filesystems/zip-filesystem.ts
8350
8269
  var COMPRESSION_METHODS = {
8351
- /** No compression */
8352
8270
  0: async (compressedFile) => compressedFile,
8353
- /** Deflation */
8354
8271
  8: async (compressedFile) => {
8355
8272
  const compression = new DeflateCompression({
8356
8273
  raw: true
@@ -8360,12 +8277,7 @@ var __exports__ = (() => {
8360
8277
  }
8361
8278
  };
8362
8279
  var ZipFileSystem = class {
8363
- /** FileProvider instance promise */
8364
8280
  fileProvider = null;
8365
- /**
8366
- * Constructor
8367
- * @param file - instance of FileProvider or file path string
8368
- */
8369
8281
  constructor(file) {
8370
8282
  if (typeof file === "string") {
8371
8283
  this.fileName = file;
@@ -8378,16 +8290,11 @@ var __exports__ = (() => {
8378
8290
  this.fileProvider = file;
8379
8291
  }
8380
8292
  }
8381
- /** Clean up resources */
8382
8293
  async destroy() {
8383
8294
  if (this.fileProvider) {
8384
8295
  await this.fileProvider.destroy();
8385
8296
  }
8386
8297
  }
8387
- /**
8388
- * Get file names list from zip archive
8389
- * @returns array of file names
8390
- */
8391
8298
  async readdir() {
8392
8299
  if (!this.fileProvider) {
8393
8300
  throw new Error("No data detected in the zip archive");
@@ -8399,11 +8306,6 @@ var __exports__ = (() => {
8399
8306
  }
8400
8307
  return fileNames;
8401
8308
  }
8402
- /**
8403
- * Get file metadata
8404
- * @param filename - name of a file
8405
- * @returns central directory data
8406
- */
8407
8309
  async stat(filename) {
8408
8310
  const cdFileHeader = await this.getCDFileHeader(filename);
8409
8311
  return {
@@ -8411,11 +8313,6 @@ var __exports__ = (() => {
8411
8313
  size: Number(cdFileHeader.uncompressedSize)
8412
8314
  };
8413
8315
  }
8414
- /**
8415
- * Implementation of fetch against this file system
8416
- * @param filename - name of a file
8417
- * @returns - Response with file data
8418
- */
8419
8316
  async fetch(filename) {
8420
8317
  if (!this.fileProvider) {
8421
8318
  throw new Error("No data detected in the zip archive");
@@ -8437,11 +8334,6 @@ var __exports__ = (() => {
8437
8334
  });
8438
8335
  return response;
8439
8336
  }
8440
- /**
8441
- * Get central directory file header
8442
- * @param filename - name of a file
8443
- * @returns central directory file header
8444
- */
8445
8337
  async getCDFileHeader(filename) {
8446
8338
  if (!this.fileProvider) {
8447
8339
  throw new Error("No data detected in the zip archive");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/zip",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Zip Archive Loader",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,11 +38,11 @@
38
38
  "build-bundle": "ocular-bundle ./src/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@loaders.gl/compression": "4.0.0-beta.3",
42
- "@loaders.gl/crypto": "4.0.0-beta.3",
43
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
41
+ "@loaders.gl/compression": "4.0.0-beta.5",
42
+ "@loaders.gl/crypto": "4.0.0-beta.5",
43
+ "@loaders.gl/loader-utils": "4.0.0-beta.5",
44
44
  "jszip": "^3.1.5",
45
45
  "md5": "^2.3.0"
46
46
  },
47
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
47
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
48
48
  }