UNPKG

1.42 kBTypeScriptView Raw
1/**
2 * Copyright 2017 Google Inc. All Rights Reserved.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 */
13export interface Endpoint {
14 postMessage(message: any, transfer?: any[]): void;
15 addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
16 removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
17}
18export declare type Proxy = Function;
19export declare type Exposable = Function | Object;
20export interface TransferHandler {
21 canHandle: (obj: {}) => Boolean;
22 serialize: (obj: {}) => {};
23 deserialize: (obj: {}) => {};
24}
25export declare const transferHandlers: Map<string, TransferHandler>;
26export declare function proxy(endpoint: Endpoint | Window, target?: any): Proxy;
27export declare function proxyValue<T>(obj: T): T;
28export declare function expose(rootObj: Exposable, endpoint: Endpoint | Window): void;