trtc-electron-sdk 10.3.404 → 10.3.405-beta.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.
@@ -1,5 +1,5 @@
1
1
  import { TRTCVideoFillMode } from "../trtc_define";
2
- export declare type TFrameData = {
2
+ export type TFrameData = {
3
3
  data: Uint8Array | ArrayBuffer;
4
4
  width: number;
5
5
  height: number;
@@ -7,7 +7,7 @@ export declare type TFrameData = {
7
7
  rotation: number;
8
8
  isNeedRotate: boolean;
9
9
  };
10
- export declare type TCanvasImageSourceStyleOptions = {
10
+ export type TCanvasImageSourceStyleOptions = {
11
11
  contentWidth: number;
12
12
  contentHeight: number;
13
13
  containerWidth: number;
package/liteav/trtc.js CHANGED
@@ -108,32 +108,46 @@ let formatLogParams = function (params) {
108
108
  return logParamsStr;
109
109
  };
110
110
  const getComponentNO = function () {
111
- var _a;
111
+ var _a, _b;
112
112
  let componentName = '';
113
113
  // @ts-ignore
114
- if (global.__TRTCElectron && global.__TRTCElectron.componentName) {
114
+ if ((_a = window === null || window === void 0 ? void 0 : window.__TRTCElectron) === null || _a === void 0 ? void 0 : _a.componentName) {
115
115
  // @ts-ignore
116
- componentName = global.__TRTCElectron.componentName;
116
+ componentName = window.__TRTCElectron.componentName;
117
117
  }
118
118
  else {
119
- const jsonStr = (_a = global.localStorage) === null || _a === void 0 ? void 0 : _a.getItem('__TRTCElectron');
120
- if (jsonStr) {
121
- try {
122
- const jsonObj = JSON.parse(jsonStr);
123
- if (jsonObj.componentName && typeof jsonObj.componentName === 'string') {
124
- componentName = jsonObj.componentName;
119
+ if ((_b = window === null || window === void 0 ? void 0 : window.localStorage) === null || _b === void 0 ? void 0 : _b.getItem) {
120
+ const jsonStr = window.localStorage.getItem('__TRTCElectron');
121
+ if (jsonStr) {
122
+ try {
123
+ const jsonObj = JSON.parse(jsonStr);
124
+ if (jsonObj.componentName && typeof jsonObj.componentName === 'string') {
125
+ componentName = jsonObj.componentName;
126
+ }
127
+ }
128
+ catch (error) {
129
+ console.warn('trtc: localstorage TRTCElectron parse error.', error);
125
130
  }
126
- }
127
- catch (error) {
128
- console.warn('trtc: localstorage TRTCElectron parse error.', error);
129
131
  }
130
132
  }
133
+ else {
134
+ /**
135
+ * localStorage not defined or accessing is denied.
136
+ *
137
+ * Will occur when third-party scripts cookies are disallowed and access to localStorage may result in thrown SecurityError exceptions.
138
+ * ref 1: https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document/
139
+ * ref 2: https://cloud.tencent.com/developer/article/1803097
140
+ */
141
+ }
131
142
  }
132
143
  let componentNO = '';
133
144
  switch (componentName) {
134
145
  case 'TUIRoom':
135
146
  componentNO = '5';
136
147
  break;
148
+ case 'TUIRoomKit':
149
+ componentNO = '16';
150
+ break;
137
151
  default:
138
152
  break;
139
153
  }
@@ -1084,7 +1098,7 @@ class TRTCCloud extends events_1.EventEmitter {
1084
1098
  */
1085
1099
  handleOnScreenCaptureStarted() {
1086
1100
  this.isScreenCapturing = true;
1087
- // 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1101
+ // 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1088
1102
  if (!screenVideoBuffer.buffer) {
1089
1103
  screenVideoBuffer.userId = '';
1090
1104
  screenVideoBuffer.streamType = this.screenCaptureStreamType;
@@ -1663,7 +1677,7 @@ class TRTCCloud extends events_1.EventEmitter {
1663
1677
  this._initRender(key, view);
1664
1678
  }
1665
1679
  // view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
1666
- // view 非 null 时,当然必须创建 Buffer
1680
+ // view 非 null 时,当然必须创建 Buffer
1667
1681
  // 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
1668
1682
  if (!localVideoBuffer.buffer) {
1669
1683
  localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
@@ -1742,7 +1756,7 @@ class TRTCCloud extends events_1.EventEmitter {
1742
1756
  this._initRender(key, view);
1743
1757
  }
1744
1758
  // view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
1745
- // view 非 null 时,当然必须创建 Buffer
1759
+ // view 非 null 时,当然必须创建 Buffer
1746
1760
  const videoBufferInfo = {
1747
1761
  userId: userId,
1748
1762
  buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.3.404",
3
+ "version": "10.3.405-beta.1",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",