@socket-mesh/client 18.1.4 → 18.1.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/client-auth-engine.d.ts +7 -7
- package/dist/client-auth-engine.js +15 -12
- package/dist/client-channels.d.ts +12 -12
- package/dist/client-channels.js +75 -72
- package/dist/client-socket-options.d.ts +18 -15
- package/dist/client-socket-options.js +1 -1
- package/dist/client-socket.d.ts +11 -10
- package/dist/client-socket.js +18 -14
- package/dist/client-transport.d.ts +27 -29
- package/dist/client-transport.js +72 -53
- package/dist/handlers/index.d.ts +4 -4
- package/dist/handlers/index.js +4 -4
- package/dist/handlers/kickout.d.ts +7 -6
- package/dist/handlers/kickout.js +1 -3
- package/dist/handlers/publish.d.ts +7 -7
- package/dist/handlers/publish.js +1 -1
- package/dist/handlers/remove-auth-token.d.ts +1 -1
- package/dist/handlers/set-auth-token.d.ts +3 -3
- package/dist/handlers/set-auth-token.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/maps/client-map.d.ts +8 -17
- package/dist/maps/index.d.ts +2 -3
- package/dist/maps/index.js +2 -3
- package/dist/maps/server-map.d.ts +11 -11
- package/dist/plugins/batching-plugin.d.ts +18 -18
- package/dist/plugins/batching-plugin.js +32 -16
- package/dist/plugins/in-order-plugin.d.ts +6 -6
- package/dist/plugins/in-order-plugin.js +30 -28
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.js +3 -3
- package/dist/plugins/offline-plugin.d.ts +7 -7
- package/dist/plugins/offline-plugin.js +27 -21
- package/package.json +42 -40
- package/dist/maps/socket-map.d.ts +0 -17
- package/dist/maps/socket-map.js +0 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { WritableConsumableStream } from
|
|
1
|
+
import { WritableConsumableStream } from '@socket-mesh/writable-consumable-stream';
|
|
2
2
|
export class InOrderPlugin {
|
|
3
|
-
|
|
3
|
+
_inboundMessageStream;
|
|
4
|
+
type;
|
|
5
|
+
// private readonly _outboundMessageStream: WritableConsumableStream<SendRequestPluginArgs<T>>;
|
|
4
6
|
constructor() {
|
|
5
7
|
this._inboundMessageStream = new WritableConsumableStream();
|
|
6
|
-
//this._outboundMessageStream = new WritableConsumableStream<SendRequestPluginArgs<T>>;
|
|
8
|
+
// this._outboundMessageStream = new WritableConsumableStream<SendRequestPluginArgs<T>>;
|
|
7
9
|
this.handleInboundMessageStream();
|
|
8
|
-
//this.handleOutboundMessageStream();
|
|
10
|
+
// this.handleOutboundMessageStream();
|
|
9
11
|
}
|
|
10
12
|
handleInboundMessageStream() {
|
|
11
13
|
(async () => {
|
|
12
|
-
for await (
|
|
14
|
+
for await (const { callback, message, promise } of this._inboundMessageStream) {
|
|
13
15
|
callback(null, message);
|
|
14
16
|
try {
|
|
15
17
|
await promise;
|
|
@@ -21,36 +23,36 @@ export class InOrderPlugin {
|
|
|
21
23
|
})();
|
|
22
24
|
}
|
|
23
25
|
/*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cont(requests);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
reqCol.listen(() => {
|
|
37
|
-
resolve();
|
|
38
|
-
});
|
|
39
|
-
|
|
26
|
+
handleOutboundMessageStream(): void {
|
|
27
|
+
(async () => {
|
|
28
|
+
for await (let { requests, cont } of this._outboundMessageStream) {
|
|
29
|
+
await new Promise<void>((resolve) => {
|
|
30
|
+
const reqCol = new RequestCollection(requests);
|
|
31
|
+
|
|
32
|
+
if (reqCol.isDone()) {
|
|
33
|
+
resolve();
|
|
40
34
|
cont(requests);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
reqCol.listen(() => {
|
|
39
|
+
resolve();
|
|
41
40
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
|
|
42
|
+
cont(requests);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
}
|
|
47
|
+
*/
|
|
46
48
|
onEnd({ transport }) {
|
|
47
49
|
if (transport.streamCleanupMode === 'close') {
|
|
48
50
|
this._inboundMessageStream.close();
|
|
49
|
-
//this._outboundMessageStream.close();
|
|
51
|
+
// this._outboundMessageStream.close();
|
|
50
52
|
}
|
|
51
53
|
else if (transport.streamCleanupMode === 'kill') {
|
|
52
54
|
this._inboundMessageStream.kill();
|
|
53
|
-
//this._outboundMessageStream.kill();
|
|
55
|
+
// this._outboundMessageStream.kill();
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
onMessageRaw(options) {
|
|
@@ -64,7 +66,7 @@ export class InOrderPlugin {
|
|
|
64
66
|
resolve(data);
|
|
65
67
|
};
|
|
66
68
|
});
|
|
67
|
-
this._inboundMessageStream.write({ callback, ...options });
|
|
69
|
+
this._inboundMessageStream.write({ callback: callback, ...options });
|
|
68
70
|
return promise;
|
|
69
71
|
}
|
|
70
72
|
}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './batching-plugin.js';
|
|
2
|
+
export * from './in-order-plugin.js';
|
|
3
|
+
export * from './offline-plugin.js';
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './batching-plugin.js';
|
|
2
|
+
export * from './in-order-plugin.js';
|
|
3
|
+
export * from './offline-plugin.js';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class OfflinePlugin<
|
|
1
|
+
import { MethodMap, Plugin, PrivateMethodMap, PublicMethodMap, SendRequestPluginArgs, ServiceMap } from '@socket-mesh/core';
|
|
2
|
+
export declare class OfflinePlugin<TIncoming extends MethodMap, TOutgoing extends PublicMethodMap, TPrivateOutgoing extends PrivateMethodMap, TService extends ServiceMap, TState extends object> implements Plugin<TIncoming, TOutgoing, TPrivateOutgoing, TService, TState> {
|
|
3
|
+
private _continue;
|
|
3
4
|
private _isReady;
|
|
4
5
|
private _requests;
|
|
5
|
-
|
|
6
|
+
type: 'offline';
|
|
6
7
|
constructor();
|
|
7
|
-
|
|
8
|
-
sendRequest({ requests, cont }: SendRequestPluginArgs<T>): void;
|
|
9
|
-
onReady(): void;
|
|
8
|
+
private flush;
|
|
10
9
|
onClose(): void;
|
|
11
10
|
onDisconnected(): void;
|
|
12
|
-
|
|
11
|
+
onReady(): void;
|
|
12
|
+
sendRequest({ cont, requests }: SendRequestPluginArgs<TIncoming, TOutgoing, TPrivateOutgoing, TService, TState>): void;
|
|
13
13
|
}
|
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
const SYSTEM_METHODS = ['#handshake', '#removeAuthToken'];
|
|
2
2
|
export class OfflinePlugin {
|
|
3
|
+
_continue;
|
|
4
|
+
_isReady;
|
|
5
|
+
_requests;
|
|
6
|
+
type;
|
|
3
7
|
constructor() {
|
|
4
8
|
this.type = 'offline';
|
|
5
9
|
this._isReady = false;
|
|
6
10
|
this._requests = [];
|
|
7
11
|
this._continue = null;
|
|
8
12
|
}
|
|
9
|
-
|
|
13
|
+
flush() {
|
|
14
|
+
if (this._requests.length) {
|
|
15
|
+
if (this._continue) {
|
|
16
|
+
for (const reqs of this._requests) {
|
|
17
|
+
this._continue(reqs);
|
|
18
|
+
}
|
|
19
|
+
this._continue = null;
|
|
20
|
+
}
|
|
21
|
+
this._requests = [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
onClose() {
|
|
25
|
+
this._isReady = false;
|
|
26
|
+
}
|
|
27
|
+
onDisconnected() {
|
|
28
|
+
this._requests = [];
|
|
29
|
+
this._continue = null;
|
|
30
|
+
}
|
|
31
|
+
onReady() {
|
|
32
|
+
this._isReady = true;
|
|
33
|
+
this.flush();
|
|
34
|
+
}
|
|
35
|
+
sendRequest({ cont, requests }) {
|
|
10
36
|
if (this._isReady) {
|
|
11
37
|
cont(requests);
|
|
12
38
|
return;
|
|
@@ -24,24 +50,4 @@ export class OfflinePlugin {
|
|
|
24
50
|
cont(systemRequests);
|
|
25
51
|
}
|
|
26
52
|
}
|
|
27
|
-
onReady() {
|
|
28
|
-
this._isReady = true;
|
|
29
|
-
this.flush();
|
|
30
|
-
}
|
|
31
|
-
onClose() {
|
|
32
|
-
this._isReady = false;
|
|
33
|
-
}
|
|
34
|
-
onDisconnected() {
|
|
35
|
-
this._requests = [];
|
|
36
|
-
this._continue = null;
|
|
37
|
-
}
|
|
38
|
-
flush() {
|
|
39
|
-
if (this._requests.length) {
|
|
40
|
-
for (const reqs of this._requests) {
|
|
41
|
-
this._continue(reqs);
|
|
42
|
-
}
|
|
43
|
-
this._requests = [];
|
|
44
|
-
this._continue = null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
53
|
}
|
package/package.json
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socket-mesh/client",
|
|
3
3
|
"description": "A TCP socket pair for easily transmitting full messages without worrying about request size limits.",
|
|
4
|
-
"version": "18.1.
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
"version": "18.1.6",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": ["./dist"],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
"browser": {
|
|
10
|
+
"ws": "./lib/ws-browser.js"
|
|
11
|
+
},
|
|
12
12
|
"author": {
|
|
13
13
|
"name": "Greg Kimmy"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
|
|
16
|
+
"build": "node ../../scripts/build.mjs && tsc --project tsconfig.build.json",
|
|
17
17
|
"bundle": "rollup --config ./rollup.config.js",
|
|
18
|
-
|
|
19
|
-
"
|
|
18
|
+
"deploy": "node ../../scripts/publish.mjs",
|
|
19
|
+
"lint": "eslint . --c ../../eslint.config.mjs",
|
|
20
|
+
"lint:fix": "eslint . --c ../../eslint.config.mjs --fix",
|
|
21
|
+
"test": "tsx --tsconfig ./tsconfig.build.json --test ./src/**/*.{spec,test}.ts ./test/**/*.{spec,test}.ts"
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/socket-mesh/client-server.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
26
28
|
"url": "https://github.com/socket-mesh/client-server/labels/client"
|
|
27
|
-
|
|
29
|
+
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@kineticcafe/rollup-plugin-delete": "
|
|
30
|
-
"@rollup/plugin-alias": "
|
|
31
|
-
"@rollup/plugin-commonjs": "
|
|
32
|
-
"@rollup/plugin-node-resolve": "
|
|
33
|
-
"@rollup/plugin-terser": "
|
|
34
|
-
"@rollup/plugin-typescript": "
|
|
35
|
-
"@socket-mesh/
|
|
36
|
-
"@socket-mesh/
|
|
37
|
-
"@types/clone-deep": "
|
|
38
|
-
"@types/jsonwebtoken": "
|
|
39
|
-
"@types/ws": "
|
|
40
|
-
"jsonwebtoken": "
|
|
41
|
-
"rollup": "
|
|
42
|
-
"rollup-plugin-dts": "
|
|
43
|
-
"tslib": "
|
|
31
|
+
"@kineticcafe/rollup-plugin-delete": "catalog:rollup",
|
|
32
|
+
"@rollup/plugin-alias": "catalog:rollup",
|
|
33
|
+
"@rollup/plugin-commonjs": "catalog:rollup",
|
|
34
|
+
"@rollup/plugin-node-resolve": "catalog:rollup",
|
|
35
|
+
"@rollup/plugin-terser": "catalog:rollup",
|
|
36
|
+
"@rollup/plugin-typescript": "catalog:rollup",
|
|
37
|
+
"@socket-mesh/typescript-config": "workspace:^",
|
|
38
|
+
"@socket-mesh/writable-consumable-stream": "workspace:^",
|
|
39
|
+
"@types/clone-deep": "catalog:clone-deep",
|
|
40
|
+
"@types/jsonwebtoken": "catalog:json-web-token",
|
|
41
|
+
"@types/ws": "catalog:ws",
|
|
42
|
+
"jsonwebtoken": "catalog:json-web-token",
|
|
43
|
+
"rollup": "catalog:rollup",
|
|
44
|
+
"rollup-plugin-dts": "catalog:rollup",
|
|
45
|
+
"tslib": "catalog:"
|
|
44
46
|
},
|
|
45
47
|
"dependencies": {
|
|
46
|
-
"@socket-mesh/async-stream-emitter": "
|
|
47
|
-
"@socket-mesh/auth": "
|
|
48
|
-
"@socket-mesh/channels": "
|
|
49
|
-
"@socket-mesh/core": "
|
|
50
|
-
"@socket-mesh/errors": "
|
|
51
|
-
"@socket-mesh/formatter": "
|
|
52
|
-
|
|
53
|
-
"events": "
|
|
54
|
-
"isomorphic-ws": "
|
|
55
|
-
"ws": "
|
|
48
|
+
"@socket-mesh/async-stream-emitter": "workspace:^",
|
|
49
|
+
"@socket-mesh/auth": "workspace:^",
|
|
50
|
+
"@socket-mesh/channels": "workspace:^",
|
|
51
|
+
"@socket-mesh/core": "workspace:^",
|
|
52
|
+
"@socket-mesh/errors": "workspace:^",
|
|
53
|
+
"@socket-mesh/formatter": "workspace:^",
|
|
54
|
+
"buffer": "catalog:",
|
|
55
|
+
"events": "catalog:",
|
|
56
|
+
"isomorphic-ws": "catalog:ws",
|
|
57
|
+
"ws": "catalog:ws"
|
|
56
58
|
},
|
|
57
59
|
"keywords": [
|
|
58
60
|
"ncom",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ClientMap, ClientPrivateMap } from "./client-map.js";
|
|
2
|
-
import { PublicMethodMap } from "@socket-mesh/core";
|
|
3
|
-
import { ServerPrivateMap } from "./server-map.js";
|
|
4
|
-
export interface SocketMapFromClient<T extends ClientMap> {
|
|
5
|
-
Incoming: T['Incoming'] & ClientPrivateMap;
|
|
6
|
-
Service: T['Service'];
|
|
7
|
-
Outgoing: T['Outgoing'];
|
|
8
|
-
PrivateOutgoing: T['PrivateOutgoing'] & ServerPrivateMap;
|
|
9
|
-
State: T['State'];
|
|
10
|
-
}
|
|
11
|
-
export interface BasicSocketMapClient<TOutgoing extends PublicMethodMap = {}, TState extends object = {}> {
|
|
12
|
-
Incoming: ClientPrivateMap;
|
|
13
|
-
Service: {};
|
|
14
|
-
Outgoing: TOutgoing;
|
|
15
|
-
PrivateOutgoing: ServerPrivateMap;
|
|
16
|
-
State: TState;
|
|
17
|
-
}
|
package/dist/maps/socket-map.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|