@automerge/automerge-repo 1.0.18 → 1.0.19
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/DocHandle.d.ts +1 -3
- package/dist/DocHandle.d.ts.map +1 -1
- package/dist/DocHandle.js +8 -13
- package/package.json +2 -2
- package/src/DocHandle.ts +7 -13
- package/test/DocHandle.test.ts +1 -1
package/dist/DocHandle.d.ts
CHANGED
|
@@ -188,8 +188,6 @@ export declare const HandleState: {
|
|
|
188
188
|
readonly REQUESTING: "requesting";
|
|
189
189
|
/** The document is available */
|
|
190
190
|
readonly READY: "ready";
|
|
191
|
-
/** We were unable to load or request the document for some reason */
|
|
192
|
-
readonly FAILED: "failed";
|
|
193
191
|
/** The document has been deleted from the repo */
|
|
194
192
|
readonly DELETED: "deleted";
|
|
195
193
|
/** The document was not available in storage or from any connected peers */
|
|
@@ -208,5 +206,5 @@ export declare const Event: {
|
|
|
208
206
|
readonly DELETE: "DELETE";
|
|
209
207
|
readonly MARK_UNAVAILABLE: "MARK_UNAVAILABLE";
|
|
210
208
|
};
|
|
211
|
-
export declare const IDLE: "idle", LOADING: "loading", AWAITING_NETWORK: "awaitingNetwork", REQUESTING: "requesting", READY: "ready",
|
|
209
|
+
export declare const IDLE: "idle", LOADING: "loading", AWAITING_NETWORK: "awaitingNetwork", REQUESTING: "requesting", READY: "ready", DELETED: "deleted", UNAVAILABLE: "unavailable";
|
|
212
210
|
//# sourceMappingURL=DocHandle.d.ts.map
|
package/dist/DocHandle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocHandle.d.ts","sourceRoot":"","sources":["../src/DocHandle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,2BAA2B,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EASL,UAAU,EAEX,MAAM,QAAQ,CAAA;AAMf,OAAO,KAAK,EA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CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACpE,MAAM,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACpD,MAAM,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACpD,WAAW,EAAE,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACzD,mBAAmB,EAAE,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IAC3E,4BAA4B,EAAE,CAC5B,OAAO,EAAE,wCAAwC,CAAC,CAAC,CAAC,KACjD,IAAI,CAAA;IACT,cAAc,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAA;CAC/D;AAMD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IACtB,kEAAkE;;IAElE,mDAAmD;;IAEnD,sDAAsD;;IAEtD,6EAA6E;;IAE7E,gCAAgC;;IAEhC,kDAAkD;;IAElD,4EAA4E;;CAEpE,CAAA;AACV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA;AAkBxE,eAAO,MAAM,KAAK;;;;;;;;;;;CAWR,CAAA;AA8CV,eAAO,MACL,IAAI,UACJ,OAAO,aACP,gBAAgB,qBAChB,UAAU,gBACV,KAAK,WACL,OAAO,aACP,WAAW,eACE,CAAA"}
|
package/dist/DocHandle.js
CHANGED
|
@@ -50,9 +50,9 @@ export class DocHandle//
|
|
|
50
50
|
* Internally we use a state machine to orchestrate document loading and/or syncing, in order to
|
|
51
51
|
* avoid requesting data we already have, or surfacing intermediate values to the consumer.
|
|
52
52
|
*
|
|
53
|
-
* ┌─────────────────────┬─────────TIMEOUT
|
|
54
|
-
* ┌───┴─────┐ ┌───┴────────┐ │
|
|
55
|
-
* ┌───────┐ ┌──FIND──┤ loading ├─REQUEST──►│ requesting ├─UPDATE──┐
|
|
53
|
+
* ┌─────────────────────┬─────────TIMEOUT────►┌─────────────┐
|
|
54
|
+
* ┌───┴─────┐ ┌───┴────────┐ │ unavailable │
|
|
55
|
+
* ┌───────┐ ┌──FIND──┤ loading ├─REQUEST──►│ requesting ├─UPDATE──┐ └─────────────┘
|
|
56
56
|
* │ idle ├──┤ └───┬─────┘ └────────────┘ │
|
|
57
57
|
* └───────┘ │ │ └─►┌────────┐
|
|
58
58
|
* │ └───────LOAD───────────────────────────────►│ ready │
|
|
@@ -87,7 +87,7 @@ export class DocHandle//
|
|
|
87
87
|
after: [
|
|
88
88
|
{
|
|
89
89
|
delay: this.#timeoutDelay,
|
|
90
|
-
target:
|
|
90
|
+
target: UNAVAILABLE,
|
|
91
91
|
},
|
|
92
92
|
],
|
|
93
93
|
},
|
|
@@ -111,7 +111,7 @@ export class DocHandle//
|
|
|
111
111
|
after: [
|
|
112
112
|
{
|
|
113
113
|
delay: this.#timeoutDelay,
|
|
114
|
-
target:
|
|
114
|
+
target: UNAVAILABLE,
|
|
115
115
|
},
|
|
116
116
|
],
|
|
117
117
|
},
|
|
@@ -122,9 +122,6 @@ export class DocHandle//
|
|
|
122
122
|
DELETE: { actions: "onDelete", target: DELETED },
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
|
-
failed: {
|
|
126
|
-
type: "final",
|
|
127
|
-
},
|
|
128
125
|
deleted: {
|
|
129
126
|
type: "final",
|
|
130
127
|
},
|
|
@@ -198,7 +195,7 @@ export class DocHandle//
|
|
|
198
195
|
if (!Array.isArray(awaitStates))
|
|
199
196
|
awaitStates = [awaitStates];
|
|
200
197
|
return Promise.any(awaitStates.map(state => waitFor(this.#machine, s => s.matches(state), {
|
|
201
|
-
timeout: this.#timeoutDelay *
|
|
198
|
+
timeout: this.#timeoutDelay * 2, // use a longer delay here so as not to race with other delays
|
|
202
199
|
})));
|
|
203
200
|
}
|
|
204
201
|
// PUBLIC
|
|
@@ -243,7 +240,7 @@ export class DocHandle//
|
|
|
243
240
|
await this.#statePromise(awaitStates);
|
|
244
241
|
}
|
|
245
242
|
catch (error) {
|
|
246
|
-
// if we timed out (or the
|
|
243
|
+
// if we timed out (or have determined the document is currently unavailable), return undefined
|
|
247
244
|
return undefined;
|
|
248
245
|
}
|
|
249
246
|
// Return the document
|
|
@@ -396,8 +393,6 @@ export const HandleState = {
|
|
|
396
393
|
REQUESTING: "requesting",
|
|
397
394
|
/** The document is available */
|
|
398
395
|
READY: "ready",
|
|
399
|
-
/** We were unable to load or request the document for some reason */
|
|
400
|
-
FAILED: "failed",
|
|
401
396
|
/** The document has been deleted from the repo */
|
|
402
397
|
DELETED: "deleted",
|
|
403
398
|
/** The document was not available in storage or from any connected peers */
|
|
@@ -417,5 +412,5 @@ export const Event = {
|
|
|
417
412
|
MARK_UNAVAILABLE: "MARK_UNAVAILABLE",
|
|
418
413
|
};
|
|
419
414
|
// CONSTANTS
|
|
420
|
-
export const { IDLE, LOADING, AWAITING_NETWORK, REQUESTING, READY,
|
|
415
|
+
export const { IDLE, LOADING, AWAITING_NETWORK, REQUESTING, READY, DELETED, UNAVAILABLE, } = HandleState;
|
|
421
416
|
const { CREATE, FIND, REQUEST, UPDATE, TIMEOUT, DELETE, REQUEST_COMPLETE, MARK_UNAVAILABLE, AWAIT_NETWORK, NETWORK_READY, } = Event;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/automerge-repo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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>",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7d28ca50dfa437ac6f7b1722b89b3f6844b90de7"
|
|
59
59
|
}
|
package/src/DocHandle.ts
CHANGED
|
@@ -71,9 +71,9 @@ export class DocHandle<T> //
|
|
|
71
71
|
* Internally we use a state machine to orchestrate document loading and/or syncing, in order to
|
|
72
72
|
* avoid requesting data we already have, or surfacing intermediate values to the consumer.
|
|
73
73
|
*
|
|
74
|
-
* ┌─────────────────────┬─────────TIMEOUT
|
|
75
|
-
* ┌───┴─────┐ ┌───┴────────┐ │
|
|
76
|
-
* ┌───────┐ ┌──FIND──┤ loading ├─REQUEST──►│ requesting ├─UPDATE──┐
|
|
74
|
+
* ┌─────────────────────┬─────────TIMEOUT────►┌─────────────┐
|
|
75
|
+
* ┌───┴─────┐ ┌───┴────────┐ │ unavailable │
|
|
76
|
+
* ┌───────┐ ┌──FIND──┤ loading ├─REQUEST──►│ requesting ├─UPDATE──┐ └─────────────┘
|
|
77
77
|
* │ idle ├──┤ └───┬─────┘ └────────────┘ │
|
|
78
78
|
* └───────┘ │ │ └─►┌────────┐
|
|
79
79
|
* │ └───────LOAD───────────────────────────────►│ ready │
|
|
@@ -111,7 +111,7 @@ export class DocHandle<T> //
|
|
|
111
111
|
after: [
|
|
112
112
|
{
|
|
113
113
|
delay: this.#timeoutDelay,
|
|
114
|
-
target:
|
|
114
|
+
target: UNAVAILABLE,
|
|
115
115
|
},
|
|
116
116
|
],
|
|
117
117
|
},
|
|
@@ -135,7 +135,7 @@ export class DocHandle<T> //
|
|
|
135
135
|
after: [
|
|
136
136
|
{
|
|
137
137
|
delay: this.#timeoutDelay,
|
|
138
|
-
target:
|
|
138
|
+
target: UNAVAILABLE,
|
|
139
139
|
},
|
|
140
140
|
],
|
|
141
141
|
},
|
|
@@ -146,9 +146,6 @@ export class DocHandle<T> //
|
|
|
146
146
|
DELETE: { actions: "onDelete", target: DELETED },
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
|
-
failed: {
|
|
150
|
-
type: "final",
|
|
151
|
-
},
|
|
152
149
|
deleted: {
|
|
153
150
|
type: "final",
|
|
154
151
|
},
|
|
@@ -240,7 +237,7 @@ export class DocHandle<T> //
|
|
|
240
237
|
return Promise.any(
|
|
241
238
|
awaitStates.map(state =>
|
|
242
239
|
waitFor(this.#machine, s => s.matches(state), {
|
|
243
|
-
timeout: this.#timeoutDelay *
|
|
240
|
+
timeout: this.#timeoutDelay * 2, // use a longer delay here so as not to race with other delays
|
|
244
241
|
})
|
|
245
242
|
)
|
|
246
243
|
)
|
|
@@ -294,7 +291,7 @@ export class DocHandle<T> //
|
|
|
294
291
|
// wait for the document to enter one of the desired states
|
|
295
292
|
await this.#statePromise(awaitStates)
|
|
296
293
|
} catch (error) {
|
|
297
|
-
// if we timed out (or the
|
|
294
|
+
// if we timed out (or have determined the document is currently unavailable), return undefined
|
|
298
295
|
return undefined
|
|
299
296
|
}
|
|
300
297
|
// Return the document
|
|
@@ -538,8 +535,6 @@ export const HandleState = {
|
|
|
538
535
|
REQUESTING: "requesting",
|
|
539
536
|
/** The document is available */
|
|
540
537
|
READY: "ready",
|
|
541
|
-
/** We were unable to load or request the document for some reason */
|
|
542
|
-
FAILED: "failed",
|
|
543
538
|
/** The document has been deleted from the repo */
|
|
544
539
|
DELETED: "deleted",
|
|
545
540
|
/** The document was not available in storage or from any connected peers */
|
|
@@ -626,7 +621,6 @@ export const {
|
|
|
626
621
|
AWAITING_NETWORK,
|
|
627
622
|
REQUESTING,
|
|
628
623
|
READY,
|
|
629
|
-
FAILED,
|
|
630
624
|
DELETED,
|
|
631
625
|
UNAVAILABLE,
|
|
632
626
|
} = HandleState
|
package/test/DocHandle.test.ts
CHANGED