@agoric/async-flow 0.1.1-dev-9288d84.0.9288d84 → 0.1.1-dev-9b2a827.0.9b2a827

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.
Files changed (3) hide show
  1. package/package.json +10 -10
  2. package/src/types.js +244 -0
  3. package/src/types.ts +0 -244
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@agoric/async-flow",
3
- "version": "0.1.1-dev-9288d84.0.9288d84",
3
+ "version": "0.1.1-dev-9b2a827.0.9b2a827",
4
4
  "description": "Upgrade async functions at await points by replay",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
7
7
  "main": "./index.js",
8
8
  "scripts": {
9
9
  "build": "exit 0",
10
- "prepack": "yarn run -T tsc --build tsconfig.build.json",
11
- "postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
10
+ "prepack": "yarn run -T prepack-package",
11
+ "postpack": "yarn run -T postpack-package",
12
12
  "test": "ava",
13
13
  "test:c8": "c8 --all ${C8_OPTIONS:-} ava",
14
14
  "test:xs": "exit 0",
@@ -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-9288d84.0.9288d84",
28
- "@agoric/internal": "0.3.3-dev-9288d84.0.9288d84",
29
- "@agoric/store": "0.9.3-dev-9288d84.0.9288d84",
30
- "@agoric/vow": "0.1.1-dev-9288d84.0.9288d84",
27
+ "@agoric/base-zone": "0.1.1-dev-9b2a827.0.9b2a827",
28
+ "@agoric/internal": "0.3.3-dev-9b2a827.0.9b2a827",
29
+ "@agoric/store": "0.9.3-dev-9b2a827.0.9b2a827",
30
+ "@agoric/vow": "0.1.1-dev-9b2a827.0.9b2a827",
31
31
  "@endo/common": "^1.2.13",
32
32
  "@endo/errors": "^1.2.13",
33
33
  "@endo/eventual-send": "^1.3.4",
@@ -37,8 +37,8 @@
37
37
  "@endo/promise-kit": "^1.1.13"
38
38
  },
39
39
  "devDependencies": {
40
- "@agoric/swingset-vat": "0.32.3-dev-9288d84.0.9288d84",
41
- "@agoric/zone": "0.2.3-dev-9288d84.0.9288d84",
40
+ "@agoric/swingset-vat": "0.32.3-dev-9b2a827.0.9b2a827",
41
+ "@agoric/zone": "0.2.3-dev-9b2a827.0.9b2a827",
42
42
  "@endo/env-options": "^1.1.11",
43
43
  "ava": "^5.3.0",
44
44
  "tsd": "^0.33.0"
@@ -62,5 +62,5 @@
62
62
  "typeCoverage": {
63
63
  "atLeast": 77.35
64
64
  },
65
- "gitHead": "9288d84e2de10401f8211183329034ee0e7ffc43"
65
+ "gitHead": "9b2a827cdf1c3203c1a73637ed80dcd5b13edb8a"
66
66
  }
package/src/types.js ADDED
@@ -0,0 +1,244 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
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
+
23
+
24
+
25
+ /**
26
+ * A HostVow must be durably storable. It corresponds to an
27
+ * ephemeral guest promise.
28
+ */
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
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
+
45
+
46
+
47
+
48
+
49
+
50
+ // from https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
51
+
52
+
53
+
54
+
55
+ /**
56
+ * Returns a boolean indicating whether the parameter is exactly the `any` type.
57
+ */
58
+
59
+
60
+ /**
61
+ * Returns a boolean indicating whether the parameter is the `unknown` type.
62
+ */
63
+
64
+
65
+ /**
66
+ * Returns a boolean for whether Host or Guest type recursion should stop for
67
+ * the given parameter.
68
+ */
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+ /**
79
+ * Convert an entire Guest interface into what the host will implement.
80
+ */
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ /**
97
+ * Convert an entire Host interface into what the Guest will receive.
98
+ */
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ /**
112
+ * The function the host must provide to match an interface the guest expects.
113
+ *
114
+ * Specifically, Promise return values are converted to Vows.
115
+ */
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ /**
150
+ * This is the type alias for the membrane log entries we currently implement.
151
+ *
152
+ * @see {FutureLogEntry} below for the full membrane log entry, which we do not
153
+ * yet support.
154
+ */
155
+
156
+
157
+
158
+
159
+
160
+
161
+
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
+ * This would be the type alias for the full membrane log, if we supported:
187
+ * - the guest sending guest-promises and guest-remotables to the host
188
+ * - the guest using `E` to eventual-send to guest wrappers of the host
189
+ * vows and remotables.
190
+ */
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
package/src/types.ts DELETED
@@ -1,244 +0,0 @@
1
- import type { Passable } from '@endo/pass-style';
2
- import type { Fulfilled, VowLike, Vow, VowTools } from '@agoric/vow';
3
- import type { IsPrimitive, IsRemotable } from '@agoric/internal';
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 = 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
- type EmptyRecord = { [K in never]: never };
54
-
55
- /**
56
- * Returns a boolean indicating whether the parameter is exactly the `any` type.
57
- */
58
- type IsStrictAny<T> = 0 extends 1 & T ? false : true;
59
-
60
- /**
61
- * Returns a boolean indicating whether the parameter is the `unknown` type.
62
- */
63
- type IsUnknown<T> = unknown extends T ? IsStrictAny<T> : false;
64
-
65
- /**
66
- * Returns a boolean for whether Host or Guest type recursion should stop for
67
- * the given parameter.
68
- */
69
- type StopRecursion<T> =
70
- IsRemotable<T> extends true
71
- ? true
72
- : IsUnknown<T> extends true
73
- ? true
74
- : IsPrimitive<T> extends true
75
- ? true
76
- : false;
77
-
78
- /**
79
- * Convert an entire Guest interface into what the host will implement.
80
- */
81
- export type HostInterface<T, Overrides = EmptyRecord> =
82
- StopRecursion<NonNullable<T>> extends true
83
- ? T
84
- : T extends VowLike<infer P>
85
- ? Vow<HostInterface<Fulfilled<P>>>
86
- : {
87
- [K in keyof T]: K extends keyof Overrides
88
- ? Overrides[K]
89
- : T[K] extends CallableFunction
90
- ? HostOf<T[K]>
91
- : T[K] extends Record<string, any>
92
- ? Simplify<HostInterface<T[K]>>
93
- : HostInterface<T[K]>;
94
- };
95
-
96
- /**
97
- * Convert an entire Host interface into what the Guest will receive.
98
- */
99
- export type GuestInterface<T> = {
100
- [K in keyof T]: T[K] extends (...args: any[]) => Vow<infer R>
101
- ? (...args: Parameters<T[K]>) => Promise<R>
102
- : T[K] extends HostAsyncFuncWrapper
103
- ? GuestOf<T[K]>
104
- : T[K] extends (...args: any[]) => any
105
- ? T[K]
106
- : T[K] extends object
107
- ? GuestInterface<T[K]>
108
- : T[K];
109
- };
110
-
111
- /**
112
- * The function the host must provide to match an interface the guest expects.
113
- *
114
- * Specifically, Promise return values are converted to Vows.
115
- */
116
- export type HostOf<F> =
117
- StopRecursion<F> extends true
118
- ? F
119
- : F extends (...args: infer A) => infer R
120
- ? (...args: A) => HostInterface<R>
121
- : F;
122
-
123
- export type HostArgs<GA extends any[]> = { [K in keyof GA]: HostOf<GA[K]> };
124
-
125
- export type PreparationOptions = {
126
- vowTools?: VowTools;
127
- makeLogStore?: (() => LogStore) | undefined;
128
- makeBijection?: (() => Bijection) | undefined;
129
- endowmentTools?: EndowmentTools;
130
- panicHandler?: (e: any) => void;
131
- };
132
- export type OutcomeKind = 'return' | 'throw';
133
-
134
- export type Outcome =
135
- | {
136
- kind: 'return';
137
- result: any;
138
- }
139
- | {
140
- kind: 'throw';
141
- problem: any;
142
- };
143
-
144
- export type Ephemera<S extends WeakKey = WeakKey, V = any> = {
145
- for: (self: S) => V;
146
- resetFor: (self: S) => void;
147
- };
148
-
149
- /**
150
- * This is the type alias for the membrane log entries we currently implement.
151
- *
152
- * @see {FutureLogEntry} below for the full membrane log entry, which we do not
153
- * yet support.
154
- */
155
- export type LogEntry =
156
- | [op: 'startGeneration', generation: number]
157
- // ///////////////// From Host to Guest /////////////////////////
158
- | [op: 'doFulfill', vow: HostVow, fulfillment: Host]
159
- | [op: 'doReject', vow: HostVow, reason: Host]
160
- | [op: 'doReturn', callIndex: number, result: Host]
161
- | [op: 'doThrow', callIndex: number, problem: Host]
162
- // ///////////////////// From Guest to Host /////////////////////////
163
- | [
164
- op: 'checkCall',
165
- target: Host,
166
- optVerb: PropertyKey | undefined,
167
- args: Host[],
168
- callIndex: number,
169
- ]
170
- | [
171
- op: 'checkSendOnly',
172
- target: Host,
173
- optVerb: PropertyKey | undefined,
174
- args: Host[],
175
- callIndex: number,
176
- ]
177
- | [
178
- op: 'checkSend',
179
- target: Host,
180
- optVerb: PropertyKey | undefined,
181
- args: Host[],
182
- callIndex: number,
183
- ];
184
-
185
- /**
186
- * This would be the type alias for the full membrane log, if we supported:
187
- * - the guest sending guest-promises and guest-remotables to the host
188
- * - the guest using `E` to eventual-send to guest wrappers of the host
189
- * vows and remotables.
190
- */
191
- export type FutureLogEntry =
192
- | [op: 'startGeneration', generation: number]
193
- // ///////////////// From Host to Guest ///////////////////////
194
- | [op: 'doFulfill', vow: HostVow, fulfillment: Host]
195
- | [op: 'doReject', vow: HostVow, reason: Host]
196
- | [
197
- op: 'doCall',
198
- target: Host,
199
- optVerb: PropertyKey | undefined,
200
- args: Host[],
201
- callIndex: number,
202
- ]
203
- | [
204
- op: 'doSendOnly',
205
- target: Host,
206
- optVerb: PropertyKey | undefined,
207
- args: Host[],
208
- callIndex: number,
209
- ]
210
- | [
211
- op: 'doSend',
212
- target: Host,
213
- optVerb: PropertyKey | undefined,
214
- args: Host[],
215
- callIndex: number,
216
- ]
217
- | [op: 'doReturn', callIndex: number, result: Host]
218
- | [op: 'doThrow', callIndex: number, problem: Host]
219
- // ///////////////////// From Guest to Host /////////////////////////
220
- | [op: 'checkFulfill', vow: HostVow, fulfillment: Host]
221
- | [op: 'checkReject', vow: HostVow, reason: Host]
222
- | [
223
- op: 'checkCall',
224
- target: Host,
225
- optVerb: PropertyKey | undefined,
226
- args: Host[],
227
- callIndex: number,
228
- ]
229
- | [
230
- op: 'checkSendOnly',
231
- target: Host,
232
- optVerb: PropertyKey | undefined,
233
- args: Host[],
234
- callIndex: number,
235
- ]
236
- | [
237
- op: 'checkSend',
238
- target: Host,
239
- optVerb: PropertyKey | undefined,
240
- args: Host[],
241
- callIndex: number,
242
- ]
243
- | [op: 'checkReturn', callIndex: number, result: Host]
244
- | [op: 'checkThrow', callIndex: number, problem: Host];