Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
surma authored Nov 6, 2019
2 parents 8bd0c3a + d1389fc commit 3280e68
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 198 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM selenium/node-chrome:latest@sha256:17f4829220384811bbe2d0a50c1c3f517159969c2aef3087defce9246deb38d9
FROM selenium/node-chrome:latest@sha256:ad2dd5e4ba1059b41beebfda2e11ecb5eda9a426983b3e32cdbcac27fe6df73f

USER root

Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,17 @@ Each function parameter and return value is given to _all_ registered transfer h
Comlink.transferHandlers.set("EVENT", {
canHandle: obj => obj instanceof Event,
serialize: ev => {
return [{
target: {
id: ev.target.id,
classList: [...ev.target.classList]
}
}, []];
return [
{
target: {
id: ev.target.id,
classList: [...ev.target.classList]
}
},
[]
];
},
deserialize: obj => obj,
deserialize: obj => obj
});
```

Expand All @@ -173,6 +176,10 @@ const port = myProxy[Comlink.createEndpoint]();
const newProxy = Comlink.wrap(port);
```

## TypeScript

Comlink does provide TypeScript types. When you `expose()` something of type `T`, the corresponding `wrap()` call will return something of type `Comlink.Remote<T>`. While this type has been battle-tested over some time now, it is implemented on a best-effort basis. There are some nuances that are incredibly hard if not impossible to encode correctly in TypeScript’s type system. It _may_ sometimes be necessary to force a certain type using `as unknown as <type>`.

## Node

Comlink works with Node’s [`worker_threads`][worker_threads] module. Take a look at the example in the `docs` folder.
Expand Down
10 changes: 8 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ module.exports = function(config) {
if (process.env.INSIDE_DOCKER) {
return ["DockerChrome"];
} else if (process.env.CHROME_ONLY) {
return ["ChromeHeadless"];
return ["SafariTechPreview"];
} else {
return availableBrowsers;
// Filtering SafariTechPreview because I am having
// local issues and I have no idea how to fix them.
// I know that’s not a good reason to disable tests,
// but Safari TP is relatively unimportant.
return availableBrowsers.filter(
browser => browser !== "SafariTechPreview"
);
}
}
},
Expand Down
Loading

0 comments on commit 3280e68

Please sign in to comment.