Skip to content

Commit

Permalink
comments; docs gen added; refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
serglider committed Feb 26, 2021
1 parent 7fd2cda commit 98e476a
Show file tree
Hide file tree
Showing 22 changed files with 4,345 additions and 109 deletions.
6 changes: 6 additions & 0 deletions declarations/defaults.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare const _default: {
passphrase: string;
isParent: boolean;
targetOrigin: string;
};
export default _default;
17 changes: 10 additions & 7 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DataHandler, CrossOriginCourierOptions } from './types';
declare type CrossOriginCourierInstance = InstanceType<typeof CrossOriginCourier>;
export default class CrossOriginCourier {
private readonly options;
private isConnected;
Expand All @@ -7,35 +8,37 @@ export default class CrossOriginCourier {
private handler;
constructor(options: Partial<CrossOriginCourierOptions>);
/**
* todo
* Prepares a connection channel and returns a Promise which resolves once the connection established.
* @param dataHandler
* @public
*/
connect(dataHandler: DataHandler): Promise<this>;
connect(dataHandler: DataHandler): Promise<CrossOriginCourierInstance>;
/**
* todo
* Sends data to the counterparty given the connection is established.
* If not, it issues a warning message in the console.
* @param data
* @public
*/
send(data: any): void;
/**
* todo
* Prepares a connection channel employing MessageChannel and issues a ping to the parent context.
* @private
*/
initChild(): void;
/**
* todo
* Prepares a connection channel by setting a listener to a ping from the child context.
* @private
*/
initParent(): void;
/**
* todo
* On ping from the parent context, sets a message listener and resolves the connection promise.
* @private
*/
onPingFromParent({ data }: MessageEvent): void;
/**
* todo
* On ping from the child context, sets a message listener and resolves the connection promise.
* @private
*/
onPingFromChild({ data, ports }: MessageEvent): void;
}
export {};
5 changes: 3 additions & 2 deletions declarations/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export declare type DataHandler = (data: any) => void;
export declare type EventHandler = (event: MessageEvent) => void;
declare type TargetOrigin = '*' | `${'https' | 'http'}://${string}.${string}`;
export declare type CrossOriginCourierOptions = {
passphrase: string;
targetOrigin: string;
targetOrigin: TargetOrigin;
isParent: boolean;
};
export declare type Foobar = (event: MessageEvent) => void;
export {};
Loading

0 comments on commit 98e476a

Please sign in to comment.