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.
- package/.eslintrc.js +0 -0
- package/LICENSE +0 -0
- package/core/constants.js +13 -0
- package/core/helper.js +604 -596
- package/core/index.js +2234 -2231
- package/core/infobar.js +276 -272
- package/core/util.js +408 -407
- package/modules/css-fonts-alt-minifier.js +342 -342
- package/modules/css-fonts-minifier.js +376 -376
- package/modules/css-matched-rules.js +0 -0
- package/modules/css-medias-alt-minifier.js +90 -90
- package/modules/css-rules-minifier.js +0 -0
- package/modules/html-images-alt-minifier.js +0 -0
- package/modules/html-minifier.js +0 -0
- package/modules/html-serializer.js +0 -0
- package/modules/index.js +0 -0
- package/modules/template-formatter.js +0 -0
- package/package.json +18 -18
- package/processors/frame-tree/content/content-frame-tree.js +426 -424
- package/processors/hooks/content/content-hooks-frames-web.js +0 -0
- package/processors/hooks/content/content-hooks-frames.js +0 -0
- package/processors/index.js +0 -0
- package/processors/lazy/content/content-lazy-loader.js +233 -233
- package/single-file-bootstrap.js +55 -55
- package/single-file-editor-helper.js +49 -49
- package/single-file-frames.js +0 -0
- package/single-file-hooks-frames.js +0 -0
- package/single-file-infobar.js +62 -62
- package/single-file.js +101 -101
- package/vendor/css-font-property-parser.js +0 -0
- package/vendor/css-media-query-parser.js +0 -0
- package/vendor/css-minifier.js +0 -0
- package/vendor/css-tree.js +0 -0
- package/vendor/css-unescape.js +0 -0
- package/vendor/html-srcset-parser.js +0 -0
- package/vendor/index.js +0 -0
- package/vendor/mime-type-parser.js +0 -0
|
File without changes
|
|
@@ -1,91 +1,91 @@
|
|
|
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
|
-
import * as cssTree from "./../vendor/css-tree.js";
|
|
25
|
-
import * as mediaQueryParser from "./../vendor/css-media-query-parser.js";
|
|
26
|
-
import { flatten } from "./../core/helper.js";
|
|
27
|
-
|
|
28
|
-
const helper = {
|
|
29
|
-
flatten
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const MEDIA_ALL = "all";
|
|
33
|
-
const MEDIA_SCREEN = "screen";
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
process
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function process(stylesheets) {
|
|
40
|
-
const stats = { processed: 0, discarded: 0 };
|
|
41
|
-
stylesheets.forEach((stylesheetInfo, element) => {
|
|
42
|
-
if (matchesMediaType(stylesheetInfo.mediaText || MEDIA_ALL, MEDIA_SCREEN) && stylesheetInfo.stylesheet.children) {
|
|
43
|
-
const removedRules = processRules(stylesheetInfo.stylesheet.children, stats);
|
|
44
|
-
removedRules.forEach(({ cssRules, cssRule }) => cssRules.remove(cssRule));
|
|
45
|
-
} else {
|
|
46
|
-
stylesheets.delete(element);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return stats;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function processRules(cssRules, stats, removedRules = []) {
|
|
53
|
-
for (let cssRule = cssRules.head; cssRule; cssRule = cssRule.next) {
|
|
54
|
-
const ruleData = cssRule.data;
|
|
55
|
-
if (ruleData.type == "Atrule" && ruleData.name == "media" && ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
|
|
56
|
-
stats.processed++;
|
|
57
|
-
if (matchesMediaType(cssTree.generate(ruleData.prelude), MEDIA_SCREEN)) {
|
|
58
|
-
processRules(ruleData.block.children, stats, removedRules);
|
|
59
|
-
} else {
|
|
60
|
-
removedRules.push({ cssRules, cssRule });
|
|
61
|
-
stats.discarded++;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return removedRules;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function matchesMediaType(mediaText, mediaType) {
|
|
69
|
-
const foundMediaTypes = helper.flatten(mediaQueryParser.parseMediaList(mediaText).map(node => getMediaTypes(node, mediaType)));
|
|
70
|
-
return foundMediaTypes.find(mediaTypeInfo => (!mediaTypeInfo.not && (mediaTypeInfo.value == mediaType || mediaTypeInfo.value == MEDIA_ALL))
|
|
71
|
-
|| (mediaTypeInfo.not && (mediaTypeInfo.value == MEDIA_ALL || mediaTypeInfo.value != mediaType)));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getMediaTypes(parentNode, mediaType, mediaTypes = []) {
|
|
75
|
-
parentNode.nodes.map((node, indexNode) => {
|
|
76
|
-
if (node.type == "media-query") {
|
|
77
|
-
return getMediaTypes(node, mediaType, mediaTypes);
|
|
78
|
-
} else {
|
|
79
|
-
if (node.type == "media-type") {
|
|
80
|
-
const nodeMediaType = { not: Boolean(indexNode && parentNode.nodes[0].type == "keyword" && parentNode.nodes[0].value == "not"), value: node.value };
|
|
81
|
-
if (!mediaTypes.find(mediaType => nodeMediaType.not == mediaType.not && nodeMediaType.value == mediaType.value)) {
|
|
82
|
-
mediaTypes.push(nodeMediaType);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
if (!mediaTypes.length) {
|
|
88
|
-
mediaTypes.push({ not: false, value: MEDIA_ALL });
|
|
89
|
-
}
|
|
90
|
-
return mediaTypes;
|
|
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
|
+
import * as cssTree from "./../vendor/css-tree.js";
|
|
25
|
+
import * as mediaQueryParser from "./../vendor/css-media-query-parser.js";
|
|
26
|
+
import { flatten } from "./../core/helper.js";
|
|
27
|
+
|
|
28
|
+
const helper = {
|
|
29
|
+
flatten
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const MEDIA_ALL = "all";
|
|
33
|
+
const MEDIA_SCREEN = "screen";
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
process
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function process(stylesheets) {
|
|
40
|
+
const stats = { processed: 0, discarded: 0 };
|
|
41
|
+
stylesheets.forEach((stylesheetInfo, element) => {
|
|
42
|
+
if (matchesMediaType(stylesheetInfo.mediaText || MEDIA_ALL, MEDIA_SCREEN) && stylesheetInfo.stylesheet.children) {
|
|
43
|
+
const removedRules = processRules(stylesheetInfo.stylesheet.children, stats);
|
|
44
|
+
removedRules.forEach(({ cssRules, cssRule }) => cssRules.remove(cssRule));
|
|
45
|
+
} else {
|
|
46
|
+
stylesheets.delete(element);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return stats;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function processRules(cssRules, stats, removedRules = []) {
|
|
53
|
+
for (let cssRule = cssRules.head; cssRule; cssRule = cssRule.next) {
|
|
54
|
+
const ruleData = cssRule.data;
|
|
55
|
+
if (ruleData.type == "Atrule" && ruleData.name == "media" && ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
|
|
56
|
+
stats.processed++;
|
|
57
|
+
if (matchesMediaType(cssTree.generate(ruleData.prelude), MEDIA_SCREEN)) {
|
|
58
|
+
processRules(ruleData.block.children, stats, removedRules);
|
|
59
|
+
} else {
|
|
60
|
+
removedRules.push({ cssRules, cssRule });
|
|
61
|
+
stats.discarded++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return removedRules;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function matchesMediaType(mediaText, mediaType) {
|
|
69
|
+
const foundMediaTypes = helper.flatten(mediaQueryParser.parseMediaList(mediaText).map(node => getMediaTypes(node, mediaType)));
|
|
70
|
+
return foundMediaTypes.find(mediaTypeInfo => (!mediaTypeInfo.not && (mediaTypeInfo.value == mediaType || mediaTypeInfo.value == MEDIA_ALL))
|
|
71
|
+
|| (mediaTypeInfo.not && (mediaTypeInfo.value == MEDIA_ALL || mediaTypeInfo.value != mediaType)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getMediaTypes(parentNode, mediaType, mediaTypes = []) {
|
|
75
|
+
parentNode.nodes.map((node, indexNode) => {
|
|
76
|
+
if (node.type == "media-query") {
|
|
77
|
+
return getMediaTypes(node, mediaType, mediaTypes);
|
|
78
|
+
} else {
|
|
79
|
+
if (node.type == "media-type") {
|
|
80
|
+
const nodeMediaType = { not: Boolean(indexNode && parentNode.nodes[0].type == "keyword" && parentNode.nodes[0].value == "not"), value: node.value };
|
|
81
|
+
if (!mediaTypes.find(mediaType => nodeMediaType.not == mediaType.not && nodeMediaType.value == mediaType.value)) {
|
|
82
|
+
mediaTypes.push(nodeMediaType);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (!mediaTypes.length) {
|
|
88
|
+
mediaTypes.push({ not: false, value: MEDIA_ALL });
|
|
89
|
+
}
|
|
90
|
+
return mediaTypes;
|
|
91
91
|
}
|
|
File without changes
|
|
File without changes
|
package/modules/html-minifier.js
CHANGED
|
File without changes
|
|
File without changes
|
package/modules/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "single-file-core",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "SingleFile Core",
|
|
5
|
-
"author": "Gildas Lormeau",
|
|
6
|
-
"license": "AGPL-3.0-or-later",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/gildas-lormeau/single-file-core.git"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/gildas-lormeau/single-file-core/issues"
|
|
16
|
-
},
|
|
17
|
-
"homepage": "https://github.com/gildas-lormeau/single-file-core#readme"
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "single-file-core",
|
|
3
|
+
"version": "1.1.78",
|
|
4
|
+
"description": "SingleFile Core",
|
|
5
|
+
"author": "Gildas Lormeau",
|
|
6
|
+
"license": "AGPL-3.0-or-later",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/gildas-lormeau/single-file-core.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/gildas-lormeau/single-file-core/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/gildas-lormeau/single-file-core#readme"
|
|
18
|
+
}
|