@agoric/async-flow 0.1.1-dev-12ce494.0 → 0.1.1-dev-5d18974.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/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +11 -10
- package/src/replay-membrane.d.ts.map +1 -1
- package/src/replay-membrane.js +6 -66
- package/src/types.d.ts +170 -38
- package/src/types.js +1 -196
- package/test/bad-host.test.js +2 -2
- package/test/types.test-d.ts +22 -0
- package/tsconfig.json +2 -0
- package/src/types.d.ts.map +0 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/async-flow",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-5d18974.0+5d18974",
|
|
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-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/store": "0.9.3-dev-
|
|
30
|
-
"@agoric/vow": "0.1.1-dev-
|
|
27
|
+
"@agoric/base-zone": "0.1.1-dev-5d18974.0+5d18974",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-5d18974.0+5d18974",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-5d18974.0+5d18974",
|
|
30
|
+
"@agoric/vow": "0.1.1-dev-5d18974.0+5d18974",
|
|
31
31
|
"@endo/common": "^1.2.2",
|
|
32
32
|
"@endo/errors": "^1.2.2",
|
|
33
33
|
"@endo/eventual-send": "^1.2.2",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"@endo/promise-kit": "^1.1.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
41
|
-
"@agoric/zone": "0.2.3-dev-
|
|
40
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-5d18974.0+5d18974",
|
|
41
|
+
"@agoric/zone": "0.2.3-dev-5d18974.0+5d18974",
|
|
42
42
|
"@endo/env-options": "^1.1.4",
|
|
43
43
|
"@endo/ses-ava": "^1.2.2",
|
|
44
|
-
"ava": "^5.3.0"
|
|
44
|
+
"ava": "^5.3.0",
|
|
45
|
+
"tsd": "^0.31.1"
|
|
45
46
|
},
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"workerThreads": false
|
|
61
62
|
},
|
|
62
63
|
"typeCoverage": {
|
|
63
|
-
"atLeast": 77.
|
|
64
|
+
"atLeast": 77.32
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "5d18974dc0f204abf085a9ef1f95c8b7e890335f"
|
|
66
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay-membrane.d.ts","sourceRoot":"","sources":["replay-membrane.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replay-membrane.d.ts","sourceRoot":"","sources":["replay-membrane.js"],"names":[],"mappings":"AA8BO,oFANJ;IAAsB,GAAG,EAAjB,QAAQ;IACO,SAAS,EAAxB,SAAS;IACK,QAAQ,EAAtB,QAAQ;IAC6B,SAAS,EAA9C,CAAC,MAAM,EAAE,eAAU,GAAG,KAAK,IAAI;IACA,KAAK,EAApC,CAAC,OAAO,EAAE,KAAK,KAAK,KAAK;CACnC;;;;;;;;;;GAmpBA;6BAGa,UAAU,mDA3pBrB;IAAsB,GAAG,EAAjB,QAAQ;IACO,SAAS,EAAxB,SAAS;IACK,QAAQ,EAAtB,QAAQ;IAC6B,SAAS,EAA9C,CAAC,MAAM,EAAE,eAAU,GAAG,KAAK,IAAI;IACA,KAAK,EAApC,CAAC,OAAO,EAAE,KAAK,KAAK,KAAK;CACnC;;;;;;;;;;GAspB2C;8BApqBjB,qBAAqB;+BACpB,qBAAqB;8BAFT,aAAa;yBAAb,aAAa;8BADD,kBAAkB"}
|
package/src/replay-membrane.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-use-before-define */
|
|
2
|
+
import { isVow } from '@agoric/vow/src/vow-utils.js';
|
|
3
|
+
import { heapVowE } from '@agoric/vow/vat.js';
|
|
4
|
+
import { throwLabeled } from '@endo/common/throw-labeled.js';
|
|
2
5
|
import { Fail, X, b, makeError, q } from '@endo/errors';
|
|
3
6
|
import { E } from '@endo/eventual-send';
|
|
4
7
|
import { getMethodNames } from '@endo/eventual-send/utils.js';
|
|
5
|
-
import {
|
|
6
|
-
import { objectMap } from '@endo/common/object-map.js';
|
|
7
|
-
import {
|
|
8
|
-
Far,
|
|
9
|
-
Remotable,
|
|
10
|
-
getInterfaceOf,
|
|
11
|
-
getTag,
|
|
12
|
-
makeTagged,
|
|
13
|
-
passStyleOf,
|
|
14
|
-
} from '@endo/pass-style';
|
|
15
|
-
import { heapVowE } from '@agoric/vow/vat.js';
|
|
16
|
-
import { isVow } from '@agoric/vow/src/vow-utils.js';
|
|
17
|
-
import { makeEquate } from './equate.js';
|
|
8
|
+
import { Far, Remotable, getInterfaceOf } from '@endo/pass-style';
|
|
18
9
|
import { makeConvertKit } from './convert.js';
|
|
10
|
+
import { makeEquate } from './equate.js';
|
|
19
11
|
|
|
20
12
|
/**
|
|
21
13
|
* @import {PromiseKit} from '@endo/promise-kit'
|
|
@@ -43,7 +35,7 @@ export const makeReplayMembrane = ({
|
|
|
43
35
|
watchWake,
|
|
44
36
|
panic,
|
|
45
37
|
}) => {
|
|
46
|
-
const { when,
|
|
38
|
+
const { when, makeVowKit } = vowTools;
|
|
47
39
|
|
|
48
40
|
const equate = makeEquate(bijection);
|
|
49
41
|
|
|
@@ -137,63 +129,12 @@ export const makeReplayMembrane = ({
|
|
|
137
129
|
|
|
138
130
|
// ///////////// Guest to Host or consume log ////////////////////////////////
|
|
139
131
|
|
|
140
|
-
/**
|
|
141
|
-
* The host is not supposed to expose host-side promises to the membrane,
|
|
142
|
-
* since they cannot be stored durably or survive upgrade. We cannot just
|
|
143
|
-
* automatically wrap any such host promises with host vows, because that
|
|
144
|
-
* would mask upgrade hazards if an upgrade happens before the vow settles.
|
|
145
|
-
* However, during the transition, the current host APIs called by
|
|
146
|
-
* orchestration still return many promises. We want to generate diagnostics
|
|
147
|
-
* when we encounter them, but for now, automatically convert them to
|
|
148
|
-
* host vow anyway, just so integration testing can proceed to reveal
|
|
149
|
-
* additional problems beyond these.
|
|
150
|
-
*
|
|
151
|
-
* @param {Passable} h
|
|
152
|
-
*/
|
|
153
|
-
const tolerateHostPromiseToVow = h => {
|
|
154
|
-
const passStyle = passStyleOf(h);
|
|
155
|
-
switch (passStyle) {
|
|
156
|
-
case 'promise': {
|
|
157
|
-
const e = Error('where warning happened');
|
|
158
|
-
console.log('Warning for now: vow expected, not promise', h, e);
|
|
159
|
-
// TODO remove this stopgap. Here for now because host-side
|
|
160
|
-
// promises are everywhere!
|
|
161
|
-
// Note: A good place to set a breakpoint, or to uncomment the
|
|
162
|
-
// `debugger;` line, to work around bundling.
|
|
163
|
-
// debugger;
|
|
164
|
-
return watch(h);
|
|
165
|
-
}
|
|
166
|
-
case 'copyRecord': {
|
|
167
|
-
const o = /** @type {object} */ (h);
|
|
168
|
-
return objectMap(o, tolerateHostPromiseToVow);
|
|
169
|
-
}
|
|
170
|
-
case 'copyArray': {
|
|
171
|
-
const a = /** @type {Array} */ (h);
|
|
172
|
-
return harden(a.map(tolerateHostPromiseToVow));
|
|
173
|
-
}
|
|
174
|
-
case 'tagged': {
|
|
175
|
-
const t = /** @type {CopyTagged} */ (h);
|
|
176
|
-
if (isVow(t)) {
|
|
177
|
-
return h;
|
|
178
|
-
}
|
|
179
|
-
return makeTagged(getTag(t), tolerateHostPromiseToVow(t.payload));
|
|
180
|
-
}
|
|
181
|
-
default: {
|
|
182
|
-
return h;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
132
|
const performCall = (hostTarget, optVerb, hostArgs, callIndex) => {
|
|
188
133
|
let hostResult;
|
|
189
134
|
try {
|
|
190
135
|
hostResult = optVerb
|
|
191
136
|
? hostTarget[optVerb](...hostArgs)
|
|
192
137
|
: hostTarget(...hostArgs);
|
|
193
|
-
// This is a temporary kludge anyway. But note that it only
|
|
194
|
-
// catches the case where the promise is at the top of hostResult.
|
|
195
|
-
harden(hostResult);
|
|
196
|
-
hostResult = tolerateHostPromiseToVow(hostResult);
|
|
197
138
|
// Try converting here just to route the error correctly
|
|
198
139
|
hostToGuest(hostResult, `converting ${optVerb || 'host'} result`);
|
|
199
140
|
} catch (hostProblem) {
|
|
@@ -575,7 +516,6 @@ export const makeReplayMembrane = ({
|
|
|
575
516
|
* @returns {Promise}
|
|
576
517
|
*/
|
|
577
518
|
const makeGuestForHostVow = (hVow, promiseKey = undefined) => {
|
|
578
|
-
hVow = tolerateHostPromiseToVow(hVow);
|
|
579
519
|
isVow(hVow) || Fail`vow expected ${hVow}`;
|
|
580
520
|
const { promise, resolve, reject } = makeGuestPromiseKit();
|
|
581
521
|
promiseKey ??= promise;
|
package/src/types.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Passable } from '@endo/pass-style';
|
|
2
|
+
import type { Vow, VowTools } from '@agoric/vow';
|
|
3
|
+
import type { LogStore } from './log-store.js';
|
|
4
|
+
import type { Bijection } from './bijection.js';
|
|
5
|
+
import type { EndowmentTools } from './endowments.js';
|
|
6
|
+
|
|
7
|
+
export type FlowState =
|
|
8
|
+
| 'Running'
|
|
9
|
+
| 'Sleeping'
|
|
10
|
+
| 'Replaying'
|
|
11
|
+
| 'Failed'
|
|
12
|
+
| 'Done';
|
|
13
|
+
|
|
2
14
|
/**
|
|
3
15
|
* `T` defaults to `any`, not `Passable`, because unwrapped guests include
|
|
4
16
|
* non-passables, like unwrapped functions and unwrapped state records.
|
|
@@ -8,52 +20,172 @@ export type FlowState = "Running" | "Sleeping" | "Replaying" | "Failed" | "Done"
|
|
|
8
20
|
*/
|
|
9
21
|
export type Guest<T extends unknown = any> = T;
|
|
10
22
|
export type Host<T extends Passable = Passable> = T;
|
|
23
|
+
|
|
11
24
|
/**
|
|
12
25
|
* A HostVow must be durably storable. It corresponds to an
|
|
13
26
|
* ephemeral guest promise.
|
|
14
27
|
*/
|
|
15
28
|
export type HostVow<T extends Passable = Passable> = Host<Vow<T>>;
|
|
16
|
-
|
|
29
|
+
|
|
30
|
+
export type GuestAsyncFunc = (
|
|
31
|
+
...activationArgs: Guest[]
|
|
32
|
+
) => Guest<Promise<any>>;
|
|
33
|
+
|
|
17
34
|
export type HostAsyncFuncWrapper = (...activationArgs: Host[]) => HostVow;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The function from the host as it will be available in the guest.
|
|
38
|
+
*
|
|
39
|
+
* Specifically, Vow return values are converted to Promises.
|
|
40
|
+
*/
|
|
41
|
+
export type GuestOf<F extends HostAsyncFuncWrapper> = F extends (
|
|
42
|
+
...args: infer A
|
|
43
|
+
) => Vow<infer R>
|
|
44
|
+
? (...args: A) => Promise<R>
|
|
45
|
+
: F;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Convert an entire Guest interface into what the host will implement.
|
|
49
|
+
*/
|
|
50
|
+
type HostInterface<T> = {
|
|
51
|
+
[K in keyof T]: HostOf<T[K]>;
|
|
34
52
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The function the host must provide to match an interface the guest expects.
|
|
56
|
+
*
|
|
57
|
+
* Specifically, Promise return values are converted to Vows.
|
|
58
|
+
*/
|
|
59
|
+
export type HostOf<F> = F extends (...args: infer A) => Promise<infer R>
|
|
60
|
+
? (...args: A) => Vow<R extends Passable ? R : HostInterface<R>>
|
|
61
|
+
: F;
|
|
62
|
+
|
|
63
|
+
export type PreparationOptions = {
|
|
64
|
+
vowTools?: VowTools;
|
|
65
|
+
makeLogStore?: (() => LogStore) | undefined;
|
|
66
|
+
makeBijection?: (() => Bijection) | undefined;
|
|
67
|
+
endowmentTools?: EndowmentTools;
|
|
42
68
|
};
|
|
69
|
+
export type OutcomeKind = 'return' | 'throw';
|
|
70
|
+
|
|
71
|
+
export type Outcome =
|
|
72
|
+
| {
|
|
73
|
+
kind: 'return';
|
|
74
|
+
result: any;
|
|
75
|
+
}
|
|
76
|
+
| {
|
|
77
|
+
kind: 'throw';
|
|
78
|
+
problem: any;
|
|
79
|
+
};
|
|
80
|
+
|
|
43
81
|
export type Ephemera<S extends WeakKey = WeakKey, V extends unknown = any> = {
|
|
44
|
-
|
|
45
|
-
|
|
82
|
+
for: (self: S) => V;
|
|
83
|
+
resetFor: (self: S) => void;
|
|
46
84
|
};
|
|
85
|
+
|
|
47
86
|
/**
|
|
48
|
-
* This is the
|
|
49
|
-
*
|
|
50
|
-
* membrane log entry, which we do not
|
|
87
|
+
* This is the type alias for the membrane log entries we currently implement.
|
|
88
|
+
*
|
|
89
|
+
* @see {FutureLogEntry} below for the full membrane log entry, which we do not
|
|
90
|
+
* yet support.
|
|
51
91
|
*/
|
|
52
|
-
export type LogEntry =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
export type LogEntry =
|
|
93
|
+
| [
|
|
94
|
+
// ///////////////// From Host to Guest /////////////////////////
|
|
95
|
+
op: 'doFulfill',
|
|
96
|
+
vow: HostVow,
|
|
97
|
+
fulfillment: Host,
|
|
98
|
+
]
|
|
99
|
+
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
100
|
+
| [op: 'doReturn', callIndex: number, result: Host]
|
|
101
|
+
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
102
|
+
| [
|
|
103
|
+
// ///////////////////// From Guest to Host /////////////////////////
|
|
104
|
+
op: 'checkCall',
|
|
105
|
+
target: Host,
|
|
106
|
+
optVerb: PropertyKey | undefined,
|
|
107
|
+
args: Host[],
|
|
108
|
+
callIndex: number,
|
|
109
|
+
]
|
|
110
|
+
| [
|
|
111
|
+
op: 'checkSendOnly',
|
|
112
|
+
target: Host,
|
|
113
|
+
optVerb: PropertyKey | undefined,
|
|
114
|
+
args: Host[],
|
|
115
|
+
callIndex: number,
|
|
116
|
+
]
|
|
117
|
+
| [
|
|
118
|
+
op: 'checkSend',
|
|
119
|
+
target: Host,
|
|
120
|
+
optVerb: PropertyKey | undefined,
|
|
121
|
+
args: Host[],
|
|
122
|
+
callIndex: number,
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* This would be the type alias for the full membrane log, if we supported:
|
|
127
|
+
* - the guest sending guest-promises and guest-remotables to the host
|
|
128
|
+
* - the guest using `E` to eventual-send to guest wrappers of the host
|
|
129
|
+
* vows and remotables.
|
|
130
|
+
*/
|
|
131
|
+
export type FutureLogEntry =
|
|
132
|
+
| [
|
|
133
|
+
// ///////////////// From Host to Guest ///////////////////////
|
|
134
|
+
op: 'doFulfill',
|
|
135
|
+
vow: HostVow,
|
|
136
|
+
fulfillment: Host,
|
|
137
|
+
]
|
|
138
|
+
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
139
|
+
| [
|
|
140
|
+
op: 'doCall',
|
|
141
|
+
target: Host,
|
|
142
|
+
optVerb: PropertyKey | undefined,
|
|
143
|
+
args: Host[],
|
|
144
|
+
callIndex: number,
|
|
145
|
+
]
|
|
146
|
+
| [
|
|
147
|
+
op: 'doSendOnly',
|
|
148
|
+
target: Host,
|
|
149
|
+
optVerb: PropertyKey | undefined,
|
|
150
|
+
args: Host[],
|
|
151
|
+
callIndex: number,
|
|
152
|
+
]
|
|
153
|
+
| [
|
|
154
|
+
op: 'doSend',
|
|
155
|
+
target: Host,
|
|
156
|
+
optVerb: PropertyKey | undefined,
|
|
157
|
+
args: Host[],
|
|
158
|
+
callIndex: number,
|
|
159
|
+
]
|
|
160
|
+
| [op: 'doReturn', callIndex: number, result: Host]
|
|
161
|
+
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
162
|
+
| [
|
|
163
|
+
// ///////////////////// From Guest to Host /////////////////////////
|
|
164
|
+
op: 'checkFulfill',
|
|
165
|
+
vow: HostVow,
|
|
166
|
+
fulfillment: Host,
|
|
167
|
+
]
|
|
168
|
+
| [op: 'checkReject', vow: HostVow, reason: Host]
|
|
169
|
+
| [
|
|
170
|
+
op: 'checkCall',
|
|
171
|
+
target: Host,
|
|
172
|
+
optVerb: PropertyKey | undefined,
|
|
173
|
+
args: Host[],
|
|
174
|
+
callIndex: number,
|
|
175
|
+
]
|
|
176
|
+
| [
|
|
177
|
+
op: 'checkSendOnly',
|
|
178
|
+
target: Host,
|
|
179
|
+
optVerb: PropertyKey | undefined,
|
|
180
|
+
args: Host[],
|
|
181
|
+
callIndex: number,
|
|
182
|
+
]
|
|
183
|
+
| [
|
|
184
|
+
op: 'checkSend',
|
|
185
|
+
target: Host,
|
|
186
|
+
optVerb: PropertyKey | undefined,
|
|
187
|
+
args: Host[],
|
|
188
|
+
callIndex: number,
|
|
189
|
+
]
|
|
190
|
+
| [op: 'checkReturn', callIndex: number, result: Host]
|
|
191
|
+
| [op: 'checkThrow', callIndex: number, problem: Host];
|
package/src/types.js
CHANGED
|
@@ -1,196 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @import {Passable} from '@endo/pass-style'
|
|
6
|
-
* @import {Vow, VowTools} from '@agoric/vow'
|
|
7
|
-
* @import {LogStore} from './log-store.js'
|
|
8
|
-
* @import {Bijection} from './bijection.js'
|
|
9
|
-
* @import {EndowmentTools} from './endowments.js'
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {'Running' |
|
|
14
|
-
* 'Sleeping' |
|
|
15
|
-
* 'Replaying' |
|
|
16
|
-
* 'Failed' |
|
|
17
|
-
* 'Done'
|
|
18
|
-
* } FlowState
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* `T` defaults to `any`, not `Passable`, because unwrapped guests include
|
|
23
|
-
* non-passables, like unwrapped functions and unwrapped state records.
|
|
24
|
-
* (Unwrapped functions could be made into Remotables,
|
|
25
|
-
* but since they still could not be made durable, in this context
|
|
26
|
-
* it'd be pointless.)
|
|
27
|
-
*
|
|
28
|
-
* @template {any} [T=any]
|
|
29
|
-
* @typedef {T} Guest
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @template {Passable} [T=Passable]
|
|
34
|
-
* @typedef {T} Host
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A HostVow must be durably storable. It corresponds to an
|
|
39
|
-
* ephemeral guest promise.
|
|
40
|
-
*
|
|
41
|
-
* @template {Passable} [T=Passable]
|
|
42
|
-
* @typedef {Host<Vow<T>>} HostVow
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @typedef {(...activationArgs: Guest[]) => Guest<Promise>} GuestAsyncFunc
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @typedef {(...activationArgs: Host[]) => HostVow} HostAsyncFuncWrapper
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {object} PreparationOptions
|
|
55
|
-
* @property {VowTools} [vowTools]
|
|
56
|
-
* @property {() => LogStore} [makeLogStore]
|
|
57
|
-
* @property {() => Bijection} [makeBijection]
|
|
58
|
-
* @property {EndowmentTools} [endowmentTools]
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @typedef {'return'|'throw'} OutcomeKind
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @typedef {{kind: 'return', result: any}
|
|
67
|
-
* | {kind: 'throw', problem: any}
|
|
68
|
-
* } Outcome
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @template {WeakKey} [S=WeakKey]
|
|
73
|
-
* @template {any} [V=any]
|
|
74
|
-
* @typedef {object} Ephemera
|
|
75
|
-
* @property {(self: S) => V} for
|
|
76
|
-
* @property {(self: S) => void} resetFor
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* This is the typedef for the membrane log entries we currently implement.
|
|
81
|
-
* See comment below for the commented-out typedef for the full
|
|
82
|
-
* membrane log entry, which we do not yet support.
|
|
83
|
-
*
|
|
84
|
-
* @typedef {[ // ///////////////// From Host to Guest /////////////////////////
|
|
85
|
-
* op: 'doFulfill',
|
|
86
|
-
* vow: HostVow,
|
|
87
|
-
* fulfillment: Host,
|
|
88
|
-
* ] | [
|
|
89
|
-
* op: 'doReject',
|
|
90
|
-
* vow: HostVow,
|
|
91
|
-
* reason: Host,
|
|
92
|
-
* ] | [
|
|
93
|
-
* op: 'doReturn',
|
|
94
|
-
* callIndex: number,
|
|
95
|
-
* result: Host,
|
|
96
|
-
* ] | [
|
|
97
|
-
* op: 'doThrow',
|
|
98
|
-
* callIndex: number,
|
|
99
|
-
* problem: Host,
|
|
100
|
-
* ] | [ // ///////////////////// From Guest to Host /////////////////////////
|
|
101
|
-
* op: 'checkCall',
|
|
102
|
-
* target: Host,
|
|
103
|
-
* optVerb: PropertyKey|undefined,
|
|
104
|
-
* args: Host[],
|
|
105
|
-
* callIndex: number
|
|
106
|
-
* ] | [
|
|
107
|
-
* op: 'checkSendOnly',
|
|
108
|
-
* target: Host,
|
|
109
|
-
* optVerb: PropertyKey|undefined,
|
|
110
|
-
* args: Host[],
|
|
111
|
-
* callIndex: number
|
|
112
|
-
* ] | [
|
|
113
|
-
* op: 'checkSend',
|
|
114
|
-
* target: Host,
|
|
115
|
-
* optVerb: PropertyKey|undefined,
|
|
116
|
-
* args: Host[],
|
|
117
|
-
* callIndex: number
|
|
118
|
-
* ]} LogEntry
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* This would be the typedef for the full membrane log, if we supported
|
|
123
|
-
* - the guest sending guest-promises and guest-remotables to the host
|
|
124
|
-
* - the guest using `E` to eventual-send to guest wrappers of host
|
|
125
|
-
* vows and remotables.
|
|
126
|
-
*
|
|
127
|
-
* at-typedef {[ // ///////////////// From Host to Guest ///////////////////////
|
|
128
|
-
* op: 'doFulfill',
|
|
129
|
-
* vow: HostVow,
|
|
130
|
-
* fulfillment: Host,
|
|
131
|
-
* ] | [
|
|
132
|
-
* op: 'doReject',
|
|
133
|
-
* vow: HostVow,
|
|
134
|
-
* reason: Host,
|
|
135
|
-
* ] | [
|
|
136
|
-
* op: 'doCall',
|
|
137
|
-
* target: Host,
|
|
138
|
-
* optVerb: PropertyKey|undefined,
|
|
139
|
-
* args: Host[],
|
|
140
|
-
* callIndex: number
|
|
141
|
-
* ] | [
|
|
142
|
-
* op: 'doSendOnly',
|
|
143
|
-
* target: Host,
|
|
144
|
-
* optVerb: PropertyKey|undefined,
|
|
145
|
-
* args: Host[],
|
|
146
|
-
* callIndex: number
|
|
147
|
-
* ] | [
|
|
148
|
-
* op: 'doSend',
|
|
149
|
-
* target: Host,
|
|
150
|
-
* optVerb: PropertyKey|undefined,
|
|
151
|
-
* args: Host[],
|
|
152
|
-
* callIndex: number
|
|
153
|
-
* ] | [
|
|
154
|
-
* op: 'doReturn',
|
|
155
|
-
* callIndex: number,
|
|
156
|
-
* result: Host,
|
|
157
|
-
* ] | [
|
|
158
|
-
* op: 'doThrow',
|
|
159
|
-
* callIndex: number,
|
|
160
|
-
* problem: Host,
|
|
161
|
-
* ] | [ // ///////////////////// From Guest to Host /////////////////////////
|
|
162
|
-
* op: 'checkFulfill',
|
|
163
|
-
* vow: HostVow,
|
|
164
|
-
* fulfillment: Host,
|
|
165
|
-
* ] | [
|
|
166
|
-
* op: 'checkReject',
|
|
167
|
-
* vow: HostVow,
|
|
168
|
-
* reason: Host,
|
|
169
|
-
* ] | [
|
|
170
|
-
* op: 'checkCall',
|
|
171
|
-
* target: Host,
|
|
172
|
-
* optVerb: PropertyKey|undefined,
|
|
173
|
-
* args: Host[],
|
|
174
|
-
* callIndex: number
|
|
175
|
-
* ] | [
|
|
176
|
-
* op: 'checkSendOnly',
|
|
177
|
-
* target: Host,
|
|
178
|
-
* optVerb: PropertyKey|undefined,
|
|
179
|
-
* args: Host[],
|
|
180
|
-
* callIndex: number
|
|
181
|
-
* ] | [
|
|
182
|
-
* op: 'checkSend',
|
|
183
|
-
* target: Host,
|
|
184
|
-
* optVerb: PropertyKey|undefined,
|
|
185
|
-
* args: Host[],
|
|
186
|
-
* callIndex: number
|
|
187
|
-
* ] | [
|
|
188
|
-
* op: 'checkReturn',
|
|
189
|
-
* callIndex: number,
|
|
190
|
-
* result: Host,
|
|
191
|
-
* ] | [
|
|
192
|
-
* op: 'checkThrow',
|
|
193
|
-
* callIndex: number,
|
|
194
|
-
* problem: Host,
|
|
195
|
-
* ]} LogEntry
|
|
196
|
-
*/
|
|
1
|
+
export const empty = 'Empty JS file to correspond with its .d.ts twin';
|
package/test/bad-host.test.js
CHANGED
|
@@ -141,7 +141,7 @@ const testBadHostReplay1 = async (t, zone) => {
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
message:
|
|
144
|
-
'Remotables must be explicitly declared: "[Function nonPassableFunc]"',
|
|
144
|
+
'converting badMethod result: Remotables must be explicitly declared: "[Function nonPassableFunc]"',
|
|
145
145
|
},
|
|
146
146
|
);
|
|
147
147
|
t.log(' badHost replay1 guest error caused by host error', gErr);
|
|
@@ -177,7 +177,7 @@ const testBadHostReplay1 = async (t, zone) => {
|
|
|
177
177
|
'doThrow',
|
|
178
178
|
2,
|
|
179
179
|
Error(
|
|
180
|
-
'Remotables must be explicitly declared: "[Function nonPassableFunc]"',
|
|
180
|
+
'converting badMethod result: Remotables must be explicitly declared: "[Function nonPassableFunc]"',
|
|
181
181
|
),
|
|
182
182
|
],
|
|
183
183
|
['checkCall', badHost, 'badMethod', [], 4],
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expectType } from 'tsd';
|
|
2
|
+
import type { Zone } from '@agoric/base-zone';
|
|
3
|
+
import type { Vow, VowTools } from '@agoric/vow';
|
|
4
|
+
import type { HostOf, GuestOf } from '../src/types.js';
|
|
5
|
+
|
|
6
|
+
const vt: VowTools = null as any;
|
|
7
|
+
|
|
8
|
+
const sumVow = (a: number, b: number) => vt.asVow(() => a + b);
|
|
9
|
+
|
|
10
|
+
const sumPromise = (a: number, b: number) => Promise.resolve(a + b);
|
|
11
|
+
|
|
12
|
+
expectType<(p1: number, p2: number) => Promise<number>>(
|
|
13
|
+
null as unknown as GuestOf<typeof sumVow>,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expectType<(p1: number, p2: number) => Vow<number>>(
|
|
17
|
+
null as unknown as HostOf<typeof sumPromise>,
|
|
18
|
+
);
|
|
19
|
+
expectType<(p1: number, p2: number) => Vow<void>>(
|
|
20
|
+
// @ts-expect-error incompatible return type
|
|
21
|
+
null as unknown as HostOf<typeof sumPromise>,
|
|
22
|
+
);
|
package/tsconfig.json
CHANGED
package/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"wBAYa,SAAS,GACrB,UAAsB,GACtB,WAAuB,GACvB,QAAoB,GACpB,MAAkB;;;;;;;;kBAWC,CAAC,0BACR,CAAC;iBAIW,CAAC,SAAb,QAAU,eACV,CAAC;;;;;oBAOW,CAAC,SAAb,QAAU,eACV,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;6BAIZ,CAAC,GAAG,cAAc,EAAE,KAAK,EAAE,KAAK,KAAK,cAAS;mCAI9C,CAAC,GAAG,cAAc,EAAE,IAAI,EAAE,KAAK,OAAO;;;;;;;wCAyDxC,GAAG;;+BA3BoD,GAAG;;0BAxBjD,QAAQ;2BACR,SAAS;;;;;;0BAKhB,QAAQ,GAAC,OAAO;sBAIhB;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAC,GAC7B;IAAC,IAAI,EAAE,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAA;CAAC;qBAKnB,CAAC,SAAX,OAAQ,YACF,CAAC;SAEP,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;cACd,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI;;;;;;;uBAQlB,CAAE,iEAAiE;AAC/E,EAAQ,EAAE,WAAW,EACrB,GAAS,EAAE,OAAO,EAClB,WAAiB,EAAE,IAAI,CAClB,GAAG,CACR,EAAQ,EAAE,UAAU,EACpB,GAAS,EAAE,OAAO,EAClB,MAAY,EAAE,IAAI,CACb,GAAG,CACR,EAAQ,EAAE,UAAU,EACpB,SAAe,EAAE,MAAM,EACvB,MAAY,EAAE,IAAI,CACb,GAAG,CACR,EAAQ,EAAE,SAAS,EACnB,SAAe,EAAE,MAAM,EACvB,OAAa,EAAE,IAAI,CACd,GAAG,CAAE,qEAAqE;AAC/E,EAAQ,EAAE,WAAW,EACrB,MAAY,EAAE,IAAI,EAClB,OAAa,EAAE,WAAW,GAAC,SAAS,EACpC,IAAU,EAAE,IAAI,EAAE,EAClB,SAAe,EAAE,MAAM,CAClB,GAAG,CACR,EAAQ,EAAE,eAAe,EACzB,MAAY,EAAE,IAAI,EAClB,OAAa,EAAE,WAAW,GAAC,SAAS,EACpC,IAAU,EAAE,IAAI,EAAE,EAClB,SAAe,EAAE,MAAM,CAClB,GAAG,CACR,EAAQ,EAAE,WAAW,EACrB,MAAY,EAAE,IAAI,EAClB,OAAa,EAAE,WAAW,GAAC,SAAS,EACpC,IAAU,EAAE,IAAI,EAAE,EAClB,SAAe,EAAE,MAAM,CAClB;8BAjHqB,kBAAkB;yBACb,aAAa;8BAClB,gBAAgB;+BACf,gBAAgB"}
|