@camera.ui/sdk 0.0.1

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/LICENSE.md +22 -0
  4. package/README.md +5 -0
  5. package/dist/camera/config.js +1 -0
  6. package/dist/camera/detection.js +1 -0
  7. package/dist/camera/device.js +1 -0
  8. package/dist/camera/index.js +5 -0
  9. package/dist/camera/streaming.js +1 -0
  10. package/dist/camera/types.js +1 -0
  11. package/dist/external.js +1 -0
  12. package/dist/index.d.ts +5042 -0
  13. package/dist/index.js +16 -0
  14. package/dist/manager/index.js +1 -0
  15. package/dist/manager/types.js +1 -0
  16. package/dist/plugin/contract.js +120 -0
  17. package/dist/plugin/index.js +3 -0
  18. package/dist/plugin/interfaces.js +1 -0
  19. package/dist/plugin/types.js +1 -0
  20. package/dist/sensor/audio.js +118 -0
  21. package/dist/sensor/base.js +460 -0
  22. package/dist/sensor/battery.js +101 -0
  23. package/dist/sensor/contact.js +33 -0
  24. package/dist/sensor/doorbell.js +63 -0
  25. package/dist/sensor/face.js +124 -0
  26. package/dist/sensor/guards.js +133 -0
  27. package/dist/sensor/index.js +19 -0
  28. package/dist/sensor/licensePlate.js +116 -0
  29. package/dist/sensor/light.js +66 -0
  30. package/dist/sensor/motion.js +103 -0
  31. package/dist/sensor/object.js +137 -0
  32. package/dist/sensor/ptz.js +159 -0
  33. package/dist/sensor/siren.js +73 -0
  34. package/dist/sensor/types.js +46 -0
  35. package/dist/service/base.js +96 -0
  36. package/dist/service/index.js +3 -0
  37. package/dist/service/services.js +1 -0
  38. package/dist/service/types.js +1 -0
  39. package/dist/storage/index.js +2 -0
  40. package/dist/storage/schema.js +1 -0
  41. package/dist/storage/storages.js +1 -0
  42. package/package.json +61 -0
  43. package/tsconfig.node.json +30 -0
@@ -0,0 +1,159 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * PTZ Capability enum
5
+ * Describes what PTZ features this sensor supports
6
+ */
7
+ export var PTZCapability;
8
+ (function (PTZCapability) {
9
+ /** Supports horizontal panning */
10
+ PTZCapability["Pan"] = "pan";
11
+ /** Supports vertical tilting */
12
+ PTZCapability["Tilt"] = "tilt";
13
+ /** Supports zoom in/out */
14
+ PTZCapability["Zoom"] = "zoom";
15
+ /** Supports preset positions */
16
+ PTZCapability["Presets"] = "presets";
17
+ /** Supports home position */
18
+ PTZCapability["Home"] = "home";
19
+ })(PTZCapability || (PTZCapability = {}));
20
+ /**
21
+ * PTZ control property keys
22
+ */
23
+ export var PTZProperty;
24
+ (function (PTZProperty) {
25
+ PTZProperty["Position"] = "position";
26
+ PTZProperty["Moving"] = "moving";
27
+ PTZProperty["Presets"] = "presets";
28
+ PTZProperty["Velocity"] = "velocity";
29
+ PTZProperty["TargetPreset"] = "targetPreset";
30
+ })(PTZProperty || (PTZProperty = {}));
31
+ /**
32
+ * PTZ Control
33
+ *
34
+ * Bidirectional control for camera pan/tilt/zoom.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Move to absolute position
39
+ * ptz.position = { pan: 45, tilt: -10, zoom: 0.5 };
40
+ *
41
+ * // Continuous move
42
+ * ptz.continuousMove({ panSpeed: 1, tiltSpeed: 0, zoomSpeed: 0 });
43
+ *
44
+ * // Stop all movement
45
+ * ptz.stop();
46
+ *
47
+ * // Go to preset
48
+ * ptz.goToPreset('Entrance');
49
+ *
50
+ * // Go to home position
51
+ * ptz.goHome();
52
+ * ```
53
+ */
54
+ export class PTZControl extends Sensor {
55
+ type = SensorType.PTZ;
56
+ category = SensorCategory.Control;
57
+ name;
58
+ /**
59
+ * Create a new PTZ control sensor.
60
+ *
61
+ * @param name - Human-readable name for this sensor
62
+ */
63
+ constructor(name = 'PTZ') {
64
+ super();
65
+ this.name = name;
66
+ // Initialize defaults
67
+ this.props.position = { pan: 0, tilt: 0, zoom: 0 };
68
+ this.props.moving = false;
69
+ this.props.presets = [];
70
+ }
71
+ /** Current PTZ position */
72
+ get position() {
73
+ return this.rawProps.position;
74
+ }
75
+ /** Set PTZ position (absolute move) */
76
+ set position(value) {
77
+ this.props.position = value;
78
+ }
79
+ /** Whether PTZ is currently moving */
80
+ get moving() {
81
+ return this.rawProps.moving;
82
+ }
83
+ /** Set moving state */
84
+ set moving(value) {
85
+ this.props.moving = value;
86
+ }
87
+ /** Available presets */
88
+ get presets() {
89
+ return this.rawProps.presets;
90
+ }
91
+ /** Set available presets */
92
+ set presets(value) {
93
+ this.props.presets = value;
94
+ }
95
+ /** Current velocity (for continuous move) */
96
+ get velocity() {
97
+ return this.rawProps.velocity;
98
+ }
99
+ /** Set velocity for continuous move */
100
+ set velocity(value) {
101
+ this.props.velocity = value;
102
+ }
103
+ /** Target preset to go to */
104
+ get targetPreset() {
105
+ return this.rawProps.targetPreset;
106
+ }
107
+ /** Set target preset */
108
+ set targetPreset(value) {
109
+ this.props.targetPreset = value;
110
+ }
111
+ /** Go to home position (pan: 0, tilt: 0, zoom: 0) */
112
+ goHome() {
113
+ this.props.position = { pan: 0, tilt: 0, zoom: 0 };
114
+ }
115
+ /**
116
+ * Pan to specific angle
117
+ *
118
+ * @param angle - Pan angle in degrees
119
+ */
120
+ pan(angle) {
121
+ this.props.position = { ...this.position, pan: angle };
122
+ }
123
+ /**
124
+ * Tilt to specific angle
125
+ *
126
+ * @param angle - Tilt angle in degrees
127
+ */
128
+ tilt(angle) {
129
+ this.props.position = { ...this.position, tilt: angle };
130
+ }
131
+ /**
132
+ * Zoom to specific level (0-1)
133
+ *
134
+ * @param level - Zoom level between 0 and 1
135
+ */
136
+ zoom(level) {
137
+ this.props.position = { ...this.position, zoom: Math.max(0, Math.min(1, level)) };
138
+ }
139
+ /**
140
+ * Start continuous movement
141
+ *
142
+ * @param velocity - Movement speed for each axis (-1 to 1)
143
+ */
144
+ continuousMove(velocity) {
145
+ this.props.velocity = velocity;
146
+ }
147
+ /** Stop all movement */
148
+ stop() {
149
+ this.props.velocity = { panSpeed: 0, tiltSpeed: 0, zoomSpeed: 0 };
150
+ }
151
+ /**
152
+ * Go to a saved preset
153
+ *
154
+ * @param preset - Preset name
155
+ */
156
+ goToPreset(preset) {
157
+ this.props.targetPreset = preset;
158
+ }
159
+ }
@@ -0,0 +1,73 @@
1
+ import { Sensor } from './base.js';
2
+ import { SensorCategory, SensorType } from './types.js';
3
+ /**
4
+ * Siren Capability enum
5
+ * Describes what Siren features this sensor supports
6
+ */
7
+ export var SirenCapability;
8
+ (function (SirenCapability) {
9
+ /** Supports volume control */
10
+ SirenCapability["Volume"] = "volume";
11
+ /** Supports different siren modes */
12
+ SirenCapability["Modes"] = "modes";
13
+ })(SirenCapability || (SirenCapability = {}));
14
+ /**
15
+ * Siren control property keys
16
+ */
17
+ export var SirenProperty;
18
+ (function (SirenProperty) {
19
+ SirenProperty["Active"] = "active";
20
+ SirenProperty["Volume"] = "volume";
21
+ })(SirenProperty || (SirenProperty = {}));
22
+ /**
23
+ * Siren Control
24
+ *
25
+ * Bidirectional control for camera siren/alarm.
26
+ * Properties can be set directly: `siren.active = true`
27
+ */
28
+ export class SirenControl extends Sensor {
29
+ type = SensorType.Siren;
30
+ category = SensorCategory.Control;
31
+ name;
32
+ constructor(name = 'Siren') {
33
+ super();
34
+ this.name = name;
35
+ // Initialize defaults
36
+ this.props.active = false;
37
+ this.props.volume = 100;
38
+ }
39
+ /** Whether siren is active */
40
+ get active() {
41
+ return this.rawProps.active;
42
+ }
43
+ /** Activate/deactivate siren */
44
+ set active(value) {
45
+ this.props.active = value;
46
+ }
47
+ /** Volume level (0-100) */
48
+ get volume() {
49
+ return this.rawProps.volume;
50
+ }
51
+ /** Set volume level (0-100) */
52
+ set volume(value) {
53
+ this.props.volume = Math.max(0, Math.min(100, value));
54
+ }
55
+ /** Activate siren */
56
+ activate() {
57
+ this.props.active = true;
58
+ }
59
+ /** Deactivate siren */
60
+ deactivate() {
61
+ this.props.active = false;
62
+ }
63
+ /**
64
+ * Sound siren for a duration
65
+ *
66
+ * @param durationMs - Duration to sound siren in milliseconds
67
+ */
68
+ async soundFor(durationMs) {
69
+ this.activate();
70
+ await new Promise((resolve) => setTimeout(resolve, durationMs));
71
+ this.deactivate();
72
+ }
73
+ }
@@ -0,0 +1,46 @@
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 = {}));
@@ -0,0 +1,96 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ export * from './base.js';
2
+ export * from './services.js';
3
+ export * from './types.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './schema.js';
2
+ export * from './storages.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@camera.ui/sdk",
3
+ "version": "0.0.1",
4
+ "description": "camera.ui sdk",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "require": "./dist/index.js",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "type": "module",
13
+ "scripts": {
14
+ "build": "rimraf dist && tsc --project tsconfig.node.json && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
15
+ "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
16
+ "lint": "eslint .",
17
+ "lint:fix": "eslint --fix .",
18
+ "update": "updates --update ./",
19
+ "install-updates": "npm i --save",
20
+ "prepublishOnly": "npm i --package-lock-only && npm run lint:fix && npm run format && npm run build"
21
+ },
22
+ "dependencies": {
23
+ "rxjs": "^7.8.2"
24
+ },
25
+ "devDependencies": {
26
+ "@rollup/plugin-node-resolve": "^16.0.3",
27
+ "@rollup/plugin-typescript": "^12.3.0",
28
+ "@stylistic/eslint-plugin": "^5.6.1",
29
+ "@types/multicast-dns": "^7.2.4",
30
+ "@types/node": "^24.10.1",
31
+ "@typescript-eslint/parser": "^8.48.1",
32
+ "eslint": "^9.39.1",
33
+ "eslint-plugin-jsdoc": "^61.5.0",
34
+ "globals": "^16.5.0",
35
+ "prettier": "^3.7.4",
36
+ "rimraf": "^6.1.2",
37
+ "rollup": "^4.53.3",
38
+ "rollup-plugin-dts": "^6.3.0",
39
+ "sharp": "^0.34.5",
40
+ "tsyringe": "^4.10.0",
41
+ "typescript": "^5.9.3",
42
+ "typescript-eslint": "^8.48.1",
43
+ "updates": "^17.0.4",
44
+ "werift": "0.22.2",
45
+ "werift-rtp": "^0.8.8"
46
+ },
47
+ "author": "seydx (https://github.com/seydx/camera.ui)",
48
+ "bugs": {
49
+ "url": "https://github.com/seydx/camera.ui/issues"
50
+ },
51
+ "homepage": "https://github.com/seydx/camera.ui#readme",
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/seydx/camera.ui.git"
56
+ },
57
+ "keywords": [
58
+ "camera.ui",
59
+ "sdk"
60
+ ]
61
+ }
@@ -0,0 +1,30 @@
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
+ }