single-file-cli 1.0.69 → 1.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "1.0.69",
3
+ "version": "1.1.1",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -26,7 +26,7 @@
26
26
  "jsdom": "22.1.0",
27
27
  "puppeteer-core": "21.2.1",
28
28
  "selenium-webdriver": "4.12.0",
29
- "single-file-core": "1.1.79",
29
+ "single-file-core": "1.2.1",
30
30
  "strong-data-uri": "1.0.6",
31
31
  "yargs": "17.7.2"
32
32
  },
@@ -44,4 +44,14 @@ export default [{
44
44
  }],
45
45
  plugins: PLUGINS,
46
46
  external: EXTERNAL
47
+ }, {
48
+ input: ["single-file-core/vendor/zip/zip.min.js"],
49
+ output: [{
50
+ file: "lib/single-file-zip.min.js",
51
+ format: "es",
52
+ plugins: []
53
+ }],
54
+ context: "this",
55
+ plugins: PLUGINS,
56
+ external: EXTERNAL
47
57
  }];
package/rollup.config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* global require */
2
2
 
3
+ const resolve = require("@rollup/plugin-node-resolve");
3
4
  const { terser } = require("rollup-plugin-terser");
4
- const resolve= require("@rollup/plugin-node-resolve");
5
5
 
6
6
  const PLUGINS = [resolve({ moduleDirectories: ["node_modules"] })];
7
7
  const EXTERNAL = ["single-file-core"];
@@ -45,4 +45,14 @@ export default [{
45
45
  }],
46
46
  plugins: PLUGINS,
47
47
  external: EXTERNAL
48
+ }, {
49
+ input: ["single-file-core/vendor/zip/zip.min.js"],
50
+ output: [{
51
+ file: "lib/single-file-zip.min.js",
52
+ format: "es",
53
+ plugins: [terser()]
54
+ }],
55
+ context: "this",
56
+ plugins: PLUGINS,
57
+ external: EXTERNAL
48
58
  }];
@@ -21,7 +21,7 @@
21
21
  * Source.
22
22
  */
23
23
 
24
- /* global require, exports, URL */
24
+ /* global require, exports, URL, process */
25
25
 
26
26
  const fs = require("fs");
27
27
  const path = require("path");
@@ -62,6 +62,7 @@ const DEFAULT_OPTIONS = {
62
62
  includeBOM: false,
63
63
  insertMetaCSP: true,
64
64
  insertMetaNoIndex: false,
65
+ password: "",
65
66
  insertSingleFileComment: true,
66
67
  blockImages: false,
67
68
  blockStylesheets: false,
@@ -129,7 +130,7 @@ async function capture(urls, options) {
129
130
  async function finish(options) {
130
131
  const promiseTasks = tasks.map(task => task.promise);
131
132
  await Promise.all(promiseTasks);
132
- if (options.crawlReplaceURLs) {
133
+ if (options.crawlReplaceURLs && !options.compressContent) {
133
134
  tasks.forEach(task => {
134
135
  try {
135
136
  let pageContent = fs.readFileSync(task.filename).toString();
@@ -251,11 +252,16 @@ function getHostURL(url) {
251
252
  async function capturePage(options) {
252
253
  try {
253
254
  let filename;
255
+ options.zipScript = fs.readFileSync(require.resolve("./lib/single-file-zip.min.js")).toString();
254
256
  const pageData = await backend.getPageData(options);
255
257
  if (options.output) {
256
258
  filename = getFilename(options.output, options);
257
259
  } else if (options.dumpContent) {
258
- console.log(pageData.content); // eslint-disable-line no-console
260
+ if (options.compressContent) {
261
+ await new Promise(resolve => process.stdout.write(pageData.content, resolve));
262
+ } else {
263
+ console.log(pageData.content); // eslint-disable-line no-console
264
+ }
259
265
  } else {
260
266
  filename = getFilename(pageData.filename, options);
261
267
  }