single-file-core 1.0.71 → 1.1.73
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/{single-file-core.js → core/single-file-core.js} +15 -15
- package/{single-file-helper.js → core/single-file-helper.js} +3 -3
- package/{single-file-util.js → core/single-file-util.js} +2 -2
- package/modules/css-fonts-alt-minifier.js +1 -1
- package/modules/css-fonts-minifier.js +1 -1
- package/modules/css-medias-alt-minifier.js +1 -1
- package/package.json +1 -1
- package/processors/frame-tree/content/content-frame-tree.js +1 -1
- package/processors/lazy/content/content-lazy-loader.js +1 -1
- package/single-file-bootstrap.js +1 -1
- package/{single-file-mini-helper.js → single-file-editor-helper.js} +2 -2
- package/single-file-infobar.js +40 -1
- package/single-file.js +5 -4
- package/common/content-infobar-web.js +0 -63
- /package/{common → core}/infobar.js +0 -0
|
@@ -34,6 +34,10 @@ const Image = globalThis.Image;
|
|
|
34
34
|
|
|
35
35
|
let util, cssTree;
|
|
36
36
|
|
|
37
|
+
export {
|
|
38
|
+
getClass
|
|
39
|
+
};
|
|
40
|
+
|
|
37
41
|
function getClass(...args) {
|
|
38
42
|
[util, cssTree] = args;
|
|
39
43
|
return SingleFileClass;
|
|
@@ -489,9 +493,9 @@ class Processor {
|
|
|
489
493
|
}
|
|
490
494
|
const infobarContent = (this.options.infobarContent || "").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
|
|
491
495
|
const commentNode = this.doc.createComment(
|
|
492
|
-
"\n " + (this.options.useLegacyCommentHeader ? util.COMMENT_HEADER_LEGACY : util.COMMENT_HEADER) +
|
|
493
|
-
" \n url: " + infobarURL +
|
|
494
|
-
(this.options.removeSavedDate ? " " : " \n saved date: " + infobarSaveDate) +
|
|
496
|
+
"\n " + (this.options.useLegacyCommentHeader ? util.COMMENT_HEADER_LEGACY : util.COMMENT_HEADER) +
|
|
497
|
+
" \n url: " + infobarURL +
|
|
498
|
+
(this.options.removeSavedDate ? " " : " \n saved date: " + infobarSaveDate) +
|
|
495
499
|
(infobarContent ? " \n info: " + infobarContent : "") + "\n"
|
|
496
500
|
);
|
|
497
501
|
this.doc.documentElement.insertBefore(commentNode, this.doc.documentElement.firstChild);
|
|
@@ -583,7 +587,7 @@ class Processor {
|
|
|
583
587
|
const imageData = this.options.images[Number(attributeValue)];
|
|
584
588
|
if (imageData) {
|
|
585
589
|
if (this.options.removeHiddenElements && (
|
|
586
|
-
(imageData.size && !imageData.size.pxWidth && !imageData.size.pxHeight) ||
|
|
590
|
+
(imageData.size && !imageData.size.pxWidth && !imageData.size.pxHeight) ||
|
|
587
591
|
imgElement.getAttribute(util.HIDDEN_CONTENT_ATTRIBUTE_NAME) == "")
|
|
588
592
|
) {
|
|
589
593
|
imgElement.setAttribute("src", util.EMPTY_RESOURCE);
|
|
@@ -626,7 +630,7 @@ class Processor {
|
|
|
626
630
|
}
|
|
627
631
|
});
|
|
628
632
|
}
|
|
629
|
-
if (this.options.adoptedStyleSheets.length) {
|
|
633
|
+
if (this.options.adoptedStyleSheets && this.options.adoptedStyleSheets.length) {
|
|
630
634
|
const styleElement = this.doc.createElement("style");
|
|
631
635
|
styleElement.textContent = this.options.adoptedStyleSheets.join("\n");
|
|
632
636
|
this.doc.body.appendChild(styleElement);
|
|
@@ -1194,7 +1198,7 @@ class Processor {
|
|
|
1194
1198
|
if (shadowRootData) {
|
|
1195
1199
|
const templateElement = doc.createElement("template");
|
|
1196
1200
|
templateElement.setAttribute(SHADOWROOT_ATTRIBUTE_NAME, shadowRootData.mode);
|
|
1197
|
-
if (shadowRootData.adoptedStyleSheets) {
|
|
1201
|
+
if (shadowRootData.adoptedStyleSheets && shadowRootData.adoptedStyleSheets.length) {
|
|
1198
1202
|
shadowRootData.adoptedStyleSheets.forEach(stylesheetContent => {
|
|
1199
1203
|
const styleElement = doc.createElement("style");
|
|
1200
1204
|
styleElement.textContent = stylesheetContent;
|
|
@@ -1245,13 +1249,13 @@ class Processor {
|
|
|
1245
1249
|
|
|
1246
1250
|
async processStylesheets() {
|
|
1247
1251
|
this.options.fontDeclarations = new Map();
|
|
1248
|
-
await Promise.all([...this.stylesheets].map(([, stylesheetInfo]) =>
|
|
1252
|
+
await Promise.all([...this.stylesheets].map(([, stylesheetInfo]) =>
|
|
1249
1253
|
ProcessorHelper.processStylesheet(stylesheetInfo.stylesheet.children, this.baseURI, this.options, this.cssVariables, this.batchRequest)
|
|
1250
1254
|
));
|
|
1251
1255
|
}
|
|
1252
1256
|
|
|
1253
1257
|
async processStyleAttributes() {
|
|
1254
|
-
return Promise.all([...this.styles].map(([, stylesheet]) =>
|
|
1258
|
+
return Promise.all([...this.styles].map(([, stylesheet]) =>
|
|
1255
1259
|
ProcessorHelper.processStyle(stylesheet, this.baseURI, this.options, this.cssVariables, this.batchRequest)
|
|
1256
1260
|
));
|
|
1257
1261
|
}
|
|
@@ -1854,7 +1858,7 @@ class ProcessorHelper {
|
|
|
1854
1858
|
}
|
|
1855
1859
|
if (testValidURL(resourceURL)) {
|
|
1856
1860
|
let { content, indexResource, duplicate } = await batchRequest.addURL(
|
|
1857
|
-
resourceURL,
|
|
1861
|
+
resourceURL,
|
|
1858
1862
|
{ asBinary: true, expectedType, groupDuplicates: options.groupDuplicateImages && resourceElement.tagName.toUpperCase() == "IMG" && attributeName == "src" });
|
|
1859
1863
|
if (originURL) {
|
|
1860
1864
|
if (content == util.EMPTY_RESOURCE) {
|
|
@@ -1894,7 +1898,7 @@ class ProcessorHelper {
|
|
|
1894
1898
|
image.src = content;
|
|
1895
1899
|
image.onload = () => cleanupAndResolve();
|
|
1896
1900
|
image.onerror = () => cleanupAndResolve(true);
|
|
1897
|
-
|
|
1901
|
+
|
|
1898
1902
|
function cleanupAndResolve(value) {
|
|
1899
1903
|
clearTimeout(timeoutId);
|
|
1900
1904
|
resolve(value);
|
|
@@ -2225,8 +2229,4 @@ class Stats {
|
|
|
2225
2229
|
Object.keys(this.data.processed).forEach(key => this.add("processed", key, pageData.stats.processed[key] || 0));
|
|
2226
2230
|
}
|
|
2227
2231
|
}
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
export {
|
|
2231
|
-
getClass
|
|
2232
|
-
};
|
|
2232
|
+
}
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
/* global globalThis, CustomEvent */
|
|
25
25
|
|
|
26
|
-
import * as cssUnescape from "
|
|
27
|
-
import * as hooksFrames from "
|
|
28
|
-
import * as infobar from "./
|
|
26
|
+
import * as cssUnescape from "./../vendor/css-unescape.js";
|
|
27
|
+
import * as hooksFrames from "./../processors/hooks/content/content-hooks-frames.js";
|
|
28
|
+
import * as infobar from "./infobar.js";
|
|
29
29
|
|
|
30
30
|
const ON_BEFORE_CAPTURE_EVENT_NAME = "single-file-on-before-capture";
|
|
31
31
|
const ON_AFTER_CAPTURE_EVENT_NAME = "single-file-on-after-capture";
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
/* global globalThis, URLSearchParams */
|
|
25
25
|
|
|
26
|
-
import * as vendor from "
|
|
27
|
-
import * as modules from "
|
|
26
|
+
import * as vendor from "./../vendor/index.js";
|
|
27
|
+
import * as modules from "./../modules/index.js";
|
|
28
28
|
import * as helper from "./single-file-helper.js";
|
|
29
29
|
|
|
30
30
|
const DEBUG = false;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import * as cssTree from "./../vendor/css-tree.js";
|
|
25
25
|
import * as mediaQueryParser from "./../vendor/css-media-query-parser.js";
|
|
26
|
-
import { flatten } from "./../single-file-helper.js";
|
|
26
|
+
import { flatten } from "./../core/single-file-helper.js";
|
|
27
27
|
|
|
28
28
|
const helper = {
|
|
29
29
|
flatten
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import * as hooksFrames from "./../../hooks/content/content-hooks-frames.js";
|
|
|
27
27
|
import {
|
|
28
28
|
LAZY_SRC_ATTRIBUTE_NAME,
|
|
29
29
|
SINGLE_FILE_UI_ELEMENT_CLASS
|
|
30
|
-
} from "./../../../single-file-helper.js";
|
|
30
|
+
} from "./../../../core/single-file-helper.js";
|
|
31
31
|
const helper = {
|
|
32
32
|
LAZY_SRC_ATTRIBUTE_NAME,
|
|
33
33
|
SINGLE_FILE_UI_ELEMENT_CLASS
|
package/single-file-bootstrap.js
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import * as serializer from "./modules/html-serializer.js";
|
|
25
|
-
import * as infobar from "./
|
|
26
|
-
import { getInstance } from "./single-file-util.js";
|
|
25
|
+
import * as infobar from "./core/infobar.js";
|
|
26
|
+
import { getInstance } from "./core/single-file-util.js";
|
|
27
27
|
|
|
28
28
|
const util = getInstance();
|
|
29
29
|
const helper = {
|
package/single-file-infobar.js
CHANGED
|
@@ -21,4 +21,43 @@
|
|
|
21
21
|
* Source.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/* global globalThis, window, document */
|
|
25
|
+
|
|
26
|
+
import { appendInfobar, refreshInfobarInfo, extractInfobarData } from "./core/infobar.js";
|
|
27
|
+
|
|
28
|
+
(globalThis => {
|
|
29
|
+
|
|
30
|
+
const browser = globalThis.browser;
|
|
31
|
+
|
|
32
|
+
if (globalThis.window == globalThis.top) {
|
|
33
|
+
if (document.readyState == "loading") {
|
|
34
|
+
document.addEventListener("DOMContentLoaded", displayIcon, false);
|
|
35
|
+
} else {
|
|
36
|
+
displayIcon();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (globalThis.singlefile) {
|
|
40
|
+
globalThis.singlefile.infobar = {
|
|
41
|
+
displayIcon
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function displayIcon() {
|
|
46
|
+
let options = { displayInfobar: true };
|
|
47
|
+
const infoData = extractInfobarData(document);
|
|
48
|
+
if (infoData && infoData.saveUrl) {
|
|
49
|
+
if (browser && browser.runtime && browser.runtime.sendMessage) {
|
|
50
|
+
try {
|
|
51
|
+
options = await browser.runtime.sendMessage({ method: "tabs.getOptions", url: infoData.saveUrl });
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// ignored
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (options.displayInfobar) {
|
|
57
|
+
appendInfobar(document, options, true);
|
|
58
|
+
refreshInfobarInfo(document, infoData);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
})(typeof globalThis == "object" ? globalThis : window);
|
package/single-file.js
CHANGED
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
import * as processors from "./processors/index.js";
|
|
27
27
|
import * as vendor from "./vendor/index.js";
|
|
28
28
|
import * as modules from "./modules/index.js";
|
|
29
|
-
import * as core from "./single-file-core.js";
|
|
30
|
-
import * as helper from "./single-file-helper.js";
|
|
31
|
-
import * as util from "./single-file-util.js";
|
|
29
|
+
import * as core from "./core/single-file-core.js";
|
|
30
|
+
import * as helper from "./core/single-file-helper.js";
|
|
31
|
+
import * as util from "./core/single-file-util.js";
|
|
32
32
|
|
|
33
33
|
let SingleFile;
|
|
34
|
+
|
|
34
35
|
export {
|
|
35
36
|
init,
|
|
36
37
|
getPageData,
|
|
@@ -65,7 +66,7 @@ async function getPageData(options = {}, initOptions, doc = globalThis.document,
|
|
|
65
66
|
if (!options.removeFrames && frames && globalThis.frames) {
|
|
66
67
|
let frameTreePromise;
|
|
67
68
|
if (options.loadDeferredImages) {
|
|
68
|
-
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime));
|
|
69
|
+
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames || !options.loadDeferredImages ? 0 : options.loadDeferredImagesMaxIdleTime));
|
|
69
70
|
} else {
|
|
70
71
|
frameTreePromise = frames.getAsync(options);
|
|
71
72
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2010-2022 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, window, document */
|
|
25
|
-
|
|
26
|
-
import { appendInfobar, refreshInfobarInfo, extractInfobarData } from "./infobar.js";
|
|
27
|
-
|
|
28
|
-
(globalThis => {
|
|
29
|
-
|
|
30
|
-
const browser = globalThis.browser;
|
|
31
|
-
|
|
32
|
-
if (globalThis.window == globalThis.top) {
|
|
33
|
-
if (document.readyState == "loading") {
|
|
34
|
-
document.addEventListener("DOMContentLoaded", displayIcon, false);
|
|
35
|
-
} else {
|
|
36
|
-
displayIcon();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (globalThis.singlefile) {
|
|
40
|
-
globalThis.singlefile.infobar = {
|
|
41
|
-
displayIcon
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function displayIcon() {
|
|
46
|
-
let options = { displayInfobar: true };
|
|
47
|
-
const infoData = extractInfobarData(document);
|
|
48
|
-
if (infoData && infoData.saveUrl) {
|
|
49
|
-
if (browser && browser.runtime && browser.runtime.sendMessage) {
|
|
50
|
-
try {
|
|
51
|
-
options = await browser.runtime.sendMessage({ method: "tabs.getOptions", url: infoData.saveUrl });
|
|
52
|
-
} catch (error) {
|
|
53
|
-
// ignored
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (options.displayInfobar) {
|
|
57
|
-
appendInfobar(document, options, true);
|
|
58
|
-
refreshInfobarInfo(document, infoData);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
})(typeof globalThis == "object" ? globalThis : window);
|
|
File without changes
|