/** * Copyright 2019 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as Protocol from "./protocol.js"; export { Endpoint } from "./protocol.js"; export declare const proxyMarker: unique symbol; declare type Promisify = T extends { [proxyMarker]: boolean; } ? Promise> : T extends Promise ? T : T extends (...args: infer R1) => infer R2 ? (...args: R1) => Promisify : Promise; export declare type Remote = (T extends (...args: infer R1) => infer R2 ? (...args: R1) => Promisify : { [K in keyof T]: Promisify; }) & (T extends { new (...args: infer R1): infer R2; } ? { new (...args: R1): Promise>; } : unknown); export interface TransferHandler { canHandle(obj: any): boolean; serialize(obj: any): [any, any[]]; deserialize(obj: any): any; } export declare const transferHandlers: Map; export declare function expose(obj: any, ep?: Protocol.Endpoint): void; export declare function wrap(ep: Protocol.Endpoint): Remote; export declare function transfer(obj: any, transfers: any[]): any; export declare function proxy(obj: T): T & { [proxyMarker]: true; }; export declare function windowEndpoint(w: Window, context?: Window): Protocol.Endpoint;