@fishjam-cloud/js-server-sdk 0.23.0 → 0.25.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.
@@ -0,0 +1,123 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // package.json
34
+ var package_default = {
35
+ name: "@fishjam-cloud/js-server-sdk",
36
+ version: "0.25.0",
37
+ description: "Fishjam server SDK for JavaScript",
38
+ homepage: "https://github.com/fishjam-cloud/js-server-sdk",
39
+ author: "Fishjam Team",
40
+ repository: {
41
+ type: "git",
42
+ url: "https://github.com/fishjam-cloud/js-server-sdk.git"
43
+ },
44
+ bugs: {
45
+ url: "https://github.com/fishjam-cloud/js-server-sdk/issues"
46
+ },
47
+ license: "Apache-2.0",
48
+ keywords: [
49
+ "webrtc",
50
+ "fishjam",
51
+ "server",
52
+ "membrane"
53
+ ],
54
+ main: "./dist/index.js",
55
+ types: "./dist/index.d.ts",
56
+ files: [
57
+ "dist"
58
+ ],
59
+ exports: {
60
+ ".": "./dist/index.js",
61
+ "./gemini": "./dist/integrations/gemini.js"
62
+ },
63
+ scripts: {
64
+ build: "tsup --dts-resolve",
65
+ format: "prettier --write .",
66
+ "format:check": "prettier --check .",
67
+ typecheck: "tsc --noEmit",
68
+ lint: "eslint . --fix",
69
+ "lint:check": "eslint . "
70
+ },
71
+ tsup: {
72
+ entry: [
73
+ "src/index.ts",
74
+ "src/integrations/gemini.ts",
75
+ "src/proto.ts"
76
+ ],
77
+ noExternal: [
78
+ "fishjam-openapi",
79
+ "fishjam-proto"
80
+ ],
81
+ minify: false,
82
+ format: [
83
+ "cjs",
84
+ "esm"
85
+ ],
86
+ outDir: "dist"
87
+ },
88
+ dependencies: {
89
+ axios: "^1.7.9",
90
+ uuid: "^11.1.0"
91
+ },
92
+ peerDependencies: {
93
+ "@google/genai": "^1.0.0"
94
+ },
95
+ peerDependenciesMeta: {
96
+ "@google/genai": {
97
+ optional: true
98
+ }
99
+ },
100
+ devDependencies: {
101
+ "@fishjam-cloud/fishjam-openapi": "workspace:*",
102
+ "@fishjam-cloud/fishjam-proto": "workspace:*",
103
+ "@openapitools/openapi-generator-cli": "^2.18.4",
104
+ "@types/node": "^22.13.16",
105
+ "@types/websocket": "^1.0.10",
106
+ eslint: "^9.33.0",
107
+ prettier: "^3.6.2",
108
+ tsup: "^8.4.0",
109
+ "typed-emitter": "^2.1.0"
110
+ },
111
+ "lint-staged": {
112
+ "*.{js,ts,tsx,mjs,cjs}": [
113
+ "eslint --fix --config packages/js-server-sdk/eslint.config.mjs"
114
+ ]
115
+ }
116
+ };
117
+
118
+ export {
119
+ __require,
120
+ __commonJS,
121
+ __toESM,
122
+ package_default
123
+ };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,44 @@
1
1
  import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
2
2
  import axios from 'axios';
3
3
 
4
+ /**
5
+ * Output audio options
6
+ * @export
7
+ * @interface AgentOutput
8
+ */
9
+ interface AgentOutput {
10
+ /**
11
+ *
12
+ * @type {AudioFormat}
13
+ * @memberof AgentOutput
14
+ */
15
+ 'audioFormat'?: AudioFormat;
16
+ /**
17
+ *
18
+ * @type {AudioSampleRate}
19
+ * @memberof AgentOutput
20
+ */
21
+ 'audioSampleRate'?: AudioSampleRate;
22
+ }
23
+ /**
24
+ * The format of the output audio
25
+ * @export
26
+ * @enum {string}
27
+ */
28
+ declare const AudioFormat: {
29
+ readonly Pcm16: "pcm16";
30
+ };
31
+ type AudioFormat = typeof AudioFormat[keyof typeof AudioFormat];
32
+ /**
33
+ * The sample rate of the output audio
34
+ * @export
35
+ * @enum {string}
36
+ */
37
+ declare const AudioSampleRate: {
38
+ readonly NUMBER_16000: 16000;
39
+ readonly NUMBER_24000: 24000;
40
+ };
41
+ type AudioSampleRate = typeof AudioSampleRate[keyof typeof AudioSampleRate];
4
42
  /**
5
43
  * Describes peer status
6
44
  * @export
@@ -32,11 +70,11 @@ interface Peer$1 {
32
70
  */
33
71
  'subscribeMode': SubscribeMode;
34
72
  /**
35
- * Describes peer\'s subscriptions in manual mode
36
- * @type {Array<string>}
73
+ *
74
+ * @type {Subscriptions}
37
75
  * @memberof Peer
38
76
  */
39
- 'subscriptions': Array<string>;
77
+ 'subscriptions': Subscriptions;
40
78
  /**
41
79
  * List of all peer\'s tracks
42
80
  * @type {Array<Track>}
@@ -64,62 +102,23 @@ type PeerOptions = PeerOptionsAgent | PeerOptionsWebRTC;
64
102
  interface PeerOptionsAgent {
65
103
  /**
66
104
  *
67
- * @type {PeerOptionsAgentOutput}
105
+ * @type {AgentOutput}
68
106
  * @memberof PeerOptionsAgent
69
107
  */
70
- 'output'?: PeerOptionsAgentOutput;
108
+ 'output'?: AgentOutput;
71
109
  /**
72
- * Configuration of peer\'s subscribing policy
73
- * @type {string}
110
+ *
111
+ * @type {SubscribeMode}
74
112
  * @memberof PeerOptionsAgent
75
113
  */
76
- 'subscribeMode'?: PeerOptionsAgentSubscribeModeEnum;
77
- }
78
- declare const PeerOptionsAgentSubscribeModeEnum: {
79
- readonly Auto: "auto";
80
- readonly Manual: "manual";
81
- };
82
- type PeerOptionsAgentSubscribeModeEnum = typeof PeerOptionsAgentSubscribeModeEnum[keyof typeof PeerOptionsAgentSubscribeModeEnum];
83
- /**
84
- * Output audio options
85
- * @export
86
- * @interface PeerOptionsAgentOutput
87
- */
88
- interface PeerOptionsAgentOutput {
89
- /**
90
- * The format of the output audio
91
- * @type {string}
92
- * @memberof PeerOptionsAgentOutput
93
- */
94
- 'audioFormat'?: PeerOptionsAgentOutputAudioFormatEnum;
95
- /**
96
- * The sample rate of the output audio
97
- * @type {number}
98
- * @memberof PeerOptionsAgentOutput
99
- */
100
- 'audioSampleRate'?: PeerOptionsAgentOutputAudioSampleRateEnum;
114
+ 'subscribeMode'?: SubscribeMode;
101
115
  }
102
- declare const PeerOptionsAgentOutputAudioFormatEnum: {
103
- readonly Pcm16: "pcm16";
104
- };
105
- type PeerOptionsAgentOutputAudioFormatEnum = typeof PeerOptionsAgentOutputAudioFormatEnum[keyof typeof PeerOptionsAgentOutputAudioFormatEnum];
106
- declare const PeerOptionsAgentOutputAudioSampleRateEnum: {
107
- readonly NUMBER_16000: 16000;
108
- readonly NUMBER_24000: 24000;
109
- };
110
- type PeerOptionsAgentOutputAudioSampleRateEnum = typeof PeerOptionsAgentOutputAudioSampleRateEnum[keyof typeof PeerOptionsAgentOutputAudioSampleRateEnum];
111
116
  /**
112
117
  * Options specific to the WebRTC peer
113
118
  * @export
114
119
  * @interface PeerOptionsWebRTC
115
120
  */
116
121
  interface PeerOptionsWebRTC {
117
- /**
118
- * Enables the peer to use simulcast
119
- * @type {boolean}
120
- * @memberof PeerOptionsWebRTC
121
- */
122
- 'enableSimulcast'?: boolean;
123
122
  /**
124
123
  * Custom peer metadata
125
124
  * @type {{ [key: string]: any; }}
@@ -129,17 +128,12 @@ interface PeerOptionsWebRTC {
129
128
  [key: string]: any;
130
129
  };
131
130
  /**
132
- * Configuration of peer\'s subscribing policy
133
- * @type {string}
131
+ *
132
+ * @type {SubscribeMode}
134
133
  * @memberof PeerOptionsWebRTC
135
134
  */
136
- 'subscribeMode'?: PeerOptionsWebRTCSubscribeModeEnum;
135
+ 'subscribeMode'?: SubscribeMode;
137
136
  }
138
- declare const PeerOptionsWebRTCSubscribeModeEnum: {
139
- readonly Auto: "auto";
140
- readonly Manual: "manual";
141
- };
142
- type PeerOptionsWebRTCSubscribeModeEnum = typeof PeerOptionsWebRTCSubscribeModeEnum[keyof typeof PeerOptionsWebRTCSubscribeModeEnum];
143
137
  /**
144
138
  * Informs about the peer status
145
139
  * @export
@@ -179,17 +173,17 @@ interface RoomConfig {
179
173
  */
180
174
  'public'?: boolean;
181
175
  /**
182
- * The use-case of the room. If not provided, this defaults to conference.
183
- * @type {string}
176
+ *
177
+ * @type {RoomType}
184
178
  * @memberof RoomConfig
185
179
  */
186
- 'roomType'?: RoomConfigRoomTypeEnum;
180
+ 'roomType'?: RoomType;
187
181
  /**
188
- * Enforces video codec for each peer in the room
189
- * @type {string}
182
+ *
183
+ * @type {VideoCodec}
190
184
  * @memberof RoomConfig
191
185
  */
192
- 'videoCodec'?: RoomConfigVideoCodecEnum;
186
+ 'videoCodec'?: VideoCodec;
193
187
  /**
194
188
  * URL where Fishjam notifications will be sent
195
189
  * @type {string}
@@ -197,7 +191,12 @@ interface RoomConfig {
197
191
  */
198
192
  'webhookUrl'?: string | null;
199
193
  }
200
- declare const RoomConfigRoomTypeEnum: {
194
+ /**
195
+ * The use-case of the room. If not provided, this defaults to conference.
196
+ * @export
197
+ * @enum {string}
198
+ */
199
+ declare const RoomType: {
201
200
  readonly FullFeature: "full_feature";
202
201
  readonly AudioOnly: "audio_only";
203
202
  readonly Broadcaster: "broadcaster";
@@ -205,12 +204,7 @@ declare const RoomConfigRoomTypeEnum: {
205
204
  readonly Conference: "conference";
206
205
  readonly AudioOnlyLivestream: "audio_only_livestream";
207
206
  };
208
- type RoomConfigRoomTypeEnum = typeof RoomConfigRoomTypeEnum[keyof typeof RoomConfigRoomTypeEnum];
209
- declare const RoomConfigVideoCodecEnum: {
210
- readonly H264: "h264";
211
- readonly Vp8: "vp8";
212
- };
213
- type RoomConfigVideoCodecEnum = typeof RoomConfigVideoCodecEnum[keyof typeof RoomConfigVideoCodecEnum];
207
+ type RoomType = typeof RoomType[keyof typeof RoomType];
214
208
  /**
215
209
  * Token for authorizing broadcaster streamer connection
216
210
  * @export
@@ -234,6 +228,25 @@ declare const SubscribeMode: {
234
228
  readonly Manual: "manual";
235
229
  };
236
230
  type SubscribeMode = typeof SubscribeMode[keyof typeof SubscribeMode];
231
+ /**
232
+ * Describes peer\'s subscriptions in manual mode
233
+ * @export
234
+ * @interface Subscriptions
235
+ */
236
+ interface Subscriptions {
237
+ /**
238
+ * List of peer IDs this peer subscribes to
239
+ * @type {Array<string>}
240
+ * @memberof Subscriptions
241
+ */
242
+ 'peers': Array<string>;
243
+ /**
244
+ * List of track IDs this peer subscribes to
245
+ * @type {Array<string>}
246
+ * @memberof Subscriptions
247
+ */
248
+ 'tracks': Array<string>;
249
+ }
237
250
  /**
238
251
  * Describes media track of a Peer
239
252
  * @export
@@ -254,16 +267,31 @@ interface Track$1 {
254
267
  'metadata'?: object | null;
255
268
  /**
256
269
  *
257
- * @type {string}
270
+ * @type {TrackType}
258
271
  * @memberof Track
259
272
  */
260
- 'type'?: TrackTypeEnum;
273
+ 'type'?: TrackType$2;
261
274
  }
262
- declare const TrackTypeEnum: {
275
+ /**
276
+ *
277
+ * @export
278
+ * @enum {string}
279
+ */
280
+ declare const TrackType$2: {
263
281
  readonly Audio: "audio";
264
282
  readonly Video: "video";
265
283
  };
266
- type TrackTypeEnum = typeof TrackTypeEnum[keyof typeof TrackTypeEnum];
284
+ type TrackType$2 = typeof TrackType$2[keyof typeof TrackType$2];
285
+ /**
286
+ * Enforces video codec for each peer in the room
287
+ * @export
288
+ * @enum {string}
289
+ */
290
+ declare const VideoCodec: {
291
+ readonly H264: "h264";
292
+ readonly Vp8: "vp8";
293
+ };
294
+ type VideoCodec = typeof VideoCodec[keyof typeof VideoCodec];
267
295
  /**
268
296
  * Token for authorizing broadcaster viewer connection
269
297
  * @export
@@ -353,6 +381,8 @@ interface ServerMessage {
353
381
  viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
354
382
  streamerConnected?: ServerMessage_StreamerConnected | undefined;
355
383
  streamerDisconnected?: ServerMessage_StreamerDisconnected | undefined;
384
+ channelAdded?: ServerMessage_ChannelAdded | undefined;
385
+ channelRemoved?: ServerMessage_ChannelRemoved | undefined;
356
386
  }
357
387
  declare const ServerMessage: MessageFns$1<ServerMessage>;
358
388
  /** Notification sent when a room crashes */
@@ -411,7 +441,7 @@ interface ServerMessage_AuthRequest {
411
441
  token: string;
412
442
  }
413
443
  declare const ServerMessage_AuthRequest: MessageFns$1<ServerMessage_AuthRequest>;
414
- /** Request sent by peer to subsribe for certain message type */
444
+ /** Request sent by peer to subscribe for certain message type */
415
445
  interface ServerMessage_SubscribeRequest {
416
446
  eventType: ServerMessage_EventType;
417
447
  }
@@ -437,7 +467,7 @@ interface ServerMessage_HlsPlayable {
437
467
  componentId: string;
438
468
  }
439
469
  declare const ServerMessage_HlsPlayable: MessageFns$1<ServerMessage_HlsPlayable>;
440
- /** Notification sent when the HLS recording is successfully uploded to AWS S3 */
470
+ /** Notification sent when the HLS recording is successfully uploaded to AWS S3 */
441
471
  interface ServerMessage_HlsUploaded {
442
472
  roomId: string;
443
473
  }
@@ -479,6 +509,22 @@ interface ServerMessage_TrackMetadataUpdated {
479
509
  track: Track | undefined;
480
510
  }
481
511
  declare const ServerMessage_TrackMetadataUpdated: MessageFns$1<ServerMessage_TrackMetadataUpdated>;
512
+ /** Notification sent when a peer creates a channel */
513
+ interface ServerMessage_ChannelAdded {
514
+ roomId: string;
515
+ peerId?: string | undefined;
516
+ componentId?: string | undefined;
517
+ channelId: string;
518
+ }
519
+ declare const ServerMessage_ChannelAdded: MessageFns$1<ServerMessage_ChannelAdded>;
520
+ /** Notification sent when a peer deletes a channel */
521
+ interface ServerMessage_ChannelRemoved {
522
+ roomId: string;
523
+ peerId?: string | undefined;
524
+ componentId?: string | undefined;
525
+ channelId: string;
526
+ }
527
+ declare const ServerMessage_ChannelRemoved: MessageFns$1<ServerMessage_ChannelRemoved>;
482
528
  /** Notification sent when streamer successfully connects */
483
529
  interface ServerMessage_StreamConnected {
484
530
  streamId: string;
@@ -539,6 +585,7 @@ declare const AgentRequest_TrackData: MessageFns<AgentRequest_TrackData>;
539
585
  interface AgentResponse {
540
586
  authenticated?: AgentResponse_Authenticated | undefined;
541
587
  trackData?: AgentResponse_TrackData | undefined;
588
+ trackImage?: AgentResponse_TrackImage | undefined;
542
589
  }
543
590
  declare const AgentResponse: MessageFns<AgentResponse>;
544
591
  /** Response confirming successful authentication */
@@ -552,6 +599,12 @@ interface AgentResponse_TrackData {
552
599
  data: Uint8Array;
553
600
  }
554
601
  declare const AgentResponse_TrackData: MessageFns<AgentResponse_TrackData>;
602
+ interface AgentResponse_TrackImage {
603
+ trackId: string;
604
+ contentType: string;
605
+ data: Uint8Array;
606
+ }
607
+ declare const AgentResponse_TrackImage: MessageFns<AgentResponse_TrackImage>;
555
608
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
556
609
  type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
557
610
  [K in keyof T]?: DeepPartial<T[K]>;
@@ -750,7 +803,7 @@ declare class FishjamAgent extends FishjamAgent_base {
750
803
  */
751
804
  createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
752
805
  /**
753
- * Interrupt track indentified by `trackId`.
806
+ * Interrupt track identified by `trackId`.
754
807
  *
755
808
  * Any audio that has been sent by the agent, but not played
756
809
  * by Fishjam will be cleared and be prevented from playing.
@@ -782,6 +835,7 @@ declare class FishjamClient {
782
835
  private readonly viewerApi;
783
836
  private readonly streamerApi;
784
837
  private readonly fishjamConfig;
838
+ private deprecationWarningShown;
785
839
  /**
786
840
  * Create new instance of Fishjam Client.
787
841
  *
@@ -794,6 +848,7 @@ declare class FishjamClient {
794
848
  * ```
795
849
  */
796
850
  constructor(config: FishjamConfig);
851
+ private handleDeprecationHeader;
797
852
  /**
798
853
  * Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
799
854
  */
@@ -882,4 +937,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
882
937
  declare class UnknownException extends FishjamBaseException {
883
938
  }
884
939
 
885
- export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsWebRTC, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
940
+ export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsWebRTC, PeerStatus, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, VideoCodec, type ViewerConnected, type ViewerDisconnected, type ViewerToken };