Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comlinkjs

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comlinkjs - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

5

comlink.es6.js

@@ -116,3 +116,6 @@ /**

function isWindow(endpoint) {
return endpoint.constructor.name === 'Window';
// TODO: This doesn’t work on cross-origin iframes.
// Is `'window' in endpoint` ok?
// return endpoint.constructor.name === 'Window';
return 'window' in endpoint;
}

@@ -119,0 +122,0 @@ /**

2

comlink.es6.min.js

@@ -1,1 +0,1 @@

export const Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return'PROXY'===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case'APPLY':{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d='AsyncGeneratorFunction'===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case'GET':{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case'CONSTRUCT':{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:'PROXY',endpoint:d},[d])}}})}function d(a){if('Window'!==self.constructor.name)throw Error('self is not a window');return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,'*',c)}}function e(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener('message',b)}function h(a,b){a.removeEventListener('message',b)}function i(a){return'MessagePort'===a.constructor.name}function j(a){return'Window'===a.constructor.name}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return'asyncIterator'in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a('CONSTRUCT',b,d);return b=[],e},apply(c,d,e){if('bind'===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a('APPLY',c.slice(0,-1),b)}const f=a('APPLY',b,e);return b=[],f},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if('then'===d){const c=a('GET',b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if('string'==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:'PROXY',endpoint:d}}return{type:'OBJECT',obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol('proxyValue');return{proxy:a,proxyValue:b,expose:c}}();
export const Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return'PROXY'===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case'APPLY':{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d='AsyncGeneratorFunction'===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case'GET':{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case'CONSTRUCT':{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:'PROXY',endpoint:d},[d])}}})}function d(a){if('Window'!==self.constructor.name)throw Error('self is not a window');return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,'*',c)}}function e(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener('message',b)}function h(a,b){a.removeEventListener('message',b)}function i(a){return'MessagePort'===a.constructor.name}function j(a){return'window'in a}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return'asyncIterator'in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a('CONSTRUCT',b,d);return b=[],e},apply(c,d,e){if('bind'===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a('APPLY',c.slice(0,-1),b)}const f=a('APPLY',b,e);return b=[],f},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if('then'===d){const c=a('GET',b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if('string'==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:'PROXY',endpoint:d}}return{type:'OBJECT',obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol('proxyValue');return{proxy:a,proxyValue:b,expose:c}}();

@@ -118,3 +118,6 @@ "use strict";

function isWindow(endpoint) {
return endpoint.constructor.name === 'Window';
// TODO: This doesn’t work on cross-origin iframes.
// Is `'window' in endpoint` ok?
// return endpoint.constructor.name === 'Window';
return 'window' in endpoint;
}

@@ -121,0 +124,0 @@ /**

@@ -1,1 +0,1 @@

'use strict';self.Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return'PROXY'===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case'APPLY':{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d='AsyncGeneratorFunction'===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case'GET':{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case'CONSTRUCT':{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:'PROXY',endpoint:d},[d])}}})}function d(a){if('Window'!==self.constructor.name)throw Error('self is not a window');return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,'*',c)}}function e(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener('message',b)}function h(a,b){a.removeEventListener('message',b)}function i(a){return'MessagePort'===a.constructor.name}function j(a){return'Window'===a.constructor.name}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return'asyncIterator'in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a('CONSTRUCT',b,d);return b=[],e},apply(c,d,e){if('bind'===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a('APPLY',c.slice(0,-1),b)}const f=a('APPLY',b,e);return b=[],f},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if('then'===d){const c=a('GET',b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if('string'==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:'PROXY',endpoint:d}}return{type:'OBJECT',obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol('proxyValue');return{proxy:a,proxyValue:b,expose:c}}();
'use strict';self.Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return'PROXY'===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case'APPLY':{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d='AsyncGeneratorFunction'===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case'GET':{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case'CONSTRUCT':{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:'PROXY',endpoint:d},[d])}}})}function d(a){if('Window'!==self.constructor.name)throw Error('self is not a window');return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,'*',c)}}function e(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener('message',b)}function h(a,b){a.removeEventListener('message',b)}function i(a){return'MessagePort'===a.constructor.name}function j(a){return'window'in a}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return'asyncIterator'in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a('CONSTRUCT',b,d);return b=[],e},apply(c,d,e){if('bind'===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a('APPLY',c.slice(0,-1),b)}const f=a('APPLY',b,e);return b=[],f},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if('then'===d){const c=a('GET',b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if('string'==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:'PROXY',endpoint:d}}return{type:'OBJECT',obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol('proxyValue');return{proxy:a,proxyValue:b,expose:c}}();

@@ -127,3 +127,6 @@ /**

function isWindow(endpoint) {
return endpoint.constructor.name === 'Window';
// TODO: This doesn’t work on cross-origin iframes.
// Is `'window' in endpoint` ok?
// return endpoint.constructor.name === 'Window';
return 'window' in endpoint;
}

@@ -130,0 +133,0 @@ /**

@@ -1,1 +0,1 @@

(function(a){if("object"==typeof module&&"object"==typeof module.exports){var b=a(require,exports);b!==void 0&&(module.exports=b)}else"function"==typeof define&&define.amd&&define(["require","exports"],a)})(function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return"PROXY"===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case"APPLY":{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d="AsyncGeneratorFunction"===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case"GET":{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case"CONSTRUCT":{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:"PROXY",endpoint:d},[d])}}})}function d(a){if("Window"!==self.constructor.name)throw Error("self is not a window");return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,"*",c)}}function e(a){return"addEventListener"in a&&"removeEventListener"in a&&"postMessage"in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener("message",b)}function h(a,b){a.removeEventListener("message",b)}function i(a){return"MessagePort"===a.constructor.name}function j(a){return"Window"===a.constructor.name}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return"asyncIterator"in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a("CONSTRUCT",b,d);return b=[],e},apply(c,d,e){if("bind"===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a("APPLY",c.slice(0,-1),b)}const f=a("APPLY",b,e);return b=[],f},get(c,d,e){if("then"===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if("then"===d){const c=a("GET",b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if("string"==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:"PROXY",endpoint:d}}return{type:"OBJECT",obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol("proxyValue");return{proxy:a,proxyValue:b,expose:c}}()});
(function(a){if("object"==typeof module&&"object"==typeof module.exports){var b=a(require,exports);b!==void 0&&(module.exports=b)}else"function"==typeof define&&define.amd&&define(["require","exports"],a)})(function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.Comlink=function(){function a(b){if(j(b)&&(b=d(b)),!e(b))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");return f(b),m(async(c,d,e)=>{const f=await k(b,{type:c,callPath:d,argumentsList:e},p(e)),g=f.data;return"PROXY"===g.type?a(g.endpoint):g.obj})}function b(a){return a[v]=!0,a}function c(a,h){if(j(h)&&(h=d(h)),!e(h))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");f(h),g(h,async function(d){if(!d.data.id)return;const e=d.data;let f=await e.callPath.reduce((a,b)=>a[b],a);switch(e.type){case"APPLY":{e.callPath.pop();const c=await e.callPath.reduce((a,b)=>a[b],a),d="AsyncGeneratorFunction"===f.constructor.name;f=await f.apply(c,e.argumentsList),d&&(f=b(f))}case"GET":{const a=r(f);return a.id=e.id,h.postMessage(a,p([a]))}case"CONSTRUCT":{const a=new f(...(e.argumentsList||[])),{port1:b,port2:d}=new MessageChannel;return c(a,b),h.postMessage({id:e.id,type:"PROXY",endpoint:d},[d])}}})}function d(a){if("Window"!==self.constructor.name)throw Error("self is not a window");return{addEventListener:self.addEventListener.bind(self),removeEventListener:self.removeEventListener.bind(self),postMessage:(b,c)=>a.postMessage(b,"*",c)}}function e(a){return"addEventListener"in a&&"removeEventListener"in a&&"postMessage"in a}function f(a){i(a)&&a.start()}function g(a,b){a.addEventListener("message",b)}function h(a,b){a.removeEventListener("message",b)}function i(a){return"MessagePort"===a.constructor.name}function j(a){return"window"in a}function k(a,b,c){const d=`${s}-${t++}`;return new Promise((e)=>{g(a,function b(c){c.data.id!==d||(h(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function l(){return"asyncIterator"in Symbol}function m(a){let b=[];return new Proxy(function(){},{construct(c,d){const e=a("CONSTRUCT",b,d);return b=[],e},apply(c,d,e){if("bind"===b[b.length-1]){const c=b.slice();return b=[],(...b)=>a("APPLY",c.slice(0,-1),b)}const f=a("APPLY",b,e);return b=[],f},get(c,d,e){if("then"===d&&0===b.length)return{then:()=>e};if(l()&&d===Symbol.asyncIterator)return()=>e;if("then"===d){const c=a("GET",b);return b=[],Promise.resolve(c).then.bind(c)}return b.push(d),e}})}function n(a){return u.some((b)=>a instanceof b)}function*o(a){if(!a)return;if("string"==typeof a)return;yield a;let b=Object.values(a);Array.isArray(a)&&(b=a);for(const c of b)yield*o(c)}function p(a){const b=[];for(const c of o(a))n(c)&&b.push(c);return b}function q(a){return a&&a[v]}function r(a){if(q(a)){const{port1:b,port2:d}=new MessageChannel;return c(a,b),{type:"PROXY",endpoint:d}}return{type:"OBJECT",obj:a}}const s=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);let t=0;const u=[ArrayBuffer,MessagePort],v=Symbol("proxyValue");return{proxy:a,proxyValue:b,expose:c}}()});
{
"name": "comlinkjs",
"version": "2.0.0",
"version": "2.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "comlink.umd.js",

@@ -93,3 +93,3 @@ # Comlink

The Comlink module exports 4 functions:
The Comlink module exports 3 functions:

@@ -96,0 +96,0 @@ ### `proxy(endpoint)`

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc