single-file-core 1.5.83 → 1.5.85
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 +1 -1
- package/modules/html-minifier.js +13 -2
- package/modules/template-parser.js +1 -1
- package/package.json +1 -1
- package/processors/compression/compression-display.js +1 -1
- package/processors/compression/compression-extract.js +16 -8
- package/processors/compression/compression.js +186 -200
- package/vendor/zip/z-worker.js +1 -1
- package/vendor/zip/zip.js +5135 -1412
- package/vendor/zip/zip.min.js +1 -1
|
@@ -140,7 +140,7 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
140
140
|
doc.head.appendChild(styleElement);
|
|
141
141
|
}
|
|
142
142
|
element.textContent = "/* */";
|
|
143
|
-
element.setAttribute("onload", "this.textContent=document.querySelector('style[" + DUPLICATE_STYLESHEET_ATTRIBUTE_NAME + "=\"" + stylesheetRefIndex + "\"]')?.textContent;this.removeAttribute(
|
|
143
|
+
element.setAttribute("onload", "this.textContent=document.querySelector('style[" + DUPLICATE_STYLESHEET_ATTRIBUTE_NAME + "=\"" + stylesheetRefIndex + "\"]')?.textContent;this.removeAttribute('onload')");
|
|
144
144
|
} else {
|
|
145
145
|
element.textContent = options.inlineStylesheets.get(stylesheetRefIndex).content;
|
|
146
146
|
}
|
package/modules/html-minifier.js
CHANGED
|
@@ -113,7 +113,8 @@ const redundantAttributes = {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const REGEXP_WHITESPACE = /[ \t\f\r]+/g;
|
|
116
|
-
const
|
|
116
|
+
const REGEXP_WHITESPACE_COLLAPSE = /[ \t\f\r]{2,}|[\t\f\r]/g;
|
|
117
|
+
const REGEXP_NEWLINE = /\n{2,}/g;
|
|
117
118
|
const REGEXP_ENDS_WHITESPACE = /^\s+$/;
|
|
118
119
|
const NodeFilter_SHOW_ALL = 4294967295;
|
|
119
120
|
const Node_ELEMENT_NODE = 1;
|
|
@@ -179,7 +180,17 @@ function collapseWhitespace(node, options) {
|
|
|
179
180
|
noWhitespace = element && noWhitespaceCollapse(element);
|
|
180
181
|
}
|
|
181
182
|
if ((!element || noWhitespace) && textContent.length > 1) {
|
|
182
|
-
|
|
183
|
+
const whitespace = getWhiteSpace(node);
|
|
184
|
+
let newTextContent;
|
|
185
|
+
if (whitespace == " ") {
|
|
186
|
+
newTextContent = textContent.replace(REGEXP_WHITESPACE_COLLAPSE, " ");
|
|
187
|
+
} else {
|
|
188
|
+
newTextContent = textContent.replace(REGEXP_WHITESPACE, whitespace);
|
|
189
|
+
}
|
|
190
|
+
newTextContent = newTextContent.replace(REGEXP_NEWLINE, "\n");
|
|
191
|
+
if (newTextContent != textContent) {
|
|
192
|
+
node.textContent = newTextContent;
|
|
193
|
+
}
|
|
183
194
|
}
|
|
184
195
|
}
|
|
185
196
|
}
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export {
|
|
|
29
29
|
|
|
30
30
|
async function display(document, docContent, { disableFramePointerEvents } = {}) {
|
|
31
31
|
docContent = docContent.replace(/<noscript/gi, "<template disabled-noscript");
|
|
32
|
-
docContent = docContent.
|
|
32
|
+
docContent = docContent.replace(/<\/noscript/gi, "</template");
|
|
33
33
|
const doc = (new DOMParser()).parseFromString(docContent, "text/html");
|
|
34
34
|
if (disableFramePointerEvents) {
|
|
35
35
|
doc.querySelectorAll("iframe").forEach(element => {
|
|
@@ -27,7 +27,7 @@ export {
|
|
|
27
27
|
extract
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
async function extract(content, { password, prompt = () => { }, zipOptions = { useWebWorkers:
|
|
30
|
+
async function extract(content, { password, prompt = () => { }, zipOptions = { useWebWorkers: true }, noBlobURL } = {}) {
|
|
31
31
|
const KNOWN_MIMETYPES = {
|
|
32
32
|
"gif": "image/gif",
|
|
33
33
|
"jpg": "image/jpeg",
|
|
@@ -74,13 +74,17 @@ async function extract(content, { password, prompt = () => { }, zipOptions = { u
|
|
|
74
74
|
const REGEXP_MATCH_MANIFEST = /manifest\.json$/;
|
|
75
75
|
const CHARSET_UTF8 = ";charset=utf-8";
|
|
76
76
|
const REGEXP_ESCAPE = /([{}()^$&.*?/+|[\\\\]|\]|-)/g;
|
|
77
|
-
|
|
78
|
-
if (Array.isArray(content)) {
|
|
79
|
-
content = new Blob([new Uint8Array(content)]);
|
|
80
|
-
}
|
|
77
|
+
let reader;
|
|
81
78
|
zip.configure(zipOptions);
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (content.readUint8Array) {
|
|
80
|
+
reader = content;
|
|
81
|
+
} else {
|
|
82
|
+
if (Array.isArray(content)) {
|
|
83
|
+
content = new Blob([new Uint8Array(content)]);
|
|
84
|
+
}
|
|
85
|
+
reader = new zip.BlobReader(content);
|
|
86
|
+
}
|
|
87
|
+
const zipReader = new zip.ZipReader(reader);
|
|
84
88
|
const entries = await zipReader.getEntries();
|
|
85
89
|
const options = { password };
|
|
86
90
|
let docContent, origDocContent, url, resources = [], indexPages = [], textResources = [];
|
|
@@ -98,7 +102,11 @@ async function extract(content, { password, prompt = () => { }, zipOptions = { u
|
|
|
98
102
|
textResources.push(resourceInfo);
|
|
99
103
|
}
|
|
100
104
|
dataWriter = new zip.TextWriter();
|
|
101
|
-
|
|
105
|
+
if (entry.uncompressedSize > 0) {
|
|
106
|
+
textContent = await entry.getData(dataWriter, options);
|
|
107
|
+
} else {
|
|
108
|
+
textContent = "";
|
|
109
|
+
}
|
|
102
110
|
if (filename.match(REGEXP_MATCH_INDEX)) {
|
|
103
111
|
mimeType = "text/html" + CHARSET_UTF8;
|
|
104
112
|
} else {
|