-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
♻️ Rewrite in TypeScript
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version you desire here | ||
- image: circleci/node:10.14.0 | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
# - image: circleci/mongo:3.4.4 | ||
|
||
working_directory: ~/repo | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "yarn.lock" }} | ||
|
||
# run tests! | ||
- run: yarn test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v10.14.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"trailingComma": "es5" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
talker.js | ||
========= | ||
# talker.js | ||
|
||
A tiny (<4kB minified, <1kB min+gzip), promise-based library for cross-origin communication between frames and windows. | ||
A small (<13kB minified, <6kB min+gzip), promise-based library for cross-origin communication between frames and windows. | ||
|
||
Documentation | ||
------------- | ||
## Documentation | ||
|
||
Please see [drive.secondstreet.com/introducing-talker](http://drive.secondstreet.com/introducing-talker/) for instructions and examples for using Talker.js in your own projects. | ||
|
||
Building | ||
-------- | ||
## Building | ||
|
||
``` | ||
npm install -g grunt-cli | ||
npm install | ||
grunt | ||
yarn install | ||
yarn run build | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,8 @@ | |
"author": "Second Street <[email protected]>", | ||
"description": "A tiny, promise-based library for cross-origin communication between frames and windows.", | ||
"main": "./dist/talker.min.js", | ||
"moduleType": [ | ||
"globals" | ||
], | ||
"keywords": [ | ||
"iframe", | ||
"postMessage", | ||
"cross-domain", | ||
"cross-origin", | ||
"promise" | ||
], | ||
"moduleType": ["globals"], | ||
"keywords": ["iframe", "postMessage", "cross-domain", "cross-origin", "promise"], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
] | ||
"ignore": ["**/.*", "node_modules", "bower_components", "test", "tests"] | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export declare const TALKER_CONTENT_TYPE: string; | ||
export declare const TALKER_ERR_MSG_TIMEOUT: string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { ManipulablePromise } from "./utils/manipulable-promise"; | ||
import { IncomingMessage, OutgoingMessage, Stringifyable } from "./message"; | ||
/** | ||
* Talker | ||
* Opens a communication line between this window and a remote window via postMessage. | ||
*/ | ||
declare class Talker { | ||
private readonly remoteWindow; | ||
private readonly remoteOrigin; | ||
private readonly localWindow; | ||
timeout: number; | ||
/** | ||
* @property onMessage - Will be called with every non-handshake, non-response message from the remote window | ||
*/ | ||
onMessage?: (message: IncomingMessage) => void; | ||
private readonly handshake; | ||
private handshaken; | ||
private latestId; | ||
private readonly queue; | ||
private readonly sent; | ||
/** | ||
* @param remoteWindow - The remote `window` object to post/receive messages to/from | ||
* @param remoteOrigin - The protocol, host, and port you expect the remoteWindow to be | ||
* @param localWindow - The local `window` object | ||
*/ | ||
constructor(remoteWindow: Window, remoteOrigin: string, localWindow?: Window); | ||
/** | ||
* @param namespace - The namespace the message is in | ||
* @param data - The data to send | ||
* @param responseToId - If this is a response to a previous message, its ID. | ||
*/ | ||
send(namespace: string, data: Stringifyable, responseToId?: number | null): ManipulablePromise<IncomingMessage | Error>; | ||
/** | ||
* This is not marked private because other Talker-related classes need access to it, | ||
* but your application code should probably avoid calling this method. | ||
*/ | ||
nextId(): number; | ||
private receiveMessage; | ||
/** | ||
* Determines whether it is safe and appropriate to parse a postMessage messageEvent | ||
* @param source - "source" property from the postMessage event | ||
* @param origin - Protocol, host, and port | ||
* @param type - Internet Media Type | ||
*/ | ||
private isSafeMessage; | ||
private handleHandshake; | ||
private handleMessage; | ||
/** | ||
* @param id - Message ID of the waiting promise | ||
* @param message - Message that is responding to that ID | ||
*/ | ||
private respondToMessage; | ||
/** | ||
* Send a non-response message to awaiting hooks/callbacks | ||
* @param message - Message that arrived | ||
*/ | ||
private broadcastMessage; | ||
/** | ||
* Send a handshake message to the remote window | ||
* @param confirmation - Is this a confirmation handshake? | ||
*/ | ||
private sendHandshake; | ||
/** | ||
* Wrapper around window.postMessage to only send if we have the necessary objects | ||
*/ | ||
private postMessage; | ||
/** | ||
* Flushes the internal queue of outgoing messages, sending each one. | ||
* Does nothing if Talker has not handshaken with the remote. | ||
*/ | ||
private flushQueue; | ||
} | ||
export { IncomingMessage, OutgoingMessage }; | ||
export default Talker; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.