Skip to content

Commit

Permalink
Support OffscreenCanvas (fixes #165)
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Oct 4, 2018
1 parent 1d27bcd commit d9b5e55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion comlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export interface TransferHandler {
deserialize: (obj: {}) => {};
}

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

const proxyValueSymbol = Symbol("proxyValue");
Expand Down
3 changes: 2 additions & 1 deletion dist/comlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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);
const proxyValueSymbol = Symbol("proxyValue");
const throwSymbol = Symbol("throw");
Expand Down
3 changes: 2 additions & 1 deletion dist/umd/comlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ else {factory([], self.Comlink={});}
})(function (require, exports) {
"use strict";
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);
const proxyValueSymbol = Symbol("proxyValue");
const throwSymbol = Symbol("throw");
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/05-service-worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const obj = {
}
};

self.addEventListener('message', (event) => {
self.addEventListener("message", event => {
if (event.data.comlinkInit) {
Comlink.expose(obj, event.data.port);
return;
Expand Down

0 comments on commit d9b5e55

Please sign in to comment.