@agoric/eventual-send
Advanced tools
Comparing version 0.14.2-dev-0e4bf0e.0 to 0.14.2-dev-0f87afd.0
{ | ||
"name": "@agoric/eventual-send", | ||
"version": "0.14.2-dev-0e4bf0e.0+0e4bf0e", | ||
"version": "0.14.2-dev-0f87afd.0+0f87afd", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -29,4 +29,4 @@ "type": "module", | ||
"devDependencies": { | ||
"@endo/lockdown": "^0.1.7", | ||
"@endo/ses-ava": "^0.2.19", | ||
"@endo/lockdown": "^0.1.8", | ||
"@endo/ses-ava": "^0.2.20", | ||
"ava": "^3.12.1", | ||
@@ -58,3 +58,3 @@ "c8": "^7.7.2" | ||
}, | ||
"gitHead": "0e4bf0ee2556282035de1694770c53b1a3d9a26c" | ||
"gitHead": "0f87afd3bef437ae9ec348175f4bcebe01ea2fa7" | ||
} |
@@ -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