agora-electron-sdk 4.3.2 → 4.4.0-dev.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.
Files changed (100) hide show
  1. package/gulpfile.js +3 -1
  2. package/js/AgoraSdk.js +4 -4
  3. package/js/Private/AgoraBase.js +367 -326
  4. package/js/Private/AgoraMediaBase.js +265 -76
  5. package/js/Private/AgoraMediaPlayerTypes.js +12 -30
  6. package/js/Private/IAgoraH265Transcoder.js +2 -5
  7. package/js/Private/IAgoraLog.js +2 -5
  8. package/js/Private/IAgoraMediaEngine.js +2 -5
  9. package/js/Private/IAgoraMediaPlayer.js +4 -10
  10. package/js/Private/IAgoraMediaRecorder.js +2 -5
  11. package/js/Private/IAgoraMediaStreamingSource.js +2 -5
  12. package/js/Private/IAgoraMusicContentCenter.js +21 -68
  13. package/js/Private/IAgoraRhythmPlayer.js +2 -5
  14. package/js/Private/IAgoraRtcEngine.js +76 -130
  15. package/js/Private/IAgoraRtcEngineEx.js +5 -28
  16. package/js/Private/IAgoraSpatialAudio.js +6 -15
  17. package/js/Private/IAudioDeviceManager.js +2 -5
  18. package/js/Private/impl/AgoraMediaBaseImpl.js +11 -14
  19. package/js/Private/impl/IAgoraH265TranscoderImpl.js +43 -46
  20. package/js/Private/impl/IAgoraMediaEngineImpl.js +155 -172
  21. package/js/Private/impl/IAgoraMediaPlayerImpl.js +534 -546
  22. package/js/Private/impl/IAgoraMediaRecorderImpl.js +26 -29
  23. package/js/Private/impl/IAgoraMusicContentCenterImpl.js +218 -251
  24. package/js/Private/impl/IAgoraRtcEngineExImpl.js +434 -436
  25. package/js/Private/impl/IAgoraRtcEngineImpl.js +2445 -2423
  26. package/js/Private/impl/IAgoraSpatialAudioImpl.js +167 -170
  27. package/js/Private/impl/IAudioDeviceManagerImpl.js +232 -235
  28. package/js/Private/internal/AgoraH265TranscoderInternal.js +33 -57
  29. package/js/Private/internal/AgoraMediaBaseInternal.js +9 -28
  30. package/js/Private/internal/AudioDeviceManagerInternal.js +24 -44
  31. package/js/Private/internal/IrisApiEngine.js +94 -145
  32. package/js/Private/internal/LocalSpatialAudioEngineInternal.js +3 -23
  33. package/js/Private/internal/MediaEngineInternal.js +69 -94
  34. package/js/Private/internal/MediaPlayerInternal.js +105 -125
  35. package/js/Private/internal/MediaRecorderInternal.js +37 -64
  36. package/js/Private/internal/MusicContentCenterInternal.js +92 -129
  37. package/js/Private/internal/RtcEngineExInternal.js +213 -243
  38. package/js/Private/ti/AgoraBase-ti.js +2 -2
  39. package/js/Private/ti/AgoraMediaBase-ti.js +2 -2
  40. package/js/Private/ti/AgoraMediaPlayerTypes-ti.js +1 -1
  41. package/js/Private/ti/IAgoraH265Transcoder-ti.js +2 -2
  42. package/js/Private/ti/IAgoraLog-ti.js +1 -1
  43. package/js/Private/ti/IAgoraMediaEngine-ti.js +1 -1
  44. package/js/Private/ti/IAgoraMediaPlayer-ti.js +2 -2
  45. package/js/Private/ti/IAgoraMediaPlayerSource-ti.js +2 -2
  46. package/js/Private/ti/IAgoraMediaRecorder-ti.js +1 -1
  47. package/js/Private/ti/IAgoraMediaStreamingSource-ti.js +1 -1
  48. package/js/Private/ti/IAgoraMusicContentCenter-ti.js +2 -2
  49. package/js/Private/ti/IAgoraRhythmPlayer-ti.js +1 -1
  50. package/js/Private/ti/IAgoraRtcEngine-ti.js +7 -7
  51. package/js/Private/ti/IAgoraRtcEngineEx-ti.js +1 -1
  52. package/js/Private/ti/IAgoraSpatialAudio-ti.js +1 -1
  53. package/js/Private/ti/IAudioDeviceManager-ti.js +1 -1
  54. package/js/Renderer/AgoraView.js +100 -145
  55. package/js/Renderer/IRenderer.js +43 -53
  56. package/js/Renderer/IRendererManager.js +106 -132
  57. package/js/Renderer/RendererCache.js +63 -96
  58. package/js/Renderer/RendererManager.js +35 -69
  59. package/js/Renderer/WebGLRenderer/index.js +77 -106
  60. package/js/Renderer/YUVCanvasRenderer/index.js +18 -40
  61. package/js/Utils.js +45 -64
  62. package/package.json +9 -7
  63. package/scripts/checkElectron.js +41 -0
  64. package/scripts/downloadPrebuild.js +56 -24
  65. package/scripts/synclib.js +6 -6
  66. package/ts/Private/AgoraBase.ts +269 -4
  67. package/ts/Private/AgoraMediaBase.ts +343 -1
  68. package/ts/Private/IAgoraMediaEngine.ts +3 -3
  69. package/ts/Private/IAgoraRtcEngine.ts +130 -119
  70. package/ts/Private/IAgoraRtcEngineEx.ts +14 -9
  71. package/ts/Private/impl/IAgoraRtcEngineExImpl.ts +30 -0
  72. package/ts/Private/impl/IAgoraRtcEngineImpl.ts +181 -61
  73. package/ts/Private/internal/IrisApiEngine.ts +3 -7
  74. package/ts/Private/internal/MediaEngineInternal.ts +0 -1
  75. package/ts/Private/internal/RtcEngineExInternal.ts +8 -4
  76. package/ts/Private/ti/IAgoraRtcEngine-ti.ts +5 -5
  77. package/ts/Renderer/IRenderer.ts +1 -2
  78. package/ts/Renderer/IRendererManager.ts +21 -12
  79. package/ts/Utils.ts +15 -0
  80. package/types/Private/AgoraBase.d.ts +264 -8
  81. package/types/Private/AgoraBase.d.ts.map +1 -1
  82. package/types/Private/AgoraMediaBase.d.ts +336 -1
  83. package/types/Private/AgoraMediaBase.d.ts.map +1 -1
  84. package/types/Private/IAgoraMediaEngine.d.ts +3 -3
  85. package/types/Private/IAgoraRtcEngine.d.ts +106 -116
  86. package/types/Private/IAgoraRtcEngine.d.ts.map +1 -1
  87. package/types/Private/IAgoraRtcEngineEx.d.ts +10 -10
  88. package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -1
  89. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts +3 -1
  90. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -1
  91. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +13 -5
  92. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -1
  93. package/types/Private/internal/IrisApiEngine.d.ts.map +1 -1
  94. package/types/Private/internal/MediaEngineInternal.d.ts.map +1 -1
  95. package/types/Private/internal/RtcEngineExInternal.d.ts +1 -0
  96. package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -1
  97. package/types/Renderer/IRenderer.d.ts.map +1 -1
  98. package/types/Renderer/IRendererManager.d.ts.map +1 -1
  99. package/types/Utils.d.ts +4 -0
  100. package/types/Utils.d.ts.map +1 -1
@@ -27,14 +27,14 @@ exports.IAudioEncodedFrameObserver = void 0;
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IAudioEncodedFrameObserver = t.iface([], {
33
33
  "onRecordAudioEncodedFrame": t.opt(t.func("void", t.param("frameBuffer", "Uint8Array"), t.param("length", "number"), t.param("audioEncodedFrameInfo", "EncodedAudioFrameInfo"))),
34
34
  "onPlaybackAudioEncodedFrame": t.opt(t.func("void", t.param("frameBuffer", "Uint8Array"), t.param("length", "number"), t.param("audioEncodedFrameInfo", "EncodedAudioFrameInfo"))),
35
35
  "onMixedAudioEncodedFrame": t.opt(t.func("void", t.param("frameBuffer", "Uint8Array"), t.param("length", "number"), t.param("audioEncodedFrameInfo", "EncodedAudioFrameInfo"))),
36
36
  });
37
- var exportedTypeSuite = {
37
+ const exportedTypeSuite = {
38
38
  IAudioEncodedFrameObserver: exports.IAudioEncodedFrameObserver,
39
39
  };
40
40
  exports.default = exportedTypeSuite;
@@ -27,7 +27,7 @@ exports.IMediaRecorderObserver = exports.IFaceInfoObserver = exports.IVideoFrame
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IAudioPcmFrameSink = t.iface([], {
33
33
  "onFrame": t.opt(t.func("void", t.param("frame", "AudioPcmFrame"))),
@@ -62,7 +62,7 @@ exports.IMediaRecorderObserver = t.iface([], {
62
62
  "onRecorderStateChanged": t.opt(t.func("void", t.param("channelId", "string"), t.param("uid", "number"), t.param("state", "RecorderState"), t.param("reason", "RecorderReasonCode"))),
63
63
  "onRecorderInfoUpdated": t.opt(t.func("void", t.param("channelId", "string"), t.param("uid", "number"), t.param("info", "RecorderInfo"))),
64
64
  });
65
- var exportedTypeSuite = {
65
+ const exportedTypeSuite = {
66
66
  IAudioPcmFrameSink: exports.IAudioPcmFrameSink,
67
67
  IAudioFrameObserverBase: exports.IAudioFrameObserverBase,
68
68
  IAudioFrameObserver: exports.IAudioFrameObserver,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -27,14 +27,14 @@ exports.IH265TranscoderObserver = void 0;
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IH265TranscoderObserver = t.iface([], {
33
33
  "onEnableTranscode": t.opt(t.func("void", t.param("result", "H265TranscodeResult"))),
34
34
  "onQueryChannel": t.opt(t.func("void", t.param("result", "H265TranscodeResult"), t.param("originChannel", "string"), t.param("transcodeChannel", "string"))),
35
35
  "onTriggerTranscode": t.opt(t.func("void", t.param("result", "H265TranscodeResult"))),
36
36
  });
37
- var exportedTypeSuite = {
37
+ const exportedTypeSuite = {
38
38
  IH265TranscoderObserver: exports.IH265TranscoderObserver,
39
39
  };
40
40
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -27,12 +27,12 @@ exports.IMediaPlayerVideoFrameObserver = void 0;
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IMediaPlayerVideoFrameObserver = t.iface([], {
33
33
  "onFrame": t.opt(t.func("void", t.param("frame", "VideoFrame"))),
34
34
  });
35
- var exportedTypeSuite = {
35
+ const exportedTypeSuite = {
36
36
  IMediaPlayerVideoFrameObserver: exports.IMediaPlayerVideoFrameObserver,
37
37
  };
38
38
  exports.default = exportedTypeSuite;
@@ -27,7 +27,7 @@ exports.IMediaPlayerSourceObserver = void 0;
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IMediaPlayerSourceObserver = t.iface([], {
33
33
  "onPlayerSourceStateChanged": t.opt(t.func("void", t.param("state", "MediaPlayerState"), t.param("reason", "MediaPlayerReason"))),
@@ -44,7 +44,7 @@ exports.IMediaPlayerSourceObserver = t.iface([], {
44
44
  "onPlayerPlaybackStats": t.opt(t.func("void", t.param("stats", "PlayerPlaybackStats"))),
45
45
  "onAudioVolumeIndication": t.opt(t.func("void", t.param("volume", "number"))),
46
46
  });
47
- var exportedTypeSuite = {
47
+ const exportedTypeSuite = {
48
48
  IMediaPlayerSourceObserver: exports.IMediaPlayerSourceObserver,
49
49
  };
50
50
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -27,7 +27,7 @@ exports.IMusicContentCenterEventHandler = void 0;
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IMusicContentCenterEventHandler = t.iface([], {
33
33
  "onMusicChartsResult": t.opt(t.func("void", t.param("requestId", "string"), t.param("result", t.array("MusicChartInfo")), t.param("reason", "MusicContentCenterStateReason"))),
@@ -36,7 +36,7 @@ exports.IMusicContentCenterEventHandler = t.iface([], {
36
36
  "onSongSimpleInfoResult": t.opt(t.func("void", t.param("requestId", "string"), t.param("songCode", "number"), t.param("simpleInfo", "string"), t.param("reason", "MusicContentCenterStateReason"))),
37
37
  "onPreLoadEvent": t.opt(t.func("void", t.param("requestId", "string"), t.param("songCode", "number"), t.param("percent", "number"), t.param("lyricUrl", "string"), t.param("state", "PreloadState"), t.param("reason", "MusicContentCenterStateReason"))),
38
38
  });
39
- var exportedTypeSuite = {
39
+ const exportedTypeSuite = {
40
40
  IMusicContentCenterEventHandler: exports.IMusicContentCenterEventHandler,
41
41
  };
42
42
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -27,7 +27,7 @@ exports.IDirectCdnStreamingEventHandler = exports.IMetadataObserver = exports.IR
27
27
  /**
28
28
  * This module was automatically generated by `ts-interface-builder`
29
29
  */
30
- var t = __importStar(require("ts-interface-checker"));
30
+ const t = __importStar(require("ts-interface-checker"));
31
31
  // tslint:disable:object-literal-key-quotes
32
32
  exports.IRtcEngineEventHandler = t.iface([], {
33
33
  "onJoinChannelSuccess": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("elapsed", "number"))),
@@ -65,7 +65,7 @@ exports.IRtcEngineEventHandler = t.iface([], {
65
65
  "onUserEnableLocalVideo": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("remoteUid", "number"), t.param("enabled", "boolean"))),
66
66
  "onRemoteAudioStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "RemoteAudioStats"))),
67
67
  "onLocalAudioStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "LocalAudioStats"))),
68
- "onLocalVideoStats": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("stats", "LocalVideoStats"))),
68
+ "onLocalVideoStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "LocalVideoStats"))),
69
69
  "onRemoteVideoStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "RemoteVideoStats"))),
70
70
  "onCameraReady": t.opt(t.func("void")),
71
71
  "onCameraFocusAreaChanged": t.opt(t.func("void", t.param("x", "number"), t.param("y", "number"), t.param("width", "number"), t.param("height", "number"))),
@@ -120,10 +120,10 @@ exports.IRtcEngineEventHandler = t.iface([], {
120
120
  "onVideoPublishStateChanged": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("channel", "string"), t.param("oldState", "StreamPublishState"), t.param("newState", "StreamPublishState"), t.param("elapseSinceLastState", "number"))),
121
121
  "onTranscodedStreamLayoutInfo": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("uid", "number"), t.param("width", "number"), t.param("height", "number"), t.param("layoutCount", "number"), t.param("layoutlist", t.array("VideoLayout")))),
122
122
  "onAudioMetadataReceived": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("uid", "number"), t.param("metadata", "string"), t.param("length", "number"))),
123
- "onExtensionEvent": t.opt(t.func("void", t.param("provider", "string"), t.param("extension", "string"), t.param("key", "string"), t.param("value", "string"))),
124
- "onExtensionStarted": t.opt(t.func("void", t.param("provider", "string"), t.param("extension", "string"))),
125
- "onExtensionStopped": t.opt(t.func("void", t.param("provider", "string"), t.param("extension", "string"))),
126
- "onExtensionError": t.opt(t.func("void", t.param("provider", "string"), t.param("extension", "string"), t.param("error", "number"), t.param("message", "string"))),
123
+ "onExtensionEventWithContext": t.opt(t.func("void", t.param("context", "ExtensionContext"), t.param("key", "string"), t.param("value", "string"))),
124
+ "onExtensionStartedWithContext": t.opt(t.func("void", t.param("context", "ExtensionContext"))),
125
+ "onExtensionStoppedWithContext": t.opt(t.func("void", t.param("context", "ExtensionContext"))),
126
+ "onExtensionErrorWithContext": t.opt(t.func("void", t.param("context", "ExtensionContext"), t.param("error", "number"), t.param("message", "string"))),
127
127
  "onSetRtmFlagResult": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("code", "number"))),
128
128
  });
129
129
  exports.IMetadataObserver = t.iface([], {
@@ -133,7 +133,7 @@ exports.IDirectCdnStreamingEventHandler = t.iface([], {
133
133
  "onDirectCdnStreamingStateChanged": t.opt(t.func("void", t.param("state", "DirectCdnStreamingState"), t.param("reason", "DirectCdnStreamingReason"), t.param("message", "string"))),
134
134
  "onDirectCdnStreamingStats": t.opt(t.func("void", t.param("stats", "DirectCdnStreamingStats"))),
135
135
  });
136
- var exportedTypeSuite = {
136
+ const exportedTypeSuite = {
137
137
  IRtcEngineEventHandler: exports.IRtcEngineEventHandler,
138
138
  IMetadataObserver: exports.IMetadataObserver,
139
139
  IDirectCdnStreamingEventHandler: exports.IDirectCdnStreamingEventHandler,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // tslint:disable:object-literal-key-quotes
4
- var exportedTypeSuite = {};
4
+ const exportedTypeSuite = {};
5
5
  exports.default = exportedTypeSuite;
@@ -1,168 +1,124 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var AgoraBase_1 = require("../Private/AgoraBase");
19
- var AgoraMediaBase_1 = require("../Private/AgoraMediaBase");
20
- var Utils_1 = require("../Utils");
21
- var VIDEO_SOURCE_TYPE_STRING = 'video-source-type';
22
- var UID_STRING = 'uid';
23
- var CHANNEL_ID_STRING = 'channel-id';
24
- var RENDERER_CONTENT_MODE_STRING = 'renderer-content-mode';
25
- var RENDERER_MIRROR_STRING = 'renderer-mirror';
26
- var observedAttributes = [
3
+ const AgoraBase_1 = require("../Private/AgoraBase");
4
+ const AgoraMediaBase_1 = require("../Private/AgoraMediaBase");
5
+ const Utils_1 = require("../Utils");
6
+ const VIDEO_SOURCE_TYPE_STRING = 'video-source-type';
7
+ const UID_STRING = 'uid';
8
+ const CHANNEL_ID_STRING = 'channel-id';
9
+ const RENDERER_CONTENT_MODE_STRING = 'renderer-content-mode';
10
+ const RENDERER_MIRROR_STRING = 'renderer-mirror';
11
+ const observedAttributes = [
27
12
  VIDEO_SOURCE_TYPE_STRING,
28
13
  UID_STRING,
29
14
  CHANNEL_ID_STRING,
30
15
  RENDERER_CONTENT_MODE_STRING,
31
16
  RENDERER_MIRROR_STRING,
32
17
  ];
33
- var AgoraView = /** @class */ (function (_super) {
34
- __extends(AgoraView, _super);
35
- function AgoraView() {
36
- var _this = _super.call(this) || this;
37
- _this.isConnectedCallback = false;
38
- _this.initializeRender = function () {
39
- var _a;
40
- var _b = _this, channelId = _b.channelId, uid = _b.uid, sourceType = _b.sourceType, renderMode = _b.renderMode, renderMirror = _b.renderMirror;
41
- (_a = Utils_1.AgoraEnv.AgoraRendererManager) === null || _a === void 0 ? void 0 : _a.addOrRemoveRenderer({
42
- sourceType: sourceType,
43
- view: _this,
44
- uid: uid,
45
- channelId: channelId,
46
- renderMode: renderMode,
18
+ class AgoraView extends HTMLElement {
19
+ static get observedAttributes() {
20
+ return observedAttributes;
21
+ }
22
+ get sourceType() {
23
+ const number = Number(this.getAttribute(VIDEO_SOURCE_TYPE_STRING));
24
+ return isNaN(number) ? 0 : number;
25
+ }
26
+ set sourceType(val) {
27
+ if (val) {
28
+ this.setAttribute(VIDEO_SOURCE_TYPE_STRING, String(val));
29
+ }
30
+ else {
31
+ this.removeAttribute(VIDEO_SOURCE_TYPE_STRING);
32
+ }
33
+ }
34
+ get uid() {
35
+ const number = Number(this.getAttribute(UID_STRING));
36
+ return isNaN(number) ? 0 : number;
37
+ }
38
+ set uid(val) {
39
+ if (val) {
40
+ this.setAttribute(UID_STRING, String(val));
41
+ }
42
+ else {
43
+ this.removeAttribute(UID_STRING);
44
+ }
45
+ }
46
+ get channelId() {
47
+ return this.getAttribute(CHANNEL_ID_STRING) || '';
48
+ }
49
+ set channelId(val) {
50
+ if (val) {
51
+ this.setAttribute(CHANNEL_ID_STRING, val);
52
+ }
53
+ else {
54
+ this.removeAttribute(CHANNEL_ID_STRING);
55
+ }
56
+ }
57
+ get renderMode() {
58
+ const number = Number(this.getAttribute(RENDERER_CONTENT_MODE_STRING) ||
59
+ AgoraMediaBase_1.RenderModeType.RenderModeFit);
60
+ return isNaN(number) ? AgoraMediaBase_1.RenderModeType.RenderModeFit : number;
61
+ }
62
+ set renderMode(val) {
63
+ if (val) {
64
+ this.setAttribute(RENDERER_CONTENT_MODE_STRING, String(val));
65
+ }
66
+ else {
67
+ this.removeAttribute(RENDERER_CONTENT_MODE_STRING);
68
+ }
69
+ }
70
+ get renderMirror() {
71
+ return this.getAttribute(RENDERER_MIRROR_STRING) === 'true';
72
+ }
73
+ set renderMirror(val) {
74
+ if (val) {
75
+ this.setAttribute(RENDERER_MIRROR_STRING, String(val));
76
+ }
77
+ else {
78
+ this.removeAttribute(RENDERER_MIRROR_STRING);
79
+ }
80
+ }
81
+ constructor() {
82
+ super();
83
+ this.isConnectedCallback = false;
84
+ this.initializeRender = () => {
85
+ const { channelId, uid, sourceType, renderMode, renderMirror } = this;
86
+ Utils_1.AgoraEnv.AgoraRendererManager?.addOrRemoveRenderer({
87
+ sourceType,
88
+ view: this,
89
+ uid,
90
+ channelId,
91
+ renderMode,
47
92
  mirrorMode: renderMirror
48
93
  ? AgoraBase_1.VideoMirrorModeType.VideoMirrorModeEnabled
49
94
  : AgoraBase_1.VideoMirrorModeType.VideoMirrorModeDisabled,
50
95
  setupMode: AgoraBase_1.VideoViewSetupMode.VideoViewSetupReplace,
51
96
  });
52
97
  };
53
- _this.destroyRender = function () {
54
- var _a;
55
- var _b = _this, channelId = _b.channelId, uid = _b.uid, sourceType = _b.sourceType;
56
- (_a = Utils_1.AgoraEnv.AgoraRendererManager) === null || _a === void 0 ? void 0 : _a.removeRendererFromCache({
57
- channelId: channelId,
58
- uid: uid,
59
- sourceType: sourceType,
60
- view: _this,
98
+ this.destroyRender = () => {
99
+ const { channelId, uid, sourceType } = this;
100
+ Utils_1.AgoraEnv.AgoraRendererManager?.removeRendererFromCache({
101
+ channelId,
102
+ uid,
103
+ sourceType,
104
+ view: this,
61
105
  });
62
106
  };
63
- return _this;
64
107
  }
65
- Object.defineProperty(AgoraView, "observedAttributes", {
66
- get: function () {
67
- return observedAttributes;
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- Object.defineProperty(AgoraView.prototype, "sourceType", {
73
- get: function () {
74
- var number = Number(this.getAttribute(VIDEO_SOURCE_TYPE_STRING));
75
- return isNaN(number) ? 0 : number;
76
- },
77
- set: function (val) {
78
- if (val) {
79
- this.setAttribute(VIDEO_SOURCE_TYPE_STRING, String(val));
80
- }
81
- else {
82
- this.removeAttribute(VIDEO_SOURCE_TYPE_STRING);
83
- }
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(AgoraView.prototype, "uid", {
89
- get: function () {
90
- var number = Number(this.getAttribute(UID_STRING));
91
- return isNaN(number) ? 0 : number;
92
- },
93
- set: function (val) {
94
- if (val) {
95
- this.setAttribute(UID_STRING, String(val));
96
- }
97
- else {
98
- this.removeAttribute(UID_STRING);
99
- }
100
- },
101
- enumerable: false,
102
- configurable: true
103
- });
104
- Object.defineProperty(AgoraView.prototype, "channelId", {
105
- get: function () {
106
- return this.getAttribute(CHANNEL_ID_STRING) || '';
107
- },
108
- set: function (val) {
109
- if (val) {
110
- this.setAttribute(CHANNEL_ID_STRING, val);
111
- }
112
- else {
113
- this.removeAttribute(CHANNEL_ID_STRING);
114
- }
115
- },
116
- enumerable: false,
117
- configurable: true
118
- });
119
- Object.defineProperty(AgoraView.prototype, "renderMode", {
120
- get: function () {
121
- var number = Number(this.getAttribute(RENDERER_CONTENT_MODE_STRING) ||
122
- AgoraMediaBase_1.RenderModeType.RenderModeFit);
123
- return isNaN(number) ? AgoraMediaBase_1.RenderModeType.RenderModeFit : number;
124
- },
125
- set: function (val) {
126
- if (val) {
127
- this.setAttribute(RENDERER_CONTENT_MODE_STRING, String(val));
128
- }
129
- else {
130
- this.removeAttribute(RENDERER_CONTENT_MODE_STRING);
131
- }
132
- },
133
- enumerable: false,
134
- configurable: true
135
- });
136
- Object.defineProperty(AgoraView.prototype, "renderMirror", {
137
- get: function () {
138
- return this.getAttribute(RENDERER_MIRROR_STRING) === 'true';
139
- },
140
- set: function (val) {
141
- if (val) {
142
- this.setAttribute(RENDERER_MIRROR_STRING, String(val));
143
- }
144
- else {
145
- this.removeAttribute(RENDERER_MIRROR_STRING);
146
- }
147
- },
148
- enumerable: false,
149
- configurable: true
150
- });
151
- AgoraView.prototype.connectedCallback = function () {
108
+ connectedCallback() {
152
109
  this.isConnectedCallback = true;
153
110
  this.initializeRender();
154
- };
155
- AgoraView.prototype.attributeChangedCallback = function (attrName, oldVal, newVal) {
156
- var _a;
111
+ }
112
+ attributeChangedCallback(attrName, oldVal, newVal) {
157
113
  if (!this.isConnectedCallback) {
158
114
  return;
159
115
  }
160
- var isSetRenderOption = [
116
+ const isSetRenderOption = [
161
117
  RENDERER_CONTENT_MODE_STRING,
162
118
  RENDERER_MIRROR_STRING,
163
119
  ].includes(attrName);
164
120
  if (isSetRenderOption) {
165
- (_a = Utils_1.AgoraEnv.AgoraRendererManager) === null || _a === void 0 ? void 0 : _a.setRendererContext({
121
+ Utils_1.AgoraEnv.AgoraRendererManager?.setRendererContext({
166
122
  view: this,
167
123
  renderMode: this.renderMode,
168
124
  mirrorMode: this.renderMirror
@@ -171,17 +127,16 @@ var AgoraView = /** @class */ (function (_super) {
171
127
  });
172
128
  return;
173
129
  }
174
- var isNeedReInitialize = observedAttributes.includes(attrName);
130
+ const isNeedReInitialize = observedAttributes.includes(attrName);
175
131
  if (!isNeedReInitialize) {
176
132
  return;
177
133
  }
178
134
  this.initializeRender();
179
- };
180
- AgoraView.prototype.disconnectedCallback = function () {
135
+ }
136
+ disconnectedCallback() {
181
137
  this.isConnectedCallback = false;
182
138
  this.destroyRender();
183
- };
184
- return AgoraView;
185
- }(HTMLElement));
139
+ }
140
+ }
186
141
  exports.default = AgoraView;
187
142
  window.customElements.define('agora-view', AgoraView);