single-file-core 1.5.1 → 1.5.3
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.
|
@@ -507,24 +507,28 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
507
507
|
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
508
508
|
]);
|
|
509
509
|
} catch (error) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
510
|
+
if (error.name == "NetworkError") {
|
|
511
|
+
source.valid = true;
|
|
512
|
+
} else {
|
|
513
|
+
const urlNodes = cssTree.findAll(srcDeclaration.data, node => node.type == "Url");
|
|
514
|
+
const declarationFontURLs = Array.from(fontDeclarations).find(([node]) => urlNodes.includes(node) && node.value == source.fontUrl);
|
|
515
|
+
if (declarationFontURLs && declarationFontURLs[1].length) {
|
|
516
|
+
const fontURL = declarationFontURLs[1][0];
|
|
517
|
+
if (fontURL) {
|
|
518
|
+
const fontFace = new FontFace("test-font", "url(" + fontURL + ")");
|
|
519
|
+
try {
|
|
520
|
+
let timeout;
|
|
521
|
+
await Promise.race([
|
|
522
|
+
fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
|
|
523
|
+
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
524
|
+
]);
|
|
525
|
+
} catch (error) {
|
|
526
|
+
// ignored
|
|
527
|
+
}
|
|
524
528
|
}
|
|
529
|
+
} else {
|
|
530
|
+
source.valid = true;
|
|
525
531
|
}
|
|
526
|
-
} else {
|
|
527
|
-
source.valid = true;
|
|
528
532
|
}
|
|
529
533
|
}
|
|
530
534
|
} else {
|
|
@@ -418,15 +418,19 @@ function getProcessorHelperClass(utilInstance) {
|
|
|
418
418
|
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
419
419
|
]);
|
|
420
420
|
} catch (error) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
421
|
+
if (error.name == "NetworkError") {
|
|
422
|
+
source.valid = true;
|
|
423
|
+
} else {
|
|
424
|
+
const fontFace = new FontFace("test-font", "url(" + resource.url + ")");
|
|
425
|
+
try {
|
|
426
|
+
let timeout;
|
|
427
|
+
await Promise.race([
|
|
428
|
+
fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
|
|
429
|
+
new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
|
|
430
|
+
]);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
// ignored
|
|
433
|
+
}
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
436
|
} else {
|
package/package.json
CHANGED
|
@@ -66,6 +66,7 @@ const MessageChannel = globalThis.MessageChannel;
|
|
|
66
66
|
const document = globalThis.document;
|
|
67
67
|
const JSON = globalThis.JSON;
|
|
68
68
|
const MutationObserver = globalThis.MutationObserver;
|
|
69
|
+
const DOMParser = globalThis.DOMParser;
|
|
69
70
|
|
|
70
71
|
let sessions = globalThis.sessions;
|
|
71
72
|
if (!sessions) {
|
|
@@ -303,16 +304,22 @@ function processFramesSync(doc, frameElements, options, parentWindowId, sessionI
|
|
|
303
304
|
const frames = [];
|
|
304
305
|
frameElements.forEach((frameElement, frameIndex) => {
|
|
305
306
|
const windowId = parentWindowId + WINDOW_ID_SEPARATOR + frameIndex;
|
|
306
|
-
let frameDoc;
|
|
307
|
+
let frameDoc, frameWindow;
|
|
307
308
|
try {
|
|
308
309
|
frameDoc = frameElement.contentDocument;
|
|
310
|
+
frameWindow = frameElement.contentWindow;
|
|
311
|
+
frameWindow.stop();
|
|
309
312
|
} catch (error) {
|
|
310
313
|
// ignored
|
|
311
314
|
}
|
|
315
|
+
const srcdoc = frameElement.getAttribute("srcdoc");
|
|
316
|
+
if (!frameDoc && srcdoc) {
|
|
317
|
+
const doc = new DOMParser().parseFromString(srcdoc, "text/html");
|
|
318
|
+
frameDoc = doc;
|
|
319
|
+
frameWindow = globalThis;
|
|
320
|
+
}
|
|
312
321
|
if (frameDoc) {
|
|
313
322
|
try {
|
|
314
|
-
const frameWindow = frameElement.contentWindow;
|
|
315
|
-
frameWindow.stop();
|
|
316
323
|
clearFrameTimeout("requestTimeouts", sessionId, windowId);
|
|
317
324
|
processFrames(frameDoc, options, windowId, sessionId);
|
|
318
325
|
frames.push(getFrameData(frameDoc, frameWindow, windowId, options, frameElement.scrolling));
|