@contentful/experiences-visual-editor-react 1.39.0-dev-20250530T0835-140c77e.0 → 1.39.0-dev-20250603T0757-ecbd0d2.0

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/dist/index.js CHANGED
@@ -1081,6 +1081,32 @@ propertyName, resolveDesignTokens = true) => {
1081
1081
  };
1082
1082
 
1083
1083
  const CF_DEBUG_KEY$1 = 'cf_debug';
1084
+ /**
1085
+ * To ensure that the localStorage API can be used safely, we check
1086
+ * for availability (e.g. undefined in Node.js). Additionally, we
1087
+ * check if the localStorage can be used as some browsers throw a
1088
+ * SecurityError (e.g. Brave or Chromium with specific settings).
1089
+ */
1090
+ const checkLocalStorageAvailability$1 = () => {
1091
+ if (typeof localStorage === 'undefined' || localStorage === null) {
1092
+ return false;
1093
+ }
1094
+ try {
1095
+ // Attempt to set and remove an item to check if localStorage is enabled
1096
+ const TEST_KEY = 'cf_test_local_storage';
1097
+ localStorage.setItem(TEST_KEY, 'yes');
1098
+ if (localStorage.getItem(TEST_KEY) === 'yes') {
1099
+ localStorage.removeItem(TEST_KEY);
1100
+ return true;
1101
+ }
1102
+ else {
1103
+ return false;
1104
+ }
1105
+ }
1106
+ catch (_error) {
1107
+ return false;
1108
+ }
1109
+ };
1084
1110
  let DebugLogger$1 = class DebugLogger {
1085
1111
  constructor() {
1086
1112
  // Public methods for logging
@@ -1088,7 +1114,7 @@ let DebugLogger$1 = class DebugLogger {
1088
1114
  this.warn = this.logger('warn');
1089
1115
  this.log = this.logger('log');
1090
1116
  this.debug = this.logger('debug');
1091
- if (typeof localStorage === 'undefined') {
1117
+ if (!checkLocalStorageAvailability$1()) {
1092
1118
  this.enabled = false;
1093
1119
  return;
1094
1120
  }
@@ -3763,6 +3789,32 @@ var CodeNames;
3763
3789
  })(CodeNames || (CodeNames = {}));
3764
3790
 
3765
3791
  const CF_DEBUG_KEY = 'cf_debug';
3792
+ /**
3793
+ * To ensure that the localStorage API can be used safely, we check
3794
+ * for availability (e.g. undefined in Node.js). Additionally, we
3795
+ * check if the localStorage can be used as some browsers throw a
3796
+ * SecurityError (e.g. Brave or Chromium with specific settings).
3797
+ */
3798
+ const checkLocalStorageAvailability = () => {
3799
+ if (typeof localStorage === 'undefined' || localStorage === null) {
3800
+ return false;
3801
+ }
3802
+ try {
3803
+ // Attempt to set and remove an item to check if localStorage is enabled
3804
+ const TEST_KEY = 'cf_test_local_storage';
3805
+ localStorage.setItem(TEST_KEY, 'yes');
3806
+ if (localStorage.getItem(TEST_KEY) === 'yes') {
3807
+ localStorage.removeItem(TEST_KEY);
3808
+ return true;
3809
+ }
3810
+ else {
3811
+ return false;
3812
+ }
3813
+ }
3814
+ catch (_error) {
3815
+ return false;
3816
+ }
3817
+ };
3766
3818
  class DebugLogger {
3767
3819
  constructor() {
3768
3820
  // Public methods for logging
@@ -3770,7 +3822,7 @@ class DebugLogger {
3770
3822
  this.warn = this.logger('warn');
3771
3823
  this.log = this.logger('log');
3772
3824
  this.debug = this.logger('debug');
3773
- if (typeof localStorage === 'undefined') {
3825
+ if (!checkLocalStorageAvailability()) {
3774
3826
  this.enabled = false;
3775
3827
  return;
3776
3828
  }