Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
qwtel committed Aug 13, 2024
1 parent c3b1376 commit 15595c1
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 51 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Publish

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- run: npx jsr publish
14 changes: 14 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@workers/caplink",
"version": "0.0.1",
"exports": {
".": "./src/caplink.ts",
"./node-adapter": "./src/node-adapter.ts"
},
"imports": {
"@workers/typed-event-target": "jsr:@workers/typed-event-target@^1.0.0"
},
"exclude": [
".tests"
]
}
45 changes: 0 additions & 45 deletions package.json

This file was deleted.

9 changes: 6 additions & 3 deletions src/caplink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
messageChannel,
toNative,
adoptNative,
} from "./protocol";
} from "./protocol.ts";

export type { Endpoint, MessageEventTarget, PostMessageWithOrigin };

export const proxyMarker = Symbol("Caplink.proxy");
Expand Down Expand Up @@ -282,10 +283,10 @@ const throwTransferHandler = {
/**
* Allows customizing the serialization of certain values.
*/
export const transferHandlers = new Map<
export const transferHandlers: Map<
string,
TransferHandler<object|Function, unknown>
>([
> = new Map<string, any>([
["proxy", proxyTransferHandler],
["throw", throwTransferHandler],
]);
Expand Down Expand Up @@ -409,6 +410,7 @@ export function expose(
try {
const [wireValue, transfer] = toWireValue.call(ep, returnValue);
wireValue.id = id;
// @ts-ignore
(ev.source ?? ep).postMessage(wireValue, { transfer });
}
catch (err) {
Expand All @@ -419,6 +421,7 @@ export function expose(
[throwMarker]: 0,
});
wireValue.id = id;
// @ts-ignore
(ev.source ?? ep).postMessage(wireValue, { transfer });
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion src/comlink.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './caplink';
export * from './caplink.ts';
2 changes: 1 addition & 1 deletion src/node-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import type { Endpoint } from "./protocol";
import type { Endpoint } from "./protocol.ts";

export interface NodeEndpoint {
postMessage(message: any, transfer?: any[]): void;
Expand Down
2 changes: 1 addition & 1 deletion src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import type { TypedEventTarget } from "@worker-tools/typed-event-target";
import type { TypedEventTarget } from "@workers/typed-event-target";

export type MessageEventTarget = Pick<TypedEventTarget<MessagePortEventMap>, "addEventListener"|"removeEventListener">;

Expand Down

0 comments on commit 15595c1

Please sign in to comment.