@converse/skeletor 3.1.4 → 3.1.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.
package/dist/skeletor.js CHANGED
@@ -1977,7 +1977,7 @@
1977
1977
  return (options.name || defaultConfig.name) + "/" + (options.storeName || defaultConfig.storeName) + "/";
1978
1978
  }
1979
1979
 
1980
- function executeCallback$1(promise, callback) {
1980
+ function executeCallback(promise, callback) {
1981
1981
  if (callback) {
1982
1982
  promise.then(function (result) {
1983
1983
  callback(null, result);
@@ -2118,7 +2118,7 @@
2118
2118
  var promise = this.ready().then(function () {
2119
2119
  _this._dbInfo.mStore.clear();
2120
2120
  });
2121
- executeCallback$1(promise, callback);
2121
+ executeCallback(promise, callback);
2122
2122
  return promise;
2123
2123
  }
2124
2124
 
@@ -2127,7 +2127,7 @@
2127
2127
  var outPromise = promise.then(function (keyPrefix) {
2128
2128
  Store.resolve(keyPrefix).drop();
2129
2129
  });
2130
- executeCallback$1(outPromise, callback);
2130
+ executeCallback(outPromise, callback);
2131
2131
  return promise;
2132
2132
  }
2133
2133
 
@@ -2139,7 +2139,7 @@
2139
2139
  // Deserialise if the result is not null or undefined
2140
2140
  return result == null ? null : _this._dbInfo.serializer.deserialize(result); //tslint:disable-line:triple-equals
2141
2141
  });
2142
- executeCallback$1(promise, callback);
2142
+ executeCallback(promise, callback);
2143
2143
  return promise;
2144
2144
  }
2145
2145
 
@@ -2163,7 +2163,7 @@
2163
2163
  }
2164
2164
  }
2165
2165
  });
2166
- executeCallback$1(promise, callback);
2166
+ executeCallback(promise, callback);
2167
2167
  return promise;
2168
2168
  }
2169
2169
 
@@ -2182,7 +2182,7 @@
2182
2182
  }
2183
2183
  return result;
2184
2184
  });
2185
- executeCallback$1(promise, callback);
2185
+ executeCallback(promise, callback);
2186
2186
  return promise;
2187
2187
  }
2188
2188
 
@@ -2191,13 +2191,13 @@
2191
2191
  var promise = this.ready().then(function () {
2192
2192
  return _this._dbInfo.mStore.keys();
2193
2193
  });
2194
- executeCallback$1(promise, callback);
2194
+ executeCallback(promise, callback);
2195
2195
  return promise;
2196
2196
  }
2197
2197
 
2198
2198
  function length$1(callback) {
2199
2199
  var promise = this.keys().then(function (keys$) { return keys$.length; });
2200
- executeCallback$1(promise, callback);
2200
+ executeCallback(promise, callback);
2201
2201
  return promise;
2202
2202
  }
2203
2203
 
@@ -2207,7 +2207,7 @@
2207
2207
  var promise = this.ready().then(function () {
2208
2208
  _this._dbInfo.mStore.rm(key$);
2209
2209
  });
2210
- executeCallback$1(promise, callback);
2210
+ executeCallback(promise, callback);
2211
2211
  return promise;
2212
2212
  }
2213
2213
 
@@ -2237,7 +2237,7 @@
2237
2237
  });
2238
2238
  });
2239
2239
  });
2240
- executeCallback$1(promise, callback);
2240
+ executeCallback(promise, callback);
2241
2241
  return promise;
2242
2242
  }
2243
2243
 
@@ -7887,253 +7887,282 @@
7887
7887
 
7888
7888
  var localforageSetitemsExports = requireLocalforageSetitems();
7889
7889
 
7890
- function getSerializerPromise(localForageInstance) {
7891
- if (getSerializerPromise.result) {
7892
- return getSerializerPromise.result;
7893
- }
7894
- if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7895
- return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7896
- }
7897
- getSerializerPromise.result = localForageInstance.getSerializer();
7898
- return getSerializerPromise.result;
7899
- }
7890
+ var localforageGetitems$1 = {exports: {}};
7900
7891
 
7892
+ var localforageGetitems = localforageGetitems$1.exports;
7901
7893
 
7894
+ var hasRequiredLocalforageGetitems;
7902
7895
 
7903
- function executeCallback(promise, callback) {
7904
- if (callback) {
7905
- promise.then(function (result) {
7906
- callback(null, result);
7907
- }, function (error) {
7908
- callback(error);
7909
- });
7910
- }
7911
- return promise;
7912
- }
7896
+ function requireLocalforageGetitems () {
7897
+ if (hasRequiredLocalforageGetitems) return localforageGetitems$1.exports;
7898
+ hasRequiredLocalforageGetitems = 1;
7899
+ (function (module, exports) {
7900
+ (function (global, factory) {
7901
+ factory(exports, requireLocalforage()) ;
7902
+ }(localforageGetitems, (function (exports,localforage) {
7903
+ localforage = 'default' in localforage ? localforage['default'] : localforage;
7913
7904
 
7914
- function getItemKeyValue(key, callback) {
7915
- var localforageInstance = this;
7916
- var promise = localforageInstance.getItem(key).then(function (value) {
7917
- return {
7918
- key: key,
7919
- value: value
7920
- };
7921
- });
7922
- executeCallback(promise, callback);
7923
- return promise;
7924
- }
7905
+ function getSerializerPromise(localForageInstance) {
7906
+ if (getSerializerPromise.result) {
7907
+ return getSerializerPromise.result;
7908
+ }
7909
+ if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7910
+ return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7911
+ }
7912
+ getSerializerPromise.result = localForageInstance.getSerializer();
7913
+ return getSerializerPromise.result;
7914
+ }
7925
7915
 
7926
- function getItemsGeneric(keys /*, callback*/) {
7927
- var localforageInstance = this;
7928
- var promise = new Promise(function (resolve, reject) {
7929
- var itemPromises = [];
7930
7916
 
7931
- for (var i = 0, len = keys.length; i < len; i++) {
7932
- itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7933
- }
7934
7917
 
7935
- Promise.all(itemPromises).then(function (keyValuePairs) {
7936
- var result = {};
7937
- for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7938
- var keyValuePair = keyValuePairs[i];
7918
+ function executeCallback(promise, callback) {
7919
+ if (callback) {
7920
+ promise.then(function (result) {
7921
+ callback(null, result);
7922
+ }, function (error) {
7923
+ callback(error);
7924
+ });
7925
+ }
7926
+ return promise;
7927
+ }
7939
7928
 
7940
- result[keyValuePair.key] = keyValuePair.value;
7941
- }
7942
- resolve(result);
7943
- }).catch(reject);
7944
- });
7945
- return promise;
7946
- }
7929
+ function getItemKeyValue(key, callback) {
7930
+ var localforageInstance = this;
7931
+ var promise = localforageInstance.getItem(key).then(function (value) {
7932
+ return {
7933
+ key: key,
7934
+ value: value
7935
+ };
7936
+ });
7937
+ executeCallback(promise, callback);
7938
+ return promise;
7939
+ }
7947
7940
 
7941
+ function getItemsGeneric(keys /*, callback*/) {
7942
+ var localforageInstance = this;
7943
+ var promise = new Promise(function (resolve, reject) {
7944
+ var itemPromises = [];
7948
7945
 
7946
+ for (var i = 0, len = keys.length; i < len; i++) {
7947
+ itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7948
+ }
7949
7949
 
7950
+ Promise.all(itemPromises).then(function (keyValuePairs) {
7951
+ var result = {};
7952
+ for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7953
+ var keyValuePair = keyValuePairs[i];
7950
7954
 
7955
+ result[keyValuePair.key] = keyValuePair.value;
7956
+ }
7957
+ resolve(result);
7958
+ }).catch(reject);
7959
+ });
7960
+ return promise;
7961
+ }
7951
7962
 
7952
- function getAllItemsUsingIterate() {
7953
- var localforageInstance = this;
7954
- var accumulator = {};
7955
- return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7956
- accumulator[key] = value;
7957
- }).then(function () {
7958
- return accumulator;
7959
- });
7960
- }
7961
7963
 
7962
- function getIDBKeyRange() {
7963
- /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7964
- if (typeof IDBKeyRange !== 'undefined') {
7965
- return IDBKeyRange;
7966
- }
7967
- if (typeof webkitIDBKeyRange !== 'undefined') {
7968
- return webkitIDBKeyRange;
7969
- }
7970
- if (typeof mozIDBKeyRange !== 'undefined') {
7971
- return mozIDBKeyRange;
7972
- }
7973
- }
7974
7964
 
7975
- var idbKeyRange = getIDBKeyRange();
7976
7965
 
7977
- function getItemsIndexedDB(keys /*, callback*/) {
7978
- keys = keys.slice();
7979
- var localforageInstance = this;
7980
- function comparer(a, b) {
7981
- return a < b ? -1 : a > b ? 1 : 0;
7982
- }
7983
7966
 
7984
- var promise = new Promise(function (resolve, reject) {
7985
- localforageInstance.ready().then(function () {
7986
- // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
7987
- var dbInfo = localforageInstance._dbInfo;
7988
- var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
7967
+ function getAllItemsUsingIterate() {
7968
+ var localforageInstance = this;
7969
+ var accumulator = {};
7970
+ return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7971
+ accumulator[key] = value;
7972
+ }).then(function () {
7973
+ return accumulator;
7974
+ });
7975
+ }
7989
7976
 
7990
- var set = keys.sort(comparer);
7977
+ function getIDBKeyRange() {
7978
+ /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7979
+ if (typeof IDBKeyRange !== 'undefined') {
7980
+ return IDBKeyRange;
7981
+ }
7982
+ if (typeof webkitIDBKeyRange !== 'undefined') {
7983
+ return webkitIDBKeyRange;
7984
+ }
7985
+ if (typeof mozIDBKeyRange !== 'undefined') {
7986
+ return mozIDBKeyRange;
7987
+ }
7988
+ }
7991
7989
 
7992
- var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
7990
+ var idbKeyRange = getIDBKeyRange();
7993
7991
 
7994
- var req;
7992
+ function getItemsIndexedDB(keys /*, callback*/) {
7993
+ keys = keys.slice();
7994
+ var localforageInstance = this;
7995
+ function comparer(a, b) {
7996
+ return a < b ? -1 : a > b ? 1 : 0;
7997
+ }
7995
7998
 
7996
- if ('getAll' in store) {
7997
- req = store.getAll(keyRangeValue);
7998
- req.onsuccess = function () {
7999
- var value = req.result;
8000
- if (value === undefined) {
8001
- value = null;
8002
- }
8003
- resolve(value);
8004
- };
8005
- } else {
8006
- req = store.openCursor(keyRangeValue);
8007
- var result = {};
8008
- var i = 0;
7999
+ var promise = new Promise(function (resolve, reject) {
8000
+ localforageInstance.ready().then(function () {
8001
+ // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
8002
+ var dbInfo = localforageInstance._dbInfo;
8003
+ var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
8009
8004
 
8010
- req.onsuccess = function () /*event*/{
8011
- var cursor = req.result; // event.target.result;
8005
+ var set = keys.sort(comparer);
8012
8006
 
8013
- if (!cursor) {
8014
- resolve(result);
8015
- return;
8016
- }
8007
+ var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
8017
8008
 
8018
- var key = cursor.key;
8009
+ var req;
8019
8010
 
8020
- while (key > set[i]) {
8021
- i++; // The cursor has passed beyond this key. Check next.
8011
+ if ('getAll' in store) {
8012
+ req = store.getAll(keyRangeValue);
8013
+ req.onsuccess = function () {
8014
+ var value = req.result;
8015
+ if (value === undefined) {
8016
+ value = null;
8017
+ }
8018
+ resolve(value);
8019
+ };
8020
+ } else {
8021
+ req = store.openCursor(keyRangeValue);
8022
+ var result = {};
8023
+ var i = 0;
8022
8024
 
8023
- if (i === set.length) {
8024
- // There is no next. Stop searching.
8025
- resolve(result);
8026
- return;
8027
- }
8028
- }
8025
+ req.onsuccess = function () /*event*/{
8026
+ var cursor = req.result; // event.target.result;
8029
8027
 
8030
- if (key === set[i]) {
8031
- // The current cursor value should be included and we should continue
8032
- // a single step in case next item has the same key or possibly our
8033
- // next key in set.
8034
- var value = cursor.value;
8035
- if (value === undefined) {
8036
- value = null;
8037
- }
8028
+ if (!cursor) {
8029
+ resolve(result);
8030
+ return;
8031
+ }
8038
8032
 
8039
- result[key] = value;
8040
- // onfound(cursor.value);
8041
- cursor.continue();
8042
- } else {
8043
- // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
8044
- cursor.continue(set[i]);
8045
- }
8046
- };
8047
- }
8033
+ var key = cursor.key;
8048
8034
 
8049
- req.onerror = function () /*event*/{
8050
- reject(req.error);
8051
- };
8052
- }).catch(reject);
8053
- });
8054
- return promise;
8055
- }
8035
+ while (key > set[i]) {
8036
+ i++; // The cursor has passed beyond this key. Check next.
8056
8037
 
8057
- function getItemsWebsql(keys /*, callback*/) {
8058
- var localforageInstance = this;
8059
- var promise = new Promise(function (resolve, reject) {
8060
- localforageInstance.ready().then(function () {
8061
- return getSerializerPromise(localforageInstance);
8062
- }).then(function (serializer) {
8063
- var dbInfo = localforageInstance._dbInfo;
8064
- dbInfo.db.transaction(function (t) {
8038
+ if (i === set.length) {
8039
+ // There is no next. Stop searching.
8040
+ resolve(result);
8041
+ return;
8042
+ }
8043
+ }
8065
8044
 
8066
- var queryParts = new Array(keys.length);
8067
- for (var i = 0, len = keys.length; i < len; i++) {
8068
- queryParts[i] = '?';
8069
- }
8045
+ if (key === set[i]) {
8046
+ // The current cursor value should be included and we should continue
8047
+ // a single step in case next item has the same key or possibly our
8048
+ // next key in set.
8049
+ var value = cursor.value;
8050
+ if (value === undefined) {
8051
+ value = null;
8052
+ }
8070
8053
 
8071
- t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
8054
+ result[key] = value;
8055
+ // onfound(cursor.value);
8056
+ cursor.continue();
8057
+ } else {
8058
+ // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
8059
+ cursor.continue(set[i]);
8060
+ }
8061
+ };
8062
+ }
8072
8063
 
8073
- var result = {};
8064
+ req.onerror = function () /*event*/{
8065
+ reject(req.error);
8066
+ };
8067
+ }).catch(reject);
8068
+ });
8069
+ return promise;
8070
+ }
8074
8071
 
8075
- var rows = results.rows;
8076
- for (var i = 0, len = rows.length; i < len; i++) {
8077
- var item = rows.item(i);
8078
- var value = item.value;
8072
+ function getItemsWebsql(keys /*, callback*/) {
8073
+ var localforageInstance = this;
8074
+ var promise = new Promise(function (resolve, reject) {
8075
+ localforageInstance.ready().then(function () {
8076
+ return getSerializerPromise(localforageInstance);
8077
+ }).then(function (serializer) {
8078
+ var dbInfo = localforageInstance._dbInfo;
8079
+ dbInfo.db.transaction(function (t) {
8079
8080
 
8080
- // Check to see if this is serialized content we need to
8081
- // unpack.
8082
- if (value) {
8083
- value = serializer.deserialize(value);
8084
- }
8081
+ var queryParts = new Array(keys.length);
8082
+ for (var i = 0, len = keys.length; i < len; i++) {
8083
+ queryParts[i] = '?';
8084
+ }
8085
8085
 
8086
- result[item.key] = value;
8087
- }
8086
+ t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
8088
8087
 
8089
- resolve(result);
8090
- }, function (t, error) {
8091
- reject(error);
8092
- });
8093
- });
8094
- }).catch(reject);
8095
- });
8096
- return promise;
8097
- }
8088
+ var result = {};
8098
8089
 
8099
- function localforageGetItems(keys, callback) {
8100
- var localforageInstance = this;
8090
+ var rows = results.rows;
8091
+ for (var i = 0, len = rows.length; i < len; i++) {
8092
+ var item = rows.item(i);
8093
+ var value = item.value;
8101
8094
 
8102
- var promise;
8103
- if (!arguments.length || keys === null) {
8104
- promise = getAllItemsUsingIterate.apply(localforageInstance);
8105
- } else {
8106
- var currentDriver = localforageInstance.driver();
8107
- if (currentDriver === localforageInstance.INDEXEDDB) {
8108
- promise = getItemsIndexedDB.apply(localforageInstance, arguments);
8109
- } else if (currentDriver === localforageInstance.WEBSQL) {
8110
- promise = getItemsWebsql.apply(localforageInstance, arguments);
8111
- } else {
8112
- promise = getItemsGeneric.apply(localforageInstance, arguments);
8113
- }
8114
- }
8095
+ // Check to see if this is serialized content we need to
8096
+ // unpack.
8097
+ if (value) {
8098
+ value = serializer.deserialize(value);
8099
+ }
8115
8100
 
8116
- executeCallback(promise, callback);
8117
- return promise;
8118
- }
8101
+ result[item.key] = value;
8102
+ }
8119
8103
 
8120
- function extendPrototype(localforage$$1) {
8121
- var localforagePrototype = Object.getPrototypeOf(localforage$$1);
8122
- if (localforagePrototype) {
8123
- localforagePrototype.getItems = localforageGetItems;
8124
- localforagePrototype.getItems.indexedDB = function () {
8125
- return getItemsIndexedDB.apply(this, arguments);
8126
- };
8127
- localforagePrototype.getItems.websql = function () {
8128
- return getItemsWebsql.apply(this, arguments);
8129
- };
8130
- localforagePrototype.getItems.generic = function () {
8131
- return getItemsGeneric.apply(this, arguments);
8132
- };
8133
- }
8104
+ resolve(result);
8105
+ }, function (t, error) {
8106
+ reject(error);
8107
+ });
8108
+ });
8109
+ }).catch(reject);
8110
+ });
8111
+ return promise;
8112
+ }
8113
+
8114
+ function localforageGetItems(keys, callback) {
8115
+ var localforageInstance = this;
8116
+
8117
+ var promise;
8118
+ if (!arguments.length || keys === null) {
8119
+ promise = getAllItemsUsingIterate.apply(localforageInstance);
8120
+ } else {
8121
+ var currentDriver = localforageInstance.driver();
8122
+ if (currentDriver === localforageInstance.INDEXEDDB) {
8123
+ promise = getItemsIndexedDB.apply(localforageInstance, arguments);
8124
+ } else if (currentDriver === localforageInstance.WEBSQL) {
8125
+ promise = getItemsWebsql.apply(localforageInstance, arguments);
8126
+ } else {
8127
+ promise = getItemsGeneric.apply(localforageInstance, arguments);
8128
+ }
8129
+ }
8130
+
8131
+ executeCallback(promise, callback);
8132
+ return promise;
8133
+ }
8134
+
8135
+ function extendPrototype(localforage$$1) {
8136
+ var localforagePrototype = Object.getPrototypeOf(localforage$$1);
8137
+ if (localforagePrototype) {
8138
+ localforagePrototype.getItems = localforageGetItems;
8139
+ localforagePrototype.getItems.indexedDB = function () {
8140
+ return getItemsIndexedDB.apply(this, arguments);
8141
+ };
8142
+ localforagePrototype.getItems.websql = function () {
8143
+ return getItemsWebsql.apply(this, arguments);
8144
+ };
8145
+ localforagePrototype.getItems.generic = function () {
8146
+ return getItemsGeneric.apply(this, arguments);
8147
+ };
8148
+ }
8149
+ }
8150
+
8151
+ var extendPrototypeResult = extendPrototype(localforage);
8152
+
8153
+ exports.localforageGetItems = localforageGetItems;
8154
+ exports.extendPrototype = extendPrototype;
8155
+ exports.extendPrototypeResult = extendPrototypeResult;
8156
+ exports.getItemsGeneric = getItemsGeneric;
8157
+
8158
+ Object.defineProperty(exports, '__esModule', { value: true });
8159
+
8160
+ })));
8161
+ } (localforageGetitems$1, localforageGetitems$1.exports));
8162
+ return localforageGetitems$1.exports;
8134
8163
  }
8135
8164
 
8136
- extendPrototype(localForage);
8165
+ var localforageGetitemsExports = requireLocalforageGetitems();
8137
8166
 
8138
8167
  /** Used for built-in method references. */
8139
8168
  var objectProto$7 = Object.prototype;
@@ -8586,7 +8615,7 @@
8586
8615
  const IN_MEMORY = _driver;
8587
8616
  localForage.defineDriver(memoryDriver);
8588
8617
  localforageSetitemsExports.extendPrototype(localForage);
8589
- extendPrototype(localForage);
8618
+ localforageGetitemsExports.extendPrototype(localForage);
8590
8619
  // Every storage instance is registered with a WeakRef so that flushAll() can
8591
8620
  // reach pending writes without keeping instances alive. There's no leak and no
8592
8621
  // lifecycle hook to maintain: an instance is collected once its owning model or
@@ -8676,7 +8705,7 @@
8676
8705
  throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. " +
8677
8706
  "Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");
8678
8707
  }
8679
- this.store = new NodeSQLiteStorage(this.name);
8708
+ this.store = new NodeSQLiteStorage(this.name, PersistentStorage.nodeStorageDir ?? undefined);
8680
8709
  if (batchedWrites) {
8681
8710
  this.store.debouncedSetItems = mergebounce((items) => this.store.setItems(items), 50, {
8682
8711
  'promise': true,
@@ -8776,33 +8805,17 @@
8776
8805
  caughtError = error instanceof Error ? error : new Error(error?.message ?? String(error));
8777
8806
  }
8778
8807
  }
8779
- if (resp) {
8780
- if (options && options.success) {
8781
- // When storing, we don't pass back the response (which is
8782
- // the set attributes returned from localforage because
8783
- // Skeletor sets them again on the model and due to the async
8784
- // nature of localforage it can cause stale attributes to be
8785
- // set on a model after it's been updated in the meantime.
8786
- const data = method === 'read' ? resp : null;
8787
- options.success(data, options);
8788
- }
8789
- }
8790
- else if (method === 'read' && !caughtError) {
8791
- // A read that finds no record is a normal empty result (first run /
8792
- // empty storage), not an error. Resolve with `null` so the callback
8793
- // and promise forms of fetch() agree and a first-run read never
8794
- // rejects.
8795
- if (options && options.success) {
8796
- options.success(null, options);
8797
- }
8808
+ if (caughtError) {
8809
+ options?.error?.(caughtError);
8798
8810
  }
8799
- else {
8800
- // A genuine failure (storage threw, or a write produced no result):
8801
- // surface a real Error so consumers get a stack and `instanceof Error`
8802
- // holds.
8803
- if (options && options.error) {
8804
- options.error(caughtError ?? new Error('Record Not Found'));
8805
- }
8811
+ else if (options?.success) {
8812
+ // When storing, we don't pass back the response (which is the set
8813
+ // attributes returned from localforage) because Skeletor sets them
8814
+ // again on the model and due to the async nature of localforage it can
8815
+ // cause stale attributes to be set on a model after it's been updated
8816
+ // in the meantime.
8817
+ const data = method === 'read' ? (resp ?? null) : null;
8818
+ options.success(data, options);
8806
8819
  }
8807
8820
  }
8808
8821
  localSync.__name__ = 'localSync';
@@ -8896,6 +8909,18 @@
8896
8909
  // node-only driver (and its `node:sqlite` import) never enters the browser
8897
8910
  // bundle; the `@converse/skeletor/node` entry sets it.
8898
8911
  PersistentStorage.nodeStorage = null;
8912
+ /**
8913
+ * Directory the `'node'` store type writes its database files to. The driver's
8914
+ * own default is relative, so it resolves against `process.cwd()` and a process
8915
+ * started from two directories ends up with two separate sets of state. Set an
8916
+ * absolute path (`$XDG_STATE_HOME/<app>`, say) to pin it. Left `null`, the
8917
+ * driver's default applies.
8918
+ *
8919
+ * Only the `'node'` string store type reads this; passing a driver instance to
8920
+ * the constructor means you've already chosen a directory yourself.
8921
+ * @public
8922
+ */
8923
+ PersistentStorage.nodeStorageDir = null;
8899
8924
  PersistentStorage.sessionStorageInitialized = localForage.defineDriver(sessionStorageWrapper);
8900
8925
  PersistentStorage.localForage = localForage;
8901
8926