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 3.0.3 to 3.1.0

11

comlink.d.ts

@@ -18,2 +18,10 @@ /**

}
declare type ProxiedObject<T> = {
[P in keyof T]: T[P] extends (...args: infer Arguments) => infer R ? (...args: Arguments) => Promise<R> : Promise<T[P]>;
};
export declare type ProxyResult<T> = ProxiedObject<T> & (T extends (...args: infer Arguments) => infer R ? (...args: Arguments) => Promise<R> : unknown) & (T extends {
new (...args: infer ArgumentsType): infer InstanceType;
} ? {
new (...args: ArgumentsType): Promise<ProxiedObject<InstanceType>>;
} : unknown);
export declare type Proxy = Function;

@@ -27,4 +35,5 @@ export declare type Exposable = Function | Object;

export declare const transferHandlers: Map<string, TransferHandler>;
export declare function proxy(endpoint: Endpoint | Window, target?: any): Proxy;
export declare function proxy<T = any>(endpoint: Endpoint | Window, target?: any): ProxyResult<T>;
export declare function proxyValue<T>(obj: T): T;
export declare function expose(rootObj: Exposable, endpoint: Endpoint | Window): void;
export {};

12

comlink.js

@@ -13,3 +13,5 @@ /**

*/
const TRANSFERABLE_TYPES = [ArrayBuffer, MessagePort];
const TRANSFERABLE_TYPES = ["ArrayBuffer", "MessagePort", "OffscreenCanvas"]
.filter(f => f in self)
.map(f => self[f]);
const uid = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);

@@ -31,5 +33,9 @@ const proxyValueSymbol = Symbol("proxyValue");

canHandle: (obj) => obj && obj[throwSymbol],
serialize: (obj) => obj.toString() + "\n" + obj.stack,
serialize: (obj) => {
const message = obj && obj.message;
const stack = obj && obj.stack;
return Object.assign({}, obj, { message, stack });
},
deserialize: (obj) => {
throw Error(obj);
throw Object.assign(Error(), obj);
}

@@ -36,0 +42,0 @@ };

@@ -13,7 +13,5 @@ /**

*/
export interface StringMessageChannel {
export interface StringMessageChannel extends EventTarget {
send(data: string): void;
addEventListener(typ: string, listener: (ev: MessageEvent) => void | Promise<void>): void;
removeEventListener(typ: string, listener: (ev: MessageEvent) => void | Promise<void>): void;
}
export declare function wrap(smc: StringMessageChannel, id?: string | null): MessagePort;

@@ -40,5 +40,3 @@ /**

}
if (!id)
id = data.id;
if (id !== data.id)
if (id && id !== data.id)
return;

@@ -45,0 +43,0 @@ const mcs = data.messageChannels.map(messageChannel => {

{
"name": "comlinkjs",
"version": "3.0.3",
"version": "3.1.0",
"description": "",

@@ -9,18 +9,12 @@ "main": "comlink.js",

"scripts": {
"test": "npm run fmt_test && npm run unittest && npm run build",
"test": "npm run linter && npm run unittest && npm run build",
"unittest": "karma start",
"fmt_test": "test $(prettier -l ./{.,docs,test}/*.{js,ts,json,md} | wc -l) -eq 0",
"fmt": "prettier --write ./{.,docs,test}/*.{js,ts,json,md}",
"linter": "prettier --write ./*.js ./docs/**/*.js ./tests/**/*.js ./**/*.ts ./**/*.md ./**/*.json",
"watchtest": "karma start --no-single-run --browsers ChromeHeadless",
"watchtestharmony": "karma start --no-single-run --browsers ChromeCanaryHeadlessHarmony",
"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 test && cp README.md package.json dist && npm publish dist",
"build": "rm -rf dist && mkdir dist && npm run compile",
"compile": "tsc --outDir dist && tsc -m umd --outDir dist/umd && node ./mangle_umd.js"
},
"husky": {
"hooks": {
"pre-commit": "npm test"
}
},
"keywords": [],

@@ -47,5 +41,4 @@ "author": {

"devDependencies": {
"chai": "4.1.2",
"husky": "^0.14.3",
"karma": "2.0.2",
"chai": "4.2.0",
"karma": "3.1.3",
"karma-chai": "0.1.0",

@@ -55,9 +48,9 @@ "karma-chrome-launcher": "2.2.0",

"karma-mocha": "1.3.0",
"karma-safari-launcher": "^1.0.0",
"karma-safaritechpreview-launcher": "0.0.6",
"karma-safari-launcher": "1.0.0",
"karma-safaritechpreview-launcher": "1.0.0",
"mocha": "5.2.0",
"prettier": "1.13.5",
"typescript": "2.9.2"
"prettier": "1.15.3",
"typescript": "^3.2.1"
},
"dependencies": {}
}

@@ -9,3 +9,3 @@ # Comlink

// main.js
const MyClass = Comlink.proxy(new Worker('worker.js'));
const MyClass = Comlink.proxy(new Worker("worker.js"));
// `instance` is an instance of `MyClass` that lives in the worker!

@@ -60,3 +60,3 @@ const instance = await new MyClass();

```
https://cdn.jsdelivr.net/npm/comlinkjs@3.0.3/umd/comlink.js
https://cdn.jsdelivr.net/npm/comlinkjs@3.1.0/umd/comlink.js
```

@@ -93,8 +93,8 @@

By default, all parameters to a function are copied (structural clone):
By default, all parameters to a function that are not [transferable] are copied (structural clone):
```js
// main.js
const api = Comlink.proxy(new Worker('worker.js'));
const obj = {x: 0};
const api = Comlink.proxy(new Worker("worker.js"));
const obj = { x: 0 };
await api.setXto4(obj);

@@ -101,0 +101,0 @@ console.log(obj.x); // logs 0

@@ -18,2 +18,10 @@ /**

}
declare type ProxiedObject<T> = {
[P in keyof T]: T[P] extends (...args: infer Arguments) => infer R ? (...args: Arguments) => Promise<R> : Promise<T[P]>;
};
export declare type ProxyResult<T> = ProxiedObject<T> & (T extends (...args: infer Arguments) => infer R ? (...args: Arguments) => Promise<R> : unknown) & (T extends {
new (...args: infer ArgumentsType): infer InstanceType;
} ? {
new (...args: ArgumentsType): Promise<ProxiedObject<InstanceType>>;
} : unknown);
export declare type Proxy = Function;

@@ -27,4 +35,5 @@ export declare type Exposable = Function | Object;

export declare const transferHandlers: Map<string, TransferHandler>;
export declare function proxy(endpoint: Endpoint | Window, target?: any): Proxy;
export declare function proxy<T = any>(endpoint: Endpoint | Window, target?: any): ProxyResult<T>;
export declare function proxyValue<T>(obj: T): T;
export declare function expose(rootObj: Exposable, endpoint: Endpoint | Window): void;
export {};

@@ -25,3 +25,5 @@ /**

Object.defineProperty(exports, "__esModule", { value: true });
const TRANSFERABLE_TYPES = [ArrayBuffer, MessagePort];
const TRANSFERABLE_TYPES = ["ArrayBuffer", "MessagePort", "OffscreenCanvas"]
.filter(f => f in self)
.map(f => self[f]);
const uid = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);

@@ -43,5 +45,9 @@ const proxyValueSymbol = Symbol("proxyValue");

canHandle: (obj) => obj && obj[throwSymbol],
serialize: (obj) => obj.toString() + "\n" + obj.stack,
serialize: (obj) => {
const message = obj && obj.message;
const stack = obj && obj.stack;
return Object.assign({}, obj, { message, stack });
},
deserialize: (obj) => {
throw Error(obj);
throw Object.assign(Error(), obj);
}

@@ -48,0 +54,0 @@ };

@@ -13,7 +13,5 @@ /**

*/
export interface StringMessageChannel {
export interface StringMessageChannel extends EventTarget {
send(data: string): void;
addEventListener(typ: string, listener: (ev: MessageEvent) => void | Promise<void>): void;
removeEventListener(typ: string, listener: (ev: MessageEvent) => void | Promise<void>): void;
}
export declare function wrap(smc: StringMessageChannel, id?: string | null): MessagePort;

@@ -53,5 +53,3 @@ /**

}
if (!id)
id = data.id;
if (id !== data.id)
if (id && id !== data.id)
return;

@@ -58,0 +56,0 @@ const mcs = data.messageChannels.map(messageChannel => {

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