@zip.js/zip.js 2.6.31 → 2.6.33

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.
@@ -0,0 +1,199 @@
1
+ /*
2
+ Make sure the required packages are installed before running this script.
3
+
4
+ npm i @babel/core --save-dev
5
+ npm i @babel/preset-env --save-dev
6
+ npm i core-js --save-dev
7
+ npm i @rollup/plugin-babel --save-dev
8
+ npm i @rollup/plugin-commonjs --save-dev
9
+
10
+ Then, run the command below.
11
+
12
+ npx rollup -c rollup.config.dev.js
13
+
14
+ */
15
+
16
+ import { babel } from "@rollup/plugin-babel";
17
+ import resolve from "@rollup/plugin-node-resolve";
18
+ import commonjs from "@rollup/plugin-commonjs";
19
+ import replace from "@rollup/plugin-replace";
20
+ import fs from "fs";
21
+
22
+ const babelPresets = [
23
+ [
24
+ "@babel/preset-env",
25
+ {
26
+ corejs: 3,
27
+ modules: false,
28
+ useBuiltIns: "usage",
29
+ targets: {
30
+ chrome: "58"
31
+ }
32
+ }
33
+ ]
34
+ ];
35
+
36
+ const bundledPlugins = [
37
+ commonjs(),
38
+ resolve(),
39
+ babel({
40
+ babelHelpers: "bundled",
41
+ babelrc: false,
42
+ exclude: "node_modules/**",
43
+ presets: babelPresets,
44
+ compact: false
45
+ })
46
+ ];
47
+
48
+ const inlinePlugins = [
49
+ commonjs(),
50
+ resolve(),
51
+ babel({
52
+ babelHelpers: "inline",
53
+ babelrc: false,
54
+ exclude: "node_modules/**",
55
+ presets: babelPresets,
56
+ compact: false
57
+ }),
58
+ replace({
59
+ preventAssignment: true,
60
+ "`": () => "'"
61
+ })
62
+ ];
63
+
64
+ const GLOBALS = "const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator } = typeof globalThis !== 'undefined' ? globalThis : this || self;";
65
+ const GLOBALS_WORKER = "const { Array, Object, Math, Error, Uint8Array, Uint16Array, Uint32Array, Int32Array, Map, DataView, Promise, TextEncoder, crypto, postMessage, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream } = self;";
66
+
67
+ export default [{
68
+ input: "lib/z-worker.js",
69
+ output: [{
70
+ intro: GLOBALS_WORKER,
71
+ file: "lib/z-worker-inline.js",
72
+ format: "es"
73
+ }],
74
+ plugins: [
75
+ inlinePlugins
76
+ ]
77
+ }, {
78
+ input: "lib/z-worker-inline-template.js",
79
+ output: [{
80
+ file: "lib/z-worker-inline.js",
81
+ format: "es"
82
+ }],
83
+ plugins: [
84
+ replace({
85
+ preventAssignment: true,
86
+ "__workerCode__": () => fs.readFileSync("lib/z-worker-inline.js").toString()
87
+ })
88
+ ]
89
+ }, {
90
+ input: ["lib/zip.js"],
91
+ output: [{
92
+ intro: GLOBALS,
93
+ file: "dist/zip.min.js",
94
+ format: "umd",
95
+ name: "zip"
96
+ }, {
97
+ intro: GLOBALS,
98
+ file: "dist/zip.js",
99
+ format: "umd",
100
+ name: "zip"
101
+ }],
102
+ plugins: bundledPlugins
103
+ }, {
104
+ input: ["lib/zip-full.js"],
105
+ output: [{
106
+ intro: GLOBALS,
107
+ file: "dist/zip-full.min.js",
108
+ format: "umd",
109
+ name: "zip"
110
+ }, {
111
+ intro: GLOBALS,
112
+ file: "dist/zip-full.js",
113
+ format: "umd",
114
+ name: "zip"
115
+ }],
116
+ plugins: bundledPlugins
117
+ }, {
118
+ input: "lib/zip-no-worker.js",
119
+ output: [{
120
+ intro: GLOBALS,
121
+ file: "dist/zip-no-worker.min.js",
122
+ format: "umd",
123
+ name: "zip"
124
+ }],
125
+ plugins: bundledPlugins
126
+ }, {
127
+ input: "lib/zip-no-worker-deflate.js",
128
+ output: [{
129
+ intro: GLOBALS,
130
+ file: "dist/zip-no-worker-deflate.min.js",
131
+ format: "umd",
132
+ name: "zip"
133
+ }],
134
+ plugins: bundledPlugins
135
+ }, {
136
+ input: "lib/zip-no-worker-inflate.js",
137
+ output: [{
138
+ intro: GLOBALS,
139
+ file: "dist/zip-no-worker-inflate.min.js",
140
+ format: "umd",
141
+ name: "zip"
142
+ }],
143
+ plugins: bundledPlugins
144
+ }, {
145
+ input: "lib/zip-fs.js",
146
+ output: [{
147
+ intro: GLOBALS,
148
+ file: "dist/zip-fs.min.js",
149
+ format: "umd",
150
+ name: "zip"
151
+ }, {
152
+ intro: GLOBALS,
153
+ file: "dist/zip-fs.js",
154
+ format: "umd",
155
+ name: "zip"
156
+ }],
157
+ plugins: bundledPlugins
158
+ }, {
159
+ input: "index.js",
160
+ output: [{
161
+ intro: GLOBALS,
162
+ file: "dist/zip-fs-full.min.js",
163
+ format: "umd",
164
+ name: "zip"
165
+ }, {
166
+ intro: GLOBALS,
167
+ file: "dist/zip-fs-full.js",
168
+ format: "umd",
169
+ name: "zip"
170
+ }, {
171
+ file: "index.cjs",
172
+ format: "cjs"
173
+ }],
174
+ plugins: bundledPlugins
175
+ }, {
176
+ input: "lib/z-worker-bootstrap-pako.js",
177
+ output: [{
178
+ intro: GLOBALS_WORKER,
179
+ file: "dist/z-worker-pako.js",
180
+ format: "iife"
181
+ }],
182
+ plugins: inlinePlugins
183
+ }, {
184
+ input: "lib/z-worker-bootstrap-fflate.js",
185
+ output: [{
186
+ intro: GLOBALS_WORKER,
187
+ file: "dist/z-worker-fflate.js",
188
+ format: "iife"
189
+ }],
190
+ plugins: inlinePlugins
191
+ }, {
192
+ input: "lib/z-worker.js",
193
+ output: [{
194
+ intro: GLOBALS_WORKER,
195
+ file: "dist/z-worker.js",
196
+ format: "iife"
197
+ }],
198
+ plugins: inlinePlugins
199
+ }];
@@ -0,0 +1,243 @@
1
+ /*
2
+ Make sure the required packages are installed before running this script.
3
+
4
+ npm i @babel/core --save-dev
5
+ npm i @babel/preset-env --save-dev
6
+ npm i core-js --save-dev
7
+ npm i @rollup/plugin-babel --save-dev
8
+ npm i @rollup/plugin-commonjs --save-dev
9
+
10
+ Then, run the command below.
11
+
12
+ npx rollup -c rollup.config.js
13
+
14
+ */
15
+
16
+ import { babel } from "@rollup/plugin-babel";
17
+ import resolve from "@rollup/plugin-node-resolve";
18
+ import commonjs from "@rollup/plugin-commonjs";
19
+ import replace from "@rollup/plugin-replace";
20
+ import { terser } from "rollup-plugin-terser";
21
+ import fs from "fs";
22
+
23
+ const babelPresets = [
24
+ [
25
+ "@babel/preset-env",
26
+ {
27
+ corejs: 3,
28
+ modules: false,
29
+ useBuiltIns: "usage",
30
+ targets: {
31
+ chrome: "58"
32
+ }
33
+ }
34
+ ]
35
+ ];
36
+
37
+ const bundledPlugins = [
38
+ commonjs(),
39
+ resolve(),
40
+ babel({
41
+ babelHelpers: "bundled",
42
+ babelrc: false,
43
+ exclude: "node_modules/**",
44
+ presets: babelPresets,
45
+ compact: false
46
+ })
47
+ ];
48
+
49
+ const inlinePlugins = [
50
+ commonjs(),
51
+ resolve(),
52
+ babel({
53
+ babelHelpers: "inline",
54
+ babelrc: false,
55
+ exclude: "node_modules/**",
56
+ presets: babelPresets,
57
+ compact: false
58
+ })
59
+ ];
60
+
61
+ const bundledTerserOptions = {
62
+ compress: {
63
+ unsafe: true,
64
+ unsafe_arrows: true,
65
+ unsafe_comps: true,
66
+ unsafe_symbols: true,
67
+ unsafe_proto: true,
68
+ keep_fargs: false,
69
+ passes: 3,
70
+ ecma: "5"
71
+ }
72
+ };
73
+
74
+ const inlineTerserOptions = {
75
+ compress: {
76
+ unsafe: true,
77
+ unsafe_comps: true,
78
+ unsafe_math: true,
79
+ unsafe_symbols: true,
80
+ unsafe_proto: true,
81
+ keep_fargs: false,
82
+ passes: 3,
83
+ ecma: "5"
84
+ },
85
+ mangle: {
86
+ properties: {
87
+ reserved: ["codecType", "config", "salt", "iterations", "keys", "password", "encryptionStrength", "encrypted", "signed", "compressed", "level", "zipCrypto", "passwordVerification", "pull", "enqueue", "close", "messageId", "chunkSize", "highWaterMark", "useCompressionStream"]
88
+ }
89
+ }
90
+ };
91
+
92
+ const GLOBALS = "const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator } = typeof globalThis !== 'undefined' ? globalThis : this || self;";
93
+ const GLOBALS_WORKER = "const { Array, Object, Math, Error, Uint8Array, Uint32Array, Int32Array, Map, DataView, Promise, TextEncoder, crypto, postMessage, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream } = self;";
94
+
95
+ export default [{
96
+ input: "lib/z-worker.js",
97
+ output: [{
98
+ intro: GLOBALS_WORKER,
99
+ file: "lib/z-worker-inline.js",
100
+ format: "es",
101
+ plugins: [terser(inlineTerserOptions)]
102
+ }],
103
+ plugins: [
104
+ inlinePlugins,
105
+ replace({
106
+ preventAssignment: true,
107
+ "`": () => "'"
108
+ })
109
+ ]
110
+ }, {
111
+ input: "lib/z-worker-inline-template.js",
112
+ output: [{
113
+ file: "lib/z-worker-inline.js",
114
+ format: "es"
115
+ }],
116
+ plugins: [
117
+ replace({
118
+ preventAssignment: true,
119
+ "__workerCode__": () => fs.readFileSync("lib/z-worker-inline.js").toString()
120
+ }),
121
+ terser(bundledTerserOptions)
122
+ ]
123
+ }, {
124
+ input: ["lib/zip.js"],
125
+ output: [{
126
+ intro: GLOBALS,
127
+ file: "dist/zip.min.js",
128
+ format: "umd",
129
+ name: "zip",
130
+ plugins: [terser(bundledTerserOptions)]
131
+ }, {
132
+ intro: GLOBALS,
133
+ file: "dist/zip.js",
134
+ format: "umd",
135
+ name: "zip"
136
+ }],
137
+ plugins: bundledPlugins
138
+ }, {
139
+ input: ["lib/zip-full.js"],
140
+ output: [{
141
+ intro: GLOBALS,
142
+ file: "dist/zip-full.min.js",
143
+ format: "umd",
144
+ name: "zip",
145
+ plugins: [terser(bundledTerserOptions)]
146
+ }, {
147
+ intro: GLOBALS,
148
+ file: "dist/zip-full.js",
149
+ format: "umd",
150
+ name: "zip"
151
+ }],
152
+ plugins: bundledPlugins
153
+ }, {
154
+ input: "lib/zip-no-worker.js",
155
+ output: [{
156
+ intro: GLOBALS,
157
+ file: "dist/zip-no-worker.min.js",
158
+ format: "umd",
159
+ name: "zip",
160
+ plugins: [terser(bundledTerserOptions)]
161
+ }],
162
+ plugins: bundledPlugins
163
+ }, {
164
+ input: "lib/zip-no-worker-deflate.js",
165
+ output: [{
166
+ intro: GLOBALS,
167
+ file: "dist/zip-no-worker-deflate.min.js",
168
+ format: "umd",
169
+ name: "zip",
170
+ plugins: [terser(bundledTerserOptions)]
171
+ }],
172
+ plugins: bundledPlugins
173
+ }, {
174
+ input: "lib/zip-no-worker-inflate.js",
175
+ output: [{
176
+ intro: GLOBALS,
177
+ file: "dist/zip-no-worker-inflate.min.js",
178
+ format: "umd",
179
+ name: "zip",
180
+ plugins: [terser(bundledTerserOptions)]
181
+ }],
182
+ plugins: bundledPlugins
183
+ }, {
184
+ input: "lib/zip-fs.js",
185
+ output: [{
186
+ intro: GLOBALS,
187
+ file: "dist/zip-fs.min.js",
188
+ format: "umd",
189
+ name: "zip",
190
+ plugins: [terser(bundledTerserOptions)]
191
+ }, {
192
+ intro: GLOBALS,
193
+ file: "dist/zip-fs.js",
194
+ format: "umd",
195
+ name: "zip"
196
+ }],
197
+ plugins: bundledPlugins
198
+ }, {
199
+ input: "index.js",
200
+ output: [{
201
+ intro: GLOBALS,
202
+ file: "dist/zip-fs-full.min.js",
203
+ format: "umd",
204
+ name: "zip",
205
+ plugins: [terser(bundledTerserOptions)]
206
+ }, {
207
+ intro: GLOBALS,
208
+ file: "dist/zip-fs-full.js",
209
+ format: "umd",
210
+ name: "zip"
211
+ }, {
212
+ file: "index.cjs",
213
+ format: "cjs"
214
+ }],
215
+ plugins: bundledPlugins
216
+ }, {
217
+ input: "lib/z-worker-bootstrap-pako.js",
218
+ output: [{
219
+ intro: GLOBALS_WORKER,
220
+ file: "dist/z-worker-pako.js",
221
+ format: "iife",
222
+ plugins: [terser(bundledTerserOptions)]
223
+ }],
224
+ plugins: inlinePlugins
225
+ }, {
226
+ input: "lib/z-worker-bootstrap-fflate.js",
227
+ output: [{
228
+ intro: GLOBALS_WORKER,
229
+ file: "dist/z-worker-fflate.js",
230
+ format: "iife",
231
+ plugins: [terser(bundledTerserOptions)]
232
+ }],
233
+ plugins: inlinePlugins
234
+ }, {
235
+ input: "lib/z-worker.js",
236
+ output: [{
237
+ intro: GLOBALS_WORKER,
238
+ file: "dist/z-worker.js",
239
+ format: "iife",
240
+ plugins: [terser(bundledTerserOptions)]
241
+ }],
242
+ plugins: inlinePlugins
243
+ }];
@@ -12,8 +12,7 @@ async function test() {
12
12
  const blobWriter = new zip.BlobWriter("application/zip");
13
13
  const zipWriter = new zip.ZipWriter(blobWriter);
14
14
  const readable = (await fetch(new URL("../data/lorem.txt", import.meta.url))).body;
15
- const reader = { readable };
16
- await zipWriter.add(FILENAME, reader);
15
+ await zipWriter.add(FILENAME, readable);
17
16
  await zipWriter.close();
18
17
  const zipReader = new zip.ZipReader(new zip.BlobReader(await blobWriter.getData()));
19
18
  const entries = await zipReader.getEntries();
@@ -9,7 +9,7 @@ export { test };
9
9
  async function test() {
10
10
  zip.configure({ chunkSize: 128, useWebWorkers: true });
11
11
  const readable = (await fetch(new URL("../data/lorem.zip", import.meta.url))).body;
12
- const zipReader = new zip.ZipReader({ readable });
12
+ const zipReader = new zip.ZipReader(readable);
13
13
  const entries = await zipReader.getEntries();
14
14
  const data = await entries[0].getData(new zip.BlobWriter());
15
15
  await zipReader.close();