@3deye-toolkit/react-camera 0.0.1-alpha.21 → 0.0.1-alpha.24

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { BehaviorSubject } from 'rxjs';
4
4
  import crossfilter from 'crossfilter2';
5
- import { IReactionDisposer } from 'mobx';
5
+ import type { IReactionDisposer } from 'mobx';
6
6
  import { Observable } from 'rxjs';
7
7
  import { default as React_2 } from 'react';
8
8
  import { Subject } from 'rxjs';
@@ -78,6 +78,7 @@ declare class ArchiveChunk_2 implements Chunk_2 {
78
78
  }
79
79
 
80
80
  declare class ArchivesStore extends ApiStore {
81
+ private camerasStore;
81
82
  data: crossfilter.Crossfilter<ArchiveChunk_2>;
82
83
  chunksByCameraId: crossfilter.Dimension<ArchiveChunk_2, number>;
83
84
  chunksByStart: crossfilter.Dimension<ArchiveChunk_2, number>;
@@ -89,22 +90,47 @@ declare class ArchivesStore extends ApiStore {
89
90
  private pendingRequestsByCameraId;
90
91
  knownIntervals: Map<number, [Date, Date]>;
91
92
  updates: number;
92
- constructor();
93
+ constructor(camerasStore: CamerasStore);
93
94
  /**
94
95
  * Fetches archive chunks for given camera and period
95
96
  * @param cameraId - camera id
96
97
  * @param startTime - start of the period
97
98
  * @param endTime - end of the period
98
99
  * TODO: add support for null endTime in order to remove requestedArchivesSince logic from player controller
100
+ * TODO: add error handling
99
101
  */
100
102
  fetch(cameraId: number, startTime: Date, endTime: Date): Observable<ArchiveChunk_2[]>;
101
- extendKnownInterval(cameraId: number, chunks: ArchiveChunk_2[]): void;
103
+ extendKnownInterval(cameraId: number, startTime: Date, chunks: ArchiveChunk_2[]): void;
102
104
  add(chunks: ArchiveChunk_2[]): void;
103
105
  getChunks({ cameraId, from, to }: ChunksQuery): ArchiveChunk_2[];
104
- findClosestChunk({ cameraId, time }: {
106
+ /**
107
+ * Returns chunk that either contain the given time or is right adjacent to it
108
+ * @param camera - camera id
109
+ * @param time - time to search for
110
+ * @returns ArchiveChunk or undefined if there is no such chunk in the current archive
111
+ */
112
+ getClosestChunkRight: ({ cameraId, time }: {
113
+ cameraId: number;
114
+ time: Date;
115
+ }) => ArchiveChunk_2;
116
+ /**
117
+ * Return chunks that either contain the given time or is left adjacent to it
118
+ * @param camera - camera id
119
+ * @param time - time to search for
120
+ * @returns ArchiveChunk or undefined if there is no such chunk in the current archive
121
+ */
122
+ getClosestChunkLeft: ({ cameraId, time }: {
123
+ cameraId: number;
124
+ time: Date;
125
+ }) => ArchiveChunk_2;
126
+ fetchNextChunk: ({ cameraId, time }: {
105
127
  cameraId: number;
106
128
  time: Date;
107
- }): ArchiveChunk_2;
129
+ }) => Observable<ArchiveChunk_2 | undefined>;
130
+ fetchPrevChunk: ({ cameraId, time }: {
131
+ cameraId: number;
132
+ time: Date;
133
+ }) => Observable<ArchiveChunk_2 | undefined>;
108
134
  protected afterInit(): void;
109
135
  }
110
136
 
@@ -114,31 +140,30 @@ declare class Auth {
114
140
  storage: Storage_2;
115
141
  tokenServiceUrl: string;
116
142
  tokenStorageKey: string;
117
- widgetTokenServiceUrl?: string;
118
143
  deviceInfo: string | null;
119
144
  clientId: string;
120
145
  private pendingUpdateTokenRequest;
121
146
  get isAuthenticated(): boolean;
122
- constructor({ tokenServiceUrl, widgetTokenServiceUrl, storage, tokenStorageKey, deviceInfo, clientId }: AuthStoreOptions);
147
+ constructor({ tokenServiceUrl, storage, tokenStorageKey, deviceInfo, clientId }: AuthStoreOptions);
123
148
  signOut: () => void;
124
- signIn: ({ username, password, tokenToKick, agreedWithTerms }: {
149
+ signIn: (options: {
125
150
  username: string;
126
151
  password: string;
127
- tokenToKick?: string | undefined;
128
- agreedWithTerms?: boolean | undefined;
152
+ replaceToken?: string;
153
+ agreedWithTerms?: boolean;
154
+ code?: string;
129
155
  }) => Promise<Token> | undefined;
130
156
  invalidateToken: () => void;
131
157
  getTokenFromStorage(): Promise<Token | null>;
132
158
  private storeToken;
133
159
  private getInitialToken;
134
- private fetchTokenBy;
160
+ private fetchToken;
135
161
  private updateToken;
136
162
  private fetchWidgetToken;
137
163
  }
138
164
 
139
165
  declare interface AuthStoreOptions {
140
166
  tokenServiceUrl: string;
141
- widgetTokenServiceUrl?: string;
142
167
  storage: Storage_2;
143
168
  tokenStorageKey: string;
144
169
  deviceInfo: any;
@@ -158,12 +183,39 @@ export declare const BoxSelector: (({ onSelect, onRequestCancel, onClose }: Prop
158
183
  displayName: string;
159
184
  };
160
185
 
161
- declare const Camera: ((props: Props) => JSX.Element) & {
186
+ export declare class Camera {
187
+ id: number;
188
+ name: string;
189
+ imageUrl: string;
190
+ streamUrl: string;
191
+ dashStreamUrl: string;
192
+ address: {
193
+ Lat: number;
194
+ Lng: number;
195
+ } | null;
196
+ archiveDuration: number;
197
+ dvrWindowLength: number;
198
+ stateUpdatedAt: Date;
199
+ raw: RawCamera;
200
+ enabled: boolean;
201
+ isMicEnabled: boolean;
202
+ state: string;
203
+ pin: string;
204
+ webRtcUrl: string;
205
+ isPtz: boolean;
206
+ permissions: number;
207
+ get isOnline(): boolean;
208
+ get supportsWebRTC(): boolean;
209
+ constructor(raw: RawCamera);
210
+ update: (raw: RawCamera) => void;
211
+ }
212
+
213
+ declare const Camera_2: ((props: Props) => JSX.Element) & {
162
214
  displayName: string;
163
215
  };
164
- export default Camera;
216
+ export default Camera_2;
165
217
 
166
- declare interface Camera_2 {
218
+ declare interface Camera_3 {
167
219
  id: number;
168
220
  name: string;
169
221
  streamUrl: string;
@@ -184,6 +236,19 @@ declare interface Camera_2 {
184
236
  raw: RawCamera;
185
237
  }
186
238
 
239
+ declare class CamerasStore extends ApiStore {
240
+ camerasById: Map<number, Camera>;
241
+ data: Camera[];
242
+ loading: boolean;
243
+ loaded: boolean;
244
+ constructor();
245
+ load: () => Observable<RawCamera[]> | undefined;
246
+ add: (cameras: RawCamera[]) => void;
247
+ sync: () => Observable<RawCamera[]>;
248
+ protected afterInit(): void;
249
+ dispose(): void;
250
+ }
251
+
187
252
  declare interface CameraStatistics {
188
253
  id: number;
189
254
  month: number;
@@ -459,11 +524,12 @@ declare interface PlayerBehavior {
459
524
 
460
525
  export declare const PlayerContext: React_2.Context<PlayerController>;
461
526
 
462
- declare class PlayerController {
527
+ export declare class PlayerController {
463
528
  id: number;
464
529
  disposables: (IReactionDisposer | Subscription)[];
465
530
  liveChunk?: LiveChunk | null;
466
531
  currentTime: Date | null;
532
+ targetTime: Date | null;
467
533
  chunk: ArchiveChunk | LiveChunk | null;
468
534
  paused: boolean;
469
535
  loading: boolean;
@@ -472,14 +538,17 @@ declare class PlayerController {
472
538
  volume: number;
473
539
  muted: boolean;
474
540
  videoResizeMode: VideoResizeMode;
475
- camera: Camera_2;
541
+ camera: Camera_3;
476
542
  stats: any;
477
543
  mode: 'archive' | 'DVR' | 'WebRTC' | null;
478
544
  behavior: PlayerBehavior | null;
545
+ transform: string | null;
479
546
  width: number;
480
547
  height: number;
481
- chunkRequestTime: Date | null;
482
- requestedArchivesSince: Date;
548
+ chunkRequest: {
549
+ time: Date;
550
+ backward: boolean;
551
+ } | null;
483
552
  archivesRequest: Observable<ArchiveChunk[]>;
484
553
  video: HTMLVideoElement;
485
554
  clip?: Clip;
@@ -500,7 +569,7 @@ declare class PlayerController {
500
569
  };
501
570
  seekTime?: Date | null;
502
571
  constructor({ camera, startTime, endTime, clip, archivesStore, behaviors }: {
503
- camera: Camera_2;
572
+ camera: Camera_3;
504
573
  clip?: Clip;
505
574
  startTime?: Date | null;
506
575
  endTime?: Date;
@@ -516,23 +585,40 @@ declare class PlayerController {
516
585
  seekAfterReady(): void;
517
586
  stopLoadingOnError(): void;
518
587
  replaceErrorMessageOnOffline(): void;
519
- changeMedia: ({ time, chunk }: {
520
- time?: Date | null | undefined;
588
+ changeMedia: ({ time, chunk, backward }: {
589
+ time: Date;
521
590
  chunk?: LiveChunk | ArchiveChunk | undefined;
591
+ backward?: boolean | undefined;
522
592
  }) => void;
523
593
  initCurrentTime(): void;
594
+ /**
595
+ * If the chunk after chunk request is the same as the current chunk,
596
+ * then we can dismiss loading indicator and seek.
597
+ */
598
+ initSameChunkRequestFix(): void;
524
599
  initLiveChunkUpdate(): void;
525
600
  initChunkRequest(): void;
526
- requestArchives: (time: Date) => Observable<ArchiveChunk[]>;
527
601
  setupLiveChunk(): void;
528
602
  /**
529
603
  * Inits correct behavior for current player mode
530
604
  */
531
605
  initPlayerBehavior(): void;
606
+ /**
607
+ * Rewind by given amount of milliseconds
608
+ * @param value milliseconds
609
+ * @returns
610
+ */
611
+ seekBackward: (value: number) => void;
612
+ /**
613
+ * Seek forward by given amount of milliseconds
614
+ * @param value
615
+ * @returns
616
+ */
617
+ seekForward: (value: number) => void;
532
618
  goLive: () => void;
533
619
  fallbackToDVR: () => void;
534
- setCamera: (camera: Camera_2) => void;
535
- setCameraAndStartTime: (camera: Camera_2, startTime: Date | null) => void;
620
+ setCamera: (camera: Camera_3) => void;
621
+ setCameraAndStartTime: (camera: Camera_3, startTime: Date | null) => void;
536
622
  toggleResizeMode: () => void;
537
623
  setVideoResizeMode: (mode: VideoResizeMode) => void;
538
624
  toggleMute: () => void;
@@ -541,6 +627,7 @@ declare class PlayerController {
541
627
  setPlaybackRate: (rate: number) => void;
542
628
  reactToVolumeChange(): void;
543
629
  togglePlayback: () => void;
630
+ setTransform(transform: string | null): void;
544
631
  play: () => void;
545
632
  pause: () => void;
546
633
  detach: () => void;
@@ -595,7 +682,13 @@ declare interface Props_7 {
595
682
  onRequestToggleFullscreen: (() => void) | null;
596
683
  }
597
684
 
598
- export declare const PtzControl: React_2.FC;
685
+ declare interface Props_8 {
686
+ style?: React_2.CSSProperties;
687
+ }
688
+
689
+ export declare const PtzControls: (({ style }: Props_8) => JSX.Element) & {
690
+ displayName: string;
691
+ };
599
692
 
600
693
  declare interface RawCamera {
601
694
  id: number;
@@ -716,29 +809,32 @@ declare interface RawSharedClip {
716
809
  validTo: string | Date;
717
810
  }
718
811
 
719
- declare interface RawToken {
720
- access_token: string;
812
+ declare type RawToken = {
721
813
  accessToken: string;
722
- access_token_expires: string;
723
814
  accessTokenExpires: string;
724
- access_token_issued: string;
725
815
  accessTokenIssued: string;
726
- client_id: string;
727
816
  clientId: string;
728
- expires_in: number;
729
817
  expiresIn: number;
730
- refresh_token: string;
731
818
  refreshToken: string;
732
- refresh_token_expires: string;
733
819
  refreshTokenExpires: string;
734
- refresh_token_issued: string;
735
820
  refreshTokenIssued: string;
736
- token_type: string;
737
821
  tokenType: string;
738
822
  userName: string;
823
+ } & {
824
+ access_token: string;
825
+ access_token_expires: string;
826
+ access_token_issued: string;
827
+ client_id: string;
828
+ expires_in: number;
829
+ refresh_token: string;
830
+ refresh_token_expires: string;
831
+ refresh_token_issued: string;
832
+ token_type: string;
833
+ userName: string;
834
+ } & {
739
835
  widgetId?: string;
740
836
  widgetToken?: string;
741
- }
837
+ };
742
838
 
743
839
  declare interface RawUser {
744
840
  id: number;