single-file-cli 1.1.53 → 2.0.2
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/{.eslintrc.js → .eslintrc.json} +5 -6
- package/Dockerfile +2 -1
- package/README.MD +56 -60
- package/args.js +252 -334
- package/back-ends/chromium-back-end.js +223 -0
- package/back-ends/chromium-browser.js +89 -0
- package/back-ends/chromium-constants.js +157 -0
- package/back-ends/{common/scripts.js → single-file-script.js} +21 -49
- package/build-lib-dev.sh +84 -0
- package/build-lib.sh +80 -3
- package/compile.sh +13 -0
- package/deno-polyfill.js +223 -0
- package/deno.json +13 -0
- package/deno.lock +49 -0
- package/lib/single-file-bundle.js +1 -0
- package/package.json +9 -33
- package/single-file +39 -14
- package/single-file-cli-api.js +32 -44
- package/back-ends/extensions/bypass-csp/index.js +0 -36
- package/back-ends/extensions/bypass-csp/manifest.json +0 -20
- package/back-ends/extensions/disable-web-security/index.js +0 -54
- package/back-ends/extensions/disable-web-security/manifest.json +0 -20
- package/back-ends/extensions/network-idle/bg.js +0 -61
- package/back-ends/extensions/network-idle/content.js +0 -29
- package/back-ends/extensions/network-idle/manifest.json +0 -31
- package/back-ends/extensions/signed/bypass_csp-0.0.3-an+fx.xpi +0 -0
- package/back-ends/extensions/signed/disable_web_security-0.0.3-an+fx.xpi +0 -0
- package/back-ends/extensions/signed/network_idle-0.0.2-an+fx.xpi +0 -0
- package/back-ends/jsdom.js +0 -159
- package/back-ends/playwright-chromium.js +0 -126
- package/back-ends/playwright-firefox.js +0 -115
- package/back-ends/playwright-webkit.js +0 -126
- package/back-ends/puppeteer-firefox.js +0 -172
- package/back-ends/puppeteer.js +0 -201
- package/back-ends/webdriver-chromium.js +0 -172
- package/back-ends/webdriver-gecko.js +0 -190
- package/lib/single-file-bootstrap.js +0 -1
- package/lib/single-file-frames.js +0 -1
- package/lib/single-file-hooks-frames.js +0 -1
- package/lib/single-file-zip.min.js +0 -1
- package/lib/single-file.js +0 -1
- package/rollup.config.dev.js +0 -57
- package/rollup.config.js +0 -58
package/build-lib.sh
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
npm
|
|
4
|
-
npm update
|
|
3
|
+
deno vendor "npm:single-file-core"
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
echo "
|
|
6
|
+
import { build } from 'npm:esbuild';
|
|
7
|
+
|
|
8
|
+
await build({
|
|
9
|
+
entryPoints: [
|
|
10
|
+
'node_modules/single-file-core/single-file.js'
|
|
11
|
+
],
|
|
12
|
+
bundle: true,
|
|
13
|
+
globalName: 'singlefile',
|
|
14
|
+
outdir: 'lib/',
|
|
15
|
+
platform: 'browser',
|
|
16
|
+
sourcemap: false,
|
|
17
|
+
minify: true,
|
|
18
|
+
format: 'iife',
|
|
19
|
+
plugins: [],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await build({
|
|
23
|
+
entryPoints: [
|
|
24
|
+
'node_modules/single-file-core/single-file-bootstrap.js'
|
|
25
|
+
],
|
|
26
|
+
bundle: true,
|
|
27
|
+
globalName: 'singlefileBootstrap',
|
|
28
|
+
outdir: 'lib/',
|
|
29
|
+
platform: 'browser',
|
|
30
|
+
sourcemap: false,
|
|
31
|
+
minify: true,
|
|
32
|
+
format: 'iife',
|
|
33
|
+
plugins: [],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await build({
|
|
37
|
+
entryPoints: [
|
|
38
|
+
'node_modules/single-file-core/single-file-hooks-frames.js'
|
|
39
|
+
],
|
|
40
|
+
bundle: true,
|
|
41
|
+
outdir: 'lib/',
|
|
42
|
+
platform: 'browser',
|
|
43
|
+
sourcemap: false,
|
|
44
|
+
minify: true,
|
|
45
|
+
format: 'iife',
|
|
46
|
+
plugins: [],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await build({
|
|
50
|
+
entryPoints: [
|
|
51
|
+
'node_modules/single-file-core/vendor/zip/zip.min.js'
|
|
52
|
+
],
|
|
53
|
+
bundle: true,
|
|
54
|
+
globalName: 'zip',
|
|
55
|
+
outdir: 'lib/',
|
|
56
|
+
platform: 'browser',
|
|
57
|
+
sourcemap: false,
|
|
58
|
+
minify: true,
|
|
59
|
+
format: 'iife',
|
|
60
|
+
plugins: [],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const SCRIPTS = [
|
|
64
|
+
'lib/single-file.js',
|
|
65
|
+
'lib/single-file-bootstrap.js',
|
|
66
|
+
'lib/zip.min.js'
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
let script = '';
|
|
70
|
+
const scripts = SCRIPTS.map(script => Deno.readTextFile(script));
|
|
71
|
+
const sources = await Promise.all(scripts);
|
|
72
|
+
script += 'const script = ' + JSON.stringify(sources.join(';')) + ';';
|
|
73
|
+
const hookScript = await Deno.readTextFile('lib/single-file-hooks-frames.js');
|
|
74
|
+
script += 'const hookScript = ' + JSON.stringify(hookScript) + ';';
|
|
75
|
+
const zipScript = await Deno.readTextFile('lib/zip.min.js');
|
|
76
|
+
script += 'const zipScript = ' + JSON.stringify(zipScript) + ';';
|
|
77
|
+
script += 'export { script, zipScript, hookScript };';
|
|
78
|
+
await Deno.writeTextFile('lib/single-file-bundle.js', script)
|
|
79
|
+
await Promise.all(SCRIPTS.map(script => Deno.remove(script)));
|
|
80
|
+
await Deno.remove('lib/single-file-hooks-frames.js');
|
|
81
|
+
" | deno run --allow-read --allow-write --allow-net --allow-run --allow-env --lock=node_modules/deno.lock.tmp -
|
|
82
|
+
|
|
83
|
+
rm -rf node_modules
|
package/compile.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
cp ./package.json ./package.json.copy
|
|
4
|
+
jq 'del(.dependencies)' ./package.json.copy > ./package.json
|
|
5
|
+
rm -rf node_modules
|
|
6
|
+
|
|
7
|
+
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-aarch64-apple-darwin --target=aarch64-apple-darwin ./single-file
|
|
8
|
+
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-x86_64-apple-darwin --target=x86_64-apple-darwin ./single-file
|
|
9
|
+
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-x86_64-linux --target=x86_64-unknown-linux-gnu ./single-file
|
|
10
|
+
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-aarch64-linux --target=aarch64-unknown-linux-gnu ./single-file
|
|
11
|
+
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file.exe --target=x86_64-pc-windows-msvc ./single-file
|
|
12
|
+
|
|
13
|
+
mv ./package.json.copy ./package.json
|
package/deno-polyfill.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2010-2024 Gildas Lormeau
|
|
3
|
+
* contact : gildas.lormeau <at> gmail.com
|
|
4
|
+
*
|
|
5
|
+
* This file is part of SingleFile.
|
|
6
|
+
*
|
|
7
|
+
* The code in this file is free software: you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Affero General Public License
|
|
9
|
+
* (GNU AGPL) as published by the Free Software Foundation, either version 3
|
|
10
|
+
* of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* The code in this file is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
|
15
|
+
* General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* As additional permission under GNU AGPL version 3 section 7, you may
|
|
18
|
+
* distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
|
|
19
|
+
* AGPL normally required by section 4, provided you include this license
|
|
20
|
+
* notice and a URL through which recipients can access the Corresponding
|
|
21
|
+
* Source.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/* global globalThis, URL, Deno, process */
|
|
25
|
+
|
|
26
|
+
import * as path from "path";
|
|
27
|
+
import { CDP } from "simple-cdp";
|
|
28
|
+
|
|
29
|
+
const DENO_RUNTIME_DETECTED = typeof Deno !== "undefined";
|
|
30
|
+
|
|
31
|
+
const NPM_MODULES = {
|
|
32
|
+
"ws": "ws",
|
|
33
|
+
"simple-cdp": "simple-cdp",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const NODE_MODULES = {
|
|
37
|
+
"fs": "node:fs/promises",
|
|
38
|
+
"os": "node:os",
|
|
39
|
+
"child_process": "node:child_process",
|
|
40
|
+
"url": "node:url"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
initGlobalThisProperties,
|
|
45
|
+
args,
|
|
46
|
+
readTextFile,
|
|
47
|
+
writeTextFile,
|
|
48
|
+
mkdir,
|
|
49
|
+
makeTempDir,
|
|
50
|
+
stat,
|
|
51
|
+
remove,
|
|
52
|
+
stdout,
|
|
53
|
+
exit,
|
|
54
|
+
build,
|
|
55
|
+
errors,
|
|
56
|
+
Command,
|
|
57
|
+
toFileUrl,
|
|
58
|
+
dirname,
|
|
59
|
+
getCDP
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const args = DENO_RUNTIME_DETECTED ? Deno.args : process.argv.slice(2);
|
|
63
|
+
|
|
64
|
+
const stdout = {
|
|
65
|
+
write: DENO_RUNTIME_DETECTED ? data => Deno.stdout.write(data) : data => process.stdout.write(data)
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const build = {
|
|
69
|
+
os: DENO_RUNTIME_DETECTED ? Deno.build.os : process.platform
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const errors = {
|
|
73
|
+
NotFound: DENO_RUNTIME_DETECTED ? Deno.errors.NotFound : class NotFound extends Error {
|
|
74
|
+
constructor(message) {
|
|
75
|
+
super(message);
|
|
76
|
+
this.name = "NotFound";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async function initGlobalThisProperties() {
|
|
82
|
+
if (!DENO_RUNTIME_DETECTED) {
|
|
83
|
+
const { WebSocket } = await import(getNPMModule("ws"));
|
|
84
|
+
globalThis.WebSocket = WebSocket;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function readTextFile(path) {
|
|
89
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
90
|
+
return Deno.readTextFile(path);
|
|
91
|
+
} else {
|
|
92
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
93
|
+
return fsPromise.readFile(path, {
|
|
94
|
+
encoding: "utf8"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function writeTextFile(path, data, options = {}) {
|
|
100
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
101
|
+
return Deno.writeTextFile(path, data, options);
|
|
102
|
+
} else {
|
|
103
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
104
|
+
if (options.append) {
|
|
105
|
+
return fsPromise.appendFile(path, data, options);
|
|
106
|
+
} else {
|
|
107
|
+
return fsPromise.writeFile(path, data, options);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function mkdir(path, options = {}) {
|
|
113
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
114
|
+
return Deno.mkdir(path, options);
|
|
115
|
+
} else {
|
|
116
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
117
|
+
return fsPromise.mkdir(path, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function makeTempDir() {
|
|
122
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
123
|
+
return Deno.makeTempDir();
|
|
124
|
+
} else {
|
|
125
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
126
|
+
const os = await import(NODE_MODULES["os"]);
|
|
127
|
+
return fsPromise.mkdtemp(path.join(os.tmpdir()));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function stat(path) {
|
|
132
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
133
|
+
return Deno.stat(path);
|
|
134
|
+
} else {
|
|
135
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
136
|
+
return fsPromise.stat(path);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function remove(path, options = {}) {
|
|
141
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
142
|
+
return Deno.remove(path, options);
|
|
143
|
+
} else {
|
|
144
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
145
|
+
return fsPromise.rm(path, options);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function exit(code) {
|
|
150
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
151
|
+
Deno.exit(code);
|
|
152
|
+
} else {
|
|
153
|
+
process.exit(code);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const Command = DENO_RUNTIME_DETECTED ? Deno.Command : class Command {
|
|
158
|
+
constructor(path, options = {}) {
|
|
159
|
+
this.path = path;
|
|
160
|
+
this.options = options;
|
|
161
|
+
}
|
|
162
|
+
async spawn() {
|
|
163
|
+
const childProcess = await import(NODE_MODULES["child_process"]);
|
|
164
|
+
const child = childProcess.spawn(this.path, this.options.args);
|
|
165
|
+
|
|
166
|
+
await new Promise((resolve, reject) => {
|
|
167
|
+
child.on("spawn", () => resolve());
|
|
168
|
+
child.on("error", error => {
|
|
169
|
+
if (error.code == "ENOENT") {
|
|
170
|
+
reject(new errors.NotFound(error.message));
|
|
171
|
+
} else {
|
|
172
|
+
reject(error);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
status: new Promise((resolve, reject) => {
|
|
178
|
+
child.on("exit", code => {
|
|
179
|
+
if (code === 0 || code === 143) {
|
|
180
|
+
resolve();
|
|
181
|
+
} else {
|
|
182
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}),
|
|
186
|
+
kill() {
|
|
187
|
+
child.kill();
|
|
188
|
+
},
|
|
189
|
+
ref() {
|
|
190
|
+
// Do nothing
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
async function toFileUrl(filePath) {
|
|
197
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
198
|
+
return path.toFileUrl(filePath);
|
|
199
|
+
} else {
|
|
200
|
+
const url = await import(NODE_MODULES["url"]);
|
|
201
|
+
return new URL(url.pathToFileURL(filePath));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function dirname(filePath) {
|
|
206
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
207
|
+
return path.dirname(filePath);
|
|
208
|
+
} else {
|
|
209
|
+
return path.dirname(filePath);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function getCDP() {
|
|
214
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
215
|
+
return CDP;
|
|
216
|
+
} else {
|
|
217
|
+
return CDP;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function getNPMModule(module) {
|
|
222
|
+
return NPM_MODULES[module];
|
|
223
|
+
}
|
package/deno.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@single-file/single-file-cli",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "SingleFile CLI",
|
|
5
|
+
"nodeModulesDir": true,
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./single-file-cli-api.js"
|
|
8
|
+
},
|
|
9
|
+
"imports": {
|
|
10
|
+
"simple-cdp": "jsr:@simple-cdp/simple-cdp@^1.8.2",
|
|
11
|
+
"path": "jsr:@std/path@^0.220.1"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/deno.lock
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "3",
|
|
3
|
+
"packages": {
|
|
4
|
+
"specifiers": {
|
|
5
|
+
"jsr:@simple-cdp/simple-cdp@^1.8.2": "jsr:@simple-cdp/simple-cdp@1.8.2",
|
|
6
|
+
"jsr:@std/assert@^0.220.1": "jsr:@std/assert@0.220.1",
|
|
7
|
+
"jsr:@std/path@^0.220.1": "jsr:@std/path@0.220.1",
|
|
8
|
+
"npm:simple-cdp@^1.8.2": "npm:simple-cdp@1.8.2",
|
|
9
|
+
"npm:ws@^8.16.0": "npm:ws@8.16.0"
|
|
10
|
+
},
|
|
11
|
+
"jsr": {
|
|
12
|
+
"@simple-cdp/simple-cdp@1.8.2": {
|
|
13
|
+
"integrity": "171f82ef24c464c83f0ffc1148096a04fcd8256c6bb6b5454640614c53689165"
|
|
14
|
+
},
|
|
15
|
+
"@std/assert@0.220.1": {
|
|
16
|
+
"integrity": "88710d54f3afdd7a5761e7805abba1f56cd14e4b212feffeb3e73a9f77482425"
|
|
17
|
+
},
|
|
18
|
+
"@std/path@0.220.1": {
|
|
19
|
+
"integrity": "cc63c1b5e5192e2f718dc2f365a3514fffb26cc0380959bab0f8fb5988a52f0c",
|
|
20
|
+
"dependencies": [
|
|
21
|
+
"jsr:@std/assert@^0.220.1"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"npm": {
|
|
26
|
+
"simple-cdp@1.8.2": {
|
|
27
|
+
"integrity": "sha512-Ts4RpMMuJjdp+mLB2OJeJSUyTJZw3tUDc7ZWKytK6/4zSegwzKJEIqKv0Z2UgX0DPvma0eYg10MfaceM6CYQfA==",
|
|
28
|
+
"dependencies": {}
|
|
29
|
+
},
|
|
30
|
+
"ws@8.16.0": {
|
|
31
|
+
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
|
32
|
+
"dependencies": {}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"remote": {},
|
|
37
|
+
"workspace": {
|
|
38
|
+
"dependencies": [
|
|
39
|
+
"jsr:@simple-cdp/simple-cdp@^1.8.2",
|
|
40
|
+
"jsr:@std/path@^0.220.1"
|
|
41
|
+
],
|
|
42
|
+
"packageJson": {
|
|
43
|
+
"dependencies": [
|
|
44
|
+
"npm:simple-cdp@^1.8.2",
|
|
45
|
+
"npm:ws@^8.16.0"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|