Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
with:
fetch-depth: 2
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 20.x
node-version: 24.x
cache: 'npm'
- run: npm install --frozen-lockfile
- run: npm run build
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/release-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 20.x
node-version: 24.x
cache: 'npm'
- run: npm install --frozen-lockfile
- run: npm run build
- name: Configure NPM to use token
run:
echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" >> .npmrc
- name: Run Changeset Workflow
uses: s0/changesets-action@63d3e3fda2c00696414ca2d6683e046289c13fd8 # v2.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
with:
publish: npm run changeset publish
createGithubReleases: true
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @s0/node-tcnet

## 0.5.1

### Patch Changes

- 663a2a9: Allow simpler logger implementations

## 0.5.0

### Minor Changes
Expand Down
147 changes: 2 additions & 145 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@s0/node-tcnet",
"version": "0.5.0",
"version": "0.5.1",
"description": "Implements the TC-Supply TCNet protocol used by ShowKontrol and ProDJLink Bridge app from Pioneer",
"exports": {
".": {
Expand Down Expand Up @@ -36,7 +36,6 @@
"@typescript-eslint/parser": "^4.22.1",
"check-export-map": "^1.3.1",
"eslint": "^7.30.0",
"pino": "^9.5.0",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"tsup": "^8.3.5",
Expand All @@ -46,14 +45,6 @@
"dependencies": {
"broadcast-address": "^1.0.2"
},
"peerDependencies": {
"pino": "^9.5.0"
},
"peerDependenciesMeta": {
"pino": {
"optional": true
}
},
"publishConfig": {
"access": "public",
"provenance": true
Expand Down
19 changes: 13 additions & 6 deletions src/tcnet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Socket, createSocket, RemoteInfo } from "dgram";
import EventEmitter = require("events");
import type { Logger } from "pino";
import * as nw from "./network";
import { interfaceAddress } from "./utils";

Expand All @@ -9,8 +8,13 @@ const TCNET_TIMESTAMP_PORT = 60001;

type STORED_RESOLVE = (value?: nw.TCNetDataPacket | PromiseLike<nw.TCNetDataPacket> | undefined) => void;

export type TCNetLogger = {
error: (error: Error) => void;
debug: (message: string) => void;
};

export class TCNetConfiguration {
logger: Logger | null = null;
logger: TCNetLogger | null = null;
unicastPort = 65032;
applicationCode = 0xffff;
nodeId = Math.floor(Math.random() * 0xffff);
Expand Down Expand Up @@ -63,7 +67,7 @@ export class TCNetClient extends EventEmitter {
this.config.brodcastListeningAddress ||= this.config.broadcastAddress;
}

public get log(): Logger | null {
public get log(): TCNetLogger | null {
return this.config.logger;
}

Expand Down Expand Up @@ -118,7 +122,9 @@ export class TCNetClient extends EventEmitter {
promisifyBasicFunction(() => this.unicastSocket.close()),
])
.catch((err) => {
this.log?.error(err);
const error = new Error("Error disconnecting from TCNet");
error.cause = err instanceof Error ? err : new Error(String(err));
this.log?.error(error);
})
.then(() => void 0);
}
Expand Down Expand Up @@ -156,8 +162,9 @@ export class TCNetClient extends EventEmitter {

if (packet.length() !== -1 && packet.length() !== header.buffer.length) {
this.log?.debug(
`Packet has the wrong length (expected: ${packet.length()}, received: ${header.buffer.length})`,
header,
`${
nw.TCNetMessageType[header.messageType]
} packet has the wrong length (expected: ${packet.length()}, received: ${header.buffer.length})`,
);
return null;
}
Expand Down
Loading