connect.io
Advanced tools
Comparing version 3.0.0 to 3.0.1
/*! | ||
* chrome-connect v3.0.0 | ||
* chrome-connect v3.0.1 | ||
* https://github.com/Selection-Translator/connect.io | ||
@@ -10,6 +10,69 @@ * Released under the MIT License. | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
function E () { | ||
// Keep this empty so it's easier to inherit from | ||
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) | ||
} | ||
var TinyEmitter = _interopDefault(require('tiny-emitter')); | ||
E.prototype = { | ||
on: function (name, callback, ctx) { | ||
var e = this.e || (this.e = {}); | ||
(e[name] || (e[name] = [])).push({ | ||
fn: callback, | ||
ctx: ctx | ||
}); | ||
return this; | ||
}, | ||
once: function (name, callback, ctx) { | ||
var self = this; | ||
function listener () { | ||
self.off(name, listener); | ||
callback.apply(ctx, arguments); | ||
} | ||
listener._ = callback; | ||
return this.on(name, listener, ctx); | ||
}, | ||
emit: function (name) { | ||
var data = [].slice.call(arguments, 1); | ||
var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); | ||
var i = 0; | ||
var len = evtArr.length; | ||
for (i; i < len; i++) { | ||
evtArr[i].fn.apply(evtArr[i].ctx, data); | ||
} | ||
return this; | ||
}, | ||
off: function (name, callback) { | ||
var e = this.e || (this.e = {}); | ||
var evts = e[name]; | ||
var liveEvents = []; | ||
if (evts && callback) { | ||
for (var i = 0, len = evts.length; i < len; i++) { | ||
if (evts[i].fn !== callback && evts[i].fn._ !== callback) | ||
{ liveEvents.push(evts[i]); } | ||
} | ||
} | ||
// Remove event from queue to prevent memory leak | ||
// Suggested by https://github.com/lazd | ||
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 | ||
(liveEvents.length) | ||
? e[name] = liveEvents | ||
: delete e[name]; | ||
return this; | ||
} | ||
}; | ||
var tinyEmitter = E; | ||
var id$1 = 0; | ||
@@ -135,3 +198,3 @@ | ||
return anonymous; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -233,5 +296,5 @@ /** | ||
var Server = (function (TinyEmitter$$1) { | ||
var Server = (function (TinyEmitter) { | ||
function Server (namespace) { | ||
TinyEmitter$$1.call(this); | ||
TinyEmitter.call(this); | ||
initListener(); | ||
@@ -247,4 +310,4 @@ this.namespace = namespace; | ||
if ( TinyEmitter$$1 ) Server.__proto__ = TinyEmitter$$1; | ||
Server.prototype = Object.create( TinyEmitter$$1 && TinyEmitter$$1.prototype ); | ||
if ( TinyEmitter ) Server.__proto__ = TinyEmitter; | ||
Server.prototype = Object.create( TinyEmitter && TinyEmitter.prototype ); | ||
Server.prototype.constructor = Server; | ||
@@ -264,3 +327,3 @@ | ||
return Server; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -267,0 +330,0 @@ // namespace 到 server 对象的映射表 |
/*! | ||
* chrome-connect v3.0.0 | ||
* chrome-connect v3.0.1 | ||
* https://github.com/Selection-Translator/connect.io | ||
* Released under the MIT License. | ||
*/ | ||
import TinyEmitter from 'tiny-emitter'; | ||
function E () { | ||
// Keep this empty so it's easier to inherit from | ||
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) | ||
} | ||
E.prototype = { | ||
on: function (name, callback, ctx) { | ||
var e = this.e || (this.e = {}); | ||
(e[name] || (e[name] = [])).push({ | ||
fn: callback, | ||
ctx: ctx | ||
}); | ||
return this; | ||
}, | ||
once: function (name, callback, ctx) { | ||
var self = this; | ||
function listener () { | ||
self.off(name, listener); | ||
callback.apply(ctx, arguments); | ||
} | ||
listener._ = callback; | ||
return this.on(name, listener, ctx); | ||
}, | ||
emit: function (name) { | ||
var data = [].slice.call(arguments, 1); | ||
var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); | ||
var i = 0; | ||
var len = evtArr.length; | ||
for (i; i < len; i++) { | ||
evtArr[i].fn.apply(evtArr[i].ctx, data); | ||
} | ||
return this; | ||
}, | ||
off: function (name, callback) { | ||
var e = this.e || (this.e = {}); | ||
var evts = e[name]; | ||
var liveEvents = []; | ||
if (evts && callback) { | ||
for (var i = 0, len = evts.length; i < len; i++) { | ||
if (evts[i].fn !== callback && evts[i].fn._ !== callback) | ||
{ liveEvents.push(evts[i]); } | ||
} | ||
} | ||
// Remove event from queue to prevent memory leak | ||
// Suggested by https://github.com/lazd | ||
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 | ||
(liveEvents.length) | ||
? e[name] = liveEvents | ||
: delete e[name]; | ||
return this; | ||
} | ||
}; | ||
var tinyEmitter = E; | ||
var id$1 = 0; | ||
@@ -128,3 +193,3 @@ | ||
return anonymous; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -226,5 +291,5 @@ /** | ||
var Server = (function (TinyEmitter$$1) { | ||
var Server = (function (TinyEmitter) { | ||
function Server (namespace) { | ||
TinyEmitter$$1.call(this); | ||
TinyEmitter.call(this); | ||
initListener(); | ||
@@ -240,4 +305,4 @@ this.namespace = namespace; | ||
if ( TinyEmitter$$1 ) Server.__proto__ = TinyEmitter$$1; | ||
Server.prototype = Object.create( TinyEmitter$$1 && TinyEmitter$$1.prototype ); | ||
if ( TinyEmitter ) Server.__proto__ = TinyEmitter; | ||
Server.prototype = Object.create( TinyEmitter && TinyEmitter.prototype ); | ||
Server.prototype.constructor = Server; | ||
@@ -257,3 +322,3 @@ | ||
return Server; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -260,0 +325,0 @@ // namespace 到 server 对象的映射表 |
/*! | ||
* chrome-connect v3.0.0 | ||
* chrome-connect v3.0.1 | ||
* https://github.com/Selection-Translator/connect.io | ||
@@ -7,9 +7,74 @@ * Released under the MIT License. | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tiny-emitter')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'tiny-emitter'], factory) : | ||
(factory((global.chromeConnect = global.chromeConnect || {}),global.TinyEmitter)); | ||
}(this, (function (exports,TinyEmitter) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.chromeConnect = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
TinyEmitter = TinyEmitter && 'default' in TinyEmitter ? TinyEmitter['default'] : TinyEmitter; | ||
function E () { | ||
// Keep this empty so it's easier to inherit from | ||
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) | ||
} | ||
E.prototype = { | ||
on: function (name, callback, ctx) { | ||
var e = this.e || (this.e = {}); | ||
(e[name] || (e[name] = [])).push({ | ||
fn: callback, | ||
ctx: ctx | ||
}); | ||
return this; | ||
}, | ||
once: function (name, callback, ctx) { | ||
var self = this; | ||
function listener () { | ||
self.off(name, listener); | ||
callback.apply(ctx, arguments); | ||
} | ||
listener._ = callback; | ||
return this.on(name, listener, ctx); | ||
}, | ||
emit: function (name) { | ||
var data = [].slice.call(arguments, 1); | ||
var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); | ||
var i = 0; | ||
var len = evtArr.length; | ||
for (i; i < len; i++) { | ||
evtArr[i].fn.apply(evtArr[i].ctx, data); | ||
} | ||
return this; | ||
}, | ||
off: function (name, callback) { | ||
var e = this.e || (this.e = {}); | ||
var evts = e[name]; | ||
var liveEvents = []; | ||
if (evts && callback) { | ||
for (var i = 0, len = evts.length; i < len; i++) { | ||
if (evts[i].fn !== callback && evts[i].fn._ !== callback) | ||
{ liveEvents.push(evts[i]); } | ||
} | ||
} | ||
// Remove event from queue to prevent memory leak | ||
// Suggested by https://github.com/lazd | ||
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 | ||
(liveEvents.length) | ||
? e[name] = liveEvents | ||
: delete e[name]; | ||
return this; | ||
} | ||
}; | ||
var tinyEmitter = E; | ||
var id$1 = 0; | ||
@@ -135,3 +200,3 @@ | ||
return anonymous; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -233,5 +298,5 @@ /** | ||
var Server = (function (TinyEmitter$$1) { | ||
var Server = (function (TinyEmitter) { | ||
function Server (namespace) { | ||
TinyEmitter$$1.call(this); | ||
TinyEmitter.call(this); | ||
initListener(); | ||
@@ -247,4 +312,4 @@ this.namespace = namespace; | ||
if ( TinyEmitter$$1 ) Server.__proto__ = TinyEmitter$$1; | ||
Server.prototype = Object.create( TinyEmitter$$1 && TinyEmitter$$1.prototype ); | ||
if ( TinyEmitter ) Server.__proto__ = TinyEmitter; | ||
Server.prototype = Object.create( TinyEmitter && TinyEmitter.prototype ); | ||
Server.prototype.constructor = Server; | ||
@@ -264,3 +329,3 @@ | ||
return Server; | ||
}(TinyEmitter)); | ||
}(tinyEmitter)); | ||
@@ -267,0 +332,0 @@ // namespace 到 server 对象的映射表 |
/*! | ||
* chrome-connect v3.0.0 | ||
* chrome-connect v3.0.1 | ||
* https://github.com/Selection-Translator/connect.io | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("tiny-emitter")):"function"==typeof define&&define.amd?define(["exports","tiny-emitter"],n):n(e.chromeConnect=e.chromeConnect||{},e.TinyEmitter)}(this,function(e,n){"use strict";function t(e,n){var t;try{t=JSON.parse(e.name)}catch(e){return}var o=t._namespace;if(o){var r=p[o];if(r){var i=r.ports,s=new c(e);s.external=n,s.once("disconnect",function(){i.splice(i.indexOf(s),1)}),s.broadcast=function(e,n){i.forEach(function(t){t!==s&&t.send(e,n)})},i.push(s),r.emit("connect",s)}else e.disconnect()}}var o=0,r=function(){return String(o++)},i=function(){},c=function(e){function n(n){var t=this;e.call(this),this.disconnected=!1;var o=this._waiting={};this.port=n,n.onMessage.addListener(function(e){var r=e.id,c=o[r];c?(delete o[r],c(e.error,e.response)):r?new Promise(function(n,o){t.emit(e.name,e.data,n,o)}).then(function(e){n.postMessage({id:r,response:e})},function(e){n.postMessage({id:r,error:e})}):t.emit(e.name,e.data,i,i)}),n.onDisconnect.addListener(function(){t.emit("disconnect",!0)}),this.once("disconnect",function(e){var n=new Error("Connection has been disconnected by "+(e?"the other side":"yourself")+".");t.disconnected=!0,t.disconnect=i,t.send=function(){throw n};for(var r in o)o[r](n),delete o[r]})}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.send=function(e,n,t){var o=this;!0===n&&2===arguments.length&&(n=void 0,t=!0);var i,c={name:e,data:n};return t&&(i=new Promise(function(e,n){o._waiting[c.id=r()]=function(t,o){t?n(t):e(o)}})),this.port.postMessage(c),i},n.prototype.disconnect=function(){this.port.disconnect(),this.emit("disconnect",!1)},n}(n=n&&"default"in n?n.default:n),s=chrome.runtime,a=s.id,d=function(e,n){"object"==typeof e&&(n=e,e=a),n||(n={}),null==e&&(e=a);var t,o=n.namespace||"default",r=JSON.stringify({_namespace:o});switch(typeof e){case"string":t=s.connect(e,{name:r});break;case"number":t=chrome.tabs.connect(e,{frameId:n.frameId,name:r});break;default:throw new Error("chrome.runtime.id is undefined, please specify the extension id which you want to connect.")}var i=new c(t);return i.namespace=o,i},u=function(){u=i;var e=s.onConnect,n=s.onConnectExternal;e&&e.addListener(function(e){t(e,!1)}),n&&n.addListener(function(e){t(e,!0)})},f=function(e){function n(n){e.call(this),u(),this.namespace=n,this.ports=[]}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.send=function(e,n){this.ports.forEach(function(t){t.send(e,n)})},n}(n),p={};e.createClient=d,e.createServer=function(e){void 0===e&&(e="default");var n=p[e];return n||(p[e]=new f(e))},e.send=function(e){var n=d(e.id,{frameId:e.frameId,namespace:e.namespace}),t=n.send(e.name,e.data,e.needResponse);if(t)return t.then(function(e){return n.disconnect(),e},function(e){return n.disconnect(),Promise.reject(e)});n.disconnect()},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.chromeConnect={})}(this,function(e){"use strict";function n(){}function t(e,n){var t;try{t=JSON.parse(e.name)}catch(e){return}var o=t._namespace;if(o){var i=h[o];if(i){var r=i.ports,c=new s(e);c.external=n,c.once("disconnect",function(){r.splice(r.indexOf(c),1)}),c.broadcast=function(e,n){r.forEach(function(t){t!==c&&t.send(e,n)})},r.push(c),i.emit("connect",c)}else e.disconnect()}}n.prototype={on:function(e,n,t){var o=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:n,ctx:t}),this},once:function(e,n,t){function o(){i.off(e,o),n.apply(t,arguments)}var i=this;return o._=n,this.on(e,o,t)},emit:function(e){var n=[].slice.call(arguments,1),t=((this.e||(this.e={}))[e]||[]).slice(),o=0,i=t.length;for(o;o<i;o++)t[o].fn.apply(t[o].ctx,n);return this},off:function(e,n){var t=this.e||(this.e={}),o=t[e],i=[];if(o&&n)for(var r=0,c=o.length;r<c;r++)o[r].fn!==n&&o[r].fn._!==n&&i.push(o[r]);return i.length?t[e]=i:delete t[e],this}};var o=n,i=0,r=function(){return String(i++)},c=function(){},s=function(e){function n(n){var t=this;e.call(this),this.disconnected=!1;var o=this._waiting={};this.port=n,n.onMessage.addListener(function(e){var i=e.id,r=o[i];r?(delete o[i],r(e.error,e.response)):i?new Promise(function(n,o){t.emit(e.name,e.data,n,o)}).then(function(e){n.postMessage({id:i,response:e})},function(e){n.postMessage({id:i,error:e})}):t.emit(e.name,e.data,c,c)}),n.onDisconnect.addListener(function(){t.emit("disconnect",!0)}),this.once("disconnect",function(e){var n=new Error("Connection has been disconnected by "+(e?"the other side":"yourself")+".");t.disconnected=!0,t.disconnect=c,t.send=function(){throw n};for(var i in o)o[i](n),delete o[i]})}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.send=function(e,n,t){var o=this;!0===n&&2===arguments.length&&(n=void 0,t=!0);var i,c={name:e,data:n};return t&&(i=new Promise(function(e,n){o._waiting[c.id=r()]=function(t,o){t?n(t):e(o)}})),this.port.postMessage(c),i},n.prototype.disconnect=function(){this.port.disconnect(),this.emit("disconnect",!1)},n}(o),a=chrome.runtime,f=a.id,u=function(e,n){"object"==typeof e&&(n=e,e=f),n||(n={}),null==e&&(e=f);var t,o=n.namespace||"default",i=JSON.stringify({_namespace:o});switch(typeof e){case"string":t=a.connect(e,{name:i});break;case"number":t=chrome.tabs.connect(e,{frameId:n.frameId,name:i});break;default:throw new Error("chrome.runtime.id is undefined, please specify the extension id which you want to connect.")}var r=new s(t);return r.namespace=o,r},d=function(){d=c;var e=a.onConnect,n=a.onConnectExternal;e&&e.addListener(function(e){t(e,!1)}),n&&n.addListener(function(e){t(e,!0)})},p=function(e){function n(n){e.call(this),d(),this.namespace=n,this.ports=[]}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.send=function(e,n){this.ports.forEach(function(t){t.send(e,n)})},n}(o),h={};e.createClient=u,e.createServer=function(e){void 0===e&&(e="default");var n=h[e];return n||(h[e]=new p(e))},e.send=function(e){var n=u(e.id,{frameId:e.frameId,namespace:e.namespace}),t=n.send(e.name,e.data,e.needResponse);if(t)return t.then(function(e){return n.disconnect(),e},function(e){return n.disconnect(),Promise.reject(e)});n.disconnect()},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "connect.io", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Real-time bidirectional event-based and Promise friendly communication in Chrome extensions or Apps inspired by Socket.IO. ", | ||
@@ -9,3 +9,3 @@ "scripts": { | ||
"lint": "eslint --ignore-pattern '/dist/' --ignore-pattern '/coverage/' '**/*.js'", | ||
"prepublish": "yarn run build" | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -50,7 +50,9 @@ "main": "dist/chrome-connect.common.js", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-rollup-preprocessor": "^4.0.0", | ||
"karma-rollup-preprocessor": "^5.0.1", | ||
"phantomjs-prebuilt": "^2.1.13", | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-buble": "^0.15.0", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-buble": "^0.16.0", | ||
"rollup-plugin-commonjs": "^8.2.5", | ||
"rollup-plugin-istanbul": "^1.1.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"uglify-js": "^3.0.23" | ||
@@ -57,0 +59,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
61487
1390
0
0
24