@roboflow/inference-sdk 0.1.2 → 0.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @roboflow/inference-sdk
2
2
 
3
- Lightweight client for Roboflow's hosted inference API with WebRTC streaming support for real-time computer vision in the browser.
3
+ Lightweight JS client for Roboflow's hosted inference API with WebRTC streaming support for real-time computer vision in the browser.
4
4
 
5
5
  ## Installation
6
6
 
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- var R = Object.defineProperty;
2
- var T = (n, e, t) => e in n ? R(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var u = (n, e, t) => T(n, typeof e != "symbol" ? e + "" : e, t);
4
- class g {
1
+ var T = Object.defineProperty;
2
+ var O = (a, e, t) => e in a ? T(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var u = (a, e, t) => O(a, typeof e != "symbol" ? e + "" : e, t);
4
+ class _ {
5
5
  /**
6
6
  * @private
7
7
  * Use InferenceHTTPClient.init() instead
@@ -14,7 +14,7 @@ class g {
14
14
  static init({ apiKey: e, serverUrl: t }) {
15
15
  if (!e)
16
16
  throw new Error("apiKey is required");
17
- return new g(e, t);
17
+ return new _(e, t);
18
18
  }
19
19
  /**
20
20
  * Initialize a WebRTC worker pipeline
@@ -44,51 +44,59 @@ class g {
44
44
  async initializeWebrtcWorker({
45
45
  offer: e,
46
46
  workflowSpec: t,
47
- workspaceName: a,
47
+ workspaceName: n,
48
48
  workflowId: r,
49
49
  config: o = {}
50
50
  }) {
51
51
  if (!e || !e.sdp || !e.type)
52
52
  throw new Error("offer with sdp and type is required");
53
- const i = !!t, l = !!(a && r);
54
- if (!i && !l)
53
+ const i = !!t, s = !!(n && r);
54
+ if (!i && !s)
55
55
  throw new Error("Either workflowSpec OR (workspaceName + workflowId) is required");
56
- if (i && l)
56
+ if (i && s)
57
57
  throw new Error("Provide either workflowSpec OR (workspaceName + workflowId), not both");
58
58
  const {
59
59
  imageInputName: d = "image",
60
- streamOutputNames: s = [],
61
- dataOutputNames: c = ["string"],
62
- threadPoolWorkers: p = 4
63
- } = o, h = {
60
+ streamOutputNames: c = [],
61
+ dataOutputNames: l = ["string"],
62
+ threadPoolWorkers: p = 4,
63
+ workflowsParameters: y = {},
64
+ iceServers: w,
65
+ processingTimeout: k,
66
+ requestedPlan: S,
67
+ requestedRegion: f
68
+ } = o, g = {
64
69
  type: "WorkflowConfiguration",
65
70
  image_input_name: d,
71
+ workflows_parameters: y,
66
72
  workflows_thread_pool_workers: p,
67
73
  cancel_thread_pool_tasks_on_exit: !0,
68
74
  video_metadata_input_name: "video_metadata"
69
75
  };
70
- i ? h.workflow_specification = t : (h.workspace_name = a, h.workflow_id = r);
71
- const f = {
72
- workflow_configuration: h,
76
+ i ? g.workflow_specification = t : (g.workspace_name = n, g.workflow_id = r);
77
+ const m = {
78
+ workflow_configuration: g,
73
79
  api_key: this.apiKey,
74
80
  webrtc_realtime_processing: !0,
75
81
  webrtc_offer: {
76
82
  sdp: e.sdp,
77
83
  type: e.type
78
84
  },
79
- webrtc_turn_config: null,
80
- stream_output: s,
81
- data_output: c
82
- }, m = await fetch(`${this.serverUrl}/initialise_webrtc_worker`, {
85
+ webrtc_config: w ? { iceServers: w } : null,
86
+ stream_output: c,
87
+ data_output: l
88
+ };
89
+ k !== void 0 && (m.processing_timeout = k), S !== void 0 && (m.requested_plan = S), f !== void 0 && (m.requested_region = f), console.trace("payload", m);
90
+ const h = await fetch(`${this.serverUrl}/initialise_webrtc_worker`, {
83
91
  method: "POST",
84
92
  headers: { "Content-Type": "application/json" },
85
- body: JSON.stringify(f)
93
+ body: JSON.stringify(m)
86
94
  });
87
- if (!m.ok) {
88
- const w = await m.text().catch(() => "");
89
- throw new Error(`initialise_webrtc_worker failed (${m.status}): ${w}`);
95
+ if (!h.ok) {
96
+ const E = await h.text().catch(() => "");
97
+ throw new Error(`initialise_webrtc_worker failed (${h.status}): ${E}`);
90
98
  }
91
- return await m.json();
99
+ return await h.json();
92
100
  }
93
101
  async terminatePipeline({ pipelineId: e }) {
94
102
  if (!e)
@@ -102,7 +110,7 @@ class g {
102
110
  );
103
111
  }
104
112
  }
105
- const U = {
113
+ const K = {
106
114
  /**
107
115
  * Create a connector that uses API key directly
108
116
  *
@@ -121,25 +129,33 @@ const U = {
121
129
  * const answer = await connector.connectWrtc(offer, wrtcParams);
122
130
  * ```
123
131
  */
124
- withApiKey(n, e = {}) {
132
+ withApiKey(a, e = {}) {
125
133
  const { serverUrl: t } = e;
126
134
  return typeof window < "u" && console.warn(
127
135
  "[Security Warning] Using API key directly in browser will expose it. Use connectors.withProxyUrl() for production. See: https://docs.roboflow.com/api-reference/authentication#securing-your-api-key"
128
136
  ), {
129
- connectWrtc: async (a, r) => await g.init({ apiKey: n, serverUrl: t }).initializeWebrtcWorker({
130
- offer: a,
131
- workflowSpec: r.workflowSpec,
132
- workspaceName: r.workspaceName,
133
- workflowId: r.workflowId,
134
- config: {
135
- imageInputName: r.imageInputName,
136
- streamOutputNames: r.streamOutputNames,
137
- dataOutputNames: r.dataOutputNames,
138
- threadPoolWorkers: r.threadPoolWorkers
139
- }
140
- }),
137
+ connectWrtc: async (n, r) => {
138
+ const o = _.init({ apiKey: a, serverUrl: t });
139
+ return console.log("wrtcParams", r), await o.initializeWebrtcWorker({
140
+ offer: n,
141
+ workflowSpec: r.workflowSpec,
142
+ workspaceName: r.workspaceName,
143
+ workflowId: r.workflowId,
144
+ config: {
145
+ imageInputName: r.imageInputName,
146
+ streamOutputNames: r.streamOutputNames,
147
+ dataOutputNames: r.dataOutputNames,
148
+ threadPoolWorkers: r.threadPoolWorkers,
149
+ workflowsParameters: r.workflowsParameters,
150
+ iceServers: r.iceServers,
151
+ processingTimeout: r.processingTimeout,
152
+ requestedPlan: r.requestedPlan,
153
+ requestedRegion: r.requestedRegion
154
+ }
155
+ });
156
+ },
141
157
  // Store apiKey for cleanup
142
- _apiKey: n,
158
+ _apiKey: a,
143
159
  _serverUrl: t
144
160
  };
145
161
  },
@@ -176,22 +192,27 @@ const U = {
176
192
  * imageInputName: wrtcParams.imageInputName,
177
193
  * streamOutputNames: wrtcParams.streamOutputNames,
178
194
  * dataOutputNames: wrtcParams.dataOutputNames,
179
- * threadPoolWorkers: wrtcParams.threadPoolWorkers
195
+ * threadPoolWorkers: wrtcParams.threadPoolWorkers,
196
+ * workflowsParameters: wrtcParams.workflowsParameters,
197
+ * iceServers: wrtcParams.iceServers,
198
+ * processingTimeout: wrtcParams.processingTimeout,
199
+ * requestedPlan: wrtcParams.requestedPlan,
200
+ * requestedRegion: wrtcParams.requestedRegion
180
201
  * }
181
202
  * });
182
203
  * res.json(answer);
183
204
  * });
184
205
  * ```
185
206
  */
186
- withProxyUrl(n, e = {}) {
207
+ withProxyUrl(a, e = {}) {
187
208
  return {
188
- connectWrtc: async (t, a) => {
189
- const r = await fetch(n, {
209
+ connectWrtc: async (t, n) => {
210
+ const r = await fetch(a, {
190
211
  method: "POST",
191
212
  headers: { "Content-Type": "application/json" },
192
213
  body: JSON.stringify({
193
214
  offer: t,
194
- wrtcParams: a
215
+ wrtcParams: n
195
216
  })
196
217
  });
197
218
  if (!r.ok) {
@@ -203,25 +224,25 @@ const U = {
203
224
  };
204
225
  }
205
226
  };
206
- async function O(n = { video: !0 }) {
227
+ async function W(a = { video: !0 }) {
207
228
  try {
208
- console.log("[RFStreams] requesting with", n);
209
- const e = await navigator.mediaDevices.getUserMedia(n);
229
+ console.log("[RFStreams] requesting with", a);
230
+ const e = await navigator.mediaDevices.getUserMedia(a);
210
231
  return console.log("[RFStreams] got stream", e.getVideoTracks().map((t) => ({ id: t.id, label: t.label }))), e;
211
232
  } catch (e) {
212
233
  console.warn("[RFStreams] failed, falling back", e);
213
234
  const t = await navigator.mediaDevices.getUserMedia({ video: !0, audio: !1 });
214
- return console.log("[RFStreams] fallback stream", t.getVideoTracks().map((a) => ({ id: a.id, label: a.label }))), t;
235
+ return console.log("[RFStreams] fallback stream", t.getVideoTracks().map((n) => ({ id: n.id, label: n.label }))), t;
215
236
  }
216
237
  }
217
- function _(n) {
218
- n && (n.getTracks().forEach((e) => e.stop()), console.log("[RFStreams] Stream stopped"));
238
+ function v(a) {
239
+ a && (a.getTracks().forEach((e) => e.stop()), console.log("[RFStreams] Stream stopped"));
219
240
  }
220
- const L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
241
+ const j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
221
242
  __proto__: null,
222
- stopStream: _,
223
- useCamera: O
224
- }, Symbol.toStringTag, { value: "Module" })), W = 12;
243
+ stopStream: v,
244
+ useCamera: W
245
+ }, Symbol.toStringTag, { value: "Module" })), F = 12;
225
246
  class b {
226
247
  constructor() {
227
248
  u(this, "pendingFrames", /* @__PURE__ */ new Map());
@@ -229,22 +250,22 @@ class b {
229
250
  /**
230
251
  * Process an incoming chunk and return the complete message if all chunks received
231
252
  */
232
- processChunk(e, t, a, r) {
233
- if (a === 1)
253
+ processChunk(e, t, n, r) {
254
+ if (n === 1)
234
255
  return r;
235
256
  this.pendingFrames.has(e) || this.pendingFrames.set(e, {
236
257
  chunks: /* @__PURE__ */ new Map(),
237
- totalChunks: a
258
+ totalChunks: n
238
259
  });
239
260
  const o = this.pendingFrames.get(e);
240
- if (o.chunks.set(t, r), o.chunks.size === a) {
241
- const i = Array.from(o.chunks.values()).reduce((s, c) => s + c.length, 0), l = new Uint8Array(i);
261
+ if (o.chunks.set(t, r), o.chunks.size === n) {
262
+ const i = Array.from(o.chunks.values()).reduce((c, l) => c + l.length, 0), s = new Uint8Array(i);
242
263
  let d = 0;
243
- for (let s = 0; s < a; s++) {
244
- const c = o.chunks.get(s);
245
- l.set(c, d), d += c.length;
264
+ for (let c = 0; c < n; c++) {
265
+ const l = o.chunks.get(c);
266
+ s.set(l, d), d += l.length;
246
267
  }
247
- return this.pendingFrames.delete(e), l;
268
+ return this.pendingFrames.delete(e), s;
248
269
  }
249
270
  return null;
250
271
  }
@@ -255,24 +276,24 @@ class b {
255
276
  this.pendingFrames.clear();
256
277
  }
257
278
  }
258
- function v(n) {
259
- const e = new DataView(n), t = e.getUint32(0, !0), a = e.getUint32(4, !0), r = e.getUint32(8, !0), o = new Uint8Array(n, W);
260
- return { frameId: t, chunkIndex: a, totalChunks: r, payload: o };
279
+ function C(a) {
280
+ const e = new DataView(a), t = e.getUint32(0, !0), n = e.getUint32(4, !0), r = e.getUint32(8, !0), o = new Uint8Array(a, F);
281
+ return { frameId: t, chunkIndex: n, totalChunks: r, payload: o };
261
282
  }
262
- async function P(n, e = 6e3) {
263
- if (n.iceGatheringState === "complete") return;
283
+ async function P(a, e = 6e3) {
284
+ if (a.iceGatheringState === "complete") return;
264
285
  let t = !1;
265
- const a = (r) => {
286
+ const n = (r) => {
266
287
  r.candidate && r.candidate.type === "srflx" && (t = !0);
267
288
  };
268
- n.addEventListener("icecandidate", a);
289
+ a.addEventListener("icecandidate", n);
269
290
  try {
270
291
  await Promise.race([
271
292
  new Promise((r) => {
272
293
  const o = () => {
273
- n.iceGatheringState === "complete" && (n.removeEventListener("icegatheringstatechange", o), r());
294
+ a.iceGatheringState === "complete" && (a.removeEventListener("icegatheringstatechange", o), r());
274
295
  };
275
- n.addEventListener("icegatheringstatechange", o);
296
+ a.addEventListener("icegatheringstatechange", o);
276
297
  }),
277
298
  new Promise((r, o) => {
278
299
  setTimeout(() => {
@@ -281,56 +302,59 @@ async function P(n, e = 6e3) {
281
302
  })
282
303
  ]);
283
304
  } finally {
284
- n.removeEventListener("icecandidate", a);
305
+ a.removeEventListener("icecandidate", n);
285
306
  }
286
307
  }
287
- function F(n) {
308
+ function I(a) {
288
309
  return new Promise((e) => {
289
- n.addEventListener("track", (t) => {
310
+ a.addEventListener("track", (t) => {
290
311
  t.streams && t.streams[0] && e(t.streams[0]);
291
312
  });
292
313
  });
293
314
  }
294
- async function I(n) {
295
- const e = "stun:stun.l.google.com:19302", t = new RTCPeerConnection({
296
- iceServers: [{ urls: [e] }]
315
+ const D = [
316
+ { urls: ["stun:stun.l.google.com:19302"] }
317
+ ];
318
+ async function x(a, e) {
319
+ const t = e ?? D, n = new RTCPeerConnection({
320
+ iceServers: t
297
321
  });
298
322
  try {
299
- t.addTransceiver("video", { direction: "recvonly" });
300
- } catch (i) {
301
- console.warn("[RFWebRTC] Could not add transceiver:", i);
323
+ n.addTransceiver("video", { direction: "recvonly" });
324
+ } catch (s) {
325
+ console.warn("[RFWebRTC] Could not add transceiver:", s);
302
326
  }
303
- n.getVideoTracks().forEach((i) => {
327
+ a.getVideoTracks().forEach((s) => {
304
328
  try {
305
- i.contentHint = "detail";
329
+ s.contentHint = "detail";
306
330
  } catch {
307
331
  }
308
- t.addTrack(i, n);
332
+ n.addTrack(s, a);
309
333
  });
310
- const a = F(t), r = t.createDataChannel("roboflow-control", {
334
+ const r = I(n), o = n.createDataChannel("roboflow-control", {
311
335
  ordered: !0
312
- }), o = await t.createOffer();
313
- return await t.setLocalDescription(o), await P(t), {
314
- pc: t,
315
- offer: t.localDescription,
316
- remoteStreamPromise: a,
317
- dataChannel: r
336
+ }), i = await n.createOffer();
337
+ return await n.setLocalDescription(i), await P(n), {
338
+ pc: n,
339
+ offer: n.localDescription,
340
+ remoteStreamPromise: r,
341
+ dataChannel: o
318
342
  };
319
343
  }
320
- async function x(n) {
321
- const e = n.getSenders().find((a) => a.track && a.track.kind === "video");
344
+ async function N(a) {
345
+ const e = a.getSenders().find((n) => n.track && n.track.kind === "video");
322
346
  if (!e) return;
323
347
  const t = e.getParameters();
324
348
  t.encodings = t.encodings || [{}], t.encodings[0].scaleResolutionDownBy = 1;
325
349
  try {
326
350
  await e.setParameters(t);
327
- } catch (a) {
328
- console.warn("[RFWebRTC] Failed to set encoding parameters:", a);
351
+ } catch (n) {
352
+ console.warn("[RFWebRTC] Failed to set encoding parameters:", n);
329
353
  }
330
354
  }
331
- class C {
355
+ class R {
332
356
  /** @private */
333
- constructor(e, t, a, r, o, i, l) {
357
+ constructor(e, t, n, r, o, i, s) {
334
358
  u(this, "pc");
335
359
  u(this, "_localStream");
336
360
  u(this, "remoteStreamPromise");
@@ -338,21 +362,21 @@ class C {
338
362
  u(this, "apiKey");
339
363
  u(this, "dataChannel");
340
364
  u(this, "reassembler");
341
- this.pc = e, this._localStream = t, this.remoteStreamPromise = a, this.pipelineId = r, this.apiKey = o, this.dataChannel = i, this.reassembler = new b(), this.dataChannel.binaryType = "arraybuffer", l && (this.dataChannel.addEventListener("open", () => {
365
+ this.pc = e, this._localStream = t, this.remoteStreamPromise = n, this.pipelineId = r, this.apiKey = o, this.dataChannel = i, this.reassembler = new b(), this.dataChannel.binaryType = "arraybuffer", s && (this.dataChannel.addEventListener("open", () => {
342
366
  }), this.dataChannel.addEventListener("message", (d) => {
343
367
  try {
344
368
  if (d.data instanceof ArrayBuffer) {
345
- const { frameId: s, chunkIndex: c, totalChunks: p, payload: h } = v(d.data), f = this.reassembler.processChunk(s, c, p, h);
346
- if (f) {
347
- const k = new TextDecoder("utf-8").decode(f), w = JSON.parse(k);
348
- l(w);
369
+ const { frameId: c, chunkIndex: l, totalChunks: p, payload: y } = C(d.data), w = this.reassembler.processChunk(c, l, p, y);
370
+ if (w) {
371
+ const S = new TextDecoder("utf-8").decode(w), f = JSON.parse(S);
372
+ s(f);
349
373
  }
350
374
  } else {
351
- const s = JSON.parse(d.data);
352
- l(s);
375
+ const c = JSON.parse(d.data);
376
+ s(c);
353
377
  }
354
- } catch (s) {
355
- console.error("[RFWebRTC] Failed to parse data channel message:", s);
378
+ } catch (c) {
379
+ console.error("[RFWebRTC] Failed to parse data channel message:", c);
356
380
  }
357
381
  }), this.dataChannel.addEventListener("error", (d) => {
358
382
  console.error("[RFWebRTC] Data channel error:", d);
@@ -406,7 +430,7 @@ class C {
406
430
  * ```
407
431
  */
408
432
  async cleanup() {
409
- this.reassembler.clear(), this.pipelineId && this.apiKey && await g.init({ apiKey: this.apiKey }).terminatePipeline({ pipelineId: this.pipelineId }), this.pc && this.pc.connectionState !== "closed" && this.pc.close(), _(this._localStream);
433
+ this.reassembler.clear(), this.pipelineId && this.apiKey && await _.init({ apiKey: this.apiKey }).terminatePipeline({ pipelineId: this.pipelineId }), this.pc && this.pc.connectionState !== "closed" && this.pc.close(), v(this._localStream);
410
434
  }
411
435
  /**
412
436
  * Reconfigure pipeline outputs at runtime
@@ -461,44 +485,47 @@ class C {
461
485
  }
462
486
  }
463
487
  }
464
- async function D({
465
- source: n,
488
+ async function U({
489
+ source: a,
466
490
  connector: e,
467
491
  wrtcParams: t,
468
- onData: a,
492
+ onData: n,
469
493
  options: r = {}
470
494
  }) {
471
- var w;
495
+ var f;
472
496
  if (!e || typeof e.connectWrtc != "function")
473
497
  throw new Error("connector must have a connectWrtc method");
474
- const o = n, { pc: i, offer: l, remoteStreamPromise: d, dataChannel: s } = await I(o), c = await e.connectWrtc(
475
- { sdp: l.sdp, type: l.type },
498
+ const o = a, { pc: i, offer: s, remoteStreamPromise: d, dataChannel: c } = await x(
499
+ o,
500
+ t.iceServers
501
+ ), l = await e.connectWrtc(
502
+ { sdp: s.sdp, type: s.type },
476
503
  t
477
- ), p = { sdp: c.sdp, type: c.type };
504
+ ), p = { sdp: l.sdp, type: l.type };
478
505
  if (!(p != null && p.sdp) || !(p != null && p.type))
479
- throw console.error("[RFWebRTC] Invalid answer from server:", c), new Error("connector.connectWrtc must return answer with sdp and type");
480
- const h = ((w = c == null ? void 0 : c.context) == null ? void 0 : w.pipeline_id) || null;
481
- await i.setRemoteDescription(p), await new Promise((E, S) => {
482
- const y = () => {
483
- i.connectionState === "connected" ? (i.removeEventListener("connectionstatechange", y), E()) : i.connectionState === "failed" && (i.removeEventListener("connectionstatechange", y), S(new Error("WebRTC connection failed")));
506
+ throw console.error("[RFWebRTC] Invalid answer from server:", l), new Error("connector.connectWrtc must return answer with sdp and type");
507
+ const y = ((f = l == null ? void 0 : l.context) == null ? void 0 : f.pipeline_id) || null;
508
+ await i.setRemoteDescription(p), await new Promise((g, m) => {
509
+ const h = () => {
510
+ i.connectionState === "connected" ? (i.removeEventListener("connectionstatechange", h), g()) : i.connectionState === "failed" && (i.removeEventListener("connectionstatechange", h), m(new Error("WebRTC connection failed")));
484
511
  };
485
- i.addEventListener("connectionstatechange", y), y(), setTimeout(() => {
486
- i.removeEventListener("connectionstatechange", y), S(new Error("WebRTC connection timeout after 30s"));
512
+ i.addEventListener("connectionstatechange", h), h(), setTimeout(() => {
513
+ i.removeEventListener("connectionstatechange", h), m(new Error("WebRTC connection timeout after 30s"));
487
514
  }, 3e4);
488
- }), r.disableInputStreamDownscaling !== !1 && await x(i);
489
- const m = e._apiKey || null;
490
- return new C(i, o, d, h, m, s, a);
515
+ }), r.disableInputStreamDownscaling !== !1 && await N(i);
516
+ const k = e._apiKey || null;
517
+ return new R(i, o, d, y, k, c, n);
491
518
  }
492
- const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
519
+ const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
493
520
  __proto__: null,
494
521
  ChunkReassembler: b,
495
- RFWebRTCConnection: C,
496
- parseBinaryHeader: v,
497
- useStream: D
522
+ RFWebRTCConnection: R,
523
+ parseBinaryHeader: C,
524
+ useStream: U
498
525
  }, Symbol.toStringTag, { value: "Module" }));
499
526
  export {
500
- g as InferenceHTTPClient,
501
- U as connectors,
502
- L as streams,
503
- K as webrtc
527
+ _ as InferenceHTTPClient,
528
+ K as connectors,
529
+ j as streams,
530
+ $ as webrtc
504
531
  };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c.RoboflowClient={}))})(this,function(c){"use strict";var L=Object.defineProperty;var K=(c,s,y)=>s in c?L(c,s,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[s]=y;var m=(c,s,y)=>K(c,typeof s!="symbol"?s+"":s,y);class s{constructor(e,t="https://serverless.roboflow.com"){m(this,"apiKey");m(this,"serverUrl");this.apiKey=e,this.serverUrl=t}static init({apiKey:e,serverUrl:t}){if(!e)throw new Error("apiKey is required");return new s(e,t)}async initializeWebrtcWorker({offer:e,workflowSpec:t,workspaceName:a,workflowId:n,config:o={}}){if(!e||!e.sdp||!e.type)throw new Error("offer with sdp and type is required");const i=!!t,p=!!(a&&n);if(!i&&!p)throw new Error("Either workflowSpec OR (workspaceName + workflowId) is required");if(i&&p)throw new Error("Provide either workflowSpec OR (workspaceName + workflowId), not both");const{imageInputName:u="image",streamOutputNames:l=[],dataOutputNames:d=["string"],threadPoolWorkers:h=4}=o,f={type:"WorkflowConfiguration",image_input_name:u,workflows_thread_pool_workers:h,cancel_thread_pool_tasks_on_exit:!0,video_metadata_input_name:"video_metadata"};i?f.workflow_specification=t:(f.workspace_name=a,f.workflow_id=n);const S={workflow_configuration:f,api_key:this.apiKey,webrtc_realtime_processing:!0,webrtc_offer:{sdp:e.sdp,type:e.type},webrtc_turn_config:null,stream_output:l,data_output:d},w=await fetch(`${this.serverUrl}/initialise_webrtc_worker`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)});if(!w.ok){const g=await w.text().catch(()=>"");throw new Error(`initialise_webrtc_worker failed (${w.status}): ${g}`)}return await w.json()}async terminatePipeline({pipelineId:e}){if(!e)throw new Error("pipelineId is required");await fetch(`${this.serverUrl}/inference_pipelines/${e}/terminate?api_key=${this.apiKey}`,{method:"POST",headers:{"Content-Type":"application/json"}})}}const y={withApiKey(r,e={}){const{serverUrl:t}=e;return typeof window<"u"&&console.warn("[Security Warning] Using API key directly in browser will expose it. Use connectors.withProxyUrl() for production. See: https://docs.roboflow.com/api-reference/authentication#securing-your-api-key"),{connectWrtc:async(a,n)=>await s.init({apiKey:r,serverUrl:t}).initializeWebrtcWorker({offer:a,workflowSpec:n.workflowSpec,workspaceName:n.workspaceName,workflowId:n.workflowId,config:{imageInputName:n.imageInputName,streamOutputNames:n.streamOutputNames,dataOutputNames:n.dataOutputNames,threadPoolWorkers:n.threadPoolWorkers}}),_apiKey:r,_serverUrl:t}},withProxyUrl(r,e={}){return{connectWrtc:async(t,a)=>{const n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:t,wrtcParams:a})});if(!n.ok){const o=await n.text().catch(()=>"");throw new Error(`Proxy request failed (${n.status}): ${o}`)}return await n.json()}}}};async function E(r={video:!0}){try{console.log("[RFStreams] requesting with",r);const e=await navigator.mediaDevices.getUserMedia(r);return console.log("[RFStreams] got stream",e.getVideoTracks().map(t=>({id:t.id,label:t.label}))),e}catch(e){console.warn("[RFStreams] failed, falling back",e);const t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});return console.log("[RFStreams] fallback stream",t.getVideoTracks().map(a=>({id:a.id,label:a.label}))),t}}function _(r){r&&(r.getTracks().forEach(e=>e.stop()),console.log("[RFStreams] Stream stopped"))}const O=Object.freeze(Object.defineProperty({__proto__:null,stopStream:_,useCamera:E},Symbol.toStringTag,{value:"Module"})),W=12;class v{constructor(){m(this,"pendingFrames",new Map)}processChunk(e,t,a,n){if(a===1)return n;this.pendingFrames.has(e)||this.pendingFrames.set(e,{chunks:new Map,totalChunks:a});const o=this.pendingFrames.get(e);if(o.chunks.set(t,n),o.chunks.size===a){const i=Array.from(o.chunks.values()).reduce((l,d)=>l+d.length,0),p=new Uint8Array(i);let u=0;for(let l=0;l<a;l++){const d=o.chunks.get(l);p.set(d,u),u+=d.length}return this.pendingFrames.delete(e),p}return null}clear(){this.pendingFrames.clear()}}function C(r){const e=new DataView(r),t=e.getUint32(0,!0),a=e.getUint32(4,!0),n=e.getUint32(8,!0),o=new Uint8Array(r,W);return{frameId:t,chunkIndex:a,totalChunks:n,payload:o}}async function P(r,e=6e3){if(r.iceGatheringState==="complete")return;let t=!1;const a=n=>{n.candidate&&n.candidate.type==="srflx"&&(t=!0)};r.addEventListener("icecandidate",a);try{await Promise.race([new Promise(n=>{const o=()=>{r.iceGatheringState==="complete"&&(r.removeEventListener("icegatheringstatechange",o),n())};r.addEventListener("icegatheringstatechange",o)}),new Promise((n,o)=>{setTimeout(()=>{t?n():(console.error("[ICE] timeout with NO srflx candidate! Connection may fail."),o(new Error("ICE gathering timeout without srflx candidate")))},e)})])}finally{r.removeEventListener("icecandidate",a)}}function F(r){return new Promise(e=>{r.addEventListener("track",t=>{t.streams&&t.streams[0]&&e(t.streams[0])})})}async function I(r){const e="stun:stun.l.google.com:19302",t=new RTCPeerConnection({iceServers:[{urls:[e]}]});try{t.addTransceiver("video",{direction:"recvonly"})}catch(i){console.warn("[RFWebRTC] Could not add transceiver:",i)}r.getVideoTracks().forEach(i=>{try{i.contentHint="detail"}catch{}t.addTrack(i,r)});const a=F(t),n=t.createDataChannel("roboflow-control",{ordered:!0}),o=await t.createOffer();return await t.setLocalDescription(o),await P(t),{pc:t,offer:t.localDescription,remoteStreamPromise:a,dataChannel:n}}async function D(r){const e=r.getSenders().find(a=>a.track&&a.track.kind==="video");if(!e)return;const t=e.getParameters();t.encodings=t.encodings||[{}],t.encodings[0].scaleResolutionDownBy=1;try{await e.setParameters(t)}catch(a){console.warn("[RFWebRTC] Failed to set encoding parameters:",a)}}class T{constructor(e,t,a,n,o,i,p){m(this,"pc");m(this,"_localStream");m(this,"remoteStreamPromise");m(this,"pipelineId");m(this,"apiKey");m(this,"dataChannel");m(this,"reassembler");this.pc=e,this._localStream=t,this.remoteStreamPromise=a,this.pipelineId=n,this.apiKey=o,this.dataChannel=i,this.reassembler=new v,this.dataChannel.binaryType="arraybuffer",p&&(this.dataChannel.addEventListener("open",()=>{}),this.dataChannel.addEventListener("message",u=>{try{if(u.data instanceof ArrayBuffer){const{frameId:l,chunkIndex:d,totalChunks:h,payload:f}=C(u.data),S=this.reassembler.processChunk(l,d,h,f);if(S){const b=new TextDecoder("utf-8").decode(S),g=JSON.parse(b);p(g)}}else{const l=JSON.parse(u.data);p(l)}}catch(l){console.error("[RFWebRTC] Failed to parse data channel message:",l)}}),this.dataChannel.addEventListener("error",u=>{console.error("[RFWebRTC] Data channel error:",u)}),this.dataChannel.addEventListener("close",()=>{this.reassembler.clear()}))}async remoteStream(){return await this.remoteStreamPromise}localStream(){return this._localStream}async cleanup(){this.reassembler.clear(),this.pipelineId&&this.apiKey&&await s.init({apiKey:this.apiKey}).terminatePipeline({pipelineId:this.pipelineId}),this.pc&&this.pc.connectionState!=="closed"&&this.pc.close(),_(this._localStream)}reconfigureOutputs(e){const t={};e.streamOutput!==void 0&&(t.stream_output=e.streamOutput),e.dataOutput!==void 0&&(t.data_output=e.dataOutput),this.sendData(t)}sendData(e){if(this.dataChannel.readyState!=="open"){console.warn("[RFWebRTC] Data channel is not open. Current state:",this.dataChannel.readyState);return}try{const t=typeof e=="string"?e:JSON.stringify(e);this.dataChannel.send(t)}catch(t){console.error("[RFWebRTC] Failed to send data:",t)}}}async function N({source:r,connector:e,wrtcParams:t,onData:a,options:n={}}){var g;if(!e||typeof e.connectWrtc!="function")throw new Error("connector must have a connectWrtc method");const o=r,{pc:i,offer:p,remoteStreamPromise:u,dataChannel:l}=await I(o),d=await e.connectWrtc({sdp:p.sdp,type:p.type},t),h={sdp:d.sdp,type:d.type};if(!(h!=null&&h.sdp)||!(h!=null&&h.type))throw console.error("[RFWebRTC] Invalid answer from server:",d),new Error("connector.connectWrtc must return answer with sdp and type");const f=((g=d==null?void 0:d.context)==null?void 0:g.pipeline_id)||null;await i.setRemoteDescription(h),await new Promise((x,R)=>{const k=()=>{i.connectionState==="connected"?(i.removeEventListener("connectionstatechange",k),x()):i.connectionState==="failed"&&(i.removeEventListener("connectionstatechange",k),R(new Error("WebRTC connection failed")))};i.addEventListener("connectionstatechange",k),k(),setTimeout(()=>{i.removeEventListener("connectionstatechange",k),R(new Error("WebRTC connection timeout after 30s"))},3e4)}),n.disableInputStreamDownscaling!==!1&&await D(i);const w=e._apiKey||null;return new T(i,o,u,f,w,l,a)}const U=Object.freeze(Object.defineProperty({__proto__:null,ChunkReassembler:v,RFWebRTCConnection:T,parseBinaryHeader:C,useStream:N},Symbol.toStringTag,{value:"Module"}));c.InferenceHTTPClient=s,c.connectors=y,c.streams=O,c.webrtc=U,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(l=typeof globalThis<"u"?globalThis:l||self,s(l.RoboflowClient={}))})(this,function(l){"use strict";var K=Object.defineProperty;var j=(l,s,y)=>s in l?K(l,s,{enumerable:!0,configurable:!0,writable:!0,value:y}):l[s]=y;var f=(l,s,y)=>j(l,typeof s!="symbol"?s+"":s,y);class s{constructor(e,t="https://serverless.roboflow.com"){f(this,"apiKey");f(this,"serverUrl");this.apiKey=e,this.serverUrl=t}static init({apiKey:e,serverUrl:t}){if(!e)throw new Error("apiKey is required");return new s(e,t)}async initializeWebrtcWorker({offer:e,workflowSpec:t,workspaceName:r,workflowId:n,config:a={}}){if(!e||!e.sdp||!e.type)throw new Error("offer with sdp and type is required");const i=!!t,c=!!(r&&n);if(!i&&!c)throw new Error("Either workflowSpec OR (workspaceName + workflowId) is required");if(i&&c)throw new Error("Provide either workflowSpec OR (workspaceName + workflowId), not both");const{imageInputName:p="image",streamOutputNames:d=[],dataOutputNames:u=["string"],threadPoolWorkers:h=4,workflowsParameters:_={},iceServers:S,processingTimeout:b,requestedPlan:v,requestedRegion:g}=a,k={type:"WorkflowConfiguration",image_input_name:p,workflows_parameters:_,workflows_thread_pool_workers:h,cancel_thread_pool_tasks_on_exit:!0,video_metadata_input_name:"video_metadata"};i?k.workflow_specification=t:(k.workspace_name=r,k.workflow_id=n);const w={workflow_configuration:k,api_key:this.apiKey,webrtc_realtime_processing:!0,webrtc_offer:{sdp:e.sdp,type:e.type},webrtc_config:S?{iceServers:S}:null,stream_output:d,data_output:u};b!==void 0&&(w.processing_timeout=b),v!==void 0&&(w.requested_plan=v),g!==void 0&&(w.requested_region=g),console.trace("payload",w);const m=await fetch(`${this.serverUrl}/initialise_webrtc_worker`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!m.ok){const q=await m.text().catch(()=>"");throw new Error(`initialise_webrtc_worker failed (${m.status}): ${q}`)}return await m.json()}async terminatePipeline({pipelineId:e}){if(!e)throw new Error("pipelineId is required");await fetch(`${this.serverUrl}/inference_pipelines/${e}/terminate?api_key=${this.apiKey}`,{method:"POST",headers:{"Content-Type":"application/json"}})}}const y={withApiKey(o,e={}){const{serverUrl:t}=e;return typeof window<"u"&&console.warn("[Security Warning] Using API key directly in browser will expose it. Use connectors.withProxyUrl() for production. See: https://docs.roboflow.com/api-reference/authentication#securing-your-api-key"),{connectWrtc:async(r,n)=>{const a=s.init({apiKey:o,serverUrl:t});return console.log("wrtcParams",n),await a.initializeWebrtcWorker({offer:r,workflowSpec:n.workflowSpec,workspaceName:n.workspaceName,workflowId:n.workflowId,config:{imageInputName:n.imageInputName,streamOutputNames:n.streamOutputNames,dataOutputNames:n.dataOutputNames,threadPoolWorkers:n.threadPoolWorkers,workflowsParameters:n.workflowsParameters,iceServers:n.iceServers,processingTimeout:n.processingTimeout,requestedPlan:n.requestedPlan,requestedRegion:n.requestedRegion}})},_apiKey:o,_serverUrl:t}},withProxyUrl(o,e={}){return{connectWrtc:async(t,r)=>{const n=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:t,wrtcParams:r})});if(!n.ok){const a=await n.text().catch(()=>"");throw new Error(`Proxy request failed (${n.status}): ${a}`)}return await n.json()}}}};async function O(o={video:!0}){try{console.log("[RFStreams] requesting with",o);const e=await navigator.mediaDevices.getUserMedia(o);return console.log("[RFStreams] got stream",e.getVideoTracks().map(t=>({id:t.id,label:t.label}))),e}catch(e){console.warn("[RFStreams] failed, falling back",e);const t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});return console.log("[RFStreams] fallback stream",t.getVideoTracks().map(r=>({id:r.id,label:r.label}))),t}}function C(o){o&&(o.getTracks().forEach(e=>e.stop()),console.log("[RFStreams] Stream stopped"))}const W=Object.freeze(Object.defineProperty({__proto__:null,stopStream:C,useCamera:O},Symbol.toStringTag,{value:"Module"})),P=12;class T{constructor(){f(this,"pendingFrames",new Map)}processChunk(e,t,r,n){if(r===1)return n;this.pendingFrames.has(e)||this.pendingFrames.set(e,{chunks:new Map,totalChunks:r});const a=this.pendingFrames.get(e);if(a.chunks.set(t,n),a.chunks.size===r){const i=Array.from(a.chunks.values()).reduce((d,u)=>d+u.length,0),c=new Uint8Array(i);let p=0;for(let d=0;d<r;d++){const u=a.chunks.get(d);c.set(u,p),p+=u.length}return this.pendingFrames.delete(e),c}return null}clear(){this.pendingFrames.clear()}}function R(o){const e=new DataView(o),t=e.getUint32(0,!0),r=e.getUint32(4,!0),n=e.getUint32(8,!0),a=new Uint8Array(o,P);return{frameId:t,chunkIndex:r,totalChunks:n,payload:a}}async function F(o,e=6e3){if(o.iceGatheringState==="complete")return;let t=!1;const r=n=>{n.candidate&&n.candidate.type==="srflx"&&(t=!0)};o.addEventListener("icecandidate",r);try{await Promise.race([new Promise(n=>{const a=()=>{o.iceGatheringState==="complete"&&(o.removeEventListener("icegatheringstatechange",a),n())};o.addEventListener("icegatheringstatechange",a)}),new Promise((n,a)=>{setTimeout(()=>{t?n():(console.error("[ICE] timeout with NO srflx candidate! Connection may fail."),a(new Error("ICE gathering timeout without srflx candidate")))},e)})])}finally{o.removeEventListener("icecandidate",r)}}function I(o){return new Promise(e=>{o.addEventListener("track",t=>{t.streams&&t.streams[0]&&e(t.streams[0])})})}const D=[{urls:["stun:stun.l.google.com:19302"]}];async function N(o,e){const t=e??D,r=new RTCPeerConnection({iceServers:t});try{r.addTransceiver("video",{direction:"recvonly"})}catch(c){console.warn("[RFWebRTC] Could not add transceiver:",c)}o.getVideoTracks().forEach(c=>{try{c.contentHint="detail"}catch{}r.addTrack(c,o)});const n=I(r),a=r.createDataChannel("roboflow-control",{ordered:!0}),i=await r.createOffer();return await r.setLocalDescription(i),await F(r),{pc:r,offer:r.localDescription,remoteStreamPromise:n,dataChannel:a}}async function U(o){const e=o.getSenders().find(r=>r.track&&r.track.kind==="video");if(!e)return;const t=e.getParameters();t.encodings=t.encodings||[{}],t.encodings[0].scaleResolutionDownBy=1;try{await e.setParameters(t)}catch(r){console.warn("[RFWebRTC] Failed to set encoding parameters:",r)}}class E{constructor(e,t,r,n,a,i,c){f(this,"pc");f(this,"_localStream");f(this,"remoteStreamPromise");f(this,"pipelineId");f(this,"apiKey");f(this,"dataChannel");f(this,"reassembler");this.pc=e,this._localStream=t,this.remoteStreamPromise=r,this.pipelineId=n,this.apiKey=a,this.dataChannel=i,this.reassembler=new T,this.dataChannel.binaryType="arraybuffer",c&&(this.dataChannel.addEventListener("open",()=>{}),this.dataChannel.addEventListener("message",p=>{try{if(p.data instanceof ArrayBuffer){const{frameId:d,chunkIndex:u,totalChunks:h,payload:_}=R(p.data),S=this.reassembler.processChunk(d,u,h,_);if(S){const v=new TextDecoder("utf-8").decode(S),g=JSON.parse(v);c(g)}}else{const d=JSON.parse(p.data);c(d)}}catch(d){console.error("[RFWebRTC] Failed to parse data channel message:",d)}}),this.dataChannel.addEventListener("error",p=>{console.error("[RFWebRTC] Data channel error:",p)}),this.dataChannel.addEventListener("close",()=>{this.reassembler.clear()}))}async remoteStream(){return await this.remoteStreamPromise}localStream(){return this._localStream}async cleanup(){this.reassembler.clear(),this.pipelineId&&this.apiKey&&await s.init({apiKey:this.apiKey}).terminatePipeline({pipelineId:this.pipelineId}),this.pc&&this.pc.connectionState!=="closed"&&this.pc.close(),C(this._localStream)}reconfigureOutputs(e){const t={};e.streamOutput!==void 0&&(t.stream_output=e.streamOutput),e.dataOutput!==void 0&&(t.data_output=e.dataOutput),this.sendData(t)}sendData(e){if(this.dataChannel.readyState!=="open"){console.warn("[RFWebRTC] Data channel is not open. Current state:",this.dataChannel.readyState);return}try{const t=typeof e=="string"?e:JSON.stringify(e);this.dataChannel.send(t)}catch(t){console.error("[RFWebRTC] Failed to send data:",t)}}}async function L({source:o,connector:e,wrtcParams:t,onData:r,options:n={}}){var g;if(!e||typeof e.connectWrtc!="function")throw new Error("connector must have a connectWrtc method");const a=o,{pc:i,offer:c,remoteStreamPromise:p,dataChannel:d}=await N(a,t.iceServers),u=await e.connectWrtc({sdp:c.sdp,type:c.type},t),h={sdp:u.sdp,type:u.type};if(!(h!=null&&h.sdp)||!(h!=null&&h.type))throw console.error("[RFWebRTC] Invalid answer from server:",u),new Error("connector.connectWrtc must return answer with sdp and type");const _=((g=u==null?void 0:u.context)==null?void 0:g.pipeline_id)||null;await i.setRemoteDescription(h),await new Promise((k,w)=>{const m=()=>{i.connectionState==="connected"?(i.removeEventListener("connectionstatechange",m),k()):i.connectionState==="failed"&&(i.removeEventListener("connectionstatechange",m),w(new Error("WebRTC connection failed")))};i.addEventListener("connectionstatechange",m),m(),setTimeout(()=>{i.removeEventListener("connectionstatechange",m),w(new Error("WebRTC connection timeout after 30s"))},3e4)}),n.disableInputStreamDownscaling!==!1&&await U(i);const b=e._apiKey||null;return new E(i,a,p,_,b,d,r)}const x=Object.freeze(Object.defineProperty({__proto__:null,ChunkReassembler:T,RFWebRTCConnection:E,parseBinaryHeader:R,useStream:L},Symbol.toStringTag,{value:"Module"}));l.InferenceHTTPClient=s,l.connectors=y,l.streams=W,l.webrtc=x,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
@@ -3,6 +3,40 @@ export interface WebRTCWorkerConfig {
3
3
  streamOutputNames?: string[];
4
4
  dataOutputNames?: string[];
5
5
  threadPoolWorkers?: number;
6
+ /**
7
+ * Workflow parameters to pass to the workflow execution
8
+ */
9
+ workflowsParameters?: Record<string, any>;
10
+ /**
11
+ * ICE servers for WebRTC connections (used for both client and server)
12
+ */
13
+ iceServers?: RTCIceServerConfig[];
14
+ /**
15
+ * Processing timeout in seconds (serverless only)
16
+ * @default 600
17
+ */
18
+ processingTimeout?: number;
19
+ /**
20
+ * Requested compute plan (serverless only)
21
+ * @example "webrtc-gpu-small"
22
+ */
23
+ requestedPlan?: string;
24
+ /**
25
+ * Requested region for processing (serverless only)
26
+ * @example "us"
27
+ */
28
+ requestedRegion?: string;
29
+ }
30
+ /**
31
+ * ICE server configuration for WebRTC connections
32
+ *
33
+ * Use this to configure custom STUN/TURN servers for users behind
34
+ * symmetric NAT or restrictive firewalls.
35
+ */
36
+ export interface RTCIceServerConfig {
37
+ urls: string[];
38
+ username?: string;
39
+ credential?: string;
6
40
  }
7
41
  export interface WebRTCOffer {
8
42
  sdp: string;
@@ -26,6 +60,42 @@ export interface WebRTCParams {
26
60
  streamOutputNames?: string[];
27
61
  dataOutputNames?: string[];
28
62
  threadPoolWorkers?: number;
63
+ /**
64
+ * Workflow parameters to pass to the workflow execution
65
+ */
66
+ workflowsParameters?: Record<string, any>;
67
+ /**
68
+ * ICE servers for WebRTC connections (used for both client and server)
69
+ *
70
+ * Use this to specify custom STUN/TURN servers for users behind
71
+ * symmetric NAT or restrictive firewalls. The same configuration is
72
+ * used for both the client-side RTCPeerConnection and sent to the
73
+ * server via webrtc_config.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * iceServers: [
78
+ * { urls: ["stun:stun.l.google.com:19302"] },
79
+ * { urls: ["turn:turn.example.com:3478"], username: "user", credential: "pass" }
80
+ * ]
81
+ * ```
82
+ */
83
+ iceServers?: RTCIceServerConfig[];
84
+ /**
85
+ * Processing timeout in seconds (serverless only)
86
+ * @default 600
87
+ */
88
+ processingTimeout?: number;
89
+ /**
90
+ * Requested compute plan (serverless only)
91
+ * @example "webrtc-gpu-small"
92
+ */
93
+ requestedPlan?: string;
94
+ /**
95
+ * Requested region for processing (serverless only)
96
+ * @example "us"
97
+ */
98
+ requestedRegion?: string;
29
99
  }
30
100
  export interface Connector {
31
101
  connectWrtc(offer: WebRTCOffer, wrtcParams: WebRTCParams): Promise<WebRTCWorkerResponse>;
@@ -138,7 +208,12 @@ export declare const connectors: {
138
208
  * imageInputName: wrtcParams.imageInputName,
139
209
  * streamOutputNames: wrtcParams.streamOutputNames,
140
210
  * dataOutputNames: wrtcParams.dataOutputNames,
141
- * threadPoolWorkers: wrtcParams.threadPoolWorkers
211
+ * threadPoolWorkers: wrtcParams.threadPoolWorkers,
212
+ * workflowsParameters: wrtcParams.workflowsParameters,
213
+ * iceServers: wrtcParams.iceServers,
214
+ * processingTimeout: wrtcParams.processingTimeout,
215
+ * requestedPlan: wrtcParams.requestedPlan,
216
+ * requestedRegion: wrtcParams.requestedRegion
142
217
  * }
143
218
  * });
144
219
  * res.json(answer);
@@ -1 +1 @@
1
- {"version":3,"file":"inference-api.d.ts","sourceRoot":"","sources":["../src/inference-api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACR,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;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O,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,WAAW,CAAmB;IAEtC,eAAe;gBAEb,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,OAAO,CAAC,WAAW,CAAC,EACzC,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,WAAW,EAAE,cAAc,EAC3B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI;IAsD9B;;;;;;;;;;;OAWG;IACG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAI1C;;;;;;;;;;;OAWG;IACH,WAAW,IAAI,WAAW;IAI1B;;;;;;;;;;;;;;OAcG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,kBAAkB,CAAC,MAAM,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI;IAclG;;;OAGG;IACH,OAAO,CAAC,QAAQ;CAajB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,SAAS,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,UAAU,EACV,MAAM,EACN,OAAY,EACb,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqE/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roboflow/inference-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Lightweight client for Roboflow's hosted inference API with WebRTC streaming support",
5
5
  "keywords": [
6
6
  "roboflow",