From c006f023b074cb6c00ab94b9bc56596a522ccf89 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Thu, 17 Jul 2014 23:50:59 -0500 Subject: [PATCH] Redo build pipeline to more cleanly minify, add AMD/CJS modules. --- Gruntfile.js | 43 +++++++++++++- README.md | 2 +- bower.json | 2 +- dist/amd/talker.min.js | 6 ++ dist/common_js/talker.min.js | 6 ++ dist/named_amd/talker.min.js | 6 ++ dist/talker.min.js | 11 ++-- dist/talker.min.js.map | 1 - package.json | 2 +- src/talker.js | 112 ++++++++++++++++++++++++++++++----- 10 files changed, 163 insertions(+), 28 deletions(-) create mode 100644 dist/amd/talker.min.js create mode 100644 dist/common_js/talker.min.js create mode 100644 dist/named_amd/talker.min.js delete mode 100644 dist/talker.min.js.map diff --git a/Gruntfile.js b/Gruntfile.js index 7b916fe..86ab587 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,16 +3,53 @@ module.exports = function(grunt) { uglify: { options: { report: 'gzip', - sourceMap: true, preserveComments: 'some', - wrap: 'Talker' + compress: { + pure_getters: true + } }, - dist: { + globals: { + options: { + banner: '(function(){', + footer: '\nwindow.Talker=Talker})()' + }, files: { 'dist/talker.min.js': [ 'src/talker.js' ] } + }, + amd: { + options: { + banner: 'define([],function(){', + footer: '\nreturn Talker})' + }, + files: { + 'dist/amd/talker.min.js': [ + 'src/talker.js' + ] + } + }, + named_amd: { + options: { + banner: 'define("talker",[],function(){', + footer: '\nreturn Talker})' + }, + files: { + 'dist/named_amd/talker.min.js': [ + 'src/talker.js' + ] + } + }, + common_js: { + options: { + footer: '\nmodule.exports=Talker' + }, + files: { + 'dist/common_js/talker.min.js': [ + 'src/talker.js' + ] + } } } }); diff --git a/README.md b/README.md index 85d0f73..f22a9b2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ talker.js ========= -A tiny (under 4kB), promise-based library for cross-origin communication between frames and windows. +A tiny (<4kB minified, <1kB min+gzip), promise-based library for cross-origin communication between frames and windows. Building -------- diff --git a/bower.json b/bower.json index c535569..787acef 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "talker.js", - "version": "1.0.0", + "version": "1.0.1", "homepage": "https://github.com/secondstreet/talker.js", "author": "Second Street ", "description": "A tiny, promise-based library for cross-origin communication between frames and windows.", diff --git a/dist/amd/talker.min.js b/dist/amd/talker.min.js new file mode 100644 index 0000000..331616c --- /dev/null +++ b/dist/amd/talker.min.js @@ -0,0 +1,6 @@ +define([],function(){/*! + * © 2014 Second Street, MIT License + * Talker.js 1.0.1 + */ +var TALKER_TYPE="application/x-talkerjs-v1+json",TALKER_ERR_TIMEOUT="timeout",pinkySwearPromise=function(){function a(a){return"function"==typeof a}function b(a){return"object"==typeof a}function c(a){"undefined"!=typeof setImmediate?setImmediate(a):"undefined"!=typeof process&&process.nextTick?process.nextTick(a):setTimeout(a,0)}var d;return function e(){var f,g=[],h=[],i=function(a,b){return null==f&&null!=a&&(f=a,g=b,h.length&&c(function(){for(var a=0;h.length>a;a++)h[a]()})),f};return i.then=function(i,j){var k=e(),l=function(){function c(e){var f,g=0;try{if(e&&(b(e)||a(e))&&a(f=e.then)){if(e===k)throw new TypeError;f.call(e,function(){g++||c.apply(d,arguments)},function(a){g++||k(!1,[a])})}else k(!0,arguments)}catch(h){g++||k(!1,[h])}}try{var e=f?i:j;a(e)?c(e.apply(d,g||[])):k(f,g)}catch(h){k(!1,[h])}};return null!=f?c(l):h.push(l),k},i}}(),objectCreate=function(a){function b(){}return b.prototype=a,new b},Talker=function(a,b){this.remoteWindow=a,this.remoteOrigin=b,this.timeout=3e3,this.handshaken=!1,this.handshake=pinkySwearPromise(),this._id=0,this._queue=[],this._sent={};var c=this;return window.addEventListener("message",function(a){c._receiveMessage(a)},!1),this._sendHandshake(),this};Talker.prototype.send=function(a,b,c){var d=new Talker.OutgoingMessage(this,a,b,c),e=pinkySwearPromise();return this._sent[d.id]=e,this._queue.push(d),this._flushQueue(),setTimeout(function(){e(!1,[new Error(TALKER_ERR_TIMEOUT)])},this.timeout),e},Talker.prototype._receiveMessage=function(a){var b,c;try{b=JSON.parse(a.data)}catch(d){b={}}return this._isSafeMessage(a.source,a.origin,b.type)?(c=b.handshake||b.handshakeConfirmation,c?this._handleHandshake(b):this._handleMessage(b)):!1},Talker.prototype._isSafeMessage=function(a,b,c){var d,e,f;return d=a===this.remoteWindow,e="*"===this.remoteOrigin||b===this.remoteOrigin,f=c===TALKER_TYPE,d&&e&&f},Talker.prototype._handleHandshake=function(a){a.handshake&&this._sendHandshake(this.handshaken),this.handshaken=!0,this.handshake(!0,[this.handshaken]),this._flushQueue()},Talker.prototype._handleMessage=function(a){var b=new Talker.IncomingMessage(this,a.namespace,a.data,a.id),c=a.responseToId;return c?this._respondToMessage(c,b):this._broadcastMessage(b)},Talker.prototype._respondToMessage=function(a,b){this._sent[a]&&(this._sent[a](!0,[b]),delete this._sent[a])},Talker.prototype._broadcastMessage=function(a){this.onMessage&&this.onMessage.call(this,a)},Talker.prototype._sendHandshake=function(a){var b={type:TALKER_TYPE},c=a?"handshakeConfirmation":"handshake";b[c]=!0,this._postMessage(b)},Talker.prototype._nextId=function(){return this._id+=1},Talker.prototype._postMessage=function(a){this.remoteWindow&&this.remoteOrigin&&this.remoteWindow.postMessage(JSON.stringify(a),this.remoteOrigin)},Talker.prototype._flushQueue=function(){if(this.handshaken){var a=this._queue.shift();if(!a)return this._queue;if(this._postMessage(a),this._queue.length>0)return this._flushQueue()}return this._queue},Talker.Message=function(a,b,c){return this.talker=a,this.namespace=b,this.data=c,this.type=TALKER_TYPE,this},Talker.OutgoingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.responseToId=d||null,this.id=this.talker._nextId()},Talker.OutgoingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.OutgoingMessage.prototype.constructor=Talker.Message,Talker.OutgoingMessage.prototype.toJSON=function(){return{id:this.id,responseToId:this.responseToId,namespace:this.namespace,data:this.data,type:this.type}},Talker.IncomingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.id=d},Talker.IncomingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.IncomingMessage.prototype.constructor=Talker.Message,Talker.IncomingMessage.prototype.respond=function(a){return this.talker.send(null,a,this.id)}; +return Talker}) \ No newline at end of file diff --git a/dist/common_js/talker.min.js b/dist/common_js/talker.min.js new file mode 100644 index 0000000..6976684 --- /dev/null +++ b/dist/common_js/talker.min.js @@ -0,0 +1,6 @@ +/*! + * © 2014 Second Street, MIT License + * Talker.js 1.0.1 + */ +var TALKER_TYPE="application/x-talkerjs-v1+json",TALKER_ERR_TIMEOUT="timeout",pinkySwearPromise=function(){function a(a){return"function"==typeof a}function b(a){return"object"==typeof a}function c(a){"undefined"!=typeof setImmediate?setImmediate(a):"undefined"!=typeof process&&process.nextTick?process.nextTick(a):setTimeout(a,0)}var d;return function e(){var f,g=[],h=[],i=function(a,b){return null==f&&null!=a&&(f=a,g=b,h.length&&c(function(){for(var a=0;h.length>a;a++)h[a]()})),f};return i.then=function(i,j){var k=e(),l=function(){function c(e){var f,g=0;try{if(e&&(b(e)||a(e))&&a(f=e.then)){if(e===k)throw new TypeError;f.call(e,function(){g++||c.apply(d,arguments)},function(a){g++||k(!1,[a])})}else k(!0,arguments)}catch(h){g++||k(!1,[h])}}try{var e=f?i:j;a(e)?c(e.apply(d,g||[])):k(f,g)}catch(h){k(!1,[h])}};return null!=f?c(l):h.push(l),k},i}}(),objectCreate=function(a){function b(){}return b.prototype=a,new b},Talker=function(a,b){this.remoteWindow=a,this.remoteOrigin=b,this.timeout=3e3,this.handshaken=!1,this.handshake=pinkySwearPromise(),this._id=0,this._queue=[],this._sent={};var c=this;return window.addEventListener("message",function(a){c._receiveMessage(a)},!1),this._sendHandshake(),this};Talker.prototype.send=function(a,b,c){var d=new Talker.OutgoingMessage(this,a,b,c),e=pinkySwearPromise();return this._sent[d.id]=e,this._queue.push(d),this._flushQueue(),setTimeout(function(){e(!1,[new Error(TALKER_ERR_TIMEOUT)])},this.timeout),e},Talker.prototype._receiveMessage=function(a){var b,c;try{b=JSON.parse(a.data)}catch(d){b={}}return this._isSafeMessage(a.source,a.origin,b.type)?(c=b.handshake||b.handshakeConfirmation,c?this._handleHandshake(b):this._handleMessage(b)):!1},Talker.prototype._isSafeMessage=function(a,b,c){var d,e,f;return d=a===this.remoteWindow,e="*"===this.remoteOrigin||b===this.remoteOrigin,f=c===TALKER_TYPE,d&&e&&f},Talker.prototype._handleHandshake=function(a){a.handshake&&this._sendHandshake(this.handshaken),this.handshaken=!0,this.handshake(!0,[this.handshaken]),this._flushQueue()},Talker.prototype._handleMessage=function(a){var b=new Talker.IncomingMessage(this,a.namespace,a.data,a.id),c=a.responseToId;return c?this._respondToMessage(c,b):this._broadcastMessage(b)},Talker.prototype._respondToMessage=function(a,b){this._sent[a]&&(this._sent[a](!0,[b]),delete this._sent[a])},Talker.prototype._broadcastMessage=function(a){this.onMessage&&this.onMessage.call(this,a)},Talker.prototype._sendHandshake=function(a){var b={type:TALKER_TYPE},c=a?"handshakeConfirmation":"handshake";b[c]=!0,this._postMessage(b)},Talker.prototype._nextId=function(){return this._id+=1},Talker.prototype._postMessage=function(a){this.remoteWindow&&this.remoteOrigin&&this.remoteWindow.postMessage(JSON.stringify(a),this.remoteOrigin)},Talker.prototype._flushQueue=function(){if(this.handshaken){var a=this._queue.shift();if(!a)return this._queue;if(this._postMessage(a),this._queue.length>0)return this._flushQueue()}return this._queue},Talker.Message=function(a,b,c){return this.talker=a,this.namespace=b,this.data=c,this.type=TALKER_TYPE,this},Talker.OutgoingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.responseToId=d||null,this.id=this.talker._nextId()},Talker.OutgoingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.OutgoingMessage.prototype.constructor=Talker.Message,Talker.OutgoingMessage.prototype.toJSON=function(){return{id:this.id,responseToId:this.responseToId,namespace:this.namespace,data:this.data,type:this.type}},Talker.IncomingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.id=d},Talker.IncomingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.IncomingMessage.prototype.constructor=Talker.Message,Talker.IncomingMessage.prototype.respond=function(a){return this.talker.send(null,a,this.id)}; +module.exports=Talker \ No newline at end of file diff --git a/dist/named_amd/talker.min.js b/dist/named_amd/talker.min.js new file mode 100644 index 0000000..eeb21f8 --- /dev/null +++ b/dist/named_amd/talker.min.js @@ -0,0 +1,6 @@ +define("talker",[],function(){/*! + * © 2014 Second Street, MIT License + * Talker.js 1.0.1 + */ +var TALKER_TYPE="application/x-talkerjs-v1+json",TALKER_ERR_TIMEOUT="timeout",pinkySwearPromise=function(){function a(a){return"function"==typeof a}function b(a){return"object"==typeof a}function c(a){"undefined"!=typeof setImmediate?setImmediate(a):"undefined"!=typeof process&&process.nextTick?process.nextTick(a):setTimeout(a,0)}var d;return function e(){var f,g=[],h=[],i=function(a,b){return null==f&&null!=a&&(f=a,g=b,h.length&&c(function(){for(var a=0;h.length>a;a++)h[a]()})),f};return i.then=function(i,j){var k=e(),l=function(){function c(e){var f,g=0;try{if(e&&(b(e)||a(e))&&a(f=e.then)){if(e===k)throw new TypeError;f.call(e,function(){g++||c.apply(d,arguments)},function(a){g++||k(!1,[a])})}else k(!0,arguments)}catch(h){g++||k(!1,[h])}}try{var e=f?i:j;a(e)?c(e.apply(d,g||[])):k(f,g)}catch(h){k(!1,[h])}};return null!=f?c(l):h.push(l),k},i}}(),objectCreate=function(a){function b(){}return b.prototype=a,new b},Talker=function(a,b){this.remoteWindow=a,this.remoteOrigin=b,this.timeout=3e3,this.handshaken=!1,this.handshake=pinkySwearPromise(),this._id=0,this._queue=[],this._sent={};var c=this;return window.addEventListener("message",function(a){c._receiveMessage(a)},!1),this._sendHandshake(),this};Talker.prototype.send=function(a,b,c){var d=new Talker.OutgoingMessage(this,a,b,c),e=pinkySwearPromise();return this._sent[d.id]=e,this._queue.push(d),this._flushQueue(),setTimeout(function(){e(!1,[new Error(TALKER_ERR_TIMEOUT)])},this.timeout),e},Talker.prototype._receiveMessage=function(a){var b,c;try{b=JSON.parse(a.data)}catch(d){b={}}return this._isSafeMessage(a.source,a.origin,b.type)?(c=b.handshake||b.handshakeConfirmation,c?this._handleHandshake(b):this._handleMessage(b)):!1},Talker.prototype._isSafeMessage=function(a,b,c){var d,e,f;return d=a===this.remoteWindow,e="*"===this.remoteOrigin||b===this.remoteOrigin,f=c===TALKER_TYPE,d&&e&&f},Talker.prototype._handleHandshake=function(a){a.handshake&&this._sendHandshake(this.handshaken),this.handshaken=!0,this.handshake(!0,[this.handshaken]),this._flushQueue()},Talker.prototype._handleMessage=function(a){var b=new Talker.IncomingMessage(this,a.namespace,a.data,a.id),c=a.responseToId;return c?this._respondToMessage(c,b):this._broadcastMessage(b)},Talker.prototype._respondToMessage=function(a,b){this._sent[a]&&(this._sent[a](!0,[b]),delete this._sent[a])},Talker.prototype._broadcastMessage=function(a){this.onMessage&&this.onMessage.call(this,a)},Talker.prototype._sendHandshake=function(a){var b={type:TALKER_TYPE},c=a?"handshakeConfirmation":"handshake";b[c]=!0,this._postMessage(b)},Talker.prototype._nextId=function(){return this._id+=1},Talker.prototype._postMessage=function(a){this.remoteWindow&&this.remoteOrigin&&this.remoteWindow.postMessage(JSON.stringify(a),this.remoteOrigin)},Talker.prototype._flushQueue=function(){if(this.handshaken){var a=this._queue.shift();if(!a)return this._queue;if(this._postMessage(a),this._queue.length>0)return this._flushQueue()}return this._queue},Talker.Message=function(a,b,c){return this.talker=a,this.namespace=b,this.data=c,this.type=TALKER_TYPE,this},Talker.OutgoingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.responseToId=d||null,this.id=this.talker._nextId()},Talker.OutgoingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.OutgoingMessage.prototype.constructor=Talker.Message,Talker.OutgoingMessage.prototype.toJSON=function(){return{id:this.id,responseToId:this.responseToId,namespace:this.namespace,data:this.data,type:this.type}},Talker.IncomingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.id=d},Talker.IncomingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.IncomingMessage.prototype.constructor=Talker.Message,Talker.IncomingMessage.prototype.respond=function(a){return this.talker.send(null,a,this.id)}; +return Talker}) \ No newline at end of file diff --git a/dist/talker.min.js b/dist/talker.min.js index d84627c..da6c9ba 100644 --- a/dist/talker.min.js +++ b/dist/talker.min.js @@ -1,7 +1,6 @@ -!function(a,b){b.Talker=a;/*! - * Talker.js 1.0.0 - * Copyright 2014 Second Street - * MIT License +(function(){/*! + * © 2014 Second Street, MIT License + * Talker.js 1.0.1 */ -var c="application/x-talkerjs-v1+json",d="timeout",e=f,f={};!function(a){function b(a){return"function"==typeof a}function c(a){"undefined"!=typeof setImmediate?setImmediate(a):"undefined"!=typeof process&&process.nextTick?process.nextTick(a):setTimeout(a,0)}a[0][a[1]]=function d(){function a(a,b){return null==e&&null!=a&&(e=a,f=b,g.length&&c(function(){for(var a=0;a0)return this._flushQueue()}return this._queue},Talker.Message=function(a,b,d){return this.talker=a,this.namespace=b,this.data=d,this.type=c,this},Talker.OutgoingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.responseToId=d||null,this.id=this.talker._nextId()},Talker.OutgoingMessage.prototype=h(Talker.Message.prototype),Talker.OutgoingMessage.prototype.constructor=Talker.Message,Talker.OutgoingMessage.prototype.toJSON=function(){return{id:this.id,responseToId:this.responseToId,namespace:this.namespace,data:this.data,type:this.type}},Talker.IncomingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.id=d},Talker.IncomingMessage.prototype=h(Talker.Message.prototype),Talker.IncomingMessage.prototype.constructor=Talker.Message,Talker.IncomingMessage.prototype.respond=function(a){return this.talker.send(null,a,this.id)}}({},function(){return this}()); -//# sourceMappingURL=talker.min.js.map \ No newline at end of file +var TALKER_TYPE="application/x-talkerjs-v1+json",TALKER_ERR_TIMEOUT="timeout",pinkySwearPromise=function(){function a(a){return"function"==typeof a}function b(a){return"object"==typeof a}function c(a){"undefined"!=typeof setImmediate?setImmediate(a):"undefined"!=typeof process&&process.nextTick?process.nextTick(a):setTimeout(a,0)}var d;return function e(){var f,g=[],h=[],i=function(a,b){return null==f&&null!=a&&(f=a,g=b,h.length&&c(function(){for(var a=0;h.length>a;a++)h[a]()})),f};return i.then=function(i,j){var k=e(),l=function(){function c(e){var f,g=0;try{if(e&&(b(e)||a(e))&&a(f=e.then)){if(e===k)throw new TypeError;f.call(e,function(){g++||c.apply(d,arguments)},function(a){g++||k(!1,[a])})}else k(!0,arguments)}catch(h){g++||k(!1,[h])}}try{var e=f?i:j;a(e)?c(e.apply(d,g||[])):k(f,g)}catch(h){k(!1,[h])}};return null!=f?c(l):h.push(l),k},i}}(),objectCreate=function(a){function b(){}return b.prototype=a,new b},Talker=function(a,b){this.remoteWindow=a,this.remoteOrigin=b,this.timeout=3e3,this.handshaken=!1,this.handshake=pinkySwearPromise(),this._id=0,this._queue=[],this._sent={};var c=this;return window.addEventListener("message",function(a){c._receiveMessage(a)},!1),this._sendHandshake(),this};Talker.prototype.send=function(a,b,c){var d=new Talker.OutgoingMessage(this,a,b,c),e=pinkySwearPromise();return this._sent[d.id]=e,this._queue.push(d),this._flushQueue(),setTimeout(function(){e(!1,[new Error(TALKER_ERR_TIMEOUT)])},this.timeout),e},Talker.prototype._receiveMessage=function(a){var b,c;try{b=JSON.parse(a.data)}catch(d){b={}}return this._isSafeMessage(a.source,a.origin,b.type)?(c=b.handshake||b.handshakeConfirmation,c?this._handleHandshake(b):this._handleMessage(b)):!1},Talker.prototype._isSafeMessage=function(a,b,c){var d,e,f;return d=a===this.remoteWindow,e="*"===this.remoteOrigin||b===this.remoteOrigin,f=c===TALKER_TYPE,d&&e&&f},Talker.prototype._handleHandshake=function(a){a.handshake&&this._sendHandshake(this.handshaken),this.handshaken=!0,this.handshake(!0,[this.handshaken]),this._flushQueue()},Talker.prototype._handleMessage=function(a){var b=new Talker.IncomingMessage(this,a.namespace,a.data,a.id),c=a.responseToId;return c?this._respondToMessage(c,b):this._broadcastMessage(b)},Talker.prototype._respondToMessage=function(a,b){this._sent[a]&&(this._sent[a](!0,[b]),delete this._sent[a])},Talker.prototype._broadcastMessage=function(a){this.onMessage&&this.onMessage.call(this,a)},Talker.prototype._sendHandshake=function(a){var b={type:TALKER_TYPE},c=a?"handshakeConfirmation":"handshake";b[c]=!0,this._postMessage(b)},Talker.prototype._nextId=function(){return this._id+=1},Talker.prototype._postMessage=function(a){this.remoteWindow&&this.remoteOrigin&&this.remoteWindow.postMessage(JSON.stringify(a),this.remoteOrigin)},Talker.prototype._flushQueue=function(){if(this.handshaken){var a=this._queue.shift();if(!a)return this._queue;if(this._postMessage(a),this._queue.length>0)return this._flushQueue()}return this._queue},Talker.Message=function(a,b,c){return this.talker=a,this.namespace=b,this.data=c,this.type=TALKER_TYPE,this},Talker.OutgoingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.responseToId=d||null,this.id=this.talker._nextId()},Talker.OutgoingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.OutgoingMessage.prototype.constructor=Talker.Message,Talker.OutgoingMessage.prototype.toJSON=function(){return{id:this.id,responseToId:this.responseToId,namespace:this.namespace,data:this.data,type:this.type}},Talker.IncomingMessage=function(a,b,c,d){Talker.Message.call(this,a,b,c),this.id=d},Talker.IncomingMessage.prototype=objectCreate(Talker.Message.prototype),Talker.IncomingMessage.prototype.constructor=Talker.Message,Talker.IncomingMessage.prototype.respond=function(a){return this.talker.send(null,a,this.id)}; +window.Talker=Talker})() \ No newline at end of file diff --git a/dist/talker.min.js.map b/dist/talker.min.js.map deleted file mode 100644 index a674a95..0000000 --- a/dist/talker.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"talker.min.js","sources":["?","../src/talker.js"],"names":["exports","global","TALKER_TYPE","TALKER_ERR_TIMEOUT","_module","module","c","f","g","h","setImmediate","process","nextTick","setTimeout","m","l","a","k","b","length","then","n","e","d","TypeError","call","apply","arguments","push","window","pinkySwear","objectCreate","proto","ctor","prototype","Talker","remoteWindow","remoteOrigin","this","timeout","handshaken","handshake","_id","_queue","_sent","_this","addEventListener","messageEvent","_receiveMessage","_sendHandshake","send","namespace","data","responseToId","message","OutgoingMessage","promise","id","_flushQueue","Error","object","isHandshake","JSON","parse","_isSafeMessage","source","origin","type","handshakeConfirmation","_handleHandshake","_handleMessage","safeSource","safeOrigin","safeType","rawObject","IncomingMessage","responseId","_respondToMessage","_broadcastMessage","onMessage","confirmation","handshakeType","_postMessage","_nextId","postMessage","stringify","shift","Message","talker","constructor","toJSON","respond"],"mappings":"CAAC,SAASA,EAASC,GAASA,EAAe,OAAID;;;;;ACM/C,GAAIE,GAAc,iCACdC,EAAqB,UAQrBC,EAAUC,EAAQA,MACtB,SAAUC,GAAG,QAASC,GAAEC,GAAG,MAAM,kBAAmBA,GAAE,QAASC,GAAED,GAAG,mBAAoBE,cAAaA,aAAaF,GAAG,mBAAoBG,UAASA,QAAQC,SAASD,QAAQC,SAASJ,GAAGK,WAAWL,EAAE,GAAGF,EAAE,GAAGA,EAAE,IAAI,QAASQ,KAAI,QAASR,GAAES,EAAER,GAA0F,MAAvF,OAAMS,GAAG,MAAMD,IAAIC,EAAED,EAAEE,EAAEV,EAAEW,EAAEC,QAAQV,EAAE,WAAW,IAAI,GAAIO,GAAE,EAAEA,EAAEE,EAAEC,OAAOH,IAAIE,EAAEF,QAAeA,EAAE,GAAIA,GAAEC,KAAKC,IAClH,OADuHZ,GAAEc,KAAK,SAASd,EAAEe,GAAG,QAASC,KAAI,IAAI,GAAIJ,GAAEF,EAAEV,EAAEe,CAAE,IAAGd,EAAEW,GAAG,CAAC,GAAIT,GAAE,SAASO,GAAG,GAAIV,GAAEY,EAAE,CAAE,KAAI,GAAGF,IAAI,gBAAiBA,IAAGT,EAAES,KAAKT,EAAED,EAAEU,EAAEI,MAAM,CAAC,GAAGJ,IAAIO,EAAE,KAAM,IAAIC,UACxflB,GAAEmB,KAAKT,EAAE,WAAWE,KAAKT,EAAEiB,MAAM,OAAOC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AK,KAAME,EAAMd,KAAKmB,SDhTuC,WAAW,MAAOnB"} \ No newline at end of file diff --git a/package.json b/package.json index 834ff8d..ebf6d2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "talker.js", - "version": "1.0.0", + "version": "1.0.1", "description": "A tiny, promise-based library for cross-origin communication between frames and windows.", "main": "src/talker.js", "devDependencies": { diff --git a/src/talker.js b/src/talker.js index f338584..99a478d 100755 --- a/src/talker.js +++ b/src/talker.js @@ -1,7 +1,6 @@ /*! - * Talker.js 1.0.0 - * Copyright 2014 Second Street - * MIT License + * © 2014 Second Street, MIT License + * Talker.js 1.0.1 */ //region Constants var TALKER_TYPE = 'application/x-talkerjs-v1+json'; @@ -9,15 +8,98 @@ var TALKER_ERR_TIMEOUT = 'timeout'; //endregion Constants //region Third-Party Libraries -/** - * PinkySwear.js 2.1 - * License: Public Domain