@agoric/vow 0.1.1-dev-c19f1b5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vow",
3
- "version": "0.1.1-dev-c19f1b5.0+c19f1b5",
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-c19f1b5.0+c19f1b5",
24
- "@agoric/internal": "0.3.3-dev-c19f1b5.0+c19f1b5",
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": "c19f1b5b918e83f8f45c05c0683ee0f97ed0e415"
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 = unknown, TResult1_1 = T_1, TResult2_1 = T_1, C = unknown>(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<TResult1_1 | TResult2_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: any) => import("./types.js").Vow<any>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAaO;kCAFa,GAAG,KAAK,OAAO;;sFAEc,CAAC;;;;EAWjD;0BAlBuB,mBAAmB"}
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 = T, C = any> = {
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 = unknown, TResult1_1 = T_1, TResult2_1 = T_1, C = unknown>(specimenP: ERef<T_1 | Vow<T_1>>, watcher?: Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => Vow<TResult1_1 | TResult2_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: any) => Vow<any>;
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';
@@ -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;0BAQkB,CAAC,UAHV;IACZ,GAAO,EAAE,GAAG,CAES,CAAC,AAFR,CAAC,CAAC;IAChB,QAAY,EAAE,WAAW,CACJ,CAAC,AADK,CAAC,CAAC;IAC7B,OAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CACpB;wBAK0C,CAAC;oDAAI,IAAI;oBAAkB,GAAG,GAAG,IAAI;;oBAS7D,CAAC,QAAyD,QAAQ,MAClB,QAAQ,MAD3C,CAAC;2BAAd,CAAC,YAAY,CAAC;2BACb,GAAG;;qBAKA,CAAC,UAAd,IAAI,CAAS,CAAC,AAAR,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;;iEAhFuB,CAAA;;;;;iCAPd,kBAAkB;oCAHvB,qBAAqB;qCAEpB,kBAAkB;4BACd,kBAAkB"}
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=T]
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 */
@@ -1,11 +1,9 @@
1
- export function prepareWatchUtils(zone: Zone, watch: <T = unknown, TResult1 = T, TResult2 = T, C = unknown>(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<TResult1 | TResult2>, makeVowKit: () => VowKit<any>): () => import("@endo/exo").Guarded<{
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
- * @template [T=any]
4
- * @param {Specimen<T>[]} vows
3
+ * @param {unknown[]} vows
5
4
  */
6
- all<T_1 = any>(vows: Specimen<T_1>[]): import("./types.js").Vow<any>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"watch-utils.d.ts","sourceRoot":"","sources":["watch-utils.js"],"names":[],"mappings":"AAuBO;IA8BC;;;OAGG;QADiB,GAAC;GA8E5B;0BA/HwB,mBAAmB;4BAET,YAAY;8BAAZ,YAAY"}
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"}
@@ -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 {Specimen, VowKit} from './types.js'
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
- * @template [T=any]
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 = unknown, TResult1 = T, TResult2 = T, C = unknown>(specimenP: ERef<T | Vow<T>>, watcher?: Watcher<T, TResult1, TResult2> | undefined, watcherContext?: C | undefined) => Vow<TResult1 | TResult2>;
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';
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["watch.js"],"names":[],"mappings":"AAyHO,sGAFa,GAAG,KAAK,OAAO,iBAmBT,CAAC,oMAwB1B;oBAIa,UAAU,CAAC,OAAO,YAAY,CAAC;0BA/JJ,mBAAmB;4BACA,YAAY;yBAAZ,YAAY;0BAAZ,YAAY;6BAAZ,YAAY"}
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=unknown]
135
+ * @template [T=any]
136
136
  * @template [TResult1=T]
137
- * @template [TResult2=T]
138
- * @template [C=unknown] watcher context
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
- /** @type {VowKit<TResult1 | TResult2>} */
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