single-file-cli 2.0.53 → 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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@single-file/single-file-cli",
3
- "version": "2.0.53",
3
+ "version": "2.0.54",
4
4
  "description": "SingleFile CLI",
5
5
  "nodeModulesDir": true,
6
6
  "exports": {
package/lib/cdp-client.js CHANGED
@@ -125,7 +125,6 @@ async function getPageData(options) {
125
125
  }
126
126
  alternativeUrl = alternativeUrl.href;
127
127
  let httpInfo;
128
- delete options.zipScript;
129
128
  Fetch.addEventListener("requestPaused", async ({ params }) => {
130
129
  const { requestId, request, resourceType, responseHeaders, responseStatusCode, responseStatusText } = params;
131
130
  if (options.outputJson && !httpInfo && (request.url == url || request.url == alternativeUrl) && responseStatusCode !== undefined) {
@@ -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/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "2.0.53";
1
+ export const version = "2.0.54";
package/options.js CHANGED
@@ -132,9 +132,11 @@ 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" },
139
+ "insert-single-file-comment": { description: "Insert a comment in the HTML header with the URL of the page", type: "boolean", defaultValue: true },
138
140
  };
139
141
 
140
142
  const { args, exit } = Deno;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "2.0.53",
3
+ "version": "2.0.55",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "engines": {
@@ -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);