@agoric/async-flow 0.1.1-dev-0b1501a.0 → 0.1.1-dev-e3b41dc.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 -1
- package/index.js +1 -1
- package/package.json +8 -8
- package/src/types-index.d.ts +2 -0
- package/src/types.d.ts +97 -166
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +222 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- /package/src/{types.js → types-index.js} +0 -0
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-e3b41dc.0+e3b41dc",
|
|
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-e3b41dc.0+e3b41dc",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-e3b41dc.0+e3b41dc",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-e3b41dc.0+e3b41dc",
|
|
30
|
+
"@agoric/vow": "0.1.1-dev-e3b41dc.0+e3b41dc",
|
|
31
31
|
"@endo/common": "^1.2.5",
|
|
32
32
|
"@endo/errors": "^1.2.5",
|
|
33
33
|
"@endo/eventual-send": "^1.2.5",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@endo/promise-kit": "^1.1.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
41
|
-
"@agoric/zone": "0.2.3-dev-
|
|
40
|
+
"@agoric/swingset-vat": "0.32.3-dev-e3b41dc.0+e3b41dc",
|
|
41
|
+
"@agoric/zone": "0.2.3-dev-e3b41dc.0+e3b41dc",
|
|
42
42
|
"@endo/env-options": "^1.1.6",
|
|
43
43
|
"ava": "^5.3.0",
|
|
44
44
|
"tsd": "^0.31.1"
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"typeCoverage": {
|
|
63
63
|
"atLeast": 77.29
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e3b41dc204ce335217bf18ed4889aba18734d8f6"
|
|
66
66
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -3,14 +3,7 @@ import type { Vow, VowTools } from '@agoric/vow';
|
|
|
3
3
|
import type { LogStore } from './log-store.js';
|
|
4
4
|
import type { Bijection } from './bijection.js';
|
|
5
5
|
import type { EndowmentTools } from './endowments.js';
|
|
6
|
-
|
|
7
|
-
export type FlowState =
|
|
8
|
-
| 'Running'
|
|
9
|
-
| 'Sleeping'
|
|
10
|
-
| 'Replaying'
|
|
11
|
-
| 'Failed'
|
|
12
|
-
| 'Done';
|
|
13
|
-
|
|
6
|
+
export type FlowState = 'Running' | 'Sleeping' | 'Replaying' | 'Failed' | 'Done';
|
|
14
7
|
/**
|
|
15
8
|
* `T` defaults to `any`, not `Passable`, because unwrapped guests include
|
|
16
9
|
* non-passables, like unwrapped functions and unwrapped state records.
|
|
@@ -20,202 +13,140 @@ export type FlowState =
|
|
|
20
13
|
*/
|
|
21
14
|
export type Guest<T extends unknown = any> = T;
|
|
22
15
|
export type Host<T extends Passable = Passable> = T;
|
|
23
|
-
|
|
24
16
|
/**
|
|
25
17
|
* A HostVow must be durably storable. It corresponds to an
|
|
26
18
|
* ephemeral guest promise.
|
|
27
19
|
*/
|
|
28
20
|
export type HostVow<T extends Passable = Passable> = Host<Vow<T>>;
|
|
29
|
-
|
|
30
|
-
export type
|
|
31
|
-
...activationArgs: Guest[]
|
|
32
|
-
) => Guest<Promise<any>>;
|
|
33
|
-
|
|
34
|
-
export type HostAsyncFuncWrapper = (
|
|
35
|
-
...activationArgs: Host<any>[]
|
|
36
|
-
) => HostVow<any>;
|
|
37
|
-
|
|
21
|
+
export type GuestAsyncFunc = (...activationArgs: Guest[]) => Guest<Promise<any>>;
|
|
22
|
+
export type HostAsyncFuncWrapper = (...activationArgs: Host<any>[]) => HostVow<any>;
|
|
38
23
|
/**
|
|
39
24
|
* The function from the host as it will be available in the guest.
|
|
40
25
|
*
|
|
41
26
|
* Specifically, Vow return values are converted to Promises.
|
|
42
27
|
*/
|
|
43
|
-
export type GuestOf<F extends HostAsyncFuncWrapper> = F extends (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
: F;
|
|
48
|
-
|
|
49
|
-
// from https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
50
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
51
|
-
|
|
28
|
+
export type GuestOf<F extends HostAsyncFuncWrapper> = F extends (...args: infer A) => Vow<infer R> ? (...args: A) => Promise<R> : F;
|
|
29
|
+
type Simplify<T> = {
|
|
30
|
+
[KeyType in keyof T]: T[KeyType];
|
|
31
|
+
} & {};
|
|
52
32
|
/**
|
|
53
33
|
* Convert an entire Guest interface into what the host will implement.
|
|
54
34
|
*/
|
|
55
|
-
type HostInterface<T> = {
|
|
56
|
-
|
|
57
|
-
? HostOf<T[K]>
|
|
58
|
-
: T[K] extends Record<string, any>
|
|
59
|
-
? Simplify<HostInterface<T[K]>>
|
|
60
|
-
: T[K];
|
|
35
|
+
export type HostInterface<T> = {
|
|
36
|
+
[K in keyof T]: T[K] extends CallableFunction ? HostOf<T[K]> : T[K] extends Record<string, any> ? Simplify<HostInterface<T[K]>> : T[K];
|
|
61
37
|
};
|
|
62
|
-
|
|
63
38
|
/**
|
|
64
39
|
* Convert an entire Host interface into what the Guest will receive.
|
|
65
40
|
*/
|
|
66
41
|
export type GuestInterface<T> = {
|
|
67
|
-
|
|
68
|
-
? (...args: Parameters<T[K]>) => Promise<R>
|
|
69
|
-
: T[K] extends HostAsyncFuncWrapper
|
|
70
|
-
? GuestOf<T[K]>
|
|
71
|
-
: T[K] extends (...args: any[]) => infer R
|
|
72
|
-
? T[K]
|
|
73
|
-
: T[K] extends object
|
|
74
|
-
? GuestInterface<T[K]>
|
|
75
|
-
: T[K];
|
|
42
|
+
[K in keyof T]: T[K] extends (...args: any[]) => Vow<infer R> ? (...args: Parameters<T[K]>) => Promise<R> : T[K] extends HostAsyncFuncWrapper ? GuestOf<T[K]> : T[K] extends (...args: any[]) => infer R ? T[K] : T[K] extends object ? GuestInterface<T[K]> : T[K];
|
|
76
43
|
};
|
|
77
|
-
|
|
78
44
|
/**
|
|
79
45
|
* The function the host must provide to match an interface the guest expects.
|
|
80
46
|
*
|
|
81
47
|
* Specifically, Promise return values are converted to Vows.
|
|
82
48
|
*/
|
|
83
|
-
export type HostOf<F extends CallableFunction> = F extends (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
? (...args: A) => Vow<T extends Passable ? T : HostInterface<T>>
|
|
88
|
-
: (...args: A) => HostInterface<R>
|
|
89
|
-
: F;
|
|
90
|
-
|
|
91
|
-
export type HostArgs<GA extends any[]> = { [K in keyof GA]: HostOf<GA[K]> };
|
|
92
|
-
|
|
49
|
+
export type HostOf<F extends CallableFunction> = F extends (...args: infer A) => infer R ? R extends Promise<infer T> ? (...args: A) => Vow<T extends Passable ? T : HostInterface<T>> : (...args: A) => HostInterface<R> : F;
|
|
50
|
+
export type HostArgs<GA extends any[]> = {
|
|
51
|
+
[K in keyof GA]: HostOf<GA[K]>;
|
|
52
|
+
};
|
|
93
53
|
export type PreparationOptions = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
54
|
+
vowTools?: VowTools;
|
|
55
|
+
makeLogStore?: (() => LogStore) | undefined;
|
|
56
|
+
makeBijection?: (() => Bijection) | undefined;
|
|
57
|
+
endowmentTools?: EndowmentTools;
|
|
98
58
|
};
|
|
99
59
|
export type OutcomeKind = 'return' | 'throw';
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
kind: 'throw';
|
|
108
|
-
problem: any;
|
|
109
|
-
};
|
|
110
|
-
|
|
60
|
+
export type Outcome = {
|
|
61
|
+
kind: 'return';
|
|
62
|
+
result: any;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'throw';
|
|
65
|
+
problem: any;
|
|
66
|
+
};
|
|
111
67
|
export type Ephemera<S extends WeakKey = WeakKey, V extends unknown = any> = {
|
|
112
|
-
|
|
113
|
-
|
|
68
|
+
for: (self: S) => V;
|
|
69
|
+
resetFor: (self: S) => void;
|
|
114
70
|
};
|
|
115
|
-
|
|
116
71
|
/**
|
|
117
72
|
* This is the type alias for the membrane log entries we currently implement.
|
|
118
73
|
*
|
|
119
74
|
* @see {FutureLogEntry} below for the full membrane log entry, which we do not
|
|
120
75
|
* yet support.
|
|
121
76
|
*/
|
|
122
|
-
export type LogEntry =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
callIndex: number,
|
|
146
|
-
]
|
|
147
|
-
| [
|
|
148
|
-
op: 'checkSend',
|
|
149
|
-
target: Host,
|
|
150
|
-
optVerb: PropertyKey | undefined,
|
|
151
|
-
args: Host[],
|
|
152
|
-
callIndex: number,
|
|
153
|
-
];
|
|
154
|
-
|
|
77
|
+
export type LogEntry = [
|
|
78
|
+
op: 'doFulfill',
|
|
79
|
+
vow: HostVow,
|
|
80
|
+
fulfillment: Host
|
|
81
|
+
] | [op: 'doReject', vow: HostVow, reason: Host] | [op: 'doReturn', callIndex: number, result: Host] | [op: 'doThrow', callIndex: number, problem: Host] | [
|
|
82
|
+
op: 'checkCall',
|
|
83
|
+
target: Host,
|
|
84
|
+
optVerb: PropertyKey | undefined,
|
|
85
|
+
args: Host[],
|
|
86
|
+
callIndex: number
|
|
87
|
+
] | [
|
|
88
|
+
op: 'checkSendOnly',
|
|
89
|
+
target: Host,
|
|
90
|
+
optVerb: PropertyKey | undefined,
|
|
91
|
+
args: Host[],
|
|
92
|
+
callIndex: number
|
|
93
|
+
] | [
|
|
94
|
+
op: 'checkSend',
|
|
95
|
+
target: Host,
|
|
96
|
+
optVerb: PropertyKey | undefined,
|
|
97
|
+
args: Host[],
|
|
98
|
+
callIndex: number
|
|
99
|
+
];
|
|
155
100
|
/**
|
|
156
101
|
* This would be the type alias for the full membrane log, if we supported:
|
|
157
102
|
* - the guest sending guest-promises and guest-remotables to the host
|
|
158
103
|
* - the guest using `E` to eventual-send to guest wrappers of the host
|
|
159
104
|
* vows and remotables.
|
|
160
105
|
*/
|
|
161
|
-
export type FutureLogEntry =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
]
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
]
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
target: Host,
|
|
209
|
-
optVerb: PropertyKey | undefined,
|
|
210
|
-
args: Host[],
|
|
211
|
-
callIndex: number,
|
|
212
|
-
]
|
|
213
|
-
| [
|
|
214
|
-
op: 'checkSend',
|
|
215
|
-
target: Host,
|
|
216
|
-
optVerb: PropertyKey | undefined,
|
|
217
|
-
args: Host[],
|
|
218
|
-
callIndex: number,
|
|
219
|
-
]
|
|
220
|
-
| [op: 'checkReturn', callIndex: number, result: Host]
|
|
221
|
-
| [op: 'checkThrow', callIndex: number, problem: Host];
|
|
106
|
+
export type FutureLogEntry = [
|
|
107
|
+
op: 'doFulfill',
|
|
108
|
+
vow: HostVow,
|
|
109
|
+
fulfillment: Host
|
|
110
|
+
] | [op: 'doReject', vow: HostVow, reason: Host] | [
|
|
111
|
+
op: 'doCall',
|
|
112
|
+
target: Host,
|
|
113
|
+
optVerb: PropertyKey | undefined,
|
|
114
|
+
args: Host[],
|
|
115
|
+
callIndex: number
|
|
116
|
+
] | [
|
|
117
|
+
op: 'doSendOnly',
|
|
118
|
+
target: Host,
|
|
119
|
+
optVerb: PropertyKey | undefined,
|
|
120
|
+
args: Host[],
|
|
121
|
+
callIndex: number
|
|
122
|
+
] | [
|
|
123
|
+
op: 'doSend',
|
|
124
|
+
target: Host,
|
|
125
|
+
optVerb: PropertyKey | undefined,
|
|
126
|
+
args: Host[],
|
|
127
|
+
callIndex: number
|
|
128
|
+
] | [op: 'doReturn', callIndex: number, result: Host] | [op: 'doThrow', callIndex: number, problem: Host] | [
|
|
129
|
+
op: 'checkFulfill',
|
|
130
|
+
vow: HostVow,
|
|
131
|
+
fulfillment: Host
|
|
132
|
+
] | [op: 'checkReject', vow: HostVow, reason: Host] | [
|
|
133
|
+
op: 'checkCall',
|
|
134
|
+
target: Host,
|
|
135
|
+
optVerb: PropertyKey | undefined,
|
|
136
|
+
args: Host[],
|
|
137
|
+
callIndex: number
|
|
138
|
+
] | [
|
|
139
|
+
op: 'checkSendOnly',
|
|
140
|
+
target: Host,
|
|
141
|
+
optVerb: PropertyKey | undefined,
|
|
142
|
+
args: Host[],
|
|
143
|
+
callIndex: number
|
|
144
|
+
] | [
|
|
145
|
+
op: 'checkSend',
|
|
146
|
+
target: Host,
|
|
147
|
+
optVerb: PropertyKey | undefined,
|
|
148
|
+
args: Host[],
|
|
149
|
+
callIndex: number
|
|
150
|
+
] | [op: 'checkReturn', callIndex: number, result: Host] | [op: 'checkThrow', callIndex: number, problem: Host];
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,UAAU,GACV,WAAW,GACX,QAAQ,GACR,MAAM,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,GAAG,IAAI,CAAC,CAAC;AAC/C,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,OA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B,GACD;IACE,EAAE,EAAE,eAAe;IACnB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,WAAW,GAAG,SAAS;IAChC,IAAI,EAAE,IAAI,EAAE;IACZ,SAAS,EAAE,MAAM;CAClB,GACD;IACE,EAAE,EAAE,WAAW;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,WAAW,GAAG,SAAS;IAChC,IAAI,EAAE,IAAI,EAAE;IACZ,SAAS,EAAE,MAAM;CAClB,GACD,CAAC,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GACpD,CAAC,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC"}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
2
|
+
import type { Passable } from '@endo/pass-style';
|
|
3
|
+
import type { Vow, VowTools } from '@agoric/vow';
|
|
4
|
+
import type { LogStore } from './log-store.js';
|
|
5
|
+
import type { Bijection } from './bijection.js';
|
|
6
|
+
import type { EndowmentTools } from './endowments.js';
|
|
7
|
+
|
|
8
|
+
export type FlowState =
|
|
9
|
+
| 'Running'
|
|
10
|
+
| 'Sleeping'
|
|
11
|
+
| 'Replaying'
|
|
12
|
+
| 'Failed'
|
|
13
|
+
| 'Done';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `T` defaults to `any`, not `Passable`, because unwrapped guests include
|
|
17
|
+
* non-passables, like unwrapped functions and unwrapped state records.
|
|
18
|
+
* (Unwrapped functions could be made into Remotables,
|
|
19
|
+
* but since they still could not be made durable, in this context
|
|
20
|
+
* it'd be pointless.)
|
|
21
|
+
*/
|
|
22
|
+
export type Guest<T extends unknown = any> = T;
|
|
23
|
+
export type Host<T extends Passable = Passable> = T;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A HostVow must be durably storable. It corresponds to an
|
|
27
|
+
* ephemeral guest promise.
|
|
28
|
+
*/
|
|
29
|
+
export type HostVow<T extends Passable = Passable> = Host<Vow<T>>;
|
|
30
|
+
|
|
31
|
+
export type GuestAsyncFunc = (
|
|
32
|
+
...activationArgs: Guest[]
|
|
33
|
+
) => Guest<Promise<any>>;
|
|
34
|
+
|
|
35
|
+
export type HostAsyncFuncWrapper = (
|
|
36
|
+
...activationArgs: Host<any>[]
|
|
37
|
+
) => HostVow<any>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The function from the host as it will be available in the guest.
|
|
41
|
+
*
|
|
42
|
+
* Specifically, Vow return values are converted to Promises.
|
|
43
|
+
*/
|
|
44
|
+
export type GuestOf<F extends HostAsyncFuncWrapper> = F extends (
|
|
45
|
+
...args: infer A
|
|
46
|
+
) => Vow<infer R>
|
|
47
|
+
? (...args: A) => Promise<R>
|
|
48
|
+
: F;
|
|
49
|
+
|
|
50
|
+
// from https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
51
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Convert an entire Guest interface into what the host will implement.
|
|
55
|
+
*/
|
|
56
|
+
export type HostInterface<T> = {
|
|
57
|
+
[K in keyof T]: T[K] extends CallableFunction
|
|
58
|
+
? HostOf<T[K]>
|
|
59
|
+
: T[K] extends Record<string, any>
|
|
60
|
+
? Simplify<HostInterface<T[K]>>
|
|
61
|
+
: T[K];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Convert an entire Host interface into what the Guest will receive.
|
|
66
|
+
*/
|
|
67
|
+
export type GuestInterface<T> = {
|
|
68
|
+
[K in keyof T]: T[K] extends (...args: any[]) => Vow<infer R>
|
|
69
|
+
? (...args: Parameters<T[K]>) => Promise<R>
|
|
70
|
+
: T[K] extends HostAsyncFuncWrapper
|
|
71
|
+
? GuestOf<T[K]>
|
|
72
|
+
: T[K] extends (...args: any[]) => infer R
|
|
73
|
+
? T[K]
|
|
74
|
+
: T[K] extends object
|
|
75
|
+
? GuestInterface<T[K]>
|
|
76
|
+
: T[K];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The function the host must provide to match an interface the guest expects.
|
|
81
|
+
*
|
|
82
|
+
* Specifically, Promise return values are converted to Vows.
|
|
83
|
+
*/
|
|
84
|
+
export type HostOf<F extends CallableFunction> = F extends (
|
|
85
|
+
...args: infer A
|
|
86
|
+
) => infer R
|
|
87
|
+
? R extends Promise<infer T>
|
|
88
|
+
? (...args: A) => Vow<T extends Passable ? T : HostInterface<T>>
|
|
89
|
+
: (...args: A) => HostInterface<R>
|
|
90
|
+
: F;
|
|
91
|
+
|
|
92
|
+
export type HostArgs<GA extends any[]> = { [K in keyof GA]: HostOf<GA[K]> };
|
|
93
|
+
|
|
94
|
+
export type PreparationOptions = {
|
|
95
|
+
vowTools?: VowTools;
|
|
96
|
+
makeLogStore?: (() => LogStore) | undefined;
|
|
97
|
+
makeBijection?: (() => Bijection) | undefined;
|
|
98
|
+
endowmentTools?: EndowmentTools;
|
|
99
|
+
};
|
|
100
|
+
export type OutcomeKind = 'return' | 'throw';
|
|
101
|
+
|
|
102
|
+
export type Outcome =
|
|
103
|
+
| {
|
|
104
|
+
kind: 'return';
|
|
105
|
+
result: any;
|
|
106
|
+
}
|
|
107
|
+
| {
|
|
108
|
+
kind: 'throw';
|
|
109
|
+
problem: any;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type Ephemera<S extends WeakKey = WeakKey, V extends unknown = any> = {
|
|
113
|
+
for: (self: S) => V;
|
|
114
|
+
resetFor: (self: S) => void;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* This is the type alias for the membrane log entries we currently implement.
|
|
119
|
+
*
|
|
120
|
+
* @see {FutureLogEntry} below for the full membrane log entry, which we do not
|
|
121
|
+
* yet support.
|
|
122
|
+
*/
|
|
123
|
+
export type LogEntry =
|
|
124
|
+
| [
|
|
125
|
+
// ///////////////// From Host to Guest /////////////////////////
|
|
126
|
+
op: 'doFulfill',
|
|
127
|
+
vow: HostVow,
|
|
128
|
+
fulfillment: Host,
|
|
129
|
+
]
|
|
130
|
+
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
131
|
+
| [op: 'doReturn', callIndex: number, result: Host]
|
|
132
|
+
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
133
|
+
| [
|
|
134
|
+
// ///////////////////// From Guest to Host /////////////////////////
|
|
135
|
+
op: 'checkCall',
|
|
136
|
+
target: Host,
|
|
137
|
+
optVerb: PropertyKey | undefined,
|
|
138
|
+
args: Host[],
|
|
139
|
+
callIndex: number,
|
|
140
|
+
]
|
|
141
|
+
| [
|
|
142
|
+
op: 'checkSendOnly',
|
|
143
|
+
target: Host,
|
|
144
|
+
optVerb: PropertyKey | undefined,
|
|
145
|
+
args: Host[],
|
|
146
|
+
callIndex: number,
|
|
147
|
+
]
|
|
148
|
+
| [
|
|
149
|
+
op: 'checkSend',
|
|
150
|
+
target: Host,
|
|
151
|
+
optVerb: PropertyKey | undefined,
|
|
152
|
+
args: Host[],
|
|
153
|
+
callIndex: number,
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* This would be the type alias for the full membrane log, if we supported:
|
|
158
|
+
* - the guest sending guest-promises and guest-remotables to the host
|
|
159
|
+
* - the guest using `E` to eventual-send to guest wrappers of the host
|
|
160
|
+
* vows and remotables.
|
|
161
|
+
*/
|
|
162
|
+
export type FutureLogEntry =
|
|
163
|
+
| [
|
|
164
|
+
// ///////////////// From Host to Guest ///////////////////////
|
|
165
|
+
op: 'doFulfill',
|
|
166
|
+
vow: HostVow,
|
|
167
|
+
fulfillment: Host,
|
|
168
|
+
]
|
|
169
|
+
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
170
|
+
| [
|
|
171
|
+
op: 'doCall',
|
|
172
|
+
target: Host,
|
|
173
|
+
optVerb: PropertyKey | undefined,
|
|
174
|
+
args: Host[],
|
|
175
|
+
callIndex: number,
|
|
176
|
+
]
|
|
177
|
+
| [
|
|
178
|
+
op: 'doSendOnly',
|
|
179
|
+
target: Host,
|
|
180
|
+
optVerb: PropertyKey | undefined,
|
|
181
|
+
args: Host[],
|
|
182
|
+
callIndex: number,
|
|
183
|
+
]
|
|
184
|
+
| [
|
|
185
|
+
op: 'doSend',
|
|
186
|
+
target: Host,
|
|
187
|
+
optVerb: PropertyKey | undefined,
|
|
188
|
+
args: Host[],
|
|
189
|
+
callIndex: number,
|
|
190
|
+
]
|
|
191
|
+
| [op: 'doReturn', callIndex: number, result: Host]
|
|
192
|
+
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
193
|
+
| [
|
|
194
|
+
// ///////////////////// From Guest to Host /////////////////////////
|
|
195
|
+
op: 'checkFulfill',
|
|
196
|
+
vow: HostVow,
|
|
197
|
+
fulfillment: Host,
|
|
198
|
+
]
|
|
199
|
+
| [op: 'checkReject', vow: HostVow, reason: Host]
|
|
200
|
+
| [
|
|
201
|
+
op: 'checkCall',
|
|
202
|
+
target: Host,
|
|
203
|
+
optVerb: PropertyKey | undefined,
|
|
204
|
+
args: Host[],
|
|
205
|
+
callIndex: number,
|
|
206
|
+
]
|
|
207
|
+
| [
|
|
208
|
+
op: 'checkSendOnly',
|
|
209
|
+
target: Host,
|
|
210
|
+
optVerb: PropertyKey | undefined,
|
|
211
|
+
args: Host[],
|
|
212
|
+
callIndex: number,
|
|
213
|
+
]
|
|
214
|
+
| [
|
|
215
|
+
op: 'checkSend',
|
|
216
|
+
target: Host,
|
|
217
|
+
optVerb: PropertyKey | undefined,
|
|
218
|
+
args: Host[],
|
|
219
|
+
callIndex: number,
|
|
220
|
+
]
|
|
221
|
+
| [op: 'checkReturn', callIndex: number, result: Host]
|
|
222
|
+
| [op: 'checkThrow', callIndex: number, problem: Host];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./index.js","./src/async-flow.js","./src/bijection.js","./src/convert.js","./src/endowments.js","./src/ephemera.js","./src/equate.js","./src/log-store.js","./src/replay-membrane.js","./src/type-guards.js","./src/types.d.ts"],"version":"5.6.2"}
|
|
1
|
+
{"root":["./index.js","./src/async-flow.js","./src/bijection.js","./src/convert.js","./src/endowments.js","./src/ephemera.js","./src/equate.js","./src/log-store.js","./src/replay-membrane.js","./src/type-guards.js","./src/types-index.d.ts","./src/types.ts"],"version":"5.6.2"}
|
|
File without changes
|