@zip.js/zip.js 2.6.79 → 2.6.80
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/README.md +4 -4
- package/dist/zip-fs-full.js +63 -33
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +63 -33
- package/dist/zip-fs.min.js +1 -1
- package/index.cjs +63 -33
- package/index.d.ts +22 -15
- package/lib/core/zip-fs-core.js +66 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,10 @@ encryption.
|
|
|
10
10
|
|
|
11
11
|
See here for more info: https://gildas-lormeau.github.io/zip.js/
|
|
12
12
|
|
|
13
|
+
## PWA Demo based on React
|
|
14
|
+
|
|
15
|
+
See https://gildas-lormeau.github.io/zipjs-react-app
|
|
16
|
+
|
|
13
17
|
# Examples
|
|
14
18
|
|
|
15
19
|
## Hello world
|
|
@@ -164,10 +168,6 @@ function downloadFile(blob) {
|
|
|
164
168
|
|
|
165
169
|
Run the code on Plunker: https://plnkr.co/edit/4sVljNIpqSUE9HCA?preview
|
|
166
170
|
|
|
167
|
-
## Demo of the FS API based on React
|
|
168
|
-
|
|
169
|
-
See https://gildas-lormeau.github.io/zipjs-react-app
|
|
170
|
-
|
|
171
171
|
## Tests
|
|
172
172
|
|
|
173
173
|
See https://github.com/gildas-lormeau/zip.js/tree/master/tests/all
|
package/dist/zip-fs-full.js
CHANGED
|
@@ -10100,6 +10100,7 @@
|
|
|
10100
10100
|
fs,
|
|
10101
10101
|
name,
|
|
10102
10102
|
data: params.data,
|
|
10103
|
+
options: params.options,
|
|
10103
10104
|
id: fs.entries.length,
|
|
10104
10105
|
parent,
|
|
10105
10106
|
children: [],
|
|
@@ -10266,39 +10267,43 @@
|
|
|
10266
10267
|
return clonedEntry;
|
|
10267
10268
|
}
|
|
10268
10269
|
|
|
10269
|
-
addDirectory(name) {
|
|
10270
|
-
return addChild(this, name,
|
|
10270
|
+
addDirectory(name, options) {
|
|
10271
|
+
return addChild(this, name, { options }, true);
|
|
10271
10272
|
}
|
|
10272
10273
|
|
|
10273
|
-
addText(name, text) {
|
|
10274
|
+
addText(name, text, options = {}) {
|
|
10274
10275
|
return addChild(this, name, {
|
|
10275
10276
|
data: text,
|
|
10276
10277
|
Reader: TextReader,
|
|
10277
|
-
Writer: TextWriter
|
|
10278
|
+
Writer: TextWriter,
|
|
10279
|
+
options
|
|
10278
10280
|
});
|
|
10279
10281
|
}
|
|
10280
10282
|
|
|
10281
|
-
addBlob(name, blob) {
|
|
10283
|
+
addBlob(name, blob, options = {}) {
|
|
10282
10284
|
return addChild(this, name, {
|
|
10283
10285
|
data: blob,
|
|
10284
10286
|
Reader: BlobReader,
|
|
10285
|
-
Writer: BlobWriter
|
|
10287
|
+
Writer: BlobWriter,
|
|
10288
|
+
options
|
|
10286
10289
|
});
|
|
10287
10290
|
}
|
|
10288
10291
|
|
|
10289
|
-
addData64URI(name, dataURI) {
|
|
10292
|
+
addData64URI(name, dataURI, options = {}) {
|
|
10290
10293
|
return addChild(this, name, {
|
|
10291
10294
|
data: dataURI,
|
|
10292
10295
|
Reader: Data64URIReader,
|
|
10293
|
-
Writer: Data64URIWriter
|
|
10296
|
+
Writer: Data64URIWriter,
|
|
10297
|
+
options
|
|
10294
10298
|
});
|
|
10295
10299
|
}
|
|
10296
10300
|
|
|
10297
|
-
addUint8Array(name, array) {
|
|
10301
|
+
addUint8Array(name, array, options = {}) {
|
|
10298
10302
|
return addChild(this, name, {
|
|
10299
10303
|
data: array,
|
|
10300
10304
|
Reader: Uint8ArrayReader,
|
|
10301
|
-
Writer: Uint8ArrayWriter
|
|
10305
|
+
Writer: Uint8ArrayWriter,
|
|
10306
|
+
options
|
|
10302
10307
|
});
|
|
10303
10308
|
}
|
|
10304
10309
|
|
|
@@ -10309,18 +10314,20 @@
|
|
|
10309
10314
|
constructor(url) {
|
|
10310
10315
|
super(url, options);
|
|
10311
10316
|
}
|
|
10312
|
-
}
|
|
10317
|
+
},
|
|
10318
|
+
options
|
|
10313
10319
|
});
|
|
10314
10320
|
}
|
|
10315
10321
|
|
|
10316
|
-
addReadable(name, readable) {
|
|
10322
|
+
addReadable(name, readable, options = {}) {
|
|
10317
10323
|
return addChild(this, name, {
|
|
10318
|
-
Reader: function () { return { readable }; }
|
|
10324
|
+
Reader: function () { return { readable }; },
|
|
10325
|
+
options
|
|
10319
10326
|
});
|
|
10320
10327
|
}
|
|
10321
10328
|
|
|
10322
|
-
addFileSystemEntry(fileSystemEntry) {
|
|
10323
|
-
return addFileSystemEntry(this, fileSystemEntry);
|
|
10329
|
+
addFileSystemEntry(fileSystemEntry, options = {}) {
|
|
10330
|
+
return addFileSystemEntry(this, fileSystemEntry, options);
|
|
10324
10331
|
}
|
|
10325
10332
|
|
|
10326
10333
|
addData(name, params) {
|
|
@@ -10458,32 +10465,32 @@
|
|
|
10458
10465
|
return this.root.getChildByName(name);
|
|
10459
10466
|
}
|
|
10460
10467
|
|
|
10461
|
-
addDirectory(name) {
|
|
10462
|
-
return this.root.addDirectory(name);
|
|
10468
|
+
addDirectory(name, options) {
|
|
10469
|
+
return this.root.addDirectory(name, options);
|
|
10463
10470
|
}
|
|
10464
10471
|
|
|
10465
|
-
addText(name, text) {
|
|
10466
|
-
return this.root.addText(name, text);
|
|
10472
|
+
addText(name, text, options) {
|
|
10473
|
+
return this.root.addText(name, text, options);
|
|
10467
10474
|
}
|
|
10468
10475
|
|
|
10469
|
-
addBlob(name, blob) {
|
|
10470
|
-
return this.root.addBlob(name, blob);
|
|
10476
|
+
addBlob(name, blob, options) {
|
|
10477
|
+
return this.root.addBlob(name, blob, options);
|
|
10471
10478
|
}
|
|
10472
10479
|
|
|
10473
|
-
addData64URI(name, dataURI) {
|
|
10474
|
-
return this.root.addData64URI(name, dataURI);
|
|
10480
|
+
addData64URI(name, dataURI, options) {
|
|
10481
|
+
return this.root.addData64URI(name, dataURI, options);
|
|
10475
10482
|
}
|
|
10476
10483
|
|
|
10477
10484
|
addHttpContent(name, url, options) {
|
|
10478
10485
|
return this.root.addHttpContent(name, url, options);
|
|
10479
10486
|
}
|
|
10480
10487
|
|
|
10481
|
-
addReadable(name, readable) {
|
|
10482
|
-
return this.root.addReadable(name, readable);
|
|
10488
|
+
addReadable(name, readable, options) {
|
|
10489
|
+
return this.root.addReadable(name, readable, options);
|
|
10483
10490
|
}
|
|
10484
10491
|
|
|
10485
|
-
addFileSystemEntry(fileSystemEntry) {
|
|
10486
|
-
return this.root.addFileSystemEntry(fileSystemEntry);
|
|
10492
|
+
addFileSystemEntry(fileSystemEntry, options) {
|
|
10493
|
+
return this.root.addFileSystemEntry(fileSystemEntry, options);
|
|
10487
10494
|
}
|
|
10488
10495
|
|
|
10489
10496
|
addData(name, params) {
|
|
@@ -10625,9 +10632,32 @@
|
|
|
10625
10632
|
|
|
10626
10633
|
async function processChild(child) {
|
|
10627
10634
|
const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
|
|
10635
|
+
let externalFileAttribute;
|
|
10636
|
+
let versionMadeBy;
|
|
10637
|
+
let comment;
|
|
10638
|
+
let lastModDate;
|
|
10639
|
+
let lastAccessDate;
|
|
10640
|
+
let creationDate;
|
|
10641
|
+
let childOptions = child.options || {};
|
|
10642
|
+
if (child.data instanceof Entry) {
|
|
10643
|
+
({
|
|
10644
|
+
externalFileAttribute,
|
|
10645
|
+
versionMadeBy,
|
|
10646
|
+
comment,
|
|
10647
|
+
lastModDate,
|
|
10648
|
+
lastAccessDate,
|
|
10649
|
+
creationDate
|
|
10650
|
+
} = child.data);
|
|
10651
|
+
}
|
|
10628
10652
|
await zipWriter.add(name, child.reader, Object.assign({
|
|
10629
10653
|
directory: child.directory
|
|
10630
10654
|
}, Object.assign({}, options, {
|
|
10655
|
+
externalFileAttribute,
|
|
10656
|
+
versionMadeBy,
|
|
10657
|
+
comment,
|
|
10658
|
+
lastModDate,
|
|
10659
|
+
lastAccessDate,
|
|
10660
|
+
creationDate,
|
|
10631
10661
|
onprogress: async indexProgress => {
|
|
10632
10662
|
if (options.onprogress) {
|
|
10633
10663
|
entryOffsets.set(name, indexProgress);
|
|
@@ -10638,30 +10668,30 @@
|
|
|
10638
10668
|
}
|
|
10639
10669
|
}
|
|
10640
10670
|
}
|
|
10641
|
-
})));
|
|
10671
|
+
}, childOptions)));
|
|
10642
10672
|
await process(zipWriter, child);
|
|
10643
10673
|
}
|
|
10644
10674
|
}
|
|
10645
10675
|
}
|
|
10646
10676
|
|
|
10647
|
-
async function addFileSystemEntry(zipEntry, fileSystemEntry) {
|
|
10677
|
+
async function addFileSystemEntry(zipEntry, fileSystemEntry, options) {
|
|
10648
10678
|
if (fileSystemEntry.isDirectory) {
|
|
10649
|
-
const entry = zipEntry.addDirectory(fileSystemEntry.name);
|
|
10679
|
+
const entry = zipEntry.addDirectory(fileSystemEntry.name, options);
|
|
10650
10680
|
await addDirectory(entry, fileSystemEntry);
|
|
10651
10681
|
return entry;
|
|
10652
10682
|
} else {
|
|
10653
|
-
return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file)), reject));
|
|
10683
|
+
return new Promise((resolve, reject) => fileSystemEntry.file(file => resolve(zipEntry.addBlob(fileSystemEntry.name, file, options)), reject));
|
|
10654
10684
|
}
|
|
10655
10685
|
|
|
10656
10686
|
async function addDirectory(zipEntry, fileEntry) {
|
|
10657
10687
|
const children = await getChildren(fileEntry);
|
|
10658
10688
|
for (const child of children) {
|
|
10659
10689
|
if (child.isDirectory) {
|
|
10660
|
-
await addDirectory(zipEntry.addDirectory(child.name), child);
|
|
10690
|
+
await addDirectory(zipEntry.addDirectory(child.name, options), child);
|
|
10661
10691
|
} else {
|
|
10662
10692
|
await new Promise((resolve, reject) => {
|
|
10663
10693
|
child.file(file => {
|
|
10664
|
-
const childZipEntry = zipEntry.addBlob(child.name, file);
|
|
10694
|
+
const childZipEntry = zipEntry.addBlob(child.name, file, options);
|
|
10665
10695
|
childZipEntry.uncompressedSize = file.size;
|
|
10666
10696
|
resolve(childZipEntry);
|
|
10667
10697
|
}, reject);
|