@zip.js/zip.js 2.6.63 → 2.6.64
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/.vscode/launch.json +18 -0
- package/package.json +1 -1
- package/.eslintrc.json +0 -43
- package/cli-deno/mc-zip.js +0 -185
- package/rollup-es5.config.dev.js +0 -199
- package/rollup-es5.config.js +0 -243
- package/rollup-fflate.config.dev.js +0 -124
- package/rollup-fflate.config.js +0 -162
- package/rollup.config.dev.js +0 -126
- package/rollup.config.js +0 -171
- package/tests/all/loader.html +0 -29
- package/tests/all/test-abort-signal-read.js +0 -34
- package/tests/all/test-abort-signal-write.js +0 -30
- package/tests/all/test-array.js +0 -29
- package/tests/all/test-base64.js +0 -25
- package/tests/all/test-blob.js +0 -31
- package/tests/all/test-common-js.cjs +0 -31
- package/tests/all/test-crc.js +0 -22
- package/tests/all/test-crypto.js +0 -47
- package/tests/all/test-custom-io.js +0 -61
- package/tests/all/test-data-descriptor-signature.js +0 -33
- package/tests/all/test-data-descriptor.js +0 -33
- package/tests/all/test-duplicated-filename.js +0 -24
- package/tests/all/test-empty.js +0 -16
- package/tests/all/test-extended-timestamp.js +0 -30
- package/tests/all/test-extra-field.js +0 -26
- package/tests/all/test-fflate-no-worker.js +0 -31
- package/tests/all/test-fflate.js +0 -29
- package/tests/all/test-fs-base64.js +0 -24
- package/tests/all/test-fs-export-options.js +0 -34
- package/tests/all/test-fs-http-import.js +0 -25
- package/tests/all/test-fs-http-reader.js +0 -24
- package/tests/all/test-fs-replace.js +0 -27
- package/tests/all/test-fs-streams.js +0 -24
- package/tests/all/test-fs-text.js +0 -21
- package/tests/all/test-fs-unzip-store.js +0 -25
- package/tests/all/test-fs.js +0 -24
- package/tests/all/test-http-crypto.js +0 -31
- package/tests/all/test-http-range.js +0 -18
- package/tests/all/test-http-split-zip.js +0 -37
- package/tests/all/test-http-zip64.js +0 -21
- package/tests/all/test-invalid-crc.js +0 -30
- package/tests/all/test-multiple-writers.js +0 -19
- package/tests/all/test-no-worker.js +0 -25
- package/tests/all/test-pako-no-worker.js +0 -31
- package/tests/all/test-pako.js +0 -29
- package/tests/all/test-parallel-reads.js +0 -53
- package/tests/all/test-parallel-writes-auto-buffered.js +0 -71
- package/tests/all/test-parallel-writes-ordered.js +0 -34
- package/tests/all/test-parallel-writes.js +0 -51
- package/tests/all/test-readable-stream.js +0 -23
- package/tests/all/test-readable-zip-stream.js +0 -20
- package/tests/all/test-safe-closing.js +0 -51
- package/tests/all/test-split-data.js +0 -38
- package/tests/all/test-split-zip.js +0 -41
- package/tests/all/test-store.js +0 -38
- package/tests/all/test-streams.js +0 -29
- package/tests/all/test-sw-worker.js +0 -31
- package/tests/all/test-sw.js +0 -44
- package/tests/all/test-worker-timeout.js +0 -22
- package/tests/all/test-wrapped.js +0 -72
- package/tests/all/test-writable-stream.js +0 -39
- package/tests/all/test-zip64-auto.js +0 -78
- package/tests/all/test-zip64-crypto.js +0 -35
- package/tests/all/test-zip64.js +0 -25
- package/tests/all/test-zipcrypto.js +0 -41
- package/tests/data/lorem-encrypted.zip +0 -0
- package/tests/data/lorem-invalid-crc.zip +0 -0
- package/tests/data/lorem-split.z01 +0 -0
- package/tests/data/lorem-split.z02 +0 -0
- package/tests/data/lorem-split.z03 +0 -0
- package/tests/data/lorem-split.z04 +0 -0
- package/tests/data/lorem-split.z05 +0 -0
- package/tests/data/lorem-split.z06 +0 -0
- package/tests/data/lorem-split.z07 +0 -0
- package/tests/data/lorem-split.zip +0 -0
- package/tests/data/lorem-store.zip +0 -0
- package/tests/data/lorem-zip64.zip +0 -0
- package/tests/data/lorem.txt +0 -1
- package/tests/data/lorem.zip +0 -0
- package/tests/deno-runner.js +0 -15
- package/tests/index.html +0 -21
- package/tests/node-runner.js +0 -40
- package/tests/tests-data.js +0 -55
- package/tests/vendor/fflate-es2019.min.js +0 -1
- package/tests/vendor/fflate.min.js +0 -1
- package/tests/vendor/pako.min.js +0 -2
- package/tests/vendor/pako_deflate.min.js +0 -2
- package/tests/vendor/pako_inflate.min.js +0 -2
- package/tests/web-runner.js +0 -50
- package/tsconfig.json +0 -6
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch node-runner",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"program": "${workspaceFolder}/tests/node-runner.js",
|
|
15
|
+
"cwd": "${workspaceFolder}/tests"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/package.json
CHANGED
package/.eslintrc.json
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"es6": true,
|
|
4
|
-
"node": false,
|
|
5
|
-
"browser": false
|
|
6
|
-
},
|
|
7
|
-
"globals": {
|
|
8
|
-
"console": true
|
|
9
|
-
},
|
|
10
|
-
"extends": "eslint:recommended",
|
|
11
|
-
"parserOptions": {
|
|
12
|
-
"ecmaVersion": 2020,
|
|
13
|
-
"sourceType": "module"
|
|
14
|
-
},
|
|
15
|
-
"ignorePatterns": [
|
|
16
|
-
"dist/",
|
|
17
|
-
"*-inline.js"
|
|
18
|
-
],
|
|
19
|
-
"rules": {
|
|
20
|
-
"indent": [
|
|
21
|
-
"error",
|
|
22
|
-
"tab",
|
|
23
|
-
{
|
|
24
|
-
"SwitchCase": 1
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
"linebreak-style": [
|
|
28
|
-
"error",
|
|
29
|
-
"unix"
|
|
30
|
-
],
|
|
31
|
-
"quotes": [
|
|
32
|
-
"error",
|
|
33
|
-
"double"
|
|
34
|
-
],
|
|
35
|
-
"semi": [
|
|
36
|
-
"error",
|
|
37
|
-
"always"
|
|
38
|
-
],
|
|
39
|
-
"no-console": [
|
|
40
|
-
"warn"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
}
|
package/cli-deno/mc-zip.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S deno run --allow-write --allow-read --allow-net
|
|
2
|
-
|
|
3
|
-
/* global Deno, URL, TextEncoderStream */
|
|
4
|
-
|
|
5
|
-
import { parse as parseArgs } from "https://deno.land/std@0.147.0/flags/mod.ts";
|
|
6
|
-
import { normalize as normalizePath, resolve as resolvePath, extname } from "https://deno.land/std@0.147.0/path/mod.ts";
|
|
7
|
-
import { configure, ZipWriter, terminateWorkers, HttpReader } from "../index.js";
|
|
8
|
-
|
|
9
|
-
const args = parseArgs(Deno.args);
|
|
10
|
-
const stdout = getTextWriter(Deno.stdout);
|
|
11
|
-
main();
|
|
12
|
-
|
|
13
|
-
async function main() {
|
|
14
|
-
const zipfile = args._.shift();
|
|
15
|
-
const list = Array.from(args._);
|
|
16
|
-
if (!zipfile || !list.length) {
|
|
17
|
-
await displayUsage();
|
|
18
|
-
} else {
|
|
19
|
-
await runCommand(zipfile, list, getOptions());
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function displayUsage() {
|
|
24
|
-
await stdout.write("Copyright (c) 2022 Gildas Lormeau. All rights reserved.\n");
|
|
25
|
-
await stdout.write("mc-zip 1.0. Usage:\n");
|
|
26
|
-
await stdout.write("mc-zip [options] zipfile list\n");
|
|
27
|
-
await stdout.write(" The default action is to create or overwrite zipfile entries from list of file names and URLs. Options:\n");
|
|
28
|
-
await stdout.write(" --include-directories include directories in the zip file (default: true)\n");
|
|
29
|
-
await stdout.write(" --include-sub-directories include sub-directories in the zip file (default: true)\n");
|
|
30
|
-
await stdout.write(" --max-workers number of workers (default: number of logical cores)\n");
|
|
31
|
-
await stdout.write(" --buffered-write compress entries in parallel with workers (default: true)\n");
|
|
32
|
-
await stdout.write(" --password password (default: empty string)\n");
|
|
33
|
-
await stdout.write(" --encryption-strength encryption strength when using AES between 1 and 3 (default: 3)\n");
|
|
34
|
-
await stdout.write(" --zip-crypto use ZipCrypto instead of AES (default: false)\n");
|
|
35
|
-
await stdout.write(" --data-descriptor add data descriptors (default: true)\n");
|
|
36
|
-
await stdout.write(" --data-descriptor-signature add data descriptor signatures (default: false)\n");
|
|
37
|
-
await stdout.write(" --keep-order keep entries order (default: true)\n");
|
|
38
|
-
await stdout.write(" --zip64 use Zip64 format (default: false)\n");
|
|
39
|
-
await stdout.write(" --prevent-parent-directories remove occurences of \"../\" in filenames (default: true)\n");
|
|
40
|
-
await stdout.write("\n");
|
|
41
|
-
Deno.exit(-1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getOptions() {
|
|
45
|
-
const options = {
|
|
46
|
-
bufferedWrite: true,
|
|
47
|
-
encryptionStrength: 3,
|
|
48
|
-
dataDescriptor: true,
|
|
49
|
-
keepOrder: true,
|
|
50
|
-
includeDirectories: true,
|
|
51
|
-
includeSubDirectories: true,
|
|
52
|
-
preventParentDirectories: true
|
|
53
|
-
};
|
|
54
|
-
for (const option of Object.getOwnPropertyNames(args)) {
|
|
55
|
-
if (option != "_") {
|
|
56
|
-
options[toCamelCase(option)] = args[option];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return options;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function runCommand(zipfile, list, options) {
|
|
63
|
-
list = await Promise.all(list.map(file => getFileInfo(file, options)));
|
|
64
|
-
if (options.includeDirectories) {
|
|
65
|
-
list = await Promise.all(list.map(file => addDirectories(file, options)));
|
|
66
|
-
}
|
|
67
|
-
list = list.flat();
|
|
68
|
-
zipfile = await Deno.open(zipfile, { create: true, write: true });
|
|
69
|
-
configure(options);
|
|
70
|
-
const zipWriter = new ZipWriter(zipfile, options);
|
|
71
|
-
try {
|
|
72
|
-
await Promise.all(list.map(file => addFile(zipWriter, file)));
|
|
73
|
-
await zipWriter.close();
|
|
74
|
-
} finally {
|
|
75
|
-
terminateWorkers();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function addFile(zipWriter, file) {
|
|
80
|
-
const options = {
|
|
81
|
-
onstart: () => stdout.write(" adding: " + file.name + "\n")
|
|
82
|
-
};
|
|
83
|
-
try {
|
|
84
|
-
const reader = await getReader(file);
|
|
85
|
-
if (reader) {
|
|
86
|
-
await zipWriter.add(file.name, reader, options);
|
|
87
|
-
}
|
|
88
|
-
} catch (error) {
|
|
89
|
-
await stdout.write(" error: " + error.message + ", file: " + file.url + "\n");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function getFileInfo(file, options) {
|
|
94
|
-
let name, isFile, isDirectory, resolvedName, size;
|
|
95
|
-
const remote = isRemote(file);
|
|
96
|
-
if (remote) {
|
|
97
|
-
const url = new URL(file, import.meta.url);
|
|
98
|
-
name = url.hostname + (url.pathname == "/" ? "/index.html" : url.pathname);
|
|
99
|
-
if (!extname(name)) {
|
|
100
|
-
name += ".html";
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
name = file;
|
|
104
|
-
resolvedName = resolvePath(name);
|
|
105
|
-
}
|
|
106
|
-
name = normalizePath(replaceSlashes(name));
|
|
107
|
-
if (resolvedName) {
|
|
108
|
-
if (options.preventParentDirectories) {
|
|
109
|
-
name = cleanFilename(name);
|
|
110
|
-
}
|
|
111
|
-
const stat = await Deno.stat(resolvedName);
|
|
112
|
-
isFile = stat.isFile;
|
|
113
|
-
isDirectory = stat.isDirectory;
|
|
114
|
-
size = stat.size;
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
url: file, name, remote, isFile, size, isDirectory, resolvedName
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function addDirectories(file, options) {
|
|
122
|
-
if (file.isDirectory) {
|
|
123
|
-
const result = [];
|
|
124
|
-
for await (const entry of Deno.readDir(resolvePath(file.url))) {
|
|
125
|
-
const fileInfo = await getFileInfo(file.url + "/" + entry.name, options);
|
|
126
|
-
if (entry.isFile) {
|
|
127
|
-
result.push(fileInfo);
|
|
128
|
-
} else if (entry.isDirectory && options.includeSubDirectories) {
|
|
129
|
-
result.push(await addDirectories(fileInfo, options));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return result.flat();
|
|
133
|
-
} else {
|
|
134
|
-
return file;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function getReader(file) {
|
|
139
|
-
if (file.remote) {
|
|
140
|
-
return new HttpReader(file.url);
|
|
141
|
-
} else if (file.isFile) {
|
|
142
|
-
const { size } = file;
|
|
143
|
-
const { readable } = await Deno.open(resolvePath(file.url), { read: true });
|
|
144
|
-
return {
|
|
145
|
-
readable,
|
|
146
|
-
size
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function isRemote(path) {
|
|
152
|
-
return path.startsWith("http:") || path.startsWith("https:");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function getTextWriter(stdout) {
|
|
156
|
-
const textEncoderStream = new TextEncoderStream();
|
|
157
|
-
textEncoderStream.readable.pipeTo(stdout.writable);
|
|
158
|
-
return textEncoderStream.writable.getWriter();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function replaceSlashes(url) {
|
|
162
|
-
url = url.replace(/\\/g, "/");
|
|
163
|
-
const match = url.match(/^(?:\/)?(.*?)(?:\/)?$/);
|
|
164
|
-
if (match) {
|
|
165
|
-
return match[1];
|
|
166
|
-
} else {
|
|
167
|
-
return url;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function cleanFilename(name) {
|
|
172
|
-
const result = replaceSlashes(("/" + name + "/").replace(/(\/|\\)+(\.+)(\/|\\)+/g, "/"));
|
|
173
|
-
if (result == name) {
|
|
174
|
-
return result;
|
|
175
|
-
} else {
|
|
176
|
-
return cleanFilename(result);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function toCamelCase(kebabCase) {
|
|
181
|
-
return kebabCase
|
|
182
|
-
.split("-")
|
|
183
|
-
.map((word, indexWord) => indexWord ? word.charAt(0).toUpperCase() + word.substring(1) : word)
|
|
184
|
-
.join("");
|
|
185
|
-
}
|
package/rollup-es5.config.dev.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
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, Worker } = typeof globalThis !== 'undefined' ? globalThis : this || self;";
|
|
65
|
-
const GLOBALS_WORKER = "const { Array, Object, Number, 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
|
-
}];
|
package/rollup-es5.config.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
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", "preventAbort", "CompressionStreamNative", "DecompressionStreamNative"]
|
|
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, Worker } = typeof globalThis !== 'undefined' ? globalThis : this || self;";
|
|
93
|
-
const GLOBALS_WORKER = "const { Array, Object, Number, 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
|
-
}];
|