@agoric/eventual-send
Advanced tools
Comparing version 0.14.2-dev-d44c803.0 to 0.14.2-dev-de7ed07.0
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.14.2-dev-d44c803.0+d44c803", | ||
"version": "0.14.2-dev-de7ed07.0+de7ed07", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -57,3 +57,3 @@ "type": "module", | ||
}, | ||
"gitHead": "d44c803ec0af33a9c859783eb97da0de6f390cd9" | ||
"gitHead": "de7ed0727a58e491ad2aa31cee48fe7497259f7c" | ||
} |
@@ -26,3 +26,3 @@ // @ts-check | ||
* @param {*} x Any value passed to E(x) | ||
* @param {*} HandledPromise | ||
* @param {import('./index').HandledPromiseConstructor} HandledPromise | ||
* @returns {ProxyHandler} the Proxy handler | ||
@@ -57,3 +57,3 @@ */ | ||
* @param {*} x Any value passed to E.sendOnly(x) | ||
* @param {*} HandledPromise | ||
* @param {import('./index').HandledPromiseConstructor} HandledPromise | ||
* @returns {ProxyHandler} the Proxy handler | ||
@@ -81,2 +81,6 @@ */ | ||
/** | ||
* @param {import('./index').HandledPromiseConstructor} HandledPromise | ||
* @returns {import('./index').EProxy} | ||
*/ | ||
export default function makeE(HandledPromise) { | ||
@@ -83,0 +87,0 @@ function E(x) { |
@@ -19,7 +19,16 @@ /* eslint-disable no-shadow,no-unused-vars,no-use-before-define,no-var,vars-on-top */ | ||
type Unpromise<T> = T extends ERef<infer U> ? U : T; | ||
type FilteredKeys<T, U> = { | ||
[P in keyof T]: T[P] extends U ? P : never; | ||
}[keyof T]; | ||
type Parameters<T> = T extends (...args: infer T) => any ? T : any; | ||
type ReturnType<T> = T extends (...args: any[]) => infer T ? T : any; | ||
type DataOnly<T> = Omit<T, FilteredKeys<T, Function>>; | ||
type FunctionOnly<T> = Pick<T, FilteredKeys<T, Function>> & | ||
(T extends Function ? (...args: Parameters<T>) => ReturnType<T> : {}); | ||
interface Remotable<T> { | ||
__Remote__: T; | ||
} | ||
type Remote<Primary, Local = DataOnly<Primary>> = ERef< | ||
Local & Remotable<Primary> | ||
>; | ||
interface EHandler<T> { | ||
@@ -61,3 +70,3 @@ get?: (p: T, name: Property, returnedP?: Promise<unknown>) => any; | ||
declare interface HandledPromiseStaticMethods { | ||
resolve<T>(x: T): Promise<Unpromise<T>>; | ||
resolve<T>(x: T): Promise<Awaited<T>>; | ||
resolve(): Promise<undefined>; | ||
@@ -98,10 +107,10 @@ applyFunction(target: unknown, args: unknown[]): Promise<unknown>; | ||
...args: Parameters<T[P]> | ||
) => Promise<Unpromise<ReturnType<T[P]>>>; | ||
) => Promise<Awaited<ReturnType<T[P]>>>; | ||
}; | ||
type ESingleCall<T> = T extends Function | ||
? ((...args: Parameters<T>) => Promise<Unpromise<ReturnType<T>>>) & | ||
? ((...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>) & | ||
ESingleMethod<Required<T>> | ||
: ESingleMethod<Required<T>>; | ||
type ESingleGet<T> = { | ||
readonly [P in keyof T]: Promise<Unpromise<T[P]>>; | ||
readonly [P in keyof T]: Promise<Awaited<T[P]>>; | ||
}; | ||
@@ -121,3 +130,3 @@ | ||
interface ESendOnly { | ||
<T>(x: T): ESingleCallOnly<Unpromise<T>>; | ||
<T>(x: T): ESingleCallOnly<Awaited<T>>; | ||
} | ||
@@ -135,3 +144,9 @@ | ||
*/ | ||
<T>(x: T): ESingleCall<Unpromise<T>>; | ||
<T>(x: T): ESingleCall< | ||
T extends Remotable<infer U> | ||
? FunctionOnly<U> | ||
: Awaited<T> extends Remotable<infer U> | ||
? FunctionOnly<U> | ||
: Awaited<T> | ||
>; | ||
@@ -147,3 +162,11 @@ /** | ||
*/ | ||
readonly get: <T>(x: T) => ESingleGet<Unpromise<T>>; | ||
readonly get: <T>( | ||
x: T, | ||
) => ESingleGet< | ||
T extends Remotable<infer U> | ||
? DataOnly<U> | ||
: Awaited<T> extends Remotable<infer U> | ||
? DataOnly<U> | ||
: Awaited<T> | ||
>; | ||
@@ -154,3 +177,3 @@ /** | ||
*/ | ||
readonly resolve: <T>(x: T) => Promise<Unpromise<T>>; | ||
readonly resolve: <T>(x: T) => Promise<Awaited<T>>; | ||
@@ -163,3 +186,3 @@ /** | ||
x: T, | ||
onfulfilled?: (value: Unpromise<T>) => ERef<U>, | ||
onfulfilled?: (value: Awaited<T>) => ERef<U>, | ||
onrejected?: (reason: any) => ERef<U>, | ||
@@ -166,0 +189,0 @@ ) => Promise<U>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
69773
1049