@k13engineering/yajrpc 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.d.ts +5 -3
- package/dist/lib/index.js +23 -2
- package/dist/lib/websocket.d.ts +1 -1
- package/dist/lib/websocket.js +6 -0
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createJrpc } from "./jrpc.js";
|
|
2
|
-
import { createWebSocketJrpc } from "./websocket.js";
|
|
2
|
+
import { createWebSocketJrpc, createJsonParser } from "./websocket.js";
|
|
3
3
|
import { createRpcRequestsDefinition } from "./definitions/requests.js";
|
|
4
4
|
import { createRpcNotificationsDefinition } from "./definitions/notification.js";
|
|
5
5
|
import { createCombined } from "./definitions/combined.js";
|
|
6
6
|
import type { TObjectParser } from "./definitions/parser.js";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import type { TWebSocketMessageParser } from "./websocket.js";
|
|
8
|
+
import type { TJrpc, TJsonRpcMessage, TNotificationHandler, TNotifyMethod, TRequestHandler, TRequestResponse, TRequestMethod, TRequestResult } from "./jrpc.js";
|
|
9
|
+
export { createJrpc, createWebSocketJrpc, createJsonParser, createRpcRequestsDefinition, createRpcNotificationsDefinition, createCombined };
|
|
10
|
+
export type { TObjectParser, TWebSocketMessageParser, TJrpc, TJsonRpcMessage, TNotificationHandler, TNotifyMethod, TRequestHandler, TRequestResponse, TRequestMethod, TRequestResult };
|
package/dist/lib/index.js
CHANGED
|
@@ -1,19 +1,40 @@
|
|
|
1
1
|
import { createJrpc } from "./jrpc.js";
|
|
2
|
-
import { createWebSocketJrpc } from "./websocket.js";
|
|
2
|
+
import { createWebSocketJrpc, createJsonParser } from "./websocket.js";
|
|
3
3
|
import { createRpcRequestsDefinition } from "./definitions/requests.js";
|
|
4
4
|
import { createRpcNotificationsDefinition } from "./definitions/notification.js";
|
|
5
5
|
import { createCombined } from "./definitions/combined.js";
|
|
6
6
|
|
|
7
7
|
/*import type { TObjectParser } from "./definitions/parser.ts";*/
|
|
8
|
+
/*import type { TWebSocketMessageParser } from "./websocket.ts";*/
|
|
9
|
+
/*import type {
|
|
10
|
+
TJrpc,
|
|
11
|
+
TJsonRpcMessage,
|
|
12
|
+
TNotificationHandler,
|
|
13
|
+
TNotifyMethod,
|
|
14
|
+
TRequestHandler,
|
|
15
|
+
TRequestResponse,
|
|
16
|
+
TRequestMethod,
|
|
17
|
+
TRequestResult
|
|
18
|
+
} from "./jrpc.ts";*/
|
|
8
19
|
|
|
9
20
|
export {
|
|
10
21
|
createJrpc,
|
|
11
22
|
createWebSocketJrpc,
|
|
23
|
+
createJsonParser,
|
|
12
24
|
createRpcRequestsDefinition,
|
|
13
25
|
createRpcNotificationsDefinition,
|
|
14
26
|
createCombined
|
|
15
27
|
};
|
|
16
28
|
|
|
17
29
|
/*export type {
|
|
18
|
-
TObjectParser
|
|
30
|
+
TObjectParser,
|
|
31
|
+
TWebSocketMessageParser,
|
|
32
|
+
TJrpc,
|
|
33
|
+
TJsonRpcMessage,
|
|
34
|
+
TNotificationHandler,
|
|
35
|
+
TNotifyMethod,
|
|
36
|
+
TRequestHandler,
|
|
37
|
+
TRequestResponse,
|
|
38
|
+
TRequestMethod,
|
|
39
|
+
TRequestResult
|
|
19
40
|
};*/
|
package/dist/lib/websocket.d.ts
CHANGED
|
@@ -32,4 +32,4 @@ declare const createWebSocketJrpc: ({ socket, parser, handleRequest, handleNotif
|
|
|
32
32
|
type TWebsocketJrpcHandle = ReturnType<typeof createWebSocketJrpc>;
|
|
33
33
|
declare const createJsonParser: () => TWebSocketMessageParser;
|
|
34
34
|
export { createWebSocketJrpc, createJsonParser };
|
|
35
|
-
export type { TWebsocketJrpcHandle, };
|
|
35
|
+
export type { TWebsocketJrpcHandle, TWebSocketMessageParser };
|
package/dist/lib/websocket.js
CHANGED
|
@@ -14,6 +14,7 @@ import { createJrpc } from "./index.js";
|
|
|
14
14
|
format: (args: { message: unknown }) => string | Uint8Array;
|
|
15
15
|
};*/
|
|
16
16
|
|
|
17
|
+
// eslint-disable-next-line max-statements
|
|
17
18
|
const createWebSocketJrpc = ({
|
|
18
19
|
socket,
|
|
19
20
|
|
|
@@ -53,6 +54,10 @@ const createWebSocketJrpc = ({
|
|
|
53
54
|
sendQueue = [];
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
socket.addEventListener("open", () => {
|
|
58
|
+
maybeSendNext();
|
|
59
|
+
});
|
|
60
|
+
|
|
56
61
|
const sendOrQueueRawMessage = ({ data }/*: { data: string | Uint8Array }*/) => {
|
|
57
62
|
sendQueue.push(data);
|
|
58
63
|
maybeSendNext();
|
|
@@ -199,4 +204,5 @@ export {
|
|
|
199
204
|
|
|
200
205
|
/*export type {
|
|
201
206
|
TWebsocketJrpcHandle,
|
|
207
|
+
TWebSocketMessageParser
|
|
202
208
|
};*/
|
package/package.json
CHANGED