adecksibility-widget 2.5.7 → 2.5.8

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/README.md CHANGED
@@ -11,7 +11,7 @@ Premium standalone accessibility widget bundle for WordPress and non-WordPress s
11
11
  platform: "standalone"
12
12
  };
13
13
  </script>
14
- <script src="https://cdn.jsdelivr.net/npm/adecksibility-widget@2.5.7/dist/adecksibility-widget-pro.umd.js" defer></script>
14
+ <script src="https://cdn.jsdelivr.net/npm/adecksibility-widget@2.5.8/dist/adecksibility-widget-pro.umd.js" defer></script>
15
15
  ```
16
16
 
17
17
  ## Notes
@@ -883,8 +883,19 @@ var DEFAULT_STORAGE_KEYS = {
883
883
  hiddenSession: 'adeck_hidden_session'
884
884
  };
885
885
 
886
- function buildStorageKeys(storageKeys) {
887
- return Object.assign({}, DEFAULT_STORAGE_KEYS, storageKeys || {});
886
+ function buildStorageKeys(storageKeys, storageNamespace) {
887
+ var resolvedKeys = Object.assign({}, DEFAULT_STORAGE_KEYS, storageKeys || {});
888
+ var namespace = typeof storageNamespace === 'string' ? storageNamespace.trim() : '';
889
+
890
+ if (!namespace) {
891
+ return resolvedKeys;
892
+ }
893
+
894
+ Object.keys(resolvedKeys).forEach(function (key) {
895
+ resolvedKeys[key] = namespace + ':' + resolvedKeys[key];
896
+ });
897
+
898
+ return resolvedKeys;
888
899
  }
889
900
 
890
901
  function createStorageAdapter(storageArea) {
@@ -991,7 +1002,7 @@ function isFeatureEnabled(featureName) {
991
1002
  function init(options) {
992
1003
  options = options || {};
993
1004
 
994
- storageKeys = buildStorageKeys(options.storageKeys);
1005
+ storageKeys = buildStorageKeys(options.storageKeys, options.storageNamespace);
995
1006
  storage = createStorageAdapter(options.storage || global.localStorage);
996
1007
  sessionStore = createStorageAdapter(options.sessionStorage || global.sessionStorage);
997
1008
  i18n = options.i18n || getDefaultMessages();
@@ -2617,7 +2628,21 @@ global.ADecksibility.initWhenReady = initWhenReady;
2617
2628
  }
2618
2629
 
2619
2630
  if (!merged.storageNamespace || merged.storageNamespace === DEFAULT_CONFIG.storageNamespace) {
2620
- merged.storageNamespace = 'adecksibility:' + String(merged.tenant.slug || merged.tenant.id || 'default');
2631
+ var namespaceSeed = '';
2632
+
2633
+ if (typeof merged.host === 'string' && merged.host && merged.host !== 'standalone' && merged.host !== 'generic') {
2634
+ namespaceSeed = merged.host;
2635
+ } else if (merged.tenant && typeof merged.tenant.slug === 'string' && merged.tenant.slug && merged.tenant.slug !== 'default') {
2636
+ namespaceSeed = merged.tenant.slug;
2637
+ } else if (merged.tenant && typeof merged.tenant.id === 'string' && merged.tenant.id && merged.tenant.id !== 'default') {
2638
+ namespaceSeed = merged.tenant.id;
2639
+ } else if (global.location && global.location.host) {
2640
+ namespaceSeed = global.location.host;
2641
+ } else {
2642
+ namespaceSeed = 'default';
2643
+ }
2644
+
2645
+ merged.storageNamespace = 'adecksibility:' + String(namespaceSeed).toLowerCase();
2621
2646
  }
2622
2647
 
2623
2648
  if (typeof merged.statementHtml === 'string' && merged.statementHtml.trim()) {
@@ -2742,9 +2767,11 @@ global.ADecksibility.initWhenReady = initWhenReady;
2742
2767
 
2743
2768
  function ensureDarkModeBootstrap(config) {
2744
2769
  var themeStorageKey = ((config.storageKeys || {}).theme) || 'adeck_theme';
2770
+ var storageNamespace = (config && typeof config.storageNamespace === 'string') ? config.storageNamespace.trim() : '';
2771
+ var resolvedThemeStorageKey = storageNamespace ? (storageNamespace + ':' + themeStorageKey) : themeStorageKey;
2745
2772
  var script = document.getElementById('adeck-dark-mode-bootstrap');
2746
2773
  var contents = "(function(){try{var storedTheme=window.localStorage.getItem(" +
2747
- JSON.stringify(themeStorageKey) +
2774
+ JSON.stringify(resolvedThemeStorageKey) +
2748
2775
  ");if(storedTheme==='dark'){document.documentElement.setAttribute('data-adeck-theme','dark');document.documentElement.classList.add('adeck-dark-mode','adeck-dark-mode-preload');}}catch(error){}}());";
2749
2776
 
2750
2777
  if (!script) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adecksibility-widget",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "description": "Premium standalone accessibility widget bundle for WordPress and non-WordPress sites.",
5
5
  "main": "dist/adecksibility-widget-pro.umd.js",
6
6
  "files": [