@eyepop.ai/eyepop 1.11.2 → 1.11.4

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.
@@ -8654,7 +8654,7 @@ var Stream = class _Stream {
8654
8654
  async function* iterLines() {
8655
8655
  const lineDecoder = new EyepopLineDecoder();
8656
8656
  const iter = readableStreamAsyncIterable(await readableStream);
8657
- for await (const chunk of iter) {
8657
+ for await (let chunk of iter) {
8658
8658
  for (const line of lineDecoder.decode(chunk)) {
8659
8659
  yield line;
8660
8660
  }
@@ -8693,45 +8693,6 @@ var Stream = class _Stream {
8693
8693
  }
8694
8694
  return iterator();
8695
8695
  }
8696
- /**
8697
- * Generates a Stream from a newline-separated ReadableStream
8698
- * where each item is a JSON value.
8699
- */
8700
- static fromReadableStream(readableStream, controller) {
8701
- let consumed = false;
8702
- async function* iterLines() {
8703
- const lineDecoder = new EyepopLineDecoder();
8704
- const iter = readableStreamAsyncIterable(readableStream);
8705
- for await (const chunk of iter) {
8706
- for (const line of lineDecoder.decode(chunk)) {
8707
- yield line;
8708
- }
8709
- }
8710
- for (const line of lineDecoder.flush()) {
8711
- yield line;
8712
- }
8713
- }
8714
- async function* iterator() {
8715
- if (consumed) {
8716
- throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
8717
- }
8718
- consumed = true;
8719
- let done = false;
8720
- try {
8721
- for await (const line of iterLines()) {
8722
- if (done) continue;
8723
- if (line) yield JSON.parse(line);
8724
- }
8725
- done = true;
8726
- } catch (e) {
8727
- if (e instanceof Error && e.name === "AbortError") return;
8728
- throw e;
8729
- } finally {
8730
- if (!done) controller.abort();
8731
- }
8732
- }
8733
- return new _Stream(iterator, controller);
8734
- }
8735
8696
  [Symbol.asyncIterator]() {
8736
8697
  return this.iterator();
8737
8698
  }
@@ -8757,34 +8718,6 @@ var Stream = class _Stream {
8757
8718
  };
8758
8719
  return [new _Stream(() => teeIterator(left), this.controller), new _Stream(() => teeIterator(right), this.controller)];
8759
8720
  }
8760
- /**
8761
- * Converts this stream to a newline-separated ReadableStream of
8762
- * JSON stringified values in the stream
8763
- * which can be turned back into a Stream with `Stream.fromReadableStream()`.
8764
- */
8765
- toReadableStream() {
8766
- const self = this;
8767
- let iter;
8768
- const encoder = new TextEncoder();
8769
- return new ReadableStream({
8770
- async start() {
8771
- iter = self[Symbol.asyncIterator]();
8772
- },
8773
- async pull(ctrl) {
8774
- try {
8775
- const { value, done } = await iter.next();
8776
- if (done) return ctrl.close();
8777
- const bytes = encoder.encode(JSON.stringify(value) + "\n");
8778
- ctrl.enqueue(bytes);
8779
- } catch (err) {
8780
- ctrl.error(err);
8781
- }
8782
- },
8783
- async cancel() {
8784
- await iter.return?.();
8785
- }
8786
- });
8787
- }
8788
8721
  };
8789
8722
  var _EyepopLineDecoder = class _EyepopLineDecoder {
8790
8723
  // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
@@ -8858,7 +8791,9 @@ _EyepopLineDecoder.NEWLINE_CHARS = /* @__PURE__ */ new Set(["\n", "\r", "\v", "\
8858
8791
  _EyepopLineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
8859
8792
  var EyepopLineDecoder = _EyepopLineDecoder;
8860
8793
  function readableStreamAsyncIterable(stream) {
8861
- if (stream[Symbol.asyncIterator]) return stream;
8794
+ if (stream[Symbol.asyncIterator]) {
8795
+ return stream[Symbol.asyncIterator]();
8796
+ }
8862
8797
  const reader = stream.getReader();
8863
8798
  return {
8864
8799
  async next() {
@@ -9623,7 +9558,7 @@ var iteratorToStream2;
9623
9558
  // shims/http_client.ts
9624
9559
  var createHttpClient;
9625
9560
  if ("document" in globalThis && "implementation" in globalThis.document) {
9626
- class HttpClient2 {
9561
+ class BrowserHttpClient {
9627
9562
  constructor() {
9628
9563
  }
9629
9564
  async fetch(input, init) {
@@ -9634,14 +9569,16 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9634
9569
  }
9635
9570
  createHttpClient = async () => {
9636
9571
  console.debug("EyePop: creating HttpClient in browser");
9637
- return new HttpClient2();
9572
+ return new BrowserHttpClient();
9638
9573
  };
9639
9574
  }
9640
9575
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9641
- class HttpClient2 {
9576
+ class ReactNativeHttpClient {
9642
9577
  constructor() {
9643
9578
  }
9644
9579
  async fetch(input, init) {
9580
+ init || (init = {});
9581
+ init.reactNative = { textStreaming: true };
9645
9582
  return await fetch(input, init);
9646
9583
  }
9647
9584
  async close() {
@@ -9649,10 +9586,10 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9649
9586
  }
9650
9587
  createHttpClient = async () => {
9651
9588
  console.debug("EyePop: creating HttpClient in ReactNative");
9652
- return new HttpClient2();
9589
+ return new ReactNativeHttpClient();
9653
9590
  };
9654
9591
  } else {
9655
- class HttpClient2 {
9592
+ class NodeHttpClient {
9656
9593
  constructor(agent) {
9657
9594
  this.agent = agent;
9658
9595
  }
@@ -9674,7 +9611,7 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9674
9611
  // two parallel streaming requests to the same host seem to deadlock with pipelining > 0
9675
9612
  pipelining: 0
9676
9613
  });
9677
- return new HttpClient2(agent);
9614
+ return new NodeHttpClient(agent);
9678
9615
  };
9679
9616
  }
9680
9617