New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.3.3 to 2.3.4

4

comlink.es6.js

@@ -285,4 +285,6 @@ /**

visited.add(value);
if (ArrayBuffer.isView(value))
return;
yield { value, path };
let keys = Object.keys(value);
const keys = Object.keys(value);
for (const key of keys)

@@ -289,0 +291,0 @@ yield* iterateAllProperties(value[key], [...path, key], visited);

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

export const Comlink=function(){function a(a){if(n(a)&&(a=h(a)),!i(a))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return j(a),p(async(b)=>{let c=[];('APPLY'===b.type||'CONSTRUCT'===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(('APPLY'===f.type||'CONSTRUCT'===f.type)&&(j=f.argumentsList.map(e)),'APPLY'===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if('CONSTRUCT'===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return'SET'===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:'RAW',value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join('.')}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return'RAW'===a.type}function h(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 i(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener('message',b)}function l(a,b){a.removeEventListener('message',b)}function m(a){return'MessagePort'===a.constructor.name}function n(a){return['window','length','location','parent','opener'].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:'CONSTRUCT',callPath:b,argumentsList:d})},apply(c,d,e){return'bind'===b[b.length-1]?p(a,b.slice(0,-1)):a({type:'APPLY',callPath:b,argumentsList:e})},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if('then'===d){const c=a({type:'GET',callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:'SET',callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&'string'!=typeof a){'object'==typeof a&&c.add(a),yield{value:a,path:b};let d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:'RAW',value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol('proxyValue'),x=Symbol('throw'),y=new Map([['PROXY',{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],['THROW',{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+'\n'+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,expose:c}}();
export const Comlink=function(){function a(a){if(n(a)&&(a=h(a)),!i(a))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return j(a),p(async(b)=>{let c=[];('APPLY'===b.type||'CONSTRUCT'===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(('APPLY'===f.type||'CONSTRUCT'===f.type)&&(j=f.argumentsList.map(e)),'APPLY'===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if('CONSTRUCT'===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return'SET'===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:'RAW',value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join('.')}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return'RAW'===a.type}function h(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 i(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener('message',b)}function l(a,b){a.removeEventListener('message',b)}function m(a){return'MessagePort'===a.constructor.name}function n(a){return['window','length','location','parent','opener'].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:'CONSTRUCT',callPath:b,argumentsList:d})},apply(c,d,e){return'bind'===b[b.length-1]?p(a,b.slice(0,-1)):a({type:'APPLY',callPath:b,argumentsList:e})},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if('then'===d){const c=a({type:'GET',callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:'SET',callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&'string'!=typeof a&&('object'==typeof a&&c.add(a),!ArrayBuffer.isView(a))){yield{value:a,path:b};const d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:'RAW',value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol('proxyValue'),x=Symbol('throw'),y=new Map([['PROXY',{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],['THROW',{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+'\n'+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,expose:c}}();

@@ -287,4 +287,6 @@ "use strict";

visited.add(value);
if (ArrayBuffer.isView(value))
return;
yield { value, path };
let keys = Object.keys(value);
const keys = Object.keys(value);
for (const key of keys)

@@ -291,0 +293,0 @@ yield* iterateAllProperties(value[key], [...path, key], visited);

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

'use strict';self.Comlink=function(){function a(a){if(n(a)&&(a=h(a)),!i(a))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return j(a),p(async(b)=>{let c=[];('APPLY'===b.type||'CONSTRUCT'===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(('APPLY'===f.type||'CONSTRUCT'===f.type)&&(j=f.argumentsList.map(e)),'APPLY'===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if('CONSTRUCT'===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return'SET'===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:'RAW',value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join('.')}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return'RAW'===a.type}function h(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 i(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener('message',b)}function l(a,b){a.removeEventListener('message',b)}function m(a){return'MessagePort'===a.constructor.name}function n(a){return['window','length','location','parent','opener'].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:'CONSTRUCT',callPath:b,argumentsList:d})},apply(c,d,e){return'bind'===b[b.length-1]?p(a,b.slice(0,-1)):a({type:'APPLY',callPath:b,argumentsList:e})},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if('then'===d){const c=a({type:'GET',callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:'SET',callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&'string'!=typeof a){'object'==typeof a&&c.add(a),yield{value:a,path:b};let d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:'RAW',value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol('proxyValue'),x=Symbol('throw'),y=new Map([['PROXY',{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],['THROW',{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+'\n'+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,expose:c}}();
'use strict';self.Comlink=function(){function a(a){if(n(a)&&(a=h(a)),!i(a))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');return j(a),p(async(b)=>{let c=[];('APPLY'===b.type||'CONSTRUCT'===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error('endpoint does not have all of addEventListener, removeEventListener and postMessage defined');j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(('APPLY'===f.type||'CONSTRUCT'===f.type)&&(j=f.argumentsList.map(e)),'APPLY'===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if('CONSTRUCT'===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return'SET'===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:'RAW',value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join('.')}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return'RAW'===a.type}function h(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 i(a){return'addEventListener'in a&&'removeEventListener'in a&&'postMessage'in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener('message',b)}function l(a,b){a.removeEventListener('message',b)}function m(a){return'MessagePort'===a.constructor.name}function n(a){return['window','length','location','parent','opener'].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:'CONSTRUCT',callPath:b,argumentsList:d})},apply(c,d,e){return'bind'===b[b.length-1]?p(a,b.slice(0,-1)):a({type:'APPLY',callPath:b,argumentsList:e})},get(c,d,e){if('then'===d&&0===b.length)return{then:()=>e};if('then'===d){const c=a({type:'GET',callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:'SET',callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&'string'!=typeof a&&('object'==typeof a&&c.add(a),!ArrayBuffer.isView(a))){yield{value:a,path:b};const d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:'RAW',value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol('proxyValue'),x=Symbol('throw'),y=new Map([['PROXY',{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],['THROW',{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+'\n'+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,expose:c}}();

@@ -296,4 +296,6 @@ /**

visited.add(value);
if (ArrayBuffer.isView(value))
return;
yield { value, path };
let keys = Object.keys(value);
const keys = Object.keys(value);
for (const key of keys)

@@ -300,0 +302,0 @@ yield* iterateAllProperties(value[key], [...path, key], visited);

@@ -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(a){if(n(a)&&(a=h(a)),!i(a))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");return j(a),p(async(b)=>{let c=[];("APPLY"===b.type||"CONSTRUCT"===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(("APPLY"===f.type||"CONSTRUCT"===f.type)&&(j=f.argumentsList.map(e)),"APPLY"===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if("CONSTRUCT"===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return"SET"===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:"RAW",value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join(".")}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return"RAW"===a.type}function h(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 i(a){return"addEventListener"in a&&"removeEventListener"in a&&"postMessage"in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener("message",b)}function l(a,b){a.removeEventListener("message",b)}function m(a){return"MessagePort"===a.constructor.name}function n(a){return["window","length","location","parent","opener"].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:"CONSTRUCT",callPath:b,argumentsList:d})},apply(c,d,e){return"bind"===b[b.length-1]?p(a,b.slice(0,-1)):a({type:"APPLY",callPath:b,argumentsList:e})},get(c,d,e){if("then"===d&&0===b.length)return{then:()=>e};if("then"===d){const c=a({type:"GET",callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:"SET",callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&"string"!=typeof a){"object"==typeof a&&c.add(a),yield{value:a,path:b};let d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:"RAW",value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol("proxyValue"),x=Symbol("throw"),y=new Map([["PROXY",{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],["THROW",{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+"\n"+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,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(a){if(n(a)&&(a=h(a)),!i(a))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");return j(a),p(async(b)=>{let c=[];("APPLY"===b.type||"CONSTRUCT"===b.type)&&(c=b.argumentsList.map(d));const f=await o(a,Object.assign({},b,{argumentsList:c}),r(c)),g=f.data;return e(g.value)})}function b(a){return a[w]=!0,a}function c(a,c){if(n(c)&&(c=h(c)),!i(c))throw Error("endpoint does not have all of addEventListener, removeEventListener and postMessage defined");j(c),k(c,async function(d){if(!d.data.id)return;const f=d.data;let g=await f.callPath.slice(0,-1).reduce((a,b)=>a[b],a),h=await f.callPath.reduce((a,b)=>a[b],a),i=h,j=[];if(("APPLY"===f.type||"CONSTRUCT"===f.type)&&(j=f.argumentsList.map(e)),"APPLY"===f.type)try{i=await h.apply(g,j)}catch(a){i=a,i[x]=!0}if("CONSTRUCT"===f.type)try{i=new h(...j),i=b(i)}catch(a){i=a,i[x]=!0}return"SET"===f.type&&(h[f.property]=f.value,i=!0),i=t(i),i.id=f.id,c.postMessage(i,r([i]))})}function d(a){for(const[b,c]of y.entries())if(c.canHandle(a))return{type:b,value:c.serialize(a)};let b=[];for(const c of s(a))for(const[a,d]of y.entries())d.canHandle(c.value)&&b.push({path:c.path,wrappedValue:{type:a,value:d.serialize(c.value)}});for(const c of b){const b=c.path.slice(0,-1).reduce((a,b)=>a[b],a);b[c.path[c.path.length-1]]=null}return{type:"RAW",value:a,wrappedChildren:b}}function e(a){if(y.has(a.type)){const b=y.get(a.type);return b.deserialize(a.value)}if(g(a)){for(const b of a.wrappedChildren||[]){if(!y.has(b.wrappedValue.type))throw Error(`Unknown value type "${a.type}" at ${b.path.join(".")}`);const c=y.get(b.wrappedValue.type),d=c.deserialize(b.wrappedValue.value);f(a.value,b.path,d)}return a.value}throw Error(`Unknown value type "${a.type}"`)}function f(a,b,c){const d=b.slice(-1)[0],e=b.slice(0,-1).reduce((a,b)=>a[b],a);e[d]=c}function g(a){return"RAW"===a.type}function h(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 i(a){return"addEventListener"in a&&"removeEventListener"in a&&"postMessage"in a}function j(a){m(a)&&a.start()}function k(a,b){a.addEventListener("message",b)}function l(a,b){a.removeEventListener("message",b)}function m(a){return"MessagePort"===a.constructor.name}function n(a){return["window","length","location","parent","opener"].every((b)=>b in a)}function o(a,b,c){const d=`${v}-${z++}`;return new Promise((e)=>{k(a,function b(c){c.data.id!==d||(l(a,b),e(c))}),b=Object.assign({},b,{id:d}),a.postMessage(b,c)})}function p(a,b=[]){return new Proxy(function(){},{construct(c,d){return a({type:"CONSTRUCT",callPath:b,argumentsList:d})},apply(c,d,e){return"bind"===b[b.length-1]?p(a,b.slice(0,-1)):a({type:"APPLY",callPath:b,argumentsList:e})},get(c,d,e){if("then"===d&&0===b.length)return{then:()=>e};if("then"===d){const c=a({type:"GET",callPath:b});return Promise.resolve(c).then.bind(c)}return p(a,b.concat(d))},set(c,d,e){return a({type:"SET",callPath:b,property:d,value:e})}})}function q(a){return u.some((b)=>a instanceof b)}function*s(a,b=[],c=null){if(a&&(c||(c=new WeakSet),!c.has(a))&&"string"!=typeof a&&("object"==typeof a&&c.add(a),!ArrayBuffer.isView(a))){yield{value:a,path:b};const d=Object.keys(a);for(const e of d)yield*s(a[e],[...b,e],c)}}function r(a){const b=[];for(const c of s(a))q(c.value)&&b.push(c.value);return b}function t(a){for(const[b,c]of y.entries())if(c.canHandle(a)){const d=c.serialize(a);return{value:{type:b,value:d}}}return{value:{type:"RAW",value:a}}}const u=[ArrayBuffer,MessagePort],v=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER),w=Symbol("proxyValue"),x=Symbol("throw"),y=new Map([["PROXY",{canHandle:(a)=>a&&a[w],serialize:(a)=>{const{port1:b,port2:d}=new MessageChannel;return c(a,b),d},deserialize:(b)=>a(b)}],["THROW",{canHandle:(a)=>a&&a[x],serialize:(a)=>a.toString()+"\n"+a.stack,deserialize:(a)=>{throw Error(a)}}]]);let z=0;return{proxy:a,proxyValue:b,transferHandlers:y,expose:c}}()});
{
"name": "comlinkjs",
"version": "2.3.3",
"version": "2.3.4",
"description": "",

@@ -36,7 +36,11 @@ "main": "comlink.umd.js",

],
"repository": {
"type": "git",
"url": "https://github.com/GoogleChromeLabs/comlink.git"
},
"license": "Apache-2.0",
"devDependencies": {
"babel-minify": "^0.3.0",
"babel-minify": "0.3.0",
"chai": "4.1.2",
"eslint": "4.18.1",
"eslint": "4.19.0",
"eslint-config-google": "0.9.1",

@@ -50,3 +54,3 @@ "karma": "2.0.0",

"karma-typescript": "3.0.12",
"mocha": "5.0.1",
"mocha": "5.0.4",
"typescript": "2.7.2",

@@ -53,0 +57,0 @@ "typescript-eslint-parser": "14.0.0"

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