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.6 to 2.4.0

2

comlink.es6.js

@@ -67,3 +67,3 @@ /**

attachMessageHandler(endpoint, async function (event) {
if (!event.data || !event.data.id)
if (!event.data.id)
return;

@@ -70,0 +70,0 @@ const irequest = event.data;

@@ -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||!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)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)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)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)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)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)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}}();

@@ -69,3 +69,3 @@ "use strict";

attachMessageHandler(endpoint, async function (event) {
if (!event.data || !event.data.id)
if (!event.data.id)
return;

@@ -72,0 +72,0 @@ const irequest = event.data;

@@ -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||!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)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)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)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)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)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)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}}();

@@ -78,3 +78,3 @@ /**

attachMessageHandler(endpoint, async function (event) {
if (!event.data || !event.data.id)
if (!event.data.id)
return;

@@ -81,0 +81,0 @@ const irequest = event.data;

@@ -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||!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)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)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)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)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)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)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}}()});

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

export const MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=(a)=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",(b)=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map((b)=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(g/16).fill(0).map(()=>e()).join("")}const g=128;return{wrap:a}}();
export const MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=a=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",b=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map(b=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(8).fill(0).map(()=>e()).join("")}return{wrap:a}}();

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

"use strict";self.MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=(a)=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",(b)=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map((b)=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(g/16).fill(0).map(()=>e()).join("")}const g=128;return{wrap:a}}();
"use strict";self.MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=a=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",b=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map(b=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(8).fill(0).map(()=>e()).join("")}return{wrap:a}}();

@@ -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.MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=(a)=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",(b)=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map((b)=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(g/16).fill(0).map(()=>e()).join("")}const g=128;return{wrap:a}}()});
(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.MessageChannelAdapter=function(){function a(a,c=null){const{port1:d,port2:e}=new MessageChannel;return b(e,a,c),d}function b(e,g,h=null){e.onmessage=a=>{h||(h=f());const e=a.data,i=Array.from(d(a.data));for(const d of i){const a=f(),h=c(e,d,a);b(h,g,a)}const j=JSON.stringify({id:h,msg:e,messageChannels:i});g.send(j)},g.addEventListener("message",b=>{const d=JSON.parse(b.data);if(h||(h=d.id),h===d.id){const b=d.messageChannels.map(b=>{const e=b.reduce((a,b)=>a[b],d.msg),f=a(g,e);return c(d.msg,b,f),f});e.postMessage(d.msg,b)}})}function c(a,b,c){for(const d of b.slice(0,-1))a=a[d];const d=b[b.length-1],e=a[d];return a[d]=c,e}function*d(a,b=[]){if(a&&"string"!=typeof a){if(a instanceof MessagePort)return void(yield b.slice());for(const c of Object.keys(a))b.push(c),yield*d(a[c],b),b.pop()}}function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function f(){return Array(8).fill(0).map(()=>e()).join("")}return{wrap:a}}()});
{
"name": "comlinkjs",
"version": "2.3.6",
"version": "2.4.0",
"description": "",

@@ -15,3 +15,3 @@ "main": "comlink.umd.js",

"version": "sed -i.bak -e 's!comlinkjs@[0-9.]+!comlinkjs@'${npm_package_version}'!' README.md && git add README.md",
"mypublish": "npm run build && npm run test && cp README.md package.json dist && npm publish dist && sed -i.bak -e 's!\"comlinkjs\"!\"comlink\"!' dist/package.json && npm publish dist",
"mypublish": "npm run build && npm run linter && cp README.md package.json dist && npm publish dist",
"build": "rm -rf dist && mkdir dist && npm run compile && npm run mangle_global && npm run minify",

@@ -51,8 +51,9 @@ "compile": "tsc --outDir dist -m none && mv dist/comlink.{,global.}js && mv dist/messagechanneladapter.{,global.}js && tsc --outDir dist -m es2015 && mv dist/comlink.{,es6.}js && mv dist/messagechanneladapter.{,es6.}js && tsc -d --outDir dist -m umd && mv dist/comlink.{,umd.}js && mv dist/messagechanneladapter.{,umd.}js",

"karma-safari-launcher": "1.0.0",
"karma-safaritechpreview-launcher": "0.0.6",
"karma-typescript": "3.0.12",
"mocha": "5.1.1",
"typescript": "2.8.3",
"prettier": "1.12.1"
"prettier": "1.12.1",
"typescript": "2.8.3"
},
"dependencies": {}
}

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