incyclist-devices 3.0.1 → 3.0.3

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.
@@ -50,7 +50,6 @@ class DirectConnectInterface extends node_events_1.default {
50
50
  }
51
51
  constructor(props) {
52
52
  super();
53
- console.log('# New Wifi Interface', props);
54
53
  this.props = props;
55
54
  this.logEnabled = props.log || true;
56
55
  const { binding } = props;
@@ -352,7 +352,6 @@ class DirectConnectPeripheral {
352
352
  const { address, port } = this.announcement;
353
353
  try {
354
354
  const net = this.getBinding().net;
355
- console.log('# net Binding ', this.getBinding().net);
356
355
  this.socket = net.createSocket();
357
356
  return new Promise((resolve, reject) => {
358
357
  this.socket.once('timeout', () => {
@@ -1,7 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.useSerialPortProvider = void 0;
4
- const stream_1 = require("@serialport/stream");
37
+ const _Stream = __importStar(require("@serialport/stream"));
38
+ const { SerialPortStream } = _Stream;
5
39
  const DEFAULT_BAUD_RATE = 9600;
6
40
  class SerialPortProvider {
7
41
  static _instance;
@@ -36,7 +70,7 @@ class SerialPortProvider {
36
70
  props.autoOpen = false;
37
71
  if (!props.baudRate)
38
72
  props.baudRate = DEFAULT_BAUD_RATE;
39
- return new stream_1.SerialPortStream(props);
73
+ return new SerialPortStream(props);
40
74
  }
41
75
  const legacy = this.getLegacyInfo(ifaceName);
42
76
  if (legacy && legacy.Serialport) {
@@ -1,7 +1,37 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.FileTimeSupport = exports.BikeType = exports.ReservedCommands = exports.validatePath = exports.validateHost = exports.DEBUG_LOGGER = void 0;
7
37
  exports.responseLog = responseLog;
@@ -19,7 +49,7 @@ exports.parseTrainingData = parseTrainingData;
19
49
  exports.getPersonData = getPersonData;
20
50
  exports.parsePersonData = parsePersonData;
21
51
  const index_js_1 = require("../../../types/index.js");
22
- const win32filetime_1 = __importDefault(require("win32filetime"));
52
+ const FileTime = __importStar(require("win32filetime"));
23
53
  const sum = (arr) => arr.reduce((a, b) => a + b, 0);
24
54
  exports.DEBUG_LOGGER = {
25
55
  log: (e, ...args) => console.log(e, ...args),
@@ -224,8 +254,8 @@ function getBikeType(bikeTypeStr) {
224
254
  return BikeType.RACE;
225
255
  }
226
256
  exports.FileTimeSupport = {
227
- fromCurrentDate: () => win32filetime_1.default.fromUnix(Date.now()),
228
- fromDate: (date) => win32filetime_1.default.fromUnix(date),
257
+ fromCurrentDate: () => FileTime.fromUnix(Date.now()),
258
+ fromDate: (date) => FileTime.fromUnix(date),
229
259
  };
230
260
  function routeToEpp(route, date) {
231
261
  const buffer = Buffer.alloc(376 + route.points.length * 12);
@@ -44,7 +44,6 @@ export default class DirectConnectInterface extends EventEmitter {
44
44
  }
45
45
  constructor(props) {
46
46
  super();
47
- console.log('# New Wifi Interface', props);
48
47
  this.props = props;
49
48
  this.logEnabled = props.log || true;
50
49
  const { binding } = props;
@@ -346,7 +346,6 @@ export class DirectConnectPeripheral {
346
346
  const { address, port } = this.announcement;
347
347
  try {
348
348
  const net = this.getBinding().net;
349
- console.log('# net Binding ', this.getBinding().net);
350
349
  this.socket = net.createSocket();
351
350
  return new Promise((resolve, reject) => {
352
351
  this.socket.once('timeout', () => {
@@ -1,4 +1,5 @@
1
- import { SerialPortStream } from '@serialport/stream';
1
+ import * as _Stream from '@serialport/stream';
2
+ const { SerialPortStream } = _Stream;
2
3
  const DEFAULT_BAUD_RATE = 9600;
3
4
  export default class SerialPortProvider {
4
5
  static _instance;
@@ -1,5 +1,5 @@
1
1
  import { Gender } from "../../../types/index.js";
2
- import FileTime from 'win32filetime';
2
+ import * as FileTime from 'win32filetime';
3
3
  const sum = (arr) => arr.reduce((a, b) => a + b, 0);
4
4
  export const DEBUG_LOGGER = {
5
5
  log: (e, ...args) => console.log(e, ...args),
@@ -1,8 +1,8 @@
1
1
  import { EventLogger } from "gd-eventlog";
2
2
  import SerialInterface from "./serial-interface.js";
3
- import { SerialCommProps } from "../types.js";
4
- import { SerialPortStream } from "@serialport/stream";
3
+ import { SerialCommProps, SerialPortStream } from "../types.js";
5
4
  import { Queue } from "../../utils/utils.js";
5
+ import { Duplex } from "node:stream";
6
6
  export type ConnectionState = 'Connecting' | 'Connected' | 'Disconnected' | 'Disconnecting';
7
7
  export type Request = {
8
8
  logString?: string;
@@ -19,7 +19,7 @@ export default class SerialPortComms<T extends CommsState, C extends Request, R
19
19
  protected props: SerialCommProps;
20
20
  protected sp: SerialPortStream;
21
21
  protected connectState: ConnectionState;
22
- protected connectPromise: Promise<SerialPortStream>;
22
+ protected connectPromise: Promise<Duplex>;
23
23
  protected disconnectPromise: Promise<boolean>;
24
24
  protected writePromise: Promise<void>;
25
25
  protected sendCmdPromise: Promise<R>;
@@ -1,7 +1,6 @@
1
1
  import EventEmitter from "node:events";
2
2
  import { BindingInterface } from "@serialport/bindings-interface";
3
- import { SerialPortStream } from '@serialport/stream';
4
- import { SerialDeviceSettings, SerialScannerProps, PortMapping, SerialInterfaceProps } from "../types.js";
3
+ import { SerialDeviceSettings, SerialScannerProps, PortMapping, SerialInterfaceProps, SerialPortStream } from "../types.js";
5
4
  import { DeviceSettings, IncyclistInterface } from "../../types/index.js";
6
5
  import { EventLogger } from "gd-eventlog";
7
6
  export default class SerialInterface extends EventEmitter implements IncyclistInterface {
@@ -1,8 +1,17 @@
1
1
  import { EventLogger } from "gd-eventlog";
2
2
  import { BindingInterface } from "@serialport/bindings-interface";
3
- import { SerialPortStream } from "@serialport/stream";
4
3
  import { DeviceSettings, IncyclistScanProps, InterfaceProps } from "../types/index.js";
5
4
  import SerialInterface from "./base/serial-interface.js";
5
+ import { Duplex } from "node:stream";
6
+ export interface SerialPortStream extends Duplex {
7
+ open(callback?: (err: Error | null) => void): void;
8
+ close(callback?: (err: Error | null) => void): void;
9
+ flush(callback?: (err: Error | null) => void): void;
10
+ drain(callback?: (err: Error | null) => void): void;
11
+ set?(options: any, callback?: (err: Error | null) => void): void;
12
+ update?(options: any, callback?: (err: Error | null) => void): void;
13
+ isOpen: boolean;
14
+ }
6
15
  export type SerialCommProps = {
7
16
  serial: SerialInterface;
8
17
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "scripts": {
5
5
  "lint": "eslint . --ext .ts",
6
6
  "build": "npm run build:esm && npm run build:cjs",
@@ -31,7 +31,7 @@
31
31
  "@serialport/binding-mock": "^10.2.2",
32
32
  "@serialport/bindings-cpp": "^13.0.1",
33
33
  "@stoprocent/noble": "^2.3.10",
34
- "@types/node": "^25.0.10",
34
+ "@types/node": "^25.1.0",
35
35
  "@typescript-eslint/eslint-plugin": "^8.54.0",
36
36
  "@typescript-eslint/parser": "^8.54.0",
37
37
  "@vitest/coverage-v8": "^4.0.18",
@@ -39,7 +39,7 @@
39
39
  "eslint": "^9.39.2",
40
40
  "protoc": "^33.4.0",
41
41
  "ts-node": "^10.9.2",
42
- "typescript": "^5.9.2",
42
+ "typescript": "^5.9.3",
43
43
  "vitest": "^4.0.18"
44
44
  },
45
45
  "files": [