@zip.js/zip.js 2.6.66 → 2.6.68
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/zip-fs-full.js +17 -8
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +17 -8
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +5 -5
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +5 -5
- package/dist/zip.min.js +1 -1
- package/index.cjs +17 -8
- package/index.d.ts +6 -0
- package/lib/core/io.js +5 -5
- package/lib/core/zip-fs-core.js +12 -3
- package/package.json +1 -1
package/lib/core/io.js
CHANGED
|
@@ -262,8 +262,8 @@ class FetchReader extends Reader {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
async init() {
|
|
265
|
-
super.init();
|
|
266
265
|
await initHttpReader(this, sendFetchRequest, getFetchRequestData);
|
|
266
|
+
super.init();
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
readUint8Array(index, length) {
|
|
@@ -279,8 +279,8 @@ class XHRReader extends Reader {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
async init() {
|
|
282
|
-
super.init();
|
|
283
282
|
await initHttpReader(this, sendXMLHttpRequest, getXMLHttpRequestData);
|
|
283
|
+
super.init();
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
readUint8Array(index, length) {
|
|
@@ -467,8 +467,8 @@ class HttpReader extends Reader {
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
async init() {
|
|
470
|
-
super.init();
|
|
471
470
|
await this.reader.init();
|
|
471
|
+
super.init();
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
readUint8Array(index, length) {
|
|
@@ -503,11 +503,11 @@ class Uint8ArrayReader extends Reader {
|
|
|
503
503
|
class Uint8ArrayWriter extends Writer {
|
|
504
504
|
|
|
505
505
|
init(initSize = 0) {
|
|
506
|
-
super.init();
|
|
507
506
|
Object.assign(this, {
|
|
508
507
|
offset: 0,
|
|
509
508
|
array: new Uint8Array(initSize)
|
|
510
509
|
});
|
|
510
|
+
super.init();
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
writeUint8Array(array) {
|
|
@@ -534,7 +534,6 @@ class SplitDataReader extends Reader {
|
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
async init() {
|
|
537
|
-
super.init();
|
|
538
537
|
const reader = this;
|
|
539
538
|
const { readers } = reader;
|
|
540
539
|
reader.lastDiskNumber = 0;
|
|
@@ -542,6 +541,7 @@ class SplitDataReader extends Reader {
|
|
|
542
541
|
await diskReader.init();
|
|
543
542
|
reader.size += diskReader.size;
|
|
544
543
|
}));
|
|
544
|
+
super.init();
|
|
545
545
|
}
|
|
546
546
|
|
|
547
547
|
async readUint8Array(offset, length, diskNumber = 0) {
|
package/lib/core/zip-fs-core.js
CHANGED
|
@@ -102,6 +102,15 @@ class ZipEntry {
|
|
|
102
102
|
}
|
|
103
103
|
return Boolean(entry);
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
rename(name) {
|
|
107
|
+
const parent = this.parent;
|
|
108
|
+
if (parent && parent.getChildByName(name)) {
|
|
109
|
+
throw new Error("Entry filename already exists");
|
|
110
|
+
} else {
|
|
111
|
+
this.name = name;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
class ZipFileEntry extends ZipEntry {
|
|
@@ -495,12 +504,12 @@ function getZipBlobReader(options) {
|
|
|
495
504
|
}
|
|
496
505
|
|
|
497
506
|
async init() {
|
|
498
|
-
super.init();
|
|
499
507
|
const zipBlobReader = this;
|
|
500
508
|
zipBlobReader.size = zipBlobReader.entry.uncompressedSize;
|
|
501
509
|
const data = await zipBlobReader.entry.getData(new BlobWriter(), Object.assign({}, zipBlobReader.options, options));
|
|
502
510
|
zipBlobReader.data = data;
|
|
503
511
|
zipBlobReader.blobReader = new BlobReader(data);
|
|
512
|
+
super.init();
|
|
504
513
|
}
|
|
505
514
|
|
|
506
515
|
readUint8Array(index, length) {
|
|
@@ -511,7 +520,7 @@ function getZipBlobReader(options) {
|
|
|
511
520
|
|
|
512
521
|
async function initReaders(entry) {
|
|
513
522
|
if (entry.children.length) {
|
|
514
|
-
|
|
523
|
+
await Promise.all(entry.children.map(async child => {
|
|
515
524
|
if (child.directory) {
|
|
516
525
|
await initReaders(child);
|
|
517
526
|
} else {
|
|
@@ -519,7 +528,7 @@ async function initReaders(entry) {
|
|
|
519
528
|
await initStream(reader);
|
|
520
529
|
child.uncompressedSize = reader.size;
|
|
521
530
|
}
|
|
522
|
-
}
|
|
531
|
+
}));
|
|
523
532
|
}
|
|
524
533
|
}
|
|
525
534
|
|
package/package.json
CHANGED