@eyepop.ai/eyepop 0.11.0 → 0.12.0
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/README.md +35 -21
- package/dist/eyepop.min.js +1 -1
- package/dist/index.d.mts +25 -10
- package/dist/index.d.ts +25 -10
- package/dist/index.js +116 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -24,14 +24,26 @@ interface LiveIngress {
|
|
|
24
24
|
close(): Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
interface IngressEvent {
|
|
27
|
-
readonly ingressId
|
|
28
|
-
readonly event
|
|
27
|
+
readonly ingressId: string;
|
|
28
|
+
readonly event: "stream-ready" | "stream-ready";
|
|
29
29
|
}
|
|
30
|
-
interface
|
|
31
|
-
readonly
|
|
32
|
-
readonly file?: File | undefined;
|
|
33
|
-
readonly mimeType?: string | undefined;
|
|
30
|
+
interface FileSource {
|
|
31
|
+
readonly file: File;
|
|
34
32
|
}
|
|
33
|
+
interface StreamSource {
|
|
34
|
+
readonly stream: ReadableStream<Uint8Array>;
|
|
35
|
+
readonly mimeType: string;
|
|
36
|
+
}
|
|
37
|
+
interface PathSource {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
}
|
|
40
|
+
interface LiveSource {
|
|
41
|
+
readonly ingressId: string;
|
|
42
|
+
}
|
|
43
|
+
interface UrlSource {
|
|
44
|
+
readonly url: string;
|
|
45
|
+
}
|
|
46
|
+
type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
|
|
35
47
|
interface Prediction {
|
|
36
48
|
timestamp: number;
|
|
37
49
|
seconds: number;
|
|
@@ -145,9 +157,12 @@ declare class Endpoint {
|
|
|
145
157
|
popId(): string | null;
|
|
146
158
|
session(): Promise<SessionPlus>;
|
|
147
159
|
liveIngress(stream: MediaStream): Promise<LiveIngress>;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
process(source: Source): Promise<ResultStream>;
|
|
161
|
+
private uploadFile;
|
|
162
|
+
private uploadStream;
|
|
163
|
+
private uploadPath;
|
|
164
|
+
private loadFrom;
|
|
165
|
+
private loadLiveIngress;
|
|
151
166
|
connect(): Promise<Endpoint>;
|
|
152
167
|
private jobDone;
|
|
153
168
|
private updateState;
|
|
@@ -186,4 +201,4 @@ declare class EyePopSdk {
|
|
|
186
201
|
static plot(context: CanvasRenderingContext2D): EyePopPlot;
|
|
187
202
|
}
|
|
188
203
|
|
|
189
|
-
export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type
|
|
204
|
+
export { EndpointState, EyePopSdk, type FileSource, type IngressEvent, type LiveIngress, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type UrlSource, EyePopSdk as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,14 +24,26 @@ interface LiveIngress {
|
|
|
24
24
|
close(): Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
interface IngressEvent {
|
|
27
|
-
readonly ingressId
|
|
28
|
-
readonly event
|
|
27
|
+
readonly ingressId: string;
|
|
28
|
+
readonly event: "stream-ready" | "stream-ready";
|
|
29
29
|
}
|
|
30
|
-
interface
|
|
31
|
-
readonly
|
|
32
|
-
readonly file?: File | undefined;
|
|
33
|
-
readonly mimeType?: string | undefined;
|
|
30
|
+
interface FileSource {
|
|
31
|
+
readonly file: File;
|
|
34
32
|
}
|
|
33
|
+
interface StreamSource {
|
|
34
|
+
readonly stream: ReadableStream<Uint8Array>;
|
|
35
|
+
readonly mimeType: string;
|
|
36
|
+
}
|
|
37
|
+
interface PathSource {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
}
|
|
40
|
+
interface LiveSource {
|
|
41
|
+
readonly ingressId: string;
|
|
42
|
+
}
|
|
43
|
+
interface UrlSource {
|
|
44
|
+
readonly url: string;
|
|
45
|
+
}
|
|
46
|
+
type Source = FileSource | StreamSource | PathSource | LiveSource | UrlSource;
|
|
35
47
|
interface Prediction {
|
|
36
48
|
timestamp: number;
|
|
37
49
|
seconds: number;
|
|
@@ -145,9 +157,12 @@ declare class Endpoint {
|
|
|
145
157
|
popId(): string | null;
|
|
146
158
|
session(): Promise<SessionPlus>;
|
|
147
159
|
liveIngress(stream: MediaStream): Promise<LiveIngress>;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
process(source: Source): Promise<ResultStream>;
|
|
161
|
+
private uploadFile;
|
|
162
|
+
private uploadStream;
|
|
163
|
+
private uploadPath;
|
|
164
|
+
private loadFrom;
|
|
165
|
+
private loadLiveIngress;
|
|
151
166
|
connect(): Promise<Endpoint>;
|
|
152
167
|
private jobDone;
|
|
153
168
|
private updateState;
|
|
@@ -186,4 +201,4 @@ declare class EyePopSdk {
|
|
|
186
201
|
static plot(context: CanvasRenderingContext2D): EyePopPlot;
|
|
187
202
|
}
|
|
188
203
|
|
|
189
|
-
export { EndpointState, EyePopSdk, type IngressEvent, type LiveIngress, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type
|
|
204
|
+
export { EndpointState, EyePopSdk, type FileSource, type IngressEvent, type LiveIngress, type LiveSource, type PathSource, type Point2d, type Point3d, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedObject, type Prediction, type ResultStream, type Session, type Source, type StreamSource, type UrlSource, EyePopSdk as default };
|
package/dist/index.js
CHANGED
|
@@ -8944,7 +8944,7 @@ var AbstractJob = class {
|
|
|
8944
8944
|
return Promise.reject("abstract class");
|
|
8945
8945
|
}
|
|
8946
8946
|
start(done, status) {
|
|
8947
|
-
this._responseStream = new Promise(async (
|
|
8947
|
+
this._responseStream = new Promise(async (resolve, reject) => {
|
|
8948
8948
|
try {
|
|
8949
8949
|
let retries = 1;
|
|
8950
8950
|
while (true) {
|
|
@@ -8973,7 +8973,7 @@ var AbstractJob = class {
|
|
|
8973
8973
|
reject(`response body is empty`);
|
|
8974
8974
|
break;
|
|
8975
8975
|
} else {
|
|
8976
|
-
|
|
8976
|
+
resolve(response.body);
|
|
8977
8977
|
break;
|
|
8978
8978
|
}
|
|
8979
8979
|
} catch (error) {
|
|
@@ -9509,7 +9509,7 @@ var Whip = class _Whip extends WebRtcBase {
|
|
|
9509
9509
|
});
|
|
9510
9510
|
this._pc = pc;
|
|
9511
9511
|
pc.onicecandidate = (evt) => this.onLocalCandidate(evt);
|
|
9512
|
-
return new Promise(async (
|
|
9512
|
+
return new Promise(async (resolve, reject) => {
|
|
9513
9513
|
pc.oniceconnectionstatechange = () => {
|
|
9514
9514
|
switch (pc.iceConnectionState) {
|
|
9515
9515
|
case "failed":
|
|
@@ -9517,7 +9517,7 @@ var Whip = class _Whip extends WebRtcBase {
|
|
|
9517
9517
|
reject(`peer connection: ${pc.iceConnectionState}`);
|
|
9518
9518
|
break;
|
|
9519
9519
|
case "connected":
|
|
9520
|
-
|
|
9520
|
+
resolve(this);
|
|
9521
9521
|
break;
|
|
9522
9522
|
}
|
|
9523
9523
|
};
|
|
@@ -9634,44 +9634,22 @@ var Whip = class _Whip extends WebRtcBase {
|
|
|
9634
9634
|
};
|
|
9635
9635
|
|
|
9636
9636
|
// src/shims/local_file.ts
|
|
9637
|
-
var
|
|
9637
|
+
var resolvePath;
|
|
9638
9638
|
if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
9639
|
-
|
|
9640
|
-
resolve = async (params) => {
|
|
9641
|
-
if (params.file) {
|
|
9642
|
-
if (isFileLike(params.file)) {
|
|
9643
|
-
params = {
|
|
9644
|
-
mimeType: params.file.type,
|
|
9645
|
-
file: params.file
|
|
9646
|
-
};
|
|
9647
|
-
return params;
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9639
|
+
resolvePath = async (source) => {
|
|
9650
9640
|
throw new DOMException("resolving a path to a file is not supported in browser");
|
|
9651
9641
|
};
|
|
9652
9642
|
} else {
|
|
9653
|
-
|
|
9654
|
-
if (params.file) {
|
|
9655
|
-
return params;
|
|
9656
|
-
}
|
|
9643
|
+
resolvePath = async (source) => {
|
|
9657
9644
|
const mime = require_mime_types();
|
|
9658
|
-
const
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
mimeType = mime.lookup(params.filePath) || void 0;
|
|
9666
|
-
}
|
|
9667
|
-
stream = fs.createReadStream(params.filePath);
|
|
9668
|
-
}
|
|
9669
|
-
params = {
|
|
9670
|
-
filePath: params.filePath,
|
|
9671
|
-
mimeType,
|
|
9672
|
-
file: stream
|
|
9645
|
+
const filehandle = require("fs/promises");
|
|
9646
|
+
const fd = await filehandle.open(source.path, "r");
|
|
9647
|
+
const stream = fd.createReadStream();
|
|
9648
|
+
const mimeType = mime.lookup(source.path) || "application/octet-stream";
|
|
9649
|
+
return {
|
|
9650
|
+
stream,
|
|
9651
|
+
mimeType
|
|
9673
9652
|
};
|
|
9674
|
-
return params;
|
|
9675
9653
|
};
|
|
9676
9654
|
}
|
|
9677
9655
|
|
|
@@ -9785,59 +9763,126 @@ var Endpoint = class {
|
|
|
9785
9763
|
if (!this._baseUrl || !this._client) {
|
|
9786
9764
|
return Promise.reject("endpoint not connected, use connect() before ingress()");
|
|
9787
9765
|
}
|
|
9788
|
-
const
|
|
9766
|
+
const whip = new Whip(stream, async () => {
|
|
9789
9767
|
return this.session();
|
|
9790
9768
|
}, this._client, this._requestLogger);
|
|
9791
|
-
return
|
|
9769
|
+
return whip.start();
|
|
9770
|
+
}
|
|
9771
|
+
async process(source) {
|
|
9772
|
+
if (source.file !== void 0) {
|
|
9773
|
+
return this.uploadFile(source);
|
|
9774
|
+
} else if (source.stream !== void 0) {
|
|
9775
|
+
return this.uploadStream(source);
|
|
9776
|
+
} else if (source.path !== void 0) {
|
|
9777
|
+
return this.uploadPath(source);
|
|
9778
|
+
} else if (source.url !== void 0) {
|
|
9779
|
+
return this.loadFrom(source);
|
|
9780
|
+
} else if (source.ingressId !== void 0) {
|
|
9781
|
+
return this.loadLiveIngress(source);
|
|
9782
|
+
} else {
|
|
9783
|
+
return Promise.reject("unknown source type");
|
|
9784
|
+
}
|
|
9792
9785
|
}
|
|
9793
|
-
async
|
|
9786
|
+
async uploadFile(source) {
|
|
9794
9787
|
if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
|
|
9795
9788
|
return Promise.reject("endpoint not connected, use connect() before upload()");
|
|
9796
9789
|
}
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9790
|
+
await this._limit.acquire();
|
|
9791
|
+
try {
|
|
9792
|
+
this.updateState();
|
|
9793
|
+
const job = new UploadJob(source.file, source.file.type, async () => {
|
|
9794
|
+
return this.session();
|
|
9795
|
+
}, this._client, this._requestLogger);
|
|
9796
|
+
return job.start(() => {
|
|
9797
|
+
this.jobDone(job);
|
|
9798
|
+
}, (statusCode) => {
|
|
9799
|
+
this.jobStatus(job, statusCode);
|
|
9800
|
+
});
|
|
9801
|
+
} catch (e) {
|
|
9802
|
+
this._limit.release();
|
|
9803
|
+
throw e;
|
|
9804
|
+
}
|
|
9805
|
+
}
|
|
9806
|
+
async uploadStream(source) {
|
|
9807
|
+
if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
|
|
9808
|
+
return Promise.reject("endpoint not connected, use connect() before upload()");
|
|
9800
9809
|
}
|
|
9801
9810
|
await this._limit.acquire();
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
+
try {
|
|
9812
|
+
this.updateState();
|
|
9813
|
+
const job = new UploadJob(source.stream, source.mimeType, async () => {
|
|
9814
|
+
return this.session();
|
|
9815
|
+
}, this._client, this._requestLogger);
|
|
9816
|
+
return job.start(() => {
|
|
9817
|
+
this.jobDone(job);
|
|
9818
|
+
}, (statusCode) => {
|
|
9819
|
+
this.jobStatus(job, statusCode);
|
|
9820
|
+
});
|
|
9821
|
+
} catch (e) {
|
|
9822
|
+
this._limit.release();
|
|
9823
|
+
throw e;
|
|
9824
|
+
}
|
|
9811
9825
|
}
|
|
9812
|
-
async
|
|
9826
|
+
async uploadPath(source) {
|
|
9827
|
+
if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
|
|
9828
|
+
throw new Error("endpoint not connected, use connect() before process()");
|
|
9829
|
+
}
|
|
9830
|
+
await this._limit.acquire();
|
|
9831
|
+
try {
|
|
9832
|
+
this.updateState();
|
|
9833
|
+
const streamSource = await resolvePath(source);
|
|
9834
|
+
const job = new UploadJob(streamSource.stream, streamSource.mimeType, async () => {
|
|
9835
|
+
return this.session();
|
|
9836
|
+
}, this._client, this._requestLogger);
|
|
9837
|
+
return job.start(() => {
|
|
9838
|
+
this.jobDone(job);
|
|
9839
|
+
}, (statusCode) => {
|
|
9840
|
+
this.jobStatus(job, statusCode);
|
|
9841
|
+
});
|
|
9842
|
+
} catch (e) {
|
|
9843
|
+
this._limit.release();
|
|
9844
|
+
throw e;
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
async loadFrom(source) {
|
|
9813
9848
|
if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
|
|
9814
9849
|
throw new Error("endpoint not connected, use connect() before loadFrom()");
|
|
9815
9850
|
}
|
|
9816
9851
|
await this._limit.acquire();
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9852
|
+
try {
|
|
9853
|
+
this.updateState();
|
|
9854
|
+
const job = new LoadFromJob(source.url, async () => {
|
|
9855
|
+
return this.session();
|
|
9856
|
+
}, this._client, this._requestLogger);
|
|
9857
|
+
return job.start(() => {
|
|
9858
|
+
this.jobDone(job);
|
|
9859
|
+
}, (statusCode) => {
|
|
9860
|
+
this.jobStatus(job, statusCode);
|
|
9861
|
+
});
|
|
9862
|
+
} catch (e) {
|
|
9863
|
+
this._limit.release();
|
|
9864
|
+
throw e;
|
|
9865
|
+
}
|
|
9826
9866
|
}
|
|
9827
|
-
async loadLiveIngress(
|
|
9867
|
+
async loadLiveIngress(source) {
|
|
9828
9868
|
if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
|
|
9829
9869
|
throw new Error("endpoint not connected, use connect() before loadLiveIngress()");
|
|
9830
9870
|
}
|
|
9831
9871
|
await this._limit.acquire();
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9872
|
+
try {
|
|
9873
|
+
this.updateState();
|
|
9874
|
+
const job = new LoadLiveIngressJob(source.ingressId, async () => {
|
|
9875
|
+
return this.session();
|
|
9876
|
+
}, this._client, this._requestLogger);
|
|
9877
|
+
return job.start(() => {
|
|
9878
|
+
this.jobDone(job);
|
|
9879
|
+
}, (statusCode) => {
|
|
9880
|
+
this.jobStatus(job, statusCode);
|
|
9881
|
+
});
|
|
9882
|
+
} catch (e) {
|
|
9883
|
+
this._limit.release();
|
|
9884
|
+
throw e;
|
|
9885
|
+
}
|
|
9841
9886
|
}
|
|
9842
9887
|
// noinspection TypeScriptValidateTypes
|
|
9843
9888
|
async connect() {
|