@agoric/async-flow 0.1.1-dev-31a57fc.0 → 0.1.1-dev-ab4941a.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/async-flow",
3
- "version": "0.1.1-dev-31a57fc.0+31a57fc",
3
+ "version": "0.1.1-dev-ab4941a.0+ab4941a",
4
4
  "description": "Upgrade async functions at await points by replay",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -24,10 +24,10 @@
24
24
  "author": "Agoric",
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@agoric/base-zone": "0.1.1-dev-31a57fc.0+31a57fc",
28
- "@agoric/internal": "0.3.3-dev-31a57fc.0+31a57fc",
29
- "@agoric/store": "0.9.3-dev-31a57fc.0+31a57fc",
30
- "@agoric/vow": "0.1.1-dev-31a57fc.0+31a57fc",
27
+ "@agoric/base-zone": "0.1.1-dev-ab4941a.0+ab4941a",
28
+ "@agoric/internal": "0.3.3-dev-ab4941a.0+ab4941a",
29
+ "@agoric/store": "0.9.3-dev-ab4941a.0+ab4941a",
30
+ "@agoric/vow": "0.1.1-dev-ab4941a.0+ab4941a",
31
31
  "@endo/common": "^1.2.2",
32
32
  "@endo/errors": "^1.2.2",
33
33
  "@endo/eventual-send": "^1.2.2",
@@ -37,8 +37,8 @@
37
37
  "@endo/promise-kit": "^1.1.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@agoric/swingset-liveslots": "0.10.3-dev-31a57fc.0+31a57fc",
41
- "@agoric/zone": "0.2.3-dev-31a57fc.0+31a57fc",
40
+ "@agoric/swingset-liveslots": "0.10.3-dev-ab4941a.0+ab4941a",
41
+ "@agoric/zone": "0.2.3-dev-ab4941a.0+ab4941a",
42
42
  "@endo/env-options": "^1.1.4",
43
43
  "@endo/ses-ava": "^1.2.2",
44
44
  "ava": "^5.3.0",
@@ -61,7 +61,7 @@
61
61
  "workerThreads": false
62
62
  },
63
63
  "typeCoverage": {
64
- "atLeast": 76.95
64
+ "atLeast": 76.94
65
65
  },
66
- "gitHead": "31a57fcc7ed223d138521e7bf9de090378f29962"
66
+ "gitHead": "ab4941a38e563ef355fadbf464e1694e02923d54"
67
67
  }
@@ -29,9 +29,9 @@ export function prepareAsyncFlowTools(outerZone: Zone, outerOptions?: Preparatio
29
29
  onRejected(_fulfillment: any): void;
30
30
  };
31
31
  }>;
32
- asyncFlow: (zone: Zone, tag: string, guestFunc: GuestAsyncFunc, options?: {
32
+ asyncFlow: <F extends GuestAsyncFunc>(zone: Zone, tag: string, guestFunc: F, options?: {
33
33
  startEager?: boolean;
34
- } | undefined) => HostAsyncFuncWrapper;
34
+ } | undefined) => HostOf<F>;
35
35
  adminAsyncFlow: import("@endo/exo").Guarded<{
36
36
  getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
37
37
  wakeAll(): void;
@@ -71,9 +71,9 @@ export type AsyncFlowTools = ReturnType<(outerZone: Zone, outerOptions?: Prepara
71
71
  onRejected(_fulfillment: any): void;
72
72
  };
73
73
  }>;
74
- asyncFlow: (zone: Zone, tag: string, guestFunc: GuestAsyncFunc, options?: {
74
+ asyncFlow: <F extends GuestAsyncFunc>(zone: Zone, tag: string, guestFunc: F, options?: {
75
75
  startEager?: boolean;
76
- } | undefined) => HostAsyncFuncWrapper;
76
+ } | undefined) => HostOf<F>;
77
77
  adminAsyncFlow: import("@endo/exo").Guarded<{
78
78
  getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
79
79
  wakeAll(): void;
@@ -90,5 +90,5 @@ import type { Zone } from '@agoric/base-zone';
90
90
  import type { PreparationOptions } from '../src/types.js';
91
91
  import type { GuestAsyncFunc } from '../src/types.js';
92
92
  import type { FlowState } from '../src/types.js';
93
- import type { HostAsyncFuncWrapper } from '../src/types.js';
93
+ import type { HostOf } from '../src/types.js';
94
94
  //# sourceMappingURL=async-flow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-flow.d.ts","sourceRoot":"","sources":["async-flow.js"],"names":[],"mappings":"AAgDO,iDAHI,IAAI;gCA6CF,IAAI,OACJ,MAAM,kBACN,cAAc;qBACC,OAAO;;;YA4BzB;;eAEG;4BADU,SAAS;YAkCtB;;;;;eAKG;;;;;;;;;;;;;;;;;sBAmRA,IAAI,OACJ,MAAM,aACN,cAAc;qBACC,OAAO;sBACpB,oBAAoB;;;;;;;;EAmDlC;6BAIY,UAAU,aAlcZ,IAAI;gCA6CF,IAAI,OACJ,MAAM,kBACN,cAAc;qBACC,OAAO;;;YA4BzB;;eAEG;4BADU,SAAS;YAkCtB;;;;;eAKG;;;;;;;;;;;;;;;;;sBAmRA,IAAI,OACJ,MAAM,aACN,cAAc;qBACC,OAAO;sBACpB,oBAAoB;;;;;;;;EAuDW;6BAIjC,cAAc,CAAC,gBAAgB,CAAC;+BAIhC,UAAU,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;2BAIjD,UAAU,CAAC,gBAAgB,CAAC;wBAI5B,YAAY,CAAC,MAAM,CAAC;0BAjfV,mBAAmB;wCAC4C,iBAAiB;oCAAjB,iBAAiB;+BAAjB,iBAAiB;0CAAjB,iBAAiB"}
1
+ {"version":3,"file":"async-flow.d.ts","sourceRoot":"","sources":["async-flow.js"],"names":[],"mappings":"AAgDO,iDAHI,IAAI;gCA6CF,IAAI,OACJ,MAAM,kBACN,cAAc;qBACC,OAAO;;;YA4BzB;;eAEG;4BADU,SAAS;YAkCtB;;;;;eAKG;;;;;;;;;;;;;;;;;gBAmRmB,CAAC,SAAlB,cAAgB,QAClB,IAAI,OACJ,MAAM,aACN,CAAC;qBACc,OAAO;sBACpB,OAAO,CAAC,CAAC;;;;;;;;EAsDvB;6BAIY,UAAU,aAtcZ,IAAI;gCA6CF,IAAI,OACJ,MAAM,kBACN,cAAc;qBACC,OAAO;;;YA4BzB;;eAEG;4BADU,SAAS;YAkCtB;;;;;eAKG;;;;;;;;;;;;;;;;;gBAmRmB,CAAC,SAAlB,cAAgB,QAClB,IAAI,OACJ,MAAM,aACN,CAAC;qBACc,OAAO;sBACpB,OAAO,CAAC,CAAC;;;;;;;;EA0DsB;6BAIjC,cAAc,CAAC,gBAAgB,CAAC;+BAIhC,UAAU,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;2BAIjD,UAAU,CAAC,gBAAgB,CAAC;wBAI5B,YAAY,CAAC,MAAM,CAAC;0BArfV,mBAAmB;wCACoD,iBAAiB;oCAAjB,iBAAiB;+BAAjB,iBAAiB;4BAAjB,iBAAiB"}
package/src/async-flow.js CHANGED
@@ -13,7 +13,7 @@ import { LogEntryShape, FlowStateShape } from './type-guards.js';
13
13
  /**
14
14
  * @import {WeakMapStore} from '@agoric/store'
15
15
  * @import {Zone} from '@agoric/base-zone'
16
- * @import {FlowState, GuestAsyncFunc, HostAsyncFuncWrapper, PreparationOptions} from '../src/types.js'
16
+ * @import {FlowState, GuestAsyncFunc, HostAsyncFuncWrapper, HostOf, PreparationOptions} from '../src/types.js'
17
17
  * @import {ReplayMembrane} from '../src/replay-membrane.js'
18
18
  */
19
19
 
@@ -434,21 +434,25 @@ export const prepareAsyncFlowTools = (outerZone, outerOptions = {}) => {
434
434
  };
435
435
 
436
436
  /**
437
+ * @template {GuestAsyncFunc} F
437
438
  * @param {Zone} zone
438
439
  * @param {string} tag
439
- * @param {GuestAsyncFunc} guestFunc
440
+ * @param {F} guestFunc
440
441
  * @param {{ startEager?: boolean }} [options]
441
- * @returns {HostAsyncFuncWrapper}
442
+ * @returns {HostOf<F>}
442
443
  */
443
444
  const asyncFlow = (zone, tag, guestFunc, options = undefined) => {
444
445
  const makeAsyncFlowKit = prepareAsyncFlowKit(zone, tag, guestFunc, options);
445
446
  const hostFuncName = `${tag}_hostFlow`;
446
- const wrapperFunc = {
447
- [hostFuncName](...args) {
448
- const { flow } = makeAsyncFlowKit(args);
449
- return flow.getOutcome();
450
- },
451
- }[hostFuncName];
447
+
448
+ const wrapperFunc = /** @type {HostOf<F>} */ (
449
+ {
450
+ [hostFuncName](...args) {
451
+ const { flow } = makeAsyncFlowKit(args);
452
+ return flow.getOutcome();
453
+ },
454
+ }[hostFuncName]
455
+ );
452
456
  defineProperties(wrapperFunc, {
453
457
  length: { value: guestFunc.length },
454
458
  });
package/src/types.d.ts CHANGED
@@ -51,6 +51,13 @@ type HostInterface<T> = {
51
51
  [K in keyof T]: HostOf<T[K]>;
52
52
  };
53
53
 
54
+ /**
55
+ * Convert an entire Host interface into what the Guest will receive.
56
+ */
57
+ type GuestInterface<T> = {
58
+ [K in keyof T]: GuestOf<T[K]>;
59
+ };
60
+
54
61
  /**
55
62
  * The function the host must provide to match an interface the guest expects.
56
63
  *
@@ -60,6 +67,8 @@ export type HostOf<F> = F extends (...args: infer A) => Promise<infer R>
60
67
  ? (...args: A) => Vow<R extends Passable ? R : HostInterface<R>>
61
68
  : F;
62
69
 
70
+ export type HostArgs<GA extends any[]> = { [K in keyof GA]: HostOf<GA[K]> };
71
+
63
72
  export type PreparationOptions = {
64
73
  vowTools?: VowTools;
65
74
  makeLogStore?: (() => LogStore) | undefined;