@realsee/live 0.5.2-dev.1 → 0.5.2-dev.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.
@@ -161,6 +161,54 @@ var BuiltInRTCType;
161
161
  BuiltInRTCType["RealseeXChimeRTC"] = "chime";
162
162
  })(BuiltInRTCType || (BuiltInRTCType = {}));
163
163
 
164
+ /**
165
+ * 输出格式化日志
166
+ */
167
+ // 获取当前时间
168
+ const getTime = () => {
169
+ const date = new Date();
170
+ const year = date.getFullYear();
171
+ const month = (date.getMonth() + 1).toString().padStart(2, '0'); //月份是从0开始的
172
+ const day = date.getDate().toString().padStart(2, '0');
173
+ const hour = date.getHours().toString().padStart(2, '0');
174
+ const min = date.getMinutes().toString().padStart(2, '0');
175
+ const sec = date.getSeconds().toString().padStart(2, '0');
176
+ const ms = date.getMilliseconds();
177
+ return `[${year}-${month}-${day} ${hour}:${min}:${sec}.${ms}]`;
178
+ };
179
+ var LOG_LEVEL;
180
+ (function (LOG_LEVEL) {
181
+ LOG_LEVEL["info"] = "INFO";
182
+ LOG_LEVEL["log"] = "LOG";
183
+ LOG_LEVEL["error"] = "ERROR";
184
+ LOG_LEVEL["warn"] = "WARN";
185
+ })(LOG_LEVEL || (LOG_LEVEL = {}));
186
+ // 输出日志
187
+ const echo = (logLevel, args = []) => {
188
+ args.unshift(`Realsee Live ${getTime()} <${logLevel}> `);
189
+ switch (logLevel) {
190
+ case LOG_LEVEL.info:
191
+ return console.info(...args);
192
+ case LOG_LEVEL.error:
193
+ return console.error(...args);
194
+ case LOG_LEVEL.warn:
195
+ return console.warn(...args);
196
+ default:
197
+ return console.log(...args);
198
+ }
199
+ };
200
+ const log = (...args) => echo(LOG_LEVEL.log, args);
201
+ const info = (...args) => echo(LOG_LEVEL.info, args);
202
+ const error = (...args) => echo(LOG_LEVEL.error, args);
203
+ const warn = (...args) => echo(LOG_LEVEL.warn, args);
204
+ const logger = {
205
+ log,
206
+ info,
207
+ error,
208
+ warn,
209
+ };
210
+ var logger$1 = logger;
211
+
164
212
  // uuid
165
213
  function S4() {
166
214
  return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
@@ -288,7 +336,10 @@ class BrowserRTC extends CoreRTC {
288
336
  navigator.mediaDevices
289
337
  .getUserMedia(rule)
290
338
  .then(() => resolve(true))
291
- .catch(() => resolve(false));
339
+ .catch((e) => {
340
+ logger$1.error(e.message);
341
+ resolve(false);
342
+ });
292
343
  }
293
344
  catch (e) {
294
345
  console.error(e);
@@ -603,6 +654,9 @@ var RTCJoinedInfoCodeEnum;
603
654
  })(RTCJoinedInfoCodeEnum || (RTCJoinedInfoCodeEnum = {}));
604
655
 
605
656
  class VRWebViewRTC extends CoreRTC {
657
+ get jsBridge() {
658
+ return this.options.jsBridge;
659
+ }
606
660
  constructor({ jsBridge, getVoiceSign }) {
607
661
  super();
608
662
  this.type = RTCType.RealseeVRWebViewRTC;
@@ -621,9 +675,6 @@ class VRWebViewRTC extends CoreRTC {
621
675
  this.emit('weakNetwork');
622
676
  });
623
677
  }
624
- get jsBridge() {
625
- return this.options.jsBridge;
626
- }
627
678
  join(options) {
628
679
  return __awaiter(this, void 0, void 0, function* () {
629
680
  try {
@@ -976,7 +1027,7 @@ exports.default = LogLevel;
976
1027
 
977
1028
  var LogLevel = /*@__PURE__*/getDefaultExportFromCjs(LogLevel_1);
978
1029
 
979
- function appendUri(uri, query) {
1030
+ function appendUri(uri, query = {}) {
980
1031
  const hasQuery = uri.indexOf('?') !== -1;
981
1032
  const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
982
1033
  return uri + newQuery;
@@ -1114,66 +1165,21 @@ function objEqualDeep(value, other) {
1114
1165
  * @param options 可选参数,可选项:`deep` 是否深比较。
1115
1166
  * @returns {boolean} 是否相等。
1116
1167
  */
1117
- function equal(value, other, opt) {
1168
+ function equal(value, other, opt = { deep: false }) {
1118
1169
  if (!opt.deep)
1119
1170
  return isShallowEqual(value, other);
1120
1171
  return isDeepEqual(value, other);
1121
1172
  }
1122
1173
 
1123
- /**
1124
- * 输出格式化日志
1125
- */
1126
- // 获取当前时间
1127
- const getTime = () => {
1128
- const date = new Date();
1129
- const year = date.getFullYear();
1130
- const month = (date.getMonth() + 1).toString().padStart(2, '0'); //月份是从0开始的
1131
- const day = date.getDate().toString().padStart(2, '0');
1132
- const hour = date.getHours().toString().padStart(2, '0');
1133
- const min = date.getMinutes().toString().padStart(2, '0');
1134
- const sec = date.getSeconds().toString().padStart(2, '0');
1135
- const ms = date.getMilliseconds();
1136
- return `[${year}-${month}-${day} ${hour}:${min}:${sec}.${ms}]`;
1137
- };
1138
- var LOG_LEVEL;
1139
- (function (LOG_LEVEL) {
1140
- LOG_LEVEL["info"] = "INFO";
1141
- LOG_LEVEL["log"] = "LOG";
1142
- LOG_LEVEL["error"] = "ERROR";
1143
- LOG_LEVEL["warn"] = "WARN";
1144
- })(LOG_LEVEL || (LOG_LEVEL = {}));
1145
- // 输出日志
1146
- const echo = (logLevel, args = []) => {
1147
- args.unshift(`Realsee Live ${getTime()} <${logLevel}> `);
1148
- switch (logLevel) {
1149
- case LOG_LEVEL.info:
1150
- return console.info(...args);
1151
- case LOG_LEVEL.error:
1152
- return console.error(...args);
1153
- case LOG_LEVEL.warn:
1154
- return console.warn(...args);
1155
- default:
1156
- return console.log(...args);
1157
- }
1158
- };
1159
- const log = (...args) => echo(LOG_LEVEL.log, args);
1160
- const info = (...args) => echo(LOG_LEVEL.info, args);
1161
- const error = (...args) => echo(LOG_LEVEL.error, args);
1162
- const warn = (...args) => echo(LOG_LEVEL.warn, args);
1163
- const logger = {
1164
- log,
1165
- info,
1166
- error,
1167
- warn,
1168
- };
1169
- var logger$1 = logger;
1170
-
1171
1174
  /**
1172
1175
  * 具有鲁棒性的WebSocket封装
1173
1176
  * 1、自动重连
1174
1177
  * 2、可根据网络情况进行重连
1175
1178
  */
1176
1179
  class RobustWebSocket extends Subscribe {
1180
+ get attempts() {
1181
+ return this._attempts;
1182
+ }
1177
1183
  constructor(options) {
1178
1184
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1179
1185
  super();
@@ -1421,9 +1427,6 @@ class RobustWebSocket extends Subscribe {
1421
1427
  }
1422
1428
  this._startHealthCheck();
1423
1429
  }
1424
- get attempts() {
1425
- return this._attempts;
1426
- }
1427
1430
  setOptions(options) {
1428
1431
  if (!options)
1429
1432
  return;
@@ -1465,6 +1468,14 @@ class RobustWebSocket extends Subscribe {
1465
1468
  }
1466
1469
 
1467
1470
  class LiveController extends Subscribe {
1471
+ set state(state) {
1472
+ const prevState = JSON.parse(JSON.stringify(this._state));
1473
+ this._state = state;
1474
+ this.emit('stateChange', this.state, prevState);
1475
+ }
1476
+ get state() {
1477
+ return this._state;
1478
+ }
1468
1479
  constructor() {
1469
1480
  super();
1470
1481
  /**
@@ -1594,14 +1605,6 @@ class LiveController extends Subscribe {
1594
1605
  });
1595
1606
  this._addWebSocketEventListeners();
1596
1607
  }
1597
- set state(state) {
1598
- const prevState = JSON.parse(JSON.stringify(this._state));
1599
- this._state = state;
1600
- this.emit('stateChange', this.state, prevState);
1601
- }
1602
- get state() {
1603
- return this._state;
1604
- }
1605
1608
  /**
1606
1609
  * 发送数据
1607
1610
  * @param data
@@ -1633,6 +1636,65 @@ const _clearLiveInstanceIfNeed = () => {
1633
1636
  }
1634
1637
  };
1635
1638
  class Live extends Subscribe {
1639
+ get options() {
1640
+ return Object.freeze(this._options || {});
1641
+ }
1642
+ /**
1643
+ * 带看状态
1644
+ */
1645
+ get state() {
1646
+ return this._controller.state;
1647
+ }
1648
+ /**
1649
+ * 兼容老逻辑
1650
+ * @deprecated 请直接读取 state 属性字段,未来将移除该属性
1651
+ */
1652
+ get readyState() {
1653
+ return this._controller.state;
1654
+ }
1655
+ /**
1656
+ * 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
1657
+ * @deprecated 带看不需要关注底层ws的相关信息,未来将移除
1658
+ */
1659
+ get url() {
1660
+ return this.options.url;
1661
+ }
1662
+ /**
1663
+ * 获取当前live使用的RTC实例
1664
+ */
1665
+ get $RTC() {
1666
+ return this._options.rtc;
1667
+ }
1668
+ /**
1669
+ * 获取当前live使用的jsBridge实例
1670
+ */
1671
+ get jsBridge() {
1672
+ return this._options.jsBridge;
1673
+ }
1674
+ /**
1675
+ * 当前帧数据快照
1676
+ */
1677
+ get snapshot() {
1678
+ return this._buildInData.keyframes;
1679
+ }
1680
+ /**
1681
+ * 当前用户信息
1682
+ */
1683
+ get selfInfo() {
1684
+ return this._buildInData.selfInfo;
1685
+ }
1686
+ /**
1687
+ * 当前用户列表
1688
+ */
1689
+ get userList() {
1690
+ return this._buildInData.userList || [];
1691
+ }
1692
+ /**
1693
+ * 当前带看房间信息
1694
+ */
1695
+ get roomInfo() {
1696
+ return this._buildInData.roomInfo;
1697
+ }
1636
1698
  constructor(opts) {
1637
1699
  var _a;
1638
1700
  super();
@@ -2103,65 +2165,6 @@ class Live extends Subscribe {
2103
2165
  Object.assign(window, { $liveController: this._controller, $live: this });
2104
2166
  }
2105
2167
  }
2106
- get options() {
2107
- return Object.freeze(this._options || {});
2108
- }
2109
- /**
2110
- * 带看状态
2111
- */
2112
- get state() {
2113
- return this._controller.state;
2114
- }
2115
- /**
2116
- * 兼容老逻辑
2117
- * @deprecated 请直接读取 state 属性字段,未来将移除该属性
2118
- */
2119
- get readyState() {
2120
- return this._controller.state;
2121
- }
2122
- /**
2123
- * 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
2124
- * @deprecated 带看不需要关注底层ws的相关信息,未来将移除
2125
- */
2126
- get url() {
2127
- return this.options.url;
2128
- }
2129
- /**
2130
- * 获取当前live使用的RTC实例
2131
- */
2132
- get $RTC() {
2133
- return this._options.rtc;
2134
- }
2135
- /**
2136
- * 获取当前live使用的jsBridge实例
2137
- */
2138
- get jsBridge() {
2139
- return this._options.jsBridge;
2140
- }
2141
- /**
2142
- * 当前帧数据快照
2143
- */
2144
- get snapshot() {
2145
- return this._buildInData.keyframes;
2146
- }
2147
- /**
2148
- * 当前用户信息
2149
- */
2150
- get selfInfo() {
2151
- return this._buildInData.selfInfo;
2152
- }
2153
- /**
2154
- * 当前用户列表
2155
- */
2156
- get userList() {
2157
- return this._buildInData.userList || [];
2158
- }
2159
- /**
2160
- * 当前带看房间信息
2161
- */
2162
- get roomInfo() {
2163
- return this._buildInData.roomInfo;
2164
- }
2165
2168
  /**
2166
2169
  * 修改状态
2167
2170
  * @param evtType