react-native-onyx 1.0.62 → 1.0.63

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.
@@ -2164,7 +2164,15 @@ __webpack_require__.r(__webpack_exports__);
2164
2164
 
2165
2165
 
2166
2166
 
2167
- const customStore = (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.createStore)('OnyxDB', 'keyvaluepairs');
2167
+ // We don't want to initialize the store while the JS bundle loads as idb-keyval will try to use global.indexedDB
2168
+ // which might not be available in certain environments that load the bundle (e.g. electron main process).
2169
+ let customStoreInstance;
2170
+ const getCustomStore = () => {
2171
+ if (!customStoreInstance) {
2172
+ customStoreInstance = (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.createStore)('OnyxDB', 'keyvaluepairs');
2173
+ }
2174
+ return customStoreInstance;
2175
+ };
2168
2176
 
2169
2177
  const provider = {
2170
2178
  /**
@@ -2173,7 +2181,7 @@ const provider = {
2173
2181
  * @param {*} value
2174
2182
  * @return {Promise<void>}
2175
2183
  */
2176
- setItem: (key, value) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.set)(key, value, customStore),
2184
+ setItem: (key, value) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.set)(key, value, getCustomStore()),
2177
2185
 
2178
2186
  /**
2179
2187
  * Get multiple key-value pairs for the give array of keys in a batch.
@@ -2181,7 +2189,7 @@ const provider = {
2181
2189
  * @param {String[]} keysParam
2182
2190
  * @return {Promise<Array<[key, value]>>}
2183
2191
  */
2184
- multiGet: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.getMany)(keysParam, customStore).
2192
+ multiGet: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.getMany)(keysParam, getCustomStore()).
2185
2193
  then((values) => underscore__WEBPACK_IMPORTED_MODULE_1___default().map(values, (value, index) => [keysParam[index], value])),
2186
2194
 
2187
2195
  /**
@@ -2189,7 +2197,7 @@ const provider = {
2189
2197
  * @param {Array<[key, value]>} pairs
2190
2198
  * @return {Promise<void>}
2191
2199
  */
2192
- multiMerge: (pairs) => customStore('readwrite', (store) => {
2200
+ multiMerge: (pairs) => getCustomStore()('readwrite', (store) => {
2193
2201
  // Note: we are using the manual store transaction here, to fit the read and update
2194
2202
  // of the items in one transaction to achieve best performance.
2195
2203
 
@@ -2221,33 +2229,33 @@ const provider = {
2221
2229
  * @param {Array<[key, value]>} pairs
2222
2230
  * @return {Promise<void>}
2223
2231
  */
2224
- multiSet: (pairs) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.setMany)(pairs, customStore),
2232
+ multiSet: (pairs) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.setMany)(pairs, getCustomStore()),
2225
2233
 
2226
2234
  /**
2227
2235
  * Clear everything from storage and also stops the SyncQueue from adding anything more to storage
2228
2236
  * @returns {Promise<void>}
2229
2237
  */
2230
- clear: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.clear)(customStore),
2238
+ clear: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.clear)(getCustomStore()),
2231
2239
 
2232
2240
  /**
2233
2241
  * Returns all keys available in storage
2234
2242
  * @returns {Promise<String[]>}
2235
2243
  */
2236
- getAllKeys: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.keys)(customStore),
2244
+ getAllKeys: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.keys)(getCustomStore()),
2237
2245
 
2238
2246
  /**
2239
2247
  * Get the value of a given key or return `null` if it's not available in storage
2240
2248
  * @param {String} key
2241
2249
  * @return {Promise<*>}
2242
2250
  */
2243
- getItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.get)(key, customStore),
2251
+ getItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.get)(key, getCustomStore()),
2244
2252
 
2245
2253
  /**
2246
2254
  * Remove given key and it's value from storage
2247
2255
  * @param {String} key
2248
2256
  * @returns {Promise<void>}
2249
2257
  */
2250
- removeItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.del)(key, customStore),
2258
+ removeItem: (key) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.del)(key, getCustomStore()),
2251
2259
 
2252
2260
  /**
2253
2261
  * Remove given keys and their values from storage
@@ -2255,7 +2263,7 @@ const provider = {
2255
2263
  * @param {Array} keysParam
2256
2264
  * @returns {Promise}
2257
2265
  */
2258
- removeItems: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.delMany)(keysParam, customStore)
2266
+ removeItems: (keysParam) => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.delMany)(keysParam, getCustomStore())
2259
2267
  };
2260
2268
 
2261
2269
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (provider);