@eyepop.ai/eyepop 1.5.7 → 1.6.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.
@@ -11,7 +11,8 @@ declare enum EndpointState {
11
11
  Busy = "Busy",
12
12
  Authenticating = "Authenticating",
13
13
  FetchConfig = "FetchConfig",
14
- Error = "Error"
14
+ Error = "Error",
15
+ NotAvailable = "NotAvailable"
15
16
  }
16
17
  interface Box {
17
18
  readonly topLeft: Point2d;
@@ -225,6 +226,7 @@ declare class Endpoint<T extends Endpoint<T>> {
225
226
  private _statusRetryHandlers;
226
227
  protected _limit: Semaphore;
227
228
  private _state;
229
+ private _message;
228
230
  private _stateChangeHandler;
229
231
  protected _logger: Logger;
230
232
  protected readonly _requestLogger: Logger;
@@ -233,8 +235,9 @@ declare class Endpoint<T extends Endpoint<T>> {
233
235
  eyepopUrl(): string;
234
236
  pendingJobs(): number;
235
237
  state(): EndpointState;
238
+ lastMessage(): string | null;
236
239
  onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): T;
237
- protected updateState(newState?: EndpointState | undefined): void;
240
+ protected updateState(newState?: EndpointState | undefined, message?: string | undefined): void;
238
241
  connect(): Promise<T>;
239
242
  disconnect(wait?: boolean): Promise<void>;
240
243
  session(): Promise<Session>;
@@ -11,7 +11,8 @@ declare enum EndpointState {
11
11
  Busy = "Busy",
12
12
  Authenticating = "Authenticating",
13
13
  FetchConfig = "FetchConfig",
14
- Error = "Error"
14
+ Error = "Error",
15
+ NotAvailable = "NotAvailable"
15
16
  }
16
17
  interface Box {
17
18
  readonly topLeft: Point2d;
@@ -225,6 +226,7 @@ declare class Endpoint<T extends Endpoint<T>> {
225
226
  private _statusRetryHandlers;
226
227
  protected _limit: Semaphore;
227
228
  private _state;
229
+ private _message;
228
230
  private _stateChangeHandler;
229
231
  protected _logger: Logger;
230
232
  protected readonly _requestLogger: Logger;
@@ -233,8 +235,9 @@ declare class Endpoint<T extends Endpoint<T>> {
233
235
  eyepopUrl(): string;
234
236
  pendingJobs(): number;
235
237
  state(): EndpointState;
238
+ lastMessage(): string | null;
236
239
  onStateChanged(handler: (fromState: EndpointState, toState: EndpointState) => void): T;
237
- protected updateState(newState?: EndpointState | undefined): void;
240
+ protected updateState(newState?: EndpointState | undefined, message?: string | undefined): void;
238
241
  connect(): Promise<T>;
239
242
  disconnect(wait?: boolean): Promise<void>;
240
243
  session(): Promise<Session>;
@@ -8698,6 +8698,7 @@ var EndpointState = /* @__PURE__ */ ((EndpointState2) => {
8698
8698
  EndpointState2["Authenticating"] = "Authenticating";
8699
8699
  EndpointState2["FetchConfig"] = "FetchConfig";
8700
8700
  EndpointState2["Error"] = "Error";
8701
+ EndpointState2["NotAvailable"] = "NotAvailable";
8701
8702
  return EndpointState2;
8702
8703
  })(EndpointState || {});
8703
8704
 
@@ -9972,6 +9973,7 @@ var Endpoint = class {
9972
9973
  this._statusRetryHandlers.set(401, this.statusHandler401);
9973
9974
  this._limit = new Semaphore(this._options.jobQueueLength ?? 1024);
9974
9975
  this._state = "Idle" /* Idle */;
9976
+ this._message = null;
9975
9977
  this._stateChangeHandler = null;
9976
9978
  let rootLogger;
9977
9979
  if (options.logger) {
@@ -9999,11 +10001,14 @@ var Endpoint = class {
9999
10001
  state() {
10000
10002
  return this._state;
10001
10003
  }
10004
+ lastMessage() {
10005
+ return this._message;
10006
+ }
10002
10007
  onStateChanged(handler) {
10003
10008
  this._stateChangeHandler = handler;
10004
10009
  return this;
10005
10010
  }
10006
- updateState(newState = void 0) {
10011
+ updateState(newState = void 0, message = void 0) {
10007
10012
  const fromState = this._state;
10008
10013
  if (newState == void 0) {
10009
10014
  if (this._limit.getPermits() == this._options.jobQueueLength) {
@@ -10013,6 +10018,7 @@ var Endpoint = class {
10013
10018
  }
10014
10019
  }
10015
10020
  this._state = newState;
10021
+ this._message = message ? message : null;
10016
10022
  if (this._stateChangeHandler) {
10017
10023
  this._stateChangeHandler(fromState, this._state);
10018
10024
  }
@@ -10478,8 +10484,12 @@ var WorkerEndpoint = class extends Endpoint {
10478
10484
  });
10479
10485
  }
10480
10486
  if (response.status != 200) {
10481
- this.updateState("Error" /* Error */);
10482
10487
  const message = await response.text();
10488
+ if (response.status == 429) {
10489
+ this.updateState("NotAvailable" /* NotAvailable */, message);
10490
+ } else {
10491
+ this.updateState("Error" /* Error */, message);
10492
+ }
10483
10493
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10484
10494
  }
10485
10495
  let config = await response.json();