trtc-sdk-v5 5.19.0 → 5.19.1-beta.2

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/index.d.ts CHANGED
@@ -557,9 +557,20 @@ export declare const enum TRTCDeviceAction {
557
557
  Add = 'add',
558
558
  Active = 'active'
559
559
  }
560
+ export declare interface PermissionNeededEvent {
561
+ mediaType: 'camera' | 'microphone' | 'camera-and-microphone';
562
+ state: 'prompt' | 'denied';
563
+ userMediaElement?: HTMLElement;
564
+ cameraElement?: HTMLElement;
565
+ microphoneElement?: HTMLElement;
566
+ abort: () => void;
567
+ settled: Promise<void>;
568
+ }
569
+
560
570
  export declare interface PermissionOption {
561
571
  request?: boolean;
562
572
  types?: ('camera' | 'microphone')[];
573
+ onPermissionNeeded?: (event: PermissionNeededEvent) => void;
563
574
  }
564
575
 
565
576
  export declare interface RealtimeTranscriberStateEvent {
@@ -1385,7 +1396,33 @@ export declare const TRTCEvent: {
1385
1396
  * // event.isFullScreen: is in full screen.
1386
1397
  * })
1387
1398
  */
1388
- readonly FULL_SCREEN_STATE_CHANGED: 'full-screen-state-changed'
1399
+ readonly FULL_SCREEN_STATE_CHANGED: 'full-screen-state-changed';
1400
+ /**
1401
+ * @since v5.16.0
1402
+ * @description Permission needed event. Emitted when startLocalVideo or startLocalAudio
1403
+ * encounters a permission issue (state is 'prompt' or 'denied'). The SDK will provide a usermedia element
1404
+ * that the business side should mount into its own dialog UI and guide the user to click the button to authorize.
1405
+ *
1406
+ * - If no listener is registered for this event, the SDK will fallback to its built-in permission dialog.
1407
+ * - If a listener is registered, the SDK will NOT show its built-in dialog and will wait for the user interaction on the provided element.
1408
+ *
1409
+ * @example
1410
+ * trtc.on(TRTC.EVENT.PERMISSION_NEEDED, event => {
1411
+ * // event.state: 'prompt' | 'denied' - current permission state
1412
+ * // event.mediaType: 'camera' | 'microphone' | 'camera-and-microphone' - which media type needs permission
1413
+ * // event.element: HTMLElement - the usermedia element to mount in your dialog
1414
+ * // event.abort: () => void - call this to cancel the permission request
1415
+ *
1416
+ * myDialog.container.appendChild(event.element);
1417
+ * myDialog.show();
1418
+ *
1419
+ * myDialog.onCancel(() => {
1420
+ * event.abort();
1421
+ * myDialog.hide();
1422
+ * });
1423
+ * })
1424
+ */
1425
+ readonly PERMISSION_NEEDED: 'permission-needed'
1389
1426
  };
1390
1427
  export declare interface TRTCEventTypes {
1391
1428
  [TRTCEvent.ERROR]: [RtcError];
@@ -1493,7 +1530,13 @@ export declare interface TRTCEventTypes {
1493
1530
  [TRTCEvent.REALTIME_TRANSCRIBER_MESSAGE]: [RealtimeTranscriberMessageEvent];
1494
1531
  [TRTCEvent.REALTIME_TRANSCRIBER_STATE_CHANGED]: [RealtimeTranscriberStateEvent];
1495
1532
  [TRTCEvent.PICTURE_IN_PICTURE_STATE_CHANGED]: [PictureInPictureStateChangedEvent];
1496
- [TRTCEvent.FULL_SCREEN_STATE_CHANGED]: [FullScreenStateChangedEvent]
1533
+ [TRTCEvent.FULL_SCREEN_STATE_CHANGED]: [FullScreenStateChangedEvent];
1534
+ [TRTCEvent.PERMISSION_NEEDED]: [{
1535
+ state: 'prompt' | 'denied';
1536
+ mediaType: 'camera' | 'microphone' | 'camera-and-microphone';
1537
+ element: HTMLElement;
1538
+ abort: () => void;
1539
+ }]
1497
1540
  }
1498
1541
 
1499
1542
  export interface PictureInPictureStateChangedEvent {
@@ -2443,13 +2486,29 @@ export declare class TRTC {
2443
2486
  * @param {PermissionOption} option
2444
2487
  * @param {boolean} [option.request=true] Whether to request permission to use the camera and microphone.
2445
2488
  * @param {string[]} [option.types=['camera', 'microphone']] The types of permission to request.
2489
+ * @param {Function} [option.onPermissionNeeded] Callback when permission is needed. When provided, SDK will use `<usermedia>` element (Chrome 152+) to request permission. Falls back to getUserMedia if not supported.
2446
2490
  * @returns {Promise<PermissionResult>} Promise returns the permission state of the camera and microphone
2447
2491
  * @example
2492
+ * // Basic usage
2448
2493
  * const { camera, microphone } = await TRTC.getPermissions({
2449
- * request: true, // if true, will request permission to use the camera and microphone.
2494
+ * request: true,
2450
2495
  * types: ['camera', 'microphone']
2451
2496
  * });
2452
- * console.log(camera, microphone); // 'granted' | 'denied' | 'prompt' | null. null means the permission is not supported query.
2497
+ *
2498
+ * // With PEPC (Page-Embedded Permission Control)
2499
+ * const { camera, microphone } = await TRTC.getPermissions({
2500
+ * request: true,
2501
+ * types: ['camera', 'microphone'],
2502
+ * onPermissionNeeded: (event) => {
2503
+ * myDialog.show();
2504
+ * if (event.elements.cameraAndMicrophone) {
2505
+ * myDialog.addButton('Allow Camera & Mic', event.elements.cameraAndMicrophone);
2506
+ * }
2507
+ * myDialog.onCancel(() => event.abort());
2508
+ * event.settled.then(() => myDialog.hide());
2509
+ * }
2510
+ * });
2511
+ * console.log(camera, microphone); // 'granted' | 'denied' | 'prompt' | null
2453
2512
  */
2454
2513
  static getPermissions(option: PermissionOption): Promise<PermissionResult>;
2455
2514
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/audio-player",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK AudioPlayer plugin - unified audio player supporting PCM, URL, and Track sources",
5
5
  "main": "./audio-player.esm.js",
6
6
  "module": "./audio-player.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "module": "./cdn-streaming.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/chorus",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x Chorus plugin",
5
5
  "main": "./chorus.esm.js",
6
6
  "module": "./chorus.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/custom-encryption",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "main": "./custom-encryption.esm.js",
5
5
  "module": "./custom-encryption.esm.js",
6
6
  "types": "./custom-encryption.esm.d.ts"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/device-detector",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x device detector plugin",
5
5
  "main": "./device-detector.esm.js",
6
6
  "module": "./device-detector.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/lebplayer",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x LEBPlayer plugin",
5
5
  "main": "./lebplayer.esm.js",
6
6
  "module": "./lebplayer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/realtime-transcriber",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x Realtime Transcriber plugin",
5
5
  "main": "./realtime-transcriber.esm.js",
6
6
  "module": "./realtime-transcriber.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/small-stream-auto-switcher",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "",
5
5
  "main": "./small-stream-auto-switcher.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-decoder",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/basic-beauty",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x basic-beauty plugin",
5
5
  "main": "./basic-beauty.esm.js",
6
6
  "module": "./basic-beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/beauty",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x beauty plugin",
5
5
  "main": "./beauty.esm.js",
6
6
  "module": "./beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/face-detection",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x face detection plugin",
5
5
  "main": "./face-detection.esm.js",
6
6
  "module": "./face-detection.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-mixer",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x videoMixer plugin",
5
5
  "main": "./video-mixer.esm.js",
6
6
  "module": "./video-mixer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/virtual-background",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x virtual background plugin",
5
5
  "main": "./virtual-background.esm.js",
6
6
  "module": "./virtual-background.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/watermark",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK 5.x watermark plugin",
5
5
  "main": "./watermark.esm.js",
6
6
  "module": "./watermark.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/voice-changer",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "",
5
5
  "main": "./voice-changer.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/whiteboard",
3
- "version": "5.19.0",
3
+ "version": "5.19.1-beta.2",
4
4
  "description": "TRTC Web SDK Whiteboard plugin",
5
5
  "main": "./whiteboard.esm.js",
6
6
  "module": "./whiteboard.esm.js",