@contentful/experiences-core 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 +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1430,6 +1430,32 @@ propertyName, resolveDesignTokens = true) => {
|
|
|
1430
1430
|
};
|
|
1431
1431
|
|
|
1432
1432
|
const CF_DEBUG_KEY = 'cf_debug';
|
|
1433
|
+
/**
|
|
1434
|
+
* To ensure that the localStorage API can be used safely, we check
|
|
1435
|
+
* for availability (e.g. undefined in Node.js). Additionally, we
|
|
1436
|
+
* check if the localStorage can be used as some browsers throw a
|
|
1437
|
+
* SecurityError (e.g. Brave or Chromium with specific settings).
|
|
1438
|
+
*/
|
|
1439
|
+
const checkLocalStorageAvailability = () => {
|
|
1440
|
+
if (typeof localStorage === 'undefined' || localStorage === null) {
|
|
1441
|
+
return false;
|
|
1442
|
+
}
|
|
1443
|
+
try {
|
|
1444
|
+
// Attempt to set and remove an item to check if localStorage is enabled
|
|
1445
|
+
const TEST_KEY = 'cf_test_local_storage';
|
|
1446
|
+
localStorage.setItem(TEST_KEY, 'yes');
|
|
1447
|
+
if (localStorage.getItem(TEST_KEY) === 'yes') {
|
|
1448
|
+
localStorage.removeItem(TEST_KEY);
|
|
1449
|
+
return true;
|
|
1450
|
+
}
|
|
1451
|
+
else {
|
|
1452
|
+
return false;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
catch (_error) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1433
1459
|
class DebugLogger {
|
|
1434
1460
|
constructor() {
|
|
1435
1461
|
// Public methods for logging
|
|
@@ -1437,7 +1463,7 @@ class DebugLogger {
|
|
|
1437
1463
|
this.warn = this.logger('warn');
|
|
1438
1464
|
this.log = this.logger('log');
|
|
1439
1465
|
this.debug = this.logger('debug');
|
|
1440
|
-
if (
|
|
1466
|
+
if (!checkLocalStorageAvailability()) {
|
|
1441
1467
|
this.enabled = false;
|
|
1442
1468
|
return;
|
|
1443
1469
|
}
|