@agoric/vow 0.1.1-calypso-dev-84eb287.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # Vows
2
+
3
+ Native promises are not compatible with Agoric's durable stores, which means that on the Agoric platform, such promises disconnect their clients when their creator vat is upgraded. Vows are objects that represent promises that can be stored durably, this package also provides a `when` operator to allow clients to tolerate upgrades of vow-hosting vats, as well as a `watch` operator to subscribe to a vow in a way that survives upgrades of both the creator and subscribing client vats.
4
+
5
+ ## Vow Consumer
6
+
7
+ If your vat is a consumer of promises that are unexpectedly fulfilling to a Vow (something like):
8
+
9
+ ```js
10
+ import { E } from '@endo/far';
11
+
12
+ const a = await w1;
13
+ const b = await E(w2).something(...args);
14
+ console.log('Here they are:', { a, b });
15
+ ```
16
+
17
+ Produces output like:
18
+ ```console
19
+ Here they are: {
20
+ a: Object [Vow] {
21
+ payload: { vowV0: Object [Alleged: VowInternalsKit vowV0] {} }
22
+ },
23
+ b: Object [Vow] {
24
+ payload: { vowV0: Object [Alleged: VowInternalsKit vowV0] {} }
25
+ }
26
+ }
27
+ ```
28
+
29
+ On Agoric, you can use `V` exported from `@agoric/vow/vat.js`, which
30
+ converts a chain of promises and vows to a promise for its final
31
+ fulfilment, by unwrapping any intermediate vows:
32
+
33
+ ```js
34
+ import { V as E } from '@agoric/vow/vat.js';
35
+ [...]
36
+ const a = await E.when(w1);
37
+ const b = await E(w2).something(...args);
38
+ // Produces the expected results.
39
+ ```
40
+
41
+ ## Vow Producer
42
+
43
+ On Agoric, use the following to create and resolve a vow:
44
+
45
+ ```js
46
+ // CAVEAT: `V` uses internal ephemeral promises, so while it is convenient,
47
+ // it cannot be used by upgradable vats. See "Durability" below:
48
+ import { V as E, makeVowKit } from '@agoric/vow/vat.js';
49
+ [...]
50
+ const { resolver, vow } = makeVowKit();
51
+ // Send vow to a potentially different vat.
52
+ E(outsideReference).performSomeMethod(vow);
53
+ // some time later...
54
+ resolver.resolve('now you know the answer');
55
+ ```
56
+
57
+ ## Durability
58
+
59
+ The `@agoric/vow/vat.js` module allows vows to integrate Agoric's vat upgrade
60
+ mechanism. To create vow tools that deal with durable objects:
61
+
62
+ ```js
63
+ // NOTE: Cannot use `V` as it has non-durable internal state when unwrapping
64
+ // vows. Instead, use the default vow-exposing `E` with the `watch`
65
+ // operator.
66
+ import { E } from '@endo/far';
67
+ import { prepareVowTools } from '@agoric/vow/vat.js';
68
+ import { makeDurableZone } from '@agoric/zone';
69
+
70
+ // Only do the following once at the start of a new vat incarnation:
71
+ const zone = makeDurableZone(baggage);
72
+ const vowZone = zone.subZone('VowTools');
73
+ const { watch, makeVowKit } = prepareVowTools(vowZone);
74
+
75
+ // Now the functions have been bound to the durable baggage.
76
+ // Vows and resolvers you create can be saved in durable stores.
77
+ ```
78
+
79
+ ## Internals
80
+
81
+ The current "version 0" vow internals expose a `shorten()` method, returning a
82
+ promise for the next resolution. `watch` and `when` use `shorten()` to advance
83
+ through the vow chain step-by-step, tolerating disconnects by retrying a failed
84
+ step, rather than just making one giant leap to the end of a promise chain with
85
+ `.then(...)`.
86
+
87
+ Here is an (oversimplified) algorithm that `watch` and `when` use to obtain a
88
+ final result:
89
+
90
+ ```js
91
+ // Directly await the non-retriable original specimen.
92
+ // This is non-retriable because we don't know how our caller obtained
93
+ // it in the first place, since it is an application-specific detail
94
+ // that may not be side-effect free.
95
+ let result = await specimenP;
96
+ let vowInternals = getVowInternals(result);
97
+ // Loop until the result is no longer a vow.
98
+ while (vowInternals) {
99
+ try {
100
+ const shortened = await E(internals.vowV0).shorten();
101
+ const nextInternals = getVowInternals(shortened);
102
+ // Atomically update the state.
103
+ result = shortened;
104
+ vowInternals = nextInternals;
105
+ } catch (e) {
106
+ if (!isDisconnectionReason(e)) {
107
+ // Not a disconnect, so abort.
108
+ throw e;
109
+ }
110
+ // It was a disconnect, so try again with the same state.
111
+ }
112
+ }
113
+ return result;
114
+ ```
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@agoric/vow",
3
+ "version": "0.1.1-calypso-dev-84eb287.0+84eb287",
4
+ "description": "Remote (shortening and disconnection-tolerant) Promise-likes",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "engines": {
8
+ "node": ">=14.15.0"
9
+ },
10
+ "scripts": {
11
+ "build": "exit 0",
12
+ "prepack": "tsc --build tsconfig.build.json",
13
+ "postpack": "git clean -f '*.d.ts*'",
14
+ "test": "ava",
15
+ "test:nyc": "exit 0",
16
+ "test:xs": "exit 0",
17
+ "lint-fix": "yarn lint:eslint --fix",
18
+ "lint": "run-s --continue-on-error lint:*",
19
+ "lint:eslint": "eslint .",
20
+ "lint:types": "tsc"
21
+ },
22
+ "dependencies": {
23
+ "@agoric/base-zone": "0.1.1-calypso-dev-84eb287.0+84eb287",
24
+ "@agoric/internal": "0.3.3-calypso-dev-84eb287.0+84eb287",
25
+ "@endo/env-options": "^1.1.4",
26
+ "@endo/eventual-send": "^1.2.2",
27
+ "@endo/pass-style": "^1.4.0",
28
+ "@endo/patterns": "^1.4.0",
29
+ "@endo/promise-kit": "^1.1.2"
30
+ },
31
+ "devDependencies": {
32
+ "@agoric/internal": "^0.3.2",
33
+ "@endo/far": "^1.1.2",
34
+ "@endo/init": "^1.1.2",
35
+ "ava": "^5.3.0"
36
+ },
37
+ "ava": {
38
+ "require": [
39
+ "@endo/init/debug.js"
40
+ ],
41
+ "files": [
42
+ "test/**/*.test.*"
43
+ ]
44
+ },
45
+ "author": "Agoric",
46
+ "license": "Apache-2.0",
47
+ "files": [
48
+ "*.js",
49
+ "src"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "typeCoverage": {
55
+ "atLeast": 89.6
56
+ },
57
+ "gitHead": "84eb287915c8255d68e845a9b6e10c790f0d54cb"
58
+ }
package/src/E.d.ts ADDED
@@ -0,0 +1,165 @@
1
+ export default makeE;
2
+ export type Callable = (...args: unknown[]) => any;
3
+ export type EProxy = ReturnType<(<A = {}>(HandledPromise: HandledPromiseConstructor, powers?: {
4
+ unwrap?: Unwrapper | undefined;
5
+ additional?: A | undefined;
6
+ } | undefined) => (<T>(x: T, opts?: EUnwrapOptions | undefined) => ECallableOrMethods<RemoteFunctions<T>>) & {
7
+ /**
8
+ * E.get(x) returns a proxy on which you can get arbitrary properties.
9
+ * Each of these properties returns a promise for the property. The promise
10
+ * value will be the property fetched from whatever 'x' designates (or
11
+ * resolves to) in a future turn, not this one.
12
+ *
13
+ * @template T
14
+ * @param {T} x target for property get
15
+ * @param {EOptions} [opts]
16
+ * @returns {EGetters<LocalRecord<T>>} property get proxy
17
+ * @readonly
18
+ */
19
+ readonly get: <T>(x: T, opts?: EUnwrapOptions | undefined) => EGetters<LocalRecord<T>>;
20
+ /**
21
+ * E.resolve(x) converts x to a handled promise. It is
22
+ * shorthand for HandledPromise.resolve(x)
23
+ *
24
+ * @template T
25
+ * @param {T} x value to convert to a handled promise
26
+ * @param {EOptions} [opts]
27
+ * @returns {Promise<Awaited<T>>} handled promise for x
28
+ * @readonly
29
+ */
30
+ readonly resolve: <T>(x: T, opts?: EUnwrapOptions | undefined) => Promise<Awaited<T>>;
31
+ /**
32
+ * E.sendOnly returns a proxy similar to E, but for which the results
33
+ * are ignored (undefined is returned).
34
+ *
35
+ * @template T
36
+ * @param {T} x target for method/function call
37
+ * @param {EOptions} [opts]
38
+ * @returns {ESendOnlyCallableOrMethods<RemoteFunctions<T>>} method/function call proxy
39
+ * @readonly
40
+ */
41
+ readonly sendOnly: <T>(x: T, opts?: EUnwrapOptions | undefined) => ESendOnlyCallableOrMethods<RemoteFunctions<T>>;
42
+ /**
43
+ * E.when(x, res, rej) is equivalent to
44
+ * unwrap(x).then(onfulfilled, onrejected)
45
+ *
46
+ * @template T
47
+ * @template [TResult1=EUnwrap<T>]
48
+ * @template [TResult2=never]
49
+ * @param {ERef<T>} x value to convert to a handled promise
50
+ * @param {(value: EUnwrap<T>) => ERef<TResult1>} [onfulfilled]
51
+ * @param {(reason: any) => ERef<TResult2>} [onrejected]
52
+ * @param {EOptions} [opts]
53
+ * @returns {Promise<TResult1 | TResult2>}
54
+ * @readonly
55
+ */
56
+ readonly when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(x: ERef<T>, onfulfilled?: ((value: EUnwrap<T>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined, opts?: EUnwrapOptions | undefined) => Promise<TResult1 | TResult2>;
57
+ } & A)>;
58
+ /**
59
+ * `DataOnly<T>` means to return a record type `T2` consisting only of
60
+ * properties that are *not* functions.
61
+ */
62
+ export type DataOnly<T> = Omit<T, FilteredKeys<T, Callable>>;
63
+ export type ERef<T> = PromiseLike<T> | T;
64
+ export type ECallable<T extends Callable> = ReturnType<T> extends EUnwrap<ReturnType<T>> ? (...args: Parameters<T>) => Promise<ReturnType<T>> : ReturnType<T> extends Promise<EUnwrap<ReturnType<T>>> ? T : (...args: Parameters<T>) => Promise<EUnwrap<ReturnType<T>>>;
65
+ export type EMethods<T> = { readonly [P in keyof T]: T[P] extends Callable ? ECallable<T[P]> : never; };
66
+ export type EGetters<T> = { readonly [P in keyof T]: T[P] extends PromiseLike<any> ? T[P] : Promise<Awaited<T[P]>>; };
67
+ export type ESendOnlyCallable<T extends Callable> = (...args: Parameters<T>) => Promise<void>;
68
+ export type ESendOnlyMethods<T> = { readonly [P in keyof T]: T[P] extends Callable ? ESendOnlyCallable<T[P]> : never; };
69
+ export type ESendOnlyCallableOrMethods<T> = (T extends Callable ? ESendOnlyCallable<T> & ESendOnlyMethods<Required<T>> : ESendOnlyMethods<Required<T>>);
70
+ export type ECallableOrMethods<T> = (T extends Callable ? ECallable<T> & EMethods<Required<T>> : EMethods<Required<T>>);
71
+ /**
72
+ * Return a union of property names/symbols/numbers P for which the record element T[P]'s type extends U.
73
+ *
74
+ * Given const x = { a: 123, b: 'hello', c: 42, 49: () => {}, 53: 67 },
75
+ *
76
+ * FilteredKeys<typeof x, number> is the type 'a' | 'c' | 53.
77
+ * FilteredKeys<typeof x, string> is the type 'b'.
78
+ * FilteredKeys<typeof x, 42 | 67> is the type 'c' | 53.
79
+ * FilteredKeys<typeof x, boolean> is the type never.
80
+ */
81
+ export type FilteredKeys<T, U> = { [P in keyof T]: T[P] extends U ? P : never; }[keyof T];
82
+ /**
83
+ * `PickCallable<T>` means to return a single root callable or a record type
84
+ * consisting only of properties that are functions.
85
+ */
86
+ export type PickCallable<T> = (T extends Callable ? (...args: Parameters<T>) => ReturnType<T> : FilteredKeys<T, Callable> extends never ? any : Pick<T, FilteredKeys<T, Callable>>);
87
+ /**
88
+ * `RemoteFunctions<T>` means to return the functions and properties that are remotely callable.
89
+ */
90
+ export type RemoteFunctions<T> = (EUnwrap<T> extends RemotableBrand<any, infer R> ? PickCallable<R> : PickCallable<EUnwrap<T>>);
91
+ export type LocalRecord<T> = (T extends RemotableBrand<infer L, any> ? L : EUnwrap<T>);
92
+ /**
93
+ * Type for an object that must only be invoked with E. It supports a given
94
+ * interface but declares all the functions as asyncable.
95
+ */
96
+ export type EOnly<T> = (T extends Callable ? (...args: Parameters<T>) => ERef<Awaited<EOnly<ReturnType<T>>>> : T extends Record<PropertyKey, Callable> ? { [K in keyof T]: T[K] extends Callable ? (...args: Parameters<T[K]>) => ERef<Awaited<EOnly<ReturnType<T[K]>>>> : T[K]; } : T);
97
+ export type Unwrapper = <T>(x: T, retryContext?: string, opts?: EOptions) => Promise<EUnwrap<T>>;
98
+ export type EOptions = EUnwrapOptions;
99
+ /**
100
+ * @template [A={}]
101
+ * @param {HandledPromiseConstructor} HandledPromise
102
+ * @param {object} [powers]
103
+ * @param {Unwrapper} [powers.unwrap]
104
+ * @param {A} [powers.additional]
105
+ */
106
+ declare function makeE<A = {}>(HandledPromise: HandledPromiseConstructor, powers?: {
107
+ unwrap?: Unwrapper | undefined;
108
+ additional?: A | undefined;
109
+ } | undefined): (<T>(x: T, opts?: EUnwrapOptions | undefined) => ECallableOrMethods<RemoteFunctions<T>>) & {
110
+ /**
111
+ * E.get(x) returns a proxy on which you can get arbitrary properties.
112
+ * Each of these properties returns a promise for the property. The promise
113
+ * value will be the property fetched from whatever 'x' designates (or
114
+ * resolves to) in a future turn, not this one.
115
+ *
116
+ * @template T
117
+ * @param {T} x target for property get
118
+ * @param {EOptions} [opts]
119
+ * @returns {EGetters<LocalRecord<T>>} property get proxy
120
+ * @readonly
121
+ */
122
+ readonly get: <T>(x: T, opts?: EUnwrapOptions | undefined) => EGetters<LocalRecord<T>>;
123
+ /**
124
+ * E.resolve(x) converts x to a handled promise. It is
125
+ * shorthand for HandledPromise.resolve(x)
126
+ *
127
+ * @template T
128
+ * @param {T} x value to convert to a handled promise
129
+ * @param {EOptions} [opts]
130
+ * @returns {Promise<Awaited<T>>} handled promise for x
131
+ * @readonly
132
+ */
133
+ readonly resolve: <T>(x: T, opts?: EUnwrapOptions | undefined) => Promise<Awaited<T>>;
134
+ /**
135
+ * E.sendOnly returns a proxy similar to E, but for which the results
136
+ * are ignored (undefined is returned).
137
+ *
138
+ * @template T
139
+ * @param {T} x target for method/function call
140
+ * @param {EOptions} [opts]
141
+ * @returns {ESendOnlyCallableOrMethods<RemoteFunctions<T>>} method/function call proxy
142
+ * @readonly
143
+ */
144
+ readonly sendOnly: <T>(x: T, opts?: EUnwrapOptions | undefined) => ESendOnlyCallableOrMethods<RemoteFunctions<T>>;
145
+ /**
146
+ * E.when(x, res, rej) is equivalent to
147
+ * unwrap(x).then(onfulfilled, onrejected)
148
+ *
149
+ * @template T
150
+ * @template [TResult1=EUnwrap<T>]
151
+ * @template [TResult2=never]
152
+ * @param {ERef<T>} x value to convert to a handled promise
153
+ * @param {(value: EUnwrap<T>) => ERef<TResult1>} [onfulfilled]
154
+ * @param {(reason: any) => ERef<TResult2>} [onrejected]
155
+ * @param {EOptions} [opts]
156
+ * @returns {Promise<TResult1 | TResult2>}
157
+ * @readonly
158
+ */
159
+ readonly when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(x: ERef<T>, onfulfilled?: ((value: EUnwrap<T>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined, opts?: EUnwrapOptions | undefined) => Promise<TResult1 | TResult2>;
160
+ } & A;
161
+ import type { HandledPromiseConstructor } from '@endo/eventual-send';
162
+ import type { EUnwrapOptions } from './types.js';
163
+ import type { EUnwrap } from './types.js';
164
+ import type { RemotableBrand } from '@endo/eventual-send';
165
+ //# sourceMappingURL=E.d.ts.map
package/src/E.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"E.d.ts","sourceRoot":"","sources":["E.js"],"names":[],"mappings":";uBA6Bc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG;qBAsT3B,UAAU,GAjHV,CAAC,uBACJ,yBAAyB;;;oBAkBjB,CAAC,KACH,CAAC,wCAEC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAUjD;;;;;;;;;;;OAWG;mBALU,CAAC,KACH,CAAC,wCAEC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAWrC;;;;;;;;;OASG;uBALU,CAAC,KACH,CAAC,wCAEC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAKhC;;;;;;;;;OASG;wBALU,CAAC,KACH,CAAC,wCAEC,0BAA0B,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAW3D;;;;;;;;;;;;;OAaG;oBATU,CAAC,EACA,QAAQ,eACR,QAAQ,aACX,IAAI,CAAC,CAAC,CAAC,yBACC,QAAQ,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,sCAC5B,GAAG,KAAK,IAAI,CAAC,QAAQ,CAAC,qDAE7B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;OAoBlB;;;;;qB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