@eyepop.ai/eyepop 1.11.3 → 1.11.5

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.
@@ -797,23 +797,12 @@ declare class Stream<Prediction> implements AsyncIterable<Prediction> {
797
797
  controller: AbortController;
798
798
  constructor(iterator: () => AsyncIterator<Prediction>, controller: AbortController);
799
799
  static iterFromReadableStream<Prediction>(readableStream: Promise<ReadableStream<Uint8Array>>, controller: AbortController, eventHandler: (event: StreamEvent) => Promise<void>): AsyncIterator<Prediction, any, undefined>;
800
- /**
801
- * Generates a Stream from a newline-separated ReadableStream
802
- * where each item is a JSON value.
803
- */
804
- static fromReadableStream<Prediction>(readableStream: ReadableStream<Uint8Array>, controller: AbortController): Stream<Prediction>;
805
800
  [Symbol.asyncIterator](): AsyncIterator<Prediction>;
806
801
  /**
807
802
  * Splits the stream into two streams which can be
808
803
  * independently read from at different speeds.
809
804
  */
810
805
  tee(): [Stream<Prediction>, Stream<Prediction>];
811
- /**
812
- * Converts this stream to a newline-separated ReadableStream of
813
- * JSON stringified values in the stream
814
- * which can be turned back into a Stream with `Stream.fromReadableStream()`.
815
- */
816
- toReadableStream(): ReadableStream;
817
806
  }
818
807
 
819
808
  declare class AbstractJob implements ResultStream {
@@ -797,23 +797,12 @@ declare class Stream<Prediction> implements AsyncIterable<Prediction> {
797
797
  controller: AbortController;
798
798
  constructor(iterator: () => AsyncIterator<Prediction>, controller: AbortController);
799
799
  static iterFromReadableStream<Prediction>(readableStream: Promise<ReadableStream<Uint8Array>>, controller: AbortController, eventHandler: (event: StreamEvent) => Promise<void>): AsyncIterator<Prediction, any, undefined>;
800
- /**
801
- * Generates a Stream from a newline-separated ReadableStream
802
- * where each item is a JSON value.
803
- */
804
- static fromReadableStream<Prediction>(readableStream: ReadableStream<Uint8Array>, controller: AbortController): Stream<Prediction>;
805
800
  [Symbol.asyncIterator](): AsyncIterator<Prediction>;
806
801
  /**
807
802
  * Splits the stream into two streams which can be
808
803
  * independently read from at different speeds.
809
804
  */
810
805
  tee(): [Stream<Prediction>, Stream<Prediction>];
811
- /**
812
- * Converts this stream to a newline-separated ReadableStream of
813
- * JSON stringified values in the stream
814
- * which can be turned back into a Stream with `Stream.fromReadableStream()`.
815
- */
816
- toReadableStream(): ReadableStream;
817
806
  }
818
807
 
819
808
  declare class AbstractJob implements ResultStream {
@@ -8717,9 +8717,6 @@ var Stream = class _Stream {
8717
8717
  const lineDecoder = new EyepopLineDecoder();
8718
8718
  const iter = readableStreamAsyncIterable(await readableStream);
8719
8719
  for await (let chunk of iter) {
8720
- if (typeof chunk === "number") {
8721
- chunk = new Uint8Array([chunk & 255]);
8722
- }
8723
8720
  for (const line of lineDecoder.decode(chunk)) {
8724
8721
  yield line;
8725
8722
  }
@@ -8758,48 +8755,6 @@ var Stream = class _Stream {
8758
8755
  }
8759
8756
  return iterator();
8760
8757
  }
8761
- /**
8762
- * Generates a Stream from a newline-separated ReadableStream
8763
- * where each item is a JSON value.
8764
- */
8765
- static fromReadableStream(readableStream, controller) {
8766
- let consumed = false;
8767
- async function* iterLines() {
8768
- const lineDecoder = new EyepopLineDecoder();
8769
- const iter = readableStreamAsyncIterable(readableStream);
8770
- for await (let chunk of iter) {
8771
- if (typeof chunk === "number") {
8772
- chunk = new Uint8Array([chunk & 255]);
8773
- }
8774
- for (const line of lineDecoder.decode(chunk)) {
8775
- yield line;
8776
- }
8777
- }
8778
- for (const line of lineDecoder.flush()) {
8779
- yield line;
8780
- }
8781
- }
8782
- async function* iterator() {
8783
- if (consumed) {
8784
- throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
8785
- }
8786
- consumed = true;
8787
- let done = false;
8788
- try {
8789
- for await (const line of iterLines()) {
8790
- if (done) continue;
8791
- if (line) yield JSON.parse(line);
8792
- }
8793
- done = true;
8794
- } catch (e) {
8795
- if (e instanceof Error && e.name === "AbortError") return;
8796
- throw e;
8797
- } finally {
8798
- if (!done) controller.abort();
8799
- }
8800
- }
8801
- return new _Stream(iterator, controller);
8802
- }
8803
8758
  [Symbol.asyncIterator]() {
8804
8759
  return this.iterator();
8805
8760
  }
@@ -8825,34 +8780,6 @@ var Stream = class _Stream {
8825
8780
  };
8826
8781
  return [new _Stream(() => teeIterator(left), this.controller), new _Stream(() => teeIterator(right), this.controller)];
8827
8782
  }
8828
- /**
8829
- * Converts this stream to a newline-separated ReadableStream of
8830
- * JSON stringified values in the stream
8831
- * which can be turned back into a Stream with `Stream.fromReadableStream()`.
8832
- */
8833
- toReadableStream() {
8834
- const self = this;
8835
- let iter;
8836
- const encoder = new TextEncoder();
8837
- return new ReadableStream({
8838
- async start() {
8839
- iter = self[Symbol.asyncIterator]();
8840
- },
8841
- async pull(ctrl) {
8842
- try {
8843
- const { value, done } = await iter.next();
8844
- if (done) return ctrl.close();
8845
- const bytes = encoder.encode(JSON.stringify(value) + "\n");
8846
- ctrl.enqueue(bytes);
8847
- } catch (err) {
8848
- ctrl.error(err);
8849
- }
8850
- },
8851
- async cancel() {
8852
- await iter.return?.();
8853
- }
8854
- });
8855
- }
8856
8783
  };
8857
8784
  var _EyepopLineDecoder = class _EyepopLineDecoder {
8858
8785
  // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
@@ -8926,7 +8853,9 @@ _EyepopLineDecoder.NEWLINE_CHARS = /* @__PURE__ */ new Set(["\n", "\r", "\v", "\
8926
8853
  _EyepopLineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
8927
8854
  var EyepopLineDecoder = _EyepopLineDecoder;
8928
8855
  function readableStreamAsyncIterable(stream) {
8929
- if (stream[Symbol.asyncIterator]) return stream;
8856
+ if (stream[Symbol.asyncIterator]) {
8857
+ return stream[Symbol.asyncIterator]();
8858
+ }
8930
8859
  const reader = stream.getReader();
8931
8860
  return {
8932
8861
  async next() {
@@ -9484,7 +9413,7 @@ var WebrtcBase = class _WebrtcBase {
9484
9413
  // worker/webrtc_whip.ts
9485
9414
  var WebrtcWhip = class extends WebrtcBase {
9486
9415
  constructor(stream, getSession, client, requestLogger) {
9487
- super(getSession, client, (0, import_uuid.v4)().toString(), "/liveIngress/whip", requestLogger);
9416
+ super(getSession, client, (0, import_uuid.v4)().toString(), "liveIngress/whip", requestLogger);
9488
9417
  this._stream = stream;
9489
9418
  }
9490
9419
  async start() {
@@ -9567,7 +9496,7 @@ var WebrtcWhip = class extends WebrtcBase {
9567
9496
  // worker/webrtc_whep.ts
9568
9497
  var WebrtcWhep = class extends WebrtcBase {
9569
9498
  constructor(ingressId, getSession, client, requestLogger) {
9570
- super(getSession, client, ingressId, "/liveIngress/whep", requestLogger);
9499
+ super(getSession, client, ingressId, "liveIngress/whep", requestLogger);
9571
9500
  this._stream = null;
9572
9501
  }
9573
9502
  async close() {
@@ -9691,7 +9620,7 @@ var iteratorToStream2;
9691
9620
  // shims/http_client.ts
9692
9621
  var createHttpClient;
9693
9622
  if ("document" in globalThis && "implementation" in globalThis.document) {
9694
- class HttpClient2 {
9623
+ class BrowserHttpClient {
9695
9624
  constructor() {
9696
9625
  }
9697
9626
  async fetch(input, init) {
@@ -9702,14 +9631,15 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9702
9631
  }
9703
9632
  createHttpClient = async () => {
9704
9633
  console.debug("EyePop: creating HttpClient in browser");
9705
- return new HttpClient2();
9634
+ return new BrowserHttpClient();
9706
9635
  };
9707
- }
9708
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9709
- class HttpClient2 {
9636
+ } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9637
+ class ReactNativeHttpClient {
9710
9638
  constructor() {
9711
9639
  }
9712
9640
  async fetch(input, init) {
9641
+ init || (init = {});
9642
+ init.reactNative = { textStreaming: true };
9713
9643
  return await fetch(input, init);
9714
9644
  }
9715
9645
  async close() {
@@ -9717,10 +9647,10 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9717
9647
  }
9718
9648
  createHttpClient = async () => {
9719
9649
  console.debug("EyePop: creating HttpClient in ReactNative");
9720
- return new HttpClient2();
9650
+ return new ReactNativeHttpClient();
9721
9651
  };
9722
9652
  } else {
9723
- class HttpClient2 {
9653
+ class NodeHttpClient {
9724
9654
  constructor(agent) {
9725
9655
  this.agent = agent;
9726
9656
  }
@@ -9742,7 +9672,7 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9742
9672
  // two parallel streaming requests to the same host seem to deadlock with pipelining > 0
9743
9673
  pipelining: 0
9744
9674
  });
9745
- return new HttpClient2(agent);
9675
+ return new NodeHttpClient(agent);
9746
9676
  };
9747
9677
  }
9748
9678