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 609bfed
Show file tree
Hide file tree
Showing 27 changed files with 282 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-avocados-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"async-call-rpc": patch
---

publish on jsr registry
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: node ./.github/workflows && npx jsr publish && npx changeset publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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.

2 changes: 2 additions & 0 deletions docs/async-call-rpc.asynccalloptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = un
| --- | --- | --- | --- |
| [channel](./async-call-rpc.asynccalloptions.channel.md) | | [CallbackBasedChannel](./async-call-rpc.callbackbasedchannel.md)<!-- -->&lt;EncodedRequest \| EncodedResponse&gt; \| [EventBasedChannel](./async-call-rpc.eventbasedchannel.md)<!-- -->&lt;EncodedRequest \| EncodedResponse&gt; \| Promise&lt;[CallbackBasedChannel](./async-call-rpc.callbackbasedchannel.md)<!-- -->&lt;EncodedRequest \| EncodedResponse&gt; \| [EventBasedChannel](./async-call-rpc.eventbasedchannel.md)<!-- -->&lt;EncodedRequest \| EncodedResponse&gt;&gt; | The message channel to exchange messages between server and client |
| [encoder?](./async-call-rpc.asynccalloptions.encoder.md) | | [IsomorphicEncoder](./async-call-rpc.isomorphicencoder.md)<!-- -->&lt;EncodedRequest, EncodedResponse&gt; \| [IsomorphicEncoderFull](./async-call-rpc.isomorphicencoderfull.md)<!-- -->&lt;EncodedRequest, EncodedResponse&gt; | _(Optional)_ Encoder of requests and responses. |
| [forceSignal?](./async-call-rpc.asynccalloptions.forcesignal.md) | | [AbortSignalLike](./async-call-rpc.abortsignallike.md) | _(Optional)_ AbortSignal to force stop the instance. |
| [key?](./async-call-rpc.asynccalloptions.key.md) | | string | _(Optional)_ Name used when pretty log is enabled. |
| [log?](./async-call-rpc.asynccalloptions.log.md) | | [AsyncCallLogLevel](./async-call-rpc.asynccallloglevel.md) \| boolean \| 'all' | _(Optional)_ Choose log level. |
| [logger?](./async-call-rpc.asynccalloptions.logger.md) | | [ConsoleInterface](./async-call-rpc.consoleinterface.md) | _(Optional)_ Provide the logger |
Expand All @@ -27,6 +28,7 @@ export interface AsyncCallOptions<EncodedRequest = unknown, EncodedResponse = un
| [parameterStructures?](./async-call-rpc.asynccalloptions.parameterstructures.md) | | 'by-position' \| 'by-name' | _(Optional)_ Choose flavor of parameter structures defined in the spec |
| [preferLocalImplementation?](./async-call-rpc.asynccalloptions.preferlocalimplementation.md) | | boolean | _(Optional)_ Prefer local implementation than remote. |
| [serializer?](./async-call-rpc.asynccalloptions.serializer.md) | | [Serialization](./async-call-rpc.serialization.md) | _(Optional)_ Serializer of the requests and responses. |
| [signal?](./async-call-rpc.asynccalloptions.signal.md) | | [AbortSignalLike](./async-call-rpc.abortsignallike.md) | _(Optional)_ AbortSignal to stop the instance. |
| [strict?](./async-call-rpc.asynccalloptions.strict.md) | | [AsyncCallStrictJSONRPC](./async-call-rpc.asynccallstrictjsonrpc.md) \| boolean | _(Optional)_ Control the behavior that different from the JSON-RPC spec |
| [thenable?](./async-call-rpc.asynccalloptions.thenable.md) | | boolean | _(Optional)_ If the instance is "thenable". |

Expand Down
18 changes: 18 additions & 0 deletions docs/async-call-rpc.asynccalloptions.signal.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; [signal](./async-call-rpc.asynccalloptions.signal.md)

## AsyncCallOptions.signal property

AbortSignal to stop the instance.

**Signature:**

```typescript
signal?: AbortSignalLike;
```

## Remarks

`signal` is used to stop the instance. If the `signal` is aborted, then all new requests will be rejected, except for the pending ones.

1 change: 1 addition & 0 deletions docs/async-call-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ See the introduction at [Github](https://github.com/Jack-Works/async-call)

| Interface | Description |
| --- | --- |
| [AbortSignalLike](./async-call-rpc.abortsignallike.md) | AbortSignal |
| [AsyncCallLogLevel](./async-call-rpc.asynccallloglevel.md) | Log options |
| [AsyncCallOptions](./async-call-rpc.asynccalloptions.md) | Options for [AsyncCall()](./async-call-rpc.asynccall.md) |
| [AsyncCallStrictJSONRPC](./async-call-rpc.asynccallstrictjsonrpc.md) | Strict options |
Expand Down
25 changes: 25 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@jwk/json-rpc",
"version": "{{version}}",
"exports": {
".": "./src/Async-Call.ts",
"./full": "./src/index.ts"
},
"include": ["src/**"],
// https://github.com/jsr-io/jsr/issues/194
"exclude": [
"__tests__",
"docs",
"*.json",
"src/*.json",
"api",
"examples",
"utils-src",
"vite.config.ts",
"index.html",
"*.yaml",
"rollup.config.mjs",
"utils",
"next-docs"
]
}
14 changes: 7 additions & 7 deletions src/Async-Call-Generator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* See the document at https://github.com/Jack-Works/async-call/
*/
import type { AsyncCallOptions } from './types.js'
import { AsyncCall } from './Async-Call.js'
import { AsyncCallIgnoreResponse } from './utils/internalSymbol.js'
import { normalizeStrictOptions } from './utils/normalizeOptions.js'
import { generateRandomID } from './utils/generateRandomID.js'
import { isFunction, isString, setPrototypeOf } from './utils/constants.js'
import type { AsyncCallOptions } from './types.ts'
import { AsyncCall } from './Async-Call.ts'
import { AsyncCallIgnoreResponse } from './utils/internalSymbol.ts'
import { normalizeStrictOptions } from './utils/normalizeOptions.ts'
import { generateRandomID } from './utils/generateRandomID.ts'
import { isFunction, isString, setPrototypeOf } from './utils/constants.ts'
import {
Err_Cannot_find_a_running_iterator_with_given_ID,
Err_Only_string_can_be_the_RPC_method_name,
makeHostedMessage,
} from './utils/error.js'
} from './utils/error.ts'

const i = 'rpc.async-iterator.'
// ! side effect
Expand Down
28 changes: 14 additions & 14 deletions src/Async-Call.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from './types.js'
export type { _IgnoreResponse } from './core/notify.js'
export { JSONSerialization, NoSerialization } from './utils/serialization.js'
export { JSONEncoder, type JSONEncoderOptions } from './utils/encoder.js'
export { notify } from './core/notify.js'
export { batch } from './core/batch.js'
export type * from './types.ts'
export type { _IgnoreResponse } from './core/notify.ts'
export { JSONSerialization, NoSerialization } from './utils/serialization.ts'
export { JSONEncoder, type JSONEncoderOptions } from './utils/encoder.ts'
export { notify } from './core/notify.ts'
export { batch } from './core/batch.ts'

import {
makeRequest,
Expand All @@ -14,19 +14,19 @@ import {
ErrorResponseMethodNotFound,
ErrorResponseInvalidRequest,
ErrorResponseParseError,
} from './utils/jsonrpc.js'
} from './utils/jsonrpc.ts'
import {
removeStackHeader,
RecoverError,
makeHostedMessage,
Err_Cannot_call_method_starts_with_rpc_dot_directly,
Err_Then_is_accessed_on_local_implementation_Please_explicitly_mark_if_it_is_thenable_in_the_options,
onAbort,
} from './utils/error.js'
import { generateRandomID } from './utils/generateRandomID.js'
import { normalizeStrictOptions, normalizeLogOptions } from './utils/normalizeOptions.js'
import { AsyncCallIgnoreResponse, AsyncCallNotify, AsyncCallBatch } from './utils/internalSymbol.js'
import type { BatchQueue } from './core/batch.js'
} from './utils/error.ts'
import { generateRandomID } from './utils/generateRandomID.ts'
import { normalizeStrictOptions, normalizeLogOptions } from './utils/normalizeOptions.ts'
import { AsyncCallIgnoreResponse, AsyncCallNotify, AsyncCallBatch } from './utils/internalSymbol.ts'
import type { BatchQueue } from './core/batch.ts'
import type {
CallbackBasedChannel,
EventBasedChannel,
Expand All @@ -41,8 +41,8 @@ import type {
IsomorphicEncoder,
Requests,
Responses,
} from './types.js'
import { apply, ERROR, isArray, isFunction, isObject, isString, Promise_resolve, undefined } from './utils/constants.js'
} from './types.ts'
import { apply, ERROR, isArray, isFunction, isObject, isString, Promise_resolve, undefined } from './utils/constants.ts'

/**
* Create a RPC server & client.
Expand Down
Loading

0 comments on commit 609bfed

Please sign in to comment.