@converse/skeletor 3.1.4 → 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.
- package/CHANGES.md +6 -0
- package/README.md +9 -3
- package/dist/skeletor.d.ts +8 -2
- package/dist/skeletor.esm.js +254 -241
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +254 -241
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +4 -4
- package/dist/skeletor.node.js +255 -242
- package/dist/skeletor.node.mjs +255 -242
- package/package.json +3 -1
- package/src/declarations.d.ts +11 -0
- package/src/drivers/nodeSQLiteStorage.ts +2 -7
- package/src/drivers/types.ts +8 -2
- package/src/storage.ts +11 -26
package/dist/skeletor.node.mjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
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
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
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
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
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
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
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
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7207
|
+
var idbKeyRange = getIDBKeyRange();
|
|
7210
7208
|
|
|
7211
|
-
|
|
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
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
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
|
-
|
|
7228
|
-
var cursor = req.result; // event.target.result;
|
|
7222
|
+
var set = keys.sort(comparer);
|
|
7229
7223
|
|
|
7230
|
-
|
|
7231
|
-
resolve(result);
|
|
7232
|
-
return;
|
|
7233
|
-
}
|
|
7224
|
+
var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
|
|
7234
7225
|
|
|
7235
|
-
|
|
7226
|
+
var req;
|
|
7236
7227
|
|
|
7237
|
-
|
|
7238
|
-
|
|
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
|
-
|
|
7241
|
-
|
|
7242
|
-
resolve(result);
|
|
7243
|
-
return;
|
|
7244
|
-
}
|
|
7245
|
-
}
|
|
7242
|
+
req.onsuccess = function () /*event*/{
|
|
7243
|
+
var cursor = req.result; // event.target.result;
|
|
7246
7244
|
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7267
|
-
|
|
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
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
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
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7281
|
+
req.onerror = function () /*event*/{
|
|
7282
|
+
reject(req.error);
|
|
7283
|
+
};
|
|
7284
|
+
}).catch(reject);
|
|
7285
|
+
});
|
|
7286
|
+
return promise;
|
|
7287
|
+
}
|
|
7291
7288
|
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
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
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
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
|
-
|
|
7304
|
-
}
|
|
7303
|
+
t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
|
|
7305
7304
|
|
|
7306
|
-
|
|
7307
|
-
}, function (t, error) {
|
|
7308
|
-
reject(error);
|
|
7309
|
-
});
|
|
7310
|
-
});
|
|
7311
|
-
}).catch(reject);
|
|
7312
|
-
});
|
|
7313
|
-
return promise;
|
|
7314
|
-
}
|
|
7305
|
+
var result = {};
|
|
7315
7306
|
|
|
7316
|
-
|
|
7317
|
-
|
|
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
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
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
|
-
|
|
7334
|
-
|
|
7335
|
-
}
|
|
7318
|
+
result[item.key] = value;
|
|
7319
|
+
}
|
|
7336
7320
|
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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 (
|
|
8095
|
-
|
|
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
|
-
//
|
|
8116
|
-
//
|
|
8117
|
-
//
|
|
8118
|
-
|
|
8119
|
-
|
|
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';
|
|
@@ -8319,7 +8332,7 @@ class NodeSQLiteStorage {
|
|
|
8319
8332
|
}
|
|
8320
8333
|
throw e;
|
|
8321
8334
|
}
|
|
8322
|
-
return Promise.resolve();
|
|
8335
|
+
return Promise.resolve(items);
|
|
8323
8336
|
}
|
|
8324
8337
|
getItems(keys) {
|
|
8325
8338
|
if (keys.length === 0) {
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"browser": "dist/skeletor.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./dist/skeletor.d.ts",
|
|
12
13
|
"node": {
|
|
13
14
|
"require": "./dist/skeletor.node.js",
|
|
14
15
|
"import": "./dist/skeletor.node.mjs"
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"./node": {
|
|
23
|
+
"types": "./dist/skeletor.d.ts",
|
|
22
24
|
"require": "./dist/skeletor.node.js",
|
|
23
25
|
"import": "./dist/skeletor.node.mjs"
|
|
24
26
|
}
|
|
@@ -36,7 +38,7 @@
|
|
|
36
38
|
"contributors": [
|
|
37
39
|
"JC Brand"
|
|
38
40
|
],
|
|
39
|
-
"version": "3.1.
|
|
41
|
+
"version": "3.1.5",
|
|
40
42
|
"engines": {
|
|
41
43
|
"node": ">=22.0.0"
|
|
42
44
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@converse/localforage-getitems` ships its types as an ambient script that
|
|
3
|
+
* declares the *unscoped* module name (`localforage-getitems`), left over from
|
|
4
|
+
* the package it was forked from. TypeScript therefore resolves the scoped
|
|
5
|
+
* specifier to a `typings/index.d.ts` that isn't a module (TS2306), so declare
|
|
6
|
+
* the shape we use here instead.
|
|
7
|
+
*/
|
|
8
|
+
declare module '@converse/localforage-getitems' {
|
|
9
|
+
export function extendPrototype<T>(localforage: T): T;
|
|
10
|
+
export const extendPrototypeResult: boolean;
|
|
11
|
+
}
|