single-file-core 1.5.2 → 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
- const urlNodes = cssTree.findAll(srcDeclaration.data, node => node.type == "Url");
511
- const declarationFontURLs = Array.from(fontDeclarations).find(([node]) => urlNodes.includes(node) && node.value == source.fontUrl);
512
- if (declarationFontURLs && declarationFontURLs[1].length) {
513
- const fontURL = declarationFontURLs[1][0];
514
- if (fontURL) {
515
- const fontFace = new FontFace("test-font", "url(" + fontURL + ")");
516
- try {
517
- let timeout;
518
- await Promise.race([
519
- fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
520
- new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
521
- ]);
522
- } catch (error) {
523
- // ignored
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
- const fontFace = new FontFace("test-font", "url(" + resource.url + ")");
422
- try {
423
- let timeout;
424
- await Promise.race([
425
- fontFace.load().then(() => fontFace.loaded).then(() => { source.valid = true; globalThis.clearTimeout(timeout); }),
426
- new Promise(resolve => timeout = globalThis.setTimeout(() => { source.valid = true; resolve(); }, FONT_MAX_LOAD_DELAY))
427
- ]);
428
- } catch (error) {
429
- // ignored
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",