@@ -8,76 +8,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
88 step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
99 } ) ;
1010} ;
11- var __generator = ( this && this . __generator ) || function ( thisArg , body ) {
12- var _ = { label : 0 , sent : function ( ) { if ( t [ 0 ] & 1 ) throw t [ 1 ] ; return t [ 1 ] ; } , trys : [ ] , ops : [ ] } , f , y , t , g ;
13- return g = { next : verb ( 0 ) , "throw" : verb ( 1 ) , "return" : verb ( 2 ) } , typeof Symbol === "function" && ( g [ Symbol . iterator ] = function ( ) { return this ; } ) , g ;
14- function verb ( n ) { return function ( v ) { return step ( [ n , v ] ) ; } ; }
15- function step ( op ) {
16- if ( f ) throw new TypeError ( "Generator is already executing." ) ;
17- while ( _ ) try {
18- if ( f = 1 , y && ( t = op [ 0 ] & 2 ? y [ "return" ] : op [ 0 ] ? y [ "throw" ] || ( ( t = y [ "return" ] ) && t . call ( y ) , 0 ) : y . next ) && ! ( t = t . call ( y , op [ 1 ] ) ) . done ) return t ;
19- if ( y = 0 , t ) op = [ op [ 0 ] & 2 , t . value ] ;
20- switch ( op [ 0 ] ) {
21- case 0 : case 1 : t = op ; break ;
22- case 4 : _ . label ++ ; return { value : op [ 1 ] , done : false } ;
23- case 5 : _ . label ++ ; y = op [ 1 ] ; op = [ 0 ] ; continue ;
24- case 7 : op = _ . ops . pop ( ) ; _ . trys . pop ( ) ; continue ;
25- default :
26- if ( ! ( t = _ . trys , t = t . length > 0 && t [ t . length - 1 ] ) && ( op [ 0 ] === 6 || op [ 0 ] === 2 ) ) { _ = 0 ; continue ; }
27- if ( op [ 0 ] === 3 && ( ! t || ( op [ 1 ] > t [ 0 ] && op [ 1 ] < t [ 3 ] ) ) ) { _ . label = op [ 1 ] ; break ; }
28- if ( op [ 0 ] === 6 && _ . label < t [ 1 ] ) { _ . label = t [ 1 ] ; t = op ; break ; }
29- if ( t && _ . label < t [ 2 ] ) { _ . label = t [ 2 ] ; _ . ops . push ( op ) ; break ; }
30- if ( t [ 2 ] ) _ . ops . pop ( ) ;
31- _ . trys . pop ( ) ; continue ;
32- }
33- op = body . call ( thisArg , _ ) ;
34- } catch ( e ) { op = [ 6 , e ] ; y = 0 ; } finally { f = t = 0 ; }
35- if ( op [ 0 ] & 5 ) throw op [ 1 ] ; return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
36- }
37- } ;
3811Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3912exports . MotionDetector = void 0 ;
40- var onvif_1 = require ( "onvif" ) ;
41- var TOPIC = / R u l e E n g i n e \/ C e l l M o t i o n D e t e c t o r \/ M o t i o n $ / ;
42- var MotionDetector = /** @ class */ ( function ( ) {
43- function MotionDetector ( cam , id ) {
13+ const onvif_1 = require ( "onvif" ) ;
14+ const TOPIC = / R u l e E n g i n e \/ C e l l M o t i o n D e t e c t o r \/ M o t i o n $ / ;
15+ class MotionDetector {
16+ constructor ( cam , id ) {
4417 this . cam = cam ;
4518 this . id = id ;
4619 this . lastIsMotion = false ;
4720 }
48- MotionDetector . create = function ( id , options ) {
49- return __awaiter ( this , void 0 , void 0 , function ( ) {
50- return __generator ( this , function ( _a ) {
51- return [ 2 /*return*/ , new Promise ( function ( resolve , reject ) {
52- var cam = new onvif_1 . Cam ( options , function ( error ) {
53- if ( error ) {
54- reject ( error ) ;
55- }
56- else {
57- var monitor = new MotionDetector ( cam , id ) ;
58- resolve ( monitor ) ;
59- }
60- } ) ;
61- } ) ] ;
21+ static create ( id , options ) {
22+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
23+ return new Promise ( ( resolve , reject ) => {
24+ const cam = new onvif_1 . Cam ( options , ( error ) => {
25+ if ( error ) {
26+ reject ( error ) ;
27+ }
28+ else {
29+ const monitor = new MotionDetector ( cam , id ) ;
30+ resolve ( monitor ) ;
31+ }
32+ } ) ;
6233 } ) ;
6334 } ) ;
64- } ;
65- MotionDetector . prototype . listen = function ( onMotion ) {
66- var _this = this ;
67- this . cam . on ( 'event' , function ( message ) {
35+ }
36+ listen ( onMotion ) {
37+ this . cam . on ( 'event' , ( message ) => {
6838 var _a , _b ;
6939 if ( ( _b = ( _a = message === null || message === void 0 ? void 0 : message . topic ) === null || _a === void 0 ? void 0 : _a . _ ) === null || _b === void 0 ? void 0 : _b . match ( TOPIC ) ) {
70- var motion = message . message . message . data . simpleItem . $ . Value ;
71- if ( motion !== _this . lastIsMotion ) {
72- _this . lastIsMotion = motion ;
73- onMotion ( motion , _this . id ) ;
40+ const motion = message . message . message . data . simpleItem . $ . Value ;
41+ if ( motion !== this . lastIsMotion ) {
42+ this . lastIsMotion = motion ;
43+ onMotion ( motion , this . id ) ;
7444 }
7545 }
7646 } ) ;
77- } ;
78- MotionDetector . prototype . close = function ( ) {
47+ }
48+ close ( ) {
7949 this . cam . removeAllListeners ( 'event' ) ;
80- } ;
81- return MotionDetector ;
82- } ( ) ) ;
50+ }
51+ }
8352exports . MotionDetector = MotionDetector ;
0 commit comments