post-me
Version:
Use web Workers and other Windows through a simple Promise API
43 lines (42 loc) • 1.05 kB
TypeScript
export declare const MARKER = "@post-me";
export declare type IdType = number;
export declare type KeyType = string;
/**
* The options that can be passed when calling a method on the other context with RemoteHandle.customCall()
*
* @public
*
*/
export declare type CallOptions = {
transfer?: Transferable[];
};
/**
* The options that can be passed when emitting an event to the other context with LocalHandle.emit()
*
* @public
*
*/
export declare type EmitOptions = {
transfer?: Transferable[];
};
/**
* @internal
*/
export declare type MethodsType = Record<KeyType, Callable<any[], ValueOrPromise<any>>>;
/**
* @internal
*/
export declare type EventsType = Record<KeyType, any>;
/**
* @internal
*/
export declare type Callable<A extends Array<any>, R> = (...args: A) => R;
/**
* @internal
*/
export declare type ValueOrPromise<T> = T | Promise<T>;
/**
* @internal
*/
export declare type InnerType<T extends ValueOrPromise<any>> = T extends Promise<infer U> ? U : T;
export declare function createUniqueIdFn(): () => number;