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