single-file-core 1.1.76 → 1.1.78

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.
Files changed (37) hide show
  1. package/.eslintrc.js +0 -0
  2. package/LICENSE +0 -0
  3. package/core/constants.js +13 -0
  4. package/core/helper.js +604 -596
  5. package/core/index.js +2234 -2231
  6. package/core/infobar.js +276 -272
  7. package/core/util.js +408 -407
  8. package/modules/css-fonts-alt-minifier.js +342 -342
  9. package/modules/css-fonts-minifier.js +376 -376
  10. package/modules/css-matched-rules.js +0 -0
  11. package/modules/css-medias-alt-minifier.js +90 -90
  12. package/modules/css-rules-minifier.js +0 -0
  13. package/modules/html-images-alt-minifier.js +0 -0
  14. package/modules/html-minifier.js +0 -0
  15. package/modules/html-serializer.js +0 -0
  16. package/modules/index.js +0 -0
  17. package/modules/template-formatter.js +0 -0
  18. package/package.json +18 -18
  19. package/processors/frame-tree/content/content-frame-tree.js +426 -424
  20. package/processors/hooks/content/content-hooks-frames-web.js +0 -0
  21. package/processors/hooks/content/content-hooks-frames.js +0 -0
  22. package/processors/index.js +0 -0
  23. package/processors/lazy/content/content-lazy-loader.js +233 -233
  24. package/single-file-bootstrap.js +55 -55
  25. package/single-file-editor-helper.js +49 -49
  26. package/single-file-frames.js +0 -0
  27. package/single-file-hooks-frames.js +0 -0
  28. package/single-file-infobar.js +62 -62
  29. package/single-file.js +101 -101
  30. package/vendor/css-font-property-parser.js +0 -0
  31. package/vendor/css-media-query-parser.js +0 -0
  32. package/vendor/css-minifier.js +0 -0
  33. package/vendor/css-tree.js +0 -0
  34. package/vendor/css-unescape.js +0 -0
  35. package/vendor/html-srcset-parser.js +0 -0
  36. package/vendor/index.js +0 -0
  37. package/vendor/mime-type-parser.js +0 -0
@@ -1,50 +1,50 @@
1
- /*
2
- * Copyright 2010-2020 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
- import * as serializer from "./modules/html-serializer.js";
25
- import * as infobar from "./core/infobar.js";
26
- import { getInstance } from "./core/util.js";
27
-
28
- const util = getInstance();
29
- const helper = {
30
- serialize(doc, compressHTML) {
31
- return serializer.process(doc, compressHTML);
32
- },
33
- getDoctypeString(doc) {
34
- return util.getDoctypeString(doc);
35
- },
36
- appendInfobar(doc, options, useShadowRoot) {
37
- return infobar.appendInfobar(doc, options, useShadowRoot);
38
- },
39
- extractInfobarData(doc) {
40
- return infobar.extractInfobarData(doc);
41
- },
42
- displayIcon(doc, useShadowRoot) {
43
- return infobar.displayIcon(doc, useShadowRoot);
44
- },
45
- INFOBAR_TAGNAME: infobar.INFOBAR_TAGNAME
46
- };
47
-
48
- export {
49
- helper
1
+ /*
2
+ * Copyright 2010-2020 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
+ import * as serializer from "./modules/html-serializer.js";
25
+ import * as infobar from "./core/infobar.js";
26
+ import { getInstance } from "./core/util.js";
27
+
28
+ const util = getInstance();
29
+ const helper = {
30
+ serialize(doc, compressHTML) {
31
+ return serializer.process(doc, compressHTML);
32
+ },
33
+ getDoctypeString(doc) {
34
+ return util.getDoctypeString(doc);
35
+ },
36
+ appendInfobar(doc, options, useShadowRoot) {
37
+ return infobar.appendInfobar(doc, options, useShadowRoot);
38
+ },
39
+ extractInfobarData(doc) {
40
+ return infobar.extractInfobarData(doc);
41
+ },
42
+ displayIcon(doc, useShadowRoot) {
43
+ return infobar.displayIcon(doc, useShadowRoot);
44
+ },
45
+ INFOBAR_TAGNAME: infobar.INFOBAR_TAGNAME
46
+ };
47
+
48
+ export {
49
+ helper
50
50
  };
File without changes
File without changes
@@ -1,63 +1,63 @@
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 "./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, infoData, true);
58
- refreshInfobarInfo(document, infoData);
59
- }
60
- }
61
- }
62
-
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 "./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, infoData, true);
58
+ refreshInfobarInfo(document, infoData);
59
+ }
60
+ }
61
+ }
62
+
63
63
  })(typeof globalThis == "object" ? globalThis : window);
package/single-file.js CHANGED
@@ -1,102 +1,102 @@
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 */
25
-
26
- import * as processors from "./processors/index.js";
27
- import * as vendor from "./vendor/index.js";
28
- import * as modules from "./modules/index.js";
29
- import * as core from "./core/index.js";
30
- import * as helper from "./core/helper.js";
31
- import * as util from "./core/util.js";
32
-
33
- let SingleFile;
34
-
35
- export {
36
- init,
37
- getPageData,
38
- processors,
39
- vendor,
40
- modules,
41
- helper,
42
- SingleFile
43
- };
44
-
45
- function init(initOptions) {
46
- if (typeof SingleFile == "undefined") {
47
- SingleFile = core.getClass(util.getInstance(initOptions), vendor.cssTree);
48
- }
49
- }
50
-
51
- async function getPageData(options = {}, initOptions, doc = globalThis.document, win = globalThis) {
52
- const frames = processors.frameTree;
53
- let framesSessionId;
54
- init(initOptions);
55
- if (doc && win) {
56
- helper.initDoc(doc);
57
- const preInitializationPromises = [];
58
- if (!options.saveRawPage) {
59
- let lazyLoadPromise;
60
- if (options.loadDeferredImages) {
61
- lazyLoadPromise = processors.lazy.process(options);
62
- if (options.loadDeferredImagesBeforeFrames) {
63
- await lazyLoadPromise;
64
- }
65
- }
66
- if (!options.removeFrames && frames && globalThis.frames) {
67
- let frameTreePromise;
68
- if (options.loadDeferredImages) {
69
- frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames || !options.loadDeferredImages ? 0 : options.loadDeferredImagesMaxIdleTime));
70
- } else {
71
- frameTreePromise = frames.getAsync(options);
72
- }
73
- if (options.loadDeferredImagesBeforeFrames) {
74
- options.frames = await frameTreePromise;
75
- } else {
76
- preInitializationPromises.push(frameTreePromise);
77
- }
78
- }
79
- if (options.loadDeferredImages && !options.loadDeferredImagesBeforeFrames) {
80
- preInitializationPromises.push(lazyLoadPromise);
81
- }
82
- }
83
- if (!options.loadDeferredImagesBeforeFrames) {
84
- [options.frames] = await Promise.all(preInitializationPromises);
85
- }
86
- framesSessionId = options.frames && options.frames.sessionId;
87
- }
88
- options.doc = doc;
89
- options.win = win;
90
- options.insertCanonicalLink = true;
91
- options.onprogress = event => {
92
- if (event.type === event.RESOURCES_INITIALIZED && doc && win && options.loadDeferredImages) {
93
- processors.lazy.resetZoomLevel(options);
94
- }
95
- };
96
- const processor = new SingleFile(options);
97
- await processor.run();
98
- if (framesSessionId) {
99
- frames.cleanup(framesSessionId);
100
- }
101
- return await processor.getPageData();
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 */
25
+
26
+ import * as processors from "./processors/index.js";
27
+ import * as vendor from "./vendor/index.js";
28
+ import * as modules from "./modules/index.js";
29
+ import * as core from "./core/index.js";
30
+ import * as helper from "./core/helper.js";
31
+ import * as util from "./core/util.js";
32
+
33
+ let SingleFile;
34
+
35
+ export {
36
+ init,
37
+ getPageData,
38
+ processors,
39
+ vendor,
40
+ modules,
41
+ helper,
42
+ SingleFile
43
+ };
44
+
45
+ function init(initOptions) {
46
+ if (typeof SingleFile == "undefined") {
47
+ SingleFile = core.getClass(util.getInstance(initOptions), vendor.cssTree);
48
+ }
49
+ }
50
+
51
+ async function getPageData(options = {}, initOptions, doc = globalThis.document, win = globalThis) {
52
+ const frames = processors.frameTree;
53
+ let framesSessionId;
54
+ init(initOptions);
55
+ if (doc && win) {
56
+ helper.initDoc(doc);
57
+ const preInitializationPromises = [];
58
+ if (!options.saveRawPage) {
59
+ let lazyLoadPromise;
60
+ if (options.loadDeferredImages) {
61
+ lazyLoadPromise = processors.lazy.process(options);
62
+ if (options.loadDeferredImagesBeforeFrames) {
63
+ await lazyLoadPromise;
64
+ }
65
+ }
66
+ if (!options.removeFrames && frames && globalThis.frames) {
67
+ let frameTreePromise;
68
+ if (options.loadDeferredImages) {
69
+ frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames || !options.loadDeferredImages ? 0 : options.loadDeferredImagesMaxIdleTime));
70
+ } else {
71
+ frameTreePromise = frames.getAsync(options);
72
+ }
73
+ if (options.loadDeferredImagesBeforeFrames) {
74
+ options.frames = await frameTreePromise;
75
+ } else {
76
+ preInitializationPromises.push(frameTreePromise);
77
+ }
78
+ }
79
+ if (options.loadDeferredImages && !options.loadDeferredImagesBeforeFrames) {
80
+ preInitializationPromises.push(lazyLoadPromise);
81
+ }
82
+ }
83
+ if (!options.loadDeferredImagesBeforeFrames) {
84
+ [options.frames] = await Promise.all(preInitializationPromises);
85
+ }
86
+ framesSessionId = options.frames && options.frames.sessionId;
87
+ }
88
+ options.doc = doc;
89
+ options.win = win;
90
+ options.insertCanonicalLink = true;
91
+ options.onprogress = event => {
92
+ if (event.type === event.RESOURCES_INITIALIZED && doc && win && options.loadDeferredImages) {
93
+ processors.lazy.resetZoomLevel(options);
94
+ }
95
+ };
96
+ const processor = new SingleFile(options);
97
+ await processor.run();
98
+ if (framesSessionId) {
99
+ frames.cleanup(framesSessionId);
100
+ }
101
+ return await processor.getPageData();
102
102
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/vendor/index.js CHANGED
File without changes
File without changes