@glimt/record 0.0.40 → 0.0.42

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.
@@ -517,6 +517,7 @@ function stringifyStylesheet$1(s2) {
517
517
  ).join("");
518
518
  return fixBrowserCompatibilityIssuesInCSS$1(stringifiedRules);
519
519
  } catch (error) {
520
+ console.log("stringifyStylesheet error:", error);
520
521
  return null;
521
522
  }
522
523
  }
@@ -853,23 +854,40 @@ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
853
854
  if (_AsyncStylesheetManager.instance) return _AsyncStylesheetManager.instance;
854
855
  _AsyncStylesheetManager.instance = this;
855
856
  }
857
+ removeCloneNode(href) {
858
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
859
+ document.head.removeChild(this.clones[href].clone);
860
+ }
856
861
  onLoad(href) {
857
862
  if (!(href in this.clones) || this.clones[href] === void 0) return;
858
863
  console.log("AsyncStylesheetManager, onLoad: href:", href);
859
864
  const styleSheets2 = Array.from(document.styleSheets);
860
865
  let clonedStyleSheet = null;
861
- document.head.removeChild(this.clones[href].clone);
862
866
  for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
863
867
  if (styleSheets2[i2].href === href) {
864
868
  clonedStyleSheet = styleSheets2[i2];
865
869
  break;
866
870
  }
867
871
  }
868
- if (!clonedStyleSheet) return;
872
+ if (!clonedStyleSheet) {
873
+ console.log(
874
+ "AsyncStylesheetManager, onLoad: couldn't find stylesheet for href:",
875
+ href
876
+ );
877
+ return this.removeCloneNode(href);
878
+ }
869
879
  const newCssText = stringifyStylesheet$1(clonedStyleSheet);
870
- if (!newCssText) return;
880
+ this.removeCloneNode(href);
881
+ if (!newCssText) {
882
+ console.log(
883
+ "AsyncStylesheetManager, onLoad: couldn't stringify stylesheet for href:",
884
+ href
885
+ );
886
+ return;
887
+ }
871
888
  console.log(
872
- "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
889
+ "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation... for href:",
890
+ href
873
891
  );
874
892
  this.clones[href].cssText = newCssText;
875
893
  this.clones[href].loaded = true;
@@ -880,12 +898,11 @@ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
880
898
  }
881
899
  onLoadError(href) {
882
900
  if (!(href in this.clones) || this.clones[href] === void 0) return;
883
- document.head.removeChild(this.clones[href].clone);
901
+ this.removeCloneNode(href);
884
902
  }
885
903
  removeAllCloneElements() {
886
- for (const clone of Object.values(this.clones)) {
887
- if (!clone) continue;
888
- document.head.removeChild(clone.clone);
904
+ for (const href of Object.keys(this.clones)) {
905
+ this.removeCloneNode(href);
889
906
  }
890
907
  }
891
908
  onCleanTimeout() {
@@ -903,10 +920,6 @@ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
903
920
  this.blowCache();
904
921
  this.currentHref = document.location.href;
905
922
  const href = forElement.href;
906
- console.log(
907
- "AsyncStylesheetManager, registerClone: wants a clone for href:",
908
- href
909
- );
910
923
  if (!href) return;
911
924
  if (href in this.clones && this.clones[href] !== void 0) return;
912
925
  if (forElement.getAttribute("crossorigin") === "anonymous") return;
@@ -936,7 +949,8 @@ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
936
949
  getClonedCssTextIfAvailable(href) {
937
950
  if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
938
951
  console.log(
939
- "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
952
+ "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText, for href:",
953
+ href
940
954
  );
941
955
  return this.clones[href].cssText;
942
956
  }
@@ -1338,10 +1352,13 @@ function serializeElementNode(n2, options) {
1338
1352
  }
1339
1353
  if (tagName === "link" && inlineStylesheet) {
1340
1354
  const styleSheets2 = Array.from(doc.styleSheets);
1341
- const styleSheetIndex = styleSheets2.findIndex((s2) => {
1342
- return s2.href === n2.href;
1343
- });
1344
- const stylesheet = styleSheets2[styleSheetIndex];
1355
+ let stylesheet = null;
1356
+ for (let i2 = 0; i2 < styleSheets2.length; i2++) {
1357
+ if (styleSheets2[i2].href === n2.href) {
1358
+ stylesheet = styleSheets2[i2];
1359
+ break;
1360
+ }
1361
+ }
1345
1362
  let cssText = null;
1346
1363
  if (stylesheet) {
1347
1364
  cssText = stringifyStylesheet$1(stylesheet);
@@ -5561,6 +5578,7 @@ function stringifyStylesheet(s2) {
5561
5578
  ).join("");
5562
5579
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
5563
5580
  } catch (error) {
5581
+ console.log("stringifyStylesheet error:", error);
5564
5582
  return null;
5565
5583
  }
5566
5584
  }
@@ -5657,23 +5675,40 @@ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5657
5675
  if (_AsyncStylesheetManager22.instance) return _AsyncStylesheetManager22.instance;
5658
5676
  _AsyncStylesheetManager22.instance = this;
5659
5677
  }
5678
+ removeCloneNode(href) {
5679
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5680
+ document.head.removeChild(this.clones[href].clone);
5681
+ }
5660
5682
  onLoad(href) {
5661
5683
  if (!(href in this.clones) || this.clones[href] === void 0) return;
5662
5684
  console.log("AsyncStylesheetManager, onLoad: href:", href);
5663
5685
  const styleSheets2 = Array.from(document.styleSheets);
5664
5686
  let clonedStyleSheet = null;
5665
- document.head.removeChild(this.clones[href].clone);
5666
5687
  for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
5667
5688
  if (styleSheets2[i2].href === href) {
5668
5689
  clonedStyleSheet = styleSheets2[i2];
5669
5690
  break;
5670
5691
  }
5671
5692
  }
5672
- if (!clonedStyleSheet) return;
5693
+ if (!clonedStyleSheet) {
5694
+ console.log(
5695
+ "AsyncStylesheetManager, onLoad: couldn't find stylesheet for href:",
5696
+ href
5697
+ );
5698
+ return this.removeCloneNode(href);
5699
+ }
5673
5700
  const newCssText = stringifyStylesheet(clonedStyleSheet);
5674
- if (!newCssText) return;
5701
+ this.removeCloneNode(href);
5702
+ if (!newCssText) {
5703
+ console.log(
5704
+ "AsyncStylesheetManager, onLoad: couldn't stringify stylesheet for href:",
5705
+ href
5706
+ );
5707
+ return;
5708
+ }
5675
5709
  console.log(
5676
- "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
5710
+ "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation... for href:",
5711
+ href
5677
5712
  );
5678
5713
  this.clones[href].cssText = newCssText;
5679
5714
  this.clones[href].loaded = true;
@@ -5684,12 +5719,11 @@ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5684
5719
  }
5685
5720
  onLoadError(href) {
5686
5721
  if (!(href in this.clones) || this.clones[href] === void 0) return;
5687
- document.head.removeChild(this.clones[href].clone);
5722
+ this.removeCloneNode(href);
5688
5723
  }
5689
5724
  removeAllCloneElements() {
5690
- for (const clone of Object.values(this.clones)) {
5691
- if (!clone) continue;
5692
- document.head.removeChild(clone.clone);
5725
+ for (const href of Object.keys(this.clones)) {
5726
+ this.removeCloneNode(href);
5693
5727
  }
5694
5728
  }
5695
5729
  onCleanTimeout() {
@@ -5707,10 +5741,6 @@ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5707
5741
  this.blowCache();
5708
5742
  this.currentHref = document.location.href;
5709
5743
  const href = forElement.href;
5710
- console.log(
5711
- "AsyncStylesheetManager, registerClone: wants a clone for href:",
5712
- href
5713
- );
5714
5744
  if (!href) return;
5715
5745
  if (href in this.clones && this.clones[href] !== void 0) return;
5716
5746
  if (forElement.getAttribute("crossorigin") === "anonymous") return;
@@ -5740,7 +5770,8 @@ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5740
5770
  getClonedCssTextIfAvailable(href) {
5741
5771
  if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
5742
5772
  console.log(
5743
- "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
5773
+ "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText, for href:",
5774
+ href
5744
5775
  );
5745
5776
  return this.clones[href].cssText;
5746
5777
  }