@converse/skeletor 3.1.3 → 3.1.5

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.
@@ -338,7 +338,7 @@ function getKeyPrefix(options, defaultConfig) {
338
338
  return (options.name || defaultConfig.name) + "/" + (options.storeName || defaultConfig.storeName) + "/";
339
339
  }
340
340
 
341
- function executeCallback$1(promise, callback) {
341
+ function executeCallback(promise, callback) {
342
342
  if (callback) {
343
343
  promise.then(function (result) {
344
344
  callback(null, result);
@@ -479,7 +479,7 @@ function clear$1(callback) {
479
479
  var promise = this.ready().then(function () {
480
480
  _this._dbInfo.mStore.clear();
481
481
  });
482
- executeCallback$1(promise, callback);
482
+ executeCallback(promise, callback);
483
483
  return promise;
484
484
  }
485
485
 
@@ -488,7 +488,7 @@ function dropInstance$1(_options, _cb) {
488
488
  var outPromise = promise.then(function (keyPrefix) {
489
489
  Store.resolve(keyPrefix).drop();
490
490
  });
491
- executeCallback$1(outPromise, callback);
491
+ executeCallback(outPromise, callback);
492
492
  return promise;
493
493
  }
494
494
 
@@ -500,7 +500,7 @@ function getItem$1(key$, callback) {
500
500
  // Deserialise if the result is not null or undefined
501
501
  return result == null ? null : _this._dbInfo.serializer.deserialize(result); //tslint:disable-line:triple-equals
502
502
  });
503
- executeCallback$1(promise, callback);
503
+ executeCallback(promise, callback);
504
504
  return promise;
505
505
  }
506
506
 
@@ -524,7 +524,7 @@ function iterate$1(iterator, callback) {
524
524
  }
525
525
  }
526
526
  });
527
- executeCallback$1(promise, callback);
527
+ executeCallback(promise, callback);
528
528
  return promise;
529
529
  }
530
530
 
@@ -543,7 +543,7 @@ function key$1(idx, callback) {
543
543
  }
544
544
  return result;
545
545
  });
546
- executeCallback$1(promise, callback);
546
+ executeCallback(promise, callback);
547
547
  return promise;
548
548
  }
549
549
 
@@ -552,13 +552,13 @@ function keys$2(callback) {
552
552
  var promise = this.ready().then(function () {
553
553
  return _this._dbInfo.mStore.keys();
554
554
  });
555
- executeCallback$1(promise, callback);
555
+ executeCallback(promise, callback);
556
556
  return promise;
557
557
  }
558
558
 
559
559
  function length$1(callback) {
560
560
  var promise = this.keys().then(function (keys$) { return keys$.length; });
561
- executeCallback$1(promise, callback);
561
+ executeCallback(promise, callback);
562
562
  return promise;
563
563
  }
564
564
 
@@ -568,7 +568,7 @@ function removeItem$1(key$, callback) {
568
568
  var promise = this.ready().then(function () {
569
569
  _this._dbInfo.mStore.rm(key$);
570
570
  });
571
- executeCallback$1(promise, callback);
571
+ executeCallback(promise, callback);
572
572
  return promise;
573
573
  }
574
574
 
@@ -598,7 +598,7 @@ function setItem$1(key$, value, callback) {
598
598
  });
599
599
  });
600
600
  });
601
- executeCallback$1(promise, callback);
601
+ executeCallback(promise, callback);
602
602
  return promise;
603
603
  }
604
604
 
@@ -7108,253 +7108,282 @@ function requireLocalforageSetitems () {
7108
7108
 
7109
7109
  var localforageSetitemsExports = requireLocalforageSetitems();
7110
7110
 
7111
- function getSerializerPromise(localForageInstance) {
7112
- if (getSerializerPromise.result) {
7113
- return getSerializerPromise.result;
7114
- }
7115
- if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7116
- return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7117
- }
7118
- getSerializerPromise.result = localForageInstance.getSerializer();
7119
- return getSerializerPromise.result;
7120
- }
7111
+ var localforageGetitems$1 = {exports: {}};
7121
7112
 
7113
+ var localforageGetitems = localforageGetitems$1.exports;
7122
7114
 
7115
+ var hasRequiredLocalforageGetitems;
7123
7116
 
7124
- function executeCallback(promise, callback) {
7125
- if (callback) {
7126
- promise.then(function (result) {
7127
- callback(null, result);
7128
- }, function (error) {
7129
- callback(error);
7130
- });
7131
- }
7132
- return promise;
7133
- }
7117
+ function requireLocalforageGetitems () {
7118
+ if (hasRequiredLocalforageGetitems) return localforageGetitems$1.exports;
7119
+ hasRequiredLocalforageGetitems = 1;
7120
+ (function (module, exports) {
7121
+ (function (global, factory) {
7122
+ factory(exports, requireLocalforage()) ;
7123
+ }(localforageGetitems, (function (exports,localforage) {
7124
+ localforage = 'default' in localforage ? localforage['default'] : localforage;
7134
7125
 
7135
- function getItemKeyValue(key, callback) {
7136
- var localforageInstance = this;
7137
- var promise = localforageInstance.getItem(key).then(function (value) {
7138
- return {
7139
- key: key,
7140
- value: value
7141
- };
7142
- });
7143
- executeCallback(promise, callback);
7144
- return promise;
7145
- }
7126
+ function getSerializerPromise(localForageInstance) {
7127
+ if (getSerializerPromise.result) {
7128
+ return getSerializerPromise.result;
7129
+ }
7130
+ if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
7131
+ return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
7132
+ }
7133
+ getSerializerPromise.result = localForageInstance.getSerializer();
7134
+ return getSerializerPromise.result;
7135
+ }
7146
7136
 
7147
- function getItemsGeneric(keys /*, callback*/) {
7148
- var localforageInstance = this;
7149
- var promise = new Promise(function (resolve, reject) {
7150
- var itemPromises = [];
7151
7137
 
7152
- for (var i = 0, len = keys.length; i < len; i++) {
7153
- itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7154
- }
7155
7138
 
7156
- Promise.all(itemPromises).then(function (keyValuePairs) {
7157
- var result = {};
7158
- for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7159
- var keyValuePair = keyValuePairs[i];
7139
+ function executeCallback(promise, callback) {
7140
+ if (callback) {
7141
+ promise.then(function (result) {
7142
+ callback(null, result);
7143
+ }, function (error) {
7144
+ callback(error);
7145
+ });
7146
+ }
7147
+ return promise;
7148
+ }
7160
7149
 
7161
- result[keyValuePair.key] = keyValuePair.value;
7162
- }
7163
- resolve(result);
7164
- }).catch(reject);
7165
- });
7166
- return promise;
7167
- }
7150
+ function getItemKeyValue(key, callback) {
7151
+ var localforageInstance = this;
7152
+ var promise = localforageInstance.getItem(key).then(function (value) {
7153
+ return {
7154
+ key: key,
7155
+ value: value
7156
+ };
7157
+ });
7158
+ executeCallback(promise, callback);
7159
+ return promise;
7160
+ }
7168
7161
 
7162
+ function getItemsGeneric(keys /*, callback*/) {
7163
+ var localforageInstance = this;
7164
+ var promise = new Promise(function (resolve, reject) {
7165
+ var itemPromises = [];
7169
7166
 
7167
+ for (var i = 0, len = keys.length; i < len; i++) {
7168
+ itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
7169
+ }
7170
7170
 
7171
+ Promise.all(itemPromises).then(function (keyValuePairs) {
7172
+ var result = {};
7173
+ for (var i = 0, len = keyValuePairs.length; i < len; i++) {
7174
+ var keyValuePair = keyValuePairs[i];
7171
7175
 
7176
+ result[keyValuePair.key] = keyValuePair.value;
7177
+ }
7178
+ resolve(result);
7179
+ }).catch(reject);
7180
+ });
7181
+ return promise;
7182
+ }
7172
7183
 
7173
- function getAllItemsUsingIterate() {
7174
- var localforageInstance = this;
7175
- var accumulator = {};
7176
- return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7177
- accumulator[key] = value;
7178
- }).then(function () {
7179
- return accumulator;
7180
- });
7181
- }
7182
7184
 
7183
- function getIDBKeyRange() {
7184
- /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7185
- if (typeof IDBKeyRange !== 'undefined') {
7186
- return IDBKeyRange;
7187
- }
7188
- if (typeof webkitIDBKeyRange !== 'undefined') {
7189
- return webkitIDBKeyRange;
7190
- }
7191
- if (typeof mozIDBKeyRange !== 'undefined') {
7192
- return mozIDBKeyRange;
7193
- }
7194
- }
7195
7185
 
7196
- var idbKeyRange = getIDBKeyRange();
7197
7186
 
7198
- function getItemsIndexedDB(keys /*, callback*/) {
7199
- keys = keys.slice();
7200
- var localforageInstance = this;
7201
- function comparer(a, b) {
7202
- return a < b ? -1 : a > b ? 1 : 0;
7203
- }
7204
7187
 
7205
- var promise = new Promise(function (resolve, reject) {
7206
- localforageInstance.ready().then(function () {
7207
- // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
7208
- var dbInfo = localforageInstance._dbInfo;
7209
- var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
7188
+ function getAllItemsUsingIterate() {
7189
+ var localforageInstance = this;
7190
+ var accumulator = {};
7191
+ return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
7192
+ accumulator[key] = value;
7193
+ }).then(function () {
7194
+ return accumulator;
7195
+ });
7196
+ }
7210
7197
 
7211
- var set = keys.sort(comparer);
7198
+ function getIDBKeyRange() {
7199
+ /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
7200
+ if (typeof IDBKeyRange !== 'undefined') {
7201
+ return IDBKeyRange;
7202
+ }
7203
+ if (typeof webkitIDBKeyRange !== 'undefined') {
7204
+ return webkitIDBKeyRange;
7205
+ }
7206
+ if (typeof mozIDBKeyRange !== 'undefined') {
7207
+ return mozIDBKeyRange;
7208
+ }
7209
+ }
7212
7210
 
7213
- var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
7211
+ var idbKeyRange = getIDBKeyRange();
7214
7212
 
7215
- var req;
7213
+ function getItemsIndexedDB(keys /*, callback*/) {
7214
+ keys = keys.slice();
7215
+ var localforageInstance = this;
7216
+ function comparer(a, b) {
7217
+ return a < b ? -1 : a > b ? 1 : 0;
7218
+ }
7216
7219
 
7217
- if ('getAll' in store) {
7218
- req = store.getAll(keyRangeValue);
7219
- req.onsuccess = function () {
7220
- var value = req.result;
7221
- if (value === undefined) {
7222
- value = null;
7223
- }
7224
- resolve(value);
7225
- };
7226
- } else {
7227
- req = store.openCursor(keyRangeValue);
7228
- var result = {};
7229
- var i = 0;
7220
+ var promise = new Promise(function (resolve, reject) {
7221
+ localforageInstance.ready().then(function () {
7222
+ // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
7223
+ var dbInfo = localforageInstance._dbInfo;
7224
+ var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
7230
7225
 
7231
- req.onsuccess = function () /*event*/{
7232
- var cursor = req.result; // event.target.result;
7226
+ var set = keys.sort(comparer);
7233
7227
 
7234
- if (!cursor) {
7235
- resolve(result);
7236
- return;
7237
- }
7228
+ var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
7238
7229
 
7239
- var key = cursor.key;
7230
+ var req;
7240
7231
 
7241
- while (key > set[i]) {
7242
- i++; // The cursor has passed beyond this key. Check next.
7232
+ if ('getAll' in store) {
7233
+ req = store.getAll(keyRangeValue);
7234
+ req.onsuccess = function () {
7235
+ var value = req.result;
7236
+ if (value === undefined) {
7237
+ value = null;
7238
+ }
7239
+ resolve(value);
7240
+ };
7241
+ } else {
7242
+ req = store.openCursor(keyRangeValue);
7243
+ var result = {};
7244
+ var i = 0;
7243
7245
 
7244
- if (i === set.length) {
7245
- // There is no next. Stop searching.
7246
- resolve(result);
7247
- return;
7248
- }
7249
- }
7246
+ req.onsuccess = function () /*event*/{
7247
+ var cursor = req.result; // event.target.result;
7250
7248
 
7251
- if (key === set[i]) {
7252
- // The current cursor value should be included and we should continue
7253
- // a single step in case next item has the same key or possibly our
7254
- // next key in set.
7255
- var value = cursor.value;
7256
- if (value === undefined) {
7257
- value = null;
7258
- }
7249
+ if (!cursor) {
7250
+ resolve(result);
7251
+ return;
7252
+ }
7259
7253
 
7260
- result[key] = value;
7261
- // onfound(cursor.value);
7262
- cursor.continue();
7263
- } else {
7264
- // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
7265
- cursor.continue(set[i]);
7266
- }
7267
- };
7268
- }
7254
+ var key = cursor.key;
7269
7255
 
7270
- req.onerror = function () /*event*/{
7271
- reject(req.error);
7272
- };
7273
- }).catch(reject);
7274
- });
7275
- return promise;
7276
- }
7256
+ while (key > set[i]) {
7257
+ i++; // The cursor has passed beyond this key. Check next.
7277
7258
 
7278
- function getItemsWebsql(keys /*, callback*/) {
7279
- var localforageInstance = this;
7280
- var promise = new Promise(function (resolve, reject) {
7281
- localforageInstance.ready().then(function () {
7282
- return getSerializerPromise(localforageInstance);
7283
- }).then(function (serializer) {
7284
- var dbInfo = localforageInstance._dbInfo;
7285
- dbInfo.db.transaction(function (t) {
7259
+ if (i === set.length) {
7260
+ // There is no next. Stop searching.
7261
+ resolve(result);
7262
+ return;
7263
+ }
7264
+ }
7286
7265
 
7287
- var queryParts = new Array(keys.length);
7288
- for (var i = 0, len = keys.length; i < len; i++) {
7289
- queryParts[i] = '?';
7290
- }
7266
+ if (key === set[i]) {
7267
+ // The current cursor value should be included and we should continue
7268
+ // a single step in case next item has the same key or possibly our
7269
+ // next key in set.
7270
+ var value = cursor.value;
7271
+ if (value === undefined) {
7272
+ value = null;
7273
+ }
7291
7274
 
7292
- t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
7275
+ result[key] = value;
7276
+ // onfound(cursor.value);
7277
+ cursor.continue();
7278
+ } else {
7279
+ // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
7280
+ cursor.continue(set[i]);
7281
+ }
7282
+ };
7283
+ }
7293
7284
 
7294
- var result = {};
7285
+ req.onerror = function () /*event*/{
7286
+ reject(req.error);
7287
+ };
7288
+ }).catch(reject);
7289
+ });
7290
+ return promise;
7291
+ }
7295
7292
 
7296
- var rows = results.rows;
7297
- for (var i = 0, len = rows.length; i < len; i++) {
7298
- var item = rows.item(i);
7299
- var value = item.value;
7293
+ function getItemsWebsql(keys /*, callback*/) {
7294
+ var localforageInstance = this;
7295
+ var promise = new Promise(function (resolve, reject) {
7296
+ localforageInstance.ready().then(function () {
7297
+ return getSerializerPromise(localforageInstance);
7298
+ }).then(function (serializer) {
7299
+ var dbInfo = localforageInstance._dbInfo;
7300
+ dbInfo.db.transaction(function (t) {
7300
7301
 
7301
- // Check to see if this is serialized content we need to
7302
- // unpack.
7303
- if (value) {
7304
- value = serializer.deserialize(value);
7305
- }
7302
+ var queryParts = new Array(keys.length);
7303
+ for (var i = 0, len = keys.length; i < len; i++) {
7304
+ queryParts[i] = '?';
7305
+ }
7306
7306
 
7307
- result[item.key] = value;
7308
- }
7307
+ t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
7309
7308
 
7310
- resolve(result);
7311
- }, function (t, error) {
7312
- reject(error);
7313
- });
7314
- });
7315
- }).catch(reject);
7316
- });
7317
- return promise;
7318
- }
7309
+ var result = {};
7319
7310
 
7320
- function localforageGetItems(keys, callback) {
7321
- var localforageInstance = this;
7311
+ var rows = results.rows;
7312
+ for (var i = 0, len = rows.length; i < len; i++) {
7313
+ var item = rows.item(i);
7314
+ var value = item.value;
7322
7315
 
7323
- var promise;
7324
- if (!arguments.length || keys === null) {
7325
- promise = getAllItemsUsingIterate.apply(localforageInstance);
7326
- } else {
7327
- var currentDriver = localforageInstance.driver();
7328
- if (currentDriver === localforageInstance.INDEXEDDB) {
7329
- promise = getItemsIndexedDB.apply(localforageInstance, arguments);
7330
- } else if (currentDriver === localforageInstance.WEBSQL) {
7331
- promise = getItemsWebsql.apply(localforageInstance, arguments);
7332
- } else {
7333
- promise = getItemsGeneric.apply(localforageInstance, arguments);
7334
- }
7335
- }
7316
+ // Check to see if this is serialized content we need to
7317
+ // unpack.
7318
+ if (value) {
7319
+ value = serializer.deserialize(value);
7320
+ }
7336
7321
 
7337
- executeCallback(promise, callback);
7338
- return promise;
7339
- }
7322
+ result[item.key] = value;
7323
+ }
7340
7324
 
7341
- function extendPrototype(localforage$$1) {
7342
- var localforagePrototype = Object.getPrototypeOf(localforage$$1);
7343
- if (localforagePrototype) {
7344
- localforagePrototype.getItems = localforageGetItems;
7345
- localforagePrototype.getItems.indexedDB = function () {
7346
- return getItemsIndexedDB.apply(this, arguments);
7347
- };
7348
- localforagePrototype.getItems.websql = function () {
7349
- return getItemsWebsql.apply(this, arguments);
7350
- };
7351
- localforagePrototype.getItems.generic = function () {
7352
- return getItemsGeneric.apply(this, arguments);
7353
- };
7354
- }
7325
+ resolve(result);
7326
+ }, function (t, error) {
7327
+ reject(error);
7328
+ });
7329
+ });
7330
+ }).catch(reject);
7331
+ });
7332
+ return promise;
7333
+ }
7334
+
7335
+ function localforageGetItems(keys, callback) {
7336
+ var localforageInstance = this;
7337
+
7338
+ var promise;
7339
+ if (!arguments.length || keys === null) {
7340
+ promise = getAllItemsUsingIterate.apply(localforageInstance);
7341
+ } else {
7342
+ var currentDriver = localforageInstance.driver();
7343
+ if (currentDriver === localforageInstance.INDEXEDDB) {
7344
+ promise = getItemsIndexedDB.apply(localforageInstance, arguments);
7345
+ } else if (currentDriver === localforageInstance.WEBSQL) {
7346
+ promise = getItemsWebsql.apply(localforageInstance, arguments);
7347
+ } else {
7348
+ promise = getItemsGeneric.apply(localforageInstance, arguments);
7349
+ }
7350
+ }
7351
+
7352
+ executeCallback(promise, callback);
7353
+ return promise;
7354
+ }
7355
+
7356
+ function extendPrototype(localforage$$1) {
7357
+ var localforagePrototype = Object.getPrototypeOf(localforage$$1);
7358
+ if (localforagePrototype) {
7359
+ localforagePrototype.getItems = localforageGetItems;
7360
+ localforagePrototype.getItems.indexedDB = function () {
7361
+ return getItemsIndexedDB.apply(this, arguments);
7362
+ };
7363
+ localforagePrototype.getItems.websql = function () {
7364
+ return getItemsWebsql.apply(this, arguments);
7365
+ };
7366
+ localforagePrototype.getItems.generic = function () {
7367
+ return getItemsGeneric.apply(this, arguments);
7368
+ };
7369
+ }
7370
+ }
7371
+
7372
+ var extendPrototypeResult = extendPrototype(localforage);
7373
+
7374
+ exports.localforageGetItems = localforageGetItems;
7375
+ exports.extendPrototype = extendPrototype;
7376
+ exports.extendPrototypeResult = extendPrototypeResult;
7377
+ exports.getItemsGeneric = getItemsGeneric;
7378
+
7379
+ Object.defineProperty(exports, '__esModule', { value: true });
7380
+
7381
+ })));
7382
+ } (localforageGetitems$1, localforageGetitems$1.exports));
7383
+ return localforageGetitems$1.exports;
7355
7384
  }
7356
7385
 
7357
- extendPrototype(localForage);
7386
+ var localforageGetitemsExports = requireLocalforageGetitems();
7358
7387
 
7359
7388
  /** Used for built-in method references. */
7360
7389
  var objectProto$8 = Object.prototype;
@@ -7905,7 +7934,7 @@ function sync(method, model, options = {}) {
7905
7934
  const IN_MEMORY = _driver;
7906
7935
  localForage.defineDriver(memoryDriver);
7907
7936
  localforageSetitemsExports.extendPrototype(localForage);
7908
- extendPrototype(localForage);
7937
+ localforageGetitemsExports.extendPrototype(localForage);
7909
7938
  // Every storage instance is registered with a WeakRef so that flushAll() can
7910
7939
  // reach pending writes without keeping instances alive. There's no leak and no
7911
7940
  // lifecycle hook to maintain: an instance is collected once its owning model or
@@ -8095,33 +8124,17 @@ class PersistentStorage {
8095
8124
  caughtError = error instanceof Error ? error : new Error(error?.message ?? String(error));
8096
8125
  }
8097
8126
  }
8098
- if (resp) {
8099
- if (options && options.success) {
8100
- // When storing, we don't pass back the response (which is
8101
- // the set attributes returned from localforage because
8102
- // Skeletor sets them again on the model and due to the async
8103
- // nature of localforage it can cause stale attributes to be
8104
- // set on a model after it's been updated in the meantime.
8105
- const data = method === 'read' ? resp : null;
8106
- options.success(data, options);
8107
- }
8108
- }
8109
- else if (method === 'read' && !caughtError) {
8110
- // A read that finds no record is a normal empty result (first run /
8111
- // empty storage), not an error. Resolve with `null` so the callback
8112
- // and promise forms of fetch() agree and a first-run read never
8113
- // rejects.
8114
- if (options && options.success) {
8115
- options.success(null, options);
8116
- }
8127
+ if (caughtError) {
8128
+ options?.error?.(caughtError);
8117
8129
  }
8118
- else {
8119
- // A genuine failure (storage threw, or a write produced no result):
8120
- // surface a real Error so consumers get a stack and `instanceof Error`
8121
- // holds.
8122
- if (options && options.error) {
8123
- options.error(caughtError ?? new Error('Record Not Found'));
8124
- }
8130
+ else if (options?.success) {
8131
+ // When storing, we don't pass back the response (which is the set
8132
+ // attributes returned from localforage) because Skeletor sets them
8133
+ // again on the model and due to the async nature of localforage it can
8134
+ // cause stale attributes to be set on a model after it's been updated
8135
+ // in the meantime.
8136
+ const data = method === 'read' ? (resp ?? null) : null;
8137
+ options.success(data, options);
8125
8138
  }
8126
8139
  }
8127
8140
  localSync.__name__ = 'localSync';
@@ -8323,7 +8336,7 @@ class NodeSQLiteStorage {
8323
8336
  }
8324
8337
  throw e;
8325
8338
  }
8326
- return Promise.resolve();
8339
+ return Promise.resolve(items);
8327
8340
  }
8328
8341
  getItems(keys) {
8329
8342
  if (keys.length === 0) {
@@ -11059,18 +11072,18 @@ class Model extends EventEmitterObject {
11059
11072
  this.initialize.apply(this, arguments);
11060
11073
  // Reset changed after initial set
11061
11074
  this.changed = {};
11062
- // When autoSync is on, `initialized` is always a Promise so callers can
11063
- // uniformly `await model.initialized`. It only hydrates from storage when
11075
+ // When autoSync is on, `hydrated` is always a Promise so callers can
11076
+ // uniformly `await model.hydrated`. It only hydrates from storage when
11064
11077
  // there's something to load (storage configured and the model isn't new);
11065
11078
  // otherwise it's already ready and resolves immediately.
11066
11079
  if (this.autoSync) {
11067
11080
  if (getStorage(this) && !this.isNew()) {
11068
11081
  __classPrivateFieldSet(this, _Model_state, 'hydrating', "f");
11069
- this.initialized = __classPrivateFieldGet(this, _Model_instances, "m", _Model_hydrate).call(this);
11082
+ this.hydrated = __classPrivateFieldGet(this, _Model_instances, "m", _Model_hydrate).call(this);
11070
11083
  }
11071
11084
  else {
11072
11085
  __classPrivateFieldSet(this, _Model_state, 'ready', "f");
11073
- this.initialized = Promise.resolve();
11086
+ this.hydrated = Promise.resolve();
11074
11087
  }
11075
11088
  }
11076
11089
  else {
@@ -11243,7 +11256,7 @@ class Model extends EventEmitterObject {
11243
11256
  // Guard must come after arg normalization: when called as set(obj, opts),
11244
11257
  // fromStorage lives in `val` (second arg), not `options` (third arg).
11245
11258
  if (this.autoSync && __classPrivateFieldGet(this, _Model_state, "f") === 'hydrating' && !options.fromStorage) {
11246
- throw new Error(`Skeletor: set() called on an autoSync model before initialized resolved. Await model.initialized first.`);
11259
+ throw new Error(`Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.`);
11247
11260
  }
11248
11261
  // Run validation.
11249
11262
  if (!this._validate(attrs, options))
@@ -11683,11 +11696,11 @@ class Collection extends EventEmitterObject {
11683
11696
  if (models)
11684
11697
  this.reset(models, Object.assign({ silent: true }, options));
11685
11698
  this[Symbol.iterator] = this.values;
11686
- // When autoSync is on, `initialized` is always a Promise so callers can
11687
- // uniformly `await collection.initialized`; it resolves immediately when
11699
+ // When autoSync is on, `hydrated` is always a Promise so callers can
11700
+ // uniformly `await collection.hydrated`; it resolves immediately when
11688
11701
  // there's no storage to hydrate from.
11689
11702
  if (this.autoSync) {
11690
- this.initialized = getStorage(this) ? __classPrivateFieldGet(this, _Collection_instances, "m", _Collection_hydrate).call(this) : Promise.resolve();
11703
+ this.hydrated = getStorage(this) ? __classPrivateFieldGet(this, _Collection_instances, "m", _Collection_hydrate).call(this) : Promise.resolve();
11691
11704
  }
11692
11705
  }
11693
11706
  get comparator() {
@@ -11719,7 +11732,7 @@ class Collection extends EventEmitterObject {
11719
11732
  }
11720
11733
  /**
11721
11734
  * Override to return `true` to automatically load the collection from
11722
- * storage on construction. Await `initialized` to know when hydration
11735
+ * storage on construction. Await `hydrated` to know when hydration
11723
11736
  * is complete.
11724
11737
  *
11725
11738
  * Note: collection `autoSync` is hydrate-only. Unlike `Model`, it does