@reactor-team/js-sdk 3.0.0 → 3.0.1

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/index.d.cts CHANGED
@@ -759,6 +759,38 @@ declare class Reactor implements Disposable {
759
759
  * reconnect() for the same reason as `publishTrack()`.
760
760
  */
761
761
  pauseTrack(name: string): Promise<void>;
762
+ /**
763
+ * Bounds what one sender may spend, in bits per second.
764
+ *
765
+ * This is the ceiling that actually caps a video encoder, and it is easy to
766
+ * hit without knowing it exists: with nothing set, a Chromium-based browser
767
+ * derives a sender's maximum from the frame size alone, and that maximum is
768
+ * 2500 kbps for anything above 960x540. A 720p or 1080p publish caps at
769
+ * 2.5 Mbps until this raises it, however good the connection is.
770
+ *
771
+ * ```ts
772
+ * await reactor.publishTrack('camera', cameraTrack);
773
+ * await reactor.setTrackBitrate('camera', { maxBps: 8_000_000 });
774
+ * ```
775
+ *
776
+ * A ceiling is permission, not a target: the encoder still spends only what
777
+ * the congestion controller allocated and what the picture needs. What
778
+ * raising it buys is headroom for the moments that would otherwise clip.
779
+ *
780
+ * Needs a connected client, and a published track — there is no sender to
781
+ * bound before `publishTrack()`.
782
+ *
783
+ * Omit a bound to leave it at the browser default. `minBps` is non-standard —
784
+ * Chromium honours it, other engines ignore it.
785
+ *
786
+ * There is no connection-wide counterpart: browsers expose no equivalent of
787
+ * the native SDKs' `setBitrate`, and a method that quietly did nothing would
788
+ * be worse than its absence.
789
+ */
790
+ setTrackBitrate(name: string, bounds?: {
791
+ minBps?: number;
792
+ maxBps?: number;
793
+ }): Promise<void>;
762
794
  /** Resumes a track previously stopped with `pauseTrack()`. */
763
795
  resumeTrack(name: string): Promise<void>;
764
796
  /**
package/dist/index.d.ts CHANGED
@@ -759,6 +759,38 @@ declare class Reactor implements Disposable {
759
759
  * reconnect() for the same reason as `publishTrack()`.
760
760
  */
761
761
  pauseTrack(name: string): Promise<void>;
762
+ /**
763
+ * Bounds what one sender may spend, in bits per second.
764
+ *
765
+ * This is the ceiling that actually caps a video encoder, and it is easy to
766
+ * hit without knowing it exists: with nothing set, a Chromium-based browser
767
+ * derives a sender's maximum from the frame size alone, and that maximum is
768
+ * 2500 kbps for anything above 960x540. A 720p or 1080p publish caps at
769
+ * 2.5 Mbps until this raises it, however good the connection is.
770
+ *
771
+ * ```ts
772
+ * await reactor.publishTrack('camera', cameraTrack);
773
+ * await reactor.setTrackBitrate('camera', { maxBps: 8_000_000 });
774
+ * ```
775
+ *
776
+ * A ceiling is permission, not a target: the encoder still spends only what
777
+ * the congestion controller allocated and what the picture needs. What
778
+ * raising it buys is headroom for the moments that would otherwise clip.
779
+ *
780
+ * Needs a connected client, and a published track — there is no sender to
781
+ * bound before `publishTrack()`.
782
+ *
783
+ * Omit a bound to leave it at the browser default. `minBps` is non-standard —
784
+ * Chromium honours it, other engines ignore it.
785
+ *
786
+ * There is no connection-wide counterpart: browsers expose no equivalent of
787
+ * the native SDKs' `setBitrate`, and a method that quietly did nothing would
788
+ * be worse than its absence.
789
+ */
790
+ setTrackBitrate(name: string, bounds?: {
791
+ minBps?: number;
792
+ maxBps?: number;
793
+ }): Promise<void>;
762
794
  /** Resumes a track previously stopped with `pauseTrack()`. */
763
795
  resumeTrack(name: string): Promise<void>;
764
796
  /**
package/dist/index.js CHANGED
@@ -372,6 +372,69 @@ async function importWasmModule() {
372
372
  return module;
373
373
  }
374
374
 
375
+ // package.json
376
+ var package_default = {
377
+ name: "@reactor-team/js-sdk",
378
+ version: "3.0.1",
379
+ description: "Connect your JavaScript/TypeScript app to a live Reactor model in the browser.",
380
+ license: "Apache-2.0",
381
+ repository: {
382
+ type: "git",
383
+ url: "git+https://github.com/reactor-team/reactor-client-sdks.git",
384
+ directory: "sdks/js"
385
+ },
386
+ type: "module",
387
+ sideEffects: false,
388
+ main: "./dist/index.cjs",
389
+ module: "./dist/index.js",
390
+ types: "./dist/index.d.ts",
391
+ exports: {
392
+ ".": {
393
+ types: "./dist/index.d.ts",
394
+ import: "./dist/index.js",
395
+ require: "./dist/index.cjs"
396
+ }
397
+ },
398
+ files: [
399
+ "dist"
400
+ ],
401
+ engines: {
402
+ node: ">=18"
403
+ },
404
+ scripts: {
405
+ build: "tsup && node scripts/copy-wasm.mjs",
406
+ prepack: "npm run build",
407
+ dev: "tsup --watch",
408
+ "type-check": "tsc --noEmit",
409
+ lint: "eslint .",
410
+ test: "vitest run",
411
+ clean: "rm -rf dist"
412
+ },
413
+ dependencies: {
414
+ awaitqueue: "^3.3.1",
415
+ "hls.js": "^1.6.0",
416
+ mp4box: "^2.4.1"
417
+ },
418
+ peerDependencies: {
419
+ react: "^18.0.0 || ^19.0.0"
420
+ },
421
+ devDependencies: {
422
+ "@eslint/js": "^9.39.5",
423
+ "@stylistic/eslint-plugin": "^5.10.0",
424
+ "@testing-library/react": "^16.0.0",
425
+ "@types/react": "^19.0.0",
426
+ eslint: "^9.39.5",
427
+ "eslint-plugin-react-hooks": "^5.0.0",
428
+ jsdom: "^25.0.0",
429
+ react: "^19.0.0",
430
+ "react-dom": "^19.0.0",
431
+ tsup: "^8.3.0",
432
+ typescript: "^5.6.0",
433
+ "typescript-eslint": "^8.67.0",
434
+ vitest: "^4.1.11"
435
+ }
436
+ };
437
+
375
438
  // src/recording.ts
376
439
  var RecordingError = class extends Error {
377
440
  constructor(code, reason) {
@@ -807,7 +870,7 @@ var Reactor = class {
807
870
  queue = new AwaitQueue();
808
871
  constructor(options) {
809
872
  const { jwt, ...clientOptions } = options;
810
- this.clientOptions = clientOptions;
873
+ this.clientOptions = { sdkVersion: package_default.version, ...clientOptions };
811
874
  this.jwt = jwt ?? null;
812
875
  }
813
876
  // ── Lifecycle ───────────────────────────────────────────────────────────
@@ -1050,6 +1113,45 @@ var Reactor = class {
1050
1113
  throw this.captureError(cause);
1051
1114
  }
1052
1115
  }
1116
+ /**
1117
+ * Bounds what one sender may spend, in bits per second.
1118
+ *
1119
+ * This is the ceiling that actually caps a video encoder, and it is easy to
1120
+ * hit without knowing it exists: with nothing set, a Chromium-based browser
1121
+ * derives a sender's maximum from the frame size alone, and that maximum is
1122
+ * 2500 kbps for anything above 960x540. A 720p or 1080p publish caps at
1123
+ * 2.5 Mbps until this raises it, however good the connection is.
1124
+ *
1125
+ * ```ts
1126
+ * await reactor.publishTrack('camera', cameraTrack);
1127
+ * await reactor.setTrackBitrate('camera', { maxBps: 8_000_000 });
1128
+ * ```
1129
+ *
1130
+ * A ceiling is permission, not a target: the encoder still spends only what
1131
+ * the congestion controller allocated and what the picture needs. What
1132
+ * raising it buys is headroom for the moments that would otherwise clip.
1133
+ *
1134
+ * Needs a connected client, and a published track — there is no sender to
1135
+ * bound before `publishTrack()`.
1136
+ *
1137
+ * Omit a bound to leave it at the browser default. `minBps` is non-standard —
1138
+ * Chromium honours it, other engines ignore it.
1139
+ *
1140
+ * There is no connection-wide counterpart: browsers expose no equivalent of
1141
+ * the native SDKs' `setBitrate`, and a method that quietly did nothing would
1142
+ * be worse than its absence.
1143
+ */
1144
+ async setTrackBitrate(name, bounds = {}) {
1145
+ this.assertNotDisposed();
1146
+ try {
1147
+ await this.queue.push(async () => {
1148
+ const client = await this.getOrCreateClient();
1149
+ await client.setTrackBitrate(name, bounds.minBps, bounds.maxBps);
1150
+ }, "setTrackBitrate");
1151
+ } catch (cause) {
1152
+ throw this.captureError(cause);
1153
+ }
1154
+ }
1053
1155
  /** Resumes a track previously stopped with `pauseTrack()`. */
1054
1156
  async resumeTrack(name) {
1055
1157
  this.assertNotDisposed();