single-file-core 1.5.82 → 1.5.83
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/core/index.js
CHANGED
|
@@ -678,6 +678,7 @@ class Processor {
|
|
|
678
678
|
replaceEmojisInFilename: this.options.replaceEmojisInFilename,
|
|
679
679
|
compressContent: this.options.compressContent,
|
|
680
680
|
selfExtractingArchive: this.options.selfExtractingArchive,
|
|
681
|
+
disableCompression: this.options.disableCompression,
|
|
681
682
|
extractDataFromPage: this.options.extractDataFromPage,
|
|
682
683
|
referrer: this.options.referrer,
|
|
683
684
|
title: this.options.title,
|
|
@@ -98,8 +98,8 @@ class ProcessorHelperCommon {
|
|
|
98
98
|
["embed[src*=\".svg\"]", "src"],
|
|
99
99
|
["video[poster]", "poster"],
|
|
100
100
|
["*[background]", "background"],
|
|
101
|
-
["image", "xlink:href"],
|
|
102
|
-
["image", "href"]
|
|
101
|
+
["image, feImage", "xlink:href"],
|
|
102
|
+
["image, feImage", "href"]
|
|
103
103
|
];
|
|
104
104
|
if (options.blockImages) {
|
|
105
105
|
doc.querySelectorAll("svg").forEach(element => element.remove());
|
|
@@ -482,16 +482,24 @@ function collectDeclarationItemsForElement(element, docContext) {
|
|
|
482
482
|
return allDeclarations;
|
|
483
483
|
|
|
484
484
|
function addDeclaration(declaration, specificity, isInline, selector) {
|
|
485
|
-
const { value } = declaration.data;
|
|
485
|
+
const { property, value } = declaration.data;
|
|
486
486
|
const isRawValue = value.type === RAW_TYPE;
|
|
487
487
|
const hasValueChildNodes = hasChildNodes(value) || value.type === RAW_TYPE;
|
|
488
|
-
|
|
488
|
+
let isInvalidValue;
|
|
489
|
+
if (value.type === VALUE_TYPE &&
|
|
489
490
|
hasValueChildNodes &&
|
|
490
|
-
value.children.
|
|
491
|
-
value.children.head.data.name
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
value.children.size == 1) {
|
|
492
|
+
if (value.children.head.data.name) {
|
|
493
|
+
isInvalidValue = value.children.head.data.name.startsWith(VENDOR_PREFIX) || INVALID_CSS_ESCAPE_TEST.test(value.children.head.data.name);
|
|
494
|
+
} if (!property.startsWith(VENDOR_PREFIX) && value.children.head.data.value) {
|
|
495
|
+
try {
|
|
496
|
+
isInvalidValue = !cssTree.lexer.matchProperty(property, value).matched;
|
|
497
|
+
} catch {
|
|
498
|
+
// ignored
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (hasValueChildNodes && !isRawValue && !isInvalidValue) {
|
|
495
503
|
allDeclarations.push({
|
|
496
504
|
declaration,
|
|
497
505
|
selector,
|
package/package.json
CHANGED
|
@@ -133,7 +133,7 @@ async function process(pageData, options, lastModDate = new Date()) {
|
|
|
133
133
|
const startOffset = zipDataWriter.offset;
|
|
134
134
|
pageData.url = options.url;
|
|
135
135
|
pageData.archiveTime = (new Date()).toISOString();
|
|
136
|
-
await addPageResources(zipWriter, pageData, { password: options.password }, options.createRootDirectory ? String(Date.now()) + "_" + (options.tabId || 0) + "/" : "", options.url);
|
|
136
|
+
await addPageResources(zipWriter, pageData, { password: options.password, disableCompression: options.disableCompression }, options.createRootDirectory ? String(Date.now()) + "_" + (options.tabId || 0) + "/" : "", options.url);
|
|
137
137
|
const data = await zipWriter.close(null, { preventClose: true });
|
|
138
138
|
if (options.selfExtractingArchive) {
|
|
139
139
|
const insertionsCRLF = [];
|
|
@@ -393,25 +393,25 @@ async function addPageResources(zipWriter, pageData, options, prefixName, url) {
|
|
|
393
393
|
}, null, 2);
|
|
394
394
|
await Promise.all([
|
|
395
395
|
Promise.all([
|
|
396
|
-
addFile(zipWriter, prefixName, { name: "index.html", extension: ".html", content: pageData.content, url, password: options.password }),
|
|
397
|
-
addFile(zipWriter, prefixName, { name: "manifest.json", extension: ".json", content: jsonContent, password: options.password })
|
|
396
|
+
addFile(zipWriter, prefixName, { name: "index.html", extension: ".html", content: pageData.content, url, password: options.password }, options.disableCompression),
|
|
397
|
+
addFile(zipWriter, prefixName, { name: "manifest.json", extension: ".json", content: jsonContent, password: options.password }, options.disableCompression)
|
|
398
398
|
]),
|
|
399
399
|
Promise.all(Object.keys(pageData.resources).map(async resourceType =>
|
|
400
400
|
Promise.all(pageData.resources[resourceType].map(data => {
|
|
401
401
|
if (resourceType == "frames") {
|
|
402
402
|
return addPageResources(zipWriter, data, options, prefixName + data.name, data.url);
|
|
403
403
|
} else {
|
|
404
|
-
return addFile(zipWriter, prefixName, data,
|
|
404
|
+
return addFile(zipWriter, prefixName, data, options.disableCompression);
|
|
405
405
|
}
|
|
406
406
|
}))
|
|
407
407
|
))
|
|
408
408
|
]);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
async function addFile(zipWriter, prefixName, data) {
|
|
411
|
+
async function addFile(zipWriter, prefixName, data, disableCompresson) {
|
|
412
412
|
const dataReader = typeof data.content == "string" ? new TextReader(data.content) : new BlobReader(new Blob([new Uint8Array(data.content)]));
|
|
413
413
|
const options = { comment: data.url && data.url.startsWith("data:") ? "data:" : data.url, password: data.password, bufferedWrite: true };
|
|
414
|
-
if (NO_COMPRESSION_EXTENSIONS.includes(data.extension)) {
|
|
414
|
+
if (NO_COMPRESSION_EXTENSIONS.includes(data.extension) || disableCompresson) {
|
|
415
415
|
options.level = 0;
|
|
416
416
|
}
|
|
417
417
|
await zipWriter.add(prefixName + data.name, dataReader, options);
|
package/single-file.js
CHANGED
|
@@ -116,6 +116,7 @@ async function getPageData(options = {}, initOptions, doc, win) {
|
|
|
116
116
|
url: options.url,
|
|
117
117
|
createRootDirectory: options.createRootDirectory,
|
|
118
118
|
selfExtractingArchive: options.selfExtractingArchive,
|
|
119
|
+
disableCompression: options.disableCompression,
|
|
119
120
|
extractDataFromPage: options.extractDataFromPage,
|
|
120
121
|
preventAppendedData: options.preventAppendedData,
|
|
121
122
|
insertCanonicalLink: options.insertCanonicalLink,
|