single-file-core 1.0.51 → 1.0.52
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.
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
if (singleFileComment && isSingleFileComment(singleFileComment)) {
|
|
144
144
|
const info = singleFileComment.textContent.split("\n");
|
|
145
145
|
const [, , urlData, ...optionalData] = info;
|
|
146
|
-
const urlMatch = urlData.match(/^ url: (.*)
|
|
146
|
+
const urlMatch = urlData.match(/^ url: (.*) ?$/);
|
|
147
147
|
const url = urlMatch && urlMatch[1];
|
|
148
148
|
if (url) {
|
|
149
149
|
let options;
|
package/package.json
CHANGED
|
@@ -226,6 +226,7 @@ function initResponse(message) {
|
|
|
226
226
|
frameData.content = messageFrameData.content;
|
|
227
227
|
frameData.baseURI = messageFrameData.baseURI;
|
|
228
228
|
frameData.title = messageFrameData.title;
|
|
229
|
+
frameData.url = messageFrameData.url;
|
|
229
230
|
frameData.canvases = messageFrameData.canvases;
|
|
230
231
|
frameData.fonts = messageFrameData.fonts;
|
|
231
232
|
frameData.stylesheets = messageFrameData.stylesheets;
|
|
@@ -392,6 +393,7 @@ function getFrameData(document, globalThis, windowId, options) {
|
|
|
392
393
|
windowId,
|
|
393
394
|
content,
|
|
394
395
|
baseURI,
|
|
396
|
+
url: document.location.href,
|
|
395
397
|
title: document.title,
|
|
396
398
|
canvases: docData.canvases,
|
|
397
399
|
fonts: docData.fonts,
|
|
@@ -317,6 +317,7 @@
|
|
|
317
317
|
return new FontFace(...arguments);
|
|
318
318
|
};
|
|
319
319
|
globalThis.FontFace.prototype = FontFace.prototype;
|
|
320
|
+
globalThis.FontFace.toString = function () { return "function FontFace() { [native code] }"; };
|
|
320
321
|
const deleteFont = document.fonts.delete;
|
|
321
322
|
document.fonts.delete = function (fontFace) {
|
|
322
323
|
getDetailObject(fontFace.family).then(detail => dispatchEvent(new CustomEvent(DELETE_FONT_EVENT, { detail })));
|
package/single-file-core.js
CHANGED
|
@@ -1798,7 +1798,15 @@ class ProcessorHelper {
|
|
|
1798
1798
|
if (removeElementIfMissing && content == util.EMPTY_RESOURCE) {
|
|
1799
1799
|
resourceElement.remove();
|
|
1800
1800
|
} else if (content !== util.EMPTY_RESOURCE) {
|
|
1801
|
-
|
|
1801
|
+
let forbiddenPrefixFound = PREFIXES_FORBIDDEN_DATA_URI.filter(prefixDataURI => content.startsWith(prefixDataURI)).length;
|
|
1802
|
+
if (forbiddenPrefixFound) {
|
|
1803
|
+
forbiddenPrefixFound = await new Promise((resolve) => {
|
|
1804
|
+
const element = options.doc.createElement(resourceElement.tagName);
|
|
1805
|
+
element.setAttribute(attributeName, content);
|
|
1806
|
+
element.onload = () => resolve();
|
|
1807
|
+
element.onerror = () => resolve(true);
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1802
1810
|
if (!forbiddenPrefixFound) {
|
|
1803
1811
|
const isSVG = content.startsWith(PREFIX_DATA_URI_IMAGE_SVG);
|
|
1804
1812
|
const maxSizeDuplicateImages = options.maxSizeDuplicateImages || SINGLE_FILE_VARIABLE_MAX_SIZE;
|
package/single-file.js
CHANGED
|
@@ -55,20 +55,30 @@ async function getPageData(options = {}, initOptions, doc = globalThis.document,
|
|
|
55
55
|
helper.initDoc(doc);
|
|
56
56
|
const preInitializationPromises = [];
|
|
57
57
|
if (!options.saveRawPage) {
|
|
58
|
-
if (
|
|
58
|
+
if (options.loadDeferredImages) {
|
|
59
|
+
if (options.loadDeferredImagesBeforeFrames) {
|
|
60
|
+
await processors.lazy.process(options);
|
|
61
|
+
} else {
|
|
62
|
+
preInitializationPromises.push(processors.lazy.process(options));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!options.removeFrames && frames && globalThis.frames) {
|
|
59
66
|
let frameTreePromise;
|
|
60
67
|
if (options.loadDeferredImages) {
|
|
61
|
-
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesMaxIdleTime
|
|
68
|
+
frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime / 2));
|
|
62
69
|
} else {
|
|
63
70
|
frameTreePromise = frames.getAsync(options);
|
|
64
71
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
if (options.loadDeferredImagesBeforeFrames) {
|
|
73
|
+
options.frames = await frameTreePromise;
|
|
74
|
+
} else {
|
|
75
|
+
preInitializationPromises.push(frameTreePromise);
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
|
-
|
|
79
|
+
if (!options.loadDeferredImagesBeforeFrames) {
|
|
80
|
+
[,options.frames] = await Promise.all(preInitializationPromises);
|
|
81
|
+
}
|
|
72
82
|
framesSessionId = options.frames && options.frames.sessionId;
|
|
73
83
|
}
|
|
74
84
|
options.doc = doc;
|