Skip to content

Commit 6496225

Browse files
author
Kerrick Long
committed
Commit to actually checking in distributable files
1 parent 6cfdf69 commit 6496225

20 files changed

+464
-3
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Compiled JavaScript
2-
dist
3-
41
# Logs
52
logs
63
*.log

dist/amd/talker.min.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/common_js/talker.min.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/constants.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export declare const TALKER_CONTENT_TYPE: string;
2+
export declare const TALKER_ERR_MSG_TIMEOUT: string;

dist/constants.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/constants.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { ManipulablePromise } from "./utils/manipulable-promise";
2+
import { IncomingMessage, OutgoingMessage, Stringifyable } from "./message";
3+
/**
4+
* Talker
5+
* Opens a communication line between this window and a remote window via postMessage.
6+
*/
7+
declare class Talker {
8+
private readonly remoteWindow;
9+
private readonly remoteOrigin;
10+
private readonly localWindow;
11+
timeout: number;
12+
/**
13+
* @property onMessage - Will be called with every non-handshake, non-response message from the remote window
14+
*/
15+
onMessage?: (message: IncomingMessage) => void;
16+
private readonly handshake;
17+
private handshaken;
18+
private latestId;
19+
private readonly queue;
20+
private readonly sent;
21+
/**
22+
* @param remoteWindow - The remote `window` object to post/receive messages to/from
23+
* @param remoteOrigin - The protocol, host, and port you expect the remoteWindow to be
24+
* @param localWindow - The local `window` object
25+
*/
26+
constructor(remoteWindow: Window, remoteOrigin: string, localWindow?: Window);
27+
/**
28+
* @param namespace - The namespace the message is in
29+
* @param data - The data to send
30+
* @param responseToId - If this is a response to a previous message, its ID.
31+
*/
32+
send(namespace: string, data: Stringifyable, responseToId?: number | null): ManipulablePromise<IncomingMessage | Error>;
33+
/**
34+
* This is not marked private because other Talker-related classes need access to it,
35+
* but your application code should probably avoid calling this method.
36+
*/
37+
nextId(): number;
38+
private receiveMessage;
39+
/**
40+
* Determines whether it is safe and appropriate to parse a postMessage messageEvent
41+
* @param source - "source" property from the postMessage event
42+
* @param origin - Protocol, host, and port
43+
* @param type - Internet Media Type
44+
*/
45+
private isSafeMessage;
46+
private handleHandshake;
47+
private handleMessage;
48+
/**
49+
* @param id - Message ID of the waiting promise
50+
* @param message - Message that is responding to that ID
51+
*/
52+
private respondToMessage;
53+
/**
54+
* Send a non-response message to awaiting hooks/callbacks
55+
* @param message - Message that arrived
56+
*/
57+
private broadcastMessage;
58+
/**
59+
* Send a handshake message to the remote window
60+
* @param confirmation - Is this a confirmation handshake?
61+
*/
62+
private sendHandshake;
63+
/**
64+
* Wrapper around window.postMessage to only send if we have the necessary objects
65+
*/
66+
private postMessage;
67+
/**
68+
* Flushes the internal queue of outgoing messages, sending each one.
69+
* Does nothing if Talker has not handshaken with the remote.
70+
*/
71+
private flushQueue;
72+
}
73+
export { IncomingMessage, OutgoingMessage };
74+
export default Talker;

dist/index.js

+181
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/message.d.ts

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Promise } from "es6-promise";
2+
import Talker from "./index";
3+
declare abstract class Message {
4+
protected readonly talker: Talker;
5+
readonly namespace: string;
6+
readonly data: Stringifyable;
7+
readonly responseToId: number | null;
8+
protected readonly type: string;
9+
constructor(talker: Talker, namespace: string, data: Stringifyable, responseToId?: number | null);
10+
}
11+
export interface JSONableMessage {
12+
readonly namespace?: string;
13+
readonly data?: Stringifyable;
14+
readonly id?: number;
15+
readonly responseToId?: number;
16+
readonly type: string;
17+
readonly handshake?: boolean;
18+
readonly handshakeConfirmation?: boolean;
19+
}
20+
export interface Stringifyable {
21+
[index: string]: string | number | Stringifyable | Stringifyable[] | boolean | null | undefined;
22+
}
23+
export declare class OutgoingMessage extends Message {
24+
protected readonly talker: Talker;
25+
readonly namespace: string;
26+
readonly data: Stringifyable;
27+
readonly responseToId: number | null;
28+
readonly id: number;
29+
/**
30+
* @param talker
31+
* @param namespace
32+
* @param data
33+
* @param responseToId - If this is a response to a previous message, its ID.
34+
*/
35+
constructor(talker: Talker, namespace: string, data: Stringifyable, responseToId?: number | null);
36+
toJSON(): JSONableMessage;
37+
}
38+
export declare class IncomingMessage extends Message {
39+
protected readonly talker: Talker;
40+
readonly namespace: string;
41+
readonly data: Stringifyable;
42+
readonly id: number;
43+
constructor(talker: Talker, namespace?: string, data?: Stringifyable, id?: number);
44+
/**
45+
* Please note that this response message will use the same timeout as Talker#send.
46+
*/
47+
respond(data: Stringifyable): Promise<IncomingMessage | Error>;
48+
}
49+
export {};

0 commit comments

Comments
 (0)