@eyepop.ai/eyepop 0.14.0 → 0.15.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.
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // node_modules/mime-db/db.json
33
+ // ../../node_modules/mime-db/db.json
34
34
  var require_db = __commonJS({
35
- "node_modules/mime-db/db.json"(exports2, module2) {
35
+ "../../node_modules/mime-db/db.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  "application/1d-interleaved-parityfec": {
38
38
  source: "iana"
@@ -8555,17 +8555,17 @@ var require_db = __commonJS({
8555
8555
  }
8556
8556
  });
8557
8557
 
8558
- // node_modules/mime-db/index.js
8558
+ // ../../node_modules/mime-db/index.js
8559
8559
  var require_mime_db = __commonJS({
8560
- "node_modules/mime-db/index.js"(exports2, module2) {
8560
+ "../../node_modules/mime-db/index.js"(exports2, module2) {
8561
8561
  "use strict";
8562
8562
  module2.exports = require_db();
8563
8563
  }
8564
8564
  });
8565
8565
 
8566
- // node_modules/mime-types/index.js
8566
+ // ../../node_modules/mime-types/index.js
8567
8567
  var require_mime_types = __commonJS({
8568
- "node_modules/mime-types/index.js"(exports2) {
8568
+ "../../node_modules/mime-types/index.js"(exports2) {
8569
8569
  "use strict";
8570
8570
  var db = require_mime_db();
8571
8571
  var extname = require("path").extname;
@@ -8654,16 +8654,16 @@ var require_mime_types = __commonJS({
8654
8654
  }
8655
8655
  });
8656
8656
 
8657
- // src/index.ts
8658
- var src_exports = {};
8659
- __export(src_exports, {
8657
+ // index.ts
8658
+ var eyepop_exports = {};
8659
+ __export(eyepop_exports, {
8660
8660
  EndpointState: () => EndpointState,
8661
- EyePopSdk: () => EyePopSdk,
8662
- default: () => src_default
8661
+ EyePop: () => EyePop,
8662
+ default: () => eyepop_default
8663
8663
  });
8664
- module.exports = __toCommonJS(src_exports);
8664
+ module.exports = __toCommonJS(eyepop_exports);
8665
8665
 
8666
- // src/types.ts
8666
+ // types.ts
8667
8667
  var EndpointState = /* @__PURE__ */ ((EndpointState2) => {
8668
8668
  EndpointState2["Idle"] = "Idle";
8669
8669
  EndpointState2["Busy"] = "Busy";
@@ -8674,7 +8674,7 @@ var EndpointState = /* @__PURE__ */ ((EndpointState2) => {
8674
8674
  return EndpointState2;
8675
8675
  })(EndpointState || {});
8676
8676
 
8677
- // src/streaming.ts
8677
+ // streaming.ts
8678
8678
  var Stream = class _Stream {
8679
8679
  constructor(iterator, controller) {
8680
8680
  this.iterator = iterator;
@@ -8925,7 +8925,7 @@ function readableStreamAsyncIterable(stream) {
8925
8925
  };
8926
8926
  }
8927
8927
 
8928
- // src/jobs.ts
8928
+ // jobs.ts
8929
8929
  var AbstractJob = class {
8930
8930
  constructor(getSession, client, requestLogger) {
8931
8931
  this._responseStream = null;
@@ -9098,7 +9098,7 @@ var LoadLiveIngressJob = class extends AbstractJob {
9098
9098
  }
9099
9099
  };
9100
9100
 
9101
- // src/shims/http_client.ts
9101
+ // shims/http_client.ts
9102
9102
  var createHttpClient;
9103
9103
  if ("document" in globalThis && "implementation" in globalThis.document) {
9104
9104
  class HttpClient2 {
@@ -9137,7 +9137,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9137
9137
  };
9138
9138
  }
9139
9139
 
9140
- // src/semaphore.ts
9140
+ // semaphore.ts
9141
9141
  var Semaphore = class {
9142
9142
  /**
9143
9143
  * Creates a semaphore.
@@ -9265,7 +9265,7 @@ var Semaphore = class {
9265
9265
  }
9266
9266
  };
9267
9267
 
9268
- // node_modules/uuid/dist/esm-node/rng.js
9268
+ // ../../node_modules/uuid/dist/esm-node/rng.js
9269
9269
  var import_crypto = __toESM(require("crypto"));
9270
9270
  var rnds8Pool = new Uint8Array(256);
9271
9271
  var poolPtr = rnds8Pool.length;
@@ -9277,7 +9277,7 @@ function rng() {
9277
9277
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
9278
9278
  }
9279
9279
 
9280
- // node_modules/uuid/dist/esm-node/stringify.js
9280
+ // ../../node_modules/uuid/dist/esm-node/stringify.js
9281
9281
  var byteToHex = [];
9282
9282
  for (let i = 0; i < 256; ++i) {
9283
9283
  byteToHex.push((i + 256).toString(16).slice(1));
@@ -9286,13 +9286,13 @@ function unsafeStringify(arr, offset = 0) {
9286
9286
  return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
9287
9287
  }
9288
9288
 
9289
- // node_modules/uuid/dist/esm-node/native.js
9289
+ // ../../node_modules/uuid/dist/esm-node/native.js
9290
9290
  var import_crypto2 = __toESM(require("crypto"));
9291
9291
  var native_default = {
9292
9292
  randomUUID: import_crypto2.default.randomUUID
9293
9293
  };
9294
9294
 
9295
- // node_modules/uuid/dist/esm-node/v4.js
9295
+ // ../../node_modules/uuid/dist/esm-node/v4.js
9296
9296
  function v4(options, buf, offset) {
9297
9297
  if (native_default.randomUUID && !buf && !options) {
9298
9298
  return native_default.randomUUID();
@@ -9312,7 +9312,7 @@ function v4(options, buf, offset) {
9312
9312
  }
9313
9313
  var v4_default = v4;
9314
9314
 
9315
- // src/webrtc_base.ts
9315
+ // webrtc_base.ts
9316
9316
  var import_path = __toESM(require("path"));
9317
9317
  var WebrtcBase = class _WebrtcBase {
9318
9318
  constructor(getSession, client, ingressId, urlBasePath, requestLogger) {
@@ -9553,8 +9553,8 @@ var WebrtcBase = class _WebrtcBase {
9553
9553
  }
9554
9554
  };
9555
9555
 
9556
- // src/webrtc_whip.ts
9557
- var WebrtcWhip = class _WebrtcWhip extends WebrtcBase {
9556
+ // webrtc_whip.ts
9557
+ var WebrtcWhip = class extends WebrtcBase {
9558
9558
  constructor(stream, getSession, client, requestLogger) {
9559
9559
  super(getSession, client, v4_default().toString(), "/liveIngress/whip", requestLogger);
9560
9560
  this._stream = stream;
@@ -9586,17 +9586,6 @@ var WebrtcWhip = class _WebrtcWhip extends WebrtcBase {
9586
9586
  if (!this._pc) {
9587
9587
  throw new Error("onLocalOffer no peer connection");
9588
9588
  }
9589
- answer = new RTCSessionDescription({
9590
- type: "answer",
9591
- sdp: _WebrtcWhip.editAnswer(
9592
- answer.sdp,
9593
- "h264/90000",
9594
- void 0,
9595
- 5e3,
9596
- void 0,
9597
- true
9598
- )
9599
- });
9600
9589
  await this._pc.setRemoteDescription(new RTCSessionDescription(answer));
9601
9590
  if (this._queuedCandidates.length !== 0) {
9602
9591
  await this.sendLocalCandidates(this._queuedCandidates);
@@ -9650,7 +9639,7 @@ var WebrtcWhip = class _WebrtcWhip extends WebrtcBase {
9650
9639
  }
9651
9640
  };
9652
9641
 
9653
- // src/webrtc_whep.ts
9642
+ // webrtc_whep.ts
9654
9643
  var WebrtcWhep = class extends WebrtcBase {
9655
9644
  constructor(ingressId, getSession, client, requestLogger) {
9656
9645
  super(getSession, client, ingressId, "/liveIngress/whep", requestLogger);
@@ -9736,7 +9725,7 @@ var WebrtcWhep = class extends WebrtcBase {
9736
9725
  }
9737
9726
  };
9738
9727
 
9739
- // src/shims/local_file.ts
9728
+ // shims/local_file.ts
9740
9729
  var resolvePath;
9741
9730
  if ("document" in globalThis && "implementation" in globalThis.document) {
9742
9731
  resolvePath = async (source) => {
@@ -9756,10 +9745,10 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9756
9745
  };
9757
9746
  }
9758
9747
 
9759
- // src/endpoint.ts
9748
+ // endpoint.ts
9760
9749
  var import_pino = require("pino");
9761
9750
 
9762
- // src/shims/browser_session.ts
9751
+ // shims/browser_session.ts
9763
9752
  var import_auth0_spa_js = require("@auth0/auth0-spa-js");
9764
9753
  var authenticateBrowserSession;
9765
9754
  if ("document" in globalThis && "implementation" in globalThis.document) {
@@ -9794,7 +9783,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9794
9783
  };
9795
9784
  }
9796
9785
 
9797
- // src/endpoint.ts
9786
+ // endpoint.ts
9798
9787
  var Endpoint = class {
9799
9788
  constructor(options) {
9800
9789
  this._options = options;
@@ -10043,7 +10032,6 @@ var Endpoint = class {
10043
10032
  }
10044
10033
  async uploadPath(source) {
10045
10034
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10046
- console.log(this);
10047
10035
  throw new Error("endpoint not connected, use connect() before process()");
10048
10036
  }
10049
10037
  await this._limit.acquire();
@@ -10242,133 +10230,25 @@ var Endpoint = class {
10242
10230
  }
10243
10231
  };
10244
10232
 
10245
- // src/visualize.ts
10246
- var _EyePopPlot = class _EyePopPlot {
10247
- constructor(context) {
10248
- this._context = context;
10249
- const textSize = Math.floor(Math.max(1, 0.03 * Math.min(context.canvas.width, context.canvas.height)));
10250
- this._font = textSize + "px Poppins";
10251
- }
10252
- prediction(p) {
10253
- if (p && p.objects) {
10254
- const x_scale = this._context.canvas.width / p.source_width;
10255
- const y_scale = this._context.canvas.height / p.source_height;
10256
- for (let i = 0; i < p.objects.length; i++) {
10257
- this.object(p.objects[i], x_scale, y_scale);
10258
- }
10259
- }
10260
- }
10261
- object(obj, x_scale = 1, y_scale = 1) {
10262
- const context = this._context;
10263
- const x = obj.x * x_scale;
10264
- const y = obj.y * y_scale;
10265
- const w = obj.width * x_scale;
10266
- const h = obj.height * y_scale;
10267
- context.beginPath();
10268
- context.rect(obj.x, obj.y, obj.width, obj.height);
10269
- context.lineWidth = 1;
10270
- context.strokeStyle = _EyePopPlot.colors.opacity_color;
10271
- context.fillStyle = _EyePopPlot.colors.opacity_color;
10272
- context.fill();
10273
- context.stroke();
10274
- const mindim = Math.min(obj.height, obj.width);
10275
- let corner_size = Math.max(15, mindim / 5.33333);
10276
- var corners = [
10277
- //top left corner
10278
- [{ x, y: y + corner_size }, { x, y }, { x: x + corner_size, y }],
10279
- //bottom left corner
10280
- [{ x, y: y + h - corner_size }, { x, y: y + h }, { x: x + corner_size, y: y + h }],
10281
- //top right corner
10282
- [{ x: x + w - corner_size, y }, { x: x + w, y }, { x: x + w, y: y + corner_size }],
10283
- //bottom right corner
10284
- [{ x: x + w, y: y + h - corner_size }, { x: x + w, y: y + h }, { x: x + w - corner_size, y: y + h }]
10285
- ];
10286
- corners.forEach((corner) => {
10287
- context.beginPath();
10288
- context.moveTo(corner[0].x, corner[0].y);
10289
- context.lineTo(corner[1].x, corner[1].y);
10290
- context.lineTo(corner[2].x, corner[2].y);
10291
- context.strokeStyle = _EyePopPlot.colors.primary_color;
10292
- context.lineWidth = 1;
10293
- context.stroke();
10294
- });
10295
- const padding = Math.max(mindim * 0.02, 5);
10296
- corner_size = corner_size - padding;
10297
- var corners2 = [
10298
- //2nd top left corner
10299
- [{ x: x + padding, y: y + padding + corner_size }, {
10300
- x: x + padding,
10301
- y: y + padding
10302
- }, { x: x + padding + corner_size, y: y + padding }],
10303
- //2nd bottom left corner
10304
- [{ x: x + padding, y: y - padding + h - corner_size }, {
10305
- x: x + padding,
10306
- y: y - padding + h
10307
- }, { x: x + padding + corner_size, y: y - padding + h }],
10308
- //2nd top right corner
10309
- [{ x: x - padding + w - corner_size, y: y + padding }, {
10310
- x: x - padding + w,
10311
- y: y + padding
10312
- }, { x: x - padding + w, y: y + padding + corner_size }],
10313
- //2nd bottom right corner
10314
- [{ x: x - padding + w, y: y - padding + h - corner_size }, {
10315
- x: x - padding + w,
10316
- y: y - padding + h
10317
- }, { x: x - padding + w - corner_size, y: y - padding + h }]
10318
- ];
10319
- corners2.forEach((corner) => {
10320
- context.beginPath();
10321
- context.moveTo(corner[0].x, corner[0].y);
10322
- context.lineTo(corner[1].x, corner[1].y);
10323
- context.lineTo(corner[2].x, corner[2].y);
10324
- context.strokeStyle = _EyePopPlot.colors.secondary_color;
10325
- context.lineWidth = 1;
10326
- context.stroke();
10327
- });
10328
- let trackingLabel = "";
10329
- if (obj.traceId) {
10330
- trackingLabel = `#${obj.traceId}`;
10331
- }
10332
- context.font = this._font;
10333
- context.fillStyle = "#ffffff";
10334
- context.textAlign = "left";
10335
- context.textBaseline = "top";
10336
- context.fillText(_EyePopPlot.toTitleCase(obj.classLabel + " " + trackingLabel), obj.x + 1.5 * padding, obj.y + 1.5 * padding);
10337
- }
10338
- static toTitleCase(str) {
10339
- if (!str)
10340
- return "";
10341
- return str.replace(/\w\S*/g, function(txt) {
10342
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
10343
- });
10344
- }
10345
- };
10346
- _EyePopPlot.colors = {
10347
- primary_color: "#2fa7d7",
10348
- secondary_color: "#94e0ff",
10349
- right_color: "#a1f542",
10350
- left_color: "#e32740",
10351
- opacity_color: "rgba(47, 167, 215, 0.2)",
10352
- white: "#FFFFFF",
10353
- black: "#111111",
10354
- blank_color: "#000000"
10355
- };
10356
- var EyePopPlot = _EyePopPlot;
10357
-
10358
- // src/index.ts
10233
+ // index.ts
10359
10234
  var readEnv = (env) => {
10360
10235
  if (typeof process !== "undefined") {
10361
10236
  return process.env?.[env] ?? void 0;
10362
10237
  }
10363
10238
  return void 0;
10364
10239
  };
10365
- var _EyePopSdk = class _EyePopSdk {
10366
- static endpoint(opts = {}) {
10240
+ var EyePop;
10241
+ ((EyePop2) => {
10242
+ const envSecretKey = readEnv("EYEPOP_SECRET_KEY");
10243
+ const defaultAuth = envSecretKey ? {
10244
+ secretKey: envSecretKey
10245
+ } : void 0;
10246
+ function endpoint(opts = {}) {
10367
10247
  if (typeof opts.auth == "undefined") {
10368
- if (typeof _EyePopSdk.defaultAuth == "undefined") {
10248
+ if (typeof defaultAuth == "undefined") {
10369
10249
  throw new Error("auth option or EYEPOP_SECRET_KEY environment variable is required");
10370
10250
  }
10371
- opts.auth = _EyePopSdk.defaultAuth;
10251
+ opts.auth = defaultAuth;
10372
10252
  }
10373
10253
  if (typeof opts.popId == "undefined") {
10374
10254
  opts.popId = readEnv("EYEPOP_POP_ID");
@@ -10416,23 +10296,16 @@ var _EyePopSdk = class _EyePopSdk {
10416
10296
  opts.eyepopUrl = opts.auth.session.eyepopUrl;
10417
10297
  }
10418
10298
  }
10419
- const endpoint = new Endpoint(opts);
10420
- return endpoint;
10299
+ const endpoint2 = new Endpoint(opts);
10300
+ return endpoint2;
10421
10301
  }
10422
- static plot(context) {
10423
- return new EyePopPlot(context);
10424
- }
10425
- };
10426
- _EyePopSdk.envSecretKey = readEnv("EYEPOP_SECRET_KEY");
10427
- _EyePopSdk.defaultAuth = _EyePopSdk.envSecretKey ? {
10428
- secretKey: _EyePopSdk.envSecretKey
10429
- } : void 0;
10430
- var EyePopSdk = _EyePopSdk;
10431
- var src_default = EyePopSdk;
10302
+ EyePop2.endpoint = endpoint;
10303
+ })(EyePop || (EyePop = {}));
10304
+ var eyepop_default = EyePop;
10432
10305
  // Annotate the CommonJS export names for ESM import in node:
10433
10306
  0 && (module.exports = {
10434
10307
  EndpointState,
10435
- EyePopSdk
10308
+ EyePop
10436
10309
  });
10437
10310
  /*! Bundled license information:
10438
10311
 
@@ -10452,4 +10325,4 @@ mime-types/index.js:
10452
10325
  * MIT Licensed
10453
10326
  *)
10454
10327
  */
10455
- //# sourceMappingURL=index.js.map
10328
+ //# sourceMappingURL=eyepop.index.js.map