@automerge/automerge-repo 2.4.0-alpha.2 → 2.4.0
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/Repo.d.ts.map +1 -1
- package/dist/Repo.js +9 -3
- package/dist/helpers/abortable.d.ts +15 -0
- package/dist/helpers/abortable.d.ts.map +1 -1
- package/dist/helpers/abortable.js +18 -1
- package/package.json +2 -2
- package/src/Repo.ts +9 -3
- package/src/helpers/abortable.ts +19 -2
- package/test/Repo.test.ts +9 -2
package/dist/Repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repo.d.ts","sourceRoot":"","sources":["../src/Repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAS5C,OAAO,EAEL,SAAS,EAKV,MAAM,gBAAgB,CAAA;AAIvB,OAAO,EACL,uBAAuB,EACvB,KAAK,YAAY,EAClB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACjF,OAAO,EACL,cAAc,EAEf,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAEZ,UAAU,EACV,MAAM,EACP,MAAM,YAAY,CAAA;AACnB,OAAO,EAAa,YAAY,
|
|
1
|
+
{"version":3,"file":"Repo.d.ts","sourceRoot":"","sources":["../src/Repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,2BAA2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AC,GAAG,EAAE,qBAAqB,KAAK,IAAI,CAAA;IAC5D,aAAa,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAA;CACzC;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,MAAM,UAAU,GAClB,cAAc,GACd;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB,GACD;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA"}
|
package/dist/Repo.js
CHANGED
|
@@ -9,7 +9,7 @@ import { throttle } from "./helpers/throttle.js";
|
|
|
9
9
|
import { NetworkSubsystem } from "./network/NetworkSubsystem.js";
|
|
10
10
|
import { StorageSubsystem } from "./storage/StorageSubsystem.js";
|
|
11
11
|
import { CollectionSynchronizer } from "./synchronizer/CollectionSynchronizer.js";
|
|
12
|
-
import { abortable } from "./helpers/abortable.js";
|
|
12
|
+
import { abortable, AbortError } from "./helpers/abortable.js";
|
|
13
13
|
function randomPeerId() {
|
|
14
14
|
return ("peer-" + Math.random().toString(36).slice(4));
|
|
15
15
|
}
|
|
@@ -510,7 +510,13 @@ export class Repo extends EventEmitter {
|
|
|
510
510
|
catch (error) {
|
|
511
511
|
progressSignal.notify({
|
|
512
512
|
state: "failed",
|
|
513
|
-
error:
|
|
513
|
+
error:
|
|
514
|
+
// In most JS environments DOMException extends Error, but not always, in some environments it's a separate type.
|
|
515
|
+
// Some Node.js DOM polyfills do not always extend the Error
|
|
516
|
+
// Jsdom polyfill doesn't extend Error, whereas happy-dom does.
|
|
517
|
+
error instanceof Error || error instanceof DOMException
|
|
518
|
+
? error
|
|
519
|
+
: new Error(String(error)),
|
|
514
520
|
handle: this.#getHandle({ documentId }),
|
|
515
521
|
});
|
|
516
522
|
}
|
|
@@ -519,7 +525,7 @@ export class Repo extends EventEmitter {
|
|
|
519
525
|
const { allowableStates = ["ready"], signal } = options;
|
|
520
526
|
// Check if already aborted
|
|
521
527
|
if (signal?.aborted) {
|
|
522
|
-
throw new
|
|
528
|
+
throw new AbortError();
|
|
523
529
|
}
|
|
524
530
|
const progress = this.findWithProgress(id, { signal });
|
|
525
531
|
if ("subscribe" in progress) {
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown when an operation is aborted.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when an operation is aborted. It is a subclass of DOMException
|
|
6
|
+
* with name "AbortError".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new AbortError()
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class AbortError extends DOMException {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Wraps a Promise and causes it to reject when the signal is aborted.
|
|
3
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortable.d.ts","sourceRoot":"","sources":["../../src/helpers/abortable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"abortable.d.ts","sourceRoot":"","sources":["../../src/helpers/abortable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,OAAO,CAAC,EAAE,MAAM;CAG7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EACb,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,CAAC,CAAC,CAsBZ;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB"}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown when an operation is aborted.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when an operation is aborted. It is a subclass of DOMException
|
|
6
|
+
* with name "AbortError".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new AbortError()
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class AbortError extends DOMException {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message ?? "Operation aborted", "AbortError");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
1
18
|
/**
|
|
2
19
|
* Wraps a Promise and causes it to reject when the signal is aborted.
|
|
3
20
|
*
|
|
@@ -31,7 +48,7 @@ export function abortable(p, signal) {
|
|
|
31
48
|
return new Promise((resolve, reject) => {
|
|
32
49
|
signal?.addEventListener("abort", () => {
|
|
33
50
|
if (!settled) {
|
|
34
|
-
reject(new
|
|
51
|
+
reject(new AbortError());
|
|
35
52
|
}
|
|
36
53
|
}, { once: true });
|
|
37
54
|
p.then(result => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/automerge-repo",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A repository object to manage a collection of automerge documents",
|
|
5
5
|
"repository": "https://github.com/automerge/automerge-repo/tree/master/packages/automerge-repo",
|
|
6
6
|
"author": "Peter van Hardenberg <pvh@pvh.ca>",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "586290a804e12206362cf41c87e309bd0fb22d69"
|
|
63
63
|
}
|
package/src/Repo.ts
CHANGED
|
@@ -41,7 +41,7 @@ import type {
|
|
|
41
41
|
DocumentId,
|
|
42
42
|
PeerId,
|
|
43
43
|
} from "./types.js"
|
|
44
|
-
import { abortable, AbortOptions } from "./helpers/abortable.js"
|
|
44
|
+
import { abortable, AbortOptions, AbortError } from "./helpers/abortable.js"
|
|
45
45
|
import { FindProgress } from "./FindProgress.js"
|
|
46
46
|
|
|
47
47
|
export type FindProgressWithMethods<T> = FindProgress<T> & {
|
|
@@ -704,7 +704,13 @@ export class Repo extends EventEmitter<RepoEvents> {
|
|
|
704
704
|
} catch (error) {
|
|
705
705
|
progressSignal.notify({
|
|
706
706
|
state: "failed" as const,
|
|
707
|
-
error:
|
|
707
|
+
error:
|
|
708
|
+
// In most JS environments DOMException extends Error, but not always, in some environments it's a separate type.
|
|
709
|
+
// Some Node.js DOM polyfills do not always extend the Error
|
|
710
|
+
// Jsdom polyfill doesn't extend Error, whereas happy-dom does.
|
|
711
|
+
error instanceof Error || error instanceof DOMException
|
|
712
|
+
? error
|
|
713
|
+
: new Error(String(error)),
|
|
708
714
|
handle: this.#getHandle<T>({ documentId }),
|
|
709
715
|
})
|
|
710
716
|
}
|
|
@@ -718,7 +724,7 @@ export class Repo extends EventEmitter<RepoEvents> {
|
|
|
718
724
|
|
|
719
725
|
// Check if already aborted
|
|
720
726
|
if (signal?.aborted) {
|
|
721
|
-
throw new
|
|
727
|
+
throw new AbortError()
|
|
722
728
|
}
|
|
723
729
|
|
|
724
730
|
const progress = this.findWithProgress<T>(id, { signal })
|
package/src/helpers/abortable.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown when an operation is aborted.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when an operation is aborted. It is a subclass of DOMException
|
|
6
|
+
* with name "AbortError".
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new AbortError()
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class AbortError extends DOMException {
|
|
14
|
+
constructor(message?: string) {
|
|
15
|
+
super(message ?? "Operation aborted", "AbortError")
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
1
19
|
/**
|
|
2
20
|
* Wraps a Promise and causes it to reject when the signal is aborted.
|
|
3
21
|
*
|
|
@@ -26,7 +44,6 @@
|
|
|
26
44
|
* before the promise p settles, and settles as p settles otherwise
|
|
27
45
|
* @throws {DOMException} With name "AbortError" if aborted before p settles
|
|
28
46
|
*/
|
|
29
|
-
|
|
30
47
|
export function abortable<T>(
|
|
31
48
|
p: Promise<T>,
|
|
32
49
|
signal: AbortSignal | undefined
|
|
@@ -37,7 +54,7 @@ export function abortable<T>(
|
|
|
37
54
|
"abort",
|
|
38
55
|
() => {
|
|
39
56
|
if (!settled) {
|
|
40
|
-
reject(new
|
|
57
|
+
reject(new AbortError())
|
|
41
58
|
}
|
|
42
59
|
},
|
|
43
60
|
{ once: true }
|
package/test/Repo.test.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { getRandomItem } from "./helpers/getRandomItem.js"
|
|
|
34
34
|
import { TestDoc } from "./types.js"
|
|
35
35
|
import { StorageId, StorageKey } from "../src/storage/types.js"
|
|
36
36
|
import { FindProgress } from "../src/FindProgress.js"
|
|
37
|
+
import { AbortError } from "../src/helpers/abortable.js"
|
|
37
38
|
|
|
38
39
|
describe("Repo", () => {
|
|
39
40
|
describe("constructor", () => {
|
|
@@ -1993,7 +1994,7 @@ describe("Repo.find() abort behavior", () => {
|
|
|
1993
1994
|
|
|
1994
1995
|
await expect(
|
|
1995
1996
|
repo.find(generateAutomergeUrl(), { signal: controller.signal })
|
|
1996
|
-
).rejects.toThrow(
|
|
1997
|
+
).rejects.toThrow(AbortError)
|
|
1997
1998
|
})
|
|
1998
1999
|
|
|
1999
2000
|
it("can abort while waiting for ready state", async () => {
|
|
@@ -2007,7 +2008,13 @@ describe("Repo.find() abort behavior", () => {
|
|
|
2007
2008
|
const findPromise = repo.find(url, { signal: controller.signal })
|
|
2008
2009
|
controller.abort()
|
|
2009
2010
|
|
|
2010
|
-
|
|
2011
|
+
// Official specification just says to check `reason.name === "AbortError"`
|
|
2012
|
+
// Using AbortError promotes correctness across different JS environments and provides a simpler check.
|
|
2013
|
+
await expect(findPromise).rejects.toThrow(AbortError)
|
|
2014
|
+
await expect(findPromise).rejects.rejects.toHaveProperty(
|
|
2015
|
+
"name",
|
|
2016
|
+
"AbortError"
|
|
2017
|
+
)
|
|
2011
2018
|
await expect(findPromise).rejects.not.toThrow("unavailable")
|
|
2012
2019
|
})
|
|
2013
2020
|
|