single-file-core 1.5.120 → 1.5.122
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/lib/processor-helper-inline.js +3 -3
- package/core/util.js +3 -1
- package/doc/assets/singlefile-archive-byte-map.svg +195 -217
- package/doc/singlefile-archive.md +143 -72
- package/package.json +1 -1
- package/processors/compression/compression-packager.js +3 -3
- package/processors/compression/compression.js +32 -5
- package/processors/hooks/content/content-hooks-frames-web.js +8 -11
- package/vendor/zip/z-worker.js +1 -1
- package/vendor/zip/zip.js +25 -47
- package/vendor/zip/zip.min.js +1 -1
- package/zip-build/package-lock.json +4 -4
- package/zip-build/package.json +1 -1
- package/zip-build/reserved-property-names.json +5 -3
|
@@ -397,6 +397,9 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
+
if (options.imageReductionFactor > 1 && expectedType == "image") {
|
|
401
|
+
content = await resizeImage(doc, content, options);
|
|
402
|
+
}
|
|
400
403
|
if (removeElementIfMissing && this.testEmptyResource(content)) {
|
|
401
404
|
resourceElement.remove();
|
|
402
405
|
} else if (!this.testEmptyResource(content)) {
|
|
@@ -420,9 +423,6 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
420
423
|
const isSVG = content.startsWith(PREFIX_DATA_URI_IMAGE_SVG);
|
|
421
424
|
const maxSizeDuplicateImages = options.maxSizeDuplicateImages || SINGLE_FILE_VARIABLE_MAX_SIZE;
|
|
422
425
|
if (processDuplicates && duplicate && !isSVG && util.getContentSize(content) < maxSizeDuplicateImages) {
|
|
423
|
-
if (options.imageReductionFactor > 1 && expectedType == "image") {
|
|
424
|
-
content = await resizeImage(doc, content, options);
|
|
425
|
-
}
|
|
426
426
|
if (this.replaceImageSource(resourceElement, SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource, options)) {
|
|
427
427
|
resources.cssVariables.set(indexResource, { content, url: originURL });
|
|
428
428
|
const declarationList = cssTree.parse(resourceElement.getAttribute("style"), { context: "declarationList", parseCustomProperty: true });
|
package/core/util.js
CHANGED
|
@@ -63,6 +63,8 @@ const CONTENT_TYPE_EXTENSIONS = {
|
|
|
63
63
|
"font/collection": ".ttc"
|
|
64
64
|
};
|
|
65
65
|
const CONTENT_TYPE_OCTET_STREAM = "application/octet-stream";
|
|
66
|
+
const CONTENT_TYPES_HTML = ["text/html", "application/xhtml+xml"];
|
|
67
|
+
const EXPECTED_TYPES_MEDIA = ["font", "image", "video", "audio"];
|
|
66
68
|
|
|
67
69
|
const URL = globalThis.URL;
|
|
68
70
|
const DOMParser = globalThis.DOMParser;
|
|
@@ -308,7 +310,7 @@ function getInstance(utilOptions) {
|
|
|
308
310
|
charset = options.charset;
|
|
309
311
|
}
|
|
310
312
|
if (options.asBinary) {
|
|
311
|
-
if (response.status >= 400) {
|
|
313
|
+
if (response.status >= 400 || (EXPECTED_TYPES_MEDIA.includes(options.expectedType) && CONTENT_TYPES_HTML.includes(contentType))) {
|
|
312
314
|
return getFetchResponse(resourceURL, options);
|
|
313
315
|
}
|
|
314
316
|
try {
|