libshv-js 3.0.0 → 3.1.0

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.
@@ -17,9 +17,9 @@ jobs:
17
17
  runs-on: ubuntu-22.04
18
18
  steps:
19
19
  - uses: actions/checkout@v3
20
- - uses: denoland/setup-deno@v1
21
- with:
22
- deno-version: vx.x.x
20
+
21
+ - name: Compile
22
+ run: npx tsc
23
23
 
24
24
  - name: Run tests
25
- run: deno run test.ts
25
+ run: node test.js
package/.xo-config.json CHANGED
@@ -23,6 +23,7 @@
23
23
  "n/file-extension-in-import": "off",
24
24
  "promise-function-async": "off",
25
25
  "default-case": "off",
26
+ "import/extensions": "off",
26
27
  "prefer-promise-reject-errors": "off",
27
28
  "eslint-disable-next-line prefer-promise-reject-errors": "off",
28
29
  "unicorn/explicit-length-check": "off",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/src/chainpack.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {utf8ToString} from './cpon.ts';
2
- import {type RpcValue, type RpcValueType, type DateTime, Decimal, Double, IMap, Int, MetaMap, RpcValueWithMetaData, ShvMap, UInt, withOffset} from './rpcvalue.ts';
3
- import {UnpackContext, PackContext} from './cpcontext.ts';
1
+ import {utf8ToString} from './cpon';
2
+ import {type RpcValue, type RpcValueType, type DateTime, Decimal, Double, IMap, Int, MetaMap, RpcValueWithMetaData, ShvMap, UInt, withOffset} from './rpcvalue';
3
+ import {UnpackContext, PackContext} from './cpcontext';
4
4
 
5
5
  enum PackingSchema {
6
6
  IntThreshold = 64,
package/src/cpon.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {type RpcValue, type RpcValueType, type DateTime, type List, Decimal, Double, IMap, Int, MetaMap, RpcValueWithMetaData, ShvMap, UInt, withOffset} from './rpcvalue.ts';
2
- import {PackContext, UnpackContext} from './cpcontext.ts';
1
+ import {type RpcValue, type RpcValueType, type DateTime, type List, Decimal, Double, IMap, Int, MetaMap, RpcValueWithMetaData, ShvMap, UInt, withOffset} from './rpcvalue';
2
+ import {PackContext, UnpackContext} from './cpcontext';
3
3
 
4
4
  const hexify = (byte: number) => {
5
5
  if (byte < 10) {
package/src/rpcmessage.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {IMap, Int, MetaMap, type RpcValue, RpcValueWithMetaData} from './rpcvalue.ts';
2
- import {toCpon} from './cpon.ts';
3
- import {toChainPack} from './chainpack.ts';
1
+ import {IMap, Int, MetaMap, type RpcValue, RpcValueWithMetaData} from './rpcvalue';
2
+ import {toCpon} from './cpon';
3
+ import {toChainPack} from './chainpack';
4
4
 
5
5
  const TagRequestId = 8;
6
6
  const TagShvPath = 9;
package/src/ws-client.ts CHANGED
@@ -1,7 +1,7 @@
1
- import {ChainPackReader, ChainpackProtocolType, ChainPackWriter} from './chainpack.ts';
2
- import {type CponReader, CponProtocolType, toCpon} from './cpon.ts';
3
- import {ERROR_MESSAGE, ErrorCode, ERROR_CODE, RpcError, RpcMessage, type RpcResponse, MethodCallTimeout} from './rpcmessage.ts';
4
- import {type RpcValue, type Null, Int, IMap, ShvMap} from './rpcvalue.ts';
1
+ import {ChainPackReader, ChainpackProtocolType, ChainPackWriter} from './chainpack';
2
+ import {type CponReader, CponProtocolType} from './cpon';
3
+ import {ERROR_MESSAGE, ErrorCode, ERROR_CODE, RpcMessage, type RpcResponse, MethodCallTimeout} from './rpcmessage';
4
+ import {type RpcValue, type Null, Int, IMap, ShvMap} from './rpcvalue';
5
5
 
6
6
  const DEFAULT_TIMEOUT = 5000;
7
7
 
@@ -40,6 +40,7 @@ type WsClientOptions = {
40
40
  timeout?: number;
41
41
  wsUri: string;
42
42
  onConnected: () => void;
43
+ onDisconnected: () => void;
43
44
  onRequest: (rpc_msg: RpcMessage) => void;
44
45
  };
45
46
 
@@ -85,6 +86,7 @@ class WsClient {
85
86
  password: WsClientOptions['password'];
86
87
  loginType: WsClientOptions['loginType'];
87
88
  onConnected: WsClientOptions['onConnected'];
89
+ onDisconnected: WsClientOptions['onDisconnected'];
88
90
  onRequest: WsClientOptions['onRequest'];
89
91
  timeout: WsClientOptions['timeout'];
90
92
 
@@ -104,6 +106,7 @@ class WsClient {
104
106
  this.websocket.binaryType = 'arraybuffer';
105
107
 
106
108
  this.onConnected = options.onConnected ?? (() => {/* nothing */});
109
+ this.onDisconnected = options.onDisconnected ?? (() => {/* nothing */});
107
110
  this.onRequest = options.onRequest ?? (() => {/* nothing */});
108
111
 
109
112
  this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
@@ -132,6 +135,7 @@ class WsClient {
132
135
 
133
136
  this.websocket.addEventListener('close', () => {
134
137
  this.logDebug('DISCONNECTED');
138
+ this.onDisconnected();
135
139
  });
136
140
 
137
141
  this.websocket.addEventListener('message', evt => {
@@ -170,10 +174,6 @@ class WsClient {
170
174
  console.log('WebSocket ERROR', evt);
171
175
  this.logDebug('WebSocket ERROR');
172
176
  });
173
-
174
- this.websocket.addEventListener('close', evt => {
175
- this.logDebug(`socket close code: ${evt.code}`);
176
- });
177
177
  }
178
178
 
179
179
  callRpcMethod(shv_path: string | undefined, method: 'dir', params?: RpcValue): Promise<RpcResponse<DirResult>>;
package/test.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {toChainPack, fromChainPack} from './src/chainpack.ts';
2
- import {toCpon, fromCpon} from './src/cpon.ts';
3
- import {type DateTime} from './src/rpcvalue.ts';
1
+ import {toChainPack, fromChainPack} from './src/chainpack';
2
+ import {toCpon, fromCpon} from './src/cpon';
3
+ import {type DateTime} from './src/rpcvalue';
4
4
 
5
5
  const checkEq = (e1: string | number, e2: string | number) => {
6
6
  if (e1 !== e2) {
package/tsconfig.json CHANGED
@@ -35,7 +35,6 @@
35
35
  // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
36
  // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
37
  // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
38
  // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
39
  // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
40
  // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
@@ -91,8 +90,8 @@
91
90
  // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
92
91
  // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
93
92
  // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
94
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
95
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
93
+ "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
94
+ "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
96
95
  // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
97
96
  // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
98
97
  // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */