@flopflip/launchdarkly-adapter 13.3.0 → 13.3.2

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.
@@ -6,5 +6,5 @@ declare function getCache(cacheIdentifier: TCacheIdentifiers, cacheKey: LDContex
6
6
  get(): any;
7
7
  unset(): any;
8
8
  }>;
9
- declare function getCachedFlags(cacheIdentifier: TCacheIdentifiers): Promise<any>;
9
+ declare function getCachedFlags(cacheIdentifier: TCacheIdentifiers): any;
10
10
  export { CACHE_PREFIX, getCache, getCachedFlags };
@@ -86,19 +86,18 @@ async function getCache(cacheIdentifier, cacheKey) {
86
86
  }
87
87
  };
88
88
  }
89
- async function getCachedFlags(cacheIdentifier) {
90
- const cacheModule = await importCache(cacheIdentifier);
91
- const createCache = cacheModule.default;
92
- const referenceCache = createCache({
93
- prefix: CACHE_PREFIX
94
- });
95
- const reference = referenceCache.get(FLAGS_REFERENCE_KEY);
96
- if (reference) {
97
- // Cache without prefix as the reference is already prefixed.
98
- const flagsCache = createCache({
99
- prefix: ''
100
- });
101
- return flagsCache.get(reference);
89
+ function getCachedFlags(cacheIdentifier) {
90
+ const cacheModule = cacheIdentifier === types.cacheIdentifiers.local ? localStorage : sessionStorage;
91
+ const referenceToCachedFlags = cacheModule.getItem(FLAGS_REFERENCE_KEY);
92
+ if (referenceToCachedFlags) {
93
+ try {
94
+ const cacheKey = JSON.parse(referenceToCachedFlags);
95
+ const cachedFlags = cacheModule.getItem(cacheKey);
96
+ if (cacheKey && cachedFlags) {
97
+ return JSON.parse(cachedFlags);
98
+ }
99
+ return {};
100
+ } catch (error) {}
102
101
  }
103
102
  }
104
103
 
@@ -419,7 +418,7 @@ class LaunchDarklyAdapter {
419
418
  const adapter = new LaunchDarklyAdapter();
420
419
  adapterUtilities.exposeGlobally(adapter);
421
420
 
422
- const version = "13.3.0";
421
+ const version = "13.3.2";
423
422
 
424
423
  exports["default"] = adapter;
425
424
  exports.getCachedFlags = getCachedFlags;
@@ -86,19 +86,18 @@ async function getCache(cacheIdentifier, cacheKey) {
86
86
  }
87
87
  };
88
88
  }
89
- async function getCachedFlags(cacheIdentifier) {
90
- const cacheModule = await importCache(cacheIdentifier);
91
- const createCache = cacheModule.default;
92
- const referenceCache = createCache({
93
- prefix: CACHE_PREFIX
94
- });
95
- const reference = referenceCache.get(FLAGS_REFERENCE_KEY);
96
- if (reference) {
97
- // Cache without prefix as the reference is already prefixed.
98
- const flagsCache = createCache({
99
- prefix: ''
100
- });
101
- return flagsCache.get(reference);
89
+ function getCachedFlags(cacheIdentifier) {
90
+ const cacheModule = cacheIdentifier === types.cacheIdentifiers.local ? localStorage : sessionStorage;
91
+ const referenceToCachedFlags = cacheModule.getItem(FLAGS_REFERENCE_KEY);
92
+ if (referenceToCachedFlags) {
93
+ try {
94
+ const cacheKey = JSON.parse(referenceToCachedFlags);
95
+ const cachedFlags = cacheModule.getItem(cacheKey);
96
+ if (cacheKey && cachedFlags) {
97
+ return JSON.parse(cachedFlags);
98
+ }
99
+ return {};
100
+ } catch (error) {}
102
101
  }
103
102
  }
104
103
 
@@ -419,7 +418,7 @@ class LaunchDarklyAdapter {
419
418
  const adapter = new LaunchDarklyAdapter();
420
419
  adapterUtilities.exposeGlobally(adapter);
421
420
 
422
- const version = "13.3.0";
421
+ const version = "13.3.2";
423
422
 
424
423
  exports["default"] = adapter;
425
424
  exports.getCachedFlags = getCachedFlags;
@@ -57,19 +57,18 @@ async function getCache(cacheIdentifier, cacheKey) {
57
57
  }
58
58
  };
59
59
  }
60
- async function getCachedFlags(cacheIdentifier) {
61
- const cacheModule = await importCache(cacheIdentifier);
62
- const createCache = cacheModule.default;
63
- const referenceCache = createCache({
64
- prefix: CACHE_PREFIX
65
- });
66
- const reference = referenceCache.get(FLAGS_REFERENCE_KEY);
67
- if (reference) {
68
- // Cache without prefix as the reference is already prefixed.
69
- const flagsCache = createCache({
70
- prefix: ''
71
- });
72
- return flagsCache.get(reference);
60
+ function getCachedFlags(cacheIdentifier) {
61
+ const cacheModule = cacheIdentifier === cacheIdentifiers.local ? localStorage : sessionStorage;
62
+ const referenceToCachedFlags = cacheModule.getItem(FLAGS_REFERENCE_KEY);
63
+ if (referenceToCachedFlags) {
64
+ try {
65
+ const cacheKey = JSON.parse(referenceToCachedFlags);
66
+ const cachedFlags = cacheModule.getItem(cacheKey);
67
+ if (cacheKey && cachedFlags) {
68
+ return JSON.parse(cachedFlags);
69
+ }
70
+ return {};
71
+ } catch (error) {}
73
72
  }
74
73
  }
75
74
 
@@ -390,6 +389,6 @@ class LaunchDarklyAdapter {
390
389
  const adapter = new LaunchDarklyAdapter();
391
390
  exposeGlobally(adapter);
392
391
 
393
- const version = "13.3.0";
392
+ const version = "13.3.2";
394
393
 
395
394
  export { adapter as default, getCachedFlags, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopflip/launchdarkly-adapter",
3
- "version": "13.3.0",
3
+ "version": "13.3.2",
4
4
  "description": "A adapter around the LaunchDarkly client for flipflop",
5
5
  "main": "dist/flopflip-launchdarkly-adapter.cjs.js",
6
6
  "module": "dist/flopflip-launchdarkly-adapter.esm.js",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@babel/runtime": "7.24.0",
30
- "@flopflip/adapter-utilities": "13.3.0",
31
- "@flopflip/localstorage-cache": "13.3.0",
32
- "@flopflip/sessionstorage-cache": "13.3.0",
33
- "@flopflip/types": "13.3.0",
30
+ "@flopflip/adapter-utilities": "13.3.2",
31
+ "@flopflip/localstorage-cache": "13.3.2",
32
+ "@flopflip/sessionstorage-cache": "13.3.2",
33
+ "@flopflip/types": "13.3.2",
34
34
  "debounce-fn": "4.0.0",
35
35
  "launchdarkly-js-client-sdk": "3.1.4",
36
36
  "lodash": "4.17.21",