@converse/skeletor 3.1.1 → 3.1.3
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 +139 -0
- package/dist/skeletor.esm.js +21 -13
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +21 -13
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +1 -1
- package/dist/skeletor.node.js +21 -13
- package/dist/skeletor.node.mjs +21 -13
- package/package.json +4 -2
- package/src/collection.ts +3 -2
- package/src/model.ts +0 -4
- package/src/storage.ts +18 -6
package/dist/skeletor.js
CHANGED
|
@@ -8711,7 +8711,7 @@
|
|
|
8711
8711
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8712
8712
|
const that = this;
|
|
8713
8713
|
async function localSync(method, model, options) {
|
|
8714
|
-
let resp,
|
|
8714
|
+
let resp, caughtError, promise, new_attributes;
|
|
8715
8715
|
// We get the collection (and if necessary the model attribute.
|
|
8716
8716
|
// Waiting for storeInitialized will cause another iteration of
|
|
8717
8717
|
// the event loop, after which the collection reference will
|
|
@@ -8768,10 +8768,12 @@
|
|
|
8768
8768
|
catch (error) {
|
|
8769
8769
|
const storageSize = await that.getStorageSize();
|
|
8770
8770
|
if (error.code === 22 && storageSize === 0) {
|
|
8771
|
-
|
|
8771
|
+
caughtError = new Error('Private browsing is unsupported');
|
|
8772
8772
|
}
|
|
8773
8773
|
else {
|
|
8774
|
-
|
|
8774
|
+
// Preserve a real Error (stack/name); wrap anything else so the
|
|
8775
|
+
// error path always surfaces an Error, never a bare string.
|
|
8776
|
+
caughtError = error instanceof Error ? error : new Error(error?.message ?? String(error));
|
|
8775
8777
|
}
|
|
8776
8778
|
}
|
|
8777
8779
|
if (resp) {
|
|
@@ -8785,10 +8787,21 @@
|
|
|
8785
8787
|
options.success(data, options);
|
|
8786
8788
|
}
|
|
8787
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
|
+
}
|
|
8798
|
+
}
|
|
8788
8799
|
else {
|
|
8789
|
-
|
|
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.
|
|
8790
8803
|
if (options && options.error) {
|
|
8791
|
-
options.error(
|
|
8804
|
+
options.error(caughtError ?? new Error('Record Not Found'));
|
|
8792
8805
|
}
|
|
8793
8806
|
}
|
|
8794
8807
|
}
|
|
@@ -11460,12 +11473,6 @@
|
|
|
11460
11473
|
try {
|
|
11461
11474
|
await this.fetch({ fromStorage: true, promise: true });
|
|
11462
11475
|
}
|
|
11463
|
-
catch (e) {
|
|
11464
|
-
// 'Record Not Found' is a normal first-run state (nothing stored yet);
|
|
11465
|
-
// keep the initial attributes and resolve. Re-throw anything else.
|
|
11466
|
-
if (e !== 'Record Not Found')
|
|
11467
|
-
throw e;
|
|
11468
|
-
}
|
|
11469
11476
|
finally {
|
|
11470
11477
|
__classPrivateFieldSet(this, _Model_state, 'ready', "f");
|
|
11471
11478
|
}
|
|
@@ -12240,8 +12247,9 @@
|
|
|
12240
12247
|
}
|
|
12241
12248
|
_Collection_instances = new WeakSet(), _Collection_hydrate = async function _Collection_hydrate() {
|
|
12242
12249
|
ensureUnloadListener(PersistentStorage);
|
|
12243
|
-
//
|
|
12244
|
-
//
|
|
12250
|
+
// An empty store is a normal first-run state: findAll() returns [] and a
|
|
12251
|
+
// missing model record resolves to null, so hydration resolves rather
|
|
12252
|
+
// than rejecting.
|
|
12245
12253
|
await this.fetch({ fromStorage: true, promise: true });
|
|
12246
12254
|
}, _a = Symbol.iterator;
|
|
12247
12255
|
// This "enum" defines the three possible kinds of values which can be emitted
|