@eyepop.ai/eyepop 0.9.2 → 0.11.0

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.
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5
+ * @license MIT
6
+ */
7
+
8
+ /*!
9
+ * The buffer module from node.js, for the browser.
10
+ *
11
+ * @author Feross Aboukhadijeh <https://feross.org>
12
+ * @license MIT
13
+ */
14
+
15
+ /*! Bundled license information:
16
+
17
+ mime-db/index.js:
18
+ (*!
19
+ * mime-db
20
+ * Copyright(c) 2014 Jonathan Ong
21
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
22
+ * MIT Licensed
23
+ *)
24
+
25
+ mime-types/index.js:
26
+ (*!
27
+ * mime-types
28
+ * Copyright(c) 2014 Jonathan Ong
29
+ * Copyright(c) 2015 Douglas Christopher Wilson
30
+ * MIT Licensed
31
+ *)
32
+ */
33
+
34
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
35
+
36
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
package/dist/index.d.mts CHANGED
@@ -2,8 +2,30 @@ import { Logger } from 'pino';
2
2
  import { CanvasRenderingContext2D } from 'canvas';
3
3
 
4
4
  interface Session {
5
+ readonly eyepopUrl: string;
6
+ readonly popId: string;
5
7
  readonly accessToken: string;
6
- readonly validUntil: Date;
8
+ readonly validUntil: number;
9
+ }
10
+ interface SessionPlus extends Session {
11
+ readonly baseUrl: string;
12
+ readonly pipelineId: string;
13
+ }
14
+ declare enum EndpointState {
15
+ Idle = "Idle",
16
+ Busy = "Busy",
17
+ Authenticating = "Authenticating",
18
+ FetchConfig = "FetchConfig",
19
+ StartingPop = "StartingPop",
20
+ Error = "Error"
21
+ }
22
+ interface LiveIngress {
23
+ ingressId(): string;
24
+ close(): Promise<void>;
25
+ }
26
+ interface IngressEvent {
27
+ readonly ingressId?: string;
28
+ readonly event?: "stream-ready" | "stream-ready";
7
29
  }
8
30
  interface UploadParams {
9
31
  readonly filePath?: string | undefined;
@@ -60,8 +82,11 @@ interface PredictedKeyPoints {
60
82
  }
61
83
  interface PredictedKeyPoint extends Point3d, PredictedClass {
62
84
  }
85
+ interface ResultStream extends AsyncIterable<Prediction> {
86
+ cancel(): void;
87
+ }
63
88
 
64
- interface Options {
89
+ interface Authentication {
65
90
  /**
66
91
  * Authentication secret for server side execution.
67
92
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
@@ -71,6 +96,14 @@ interface Options {
71
96
  * Temporary authentication token for client side execution.
72
97
  */
73
98
  session?: Session | undefined;
99
+ /**
100
+ * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
101
+ * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
102
+ */
103
+ oAuth?: true | string | undefined;
104
+ }
105
+ interface Options {
106
+ auth?: Authentication | undefined;
74
107
  /**
75
108
  * Defaults to process.env['EYEPOP_POP_ID'].
76
109
  */
@@ -87,10 +120,6 @@ interface Options {
87
120
  logger?: Logger | undefined;
88
121
  }
89
122
 
90
- interface ResultStream extends AsyncIterable<Prediction> {
91
- cancel(): void;
92
- }
93
-
94
123
  declare class Endpoint {
95
124
  private _options;
96
125
  private _token;
@@ -100,18 +129,34 @@ declare class Endpoint {
100
129
  private _popName;
101
130
  private _client;
102
131
  private _limit;
132
+ private _state;
133
+ private _stateChangeHandler;
134
+ private _ingressEventHandler;
135
+ private _ingressEventWs;
103
136
  private _logger;
104
137
  private readonly _requestLogger;
105
138
  constructor(options: Options);
139
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
140
+ private startIngressWs;
141
+ onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
142
+ state(): EndpointState;
143
+ pendingJobs(): number;
106
144
  popName(): string | null;
107
- session(): Promise<Session>;
145
+ popId(): string | null;
146
+ session(): Promise<SessionPlus>;
147
+ liveIngress(stream: MediaStream): Promise<LiveIngress>;
108
148
  upload(params: UploadParams): Promise<ResultStream>;
109
149
  loadFrom(location: string): Promise<ResultStream>;
150
+ loadLiveIngress(ingressId: string): Promise<ResultStream>;
110
151
  connect(): Promise<Endpoint>;
152
+ private jobDone;
153
+ private updateState;
154
+ private jobStatus;
155
+ private reconnect;
111
156
  disconnect(wait?: boolean): Promise<void>;
112
157
  protected authorizationHeader(): Promise<string>;
113
158
  private currentAccessToken;
114
- private eyepopUrl;
159
+ eyepopUrl(): string;
115
160
  }
116
161
 
117
162
  declare class EyePopPlot {
@@ -129,13 +174,16 @@ declare class EyePopPlot {
129
174
  blank_color: string;
130
175
  };
131
176
  prediction(p: Prediction): void;
132
- object(obj: PredictedObject): void;
177
+ object(obj: PredictedObject, x_scale?: number, y_scale?: number): void;
133
178
  static toTitleCase(str: string): string;
134
179
  }
135
180
 
136
181
  declare class EyePopSdk {
137
- static endpoint({ secretKey, session, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
182
+ static defaultAuth: {
183
+ secretKey: string | undefined;
184
+ };
185
+ static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
138
186
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
139
187
  }
140
188
 
141
- export { EyePopSdk };
189
+ export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type UploadParams, EyePopSdk as default };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,30 @@ import { Logger } from 'pino';
2
2
  import { CanvasRenderingContext2D } from 'canvas';
3
3
 
4
4
  interface Session {
5
+ readonly eyepopUrl: string;
6
+ readonly popId: string;
5
7
  readonly accessToken: string;
6
- readonly validUntil: Date;
8
+ readonly validUntil: number;
9
+ }
10
+ interface SessionPlus extends Session {
11
+ readonly baseUrl: string;
12
+ readonly pipelineId: string;
13
+ }
14
+ declare enum EndpointState {
15
+ Idle = "Idle",
16
+ Busy = "Busy",
17
+ Authenticating = "Authenticating",
18
+ FetchConfig = "FetchConfig",
19
+ StartingPop = "StartingPop",
20
+ Error = "Error"
21
+ }
22
+ interface LiveIngress {
23
+ ingressId(): string;
24
+ close(): Promise<void>;
25
+ }
26
+ interface IngressEvent {
27
+ readonly ingressId?: string;
28
+ readonly event?: "stream-ready" | "stream-ready";
7
29
  }
8
30
  interface UploadParams {
9
31
  readonly filePath?: string | undefined;
@@ -60,8 +82,11 @@ interface PredictedKeyPoints {
60
82
  }
61
83
  interface PredictedKeyPoint extends Point3d, PredictedClass {
62
84
  }
85
+ interface ResultStream extends AsyncIterable<Prediction> {
86
+ cancel(): void;
87
+ }
63
88
 
64
- interface Options {
89
+ interface Authentication {
65
90
  /**
66
91
  * Authentication secret for server side execution.
67
92
  * Defaults to process.env['EYEPOP_SECRET_KEY'].
@@ -71,6 +96,14 @@ interface Options {
71
96
  * Temporary authentication token for client side execution.
72
97
  */
73
98
  session?: Session | undefined;
99
+ /**
100
+ * For development mode, attempt to fetch an session from a logged in EyePop user in the same browser session.
101
+ * Either pass the Url of the dashboard, or true fro the default url 'https://dashboard.eyepop.ai/sdkauth'
102
+ */
103
+ oAuth?: true | string | undefined;
104
+ }
105
+ interface Options {
106
+ auth?: Authentication | undefined;
74
107
  /**
75
108
  * Defaults to process.env['EYEPOP_POP_ID'].
76
109
  */
@@ -87,10 +120,6 @@ interface Options {
87
120
  logger?: Logger | undefined;
88
121
  }
89
122
 
90
- interface ResultStream extends AsyncIterable<Prediction> {
91
- cancel(): void;
92
- }
93
-
94
123
  declare class Endpoint {
95
124
  private _options;
96
125
  private _token;
@@ -100,18 +129,34 @@ declare class Endpoint {
100
129
  private _popName;
101
130
  private _client;
102
131
  private _limit;
132
+ private _state;
133
+ private _stateChangeHandler;
134
+ private _ingressEventHandler;
135
+ private _ingressEventWs;
103
136
  private _logger;
104
137
  private readonly _requestLogger;
105
138
  constructor(options: Options);
139
+ onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): Endpoint;
140
+ private startIngressWs;
141
+ onIngressEvent(handler: (event: IngressEvent) => void): Endpoint;
142
+ state(): EndpointState;
143
+ pendingJobs(): number;
106
144
  popName(): string | null;
107
- session(): Promise<Session>;
145
+ popId(): string | null;
146
+ session(): Promise<SessionPlus>;
147
+ liveIngress(stream: MediaStream): Promise<LiveIngress>;
108
148
  upload(params: UploadParams): Promise<ResultStream>;
109
149
  loadFrom(location: string): Promise<ResultStream>;
150
+ loadLiveIngress(ingressId: string): Promise<ResultStream>;
110
151
  connect(): Promise<Endpoint>;
152
+ private jobDone;
153
+ private updateState;
154
+ private jobStatus;
155
+ private reconnect;
111
156
  disconnect(wait?: boolean): Promise<void>;
112
157
  protected authorizationHeader(): Promise<string>;
113
158
  private currentAccessToken;
114
- private eyepopUrl;
159
+ eyepopUrl(): string;
115
160
  }
116
161
 
117
162
  declare class EyePopPlot {
@@ -129,13 +174,16 @@ declare class EyePopPlot {
129
174
  blank_color: string;
130
175
  };
131
176
  prediction(p: Prediction): void;
132
- object(obj: PredictedObject): void;
177
+ object(obj: PredictedObject, x_scale?: number, y_scale?: number): void;
133
178
  static toTitleCase(str: string): string;
134
179
  }
135
180
 
136
181
  declare class EyePopSdk {
137
- static endpoint({ secretKey, session, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
182
+ static defaultAuth: {
183
+ secretKey: string | undefined;
184
+ };
185
+ static endpoint({ auth, popId, eyepopUrl, autoStart, stopJobs, jobQueueLength, logger, ...opts }?: Options): Endpoint;
138
186
  static plot(context: CanvasRenderingContext2D): EyePopPlot;
139
187
  }
140
188
 
141
- export { EyePopSdk };
189
+ export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type UploadParams, EyePopSdk as default };