@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.
- package/dist/eyepop.index.d.mts +0 -11
- package/dist/eyepop.index.d.ts +0 -11
- package/dist/eyepop.index.js +12 -75
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +12 -75
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.d.mts
CHANGED
|
@@ -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 {
|
package/dist/eyepop.index.d.ts
CHANGED
|
@@ -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 {
|
package/dist/eyepop.index.js
CHANGED
|
@@ -8716,7 +8716,7 @@ var Stream = class _Stream {
|
|
|
8716
8716
|
async function* iterLines() {
|
|
8717
8717
|
const lineDecoder = new EyepopLineDecoder();
|
|
8718
8718
|
const iter = readableStreamAsyncIterable(await readableStream);
|
|
8719
|
-
for await (
|
|
8719
|
+
for await (let chunk of iter) {
|
|
8720
8720
|
for (const line of lineDecoder.decode(chunk)) {
|
|
8721
8721
|
yield line;
|
|
8722
8722
|
}
|
|
@@ -8755,45 +8755,6 @@ var Stream = class _Stream {
|
|
|
8755
8755
|
}
|
|
8756
8756
|
return iterator();
|
|
8757
8757
|
}
|
|
8758
|
-
/**
|
|
8759
|
-
* Generates a Stream from a newline-separated ReadableStream
|
|
8760
|
-
* where each item is a JSON value.
|
|
8761
|
-
*/
|
|
8762
|
-
static fromReadableStream(readableStream, controller) {
|
|
8763
|
-
let consumed = false;
|
|
8764
|
-
async function* iterLines() {
|
|
8765
|
-
const lineDecoder = new EyepopLineDecoder();
|
|
8766
|
-
const iter = readableStreamAsyncIterable(readableStream);
|
|
8767
|
-
for await (const chunk of iter) {
|
|
8768
|
-
for (const line of lineDecoder.decode(chunk)) {
|
|
8769
|
-
yield line;
|
|
8770
|
-
}
|
|
8771
|
-
}
|
|
8772
|
-
for (const line of lineDecoder.flush()) {
|
|
8773
|
-
yield line;
|
|
8774
|
-
}
|
|
8775
|
-
}
|
|
8776
|
-
async function* iterator() {
|
|
8777
|
-
if (consumed) {
|
|
8778
|
-
throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
8779
|
-
}
|
|
8780
|
-
consumed = true;
|
|
8781
|
-
let done = false;
|
|
8782
|
-
try {
|
|
8783
|
-
for await (const line of iterLines()) {
|
|
8784
|
-
if (done) continue;
|
|
8785
|
-
if (line) yield JSON.parse(line);
|
|
8786
|
-
}
|
|
8787
|
-
done = true;
|
|
8788
|
-
} catch (e) {
|
|
8789
|
-
if (e instanceof Error && e.name === "AbortError") return;
|
|
8790
|
-
throw e;
|
|
8791
|
-
} finally {
|
|
8792
|
-
if (!done) controller.abort();
|
|
8793
|
-
}
|
|
8794
|
-
}
|
|
8795
|
-
return new _Stream(iterator, controller);
|
|
8796
|
-
}
|
|
8797
8758
|
[Symbol.asyncIterator]() {
|
|
8798
8759
|
return this.iterator();
|
|
8799
8760
|
}
|
|
@@ -8819,34 +8780,6 @@ var Stream = class _Stream {
|
|
|
8819
8780
|
};
|
|
8820
8781
|
return [new _Stream(() => teeIterator(left), this.controller), new _Stream(() => teeIterator(right), this.controller)];
|
|
8821
8782
|
}
|
|
8822
|
-
/**
|
|
8823
|
-
* Converts this stream to a newline-separated ReadableStream of
|
|
8824
|
-
* JSON stringified values in the stream
|
|
8825
|
-
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
8826
|
-
*/
|
|
8827
|
-
toReadableStream() {
|
|
8828
|
-
const self = this;
|
|
8829
|
-
let iter;
|
|
8830
|
-
const encoder = new TextEncoder();
|
|
8831
|
-
return new ReadableStream({
|
|
8832
|
-
async start() {
|
|
8833
|
-
iter = self[Symbol.asyncIterator]();
|
|
8834
|
-
},
|
|
8835
|
-
async pull(ctrl) {
|
|
8836
|
-
try {
|
|
8837
|
-
const { value, done } = await iter.next();
|
|
8838
|
-
if (done) return ctrl.close();
|
|
8839
|
-
const bytes = encoder.encode(JSON.stringify(value) + "\n");
|
|
8840
|
-
ctrl.enqueue(bytes);
|
|
8841
|
-
} catch (err) {
|
|
8842
|
-
ctrl.error(err);
|
|
8843
|
-
}
|
|
8844
|
-
},
|
|
8845
|
-
async cancel() {
|
|
8846
|
-
await iter.return?.();
|
|
8847
|
-
}
|
|
8848
|
-
});
|
|
8849
|
-
}
|
|
8850
8783
|
};
|
|
8851
8784
|
var _EyepopLineDecoder = class _EyepopLineDecoder {
|
|
8852
8785
|
// TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
|
|
@@ -8920,7 +8853,9 @@ _EyepopLineDecoder.NEWLINE_CHARS = /* @__PURE__ */ new Set(["\n", "\r", "\v", "\
|
|
|
8920
8853
|
_EyepopLineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
8921
8854
|
var EyepopLineDecoder = _EyepopLineDecoder;
|
|
8922
8855
|
function readableStreamAsyncIterable(stream) {
|
|
8923
|
-
if (stream[Symbol.asyncIterator])
|
|
8856
|
+
if (stream[Symbol.asyncIterator]) {
|
|
8857
|
+
return stream[Symbol.asyncIterator]();
|
|
8858
|
+
}
|
|
8924
8859
|
const reader = stream.getReader();
|
|
8925
8860
|
return {
|
|
8926
8861
|
async next() {
|
|
@@ -9685,7 +9620,7 @@ var iteratorToStream2;
|
|
|
9685
9620
|
// shims/http_client.ts
|
|
9686
9621
|
var createHttpClient;
|
|
9687
9622
|
if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
9688
|
-
class
|
|
9623
|
+
class BrowserHttpClient {
|
|
9689
9624
|
constructor() {
|
|
9690
9625
|
}
|
|
9691
9626
|
async fetch(input, init) {
|
|
@@ -9696,14 +9631,16 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9696
9631
|
}
|
|
9697
9632
|
createHttpClient = async () => {
|
|
9698
9633
|
console.debug("EyePop: creating HttpClient in browser");
|
|
9699
|
-
return new
|
|
9634
|
+
return new BrowserHttpClient();
|
|
9700
9635
|
};
|
|
9701
9636
|
}
|
|
9702
9637
|
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
9703
|
-
class
|
|
9638
|
+
class ReactNativeHttpClient {
|
|
9704
9639
|
constructor() {
|
|
9705
9640
|
}
|
|
9706
9641
|
async fetch(input, init) {
|
|
9642
|
+
init || (init = {});
|
|
9643
|
+
init.reactNative = { textStreaming: true };
|
|
9707
9644
|
return await fetch(input, init);
|
|
9708
9645
|
}
|
|
9709
9646
|
async close() {
|
|
@@ -9711,10 +9648,10 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
|
9711
9648
|
}
|
|
9712
9649
|
createHttpClient = async () => {
|
|
9713
9650
|
console.debug("EyePop: creating HttpClient in ReactNative");
|
|
9714
|
-
return new
|
|
9651
|
+
return new ReactNativeHttpClient();
|
|
9715
9652
|
};
|
|
9716
9653
|
} else {
|
|
9717
|
-
class
|
|
9654
|
+
class NodeHttpClient {
|
|
9718
9655
|
constructor(agent) {
|
|
9719
9656
|
this.agent = agent;
|
|
9720
9657
|
}
|
|
@@ -9736,7 +9673,7 @@ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
|
9736
9673
|
// two parallel streaming requests to the same host seem to deadlock with pipelining > 0
|
|
9737
9674
|
pipelining: 0
|
|
9738
9675
|
});
|
|
9739
|
-
return new
|
|
9676
|
+
return new NodeHttpClient(agent);
|
|
9740
9677
|
};
|
|
9741
9678
|
}
|
|
9742
9679
|
|