Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependencies #1017

Closed
wants to merge 9 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"@typescript-eslint/no-use-before-define": ["error", { "classes": false, "enums": false }],

"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "error"
"@typescript-eslint/explicit-module-boundary-types": "error",

"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-duplicate-enum-values": "off"
}
}
1,022 changes: 709 additions & 313 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"debug": "^4.3.4",
"fast-srp-hap": "^2.0.4",
"futoin-hkdf": "^1.5.3",
"node-persist": "^0.0.11",
"node-persist": "^4.0.1",
"source-map-support": "^0.5.21",
"tslib": "^2.6.2",
"tweetnacl": "^1.0.3"
Expand All @@ -67,21 +67,23 @@
"@types/debug": "^4.1.12",
"@types/escape-html": "^1.0.4",
"@types/jest": "^29.5.12",
"@types/node": "^10.17.60",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"axios": "^0.28.1",
"commander": "^6.2.1",
"@types/node": "^20.12.7",
"@types/node-persist": "^3.1.8",
"@types/plist": "^3.0.5",
"@types/source-map-support": "^0.5.10",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"axios": "^1.6.8",
"commander": "^12.0.0",
"escape-html": "^1.0.3",
"eslint": "^8.57.0",
"http-parser-js": "^0.5.8",
"jest": "^29.7.0",
"rimraf": "^3.0.2",
"semver": "^7.6.0",
"simple-plist": "~1.1.1",
"rimraf": "^5.0.5",
"simple-plist": "^2.0.0-rc.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.13",
"typescript": "^4.9.5"
"typescript": "^5.4.5"
}
}
4 changes: 2 additions & 2 deletions src/accessories/AirConditioner_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ACTest
.setCharacteristic(Characteristic.Manufacturer, "Sample Company");

// listen for the "identify" event for this Accessory
ACTest.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
ACTest.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
console.log("Fan Identified!");
callback(); // success
});
Expand All @@ -60,7 +60,7 @@ FanService.getCharacteristic(Characteristic.On)!
callback(); // Our fake Fan is synchronous - this value has been successfully set
});

// We want to intercept requests for our current power state so we can query the hardware itself instead of
// We want to intercept requests for our current power state, so we can query the hardware itself instead of
// allowing HAP-NodeJS to return the cached Characteristic.value.
FanService.getCharacteristic(Characteristic.On)!
.on(CharacteristicEventTypes.GET, (callback: CharacteristicGetCallback) => {
Expand Down
8 changes: 4 additions & 4 deletions src/accessories/AppleTVRemote_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ const controller = siriSupport
remote.configureController(controller);

/*
This example plugin exposes an simple http api to interact with the remote and play around.
This example plugin exposes a simple http api to interact with the remote and play around.
The supported routes are listed below. The http server runs on port 8080 as default.
This example should not be used except for testing as the http server is unsecured.

/listTargets - list all currently configured apple tvs and their respective configuration
/getActiveTarget - return the current target id of the controlled device
/getActive - get the value of the active characteristic (active means the apple tv for the activeTarget is listening)
/getActive - get the value of the active characteristic (active means the Apple TV for the activeTarget is listening)

/press?button=<buttonId>&time=<timeInMS> - presses a given button for a given time. Time is optional and defaults to 200ms
/button?button=<buttonId>&state=<stateId> - send a single button event
/getTargetId?name=<name of apple TV> - get the target identifier for the given name of the apple tv
/setActiveTarget?identifier=<id> - set currently controlled apple tv
/getTargetId?name=<name of Apple TV> - get the target identifier for the given name of the Apple TV
/setActiveTarget?identifier=<id> - set currently controlled Apple TV
*/

http.createServer((request, response) => {
Expand Down
6 changes: 3 additions & 3 deletions src/accessories/Camera_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ class MP4StreamingServer {
console.error("ChildProcess is undefined directly after the init!");
}
if(this.debugMode) {
this.childProcess.stdout.on("data", data => console.log(data.toString()));
this.childProcess.stderr.on("data", data => console.log(data.toString()));
this.childProcess.stdout?.on("data", data => console.log(data.toString()));
this.childProcess.stderr?.on("data", data => console.log(data.toString()));
}
}

Expand Down Expand Up @@ -554,7 +554,7 @@ class MP4StreamingServer {
while (true) {
const header = await this.read(8);
const length = header.readInt32BE(0) - 8;
const type = header.slice(4).toString();
const type = header.subarray(4).toString();
const data = await this.read(length);

yield {
Expand Down
4 changes: 2 additions & 2 deletions src/accessories/Fan_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fan
.setCharacteristic(Characteristic.Manufacturer, "Sample Company");

// listen for the "identify" event for this Accessory
fan.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
fan.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
FAKE_FAN.identify();
callback(); // success
});
Expand All @@ -63,7 +63,7 @@ fan
FAKE_FAN.setPowerOn(value);
});

// We want to intercept requests for our current power state so we can query the hardware itself instead of
// We want to intercept requests for our current power state, so we can query the hardware itself instead of
// allowing HAP-NodeJS to return the cached Characteristic.value.
fan
.getService(Service.Fan)!
Expand Down
4 changes: 2 additions & 2 deletions src/accessories/GarageDoorOpener_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ garage
.setCharacteristic(Characteristic.Model, "Rev-1")
.setCharacteristic(Characteristic.SerialNumber, "TW000165");

garage.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
garage.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
FAKE_GARAGE.identify();
callback();
});

garage
.addService(Service.GarageDoorOpener, "Garage Door")
.setCharacteristic(Characteristic.TargetDoorState, Characteristic.TargetDoorState.CLOSED) // force initial state to CLOSED
.setCharacteristic(Characteristic.TargetDoorState, Characteristic.TargetDoorState.CLOSED) // force initial state to 'CLOSED'
.getCharacteristic(Characteristic.TargetDoorState)!
.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {

Expand Down
2 changes: 1 addition & 1 deletion src/accessories/Light_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ lightAccessory
.setCharacteristic(Characteristic.SerialNumber, LightController.serialNumber);

// listen for the "identify" event for this Accessory
lightAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
lightAccessory.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
LightController.identify();
callback();
});
Expand Down
8 changes: 4 additions & 4 deletions src/accessories/Lock_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lock
.setCharacteristic(Characteristic.SerialNumber, "MY-Serial-Number");

// listen for the "identify" event for this Accessory
lock.on(AccessoryEventTypes.IDENTIFY, (paired, callback) => {
lock.on(AccessoryEventTypes.IDENTIFY, (_paired, callback) => {
FAKE_LOCK.identify();
callback(); // success
});
Expand All @@ -62,18 +62,18 @@ service.getCharacteristic(Characteristic.LockTargetState)
FAKE_LOCK.unlock();
callback(); // Our fake Lock is synchronous - this value has been successfully set

// now we want to set our lock's "actual state" to be unsecured so it shows as unlocked in iOS apps
// now we want to set our lock's "actual state" to be unsecured, so it shows as unlocked in iOS apps
service.updateCharacteristic(Characteristic.LockCurrentState, Characteristic.LockCurrentState.UNSECURED);
} else if (value === Characteristic.LockTargetState.SECURED) {
FAKE_LOCK.lock();
callback(); // Our fake Lock is synchronous - this value has been successfully set

// now we want to set our lock's "actual state" to be locked so it shows as open in iOS apps
// now we want to set our lock's "actual state" to be locked, so it shows as open in iOS apps
service.updateCharacteristic(Characteristic.LockCurrentState, Characteristic.LockCurrentState.SECURED);
}
});

// We want to intercept requests for our current state so we can query the hardware itself instead of
// We want to intercept requests for our current state, so we can query the hardware itself instead of
// allowing HAP-NodeJS to return the cached Characteristic.value.
service.getCharacteristic(Characteristic.LockCurrentState)
.on(CharacteristicEventTypes.GET, callback => {
Expand Down
2 changes: 1 addition & 1 deletion src/accessories/MotionSensor_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ motionSensor
.setCharacteristic(Characteristic.SerialNumber, "A1S2NASF88EW");

// listen for the "identify" event for this Accessory
motionSensor.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
motionSensor.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
MOTION_SENSOR.identify();
callback(); // success
});
Expand Down
4 changes: 2 additions & 2 deletions src/accessories/Outlet_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ outlet
.setCharacteristic(Characteristic.SerialNumber, "A1S2NASF88EW");

// listen for the "identify" event for this Accessory
outlet.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
outlet.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
FAKE_OUTLET.identify();
callback(); // success
});
Expand All @@ -74,7 +74,7 @@ outlet
callback(); // Our fake Outlet is synchronous - this value has been successfully set
});

// We want to intercept requests for our current power state so we can query the hardware itself instead of
// We want to intercept requests for our current power state, so we can query the hardware itself instead of
// allowing HAP-NodeJS to return the cached Characteristic.value.
outlet
.getService(Service.Outlet)!
Expand Down
2 changes: 1 addition & 1 deletion src/accessories/Wi-FiRouter_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ accessory.username = "FA:3C:ED:D2:1A:A2";
accessory.pincode = "031-45-154";
accessory.category = Categories.ROUTER;

accessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
accessory.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
console.log("Identify the '%s'", accessory.displayName);
callback();
});
Expand Down
2 changes: 1 addition & 1 deletion src/accessories/Wi-FiSatellite_accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ accessory.username = "FA:3C:ED:5A:1A:A2";
accessory.pincode = "031-45-154";
accessory.category = Categories.ROUTER;

accessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
accessory.on(AccessoryEventTypes.IDENTIFY, (_paired: boolean, callback: VoidCallback) => {
console.log("Identify the '%s'", accessory.displayName);
callback();
});
Expand Down
8 changes: 4 additions & 4 deletions src/accessories/gstreamer-audioProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class GStreamerAudioProducer implements SiriAudioStreamProducer {
debug("Failed to kill gstreamer process: " + error.message);
}
});
this.process.stdout.on("data", (data: Buffer) => {
this.process.stdout?.on("data", (data: Buffer) => {
if (!this.running) { // received data after it was closed
return;
}
Expand All @@ -140,16 +140,16 @@ export class GStreamerAudioProducer implements SiriAudioStreamProducer {
Opus relies on the container format to specify the length of the frame.
Although sometimes multiple opus frames are squashed together the decoder seems to be able
to handle that as it just creates a not very noticeable distortion.
If we would want to make this perfect we would need to write a nodejs c++ submodule or something
If we wanted to make this perfect we would need to write a Node.js c++ submodule or something
to interface directly with gstreamer api.
*/

this.frameHandler({
data: data,
rms: 0.25, // only way currently to extract rms from gstreamer is by interfacing with the api directly (nodejs c++ submodule could be a solution)
rms: 0.25, // only way currently to extract rms from gstreamer is by interfacing with the api directly (Node.js c++ submodule could be a solution)
});
});
this.process.stderr.on("data", data => {
this.process.stderr?.on("data", data => {
debug("GStreamer process reports the following error: " + String(data));
});
this.process.on("exit", (code, signal) => {
Expand Down
Loading
Loading