single-file-cli 2.0.54 → 2.0.55
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/lib/deno-polyfill.js +10 -0
- package/options.js +1 -0
- package/package.json +1 -1
- package/single-file-launcher.js +4 -1
package/lib/deno-polyfill.js
CHANGED
|
@@ -100,6 +100,7 @@ const Command = DENO_RUNTIME_DETECTED ? Deno.Command : class Command {
|
|
|
100
100
|
|
|
101
101
|
const DenoAPI = {
|
|
102
102
|
args,
|
|
103
|
+
readFile,
|
|
103
104
|
readTextFile,
|
|
104
105
|
writeTextFile,
|
|
105
106
|
writeFile,
|
|
@@ -133,6 +134,15 @@ async function initGlobalThisProperties() {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
async function readFile(path) {
|
|
138
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
139
|
+
return Deno.readFile(path);
|
|
140
|
+
} else {
|
|
141
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
142
|
+
return new Uint8Array(await fsPromise.readFile(path));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
136
146
|
async function readTextFile(path) {
|
|
137
147
|
if (DENO_RUNTIME_DETECTED) {
|
|
138
148
|
return Deno.readTextFile(path);
|
package/options.js
CHANGED
|
@@ -132,6 +132,7 @@ const OPTIONS_INFO = {
|
|
|
132
132
|
"extract-data-from-page": { description: "Extract compressed data from the page instead of fetching the page in order to create universal self-extracting HTML files", type: "boolean", defaultValue: true },
|
|
133
133
|
"prevent-appended-data": { description: "Prevent appending data after the compressed data when creating self-extracting HTML files", type: "boolean" },
|
|
134
134
|
"embed-screenshot": { description: "Embed a screenshot of the page as a PNG file in the compressed file (self-extracting HTML or ZIP file). When enabled, the resulting file can be read as a ZIP file or a PNG image.", type: "boolean" },
|
|
135
|
+
"embedded-image": { description: "Path to a PNG image to embed in the compressed file.", type: "string" },
|
|
135
136
|
"output-directory": { description: "Path to where to save files, this path must exist.", type: "string" },
|
|
136
137
|
"version": { description: "Print the version number and exit.", type: "boolean" },
|
|
137
138
|
"output-json": { description: "Output the result as a JSON string containing the page and network info", type: "boolean" },
|
package/package.json
CHANGED
package/single-file-launcher.js
CHANGED
|
@@ -26,7 +26,7 @@ import { closeBrowser } from "./lib/browser.js";
|
|
|
26
26
|
import { Deno } from "./lib/deno-polyfill.js";
|
|
27
27
|
import options from "./options.js";
|
|
28
28
|
|
|
29
|
-
const { readTextFile, exit, addSignalListener } = Deno;
|
|
29
|
+
const { readTextFile, readFile, exit, addSignalListener } = Deno;
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
32
|
addSignalListener("SIGTERM", closeBrowserAndExit);
|
|
@@ -83,6 +83,9 @@ async function run() {
|
|
|
83
83
|
}
|
|
84
84
|
options.httpHeaders = headers;
|
|
85
85
|
}
|
|
86
|
+
if (options.embeddedImage) {
|
|
87
|
+
options.embeddedImage = Array.from(await readFile(options.embeddedImage));
|
|
88
|
+
}
|
|
86
89
|
options.retrieveLinks = true;
|
|
87
90
|
const singlefile = await initialize(options);
|
|
88
91
|
await singlefile.capture(urls);
|