@agoric/vow 0.1.1-dev-3154483.0 → 0.1.1-dev-5a03adc.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/package.json +4 -4
- package/src/tools.d.ts +2 -2
- package/src/tools.d.ts.map +1 -1
- package/src/tools.js +5 -0
- package/src/types.d.ts +3 -9
- package/src/types.d.ts.map +1 -1
- package/src/types.js +1 -15
- package/src/watch-utils.d.ts +3 -5
- package/src/watch-utils.d.ts.map +1 -1
- package/src/watch-utils.js +3 -3
- package/src/watch.d.ts +1 -1
- package/src/watch.d.ts.map +1 -1
- package/src/watch.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vow",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-5a03adc.0+5a03adc",
|
|
4
4
|
"description": "Remote (shortening and disconnection-tolerant) Promise-likes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
24
|
-
"@agoric/internal": "0.3.3-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-5a03adc.0+5a03adc",
|
|
24
|
+
"@agoric/internal": "0.3.3-dev-5a03adc.0+5a03adc",
|
|
25
25
|
"@endo/env-options": "^1.1.4",
|
|
26
26
|
"@endo/eventual-send": "^1.2.2",
|
|
27
27
|
"@endo/pass-style": "^1.4.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"typeCoverage": {
|
|
54
54
|
"atLeast": 89.6
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "5a03adce8cbd015d9b10b3c52267dc4fe1a3b8ab"
|
|
57
57
|
}
|
package/src/tools.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ export function prepareVowTools(zone: Zone, powers?: {
|
|
|
2
2
|
isRetryableReason?: ((reason: any) => boolean) | undefined;
|
|
3
3
|
} | undefined): {
|
|
4
4
|
when: <T, TResult1 = import("./types.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("./types.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
5
|
-
watch: <T_1 =
|
|
5
|
+
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: import("./types.js").ERef<T_1 | import("./types.js").Vow<T_1>>, watcher?: import("./types.js").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => import("./types.js").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
|
|
6
6
|
makeVowKit: <T_2>() => import("./types.js").VowKit<T_2>;
|
|
7
|
-
allVows: (vows:
|
|
7
|
+
allVows: (vows: unknown[]) => import("./types.js").Vow<any[]>;
|
|
8
8
|
};
|
|
9
9
|
import type { Zone } from '@agoric/base-zone';
|
|
10
10
|
//# sourceMappingURL=tools.d.ts.map
|
package/src/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAaO;kCAFa,GAAG,KAAK,OAAO;;sFAEc,CAAC
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAaO;kCAFa,GAAG,KAAK,OAAO;;sFAEc,CAAC;;;oBAWrC,OAAO,EAAE;EAKrB;0BAvBuB,mBAAmB"}
|
package/src/tools.js
CHANGED
|
@@ -19,6 +19,11 @@ export const prepareVowTools = (zone, powers = {}) => {
|
|
|
19
19
|
const makeWatchUtils = prepareWatchUtils(zone, watch, makeVowKit);
|
|
20
20
|
const watchUtils = makeWatchUtils();
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Vow-tolerant implementation of Promise.all.
|
|
24
|
+
*
|
|
25
|
+
* @param {unknown[]} vows
|
|
26
|
+
*/
|
|
22
27
|
const allVows = vows => watchUtils.all(vows);
|
|
23
28
|
|
|
24
29
|
return harden({ when, watch, makeVowKit, allVows });
|
package/src/types.d.ts
CHANGED
|
@@ -34,25 +34,19 @@ export type VowKit<T = any> = {
|
|
|
34
34
|
vow: Vow<T>;
|
|
35
35
|
resolver: VowResolver<T>;
|
|
36
36
|
};
|
|
37
|
-
export type VowPromiseKit<T = any> = {
|
|
38
|
-
vow: Vow<T>;
|
|
39
|
-
resolver: VowResolver<T>;
|
|
40
|
-
promise: Promise<T>;
|
|
41
|
-
};
|
|
42
37
|
export type VowResolver<T = any> = {
|
|
43
38
|
resolve(value?: T | PromiseVow<T> | undefined): void;
|
|
44
39
|
reject(reason?: any): void;
|
|
45
40
|
};
|
|
46
|
-
export type Watcher<T = any, TResult1 = T, TResult2 =
|
|
41
|
+
export type Watcher<T = any, TResult1 = T, TResult2 = never, C = any> = {
|
|
47
42
|
onFulfilled?: ((value: T, context?: C) => TResult1 | Vow<TResult1> | PromiseVow<TResult1>) | undefined;
|
|
48
43
|
onRejected?: ((reason: any) => TResult2 | Vow<TResult2> | PromiseVow<TResult2>) | undefined;
|
|
49
44
|
};
|
|
50
|
-
export type Specimen<T = any> = ERef<T | Vow<T>>;
|
|
51
45
|
export type VowTools = {
|
|
52
46
|
when: <T, TResult1 = Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
53
|
-
watch: <T_1 =
|
|
47
|
+
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: ERef<T_1 | Vow<T_1>>, watcher?: Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
|
|
54
48
|
makeVowKit: <T_2>() => VowKit<T_2>;
|
|
55
|
-
allVows: (vows:
|
|
49
|
+
allVows: (vows: unknown[]) => Vow<any[]>;
|
|
56
50
|
};
|
|
57
51
|
import type { IsPrimitive } from '@agoric/internal';
|
|
58
52
|
import type { RemotableBrand } from '@endo/eventual-send';
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;;uBAc6B,CAAC,IAAjB,OAAO,CAAS,CAAC,AAAR,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;iBAMH,CAAC,IAAD,CAAC,AAAhB,GAAG,WAAW,CAAC,CAAC,CAAC;;;;;mBAY9B,CAAK;;;;;;;kBAWsB,CAAC;;;;;;;aAAf,MAAM,OAAO,CAAC,CAAC,CAAC;;uBASe,CAAC;;;gBAKJ,CAAC;;;mBAOhB,CAAC,UAFf;IACZ,GAAO,EAAE,GAAG,CACc,CAAC,AADb,CAAC,CAAC;IAChB,QAAY,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;;uBAc6B,CAAC,IAAjB,OAAO,CAAS,CAAC,AAAR,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;iBAMH,CAAC,IAAD,CAAC,AAAhB,GAAG,WAAW,CAAC,CAAC,CAAC;;;;;mBAY9B,CAAK;;;;;;;kBAWsB,CAAC;;;;;;;aAAf,MAAM,OAAO,CAAC,CAAC,CAAC;;uBASe,CAAC;;;gBAKJ,CAAC;;;mBAOhB,CAAC,UAFf;IACZ,GAAO,EAAE,GAAG,CACc,CAAC,AADb,CAAC,CAAC;IAChB,QAAY,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CAC1B;wBAK0C,CAAC;oDAAI,IAAI;oBAAkB,GAAG,GAAG,IAAI;;oBAS7D,CAAC,QAAyD,QAAQ,MAClB,QAAQ,UAD3C,CAAC;2BAAd,CAAC,YAAY,CAAC;2BACb,GAAG;;;iEAlE0B,CAAA;;;oBAehB,SACjC;;iCAvBmC,kBAAkB;oCAHvB,qBAAqB;qCAEpB,kBAAkB;4BACd,kBAAkB"}
|
package/src/types.js
CHANGED
|
@@ -66,15 +66,6 @@ export {};
|
|
|
66
66
|
* }} VowKit
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* @template [T=any]
|
|
71
|
-
* @typedef {{
|
|
72
|
-
* vow: Vow<T>,
|
|
73
|
-
* resolver: VowResolver<T>,
|
|
74
|
-
* promise: Promise<T>
|
|
75
|
-
* }} VowPromiseKit
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
69
|
/**
|
|
79
70
|
* @template [T=any]
|
|
80
71
|
* @typedef {{ resolve(value?: T | PromiseVow<T>): void, reject(reason?: any): void }} VowResolver
|
|
@@ -83,16 +74,11 @@ export {};
|
|
|
83
74
|
/**
|
|
84
75
|
* @template [T=any]
|
|
85
76
|
* @template [TResult1=T]
|
|
86
|
-
* @template [TResult2=
|
|
77
|
+
* @template [TResult2=never]
|
|
87
78
|
* @template [C=any] watcher context
|
|
88
79
|
* @typedef {object} Watcher
|
|
89
80
|
* @property {(value: T, context?: C) => Vow<TResult1> | PromiseVow<TResult1> | TResult1} [onFulfilled]
|
|
90
81
|
* @property {(reason: any) => Vow<TResult2> | PromiseVow<TResult2> | TResult2} [onRejected]
|
|
91
82
|
*/
|
|
92
83
|
|
|
93
|
-
/**
|
|
94
|
-
* @template [T=any]
|
|
95
|
-
* @typedef {ERef<T | Vow<T>>} Specimen
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
84
|
/** @typedef {ReturnType<typeof prepareVowTools>} VowTools */
|
package/src/watch-utils.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export function prepareWatchUtils(zone: Zone, watch: <T =
|
|
1
|
+
export function prepareWatchUtils(zone: Zone, watch: <T = any, TResult1 = T, TResult2 = never, C = any>(specimenP: import("./types.js").ERef<T | import("./types.js").Vow<T>>, watcher?: import("./types.js").Watcher<T, TResult1, TResult2> | undefined, watcherContext?: C | undefined) => import("./types.js").Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>, makeVowKit: () => VowKit<any>): () => import("@endo/exo").Guarded<{
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @param {Specimen<T>[]} vows
|
|
3
|
+
* @param {unknown[]} vows
|
|
5
4
|
*/
|
|
6
|
-
all
|
|
5
|
+
all(vows: unknown[]): import("./types.js").Vow<any[]>;
|
|
7
6
|
}>;
|
|
8
7
|
import type { Zone } from '@agoric/base-zone';
|
|
9
8
|
import type { VowKit } from './types.js';
|
|
10
|
-
import type { Specimen } from './types.js';
|
|
11
9
|
//# sourceMappingURL=watch-utils.d.ts.map
|
package/src/watch-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-utils.d.ts","sourceRoot":"","sources":["watch-utils.js"],"names":[],"mappings":"AAuBO;IA8BC
|
|
1
|
+
{"version":3,"file":"watch-utils.d.ts","sourceRoot":"","sources":["watch-utils.js"],"names":[],"mappings":"AAuBO;IA8BC;;OAEG;cADQ,OAAO,EAAE;GA+E3B;0BA/HwB,mBAAmB;4BAEnB,YAAY"}
|
package/src/watch-utils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { M } from '@endo/patterns';
|
|
|
6
6
|
* @import {MapStore} from '@agoric/store/src/types.js'
|
|
7
7
|
* @import { Zone } from '@agoric/base-zone'
|
|
8
8
|
* @import { Watch } from './watch.js'
|
|
9
|
-
* @import {
|
|
9
|
+
* @import {VowKit} from './types.js'
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const VowShape = M.tagged(
|
|
@@ -52,11 +52,11 @@ export const prepareWatchUtils = (zone, watch, makeVowKit) => {
|
|
|
52
52
|
{
|
|
53
53
|
utils: {
|
|
54
54
|
/**
|
|
55
|
-
* @
|
|
56
|
-
* @param {Specimen<T>[]} vows
|
|
55
|
+
* @param {unknown[]} vows
|
|
57
56
|
*/
|
|
58
57
|
all(vows) {
|
|
59
58
|
const { nextId: id, idToVowState } = this.state;
|
|
59
|
+
/** @type {VowKit<any[]>} */
|
|
60
60
|
const kit = makeVowKit();
|
|
61
61
|
|
|
62
62
|
// Preserve the order of the vow results.
|
package/src/watch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function prepareWatch(zone: Zone, makeVowKit: () => VowKit<any>, isRetryableReason?: ((reason: any) => boolean) | undefined): <T =
|
|
1
|
+
export function prepareWatch(zone: Zone, makeVowKit: () => VowKit<any>, isRetryableReason?: ((reason: any) => boolean) | undefined): <T = any, TResult1 = T, TResult2 = never, C = any>(specimenP: ERef<T | Vow<T>>, watcher?: Watcher<T, TResult1, TResult2> | undefined, watcherContext?: C | undefined) => Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>;
|
|
2
2
|
export type Watch = ReturnType<typeof prepareWatch>;
|
|
3
3
|
import type { Zone } from '@agoric/base-zone';
|
|
4
4
|
import type { VowKit } from './types.js';
|
package/src/watch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["watch.js"],"names":[],"mappings":"AAyHO,sGAFa,GAAG,KAAK,OAAO,iBAmBT,CAAC,
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["watch.js"],"names":[],"mappings":"AAyHO,sGAFa,GAAG,KAAK,OAAO,iBAmBT,CAAC,2SA0B1B;oBAIa,UAAU,CAAC,OAAO,YAAY,CAAC;0BAjKJ,mBAAmB;4BACA,YAAY;yBAAZ,YAAY;0BAAZ,YAAY;6BAAZ,YAAY"}
|
package/src/watch.js
CHANGED
|
@@ -132,16 +132,18 @@ export const prepareWatch = (
|
|
|
132
132
|
);
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* @template [T=
|
|
135
|
+
* @template [T=any]
|
|
136
136
|
* @template [TResult1=T]
|
|
137
|
-
* @template [TResult2=
|
|
138
|
-
* @template [C=
|
|
137
|
+
* @template [TResult2=never]
|
|
138
|
+
* @template [C=any] watcher context
|
|
139
139
|
* @param {ERef<T | Vow<T>>} specimenP
|
|
140
140
|
* @param {Watcher<T, TResult1, TResult2>} [watcher]
|
|
141
141
|
* @param {C} [watcherContext]
|
|
142
142
|
*/
|
|
143
143
|
const watch = (specimenP, watcher, watcherContext) => {
|
|
144
|
-
/** @
|
|
144
|
+
/** @typedef {Exclude<TResult1, void> | Exclude<TResult2, void>} Voidless */
|
|
145
|
+
/** @typedef {Voidless extends never ? TResult1 : Voidless} Narrowest */
|
|
146
|
+
/** @type {VowKit<Narrowest>} */
|
|
145
147
|
const { resolver, vow } = makeVowKit();
|
|
146
148
|
|
|
147
149
|
// Create a promise watcher to track vows, retrying upon rejection as
|