Skip to content

Commit

Permalink
chore: publish on jsr registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Mar 5, 2024
1 parent 42fbdbe commit fc4b575
Show file tree
Hide file tree
Showing 28 changed files with 350 additions and 107 deletions.
7 changes: 7 additions & 0 deletions .github/publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { readFile, writeFile } from 'node:fs/promises'

const jsr_path = new URL('../jsr.json', import.meta.url)
const jsr = await readFile(jsr_path, 'utf8')
const { version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))

await writeFile(jsr_path, jsr.replace('{{version}}', version), 'utf8')
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- run: pnpm run doc:api
- uses: changesets/action@v1
with:
publish: npx changeset publish
publish: pnpm run ci:release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
128 changes: 67 additions & 61 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,94 @@
# Changelog

## 6.4.1

### Patch Changes

- 609bfed: publish on jsr registry

## 6.4.0

### Minor Changes

- fd34f22: add a new `encoder` option and deprecate the old `serializer` option

how to migrate:

```ts
// before
const options = {
channel,
serializer: {
serialization(data) { return ... },
deserialization(data) { return ... },
},
}

// after
const options = {
channel,
encoder: {
encode(data) { return ... },
decode(data) { return ... },
},
}
```

```ts
// before
const options = {
channel,
serializer: NoSerialization,
};
- fd34f22: add a new `encoder` option and deprecate the old `serializer` option

// after
const options = {
channel,
};
```
how to migrate:

```ts
// before
const options = {
```ts
// before
const options = {
channel,
serializer: JSONSerialization(),
};

// after
const options = {
serializer: {
serialization(data) { return ... },
deserialization(data) { return ... },
},
}

// after
const options = {
channel,
encoder: JSONEncoder(),
};
```
encoder: {
encode(data) { return ... },
decode(data) { return ... },
},
}
```

```ts
// before
const options = {
channel,
serializer: NoSerialization,
};

// after
const options = {
channel,
};
```

```ts
// before
const options = {
channel,
serializer: JSONSerialization(),
};

// after
const options = {
channel,
encoder: JSONEncoder(),
};
```

- fd34f22: `hint` added to the `CallbackBasedChannel.setup(jsonRPCHandlerCallback)` and `EventBasedChannel.on(listener)`.
- fd34f22: `hint` added to the `CallbackBasedChannel.setup(jsonRPCHandlerCallback)` and `EventBasedChannel.on(listener)`.

For an isomorphic instance of `AsyncCall` (used as both a server and a client),
when a new message comes, it does not clear if to call `decodeRequest` or `decodeRespones`.
For an isomorphic instance of `AsyncCall` (used as both a server and a client),
when a new message comes, it does not clear if to call `decodeRequest` or `decodeRespones`.

This version introduces a new option `encoder` to replace `serialization`. `serialization` is always working in isomorphic way.
This version introduces a new option `encoder` to replace `serialization`. `serialization` is always working in isomorphic way.

- If `hint` is `"request"`, `(encoder as ServerEncoding).decodeRequest` will be called first, if this method does not exist, `(encoder as IsomorphicEncoder).decode` will be called.
- If `hint` is `"response"`, `(encoder as ClientEncoding).decodeResponse` will be called first, if this method does not exist, `(encoder as IsomorphicEncoder).decode` will be called.
- If `hint` is not present, only `encoder.decode` will be called.
- If `hint` is `"request"`, `(encoder as ServerEncoding).decodeRequest` will be called first, if this method does not exist, `(encoder as IsomorphicEncoder).decode` will be called.
- If `hint` is `"response"`, `(encoder as ClientEncoding).decodeResponse` will be called first, if this method does not exist, `(encoder as IsomorphicEncoder).decode` will be called.
- If `hint` is not present, only `encoder.decode` will be called.

- 0d0900b: rename "key" to "name"
- 0d0900b: rename "key" to "name"

- fd34f22: `BSON_Serialization` and `Msgpack_Serialization` is now deprecated
- fd34f22: `BSON_Serialization` and `Msgpack_Serialization` is now deprecated

- 0431c15: rename `AsyncCallStrictJSONRPC` to `AsyncCallStrictOptions`
- 0431c15: rename `AsyncCallStrictJSONRPC` to `AsyncCallStrictOptions`

- 8a38d8b: add `signal` and `forceSignal` to stop the instance
- 8a38d8b: add `signal` and `forceSignal` to stop the instance

- c9bbbd2: rename `parameterStructures` to `parameterStructure`
- c9bbbd2: rename `parameterStructures` to `parameterStructure`

- fd34f22: expose JSON-RPC interfaces
- fd34f22: expose JSON-RPC interfaces

- fd34f22: new built-in `JSONEncoder` for the new encode option.
- fd34f22: new built-in `JSONEncoder` for the new encode option.

### Patch Changes

- fd34f22: Add `Promise<void>` into return signature of `EventBasedChannel.send`
- fd34f22: Add `Promise<void>` into return signature of `EventBasedChannel.send`

## 6.3.1

Expand Down
18 changes: 18 additions & 0 deletions api/base.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
```ts

// @public
export interface AbortSignalLike {
// (undocumented)
readonly aborted: boolean;
// (undocumented)
addEventListener(type: 'abort', listener: () => void, options: {
once: boolean;
}): void;
// (undocumented)
reason: any;
// (undocumented)
removeEventListener(type: 'abort', listener: () => void): void;
// (undocumented)
throwIfAborted(): void;
}

// @public
export function AsyncCall<OtherSideImplementedFunctions = {}>(thisSideImplementation: null | undefined | object | Promise<object>, options: AsyncCallOptions): AsyncVersionOf<OtherSideImplementedFunctions>;

Expand All @@ -21,6 +37,7 @@ export interface AsyncCallLogLevel {
export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = unknown> {
channel: CallbackBasedChannel<EncodedRequest | EncodedResponse> | EventBasedChannel<EncodedRequest | EncodedResponse> | Promise<CallbackBasedChannel<EncodedRequest | EncodedResponse> | EventBasedChannel<EncodedRequest | EncodedResponse>>;
encoder?: IsomorphicEncoder<EncodedRequest, EncodedResponse> | IsomorphicEncoderFull<EncodedRequest, EncodedResponse>;
forceSignal?: AbortSignalLike;
idGenerator?(): string | number;
// @deprecated
key?: string;
Expand All @@ -34,6 +51,7 @@ export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = un
preferLocalImplementation?: boolean;
// @deprecated
serializer?: Serialization;
signal?: AbortSignalLike;
strict?: AsyncCallStrictJSONRPC | boolean;
thenable?: boolean;
}
Expand Down
18 changes: 18 additions & 0 deletions api/full.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
```ts

// @public
export interface AbortSignalLike {
// (undocumented)
readonly aborted: boolean;
// (undocumented)
addEventListener(type: 'abort', listener: () => void, options: {
once: boolean;
}): void;
// (undocumented)
reason: any;
// (undocumented)
removeEventListener(type: 'abort', listener: () => void): void;
// (undocumented)
throwIfAborted(): void;
}

// @public
export function AsyncCall<OtherSideImplementedFunctions = {}>(thisSideImplementation: null | undefined | object | Promise<object>, options: AsyncCallOptions): AsyncVersionOf<OtherSideImplementedFunctions>;

Expand All @@ -21,6 +37,7 @@ export interface AsyncCallLogLevel {
export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = unknown> {
channel: CallbackBasedChannel<EncodedRequest | EncodedResponse> | EventBasedChannel<EncodedRequest | EncodedResponse> | Promise<CallbackBasedChannel<EncodedRequest | EncodedResponse> | EventBasedChannel<EncodedRequest | EncodedResponse>>;
encoder?: IsomorphicEncoder<EncodedRequest, EncodedResponse> | IsomorphicEncoderFull<EncodedRequest, EncodedResponse>;
forceSignal?: AbortSignalLike;
idGenerator?(): string | number;
// @deprecated
key?: string;
Expand All @@ -34,6 +51,7 @@ export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = un
preferLocalImplementation?: boolean;
// @deprecated
serializer?: Serialization;
signal?: AbortSignalLike;
strict?: AsyncCallStrictJSONRPC | boolean;
thenable?: boolean;
}
Expand Down
11 changes: 11 additions & 0 deletions docs/async-call-rpc.abortsignallike.aborted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md) &gt; [aborted](./async-call-rpc.abortsignallike.aborted.md)

## AbortSignalLike.aborted property

**Signature:**

```typescript
readonly aborted: boolean;
```
26 changes: 26 additions & 0 deletions docs/async-call-rpc.abortsignallike.addeventlistener.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md) &gt; [addEventListener](./async-call-rpc.abortsignallike.addeventlistener.md)

## AbortSignalLike.addEventListener() method

**Signature:**

```typescript
addEventListener(type: 'abort', listener: () => void, options: {
once: boolean;
}): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| type | 'abort' | |
| listener | () =&gt; void | |
| options | { once: boolean; } | |

**Returns:**

void

33 changes: 33 additions & 0 deletions docs/async-call-rpc.abortsignallike.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md)

## AbortSignalLike interface

AbortSignal

**Signature:**

```typescript
export interface AbortSignalLike
```

## Remarks

This is a subset of the AbortSignal interface defined in the \[WinterCG\](https://wintercg.org/).

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [aborted](./async-call-rpc.abortsignallike.aborted.md) | <code>readonly</code> | boolean | |
| [reason](./async-call-rpc.abortsignallike.reason.md) | | any | |

## Methods

| Method | Description |
| --- | --- |
| [addEventListener(type, listener, options)](./async-call-rpc.abortsignallike.addeventlistener.md) | |
| [removeEventListener(type, listener)](./async-call-rpc.abortsignallike.removeeventlistener.md) | |
| [throwIfAborted()](./async-call-rpc.abortsignallike.throwifaborted.md) | |

11 changes: 11 additions & 0 deletions docs/async-call-rpc.abortsignallike.reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md) &gt; [reason](./async-call-rpc.abortsignallike.reason.md)

## AbortSignalLike.reason property

**Signature:**

```typescript
reason: any;
```
23 changes: 23 additions & 0 deletions docs/async-call-rpc.abortsignallike.removeeventlistener.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md) &gt; [removeEventListener](./async-call-rpc.abortsignallike.removeeventlistener.md)

## AbortSignalLike.removeEventListener() method

**Signature:**

```typescript
removeEventListener(type: 'abort', listener: () => void): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| type | 'abort' | |
| listener | () =&gt; void | |

**Returns:**

void

15 changes: 15 additions & 0 deletions docs/async-call-rpc.abortsignallike.throwifaborted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AbortSignalLike](./async-call-rpc.abortsignallike.md) &gt; [throwIfAborted](./async-call-rpc.abortsignallike.throwifaborted.md)

## AbortSignalLike.throwIfAborted() method

**Signature:**

```typescript
throwIfAborted(): void;
```
**Returns:**

void

18 changes: 18 additions & 0 deletions docs/async-call-rpc.asynccalloptions.forcesignal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [async-call-rpc](./async-call-rpc.md) &gt; [AsyncCallOptions](./async-call-rpc.asynccalloptions.md) &gt; [forceSignal](./async-call-rpc.asynccalloptions.forcesignal.md)

## AsyncCallOptions.forceSignal property

AbortSignal to force stop the instance.

**Signature:**

```typescript
forceSignal?: AbortSignalLike;
```

## Remarks

`signal` is used to stop the instance. If the `signal` is aborted, then all new requests will be rejected, and the pending requests will be forcibly rejected and pending results will be ignored.

Loading

0 comments on commit fc4b575

Please sign in to comment.