Skip to content

Commit e769b53

Browse files
[WIP] recording: ts version bump, bundle, simpler rec api
1 parent 123690d commit e769b53

File tree

13 files changed

+141
-100
lines changed

13 files changed

+141
-100
lines changed

package-lock.json

Lines changed: 120 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"@jest/globals": "^29.6.2",
3131
"@rollup/plugin-commonjs": "^25.0.7",
3232
"@rollup/plugin-node-resolve": "^13.0.4",
33-
"@rollup/plugin-typescript": "^10.0.1",
33+
"@rollup/plugin-typescript": "^12.1.2",
3434
"@types/jest": "^29.5.0",
35-
"@types/node": "^20.5.0",
35+
"@types/node": "^22.13.14",
3636
"@types/ws": "^8.18.1",
37-
"@typescript-eslint/eslint-plugin": "8.32.1",
38-
"@typescript-eslint/parser": "8.32.1",
37+
"@typescript-eslint/eslint-plugin": "^8.46.3",
38+
"@typescript-eslint/parser": "^8.46.3",
3939
"eslint": "8.57.1",
4040
"eslint-config-prettier": "^10.1.8",
4141
"eslint-plugin-import": "^2.25.3",
@@ -50,6 +50,6 @@
5050
"rollup": "^2.79.1",
5151
"rollup-plugin-license": "3.2.0",
5252
"ts-jest": "^29.3.4",
53-
"typescript": "~5.4.3"
53+
"typescript": "~5.9.3"
5454
}
5555
}

rollup.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ export default {
3535
plugins: [
3636
typescript({
3737
tsconfig: "./tsconfig_bundle.json",
38-
declaration: false,
39-
declarationMap: false,
40-
sourceMap: false,
4138
}),
4239
resolve({
4340
browser: true,

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class SfuClient extends EventTarget {
271271
}
272272
async startRecording() {
273273
if (this.state !== SfuClientState.CONNECTED) {
274-
throw new Error("InvalidState");
274+
return;
275275
}
276276
return this._bus?.request(
277277
{
@@ -283,7 +283,7 @@ export class SfuClient extends EventTarget {
283283

284284
async stopRecording() {
285285
if (this.state !== SfuClientState.CONNECTED) {
286-
throw new Error("InvalidState");
286+
return;
287287
}
288288
return this._bus?.request(
289289
{

src/models/channel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export class Channel extends EventEmitter {
129129
logger.info(
130130
`created channel ${channel.uuid} (${key ? "unique" : "global"} key) for ${safeIssuer}`
131131
);
132+
logger.verbose(`rtc feature: ${Boolean(channel.router)}`);
133+
logger.verbose(`recording feature: ${Boolean(channel.recorder)}`);
132134
const onWorkerDeath = () => {
133135
logger.warn(`worker died, closing channel ${channel.uuid}`);
134136
channel.close();

src/models/recorder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Recorder extends EventEmitter {
3232
// TODO ffmpeg instance creation for recording to folder.path with proper name, start, build timestamps object
3333
}
3434
this._record();
35-
return { state: this.state };
35+
return this.isRecording;
3636
}
3737

3838
async stop() {
@@ -48,7 +48,7 @@ export class Recorder extends EventEmitter {
4848
// only resolve promise and switch state when completely ready to start a new recording.
4949
this.state = RECORDER_STATE.STOPPED;
5050
}
51-
return { state: this.state };
51+
return this.isRecording;
5252
}
5353

5454
get isRecording(): boolean {

src/models/session.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export class Session extends EventEmitter {
208208
continue;
209209
}
210210
this.permissions[key] = Boolean(permissions[key]);
211+
logger.verbose(`Permissions updated: ${key} = ${this.permissions[key]}`);
211212
}
212213
}
213214

src/services/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface PrivateJWTClaims {
4343
sfu_channel_uuid?: string;
4444
session_id?: SessionId;
4545
ice_servers?: object[];
46-
permissions?: SessionPermissions,
46+
permissions?: SessionPermissions;
4747
sessionIdsByChannel?: Record<string, SessionId[]>;
4848
/** If provided when requesting a channel, this key will be used instead of the global key to verify JWTs related to this channel */
4949
key?: string;

src/shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type {
3030
RtpParameters
3131
// eslint-disable-next-line node/no-unpublished-import
3232
} from "mediasoup-client/lib/types";
33-
import type { CLIENT_MESSAGE, CLIENT_REQUEST, SERVER_MESSAGE, SERVER_REQUEST } from "./enums.ts";
33+
import type { CLIENT_MESSAGE, CLIENT_REQUEST, SERVER_MESSAGE, SERVER_REQUEST } from "./enums";
3434

3535
export type BusMessage =
3636
| { name: typeof CLIENT_MESSAGE.BROADCAST; payload: JSONSerializable }

tests/network.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ describe("Full network", () => {
288288
const sender = await network.connect(channelUUID, 3);
289289
await Promise.all([user1.isConnected, sender.isConnected]);
290290
expect(sender.sfuClient.availableFeatures.recording).toBe(true);
291-
const startResult = (await sender.sfuClient.startRecording()) as { state: string };
292-
expect(startResult.state).toBe("started");
293-
const stopResult = (await sender.sfuClient.stopRecording()) as { state: string };
294-
expect(stopResult.state).toBe("stopped");
291+
const startResult = (await sender.sfuClient.startRecording()) as boolean;
292+
expect(startResult).toBe(true);
293+
const stopResult = (await sender.sfuClient.stopRecording()) as boolean;
294+
expect(stopResult).toBe(false);
295295
});
296296
});

0 commit comments

Comments
 (0)