@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.
@@ -334,7 +334,7 @@ function getKeyPrefix(options, defaultConfig) {
334
334
  return (options.name || defaultConfig.name) + "/" + (options.storeName || defaultConfig.storeName) + "/";
335
335
  }
336
336
 
337
- function executeCallback$1(promise, callback) {
337
+ function executeCallback(promise, callback) {
338
338
  if (callback) {
339
339
  promise.then(function (result) {
340
340
  callback(null, result);
@@ -475,7 +475,7 @@ function clear$1(callback) {
475
475
  var promise = this.ready().then(function () {
476
476
  _this._dbInfo.mStore.clear();
477
477
  });
478
- executeCallback$1(promise, callback);
478
+ executeCallback(promise, callback);
479
479
  return promise;
480
480
  }
481
481
 
@@ -484,7 +484,7 @@ function dropInstance$1(_options, _cb) {
484
484
  var outPromise = promise.then(function (keyPrefix) {
485
485
  Store.resolve(keyPrefix).drop();
486
486
  });
487
- executeCallback$1(outPromise, callback);
487
+ executeCallback(outPromise, callback);
488
488
  return promise;
489
489
  }
490
490
 
@@ -496,7 +496,7 @@ function getItem$1(key$, callback) {
496
496
  // Deserialise if the result is not null or undefined
497
497
  return result == null ? null : _this._dbInfo.serializer.deserialize(result); //tslint:disable-line:triple-equals
498
498
  });
499
- executeCallback$1(promise, callback);
499
+ executeCallback(promise, callback);
500
500
  return promise;
501
501
  }
502
502
 
@@ -520,7 +520,7 @@ function iterate$1(iterator, callback) {
520
520
  }
521
521
  }
522
522
  });
523
- executeCallback$1(promise, callback);
523
+ executeCallback(promise, callback);
524
524
  return promise;
525
525
  }
526
526
 
@@ -539,7 +539,7 @@ function key$1(idx, callback) {
539
539
  }
540
540
  return result;
541
541
  });
542
- executeCallback$1(promise, callback);
542
+ executeCallback(promise, callback);
543
543
  return promise;
544
544
  }
545
545
 
@@ -548,13 +548,13 @@ function keys$2(callback) {
548
548
  var promise = this.ready().then(function () {
549
549
  return _this._dbInfo.mStore.keys();
550
550
  });
551
- executeCallback$1(promise, callback);
551
+ executeCallback(promise, callback);
552
552
  return promise;
553
553
  }
554
554
 
555
555
  function length$1(callback) {
556
556
  var promise = this.keys().then(function (keys$) { return keys$.length; });
557
- executeCallback$1(promise, callback);
557
+ executeCallback(promise, callback);
558
558
  return promise;
559
559
  }
560
560
 
@@ -564,7 +564,7 @@ function removeItem$1(key$, callback) {
564
564
  var promise = this.ready().then(function () {
565
565
  _this._dbInfo.mStore.rm(key$);
566
566
  });
567
- executeCallback$1(promise, callback);
567
+ executeCallback(promise, callback);
568
568
  return promise;
569
569
  }
570
570
 
@@ -594,7 +594,7 @@ function setItem$1(key$, value, callback) {
594
594
  });
595
595
  });
596
596
  });
597
- executeCallback$1(promise, callback);
597
+ executeCallback(promise, callback);
598
598
  return promise;
599
599
  }
600
600
 
@@ -7104,253 +7104,282 @@ function requireLocalforageSetitems () {
7104
7104
 
7105
7105
  var localforageSetitemsExports = requireLocalforageSetitems();
7106
7106
 
7107
- function getSerializerPromise(localForageInstance) {
7108
- if (getSerializerPromise.result) {
7109
- return getSerializerPromise.result;
7110
- }
7111
- if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7112
- return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7113
- }
7114
- getSerializerPromise.result = localForageInstance.getSerializer();
7115
- return getSerializerPromise.result;
7116
- }
7107
+ var localforageGetitems$1 = {exports: {}};
7117
7108
 
7109
+ var localforageGetitems = localforageGetitems$1.exports;
7118
7110
 
7111
+ var hasRequiredLocalforageGetitems;
7119
7112
 
7120
- function executeCallback(promise, callback) {
7121
- if (callback) {
7122
- promise.then(function (result) {
7123
- callback(null, result);
7124
- }, function (error) {
7125
- callback(error);
7126
- });
7127
- }
7128
- return promise;
7129
- }
7113
+ function requireLocalforageGetitems () {
7114
+ if (hasRequiredLocalforageGetitems) return localforageGetitems$1.exports;
7115
+ hasRequiredLocalforageGetitems = 1;
7116
+ (function (module, exports) {
7117
+ (function (global, factory) {
7118
+ factory(exports, requireLocalforage()) ;
7119
+ }(localforageGetitems, (function (exports,localforage) {
7120
+ localforage = 'default' in localforage ? localforage['default'] : localforage;
7130
7121
 
7131
- function getItemKeyValue(key, callback) {
7132
- var localforageInstance = this;
7133
- var promise = localforageInstance.getItem(key).then(function (value) {
7134
- return {
7135
- key: key,
7136
- value: value
7137
- };
7138
- });
7139
- executeCallback(promise, callback);
7140
- return promise;
7141
- }
7122
+ function getSerializerPromise(localForageInstance) {
7123
+ if (getSerializerPromise.result) {
7124
+ return getSerializerPromise.result;
7125
+ }
7126
+ if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7127
+ return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7128
+ }
7129
+ getSerializerPromise.result = localForageInstance.getSerializer();
7130
+ return getSerializerPromise.result;
7131
+ }
7142
7132
 
7143
- function getItemsGeneric(keys /*, callback*/) {
7144
- var localforageInstance = this;
7145
- var promise = new Promise(function (resolve, reject) {
7146
- var itemPromises = [];
7147
7133
 
7148
- for (var i = 0, len = keys.length; i < len; i++) {
7149
- itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7150
- }
7151
7134
 
7152
- Promise.all(itemPromises).then(function (keyValuePairs) {
7153
- var result = {};
7154
- for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7155
- var keyValuePair = keyValuePairs[i];
7135
+ function executeCallback(promise, callback) {
7136
+ if (callback) {
7137
+ promise.then(function (result) {
7138
+ callback(null, result);
7139
+ }, function (error) {
7140
+ callback(error);
7141
+ });
7142
+ }
7143
+ return promise;
7144
+ }
7156
7145
 
7157
- result[keyValuePair.key] = keyValuePair.value;
7158
- }
7159
- resolve(result);
7160
- }).catch(reject);
7161
- });
7162
- return promise;
7163
- }
7146
+ function getItemKeyValue(key, callback) {
7147
+ var localforageInstance = this;
7148
+ var promise = localforageInstance.getItem(key).then(function (value) {
7149
+ return {
7150
+ key: key,
7151
+ value: value
7152
+ };
7153
+ });
7154
+ executeCallback(promise, callback);
7155
+ return promise;
7156
+ }
7164
7157
 
7158
+ function getItemsGeneric(keys /*, callback*/) {
7159
+ var localforageInstance = this;
7160
+ var promise = new Promise(function (resolve, reject) {
7161
+ var itemPromises = [];
7165
7162
 
7163
+ for (var i = 0, len = keys.length; i < len; i++) {
7164
+ itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7165
+ }
7166
7166
 
7167
+ Promise.all(itemPromises).then(function (keyValuePairs) {
7168
+ var result = {};
7169
+ for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7170
+ var keyValuePair = keyValuePairs[i];
7167
7171
 
7172
+ result[keyValuePair.key] = keyValuePair.value;
7173
+ }
7174
+ resolve(result);
7175
+ }).catch(reject);
7176
+ });
7177
+ return promise;
7178
+ }
7168
7179
 
7169
- function getAllItemsUsingIterate() {
7170
- var localforageInstance = this;
7171
- var accumulator = {};
7172
- return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7173
- accumulator[key] = value;
7174
- }).then(function () {
7175
- return accumulator;
7176
- });
7177
- }
7178
7180
 
7179
- function getIDBKeyRange() {
7180
- /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7181
- if (typeof IDBKeyRange !== 'undefined') {
7182
- return IDBKeyRange;
7183
- }
7184
- if (typeof webkitIDBKeyRange !== 'undefined') {
7185
- return webkitIDBKeyRange;
7186
- }
7187
- if (typeof mozIDBKeyRange !== 'undefined') {
7188
- return mozIDBKeyRange;
7189
- }
7190
- }
7191
7181
 
7192
- var idbKeyRange = getIDBKeyRange();
7193
7182
 
7194
- function getItemsIndexedDB(keys /*, callback*/) {
7195
- keys = keys.slice();
7196
- var localforageInstance = this;
7197
- function comparer(a, b) {
7198
- return a < b ? -1 : a > b ? 1 : 0;
7199
- }
7200
7183
 
7201
- var promise = new Promise(function (resolve, reject) {
7202
- localforageInstance.ready().then(function () {
7203
- // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
7204
- var dbInfo = localforageInstance._dbInfo;
7205
- var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
7184
+ function getAllItemsUsingIterate() {
7185
+ var localforageInstance = this;
7186
+ var accumulator = {};
7187
+ return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7188
+ accumulator[key] = value;
7189
+ }).then(function () {
7190
+ return accumulator;
7191
+ });
7192
+ }
7206
7193
 
7207
- var set = keys.sort(comparer);
7194
+ function getIDBKeyRange() {
7195
+ /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7196
+ if (typeof IDBKeyRange !== 'undefined') {
7197
+ return IDBKeyRange;
7198
+ }
7199
+ if (typeof webkitIDBKeyRange !== 'undefined') {
7200
+ return webkitIDBKeyRange;
7201
+ }
7202
+ if (typeof mozIDBKeyRange !== 'undefined') {
7203
+ return mozIDBKeyRange;
7204
+ }
7205
+ }
7208
7206
 
7209
- var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
7207
+ var idbKeyRange = getIDBKeyRange();
7210
7208
 
7211
- var req;
7209
+ function getItemsIndexedDB(keys /*, callback*/) {
7210
+ keys = keys.slice();
7211
+ var localforageInstance = this;
7212
+ function comparer(a, b) {
7213
+ return a < b ? -1 : a > b ? 1 : 0;
7214
+ }
7212
7215
 
7213
- if ('getAll' in store) {
7214
- req = store.getAll(keyRangeValue);
7215
- req.onsuccess = function () {
7216
- var value = req.result;
7217
- if (value === undefined) {
7218
- value = null;
7219
- }
7220
- resolve(value);
7221
- };
7222
- } else {
7223
- req = store.openCursor(keyRangeValue);
7224
- var result = {};
7225
- var i = 0;
7216
+ var promise = new Promise(function (resolve, reject) {
7217
+ localforageInstance.ready().then(function () {
7218
+ // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
7219
+ var dbInfo = localforageInstance._dbInfo;
7220
+ var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
7226
7221
 
7227
- req.onsuccess = function () /*event*/{
7228
- var cursor = req.result; // event.target.result;
7222
+ var set = keys.sort(comparer);
7229
7223
 
7230
- if (!cursor) {
7231
- resolve(result);
7232
- return;
7233
- }
7224
+ var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
7234
7225
 
7235
- var key = cursor.key;
7226
+ var req;
7236
7227
 
7237
- while (key > set[i]) {
7238
- i++; // The cursor has passed beyond this key. Check next.
7228
+ if ('getAll' in store) {
7229
+ req = store.getAll(keyRangeValue);
7230
+ req.onsuccess = function () {
7231
+ var value = req.result;
7232
+ if (value === undefined) {
7233
+ value = null;
7234
+ }
7235
+ resolve(value);
7236
+ };
7237
+ } else {
7238
+ req = store.openCursor(keyRangeValue);
7239
+ var result = {};
7240
+ var i = 0;
7239
7241
 
7240
- if (i === set.length) {
7241
- // There is no next. Stop searching.
7242
- resolve(result);
7243
- return;
7244
- }
7245
- }
7242
+ req.onsuccess = function () /*event*/{
7243
+ var cursor = req.result; // event.target.result;
7246
7244
 
7247
- if (key === set[i]) {
7248
- // The current cursor value should be included and we should continue
7249
- // a single step in case next item has the same key or possibly our
7250
- // next key in set.
7251
- var value = cursor.value;
7252
- if (value === undefined) {
7253
- value = null;
7254
- }
7245
+ if (!cursor) {
7246
+ resolve(result);
7247
+ return;
7248
+ }
7255
7249
 
7256
- result[key] = value;
7257
- // onfound(cursor.value);
7258
- cursor.continue();
7259
- } else {
7260
- // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
7261
- cursor.continue(set[i]);
7262
- }
7263
- };
7264
- }
7250
+ var key = cursor.key;
7265
7251
 
7266
- req.onerror = function () /*event*/{
7267
- reject(req.error);
7268
- };
7269
- }).catch(reject);
7270
- });
7271
- return promise;
7272
- }
7252
+ while (key > set[i]) {
7253
+ i++; // The cursor has passed beyond this key. Check next.
7273
7254
 
7274
- function getItemsWebsql(keys /*, callback*/) {
7275
- var localforageInstance = this;
7276
- var promise = new Promise(function (resolve, reject) {
7277
- localforageInstance.ready().then(function () {
7278
- return getSerializerPromise(localforageInstance);
7279
- }).then(function (serializer) {
7280
- var dbInfo = localforageInstance._dbInfo;
7281
- dbInfo.db.transaction(function (t) {
7255
+ if (i === set.length) {
7256
+ // There is no next. Stop searching.
7257
+ resolve(result);
7258
+ return;
7259
+ }
7260
+ }
7282
7261
 
7283
- var queryParts = new Array(keys.length);
7284
- for (var i = 0, len = keys.length; i < len; i++) {
7285
- queryParts[i] = '?';
7286
- }
7262
+ if (key === set[i]) {
7263
+ // The current cursor value should be included and we should continue
7264
+ // a single step in case next item has the same key or possibly our
7265
+ // next key in set.
7266
+ var value = cursor.value;
7267
+ if (value === undefined) {
7268
+ value = null;
7269
+ }
7287
7270
 
7288
- t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
7271
+ result[key] = value;
7272
+ // onfound(cursor.value);
7273
+ cursor.continue();
7274
+ } else {
7275
+ // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
7276
+ cursor.continue(set[i]);
7277
+ }
7278
+ };
7279
+ }
7289
7280
 
7290
- var result = {};
7281
+ req.onerror = function () /*event*/{
7282
+ reject(req.error);
7283
+ };
7284
+ }).catch(reject);
7285
+ });
7286
+ return promise;
7287
+ }
7291
7288
 
7292
- var rows = results.rows;
7293
- for (var i = 0, len = rows.length; i < len; i++) {
7294
- var item = rows.item(i);
7295
- var value = item.value;
7289
+ function getItemsWebsql(keys /*, callback*/) {
7290
+ var localforageInstance = this;
7291
+ var promise = new Promise(function (resolve, reject) {
7292
+ localforageInstance.ready().then(function () {
7293
+ return getSerializerPromise(localforageInstance);
7294
+ }).then(function (serializer) {
7295
+ var dbInfo = localforageInstance._dbInfo;
7296
+ dbInfo.db.transaction(function (t) {
7296
7297
 
7297
- // Check to see if this is serialized content we need to
7298
- // unpack.
7299
- if (value) {
7300
- value = serializer.deserialize(value);
7301
- }
7298
+ var queryParts = new Array(keys.length);
7299
+ for (var i = 0, len = keys.length; i < len; i++) {
7300
+ queryParts[i] = '?';
7301
+ }
7302
7302
 
7303
- result[item.key] = value;
7304
- }
7303
+ t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
7305
7304
 
7306
- resolve(result);
7307
- }, function (t, error) {
7308
- reject(error);
7309
- });
7310
- });
7311
- }).catch(reject);
7312
- });
7313
- return promise;
7314
- }
7305
+ var result = {};
7315
7306
 
7316
- function localforageGetItems(keys, callback) {
7317
- var localforageInstance = this;
7307
+ var rows = results.rows;
7308
+ for (var i = 0, len = rows.length; i < len; i++) {
7309
+ var item = rows.item(i);
7310
+ var value = item.value;
7318
7311
 
7319
- var promise;
7320
- if (!arguments.length || keys === null) {
7321
- promise = getAllItemsUsingIterate.apply(localforageInstance);
7322
- } else {
7323
- var currentDriver = localforageInstance.driver();
7324
- if (currentDriver === localforageInstance.INDEXEDDB) {
7325
- promise = getItemsIndexedDB.apply(localforageInstance, arguments);
7326
- } else if (currentDriver === localforageInstance.WEBSQL) {
7327
- promise = getItemsWebsql.apply(localforageInstance, arguments);
7328
- } else {
7329
- promise = getItemsGeneric.apply(localforageInstance, arguments);
7330
- }
7331
- }
7312
+ // Check to see if this is serialized content we need to
7313
+ // unpack.
7314
+ if (value) {
7315
+ value = serializer.deserialize(value);
7316
+ }
7332
7317
 
7333
- executeCallback(promise, callback);
7334
- return promise;
7335
- }
7318
+ result[item.key] = value;
7319
+ }
7336
7320
 
7337
- function extendPrototype(localforage$$1) {
7338
- var localforagePrototype = Object.getPrototypeOf(localforage$$1);
7339
- if (localforagePrototype) {
7340
- localforagePrototype.getItems = localforageGetItems;
7341
- localforagePrototype.getItems.indexedDB = function () {
7342
- return getItemsIndexedDB.apply(this, arguments);
7343
- };
7344
- localforagePrototype.getItems.websql = function () {
7345
- return getItemsWebsql.apply(this, arguments);
7346
- };
7347
- localforagePrototype.getItems.generic = function () {
7348
- return getItemsGeneric.apply(this, arguments);
7349
- };
7350
- }
7321
+ resolve(result);
7322
+ }, function (t, error) {
7323
+ reject(error);
7324
+ });
7325
+ });
7326
+ }).catch(reject);
7327
+ });
7328
+ return promise;
7329
+ }
7330
+
7331
+ function localforageGetItems(keys, callback) {
7332
+ var localforageInstance = this;
7333
+
7334
+ var promise;
7335
+ if (!arguments.length || keys === null) {
7336
+ promise = getAllItemsUsingIterate.apply(localforageInstance);
7337
+ } else {
7338
+ var currentDriver = localforageInstance.driver();
7339
+ if (currentDriver === localforageInstance.INDEXEDDB) {
7340
+ promise = getItemsIndexedDB.apply(localforageInstance, arguments);
7341
+ } else if (currentDriver === localforageInstance.WEBSQL) {
7342
+ promise = getItemsWebsql.apply(localforageInstance, arguments);
7343
+ } else {
7344
+ promise = getItemsGeneric.apply(localforageInstance, arguments);
7345
+ }
7346
+ }
7347
+
7348
+ executeCallback(promise, callback);
7349
+ return promise;
7350
+ }
7351
+
7352
+ function extendPrototype(localforage$$1) {
7353
+ var localforagePrototype = Object.getPrototypeOf(localforage$$1);
7354
+ if (localforagePrototype) {
7355
+ localforagePrototype.getItems = localforageGetItems;
7356
+ localforagePrototype.getItems.indexedDB = function () {
7357
+ return getItemsIndexedDB.apply(this, arguments);
7358
+ };
7359
+ localforagePrototype.getItems.websql = function () {
7360
+ return getItemsWebsql.apply(this, arguments);
7361
+ };
7362
+ localforagePrototype.getItems.generic = function () {
7363
+ return getItemsGeneric.apply(this, arguments);
7364
+ };
7365
+ }
7366
+ }
7367
+
7368
+ var extendPrototypeResult = extendPrototype(localforage);
7369
+
7370
+ exports.localforageGetItems = localforageGetItems;
7371
+ exports.extendPrototype = extendPrototype;
7372
+ exports.extendPrototypeResult = extendPrototypeResult;
7373
+ exports.getItemsGeneric = getItemsGeneric;
7374
+
7375
+ Object.defineProperty(exports, '__esModule', { value: true });
7376
+
7377
+ })));
7378
+ } (localforageGetitems$1, localforageGetitems$1.exports));
7379
+ return localforageGetitems$1.exports;
7351
7380
  }
7352
7381
 
7353
- extendPrototype(localForage);
7382
+ var localforageGetitemsExports = requireLocalforageGetitems();
7354
7383
 
7355
7384
  /** Used for built-in method references. */
7356
7385
  var objectProto$8 = Object.prototype;
@@ -7901,7 +7930,7 @@ function sync(method, model, options = {}) {
7901
7930
  const IN_MEMORY = _driver;
7902
7931
  localForage.defineDriver(memoryDriver);
7903
7932
  localforageSetitemsExports.extendPrototype(localForage);
7904
- extendPrototype(localForage);
7933
+ localforageGetitemsExports.extendPrototype(localForage);
7905
7934
  // Every storage instance is registered with a WeakRef so that flushAll() can
7906
7935
  // reach pending writes without keeping instances alive. There's no leak and no
7907
7936
  // lifecycle hook to maintain: an instance is collected once its owning model or
@@ -7991,7 +8020,7 @@ class PersistentStorage {
7991
8020
  throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. " +
7992
8021
  "Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");
7993
8022
  }
7994
- this.store = new NodeSQLiteStorage(this.name);
8023
+ this.store = new NodeSQLiteStorage(this.name, PersistentStorage.nodeStorageDir ?? undefined);
7995
8024
  if (batchedWrites) {
7996
8025
  this.store.debouncedSetItems = mergebounce((items) => this.store.setItems(items), 50, {
7997
8026
  'promise': true,
@@ -8091,33 +8120,17 @@ class PersistentStorage {
8091
8120
  caughtError = error instanceof Error ? error : new Error(error?.message ?? String(error));
8092
8121
  }
8093
8122
  }
8094
- if (resp) {
8095
- if (options && options.success) {
8096
- // When storing, we don't pass back the response (which is
8097
- // the set attributes returned from localforage because
8098
- // Skeletor sets them again on the model and due to the async
8099
- // nature of localforage it can cause stale attributes to be
8100
- // set on a model after it's been updated in the meantime.
8101
- const data = method === 'read' ? resp : null;
8102
- options.success(data, options);
8103
- }
8104
- }
8105
- else if (method === 'read' && !caughtError) {
8106
- // A read that finds no record is a normal empty result (first run /
8107
- // empty storage), not an error. Resolve with `null` so the callback
8108
- // and promise forms of fetch() agree and a first-run read never
8109
- // rejects.
8110
- if (options && options.success) {
8111
- options.success(null, options);
8112
- }
8123
+ if (caughtError) {
8124
+ options?.error?.(caughtError);
8113
8125
  }
8114
- else {
8115
- // A genuine failure (storage threw, or a write produced no result):
8116
- // surface a real Error so consumers get a stack and `instanceof Error`
8117
- // holds.
8118
- if (options && options.error) {
8119
- options.error(caughtError ?? new Error('Record Not Found'));
8120
- }
8126
+ else if (options?.success) {
8127
+ // When storing, we don't pass back the response (which is the set
8128
+ // attributes returned from localforage) because Skeletor sets them
8129
+ // again on the model and due to the async nature of localforage it can
8130
+ // cause stale attributes to be set on a model after it's been updated
8131
+ // in the meantime.
8132
+ const data = method === 'read' ? (resp ?? null) : null;
8133
+ options.success(data, options);
8121
8134
  }
8122
8135
  }
8123
8136
  localSync.__name__ = 'localSync';
@@ -8211,6 +8224,18 @@ class PersistentStorage {
8211
8224
  // node-only driver (and its `node:sqlite` import) never enters the browser
8212
8225
  // bundle; the `@converse/skeletor/node` entry sets it.
8213
8226
  PersistentStorage.nodeStorage = null;
8227
+ /**
8228
+ * Directory the `'node'` store type writes its database files to. The driver's
8229
+ * own default is relative, so it resolves against `process.cwd()` and a process
8230
+ * started from two directories ends up with two separate sets of state. Set an
8231
+ * absolute path (`$XDG_STATE_HOME/<app>`, say) to pin it. Left `null`, the
8232
+ * driver's default applies.
8233
+ *
8234
+ * Only the `'node'` string store type reads this; passing a driver instance to
8235
+ * the constructor means you've already chosen a directory yourself.
8236
+ * @public
8237
+ */
8238
+ PersistentStorage.nodeStorageDir = null;
8214
8239
  PersistentStorage.sessionStorageInitialized = localForage.defineDriver(sessionStorageWrapper);
8215
8240
  PersistentStorage.localForage = localForage;
8216
8241
 
@@ -8218,6 +8243,7 @@ const DEFAULT_BASE_DIR = '.skeletor-storage';
8218
8243
  /**
8219
8244
  * SQLite-backed implementation of StorageDriver.
8220
8245
  * Uses a single table with key/value columns, storing values as JSON strings.
8246
+ * @public
8221
8247
  */
8222
8248
  class NodeSQLiteStorage {
8223
8249
  ready() {
@@ -8319,7 +8345,7 @@ class NodeSQLiteStorage {
8319
8345
  }
8320
8346
  throw e;
8321
8347
  }
8322
- return Promise.resolve();
8348
+ return Promise.resolve(items);
8323
8349
  }
8324
8350
  getItems(keys) {
8325
8351
  if (keys.length === 0) {