libshv-js 7.1.0 → 7.1.2

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/cpon.d.ts CHANGED
@@ -22,7 +22,7 @@ declare class CponReader {
22
22
  }
23
23
  declare class CponWriter {
24
24
  private readonly indentString?;
25
- private oneLiners;
25
+ private readonly oneLiners;
26
26
  ctx: PackContext;
27
27
  nestLevel: number;
28
28
  constructor(indentString?: string | undefined, oneLiners?: OneLiners);
package/dist/json.js CHANGED
@@ -4,6 +4,7 @@ exports.toJson = exports.fromJson = void 0;
4
4
  const cpcontext_1 = require("./cpcontext");
5
5
  const cpon_1 = require("./cpon");
6
6
  const rpcvalue_1 = require("./rpcvalue");
7
+ // eslint-disable-next-line @typescript-eslint/no-restricted-types
7
8
  const decodeMap = (x) => (0, rpcvalue_1.makeMap)(Object.fromEntries(Object.entries(x).map(([key, value]) => [key, decodeValueJson(value)])));
8
9
  const decodeValueJson = (x) => {
9
10
  switch (true) {
@@ -104,7 +105,6 @@ const encodeValueJson = (x) => {
104
105
  case x instanceof Date:
105
106
  return [JSON_TAG_TYPE, 'DateTime', (0, cpon_1.stringifyDate)(x)];
106
107
  case x === undefined:
107
- // eslint-disable-next-line unicorn/no-null
108
108
  return null;
109
109
  case x instanceof rpcvalue_1.Decimal:
110
110
  case x instanceof rpcvalue_1.UInt:
@@ -1,4 +1,4 @@
1
- import { Double, IMap, MetaMap, RpcValue, type RpcValueWithMetaData } from './rpcvalue';
1
+ import { type Double, type IMap, type MetaMap, type RpcValue, type RpcValueWithMetaData } from './rpcvalue';
2
2
  export declare const RPC_MESSAGE_REQUEST_ID = 8;
3
3
  export declare const RPC_MESSAGE_SHV_PATH = 9;
4
4
  export declare const RPC_MESSAGE_METHOD = 10;
package/dist/rpcvalue.js CHANGED
@@ -48,10 +48,13 @@ const withOffset = (date, utcOffset) => {
48
48
  exports.withOffset = withOffset;
49
49
  const shvMapType = Symbol('shvMapType');
50
50
  exports.shvMapType = shvMapType;
51
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
51
52
  const isShvMap = (x) => typeof x === 'object' && x[shvMapType] === 'map';
52
53
  exports.isShvMap = isShvMap;
54
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
53
55
  const isIMap = (x) => typeof x === 'object' && x[shvMapType] === 'imap';
54
56
  exports.isIMap = isIMap;
57
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
55
58
  const isMetaMap = (x) => typeof x === 'object' && x[shvMapType] === 'metamap';
56
59
  exports.isMetaMap = isMetaMap;
57
60
  const typeName = (x) => {
@@ -73,16 +76,19 @@ const typeName = (x) => {
73
76
  }
74
77
  };
75
78
  exports.typeName = typeName;
79
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
76
80
  const makeMetaMap = (x = {}) => ({
77
81
  ...x,
78
82
  [shvMapType]: 'metamap',
79
83
  });
80
84
  exports.makeMetaMap = makeMetaMap;
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
81
86
  const makeIMap = (x = {}) => ({
82
87
  ...x,
83
88
  [shvMapType]: 'imap',
84
89
  });
85
90
  exports.makeIMap = makeIMap;
91
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
86
92
  const makeMap = (x = {}) => ({
87
93
  ...x,
88
94
  [shvMapType]: 'map',
package/dist/shv-ri.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare class ShvRI {
2
- private ri;
3
- private methodSepIx;
4
- private signalSepIx?;
2
+ static fromPathMethodSignal(path: string, method: string, signal?: string): ShvRI;
3
+ private readonly ri;
4
+ private readonly methodSepIx;
5
+ private readonly signalSepIx?;
5
6
  constructor(ri: string);
6
7
  path(): string;
7
8
  method(): string;
8
9
  signal(): string | undefined;
9
10
  hasSignal(): boolean;
10
11
  asString(): string;
11
- static fromPathMethodSignal(path: string, method: string, signal?: string): ShvRI;
12
12
  }
package/dist/shv-ri.js CHANGED
@@ -2,6 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShvRI = void 0;
4
4
  class ShvRI {
5
+ static fromPathMethodSignal(path, method, signal) {
6
+ const m = method.length === 0 ? '*' : method;
7
+ const ri = signal !== undefined
8
+ ? `${path}:${m}:${signal}`
9
+ : `${path}:${m}`;
10
+ return new ShvRI(ri);
11
+ }
5
12
  ri;
6
13
  methodSepIx;
7
14
  signalSepIx;
@@ -44,12 +51,5 @@ class ShvRI {
44
51
  asString() {
45
52
  return this.ri;
46
53
  }
47
- static fromPathMethodSignal(path, method, signal) {
48
- const m = method.length === 0 ? '*' : method;
49
- const ri = signal !== undefined
50
- ? `${path}:${m}:${signal}`
51
- : `${path}:${m}`;
52
- return new ShvRI(ri);
53
- }
54
54
  }
55
55
  exports.ShvRI = ShvRI;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ShvRI } from './shv-ri';
1
+ import { type ShvRI } from './shv-ri';
2
2
  export type StringGetter = string | Promise<string> | (() => string | Promise<string>);
3
3
  export declare const resolveString: (input: StringGetter) => string | Promise<string>;
4
4
  export type RIGetter = ShvRI | Promise<ShvRI> | (() => ShvRI | Promise<ShvRI>);
@@ -1,6 +1,6 @@
1
1
  import { type RpcMessage, type RpcRequest, type ErrorMap } from './rpcmessage';
2
2
  import { type RpcValue, type Null, type Int, type IMap, type ShvMap } from './rpcvalue';
3
- import { RIGetter } from './utils';
3
+ import { type RIGetter } from './utils';
4
4
  type SubscriptionCallback = (path: string, signal: string, param?: RpcValue) => void;
5
5
  type ResultOrError<T = RpcValue> = T | Error;
6
6
  type Login = {
@@ -218,8 +218,8 @@ declare class WsClient {
218
218
  private requestId;
219
219
  private pingTimerId;
220
220
  private rpcHandlers;
221
- private requestHandlers;
222
- private abortedRequests;
221
+ private readonly requestHandlers;
222
+ private readonly abortedRequests;
223
223
  private readonly subscriptions;
224
224
  private readonly websocket;
225
225
  private readonly options;
package/dist/ws-client.js CHANGED
@@ -11,6 +11,7 @@ const DEFAULT_TIMEOUT = 5000;
11
11
  const DEFAULT_PING_INTERVAL = 30 * 1000;
12
12
  const defaultParseMessage = (rpcVal) => {
13
13
  // Assume rpcVal is a valid RpcMessage - no runtime validation
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
14
15
  const rpcMsg = rpcVal;
15
16
  return rpcMsg;
16
17
  };
@@ -179,13 +180,13 @@ class WsClient {
179
180
  };
180
181
  if (rpcmessage_1.RPC_MESSAGE_ABORT in request.value) {
181
182
  const requestHandler = this.requestHandlers.get(requestId);
182
- if (request.value[rpcmessage_1.RPC_MESSAGE_ABORT] === true) {
183
+ if (request.value[rpcmessage_1.RPC_MESSAGE_ABORT]) {
183
184
  this.abortedRequests.add(requestId);
184
185
  if (requestHandler?.options.onAbort !== undefined) {
185
186
  requestHandler.options.onAbort();
186
187
  }
187
188
  }
188
- if (request.value[rpcmessage_1.RPC_MESSAGE_ABORT] === false && requestHandler?.options.onProgressQuery !== undefined) {
189
+ if (!request.value[rpcmessage_1.RPC_MESSAGE_ABORT] && requestHandler?.options.onProgressQuery !== undefined) {
189
190
  const progress = requestHandler.options.onProgressQuery();
190
191
  sendDelay(progress instanceof Promise ? await progress : progress);
191
192
  }
@@ -352,10 +353,11 @@ class WsClient {
352
353
  return new exports.NotImplemented(`Got an RpcResponse with unsupported keys: ${rpcMessageKeys.join(' ')}`);
353
354
  }
354
355
  })());
355
- // eslint-disable-next-line @typescript-eslint/no-array-delete
356
+ // eslint-disable-next-line @typescript-eslint/no-array-delete, @typescript-eslint/no-dynamic-delete
356
357
  delete this.rpcHandlers[Number(requestId)];
357
358
  }
358
359
  };
360
+ // eslint-disable-next-line @typescript-eslint/strict-void-return
359
361
  this.websocket.addEventListener('message', async (evt) => {
360
362
  const rpcVal = dataToRpcValue(evt.data);
361
363
  const parseMessage = this.options.parseMessage ?? defaultParseMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "7.1.0",
3
+ "version": "7.1.2",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,10 +40,10 @@
40
40
  "@typescript-eslint/parser": "^8.56.1",
41
41
  "@eslint/js": "^10.0.1",
42
42
  "eslint": "^10.0.0",
43
- "eslint-config-xo": "^0.50.0",
43
+ "eslint-config-xo": "^0.51.0",
44
44
  "eslint-formatter-unix": "^9.0.1",
45
- "eslint-plugin-unicorn": "^63.0.0",
46
- "typescript": "^5.9.3",
45
+ "eslint-plugin-unicorn": "^64.0.0",
46
+ "typescript": "^6.0.2",
47
47
  "typescript-eslint": "^8.46.1"
48
48
  }
49
49
  }