@storesjs/stores 0.8.5 → 0.8.6

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.
@@ -1 +1 @@
1
- "use strict";var e="stores:";function t(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function r(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function s(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}var n=class{constructor(t){this.async=!0,this.deserializer=i,this.serializer=o,this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e}async clearAll(){const e=this.ensureStorage();if(!e)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const t=await this.listPrefixedKeys(e,this.storageKeyPrefix);t.length&&await this.execute(e,r=>e.remove(t,r))}async contains(e){const t=this.ensureStorage();if(!t)return!1;const r=this.toStorageKey(e),s=await this.getFromStorage(t,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);await this.execute(t,e=>t.remove(r,e))}async getAllKeys(){const e=this.ensureStorage();if(!e)return[];const t=await this.getFromStorage(e,null),r=this.storageKeyPrefix;return r?Object.keys(t).filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)):Object.keys(t)}async get(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e),s=(await this.getFromStorage(t,r))[r];return a(s)?s:void 0}async set(e,t){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(e);await this.execute(r,e=>r.set({[s]:t},e))}ensureStorage(){return e=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[e]??null:null;var e}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}async listPrefixedKeys(e,t){const r=await this.getFromStorage(e,null);return Object.keys(r).filter(e=>e.startsWith(t))}async getFromStorage(e,t){return this.invokeWithCallbackSupport(r=>e.get(t,r))}async execute(e,t){await this.invokeWithCallbackSupport(t)}async invokeWithCallbackSupport(e){return new Promise((t,r)=>{let s=!1;const n=e=>{if(s)return;s=!0;const n="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;n?r(n):t(e)};try{const t=e(n);(o=t)&&"object"==typeof o&&"then"in o&&"function"==typeof o.then&&t.then(n).catch(r)}catch(e){r(e)}var o})}};function o(e){return{state:c(e.state),syncMetadata:e.syncMetadata,version:e.version}}function i(e){if(!a(e))throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:h(e.state),syncMetadata:e.syncMetadata,version:e.version}}function a(e){return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,"state")}function c(e,s=r){if(e instanceof Map||e instanceof Set)return s.call(void 0,"",e);if(!t(e))return e;const n={};for(const[t,r]of Object.entries(e))n[t]=s.call(e,t,r);return n}function h(e,r=s){const n=r.call(void 0,"",e);if(!t(n))return n;const o={};for(const e of Object.entries(n)){const t=e[0],s=e[1];o[t]=r.call(n,t,s)}return o}var l=class{constructor(t){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(e,t)=>{if(t===this.area)for(const t of this.registrations){const r=t[0],s=t[1];if(s.destroyed)continue;const n=e[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const e=this.parsePersistValue(n.newValue);if(!e||e.syncMetadata?.origin===this.sessionId)continue;const t=e?.syncMetadata,r=this.extractChangedFields(s,e.state,t,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:t?.origin??"unknown",timestamp:t?.timestamp??Date.now(),values:r})}catch(e){continue}}},t&&"storage"in t?(this.area=t.storage.area,this.storageKeyPrefix=t.storage.storageKeyPrefix):(this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e),this.sessionId=this.generateSessionId(),this.attachListener()}generateSessionId(){return"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`}register(e){this.attachListener();const t={destroyed:!1,hydrated:!0,listeners:new Set,registration:e};return this.registrations.set(e.key,t),{destroy:()=>{t.destroyed=!0,t.listeners.clear(),this.registrations.delete(e.key),this.registrations.size||this.detachListener()},publish:null}}attachListener(){"undefined"!=typeof chrome&&chrome.storage&&!this.isListening&&(this.isListening=!0,chrome.storage.onChanged.addListener(this.onStorageChanged))}detachListener(){"undefined"!=typeof chrome&&chrome.storage&&this.isListening&&(chrome.storage.onChanged.removeListener(this.onStorageChanged),this.isListening=!1)}extractChangedFields(e,t,r,s){const n=Object.create(null),o=r?.fields;if(o&&Object.keys(o).length>0){let r=!1;for(const s of e.registration.fields){const e=String(s);Object.prototype.hasOwnProperty.call(o,e)&&(n[s]=t[s],r=!0)}if(r)return n}const i=this.parsePersistValue(s);for(const r of e.registration.fields){const e=t[r],s=i?.state[r];Object.is(e,s)||(n[r]=e)}return n}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}parsePersistValue(e){return i(e)}};exports.ChromeExtensionSyncEngine=l,exports.ChromeStorageAdapter=n,exports.createSyncedChromeStorage=function(e){const t=new n(e);return{storage:t,syncEngine:new l({storage:t})}};
1
+ var e="stores:";function t(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function r(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function s(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}var n=class{constructor(t){this.async=!0,this.deserializer=i,this.serializer=o,this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e}async clearAll(){const e=this.ensureStorage();if(!e)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const t=await this.listPrefixedKeys(e,this.storageKeyPrefix);t.length&&await this.execute(e,r=>e.remove(t,r))}async contains(e){const t=this.ensureStorage();if(!t)return!1;const r=this.toStorageKey(e),s=await this.getFromStorage(t,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);await this.execute(t,e=>t.remove(r,e))}async getAllKeys(){const e=this.ensureStorage();if(!e)return[];const t=await this.getFromStorage(e,null),r=this.storageKeyPrefix;return r?Object.keys(t).filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)):Object.keys(t)}async get(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);return a((await this.getFromStorage(t,r))[r])||void 0}async set(e,t){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(e);await this.execute(r,e=>r.set({[s]:t},e))}ensureStorage(){return e=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[e]??null:null;var e}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}async listPrefixedKeys(e,t){const r=await this.getFromStorage(e,null);return Object.keys(r).filter(e=>e.startsWith(t))}async getFromStorage(e,t){return this.invokeWithCallbackSupport(r=>e.get(t,r))}async execute(e,t){await this.invokeWithCallbackSupport(t)}async invokeWithCallbackSupport(e){return new Promise((t,r)=>{let s=!1;const n=e=>{if(s)return;s=!0;const n="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;n?r(n):t(e)};try{const t=e(n);(o=t)&&"object"==typeof o&&"then"in o&&"function"==typeof o.then&&t.then(n).catch(r)}catch(e){r(e)}var o})}};function o(e){return{state:h(e.state),syncMetadata:e.syncMetadata,version:e.version}}function i(e){const t=a(e);if(!t)throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:u(t.state),syncMetadata:t.syncMetadata,version:t.version}}function a(e){if(c(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);if(c(t))return t}catch{}return null}function c(e){return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,"state")}function h(e,s=r){if(e instanceof Map||e instanceof Set)return s.call(void 0,"",e);if(!t(e))return e;const n={};for(const[t,r]of Object.entries(e))n[t]=s.call(e,t,r);return n}function u(e,r=s){const n=r.call(void 0,"",e);if(!t(n))return n;const o={};for(const e of Object.entries(n)){const t=e[0],s=e[1];o[t]=r.call(n,t,s)}return o}var l=class{constructor(t){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(e,t)=>{if(t===this.area)for(const t of this.registrations){const r=t[0],s=t[1];if(s.destroyed)continue;const n=e[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const e=this.parsePersistValue(n.newValue);if(!e||e.syncMetadata?.origin===this.sessionId)continue;const t=e?.syncMetadata,r=this.extractChangedFields(s,e.state,t,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:t?.origin??"unknown",timestamp:t?.timestamp??Date.now(),values:r})}catch(e){continue}}},t&&"storage"in t?(this.area=t.storage.area,this.storageKeyPrefix=t.storage.storageKeyPrefix):(this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e),this.sessionId=this.generateSessionId(),this.attachListener()}generateSessionId(){return"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`}register(e){this.attachListener();const t={destroyed:!1,hydrated:!0,listeners:new Set,registration:e};return this.registrations.set(e.key,t),{destroy:()=>{t.destroyed=!0,t.listeners.clear(),this.registrations.delete(e.key),this.registrations.size||this.detachListener()},publish:null}}attachListener(){"undefined"!=typeof chrome&&chrome.storage&&!this.isListening&&(this.isListening=!0,chrome.storage.onChanged.addListener(this.onStorageChanged))}detachListener(){"undefined"!=typeof chrome&&chrome.storage&&this.isListening&&(chrome.storage.onChanged.removeListener(this.onStorageChanged),this.isListening=!1)}extractChangedFields(e,t,r,s){const n=Object.create(null),o=r?.fields;if(o&&Object.keys(o).length>0){let r=!1;for(const s of e.registration.fields){const e=String(s);Object.prototype.hasOwnProperty.call(o,e)&&(n[s]=t[s],r=!0)}if(r)return n}const i=this.parsePersistValue(s);for(const r of e.registration.fields){const e=t[r],s=i?.state[r];Object.is(e,s)||(n[r]=e)}return n}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}parsePersistValue(e){return i(e)}};exports.ChromeExtensionSyncEngine=l,exports.ChromeStorageAdapter=n,exports.createSyncedChromeStorage=function(e){const t=new n(e);return{storage:t,syncEngine:new l({storage:t})}};
@@ -1 +1 @@
1
- import{DEFAULT_STORAGE_KEY_PREFIX as e,isPromiseLike as t,replacer as r,reviver as s,isPlainObject as n}from"./chunk-B3GRBY25.mjs";var i=class{constructor(t){this.async=!0,this.deserializer=o,this.serializer=a,this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e}async clearAll(){const e=this.ensureStorage();if(!e)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const t=await this.listPrefixedKeys(e,this.storageKeyPrefix);t.length&&await this.execute(e,r=>e.remove(t,r))}async contains(e){const t=this.ensureStorage();if(!t)return!1;const r=this.toStorageKey(e),s=await this.getFromStorage(t,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);await this.execute(t,e=>t.remove(r,e))}async getAllKeys(){const e=this.ensureStorage();if(!e)return[];const t=await this.getFromStorage(e,null),r=this.storageKeyPrefix;return r?Object.keys(t).filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)):Object.keys(t)}async get(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e),s=(await this.getFromStorage(t,r))[r];return c(s)?s:void 0}async set(e,t){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(e);await this.execute(r,e=>r.set({[s]:t},e))}ensureStorage(){return e=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[e]??null:null;var e}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}async listPrefixedKeys(e,t){const r=await this.getFromStorage(e,null);return Object.keys(r).filter(e=>e.startsWith(t))}async getFromStorage(e,t){return this.invokeWithCallbackSupport(r=>e.get(t,r))}async execute(e,t){await this.invokeWithCallbackSupport(t)}async invokeWithCallbackSupport(e){return new Promise((r,s)=>{let n=!1;const i=e=>{if(n)return;n=!0;const t="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;t?s(t):r(e)};try{const r=e(i);t(r)&&r.then(i).catch(s)}catch(e){s(e)}})}};function a(e){return{state:h(e.state),syncMetadata:e.syncMetadata,version:e.version}}function o(e){if(!c(e))throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:g(e.state),syncMetadata:e.syncMetadata,version:e.version}}function c(e){return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,"state")}function h(e,t=r){if(e instanceof Map||e instanceof Set)return t.call(void 0,"",e);if(!n(e))return e;const s={};for(const[r,n]of Object.entries(e))s[r]=t.call(e,r,n);return s}function g(e,t=s){const r=t.call(void 0,"",e);if(!n(r))return r;const i={};for(const e of Object.entries(r)){const s=e[0],n=e[1];i[s]=t.call(r,s,n)}return i}var l=class{constructor(t){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(e,t)=>{if(t===this.area)for(const t of this.registrations){const r=t[0],s=t[1];if(s.destroyed)continue;const n=e[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const e=this.parsePersistValue(n.newValue);if(!e||e.syncMetadata?.origin===this.sessionId)continue;const t=e?.syncMetadata,r=this.extractChangedFields(s,e.state,t,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:t?.origin??"unknown",timestamp:t?.timestamp??Date.now(),values:r})}catch(e){continue}}},t&&"storage"in t?(this.area=t.storage.area,this.storageKeyPrefix=t.storage.storageKeyPrefix):(this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e),this.sessionId=this.generateSessionId(),this.attachListener()}generateSessionId(){return"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`}register(e){this.attachListener();const t={destroyed:!1,hydrated:!0,listeners:new Set,registration:e};return this.registrations.set(e.key,t),{destroy:()=>{t.destroyed=!0,t.listeners.clear(),this.registrations.delete(e.key),this.registrations.size||this.detachListener()},publish:null}}attachListener(){"undefined"!=typeof chrome&&chrome.storage&&!this.isListening&&(this.isListening=!0,chrome.storage.onChanged.addListener(this.onStorageChanged))}detachListener(){"undefined"!=typeof chrome&&chrome.storage&&this.isListening&&(chrome.storage.onChanged.removeListener(this.onStorageChanged),this.isListening=!1)}extractChangedFields(e,t,r,s){const n=Object.create(null),i=r?.fields;if(i&&Object.keys(i).length>0){let r=!1;for(const s of e.registration.fields){const e=String(s);Object.prototype.hasOwnProperty.call(i,e)&&(n[s]=t[s],r=!0)}if(r)return n}const a=this.parsePersistValue(s);for(const r of e.registration.fields){const e=t[r],s=a?.state[r];Object.is(e,s)||(n[r]=e)}return n}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}parsePersistValue(e){return o(e)}};function u(e){const t=new i(e);return{storage:t,syncEngine:new l({storage:t})}}export{l as ChromeExtensionSyncEngine,i as ChromeStorageAdapter,u as createSyncedChromeStorage};
1
+ import{DEFAULT_STORAGE_KEY_PREFIX as t,isPromiseLike as e,replacer as r,reviver as s,isPlainObject as n}from"./chunk-B3GRBY25.mjs";var i=class{constructor(e){this.async=!0,this.deserializer=a,this.serializer=o,this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??t}async clearAll(){const t=this.ensureStorage();if(!t)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const e=await this.listPrefixedKeys(t,this.storageKeyPrefix);e.length&&await this.execute(t,r=>t.remove(e,r))}async contains(t){const e=this.ensureStorage();if(!e)return!1;const r=this.toStorageKey(t),s=await this.getFromStorage(e,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(t){const e=this.ensureStorage();if(!e)return;const r=this.toStorageKey(t);await this.execute(e,t=>e.remove(r,t))}async getAllKeys(){const t=this.ensureStorage();if(!t)return[];const e=await this.getFromStorage(t,null),r=this.storageKeyPrefix;return r?Object.keys(e).filter(t=>t.startsWith(r)).map(t=>t.slice(r.length)):Object.keys(e)}async get(t){const e=this.ensureStorage();if(!e)return;const r=this.toStorageKey(t);return c((await this.getFromStorage(e,r))[r])||void 0}async set(t,e){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(t);await this.execute(r,t=>r.set({[s]:e},t))}ensureStorage(){return t=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[t]??null:null;var t}toStorageKey(t){return this.storageKeyPrefix?`${this.storageKeyPrefix}${t}`:t}async listPrefixedKeys(t,e){const r=await this.getFromStorage(t,null);return Object.keys(r).filter(t=>t.startsWith(e))}async getFromStorage(t,e){return this.invokeWithCallbackSupport(r=>t.get(e,r))}async execute(t,e){await this.invokeWithCallbackSupport(e)}async invokeWithCallbackSupport(t){return new Promise((r,s)=>{let n=!1;const i=t=>{if(n)return;n=!0;const e="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;e?s(e):r(t)};try{const r=t(i);e(r)&&r.then(i).catch(s)}catch(t){s(t)}})}};function o(t){return{state:g(t.state),syncMetadata:t.syncMetadata,version:t.version}}function a(t){const e=c(t);if(!e)throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:l(e.state),syncMetadata:e.syncMetadata,version:e.version}}function c(t){if(h(t))return t;if("string"==typeof t)try{const e=JSON.parse(t);if(h(e))return e}catch{}return null}function h(t){return!(!t||"object"!=typeof t)&&Object.prototype.hasOwnProperty.call(t,"state")}function g(t,e=r){if(t instanceof Map||t instanceof Set)return e.call(void 0,"",t);if(!n(t))return t;const s={};for(const[r,n]of Object.entries(t))s[r]=e.call(t,r,n);return s}function l(t,e=s){const r=e.call(void 0,"",t);if(!n(r))return r;const i={};for(const t of Object.entries(r)){const s=t[0],n=t[1];i[s]=e.call(r,s,n)}return i}var u=class{constructor(e){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(t,e)=>{if(e===this.area)for(const e of this.registrations){const r=e[0],s=e[1];if(s.destroyed)continue;const n=t[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const t=this.parsePersistValue(n.newValue);if(!t||t.syncMetadata?.origin===this.sessionId)continue;const e=t?.syncMetadata,r=this.extractChangedFields(s,t.state,e,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:e?.origin??"unknown",timestamp:e?.timestamp??Date.now(),values:r})}catch(t){continue}}},e&&"storage"in e?(this.area=e.storage.area,this.storageKeyPrefix=e.storage.storageKeyPrefix):(this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??t),this.sessionId=this.generateSessionId(),this.attachListener()}generateSessionId(){return"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`}register(t){this.attachListener();const e={destroyed:!1,hydrated:!0,listeners:new Set,registration:t};return this.registrations.set(t.key,e),{destroy:()=>{e.destroyed=!0,e.listeners.clear(),this.registrations.delete(t.key),this.registrations.size||this.detachListener()},publish:null}}attachListener(){"undefined"!=typeof chrome&&chrome.storage&&!this.isListening&&(this.isListening=!0,chrome.storage.onChanged.addListener(this.onStorageChanged))}detachListener(){"undefined"!=typeof chrome&&chrome.storage&&this.isListening&&(chrome.storage.onChanged.removeListener(this.onStorageChanged),this.isListening=!1)}extractChangedFields(t,e,r,s){const n=Object.create(null),i=r?.fields;if(i&&Object.keys(i).length>0){let r=!1;for(const s of t.registration.fields){const t=String(s);Object.prototype.hasOwnProperty.call(i,t)&&(n[s]=e[s],r=!0)}if(r)return n}const o=this.parsePersistValue(s);for(const r of t.registration.fields){const t=e[r],s=o?.state[r];Object.is(t,s)||(n[r]=t)}return n}toStorageKey(t){return this.storageKeyPrefix?`${this.storageKeyPrefix}${t}`:t}parsePersistValue(t){return a(t)}};function f(t){const e=new i(t);return{storage:e,syncEngine:new u({storage:e})}}export{u as ChromeExtensionSyncEngine,i as ChromeStorageAdapter,f as createSyncedChromeStorage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storesjs/stores",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "repository": {