@reactor-team/js-sdk 1.0.22 → 2.0.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 CHANGED
@@ -9,41 +9,6 @@ There are two main ways to use the frontend SDK:
9
9
  1. **Imperative API**: Use it in any TS/JS application.
10
10
  2. **React API**: Use it in a React applications.
11
11
 
12
- ## Setup
13
-
14
- ### Fetching Protobuf Types
15
-
16
- The SDK uses generated TypeScript types from the [reactor-proto](https://github.com/reactor-team/reactor-proto) repository. These are fetched from GitHub releases and placed in `src/generated/`.
17
-
18
- 1. Set your GitHub token (required for private repo access):
19
-
20
- ```bash
21
- export GH_TOKEN=your_github_token
22
- ```
23
-
24
- 2. Fetch the protobuf types:
25
-
26
- ```bash
27
- pnpm proto
28
- ```
29
-
30
- This will download the types matching the version specified in `package.json` under `protobufsVersion`.
31
-
32
- ### Updating Protobuf Version
33
-
34
- To update to a new protobuf version:
35
-
36
- 1. Update `protobufsVersion` in `package.json` to the new semver (e.g., `"0.3.4"`)
37
- 2. Run `pnpm proto` to fetch the new types
38
-
39
- ### Cleaning Generated Files
40
-
41
- To remove the generated protobuf types:
42
-
43
- ```bash
44
- pnpm clean
45
- ```
46
-
47
12
  ## Building the SDK
48
13
 
49
14
  Set up the environment variables:
package/dist/index.js CHANGED
@@ -91,189 +91,6 @@ __export(index_exports, {
91
91
  });
92
92
  module.exports = __toCommonJS(index_exports);
93
93
 
94
- // src/generated/api/types/api_types.ts
95
- var import_wire2 = require("@bufbuild/protobuf/wire");
96
-
97
- // src/generated/api/types/base.ts
98
- var import_wire = require("@bufbuild/protobuf/wire");
99
-
100
- // src/generated/api/types/api_types.ts
101
- function createBaseSDPParamsResponse() {
102
- return { sdpAnswer: "", extraArgs: {} };
103
- }
104
- var SDPParamsResponse = {
105
- encode(message, writer = new import_wire2.BinaryWriter()) {
106
- if (message.sdpAnswer !== "") {
107
- writer.uint32(10).string(message.sdpAnswer);
108
- }
109
- globalThis.Object.entries(message.extraArgs).forEach(
110
- ([key, value]) => {
111
- SDPParamsResponse_ExtraArgsEntry.encode(
112
- { key, value },
113
- writer.uint32(18).fork()
114
- ).join();
115
- }
116
- );
117
- return writer;
118
- },
119
- decode(input, length) {
120
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
121
- const end = length === void 0 ? reader.len : reader.pos + length;
122
- const message = createBaseSDPParamsResponse();
123
- while (reader.pos < end) {
124
- const tag = reader.uint32();
125
- switch (tag >>> 3) {
126
- case 1: {
127
- if (tag !== 10) {
128
- break;
129
- }
130
- message.sdpAnswer = reader.string();
131
- continue;
132
- }
133
- case 2: {
134
- if (tag !== 18) {
135
- break;
136
- }
137
- const entry2 = SDPParamsResponse_ExtraArgsEntry.decode(
138
- reader,
139
- reader.uint32()
140
- );
141
- if (entry2.value !== void 0) {
142
- message.extraArgs[entry2.key] = entry2.value;
143
- }
144
- continue;
145
- }
146
- }
147
- if ((tag & 7) === 4 || tag === 0) {
148
- break;
149
- }
150
- reader.skip(tag & 7);
151
- }
152
- return message;
153
- },
154
- fromJSON(object) {
155
- return {
156
- sdpAnswer: isSet(object.sdpAnswer) ? globalThis.String(object.sdpAnswer) : "",
157
- extraArgs: isObject(object.extraArgs) ? globalThis.Object.entries(object.extraArgs).reduce(
158
- (acc, [key, value]) => {
159
- acc[key] = globalThis.String(value);
160
- return acc;
161
- },
162
- {}
163
- ) : {}
164
- };
165
- },
166
- toJSON(message) {
167
- const obj = {};
168
- if (message.sdpAnswer !== "") {
169
- obj.sdpAnswer = message.sdpAnswer;
170
- }
171
- if (message.extraArgs) {
172
- const entries = globalThis.Object.entries(message.extraArgs);
173
- if (entries.length > 0) {
174
- obj.extraArgs = {};
175
- entries.forEach(([k, v]) => {
176
- obj.extraArgs[k] = v;
177
- });
178
- }
179
- }
180
- return obj;
181
- },
182
- create(base) {
183
- return SDPParamsResponse.fromPartial(base != null ? base : {});
184
- },
185
- fromPartial(object) {
186
- var _a, _b;
187
- const message = createBaseSDPParamsResponse();
188
- message.sdpAnswer = (_a = object.sdpAnswer) != null ? _a : "";
189
- message.extraArgs = globalThis.Object.entries((_b = object.extraArgs) != null ? _b : {}).reduce(
190
- (acc, [key, value]) => {
191
- if (value !== void 0) {
192
- acc[key] = globalThis.String(value);
193
- }
194
- return acc;
195
- },
196
- {}
197
- );
198
- return message;
199
- }
200
- };
201
- function createBaseSDPParamsResponse_ExtraArgsEntry() {
202
- return { key: "", value: "" };
203
- }
204
- var SDPParamsResponse_ExtraArgsEntry = {
205
- encode(message, writer = new import_wire2.BinaryWriter()) {
206
- if (message.key !== "") {
207
- writer.uint32(10).string(message.key);
208
- }
209
- if (message.value !== "") {
210
- writer.uint32(18).string(message.value);
211
- }
212
- return writer;
213
- },
214
- decode(input, length) {
215
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
216
- const end = length === void 0 ? reader.len : reader.pos + length;
217
- const message = createBaseSDPParamsResponse_ExtraArgsEntry();
218
- while (reader.pos < end) {
219
- const tag = reader.uint32();
220
- switch (tag >>> 3) {
221
- case 1: {
222
- if (tag !== 10) {
223
- break;
224
- }
225
- message.key = reader.string();
226
- continue;
227
- }
228
- case 2: {
229
- if (tag !== 18) {
230
- break;
231
- }
232
- message.value = reader.string();
233
- continue;
234
- }
235
- }
236
- if ((tag & 7) === 4 || tag === 0) {
237
- break;
238
- }
239
- reader.skip(tag & 7);
240
- }
241
- return message;
242
- },
243
- fromJSON(object) {
244
- return {
245
- key: isSet(object.key) ? globalThis.String(object.key) : "",
246
- value: isSet(object.value) ? globalThis.String(object.value) : ""
247
- };
248
- },
249
- toJSON(message) {
250
- const obj = {};
251
- if (message.key !== "") {
252
- obj.key = message.key;
253
- }
254
- if (message.value !== "") {
255
- obj.value = message.value;
256
- }
257
- return obj;
258
- },
259
- create(base) {
260
- return SDPParamsResponse_ExtraArgsEntry.fromPartial(base != null ? base : {});
261
- },
262
- fromPartial(object) {
263
- var _a, _b;
264
- const message = createBaseSDPParamsResponse_ExtraArgsEntry();
265
- message.key = (_a = object.key) != null ? _a : "";
266
- message.value = (_b = object.value) != null ? _b : "";
267
- return message;
268
- }
269
- };
270
- function isObject(value) {
271
- return typeof value === "object" && value !== null;
272
- }
273
- function isSet(value) {
274
- return value !== null && value !== void 0;
275
- }
276
-
277
94
  // src/core/CoordinatorClient.ts
278
95
  var INITIAL_BACKOFF_MS = 500;
279
96
  var MAX_BACKOFF_MS = 3e4;
@@ -312,7 +129,7 @@ var CoordinatorClient = class {
312
129
  }),
313
130
  body: JSON.stringify(requestBody)
314
131
  });
315
- if (response.status !== 200) {
132
+ if (!response.ok) {
316
133
  const errorText = yield response.text();
317
134
  throw new Error(
318
135
  `Failed to create session: ${response.status} ${errorText}`
@@ -347,7 +164,7 @@ var CoordinatorClient = class {
347
164
  headers: this.getAuthHeaders()
348
165
  }
349
166
  );
350
- if (response.status !== 200) {
167
+ if (!response.ok) {
351
168
  const errorText = yield response.text();
352
169
  throw new Error(`Failed to get session: ${response.status} ${errorText}`);
353
170
  }
@@ -375,13 +192,7 @@ var CoordinatorClient = class {
375
192
  headers: this.getAuthHeaders()
376
193
  }
377
194
  );
378
- if (response.status === 200 || response.status === 204) {
379
- const data = yield response.json();
380
- console.debug(
381
- "[CoordinatorClient] Session terminated:",
382
- data.session_id,
383
- data.status
384
- );
195
+ if (response.ok) {
385
196
  this.currentSessionId = void 0;
386
197
  return;
387
198
  }
@@ -477,9 +288,7 @@ var CoordinatorClient = class {
477
288
  }
478
289
  );
479
290
  if (response.status === 200) {
480
- const answerData = SDPParamsResponse.fromJSON(
481
- yield response.json()
482
- );
291
+ const answerData = yield response.json();
483
292
  console.debug("[CoordinatorClient] Received SDP answer via polling");
484
293
  return answerData.sdp_answer;
485
294
  }