mediasoup-client 3.20.0 → 3.22.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.
Files changed (61) hide show
  1. package/README.md +9 -0
  2. package/lib/Consumer.d.ts.map +1 -1
  3. package/lib/Consumer.js +3 -0
  4. package/lib/DataConsumer.d.ts.map +1 -1
  5. package/lib/DataConsumer.js +8 -1
  6. package/lib/DataProducer.d.ts.map +1 -1
  7. package/lib/DataProducer.js +8 -1
  8. package/lib/Device.d.ts +0 -8
  9. package/lib/Device.d.ts.map +1 -1
  10. package/lib/Device.js +36 -21
  11. package/lib/Logger.d.ts +1 -0
  12. package/lib/Logger.d.ts.map +1 -1
  13. package/lib/Logger.js +4 -1
  14. package/lib/Producer.d.ts.map +1 -1
  15. package/lib/Producer.js +3 -0
  16. package/lib/RtpParameters.d.ts.map +1 -1
  17. package/lib/SctpParameters.d.ts +9 -22
  18. package/lib/SctpParameters.d.ts.map +1 -1
  19. package/lib/Transport.d.ts +1 -1
  20. package/lib/Transport.d.ts.map +1 -1
  21. package/lib/Transport.js +85 -25
  22. package/lib/handlers/Chrome111.d.ts +1 -0
  23. package/lib/handlers/Chrome111.d.ts.map +1 -1
  24. package/lib/handlers/Chrome111.js +56 -20
  25. package/lib/handlers/Chrome74.d.ts +1 -0
  26. package/lib/handlers/Chrome74.d.ts.map +1 -1
  27. package/lib/handlers/Chrome74.js +56 -20
  28. package/lib/handlers/FakeHandler.d.ts +0 -2
  29. package/lib/handlers/FakeHandler.d.ts.map +1 -1
  30. package/lib/handlers/FakeHandler.js +35 -6
  31. package/lib/handlers/Firefox120.d.ts +1 -0
  32. package/lib/handlers/Firefox120.d.ts.map +1 -1
  33. package/lib/handlers/Firefox120.js +49 -15
  34. package/lib/handlers/HandlerInterface.d.ts +2 -3
  35. package/lib/handlers/HandlerInterface.d.ts.map +1 -1
  36. package/lib/handlers/ReactNative106.d.ts +1 -0
  37. package/lib/handlers/ReactNative106.d.ts.map +1 -1
  38. package/lib/handlers/ReactNative106.js +56 -20
  39. package/lib/handlers/Safari12.d.ts +1 -0
  40. package/lib/handlers/Safari12.d.ts.map +1 -1
  41. package/lib/handlers/Safari12.js +56 -20
  42. package/lib/handlers/fakeEvents/FakeEventListener.d.ts.map +1 -1
  43. package/lib/handlers/sdp/{MediaSection.d.ts → RemoteMediaSection.d.ts} +4 -4
  44. package/lib/handlers/sdp/RemoteMediaSection.d.ts.map +1 -0
  45. package/lib/handlers/sdp/{MediaSection.js → RemoteMediaSection.js} +47 -12
  46. package/lib/handlers/sdp/RemoteSdp.d.ts.map +1 -1
  47. package/lib/handlers/sdp/RemoteSdp.js +41 -8
  48. package/lib/handlers/sdp/commonUtils.js +34 -1
  49. package/lib/handlers/sdp/unifiedPlanUtils.d.ts.map +1 -1
  50. package/lib/index.d.ts +1 -1
  51. package/lib/index.js +42 -6
  52. package/lib/ortc.d.ts +1 -6
  53. package/lib/ortc.d.ts.map +1 -1
  54. package/lib/ortc.js +35 -34
  55. package/lib/test/fakeParameters.d.ts +0 -1
  56. package/lib/test/fakeParameters.d.ts.map +1 -1
  57. package/lib/test/fakeParameters.js +36 -10
  58. package/lib/test/test.js +39 -10
  59. package/npm-scripts.mjs +157 -36
  60. package/package.json +17 -15
  61. package/lib/handlers/sdp/MediaSection.d.ts.map +0 -1
package/npm-scripts.mjs CHANGED
@@ -4,22 +4,23 @@ import * as fs from 'node:fs';
4
4
  import { execSync } from 'node:child_process';
5
5
  import pkg from './package.json' with { type: 'json' };
6
6
 
7
- const MAYOR_VERSION = pkg.version.split('.')[0];
7
+ // Main Git branch is 'v' concatenated with the major SEMVER number of the
8
+ // "version" field in package.json.
9
+ const MAIN_BRANCH = `v${pkg.version.split('.')[0]}`;
8
10
 
9
- // Paths for ESLint to check. Converted to string for convenience.
11
+ // Paths for ESLint to check.
10
12
  const ESLINT_PATHS = [
11
13
  'eslint.config.mjs',
12
14
  'jest.config.mjs',
13
15
  'npm-scripts.mjs',
14
16
  'src',
15
- ].join(' ');
17
+ ];
16
18
 
17
- // Paths for ESLint to ignore. Converted to string argument for convenience.
18
- const ESLINT_IGNORE_PATTERN_ARGS = []
19
- .map(entry => `--ignore-pattern ${entry}`)
20
- .join(' ');
19
+ // Paths for ESLint to ignore.
20
+ const ESLINT_IGNORE_PATHS = [];
21
21
 
22
- // Paths for Prettier to check/write. Converted to string for convenience.
22
+ // Paths for Prettier to check/write.
23
+ // NOTE: Prettier ignores paths in .gitignore.
23
24
  const PRETTIER_PATHS = [
24
25
  'README.md',
25
26
  'eslint.config.mjs',
@@ -28,12 +29,12 @@ const PRETTIER_PATHS = [
28
29
  'package.json',
29
30
  'tsconfig.json',
30
31
  'src',
31
- ].join(' ');
32
+ ];
32
33
 
33
34
  const task = process.argv[2];
34
35
  const taskArgs = process.argv.slice(3).join(' ');
35
36
 
36
- run();
37
+ void run();
37
38
 
38
39
  async function run() {
39
40
  logInfo(taskArgs ? `[args:"${taskArgs}"]` : '');
@@ -53,20 +54,24 @@ async function run() {
53
54
  // So here we compile TypeScript to JavaScript.
54
55
  case 'prepare': {
55
56
  buildTypescript({ force: false });
56
- replaceVersion();
57
+
58
+ break;
59
+ }
60
+
61
+ case 'prepublishOnly': {
62
+ prepublishOnly();
57
63
 
58
64
  break;
59
65
  }
60
66
 
61
67
  case 'typescript:build': {
62
- buildTypescript({ force: true });
63
- replaceVersion();
68
+ buildTypescript({ force: true, args: taskArgs });
64
69
 
65
70
  break;
66
71
  }
67
72
 
68
73
  case 'typescript:watch': {
69
- watchTypescript();
74
+ watchTypescript({ args: taskArgs });
70
75
 
71
76
  break;
72
77
  }
@@ -84,15 +89,19 @@ async function run() {
84
89
  }
85
90
 
86
91
  case 'test': {
87
- replaceVersion();
88
92
  test();
89
93
 
90
94
  break;
91
95
  }
92
96
 
93
97
  case 'coverage': {
94
- replaceVersion();
95
- coverage();
98
+ coverage({ args: taskArgs });
99
+
100
+ break;
101
+ }
102
+
103
+ case 'publish:dry-run': {
104
+ publishDryRun();
96
105
 
97
106
  break;
98
107
  }
@@ -104,7 +113,7 @@ async function run() {
104
113
  }
105
114
 
106
115
  case 'release': {
107
- release();
116
+ await release({ args: taskArgs });
108
117
 
109
118
  break;
110
119
  }
@@ -149,7 +158,8 @@ function deleteLib() {
149
158
  fs.rmSync('lib', { recursive: true, force: true });
150
159
  }
151
160
 
152
- function buildTypescript({ force }) {
161
+ function buildTypescript({ force, args = '' }) {
162
+ // Skip JavaScript code generation if the output already exists, unless forced.
153
163
  if (!force && fs.existsSync('lib')) {
154
164
  return;
155
165
  }
@@ -159,15 +169,15 @@ function buildTypescript({ force }) {
159
169
  deleteLib();
160
170
 
161
171
  // Generate .js CommonJS code and .d.ts TypeScript declaration files in lib/.
162
- executeCmd(`tsc ${taskArgs}`);
172
+ executeCmd(`tsc ${args}`);
163
173
  }
164
174
 
165
- function watchTypescript() {
175
+ function watchTypescript({ args = '' } = {}) {
166
176
  logInfo('watchTypescript()');
167
177
 
168
178
  deleteLib();
169
179
 
170
- executeCmd(`tsc --watch ${taskArgs}`);
180
+ executeCmd(`tsc --watch ${args}`);
171
181
  }
172
182
 
173
183
  function lint() {
@@ -177,29 +187,40 @@ function lint() {
177
187
  // rules.
178
188
  executeCmd('eslint-config-prettier eslint.config.mjs');
179
189
 
190
+ const eslintIgnorePatternArgs = ESLINT_IGNORE_PATHS.map(
191
+ entry => `--ignore-pattern ${entry}`
192
+ ).join(' ');
193
+ const eslintFiles = ESLINT_PATHS.join(' ');
194
+
180
195
  executeCmd(
181
- `eslint -c eslint.config.mjs --max-warnings 0 ${ESLINT_IGNORE_PATTERN_ARGS} ${ESLINT_PATHS}`
196
+ `eslint -c eslint.config.mjs --max-warnings 0 ${eslintIgnorePatternArgs} ${eslintFiles}`
182
197
  );
183
198
 
184
- executeCmd(`prettier --check ${PRETTIER_PATHS}`);
199
+ const prettierFiles = PRETTIER_PATHS.join(' ');
200
+
201
+ executeCmd(`prettier --check ${prettierFiles}`);
202
+
203
+ executeCmd('knip --config knip.config.mjs --treat-config-hints-as-errors');
185
204
  }
186
205
 
187
206
  function format() {
188
207
  logInfo('format()');
189
208
 
190
- executeCmd(`prettier --write ${PRETTIER_PATHS}`);
209
+ const prettierFiles = PRETTIER_PATHS.join(' ');
210
+
211
+ executeCmd(`prettier --write ${prettierFiles}`);
191
212
  }
192
213
 
193
- function test() {
214
+ function test({ args = '' } = {}) {
194
215
  logInfo('test()');
195
216
 
196
- executeCmd(`jest --silent false --detectOpenHandles ${taskArgs}`);
217
+ executeCmd(`jest --silent false --detectOpenHandles ${args}`);
197
218
  }
198
219
 
199
- function coverage() {
220
+ function coverage({ args = '' } = {}) {
200
221
  logInfo('coverage()');
201
222
 
202
- executeCmd(`jest --coverage ${taskArgs}`);
223
+ executeCmd(`jest --coverage ${args}`);
203
224
  executeCmd('open-cli coverage/lcov-report/index.html');
204
225
  }
205
226
 
@@ -216,25 +237,124 @@ function installDeps() {
216
237
  executeCmd('npm audit --omit dev');
217
238
  }
218
239
 
240
+ /**
241
+ * `prepublishOnly` is run by NPM only on `npm publish` (not on `npm pack`,
242
+ * `npm install` or `npm ci`). We use it to forbid publishing mediasoup-client
243
+ * from a local machine. The package must only be published by the
244
+ * `mediasoup-client-npm-publish` workflow, which runs inside GitHub Actions
245
+ * (where GITHUB_ACTIONS environment variable is set to 'true') and uses OIDC
246
+ * trusted publishing.
247
+ */
248
+ function prepublishOnly() {
249
+ logInfo('prepublishOnly()');
250
+
251
+ if (process.env.GITHUB_ACTIONS !== 'true') {
252
+ logError(
253
+ "prepublishOnly() | refusing to 'npm publish' outside of GitHub Actions: mediasoup-client is published only by the mediasoup-client-npm-publish workflow (triggered by pushing a release tag via 'npm run release')"
254
+ );
255
+
256
+ exitWithError();
257
+ }
258
+ }
259
+
260
+ function publishDryRun() {
261
+ logInfo('publishDryRun()');
262
+
263
+ // NOTE: We use `npm pack --dry-run` rather than `npm publish --dry-run`
264
+ // because the latter contacts the registry and fails with "You cannot
265
+ // publish over the previously published versions" whenever the version in
266
+ // package.json is already published (which is the usual state between
267
+ // releases), making it useless in CI.
268
+ //
269
+ // `npm pack --dry-run` still runs the `prepare` script (TypeScript build)
270
+ // and assembles the tarball exactly as a real publish would, reporting its
271
+ // contents without writing any file or contacting the registry. Useful to
272
+ // validate the `files` list in package.json and that the package builds
273
+ // before tagging a release.
274
+ executeCmd('npm pack --dry-run --loglevel warn');
275
+ }
276
+
219
277
  function checkRelease() {
220
278
  logInfo('checkRelease()');
221
279
 
222
280
  installDeps();
223
281
  buildTypescript({ force: true });
224
- replaceVersion();
225
282
  lint();
226
283
  test();
284
+ // Validate packaging (the `files` list in package.json) before the
285
+ // irreversible release steps (git push, GitHub release, npm publish).
286
+ publishDryRun();
227
287
  }
228
288
 
229
- function release() {
289
+ async function release({ args = '' } = {}) {
230
290
  logInfo('release()');
231
291
 
292
+ const version = args.trim();
293
+
294
+ if (!/^\d+\.\d+\.\d+$/.test(version)) {
295
+ logError(
296
+ `release() | a SEMVER 'x.y.z' argument is required, but got '${version}'`
297
+ );
298
+
299
+ exitWithError();
300
+ }
301
+
302
+ // Must be on the main branch.
303
+ const branch = execSync('git rev-parse --abbrev-ref HEAD', {
304
+ encoding: 'utf-8',
305
+ }).trim();
306
+
307
+ if (branch !== MAIN_BRANCH) {
308
+ logError(
309
+ `release() | must be on '${MAIN_BRANCH}' branch, but it is on '${branch}' branch`
310
+ );
311
+
312
+ exitWithError();
313
+ }
314
+
315
+ // Clean working tree required before bumping the version.
316
+ checkGitClean();
317
+
318
+ // Lint, test, build, publish dry-run.
232
319
  checkRelease();
233
- executeCmd(`git commit -am '${pkg.version}'`);
234
- executeCmd(`git tag -a ${pkg.version} -m '${pkg.version}'`);
235
- executeCmd(`git push origin v${MAYOR_VERSION}`);
236
- executeCmd(`git push origin '${pkg.version}'`);
237
- executeInteractiveCmd('npm publish');
320
+
321
+ // Bump the version in package.json + package-lock.json.
322
+ executeCmd(`npm version ${version} --no-git-tag-version`);
323
+
324
+ // Also replace the version in the transpiled JS.
325
+ replaceVersion();
326
+
327
+ // Commit the bump, tag it, and push both. The pushed tag triggers
328
+ // `mediasoup-client-npm-publish` workflow, which checks, creates the GitHub
329
+ // release and publishes to NPM.
330
+ //
331
+ // The commit message carries a "[no-ci]" marker so the regular branch CI
332
+ // workflow skips this commit.
333
+ //
334
+ // NOTE: "[no-ci]" (with a hyphen) is a custom marker, NOT GitHub's native
335
+ // "[skip ci]"/"[no ci]" (which would also skip `mediasoup-client-npm-publish`
336
+ // workflow, since the tag push shares this same commit).
337
+ executeCmd(`git commit -am 'release ${version} [no-ci]'`);
338
+ executeCmd(`git tag -a ${version} -m '${version}'`);
339
+ executeCmd(`git push origin ${MAIN_BRANCH}`);
340
+ executeCmd(`git push origin '${version}'`);
341
+ }
342
+
343
+ function checkGitClean() {
344
+ logInfo('checkGitClean()');
345
+
346
+ const status = execSync('git status --porcelain', {
347
+ encoding: 'utf-8',
348
+ stdio: ['ignore', 'pipe', 'ignore'],
349
+ });
350
+
351
+ if (status.trim()) {
352
+ logError(
353
+ 'checkGitClean() | Git working tree is not clean, commit or stash your changes first'
354
+ );
355
+
356
+ exitWithError();
357
+ }
238
358
  }
239
359
 
240
360
  function executeCmd(command) {
@@ -249,6 +369,7 @@ function executeCmd(command) {
249
369
  }
250
370
  }
251
371
 
372
+ // eslint-disable-next-line no-unused-vars
252
373
  function executeInteractiveCmd(command) {
253
374
  logInfo(`executeInteractiveCmd(): ${command}`);
254
375
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup-client",
3
- "version": "3.20.0",
3
+ "version": "3.22.0",
4
4
  "description": "mediasoup client side TypeScript library",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -61,41 +61,43 @@
61
61
  ],
62
62
  "scripts": {
63
63
  "prepare": "node npm-scripts.mjs prepare",
64
+ "prepublishOnly": "node npm-scripts.mjs prepublishOnly",
64
65
  "typescript:build": "node npm-scripts.mjs typescript:build",
65
66
  "typescript:watch": "node npm-scripts.mjs typescript:watch",
66
67
  "lint": "node npm-scripts.mjs lint",
67
68
  "format": "node npm-scripts.mjs format",
68
69
  "test": "node npm-scripts.mjs test",
69
70
  "coverage": "node npm-scripts.mjs coverage",
71
+ "publish:dry-run": "node npm-scripts.mjs publish:dry-run",
70
72
  "release:check": "node npm-scripts.mjs release:check",
71
73
  "release": "node npm-scripts.mjs release"
72
74
  },
73
75
  "dependencies": {
74
76
  "@types/debug": "^4.1.13",
75
77
  "@types/events-alias": "npm:@types/events@^3.0.3",
76
- "awaitqueue": "^3.3.0",
78
+ "awaitqueue": "^3.3.1",
77
79
  "debug": "^4.4.3",
78
80
  "events-alias": "npm:events@^3.3.0",
79
81
  "fake-mediastreamtrack": "^2.2.1",
80
- "h264-profile-level-id": "^2.3.2",
82
+ "h264-profile-level-id": "^2.3.3",
81
83
  "sdp-transform": "^3.0.0",
82
- "supports-color": "^10.2.2"
84
+ "supports-color": "^11.0.0"
83
85
  },
84
86
  "devDependencies": {
85
87
  "@eslint/js": "^10.0.1",
86
88
  "@types/jest": "^30.0.0",
87
- "@types/sdp-transform": "^2.15.0",
88
- "@types/ua-parser-js": "^0.7.39",
89
- "eslint": "^10.2.1",
89
+ "@types/sdp-transform": "^3.0.0",
90
+ "eslint": "^10.8.1",
90
91
  "eslint-config-prettier": "^10.1.8",
91
- "eslint-plugin-jest": "^29.15.2",
92
- "eslint-plugin-prettier": "^5.5.5",
93
- "globals": "^17.5.0",
94
- "jest": "^30.3.0",
92
+ "eslint-plugin-jest": "^29.16.1",
93
+ "eslint-plugin-prettier": "^5.5.6",
94
+ "globals": "^17.11.0",
95
+ "jest": "^30.4.2",
96
+ "knip": "^6.32.2",
95
97
  "open-cli": "^9.0.0",
96
- "prettier": "^3.8.3",
97
- "ts-jest": "^29.4.9",
98
- "typescript": "^5.9.3",
99
- "typescript-eslint": "^8.59.1"
98
+ "prettier": "^3.9.6",
99
+ "ts-jest": "^29.4.12",
100
+ "typescript": "^6.0.3",
101
+ "typescript-eslint": "^8.67.0"
100
102
  }
101
103
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"MediaSection.d.ts","sourceRoot":"","sources":["../../../src/handlers/sdp/MediaSection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,YAAY,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EACX,SAAS,EACT,aAAa,EAGb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,8BAAsB,YAAY;IAEjC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAC;gBAEnD,EACX,aAAa,EACb,aAAa,EACb,cAAc,GACd,EAAE;QACF,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;KAChC;IAmDD,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAE1C,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,SAAS,IAAI,YAAY,CAAC,gBAAgB;IAI1C,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;IAKpD,KAAK,IAAI,IAAI;IAIb,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB,OAAO,IAAI,IAAI;IAIf,KAAK,IAAI,IAAI;CAuBb;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACvC,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACZ,EAAE;QACF,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;QACxC,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,CAAC;QAChD,kBAAkB,CAAC,EAAE,aAAa,CAAC;QACnC,mBAAmB,CAAC,EAAE,aAAa,CAAC;QACpC,YAAY,CAAC,EAAE,oBAAoB,CAAC;KACpC;IAiQD,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAsBjC,MAAM,IAAI,IAAI;IAId,mBAAmB,CAAC,SAAS,EAAE,wBAAwB,EAAE,GAAG,IAAI;CA6BhE;AAED,qBAAa,iBAAkB,SAAQ,YAAY;gBACtC,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,GAAG,EACH,IAAI,EACJ,kBAAkB,EAClB,QAAQ,EACR,OAAO,GACP,EAAE;QACF,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;QACxC,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;QAEhC,kBAAkB,CAAC,EAAE,aAAa,CAAC;QACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KACjB;IA8ID,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAKjC,MAAM,IAAI,IAAI;CAGd"}