@eyepop.ai/eyepop 1.12.0 → 1.12.2

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.
@@ -146,6 +146,7 @@ interface Options {
146
146
  interface HttpClient {
147
147
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
148
148
  close(): Promise<void>;
149
+ isFullDuplex(): boolean;
149
150
  }
150
151
 
151
152
  /** Semaphores are initialized with a number of permits that get aquired and released
@@ -287,11 +288,12 @@ interface FileSource {
287
288
  readonly file: File;
288
289
  }
289
290
  interface StreamSource {
290
- readonly stream: ReadableStream<Uint8Array>;
291
+ readonly stream: ReadableStream<Uint8Array> | Blob | BufferSource;
291
292
  readonly mimeType: string;
292
293
  }
293
294
  interface PathSource {
294
295
  readonly path: string;
296
+ readonly mimeType?: string;
295
297
  }
296
298
  interface LiveSource {
297
299
  readonly ingressId: string;
@@ -830,7 +832,7 @@ declare class UploadJob extends AbstractJob {
830
832
  private readonly _mimeType;
831
833
  private readonly _needsFullDuplex;
832
834
  get [Symbol.toStringTag](): string;
833
- constructor(stream: ReadableStream<Uint8Array>, mimeType: string, params: SourceParams | undefined, getSession: () => Promise<WorkerSession>, client: HttpClient, requestLogger: Logger);
835
+ constructor(stream: ReadableStream<Uint8Array> | Blob | BufferSource, mimeType: string, params: SourceParams | undefined, getSession: () => Promise<WorkerSession>, client: HttpClient, requestLogger: Logger);
834
836
  protected onEvent(event: StreamEvent): Promise<void>;
835
837
  protected startJob(): Promise<Response>;
836
838
  }
@@ -146,6 +146,7 @@ interface Options {
146
146
  interface HttpClient {
147
147
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
148
148
  close(): Promise<void>;
149
+ isFullDuplex(): boolean;
149
150
  }
150
151
 
151
152
  /** Semaphores are initialized with a number of permits that get aquired and released
@@ -287,11 +288,12 @@ interface FileSource {
287
288
  readonly file: File;
288
289
  }
289
290
  interface StreamSource {
290
- readonly stream: ReadableStream<Uint8Array>;
291
+ readonly stream: ReadableStream<Uint8Array> | Blob | BufferSource;
291
292
  readonly mimeType: string;
292
293
  }
293
294
  interface PathSource {
294
295
  readonly path: string;
296
+ readonly mimeType?: string;
295
297
  }
296
298
  interface LiveSource {
297
299
  readonly ingressId: string;
@@ -830,7 +832,7 @@ declare class UploadJob extends AbstractJob {
830
832
  private readonly _mimeType;
831
833
  private readonly _needsFullDuplex;
832
834
  get [Symbol.toStringTag](): string;
833
- constructor(stream: ReadableStream<Uint8Array>, mimeType: string, params: SourceParams | undefined, getSession: () => Promise<WorkerSession>, client: HttpClient, requestLogger: Logger);
835
+ constructor(stream: ReadableStream<Uint8Array> | Blob | BufferSource, mimeType: string, params: SourceParams | undefined, getSession: () => Promise<WorkerSession>, client: HttpClient, requestLogger: Logger);
834
836
  protected onEvent(event: StreamEvent): Promise<void>;
835
837
  protected startJob(): Promise<Response>;
836
838
  }
@@ -8969,7 +8969,7 @@ var UploadJob = class extends AbstractJob {
8969
8969
  super(params, getSession, client, requestLogger);
8970
8970
  this._uploadStream = stream;
8971
8971
  this._mimeType = mimeType;
8972
- this._needsFullDuplex = mimeType.startsWith("video/");
8972
+ this._needsFullDuplex = !client.isFullDuplex() && mimeType.startsWith("video/");
8973
8973
  }
8974
8974
  async onEvent(event) {
8975
8975
  if (event.type == "prepared") {
@@ -9042,7 +9042,7 @@ var UploadJob = class extends AbstractJob {
9042
9042
  ...session.authenticationHeaders(),
9043
9043
  Accept: "application/jsonl"
9044
9044
  };
9045
- this._requestLogger.debug("before POST %s to prepare full duplex upload", prepareUrl);
9045
+ this._requestLogger.debug("before POST {} to prepare full duplex upload", prepareUrl);
9046
9046
  response = await this._client.fetch(prepareUrl, {
9047
9047
  headers,
9048
9048
  method: "POST",
@@ -9050,11 +9050,11 @@ var UploadJob = class extends AbstractJob {
9050
9050
  // @ts-ignore
9051
9051
  duplex: "half"
9052
9052
  });
9053
- this._requestLogger.debug("after POST %s to prepare full duplex upload", prepareUrl);
9053
+ this._requestLogger.debug("after POST {} to prepare full duplex upload {} {}", prepareUrl, response.status, response.statusText);
9054
9054
  } else {
9055
9055
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync`;
9056
9056
  if (this._params) {
9057
- this._requestLogger.debug("before POST %s with multipart body because of params", postUrl);
9057
+ this._requestLogger.debug("before POST {} with multipart body because of params", postUrl);
9058
9058
  const params = JSON.stringify(this._params);
9059
9059
  const paramBlob = new Blob([params], { type: "application/json" });
9060
9060
  const formData = new FormData();
@@ -9594,6 +9594,15 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9594
9594
  resolvePath = async (source) => {
9595
9595
  throw new DOMException("resolving a path to a file is not supported in browser");
9596
9596
  };
9597
+ } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9598
+ resolvePath = async (source) => {
9599
+ const response = await fetch(`file://${source.path}`);
9600
+ const blob = await response.blob();
9601
+ return {
9602
+ stream: blob,
9603
+ mimeType: source.mimeType || "image/*"
9604
+ };
9605
+ };
9597
9606
  } else {
9598
9607
  let iteratorToStream = function(iterator) {
9599
9608
  return new ReadableStream({
@@ -9620,7 +9629,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9620
9629
  const stream = fd.createReadStream();
9621
9630
  const iterator = nodeStreamToIterator(stream);
9622
9631
  const webStream = iteratorToStream(iterator);
9623
- const mimeType = mime.lookup(source.path) || "application/octet-stream";
9632
+ const mimeType = source.mimeType ? source.mimeType : mime.lookup(source.path) || "image/*";
9624
9633
  return {
9625
9634
  stream: webStream,
9626
9635
  mimeType
@@ -9640,6 +9649,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9640
9649
  }
9641
9650
  async close() {
9642
9651
  }
9652
+ isFullDuplex() {
9653
+ return false;
9654
+ }
9643
9655
  }
9644
9656
  createHttpClient = async () => {
9645
9657
  return new BrowserHttpClient();
@@ -9655,6 +9667,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9655
9667
  }
9656
9668
  async close() {
9657
9669
  }
9670
+ isFullDuplex() {
9671
+ return true;
9672
+ }
9658
9673
  }
9659
9674
  createHttpClient = async () => {
9660
9675
  return new ReactNativeHttpClient();
@@ -9672,6 +9687,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9672
9687
  async close() {
9673
9688
  return this.agent.close();
9674
9689
  }
9690
+ isFullDuplex() {
9691
+ return false;
9692
+ }
9675
9693
  }
9676
9694
  createHttpClient = async () => {
9677
9695
  const undici = require("undici");
@@ -10466,6 +10484,11 @@ var WorkerEndpoint = class extends Endpoint {
10466
10484
  }
10467
10485
  }
10468
10486
  async loadFrom(source, params) {
10487
+ if (source.url.startsWith("file://")) {
10488
+ return await this.uploadPath({
10489
+ path: source.url.substring("file://".length)
10490
+ }, params);
10491
+ }
10469
10492
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10470
10493
  throw new Error("endpoint not connected, use connect() before loadFrom()");
10471
10494
  }