@zip.js/zip.js 2.8.51 → 2.8.52

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.
@@ -48,6 +48,8 @@ let initModule = () => { };
48
48
 
49
49
  export {
50
50
  CodecWorker,
51
+ ProgressWatcherStream,
52
+ callHandler,
51
53
  configureWorker,
52
54
  resetWebWorkerSupport,
53
55
  supportsDeflate,
@@ -81,6 +81,8 @@ const FILE_ATTR_MSDOS_SYSTEM_MASK = 0x04;
81
81
  const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
82
82
  const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
83
83
  const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
84
+ const FILE_ATTR_UNIX_TYPE_SYMLINK = 0o120000;
85
+ const FILE_ATTR_UNIX_TYPE_FILE = 0o100000;
84
86
  const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
85
87
  const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
86
88
  const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
@@ -166,6 +168,8 @@ export {
166
168
  FILE_ATTR_MSDOS_ARCHIVE_MASK,
167
169
  FILE_ATTR_UNIX_TYPE_MASK,
168
170
  FILE_ATTR_UNIX_TYPE_DIR,
171
+ FILE_ATTR_UNIX_TYPE_SYMLINK,
172
+ FILE_ATTR_UNIX_TYPE_FILE,
169
173
  FILE_ATTR_UNIX_EXECUTABLE_MASK,
170
174
  FILE_ATTR_UNIX_DEFAULT_MASK,
171
175
  FILE_ATTR_UNIX_SETUID_MASK,
package/lib/core/io.js CHANGED
@@ -87,8 +87,10 @@ class Reader extends Stream {
87
87
  async pull(controller) {
88
88
  const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
89
89
  const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
90
- controller.enqueue(data);
91
- if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
90
+ if (data.length) {
91
+ controller.enqueue(data);
92
+ }
93
+ if ((chunkOffset + chunkSize >= size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
92
94
  controller.close();
93
95
  } else {
94
96
  chunkOffset += chunkSize;
@@ -166,6 +168,7 @@ class Data64URIWriter extends Writer {
166
168
  constructor(contentType) {
167
169
  super();
168
170
  Object.assign(this, {
171
+ contentType,
169
172
  data: "data:" + (contentType || "") + ";base64,",
170
173
  pending: []
171
174
  });
@@ -267,6 +270,7 @@ class BlobWriter extends Stream {
267
270
  return transformStream.writable;
268
271
  }
269
272
  });
273
+ writer.contentType = contentType;
270
274
  writer.blob = streamToBlob(transformStream.readable, contentType);
271
275
  writer.blob.catch(() => { });
272
276
  }
@@ -283,6 +287,26 @@ class TextReader extends BlobReader {
283
287
  }
284
288
  }
285
289
 
290
+ function getTextSize(text) {
291
+ let size = 0;
292
+ for (let indexCharacter = 0; indexCharacter < text.length; indexCharacter++) {
293
+ const characterCode = text.charCodeAt(indexCharacter);
294
+ if (characterCode < 0x80) {
295
+ size += 1;
296
+ } else if (characterCode < 0x800) {
297
+ size += 2;
298
+ } else if (characterCode < 0xd800 || characterCode >= 0xe000) {
299
+ size += 3;
300
+ } else if (characterCode < 0xdc00 && (text.charCodeAt(indexCharacter + 1) & 0xfc00) == 0xdc00) {
301
+ size += 4;
302
+ indexCharacter++;
303
+ } else {
304
+ size += 3;
305
+ }
306
+ }
307
+ return size;
308
+ }
309
+
286
310
  class TextWriter extends BlobWriter {
287
311
 
288
312
  constructor(encoding) {
@@ -946,6 +970,10 @@ class GenericWriter {
946
970
  }
947
971
  }
948
972
 
973
+ function ownsWritable(writer) {
974
+ return Boolean(writer && writer.getData);
975
+ }
976
+
949
977
  function isHttpFamily(url) {
950
978
  const { baseURI } = getConfiguration();
951
979
  const { protocol } = new URL(url, baseURI);
@@ -968,11 +996,13 @@ export {
968
996
  initStream,
969
997
  GenericReader,
970
998
  GenericWriter,
999
+ ownsWritable,
971
1000
  readUint8Array,
972
1001
  Reader,
973
1002
  Writer,
974
1003
  TextReader,
975
1004
  TextWriter,
1005
+ getTextSize,
976
1006
  Data64URIReader,
977
1007
  Data64URIWriter,
978
1008
  BlobReader,
@@ -36,8 +36,6 @@ export {
36
36
  streamToBlob
37
37
  };
38
38
 
39
- const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
40
-
41
39
  function toCompatibleReadable(readable) {
42
40
  if (readable instanceof ReadableStream) {
43
41
  return readable;
@@ -60,12 +58,9 @@ function toCompatibleReadable(readable) {
60
58
 
61
59
  function streamToBlob(readable, contentType) {
62
60
  readable = toCompatibleReadable(readable);
61
+ const blobOptions = contentType ? { type: contentType } : {};
63
62
  if (responseSupportsGlobalReadable()) {
64
- const options = {};
65
- if (contentType) {
66
- options.headers = [[HTTP_HEADER_CONTENT_TYPE, contentType]];
67
- }
68
- return new Response(readable, options).blob();
63
+ return new Response(readable).blob().then(blob => contentType ? new Blob([blob], blobOptions) : blob);
69
64
  }
70
65
  const chunks = [];
71
66
  return readable
@@ -74,7 +69,7 @@ function streamToBlob(readable, contentType) {
74
69
  chunks.push(chunk);
75
70
  }
76
71
  }))
77
- .then(() => new Blob(chunks, contentType ? { type: contentType } : {}));
72
+ .then(() => new Blob(chunks, blobOptions));
78
73
  }
79
74
 
80
75
  function responseSupportsGlobalReadable() {
@@ -42,6 +42,8 @@ const PROPERTY_NAME_CREATION_DATE = "creationDate";
42
42
  const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
43
43
  const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
44
44
  const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
45
+ const PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES = "internalFileAttribute";
46
+ const PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttribute";
45
47
  const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
46
48
  const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
47
49
  const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
@@ -52,6 +54,7 @@ const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
52
54
  const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
53
55
  const PROPERTY_NAME_DIRECTORY = "directory";
54
56
  const PROPERTY_NAME_EXECUTABLE = "executable";
57
+ const PROPERTY_NAME_SYMLINK = "symlink";
55
58
  const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
56
59
  const PROPERTY_NAME_SIGNATURE = "signature";
57
60
  const PROPERTY_NAME_CRC32 = "crc32";
@@ -95,6 +98,8 @@ const PROPERTY_NAMES = [
95
98
  PROPERTY_NAME_DISK_NUMBER_START,
96
99
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
97
100
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
101
+ PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
102
+ PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
98
103
  PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
99
104
  PROPERTY_NAME_MSDOS_ATTRIBUTES,
100
105
  PROPERTY_NAME_MS_DOS_COMPATIBLE,
@@ -105,6 +110,7 @@ const PROPERTY_NAMES = [
105
110
  PROPERTY_NAME_ZIPCRYPTO,
106
111
  PROPERTY_NAME_DIRECTORY,
107
112
  PROPERTY_NAME_EXECUTABLE,
113
+ PROPERTY_NAME_SYMLINK,
108
114
  PROPERTY_NAME_COMPRESSION_METHOD,
109
115
  PROPERTY_NAME_SIGNATURE,
110
116
  PROPERTY_NAME_CRC32,
@@ -157,6 +163,8 @@ export {
157
163
  PROPERTY_NAME_RAW_CREATION_DATE,
158
164
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
159
165
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
166
+ PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES,
167
+ PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES,
160
168
  PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
161
169
  PROPERTY_NAME_MSDOS_ATTRIBUTES,
162
170
  PROPERTY_NAME_MS_DOS_COMPATIBLE,