@camera.ui/sdk 0.0.3 → 0.0.5
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/README.md +2 -2
- package/dist/camera/events.js +2 -0
- package/dist/camera/index.js +3 -1
- package/dist/external.js +7 -0
- package/dist/index.d.ts +7132 -4248
- package/dist/index.js +3 -11
- package/dist/internal/contract-validators.js +21 -0
- package/dist/internal/index.d.ts +915 -0
- package/dist/internal/index.js +9 -0
- package/dist/internal/sensor-triggers.js +2 -0
- package/dist/internal/shared-utils.js +86 -0
- package/dist/internal/streaming-internal.js +1 -0
- package/dist/manager/index.js +1 -1
- package/dist/observable/index.js +419 -0
- package/dist/plugin/api.js +21 -0
- package/dist/plugin/contract.js +101 -114
- package/dist/plugin/helper.js +277 -0
- package/dist/plugin/index.js +4 -1
- package/dist/plugin/interfaces.js +51 -1
- package/dist/plugin/notifier.js +23 -0
- package/dist/plugin/oauth.js +1 -0
- package/dist/sensor/audio.js +103 -81
- package/dist/sensor/base.js +350 -318
- package/dist/sensor/battery.js +73 -59
- package/dist/sensor/classifier.js +117 -0
- package/dist/sensor/clip.js +30 -0
- package/dist/sensor/contact.js +37 -18
- package/dist/sensor/detection.js +4 -0
- package/dist/sensor/doorbell.js +52 -38
- package/dist/sensor/face.js +71 -86
- package/dist/sensor/garage.js +121 -0
- package/dist/sensor/humidity.js +52 -0
- package/dist/sensor/index.js +17 -11
- package/dist/sensor/leak.js +52 -0
- package/dist/sensor/licensePlate.js +70 -79
- package/dist/sensor/light.js +82 -38
- package/dist/sensor/lock.js +99 -0
- package/dist/sensor/motion.js +85 -70
- package/dist/sensor/object.js +73 -94
- package/dist/sensor/occupancy.js +52 -0
- package/dist/sensor/ptz.js +114 -100
- package/dist/sensor/securitySystem.js +98 -0
- package/dist/sensor/siren.js +75 -43
- package/dist/sensor/smoke.js +52 -0
- package/dist/sensor/spec.js +1 -0
- package/dist/sensor/switch.js +72 -0
- package/dist/sensor/temperature.js +52 -0
- package/dist/storage/index.js +1 -2
- package/dist/types.js +1 -0
- package/package.json +36 -23
- package/CHANGELOG.md +0 -8
- package/CONTRIBUTING.md +0 -1
- package/LICENSE.md +0 -22
- package/dist/sensor/guards.js +0 -133
- package/dist/sensor/types.js +0 -46
- package/dist/service/base.js +0 -96
- package/dist/service/index.js +0 -3
- package/tsconfig.node.json +0 -30
- /package/dist/camera/{types.js → enums.js} +0 -0
- /package/dist/{manager/types.js → camera/frames.js} +0 -0
- /package/dist/{plugin/types.js → internal/camera-config-internal.js} +0 -0
- /package/dist/{service/services.js → internal/camera-enums.js} +0 -0
- /package/dist/{service/types.js → internal/camera-wire.js} +0 -0
- /package/dist/{storage/schema.js → internal/manager-rpc.js} +0 -0
- /package/dist/{storage/storages.js → internal/sensor-rpc.js} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Sensor, SensorType, SensorCategory } from './base.js';
|
|
2
|
+
/**
|
|
3
|
+
* Properties for switch controls
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export var SwitchProperty;
|
|
8
|
+
(function (SwitchProperty) {
|
|
9
|
+
/** Whether the switch is on */
|
|
10
|
+
SwitchProperty["On"] = "on";
|
|
11
|
+
})(SwitchProperty || (SwitchProperty = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Generic on/off switch control. Override `setOn()` / `setOff()` to drive
|
|
14
|
+
* hardware and call `await super.setOn()` / `await super.setOff()` after
|
|
15
|
+
* success to sync the SDK state. For hardware-pushed updates, call the `super`
|
|
16
|
+
* methods from your event handler.
|
|
17
|
+
*/
|
|
18
|
+
export class SwitchControl extends Sensor {
|
|
19
|
+
type = SensorType.Switch;
|
|
20
|
+
category = SensorCategory.Control;
|
|
21
|
+
constructor(name = 'Switch') {
|
|
22
|
+
super(name);
|
|
23
|
+
this._writeState({ [SwitchProperty.On]: false });
|
|
24
|
+
}
|
|
25
|
+
get on() {
|
|
26
|
+
return this.props.on;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Turn the switch on. Override to drive hardware and call `await super.setOn()`
|
|
30
|
+
* after success to sync the SDK state.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* await sw.setOn();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
async setOn() {
|
|
38
|
+
this._writeState({ [SwitchProperty.On]: true });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Turn the switch off. Override to drive hardware and call `await super.setOff()`
|
|
42
|
+
* after success to sync the SDK state.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* await sw.setOff();
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async setOff() {
|
|
50
|
+
this._writeState({ [SwitchProperty.On]: false });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Cross-process consumer entry point. Dispatches writable properties
|
|
54
|
+
* to semantic methods so plugin overrides (hardware actions) are honored.
|
|
55
|
+
* Unknown properties are ignored — only `On` is externally writable.
|
|
56
|
+
*
|
|
57
|
+
* @param property - Property name to write.
|
|
58
|
+
*
|
|
59
|
+
* @param value - New value for the property.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
async updateValue(property, value) {
|
|
64
|
+
if (property === SwitchProperty.On) {
|
|
65
|
+
if (value)
|
|
66
|
+
await this.setOn();
|
|
67
|
+
else
|
|
68
|
+
await this.setOff();
|
|
69
|
+
}
|
|
70
|
+
// Unknown / non-writable property — ignored.
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Sensor, SensorType, SensorCategory } from './base.js';
|
|
2
|
+
/**
|
|
3
|
+
* Properties for temperature sensors
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export var TemperatureProperty;
|
|
8
|
+
(function (TemperatureProperty) {
|
|
9
|
+
/** Current temperature in degrees Celsius */
|
|
10
|
+
TemperatureProperty["Current"] = "current";
|
|
11
|
+
})(TemperatureProperty || (TemperatureProperty = {}));
|
|
12
|
+
/** Temperature info sensor. Reports current temperature in °C. */
|
|
13
|
+
export class TemperatureInfo extends Sensor {
|
|
14
|
+
type = SensorType.Temperature;
|
|
15
|
+
category = SensorCategory.Info;
|
|
16
|
+
constructor(name = 'Temperature') {
|
|
17
|
+
super(name);
|
|
18
|
+
this._writeState({ [TemperatureProperty.Current]: 20 });
|
|
19
|
+
}
|
|
20
|
+
get current() {
|
|
21
|
+
return this.props.current;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Report a new temperature reading. Clamped to [-270, 100] °C.
|
|
25
|
+
*
|
|
26
|
+
* @param value - Temperature reading in degrees Celsius.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* temperature.setCurrent(21.5);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
setCurrent(value) {
|
|
34
|
+
this._writeState({ [TemperatureProperty.Current]: Math.max(-270, Math.min(100, value)) });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read-only sensor: external writes are ignored. Reading via `setCurrent` is plugin-only.
|
|
38
|
+
*
|
|
39
|
+
* Called by the cross-process plugin host when a generic property write is received.
|
|
40
|
+
* Temperature sensors have no externally writable properties, so the parameters are
|
|
41
|
+
* unused (underscore-prefixed) and the call is a no-op.
|
|
42
|
+
*
|
|
43
|
+
* @param _property - Unused — temperature sensors expose no writable properties.
|
|
44
|
+
*
|
|
45
|
+
* @param _value - Unused — temperature sensors expose no writable properties.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
updateValue(_property, _value) {
|
|
50
|
+
// No-op — temperature is reported by the plugin, not set externally.
|
|
51
|
+
}
|
|
52
|
+
}
|
package/dist/storage/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './storages.js';
|
|
1
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,58 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "camera.ui sdk",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"require": "./dist/index.js",
|
|
9
9
|
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./internal": {
|
|
12
|
+
"types": "./dist/internal/index.d.ts",
|
|
13
|
+
"require": "./dist/internal/index.js",
|
|
14
|
+
"default": "./dist/internal/index.js"
|
|
10
15
|
}
|
|
11
16
|
},
|
|
12
17
|
"type": "module",
|
|
13
18
|
"scripts": {
|
|
14
19
|
"build": "rimraf dist && tsc --project tsconfig.node.json && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
20
|
+
"docs:dev": "npm run predocs && vitepress dev docs --port 5273",
|
|
21
|
+
"docs:build": "npm run predocs && rimraf docs/.vitepress/dist && vitepress build docs && cpy --flat docs/logo.png docs/.vitepress/dist",
|
|
22
|
+
"docs:preview": "npm run predocs && vitepress preview docs --port 5274",
|
|
15
23
|
"format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
|
|
16
24
|
"lint": "eslint .",
|
|
25
|
+
"type-check": "tsc --noEmit --project tsconfig.node.json",
|
|
17
26
|
"lint:fix": "eslint --fix .",
|
|
27
|
+
"test": "vitest run",
|
|
18
28
|
"update": "updates --update ./",
|
|
19
29
|
"install-updates": "npm i --save",
|
|
30
|
+
"predocs": "typedoc && node scripts/build-example-docs.mjs",
|
|
20
31
|
"prepublishOnly": "npm i --package-lock-only && npm run lint:fix && npm run format && npm run build"
|
|
21
32
|
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"rxjs": "^7.8.2"
|
|
24
|
-
},
|
|
25
33
|
"devDependencies": {
|
|
26
34
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
27
35
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
28
|
-
"@stylistic/eslint-plugin": "^5.
|
|
36
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
29
37
|
"@types/multicast-dns": "^7.2.4",
|
|
30
|
-
"@types/node": "
|
|
31
|
-
"@typescript-eslint/parser": "^8.
|
|
32
|
-
"
|
|
33
|
-
"eslint
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"rollup
|
|
39
|
-
"
|
|
38
|
+
"@types/node": "25.9.3",
|
|
39
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
40
|
+
"cpy-cli": "^7.0.0",
|
|
41
|
+
"eslint": "9.39.2",
|
|
42
|
+
"eslint-plugin-jsdoc": "^63.0.2",
|
|
43
|
+
"globals": "^17.6.0",
|
|
44
|
+
"prettier": "^3.8.4",
|
|
45
|
+
"rimraf": "^6.1.3",
|
|
46
|
+
"rollup": "^4.62.0",
|
|
47
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
48
|
+
"sharp": "^0.35.1",
|
|
40
49
|
"tsyringe": "^4.10.0",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
50
|
+
"typedoc-plugin-markdown": "^4.12.0",
|
|
51
|
+
"typedoc-vitepress-theme": "^1.1.3",
|
|
52
|
+
"typescript": "5.9.3",
|
|
53
|
+
"typescript-eslint": "^8.61.0",
|
|
54
|
+
"updates": "^17.18.0",
|
|
55
|
+
"vitepress": "^1.6.4",
|
|
56
|
+
"vitest": "^4.1.9",
|
|
57
|
+
"werift": "0.23.0",
|
|
45
58
|
"werift-rtp": "^0.8.8"
|
|
46
59
|
},
|
|
47
|
-
"author": "seydx (https://github.com/
|
|
60
|
+
"author": "seydx (https://github.com/cameraui/sdk)",
|
|
48
61
|
"bugs": {
|
|
49
|
-
"url": "https://github.com/
|
|
62
|
+
"url": "https://github.com/cameraui/sdk/issues"
|
|
50
63
|
},
|
|
51
|
-
"homepage": "https://github.com/
|
|
64
|
+
"homepage": "https://github.com/cameraui/sdk#readme",
|
|
52
65
|
"license": "MIT",
|
|
53
66
|
"repository": {
|
|
54
67
|
"type": "git",
|
|
55
|
-
"url": "git+https://github.com/
|
|
68
|
+
"url": "git+https://github.com/cameraui/sdk.git"
|
|
56
69
|
},
|
|
57
70
|
"keywords": [
|
|
58
71
|
"camera.ui",
|
package/CHANGELOG.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
All notable changes to this project will be documented in this file.
|
|
2
|
-
|
|
3
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
4
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
-
|
|
6
|
-
## [X.X.X] - ???
|
|
7
|
-
|
|
8
|
-
- Initial Release
|
package/CONTRIBUTING.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Contributing
|
package/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023-2024 seydx <dev@seydx.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/sensor/guards.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { SensorType } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Type guard for Motion sensors
|
|
4
|
-
*
|
|
5
|
-
* Narrows a SensorLike to MotionSensorLike for type-safe property access.
|
|
6
|
-
*
|
|
7
|
-
* @param sensor - The sensor to check
|
|
8
|
-
*
|
|
9
|
-
* @returns True if the sensor is a Motion sensor
|
|
10
|
-
*/
|
|
11
|
-
export function isMotionSensor(sensor) {
|
|
12
|
-
return sensor.type === SensorType.Motion;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Type guard for Object detection sensors
|
|
16
|
-
*
|
|
17
|
-
* Narrows a SensorLike to ObjectSensorLike for type-safe property access.
|
|
18
|
-
*
|
|
19
|
-
* @param sensor - The sensor to check
|
|
20
|
-
*
|
|
21
|
-
* @returns True if the sensor is an Object sensor
|
|
22
|
-
*/
|
|
23
|
-
export function isObjectSensor(sensor) {
|
|
24
|
-
return sensor.type === SensorType.Object;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Type guard for Audio sensors
|
|
28
|
-
*
|
|
29
|
-
* Narrows a SensorLike to AudioSensorLike for type-safe property access.
|
|
30
|
-
*
|
|
31
|
-
* @param sensor - The sensor to check
|
|
32
|
-
*
|
|
33
|
-
* @returns True if the sensor is an Audio sensor
|
|
34
|
-
*/
|
|
35
|
-
export function isAudioSensor(sensor) {
|
|
36
|
-
return sensor.type === SensorType.Audio;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Type guard for Face detection sensors
|
|
40
|
-
*
|
|
41
|
-
* Narrows a SensorLike to FaceSensorLike for type-safe property access.
|
|
42
|
-
*
|
|
43
|
-
* @param sensor - The sensor to check
|
|
44
|
-
*
|
|
45
|
-
* @returns True if the sensor is a Face sensor
|
|
46
|
-
*/
|
|
47
|
-
export function isFaceSensor(sensor) {
|
|
48
|
-
return sensor.type === SensorType.Face;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Type guard for License Plate detection sensors
|
|
52
|
-
*
|
|
53
|
-
* Narrows a SensorLike to LicensePlateSensorLike for type-safe property access.
|
|
54
|
-
*
|
|
55
|
-
* @param sensor - The sensor to check
|
|
56
|
-
*
|
|
57
|
-
* @returns True if the sensor is a License Plate sensor
|
|
58
|
-
*/
|
|
59
|
-
export function isLicensePlateSensor(sensor) {
|
|
60
|
-
return sensor.type === SensorType.LicensePlate;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Type guard for Contact sensors
|
|
64
|
-
*
|
|
65
|
-
* Narrows a SensorLike to ContactSensorLike for type-safe property access.
|
|
66
|
-
*
|
|
67
|
-
* @param sensor - The sensor to check
|
|
68
|
-
*
|
|
69
|
-
* @returns True if the sensor is a Contact sensor
|
|
70
|
-
*/
|
|
71
|
-
export function isContactSensor(sensor) {
|
|
72
|
-
return sensor.type === SensorType.Contact;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Type guard for Light controls
|
|
76
|
-
*
|
|
77
|
-
* Narrows a SensorLike to LightControlLike for type-safe property access.
|
|
78
|
-
*
|
|
79
|
-
* @param sensor - The sensor to check
|
|
80
|
-
*
|
|
81
|
-
* @returns True if the sensor is a Light control
|
|
82
|
-
*/
|
|
83
|
-
export function isLightControl(sensor) {
|
|
84
|
-
return sensor.type === SensorType.Light;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Type guard for Siren controls
|
|
88
|
-
*
|
|
89
|
-
* Narrows a SensorLike to SirenControlLike for type-safe property access.
|
|
90
|
-
*
|
|
91
|
-
* @param sensor - The sensor to check
|
|
92
|
-
*
|
|
93
|
-
* @returns True if the sensor is a Siren control
|
|
94
|
-
*/
|
|
95
|
-
export function isSirenControl(sensor) {
|
|
96
|
-
return sensor.type === SensorType.Siren;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Type guard for PTZ controls
|
|
100
|
-
*
|
|
101
|
-
* Narrows a SensorLike to PTZControlLike for type-safe property access.
|
|
102
|
-
*
|
|
103
|
-
* @param sensor - The sensor to check
|
|
104
|
-
*
|
|
105
|
-
* @returns True if the sensor is a PTZ control
|
|
106
|
-
*/
|
|
107
|
-
export function isPTZControl(sensor) {
|
|
108
|
-
return sensor.type === SensorType.PTZ;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Type guard for Doorbell triggers
|
|
112
|
-
*
|
|
113
|
-
* Narrows a SensorLike to DoorbellTriggerLike for type-safe property access.
|
|
114
|
-
*
|
|
115
|
-
* @param sensor - The sensor to check
|
|
116
|
-
*
|
|
117
|
-
* @returns True if the sensor is a Doorbell trigger
|
|
118
|
-
*/
|
|
119
|
-
export function isDoorbellTrigger(sensor) {
|
|
120
|
-
return sensor.type === SensorType.Doorbell;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Type guard for Battery info sensors
|
|
124
|
-
*
|
|
125
|
-
* Narrows a SensorLike to BatteryInfoLike for type-safe property access.
|
|
126
|
-
*
|
|
127
|
-
* @param sensor - The sensor to check
|
|
128
|
-
*
|
|
129
|
-
* @returns True if the sensor is a Battery info sensor
|
|
130
|
-
*/
|
|
131
|
-
export function isBatteryInfo(sensor) {
|
|
132
|
-
return sensor.type === SensorType.Battery;
|
|
133
|
-
}
|
package/dist/sensor/types.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Charging state for battery
|
|
3
|
-
*/
|
|
4
|
-
export var ChargingState;
|
|
5
|
-
(function (ChargingState) {
|
|
6
|
-
ChargingState["NotChargeable"] = "NOT_CHARGEABLE";
|
|
7
|
-
ChargingState["NotCharging"] = "NOT_CHARGING";
|
|
8
|
-
ChargingState["Charging"] = "CHARGING";
|
|
9
|
-
ChargingState["Full"] = "FULL";
|
|
10
|
-
})(ChargingState || (ChargingState = {}));
|
|
11
|
-
// ========== Sensor Types ==========
|
|
12
|
-
/**
|
|
13
|
-
* Sensor Type Enum - identifies the type of sensor/control/trigger/info
|
|
14
|
-
*/
|
|
15
|
-
export var SensorType;
|
|
16
|
-
(function (SensorType) {
|
|
17
|
-
// Detection Sensors
|
|
18
|
-
SensorType["Motion"] = "motion";
|
|
19
|
-
SensorType["Object"] = "object";
|
|
20
|
-
SensorType["Audio"] = "audio";
|
|
21
|
-
SensorType["Face"] = "face";
|
|
22
|
-
SensorType["LicensePlate"] = "licensePlate";
|
|
23
|
-
SensorType["Contact"] = "contact";
|
|
24
|
-
// Controls
|
|
25
|
-
SensorType["Light"] = "light";
|
|
26
|
-
SensorType["Siren"] = "siren";
|
|
27
|
-
SensorType["PTZ"] = "ptz";
|
|
28
|
-
// Triggers
|
|
29
|
-
SensorType["Doorbell"] = "doorbell";
|
|
30
|
-
// Info
|
|
31
|
-
SensorType["Battery"] = "battery";
|
|
32
|
-
})(SensorType || (SensorType = {}));
|
|
33
|
-
/**
|
|
34
|
-
* Sensor Category - categorizes sensors by their behavior
|
|
35
|
-
*/
|
|
36
|
-
export var SensorCategory;
|
|
37
|
-
(function (SensorCategory) {
|
|
38
|
-
/** Detection sensors (read-only, 1 provider) */
|
|
39
|
-
SensorCategory["Sensor"] = "sensor";
|
|
40
|
-
/** Bidirectional controls */
|
|
41
|
-
SensorCategory["Control"] = "control";
|
|
42
|
-
/** Event-based triggers */
|
|
43
|
-
SensorCategory["Trigger"] = "trigger";
|
|
44
|
-
/** Read-only hardware status */
|
|
45
|
-
SensorCategory["Info"] = "info";
|
|
46
|
-
})(SensorCategory || (SensorCategory = {}));
|
package/dist/service/base.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service types that can be registered by plugins
|
|
3
|
-
*/
|
|
4
|
-
export var ServiceType;
|
|
5
|
-
(function (ServiceType) {
|
|
6
|
-
/** Streaming URL generation */
|
|
7
|
-
ServiceType["Streaming"] = "streaming";
|
|
8
|
-
/** Snapshot capture */
|
|
9
|
-
ServiceType["Snapshot"] = "snapshot";
|
|
10
|
-
})(ServiceType || (ServiceType = {}));
|
|
11
|
-
/**
|
|
12
|
-
* Abstract base class for all camera services
|
|
13
|
-
*
|
|
14
|
-
* Plugins extend this class to implement custom service functionality.
|
|
15
|
-
* The service communicates with the server via RPC, with the base class
|
|
16
|
-
* handling online/offline status management.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* class MyStreamingService extends Service implements StreamingService {
|
|
21
|
-
* readonly type = ServiceType.Streaming;
|
|
22
|
-
*
|
|
23
|
-
* async streamUrl(sourceName: string): Promise<string> {
|
|
24
|
-
* return `rtsp://my-camera/${sourceName}`;
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* // In plugin:
|
|
29
|
-
* const service = new MyStreamingService(camera.id, this.pluginId);
|
|
30
|
-
* await camera.registerService(service);
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export class Service {
|
|
34
|
-
/**
|
|
35
|
-
* Camera ID this service is associated with
|
|
36
|
-
*/
|
|
37
|
-
cameraId;
|
|
38
|
-
/**
|
|
39
|
-
* Plugin ID that provides this service
|
|
40
|
-
*/
|
|
41
|
-
pluginId;
|
|
42
|
-
/**
|
|
43
|
-
* Internal online state
|
|
44
|
-
*/
|
|
45
|
-
_online = false;
|
|
46
|
-
/**
|
|
47
|
-
* Callback for online status changes (set by runtime)
|
|
48
|
-
*/
|
|
49
|
-
_onlineChangeFn;
|
|
50
|
-
/**
|
|
51
|
-
* Create a new service instance
|
|
52
|
-
*
|
|
53
|
-
* @param cameraId - ID of the camera this service is for
|
|
54
|
-
*
|
|
55
|
-
* @param pluginId - ID of the plugin providing this service
|
|
56
|
-
*/
|
|
57
|
-
constructor(cameraId, pluginId) {
|
|
58
|
-
this.cameraId = cameraId;
|
|
59
|
-
this.pluginId = pluginId;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Whether the service is currently online/available
|
|
63
|
-
*
|
|
64
|
-
* Setting this property notifies the server of the status change.
|
|
65
|
-
*/
|
|
66
|
-
get online() {
|
|
67
|
-
return this._online;
|
|
68
|
-
}
|
|
69
|
-
set online(value) {
|
|
70
|
-
if (this._online !== value) {
|
|
71
|
-
this._online = value;
|
|
72
|
-
this._onlineChangeFn?.(value);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Internal initialization - sets up the online status callback
|
|
77
|
-
*
|
|
78
|
-
* Called by the runtime when the service is registered.
|
|
79
|
-
*
|
|
80
|
-
* @param onlineChangeFn - Callback to notify server of online status changes
|
|
81
|
-
*
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
_init(onlineChangeFn) {
|
|
85
|
-
this._onlineChangeFn = onlineChangeFn;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Internal cleanup - called when service is unregistered
|
|
89
|
-
*
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
|
-
_cleanup() {
|
|
93
|
-
this._onlineChangeFn = undefined;
|
|
94
|
-
this._online = false;
|
|
95
|
-
}
|
|
96
|
-
}
|
package/dist/service/index.js
DELETED
package/tsconfig.node.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "./dist",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"module": "NodeNext",
|
|
7
|
-
"lib": [
|
|
8
|
-
"ES2022",
|
|
9
|
-
],
|
|
10
|
-
"declaration": false,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"preserveConstEnums": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"useUnknownInCatchVariables": false,
|
|
16
|
-
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"experimentalDecorators": true,
|
|
19
|
-
"emitDecoratorMetadata": true,
|
|
20
|
-
"verbatimModuleSyntax": true,
|
|
21
|
-
"noImplicitAny": true,
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"src",
|
|
25
|
-
],
|
|
26
|
-
"exclude": [
|
|
27
|
-
"node_modules",
|
|
28
|
-
"dist",
|
|
29
|
-
],
|
|
30
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|