@camera.ui/camera-ui-ring 0.0.21 → 0.0.23

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/package.json CHANGED
@@ -1,44 +1,47 @@
1
1
  {
2
2
  "displayName": "Ring",
3
3
  "name": "@camera.ui/camera-ui-ring",
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "description": "camera.ui ring plugin",
6
6
  "author": "seydx (https://github.com/seydx/camera.ui)",
7
7
  "main": "./dist/index.js",
8
+ "type": "module",
8
9
  "scripts": {
9
10
  "build": "rimraf dist && tsc",
10
11
  "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
11
12
  "lint": "eslint --fix --ext .js,.ts .",
12
13
  "update": "updates --update ./",
13
14
  "install-updates": "npm i --save",
14
- "prepublishOnly": "npm run lint && npm run format && npm run build"
15
+ "prepublishOnly": "npm i --package-lock-only && npm run lint && npm run format && npm run build"
15
16
  },
16
17
  "dependencies": {
17
- "@camera.ui/types": "^0.0.21",
18
- "ring-client-api": "^12.1.0",
19
- "werift": "^0.19.0",
20
- "ws": "^8.16.0"
18
+ "@camera.ui/rtsp": "^0.0.24",
19
+ "ring-client-api": "^13.0.0",
20
+ "rxjs": "^7.8.1",
21
+ "werift": "^0.19.4",
22
+ "ws": "^8.18.0"
21
23
  },
22
24
  "devDependencies": {
23
- "@rushstack/eslint-patch": "^1.7.0",
24
- "@types/node": "^20.11.5",
25
- "@types/ws": "^8.5.10",
26
- "@typescript-eslint/eslint-plugin": "^6.19.0",
27
- "@typescript-eslint/parser": "^6.19.0",
25
+ "@camera.ui/types": "^0.0.53",
26
+ "@rushstack/eslint-patch": "^1.10.4",
27
+ "@types/node": "^22.1.0",
28
+ "@types/ws": "^8.5.12",
29
+ "@typescript-eslint/eslint-plugin": "^8.0.1",
30
+ "@typescript-eslint/parser": "^8.0.1",
28
31
  "concurrently": "^8.2.2",
29
- "eslint": "^8.56.0",
32
+ "eslint": "8.57.0",
30
33
  "eslint-config-prettier": "^9.1.0",
31
- "eslint-plugin-prettier": "^5.1.3",
32
- "prettier": "^3.2.4",
33
- "rimraf": "^5.0.5",
34
- "typescript": "^5.3.3",
35
- "updates": "^15.1.1"
34
+ "eslint-plugin-prettier": "^5.2.1",
35
+ "prettier": "^3.3.3",
36
+ "rimraf": "^6.0.1",
37
+ "typescript": "^5.5.4",
38
+ "updates": "^16.3.7"
36
39
  },
37
40
  "bugs": {
38
41
  "url": "https://github.com/seydx/camera.ui/issues"
39
42
  },
40
43
  "engines": {
41
- "camera.ui": ">=3.0.0-alpha.0",
44
+ "camera.ui": ">=0.0.1",
42
45
  "node": ">=18.12.0"
43
46
  },
44
47
  "homepage": "https://github.com/seydx/camera.ui#readme",
@@ -51,5 +54,11 @@
51
54
  "repository": {
52
55
  "type": "git",
53
56
  "url": "git+https://github.com/seydx/camera.ui.git"
57
+ },
58
+ "camera.ui": {
59
+ "builtIns": [
60
+ "motionDetection"
61
+ ],
62
+ "dependencies": []
54
63
  }
55
64
  }
@@ -1,2 +0,0 @@
1
- import type { PluginContract } from '@camera.ui/types';
2
- export declare const pluginContract: PluginContract;
package/dist/contract.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pluginContract = void 0;
4
- exports.pluginContract = {
5
- pluginName: '@camera.ui/camera-ui-ring',
6
- builtIns: ['motionDetection'],
7
- dependencies: [],
8
- };
9
- //# sourceMappingURL=contract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAmB;IAC5C,UAAU,EAAE,2BAA2B;IACvC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAC7B,YAAY,EAAE,EAAE;CACjB,CAAC"}
package/dist/server.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { PluginConfig, PluginLogger, CameraDevice } from '@camera.ui/types';
2
- import type { WebsocketProxy } from './ws';
3
- export declare class ProxyServer {
4
- private server;
5
- private sendingSnapshot;
6
- private ringCameraConnections;
7
- private config;
8
- private logger;
9
- private cameras;
10
- constructor(config: PluginConfig, cameras: Map<string, CameraDevice>, ringCameraConnections: Map<string, WebsocketProxy>, logger: PluginLogger);
11
- close(): void;
12
- private listenServer;
13
- private queryToData;
14
- }
package/dist/server.js DELETED
@@ -1,105 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ProxyServer = void 0;
7
- const url_1 = __importDefault(require("url"));
8
- const http_1 = __importDefault(require("http"));
9
- class ProxyServer {
10
- server;
11
- sendingSnapshot = false;
12
- ringCameraConnections;
13
- config;
14
- logger;
15
- cameras;
16
- constructor(config, cameras, ringCameraConnections, logger) {
17
- this.config = config;
18
- this.logger = logger;
19
- this.cameras = cameras;
20
- this.ringCameraConnections = ringCameraConnections;
21
- this.server = http_1.default.createServer().listen(this.config.server.listen, 'localhost');
22
- if (!this.config.server.username || !this.config.server.password) {
23
- this.logger.warn('Stream endpoints are not protected');
24
- }
25
- this.listenServer();
26
- }
27
- close() {
28
- this.ringCameraConnections.forEach((connection) => connection.close());
29
- this.server.close();
30
- }
31
- listenServer() {
32
- this.server.on('upgrade', async (request, socket, head) => {
33
- if (request.url) {
34
- const parsedUrl = url_1.default.parse(request.url);
35
- let pathname = parsedUrl.pathname;
36
- if (parsedUrl.query && this.config.server.username && this.config.server.password) {
37
- const query = this.queryToData(parsedUrl.query);
38
- if (this.config.server.username !== query.username || this.config.server.password !== query.password) {
39
- this.logger.warn('Invalid username or password');
40
- pathname = null;
41
- }
42
- }
43
- if (pathname) {
44
- const decodedPathname = decodeURIComponent(pathname);
45
- const ringCameraId = decodedPathname.split('/')[1];
46
- const ws = Array.from(this.ringCameraConnections.values()).find((connection) => connection.proxyInfo.ringCameraId === ringCameraId)?.ws;
47
- if (ws) {
48
- return ws.handleUpgrade(request, socket, head, (socket) => ws.emit('connection', socket));
49
- }
50
- }
51
- }
52
- socket.destroy();
53
- });
54
- this.server.on('request', async (request, response) => {
55
- if (request.url) {
56
- const parsedUrl = url_1.default.parse(request.url);
57
- const pathname = parsedUrl.pathname;
58
- if (pathname) {
59
- const decodedPathname = decodeURIComponent(pathname);
60
- const ringCameraId = decodedPathname.split('/')[1];
61
- const cameraConnection = Array.from(this.ringCameraConnections.values()).find((connection) => connection.proxyInfo.ringCameraId === ringCameraId);
62
- const camera = Array.from(this.cameras.values()).find((camera) => camera.nativeId === ringCameraId);
63
- if (cameraConnection && !this.sendingSnapshot) {
64
- this.logger.debug(camera?.name, 'Sending snapshot...');
65
- this.sendingSnapshot = true;
66
- const buffer = await cameraConnection.snapshot();
67
- setTimeout(() => {
68
- this.sendingSnapshot = false;
69
- }, 100);
70
- this.logger.debug(camera?.name, 'Snapshot sent');
71
- response.writeHead(200, { 'Content-Type': 'image/jpeg' });
72
- response.end(buffer);
73
- return;
74
- }
75
- }
76
- }
77
- response.writeHead(404, { 'Content-Type': 'text/plain' });
78
- response.end('404 Not Found');
79
- });
80
- }
81
- queryToData(query) {
82
- const params = new URLSearchParams(query);
83
- const result = {};
84
- params.forEach((value, key) => {
85
- if (value === 'true' || value === 'false' || value === '') {
86
- result[key] = value === 'true' || value === '';
87
- }
88
- else if (value === 'null') {
89
- result[key] = null;
90
- }
91
- else if (value === 'undefined') {
92
- result[key] = undefined;
93
- }
94
- else if (!isNaN(Number(value))) {
95
- result[key] = Number(value);
96
- }
97
- else {
98
- result[key] = value;
99
- }
100
- });
101
- return result;
102
- }
103
- }
104
- exports.ProxyServer = ProxyServer;
105
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,gDAAwB;AAKxB,MAAa,WAAW;IACd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ChB,CAAC;CACF;AAjHD,kCAiHC"}
package/dist/ws.d.ts DELETED
@@ -1,21 +0,0 @@
1
- /// <reference types="pouchdb-core" />
2
- /// <reference types="node" />
3
- import { WebSocketServer } from 'ws';
4
- import type { RingCamera } from 'ring-client-api';
5
- import type { CameraDevice, PluginLogger } from '@camera.ui/types';
6
- import type { ProxyInfo } from './types';
7
- export declare class WebsocketProxy {
8
- ws: WebSocketServer;
9
- proxyInfo: ProxyInfo;
10
- private ringCamera;
11
- private cameraDevice;
12
- private logger;
13
- private pc?;
14
- private call?;
15
- constructor(ringCamera: RingCamera, cameraDevice: CameraDevice, proxyInfo: ProxyInfo, logger: PluginLogger);
16
- close(): void;
17
- snapshot(): Promise<Buffer | undefined>;
18
- private listenServer;
19
- private checkStates;
20
- private createPeerCoonection;
21
- }
package/dist/ws.js DELETED
@@ -1,201 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebsocketProxy = void 0;
4
- const ws_1 = require("ws");
5
- const peer_1 = require("./peer");
6
- const werift_1 = require("werift");
7
- class WebsocketProxy {
8
- ws;
9
- proxyInfo;
10
- ringCamera;
11
- cameraDevice;
12
- logger;
13
- pc;
14
- call;
15
- constructor(ringCamera, cameraDevice, proxyInfo, logger) {
16
- this.ws = new ws_1.WebSocketServer({ noServer: true });
17
- this.proxyInfo = proxyInfo;
18
- this.logger = logger;
19
- this.ringCamera = ringCamera;
20
- this.cameraDevice = cameraDevice;
21
- this.listenServer();
22
- this.checkStates();
23
- }
24
- close() {
25
- this.call?.stop();
26
- this.pc?.close();
27
- this.ws?.removeAllListeners();
28
- this.ws?.close();
29
- }
30
- async snapshot() {
31
- try {
32
- return await this.ringCamera.getSnapshot();
33
- }
34
- catch (error) {
35
- this.logger.error(this.cameraDevice.name, error.message);
36
- }
37
- }
38
- listenServer() {
39
- this.logger.log(`${this.cameraDevice.name} is listening on ${this.proxyInfo.streamSource} (webrtc)`);
40
- this.logger.log(`${this.cameraDevice.name} is listening on ${this.proxyInfo.snapshotSource} (snapshot)`);
41
- this.ws.on('connection', async (socket) => {
42
- this.pc = this.createPeerCoonection();
43
- const receiver = new peer_1.CustomPeerConnection(this.cameraDevice.name, this.logger);
44
- const audioTrack = new werift_1.MediaStreamTrack({ kind: 'audio' });
45
- const videoTrack = new werift_1.MediaStreamTrack({ kind: 'video' });
46
- receiver.onAudioRtp.subscribe((rtp) => {
47
- audioTrack.writeRtp(rtp);
48
- });
49
- receiver.onVideoRtp.subscribe((rtp) => {
50
- videoTrack.writeRtp(rtp);
51
- });
52
- this.pc.iceConnectionStateChange.subscribe((ev) => {
53
- this.logger.debug(`${this.cameraDevice.name}: iceConnectionStateChange: ${ev}`);
54
- if (ev === 'disconnected' || ev === 'failed' || ev === 'closed') {
55
- this.call?.stop();
56
- this.pc?.close();
57
- }
58
- });
59
- this.pc.connectionStateChange.subscribe((ev) => {
60
- this.logger.debug(`${this.cameraDevice.name}: connectionStateChange: ${ev}`);
61
- });
62
- this.pc.onTrack.subscribe((track) => {
63
- if (track.kind === 'audio') {
64
- track.onReceiveRtp.subscribe((rtp) => {
65
- receiver.returnAudioTrack.writeRtp(rtp);
66
- });
67
- }
68
- });
69
- this.pc.addTransceiver(videoTrack, { direction: 'sendonly' });
70
- this.pc.addTransceiver(audioTrack, { direction: 'sendonly' });
71
- socket.on('message', async (data) => {
72
- try {
73
- const message = JSON.parse(data.toString());
74
- switch (message.type) {
75
- case 'webrtc/offer':
76
- this.call = await this.ringCamera.startLiveCall({
77
- createPeerConnection: () => receiver,
78
- });
79
- this.logger.debug(`${this.cameraDevice.name}: Stream started`);
80
- this.call.onCallEnded.subscribe(() => {
81
- this.logger.debug(`${this.cameraDevice.name}: Stream ended`);
82
- });
83
- if (!this.call.cameraSpeakerActivated) {
84
- this.call.activateCameraSpeaker();
85
- }
86
- await this.pc?.setRemoteDescription(new werift_1.RTCSessionDescription(message.value, 'offer'));
87
- const answer = await this.pc?.createAnswer();
88
- if (answer) {
89
- await this.pc?.setLocalDescription(answer);
90
- const response = { type: 'webrtc/answer', value: answer.sdp };
91
- socket.send(JSON.stringify(response));
92
- }
93
- break;
94
- case 'webrtc/candidate':
95
- const candidate = new werift_1.RTCIceCandidate({ candidate: message.value });
96
- await this.pc?.addIceCandidate(candidate);
97
- break;
98
- default:
99
- throw new Error(`Unknown message! ${message}`);
100
- }
101
- }
102
- catch (error) {
103
- this.logger.error(this.cameraDevice.name, error);
104
- }
105
- });
106
- });
107
- }
108
- checkStates() {
109
- let motionTimeout;
110
- const resetTimeout = () => {
111
- clearTimeout(motionTimeout);
112
- motionTimeout = setTimeout(() => {
113
- this.cameraDevice.updateState('motion', { state: false });
114
- }, 30000);
115
- };
116
- let doorbellTimeout;
117
- const resetDoorbellTimeout = () => {
118
- clearTimeout(doorbellTimeout);
119
- doorbellTimeout = setTimeout(() => {
120
- this.cameraDevice.updateState('doorbell', { state: false });
121
- }, 10000);
122
- };
123
- this.ringCamera.onDoorbellPressed.subscribe(async (ding) => {
124
- this.logger.log(this.cameraDevice.name, 'onDoorbellPressed', ding);
125
- this.cameraDevice.updateState('doorbell', { state: true });
126
- resetDoorbellTimeout();
127
- });
128
- this.ringCamera.onMotionDetected.subscribe(async (motionDetected) => {
129
- if (motionDetected) {
130
- this.logger.log(this.cameraDevice.name, 'onMotionDetected');
131
- resetTimeout();
132
- }
133
- else {
134
- clearTimeout(motionTimeout);
135
- }
136
- this.cameraDevice.updateState('motion', { state: motionDetected });
137
- });
138
- this.ringCamera.onData.subscribe(async (data) => {
139
- if (this.ringCamera.hasLight && data.led_status) {
140
- this.logger.log(this.cameraDevice.name, 'light', data.led_status === 'on');
141
- this.cameraDevice.updateState('light', { state: data.led_status === 'on' });
142
- }
143
- if (this.ringCamera.hasSiren && data.siren_status) {
144
- this.logger.log(this.cameraDevice.name, 'siren', data.siren_status.seconds_remaining > 0 ? true : false);
145
- this.cameraDevice.updateState('siren', { state: data.siren_status.seconds_remaining > 0 ? true : false });
146
- }
147
- });
148
- }
149
- createPeerCoonection() {
150
- return new werift_1.RTCPeerConnection({
151
- codecs: {
152
- video: [
153
- new werift_1.RTCRtpCodecParameters({
154
- mimeType: 'video/H264',
155
- clockRate: 90000,
156
- payloadType: 96,
157
- rtcpFeedback: [{ type: 'transport-cc' }, { type: 'ccm', parameter: 'fir' }, { type: 'nack' }, { type: 'nack', parameter: 'pli' }, { type: 'goog-remb' }],
158
- parameters: 'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f',
159
- }),
160
- new werift_1.RTCRtpCodecParameters({
161
- mimeType: 'video/H264',
162
- clockRate: 90000,
163
- payloadType: 97,
164
- rtcpFeedback: [{ type: 'transport-cc' }, { type: 'ccm', parameter: 'fir' }, { type: 'nack' }, { type: 'nack', parameter: 'pli' }, { type: 'goog-remb' }],
165
- parameters: 'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f',
166
- }),
167
- new werift_1.RTCRtpCodecParameters({
168
- mimeType: 'video/H264',
169
- clockRate: 90000,
170
- payloadType: 98,
171
- rtcpFeedback: [{ type: 'transport-cc' }, { type: 'ccm', parameter: 'fir' }, { type: 'nack' }, { type: 'nack', parameter: 'pli' }, { type: 'goog-remb' }],
172
- parameters: 'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032',
173
- }),
174
- ],
175
- audio: [
176
- new werift_1.RTCRtpCodecParameters({
177
- mimeType: 'audio/opus',
178
- clockRate: 48000,
179
- payloadType: 101,
180
- channels: 2,
181
- parameters: 'minptime=10;useinbandfec=1',
182
- }),
183
- new werift_1.RTCRtpCodecParameters({
184
- mimeType: 'audio/PCMU',
185
- clockRate: 8000,
186
- channels: 1,
187
- payloadType: 0,
188
- }),
189
- new werift_1.RTCRtpCodecParameters({
190
- mimeType: 'audio/PCMA',
191
- clockRate: 8000,
192
- channels: 1,
193
- payloadType: 8,
194
- }),
195
- ],
196
- },
197
- });
198
- }
199
- }
200
- exports.WebsocketProxy = WebsocketProxy;
201
- //# sourceMappingURL=ws.js.map
package/d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AAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;wBACxJ,UAAU,EAAE,wEAAwE;qBACrF,CAAC;iBACH;gBACD,KAAK,EAAE;oBACL,IAAI,8BAAqB,CAAC;wBACxB,QAAQ,EAAE,YAAY;wBACtB,SAAS,EAAE,KAAK;wBAChB,WAAW,EAAE,GAAG;wBAChB,QAAQ,EAAE,CAAC;wBACX,UAAU,EAAE,4BAA4B;qBACzC,CAAC;oBACF,IAAI,8BAAqB,CAAC;wBACxB,QAAQ,EAAE,YAAY;wBACtB,SAAS,EAAE,IAAI;wBACf,QAAQ,EAAE,CAAC;wBACX,WAAW,EAAE,CAAC;qBACf,CAAC;oBACF,IAAI,8BAAqB,CAAC;wBACxB,QAAQ,EAAE,YAAY;wBACtB,SAAS,EAAE,IAAI;wBACf,QAAQ,EAAE,CAAC;wBACX,WAAW,EAAE,CAAC;qBACf,CAAC;iBACH;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF;AA9ND,wCA8NC"}
@@ -1,16 +0,0 @@
1
- {
2
- "server": {
3
- "listen": 9999,
4
- "username": "camera.ui",
5
- "password": "camera.ui"
6
- },
7
- "homes": [
8
- {
9
- "test": {
10
- "username": "test",
11
- "password": "test",
12
- "pin": "123"
13
- }
14
- }
15
- ]
16
- }