@realsee/live 0.4.0-alpha.2 → 0.4.0-alpha.5
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/README.md +52 -54
- package/dist/realsee-live.cjs.development.js +88 -2859
- package/dist/realsee-live.cjs.development.js.map +1 -1
- package/dist/realsee-live.cjs.production.js +1 -1
- package/dist/realsee-live.cjs.production.js.map +1 -1
- package/dist/realsee-live.esm.js +52 -2825
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +2100 -651
- package/dist/realsee-live.umd.development.js.map +1 -1
- package/dist/realsee-live.umd.production.js +1 -1
- package/dist/realsee-live.umd.production.js.map +1 -1
- package/dist/typings/live/Live.d.ts +6 -1
- package/dist/typings/live/LiveOptions.d.ts +14 -1
- package/dist/typings/react/LiveReact.d.ts +2 -0
- package/dist/typings/rtc/type.d.ts +4 -0
- package/package.json +5 -5
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RealseeLive = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const EVENT_SYMBOL = Symbol('$$REALSEE_LIVE_EVENT$$');
|
|
8
|
-
function __generateEventIfNotExisted(instance) {
|
|
9
|
-
if (!instance[EVENT_SYMBOL]) {
|
|
10
|
-
instance[EVENT_SYMBOL] = {};
|
|
7
|
+
const EVENT_SYMBOL$1 = Symbol('$$REALSEE_LIVE_EVENT$$');
|
|
8
|
+
function __generateEventIfNotExisted$1(instance) {
|
|
9
|
+
if (!instance[EVENT_SYMBOL$1]) {
|
|
10
|
+
instance[EVENT_SYMBOL$1] = {};
|
|
11
11
|
}
|
|
12
|
-
return instance[EVENT_SYMBOL];
|
|
12
|
+
return instance[EVENT_SYMBOL$1];
|
|
13
13
|
}
|
|
14
|
-
function __removeEventIfNotExisted(instance) {
|
|
15
|
-
if (!instance[EVENT_SYMBOL]) {
|
|
16
|
-
delete instance[EVENT_SYMBOL];
|
|
14
|
+
function __removeEventIfNotExisted$1(instance) {
|
|
15
|
+
if (!instance[EVENT_SYMBOL$1]) {
|
|
16
|
+
delete instance[EVENT_SYMBOL$1];
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
* }>()
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
class Subscribe {
|
|
30
|
+
class Subscribe$1 {
|
|
31
31
|
/**
|
|
32
32
|
* 判断是否注册了事件
|
|
33
33
|
* @param name 事件类型
|
|
34
34
|
*/
|
|
35
35
|
hasListener(name) {
|
|
36
|
-
const events = __generateEventIfNotExisted(this);
|
|
36
|
+
const events = __generateEventIfNotExisted$1(this);
|
|
37
37
|
return events && events[name] && events[name].length > 0;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @template C 回调函数函数上下文
|
|
47
47
|
*/
|
|
48
48
|
on(name, callback, once) {
|
|
49
|
-
const events = __generateEventIfNotExisted(this);
|
|
49
|
+
const events = __generateEventIfNotExisted$1(this);
|
|
50
50
|
if (!events[name])
|
|
51
51
|
events[name] = [];
|
|
52
52
|
events[name].push([callback, once || false]);
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
*/
|
|
75
75
|
off(name, callback) {
|
|
76
76
|
if (name === undefined) {
|
|
77
|
-
__removeEventIfNotExisted(this);
|
|
77
|
+
__removeEventIfNotExisted$1(this);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
const events = __generateEventIfNotExisted(this);
|
|
80
|
+
const events = __generateEventIfNotExisted$1(this);
|
|
81
81
|
if (!events[name])
|
|
82
82
|
events[name] = [];
|
|
83
83
|
if (callback === undefined) {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
*/
|
|
103
103
|
emit(name, ...data) {
|
|
104
104
|
let canceled = false;
|
|
105
|
-
const events = __generateEventIfNotExisted(this);
|
|
105
|
+
const events = __generateEventIfNotExisted$1(this);
|
|
106
106
|
const event = events[name] || [];
|
|
107
107
|
for (let one of event.slice()) {
|
|
108
108
|
const [callback, once = false] = one;
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
/**
|
|
120
120
|
* rtc 基础抽象类
|
|
121
121
|
*/
|
|
122
|
-
class CoreRTC extends Subscribe {
|
|
122
|
+
class CoreRTC extends Subscribe$1 {
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -158,29 +158,34 @@
|
|
|
158
158
|
RTCType["RealseeBrowserRTC"] = "RealseeBrowserRTC";
|
|
159
159
|
RTCType["RealseeVRWebViewRTC"] = "RealseeVRWebViewRTC";
|
|
160
160
|
RTCType["RealseeBrowserChimeRTC"] = "RealseeBrowserChimeRTC";
|
|
161
|
-
})(exports.RTCType || (exports.RTCType = {}));
|
|
161
|
+
})(exports.RTCType || (exports.RTCType = {}));
|
|
162
|
+
exports.BuiltInRTCType = void 0;
|
|
163
|
+
(function (BuiltInRTCType) {
|
|
164
|
+
BuiltInRTCType["RealseeXTRTC"] = "trtc";
|
|
165
|
+
BuiltInRTCType["RealseeXChimeRTC"] = "chime";
|
|
166
|
+
})(exports.BuiltInRTCType || (exports.BuiltInRTCType = {}));
|
|
162
167
|
|
|
163
168
|
// uuid
|
|
164
|
-
function S4() {
|
|
169
|
+
function S4$1() {
|
|
165
170
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
166
171
|
}
|
|
167
172
|
/**
|
|
168
173
|
* 基于伪随机数生成 **uuid**。
|
|
169
174
|
*/
|
|
170
|
-
function uuid() {
|
|
175
|
+
function uuid$1() {
|
|
171
176
|
// then to call it, plus stitch in '4' in the third group
|
|
172
|
-
return (S4() +
|
|
173
|
-
S4() +
|
|
177
|
+
return (S4$1() +
|
|
178
|
+
S4$1() +
|
|
174
179
|
'-' +
|
|
175
|
-
S4() +
|
|
180
|
+
S4$1() +
|
|
176
181
|
'-4' +
|
|
177
|
-
S4().substr(0, 3) +
|
|
182
|
+
S4$1().substr(0, 3) +
|
|
178
183
|
'-' +
|
|
179
|
-
S4() +
|
|
184
|
+
S4$1() +
|
|
180
185
|
'-' +
|
|
181
|
-
S4() +
|
|
182
|
-
S4() +
|
|
183
|
-
S4()).toLowerCase();
|
|
186
|
+
S4$1() +
|
|
187
|
+
S4$1() +
|
|
188
|
+
S4$1()).toLowerCase();
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
class BrowserRTC extends CoreRTC {
|
|
@@ -265,7 +270,7 @@
|
|
|
265
270
|
this._initParentDom();
|
|
266
271
|
}
|
|
267
272
|
_initParentDom() {
|
|
268
|
-
this.$dom.id = `rs-rtc-${uuid()}`;
|
|
273
|
+
this.$dom.id = `rs-rtc-${uuid$1()}`;
|
|
269
274
|
this.$dom.style.display = 'none';
|
|
270
275
|
document.body.appendChild(this.$dom);
|
|
271
276
|
}
|
|
@@ -10658,7 +10663,7 @@
|
|
|
10658
10663
|
: part2 < 128 ? 9 : 10;
|
|
10659
10664
|
};
|
|
10660
10665
|
|
|
10661
|
-
var require$$0$
|
|
10666
|
+
var require$$0$6 = aspromise;
|
|
10662
10667
|
|
|
10663
10668
|
var require$$1$3 = base64_1;
|
|
10664
10669
|
|
|
@@ -10678,7 +10683,7 @@
|
|
|
10678
10683
|
var util = exports;
|
|
10679
10684
|
|
|
10680
10685
|
// used to return a Promise where callback is omitted
|
|
10681
|
-
util.asPromise = require$$0$
|
|
10686
|
+
util.asPromise = require$$0$6;
|
|
10682
10687
|
|
|
10683
10688
|
// converts to / from base64 encoded strings
|
|
10684
10689
|
util.base64 = require$$1$3;
|
|
@@ -11549,13 +11554,13 @@
|
|
|
11549
11554
|
BufferWriter$1 = BufferWriter_;
|
|
11550
11555
|
};
|
|
11551
11556
|
|
|
11552
|
-
var require$$0$
|
|
11557
|
+
var require$$0$5 = writer;
|
|
11553
11558
|
|
|
11554
11559
|
var writer_buffer = BufferWriter;
|
|
11555
11560
|
|
|
11556
11561
|
// extends Writer
|
|
11557
11562
|
|
|
11558
|
-
(BufferWriter.prototype = Object.create(require$$0$
|
|
11563
|
+
(BufferWriter.prototype = Object.create(require$$0$5.prototype)).constructor = BufferWriter;
|
|
11559
11564
|
|
|
11560
11565
|
|
|
11561
11566
|
|
|
@@ -11568,7 +11573,7 @@
|
|
|
11568
11573
|
* @constructor
|
|
11569
11574
|
*/
|
|
11570
11575
|
function BufferWriter() {
|
|
11571
|
-
require$$0$
|
|
11576
|
+
require$$0$5.call(this);
|
|
11572
11577
|
}
|
|
11573
11578
|
|
|
11574
11579
|
/**
|
|
@@ -12210,7 +12215,7 @@
|
|
|
12210
12215
|
return this;
|
|
12211
12216
|
};
|
|
12212
12217
|
|
|
12213
|
-
var require$$0$
|
|
12218
|
+
var require$$0$4 = service;
|
|
12214
12219
|
|
|
12215
12220
|
var rpc_1 = createCommonjsModule(function (module, exports) {
|
|
12216
12221
|
|
|
@@ -12247,7 +12252,7 @@
|
|
|
12247
12252
|
* @returns {undefined}
|
|
12248
12253
|
*/
|
|
12249
12254
|
|
|
12250
|
-
rpc.Service = require$$0$
|
|
12255
|
+
rpc.Service = require$$0$4;
|
|
12251
12256
|
});
|
|
12252
12257
|
|
|
12253
12258
|
var roots = {};
|
|
@@ -12272,7 +12277,7 @@
|
|
|
12272
12277
|
protobuf.build = "minimal";
|
|
12273
12278
|
|
|
12274
12279
|
// Serialization
|
|
12275
|
-
protobuf.Writer = require$$0$
|
|
12280
|
+
protobuf.Writer = require$$0$5;
|
|
12276
12281
|
protobuf.BufferWriter = require$$1$2;
|
|
12277
12282
|
protobuf.Reader = require$$2;
|
|
12278
12283
|
protobuf.BufferReader = require$$3;
|
|
@@ -12298,9 +12303,9 @@
|
|
|
12298
12303
|
configure();
|
|
12299
12304
|
});
|
|
12300
12305
|
|
|
12301
|
-
var require$$0$
|
|
12306
|
+
var require$$0$3 = indexMinimal;
|
|
12302
12307
|
|
|
12303
|
-
var minimal = require$$0$
|
|
12308
|
+
var minimal = require$$0$3;
|
|
12304
12309
|
|
|
12305
12310
|
var $protobuf = minimal;
|
|
12306
12311
|
|
|
@@ -31104,7 +31109,7 @@
|
|
|
31104
31109
|
//Z_NULL: null // Use -1 or null inline, depending on var type
|
|
31105
31110
|
};
|
|
31106
31111
|
|
|
31107
|
-
var require$$0$
|
|
31112
|
+
var require$$0$2 = trees;
|
|
31108
31113
|
|
|
31109
31114
|
var adler32 = adler32_1;
|
|
31110
31115
|
|
|
@@ -31133,7 +31138,7 @@
|
|
|
31133
31138
|
// misrepresented as being the original software.
|
|
31134
31139
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
31135
31140
|
|
|
31136
|
-
const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = require$$0$
|
|
31141
|
+
const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = require$$0$2;
|
|
31137
31142
|
|
|
31138
31143
|
|
|
31139
31144
|
|
|
@@ -36365,11 +36370,11 @@
|
|
|
36365
36370
|
constants: constants
|
|
36366
36371
|
};
|
|
36367
36372
|
|
|
36368
|
-
var require$$0 = deflate_1$1;
|
|
36373
|
+
var require$$0$1 = deflate_1$1;
|
|
36369
36374
|
|
|
36370
36375
|
var require$$1$1 = inflate_1$1;
|
|
36371
36376
|
|
|
36372
|
-
const { Deflate, deflate, deflateRaw, gzip } = require$$0;
|
|
36377
|
+
const { Deflate, deflate, deflateRaw, gzip } = require$$0$1;
|
|
36373
36378
|
|
|
36374
36379
|
const { Inflate, inflate, inflateRaw, ungzip } = require$$1$1;
|
|
36375
36380
|
|
|
@@ -48210,8 +48215,8 @@
|
|
|
48210
48215
|
* 对audio标签初始化
|
|
48211
48216
|
*/
|
|
48212
48217
|
this._initDom = () => {
|
|
48213
|
-
this.$audio.id = `rs-rtc-${uuid()}`;
|
|
48214
|
-
this.$dom.id = `rs-rtc-${uuid()}`;
|
|
48218
|
+
this.$audio.id = `rs-rtc-${uuid$1()}`;
|
|
48219
|
+
this.$dom.id = `rs-rtc-${uuid$1()}`;
|
|
48215
48220
|
this.$dom.appendChild(this.$audio);
|
|
48216
48221
|
document.body.appendChild(this.$dom);
|
|
48217
48222
|
};
|
|
@@ -48774,12 +48779,1741 @@
|
|
|
48774
48779
|
return exports.WebSocketCloseError.Err_unknown;
|
|
48775
48780
|
}
|
|
48776
48781
|
|
|
48782
|
+
const cache = {};
|
|
48783
|
+
/**
|
|
48784
|
+
* 创建一个唯一的函数名(在当前页面会话中保障其唯一性即可)。
|
|
48785
|
+
* @param extra 可以额外自定义部分字符串。
|
|
48786
|
+
* @returns
|
|
48787
|
+
*/
|
|
48788
|
+
function registerGlobalValue(scheme, callback, once = true) {
|
|
48789
|
+
if (!cache[scheme]) {
|
|
48790
|
+
const uuid = '$jsBridgeFn_' + Date.now().toString(16).toUpperCase() + '_' + Math.ceil(Math.random() * 10000).toString(16).toUpperCase();
|
|
48791
|
+
cache[scheme] = {
|
|
48792
|
+
uuid,
|
|
48793
|
+
queue: [{ once, callback }],
|
|
48794
|
+
};
|
|
48795
|
+
}
|
|
48796
|
+
else {
|
|
48797
|
+
cache[scheme].queue.push({ once, callback });
|
|
48798
|
+
}
|
|
48799
|
+
Object.assign(window, {
|
|
48800
|
+
[cache[scheme].uuid]: (data) => {
|
|
48801
|
+
cache[scheme].queue = cache[scheme].queue.reduce((accu, curr) => {
|
|
48802
|
+
const { once, callback } = curr;
|
|
48803
|
+
if (!once) {
|
|
48804
|
+
accu.push(curr);
|
|
48805
|
+
}
|
|
48806
|
+
callback(data);
|
|
48807
|
+
return accu;
|
|
48808
|
+
}, []);
|
|
48809
|
+
}
|
|
48810
|
+
});
|
|
48811
|
+
return cache[scheme].uuid;
|
|
48812
|
+
}
|
|
48813
|
+
|
|
48814
|
+
class BaseController {
|
|
48815
|
+
checkReady(timeout) {
|
|
48816
|
+
return Promise.resolve([false, null]);
|
|
48817
|
+
}
|
|
48818
|
+
callAndBackfeed(scheme) {
|
|
48819
|
+
return Promise.resolve([false, null]);
|
|
48820
|
+
}
|
|
48821
|
+
callAndListen(scheme, callback) {
|
|
48822
|
+
return Promise.resolve([false, null]);
|
|
48823
|
+
}
|
|
48824
|
+
}
|
|
48825
|
+
|
|
48826
|
+
const HYBRID_BRIDGE_NAME = 'HybridBridgeLJ';
|
|
48827
|
+
const $window$1 = window;
|
|
48828
|
+
/**
|
|
48829
|
+
* Android WebView 控件。
|
|
48830
|
+
*/
|
|
48831
|
+
class WebViewController extends BaseController {
|
|
48832
|
+
constructor() {
|
|
48833
|
+
super();
|
|
48834
|
+
Promise.resolve().then(async () => {
|
|
48835
|
+
try {
|
|
48836
|
+
await this.checkBridgeReady();
|
|
48837
|
+
}
|
|
48838
|
+
catch (error) {
|
|
48839
|
+
console.warn(error);
|
|
48840
|
+
}
|
|
48841
|
+
});
|
|
48842
|
+
}
|
|
48843
|
+
/**
|
|
48844
|
+
* 检查 HybridBridgeLJ 是否ready
|
|
48845
|
+
* @param timeout 超时时间
|
|
48846
|
+
* @returns
|
|
48847
|
+
*/
|
|
48848
|
+
checkBridgeReady(timeout = 6000) {
|
|
48849
|
+
if (this.hybridBridge)
|
|
48850
|
+
return true;
|
|
48851
|
+
const start = performance.now();
|
|
48852
|
+
return new Promise((resolve, reject) => {
|
|
48853
|
+
const check = () => {
|
|
48854
|
+
if (this.hybridBridge)
|
|
48855
|
+
return resolve(true);
|
|
48856
|
+
if ($window$1.HybridBridgeLJ) {
|
|
48857
|
+
const hybridBridge = $window$1[HYBRID_BRIDGE_NAME];
|
|
48858
|
+
hybridBridge === null || hybridBridge === void 0 ? void 0 : hybridBridge.getStaticData(registerGlobalValue('HYBRID_BRIDGE_NAME', (data) => {
|
|
48859
|
+
this.deviceInfo = JSON.parse(data);
|
|
48860
|
+
this.hybridBridge = hybridBridge;
|
|
48861
|
+
return resolve(true);
|
|
48862
|
+
}));
|
|
48863
|
+
}
|
|
48864
|
+
if (performance.now() - start > (timeout || 6000)) {
|
|
48865
|
+
// console.warn('HybridBridge 初始化超时~')
|
|
48866
|
+
return reject(new Error('HybridBridge 初始化超时~'));
|
|
48867
|
+
}
|
|
48868
|
+
// 逐帧监测
|
|
48869
|
+
requestAnimationFrame(check);
|
|
48870
|
+
};
|
|
48871
|
+
// 开启监测
|
|
48872
|
+
check();
|
|
48873
|
+
});
|
|
48874
|
+
}
|
|
48875
|
+
async checkReady(timeout = 6000) {
|
|
48876
|
+
const res = [null, null];
|
|
48877
|
+
if (this.hybridBridge) {
|
|
48878
|
+
res[0] = true;
|
|
48879
|
+
return res;
|
|
48880
|
+
}
|
|
48881
|
+
try {
|
|
48882
|
+
res[0] = await this.checkBridgeReady(timeout);
|
|
48883
|
+
}
|
|
48884
|
+
catch (error) {
|
|
48885
|
+
res[0] = false;
|
|
48886
|
+
res[1] = error;
|
|
48887
|
+
}
|
|
48888
|
+
return res;
|
|
48889
|
+
}
|
|
48890
|
+
get ready() {
|
|
48891
|
+
return !!this.hybridBridge;
|
|
48892
|
+
}
|
|
48893
|
+
get scheme() {
|
|
48894
|
+
var _a;
|
|
48895
|
+
return ((_a = this.deviceInfo) === null || _a === void 0 ? void 0 : _a.scheme) || '';
|
|
48896
|
+
}
|
|
48897
|
+
createSchemeLink(schemeUrl) {
|
|
48898
|
+
if (schemeUrl.startsWith(this.scheme)) {
|
|
48899
|
+
return schemeUrl;
|
|
48900
|
+
}
|
|
48901
|
+
return this.scheme + '://' + schemeUrl;
|
|
48902
|
+
}
|
|
48903
|
+
async callAndBackfeed(scheme) {
|
|
48904
|
+
const res = [false, null];
|
|
48905
|
+
const [ready, readyError] = await this.checkReady();
|
|
48906
|
+
if (!ready) {
|
|
48907
|
+
res[0] = false;
|
|
48908
|
+
res[1] = readyError;
|
|
48909
|
+
return res;
|
|
48910
|
+
}
|
|
48911
|
+
return await new Promise(async (resolve) => {
|
|
48912
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
48913
|
+
const msg = JSON.stringify({
|
|
48914
|
+
actionUrl,
|
|
48915
|
+
functionName: registerGlobalValue(this.createSchemeLink(scheme), (data) => {
|
|
48916
|
+
const d = JSON.parse(data);
|
|
48917
|
+
res[0] = (() => {
|
|
48918
|
+
if (d === 1)
|
|
48919
|
+
return true;
|
|
48920
|
+
if (d === 0)
|
|
48921
|
+
return false;
|
|
48922
|
+
return d;
|
|
48923
|
+
})();
|
|
48924
|
+
resolve(res);
|
|
48925
|
+
}),
|
|
48926
|
+
});
|
|
48927
|
+
this.hybridBridge.callAndBackfeed(msg);
|
|
48928
|
+
});
|
|
48929
|
+
}
|
|
48930
|
+
async callAndListen(scheme, callback) {
|
|
48931
|
+
const res = [false, null];
|
|
48932
|
+
const [ready, readyError] = await this.checkReady();
|
|
48933
|
+
if (!ready) {
|
|
48934
|
+
res[0] = false;
|
|
48935
|
+
res[1] = readyError;
|
|
48936
|
+
return res;
|
|
48937
|
+
}
|
|
48938
|
+
return await new Promise(async (resolve) => {
|
|
48939
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
48940
|
+
const _callback = (data) => {
|
|
48941
|
+
const d = JSON.parse(data);
|
|
48942
|
+
const callbackParam = (() => {
|
|
48943
|
+
if (d === 1)
|
|
48944
|
+
return true;
|
|
48945
|
+
if (d === 0)
|
|
48946
|
+
return false;
|
|
48947
|
+
return d;
|
|
48948
|
+
})();
|
|
48949
|
+
callback(callbackParam);
|
|
48950
|
+
res[0] = () => {
|
|
48951
|
+
// 清理掉当前的回调引用
|
|
48952
|
+
const callbacks = cache[actionUrl];
|
|
48953
|
+
if (!callbacks)
|
|
48954
|
+
return;
|
|
48955
|
+
const idx = callbacks.queue.findIndex((func) => func.callback === _callback);
|
|
48956
|
+
if (idx !== -1) {
|
|
48957
|
+
callbacks.queue.splice(idx, 1);
|
|
48958
|
+
}
|
|
48959
|
+
};
|
|
48960
|
+
resolve(res);
|
|
48961
|
+
};
|
|
48962
|
+
const msg = JSON.stringify({
|
|
48963
|
+
actionUrl,
|
|
48964
|
+
functionName: registerGlobalValue(actionUrl, _callback, false),
|
|
48965
|
+
});
|
|
48966
|
+
this.hybridBridge.callAndListen(msg);
|
|
48967
|
+
});
|
|
48968
|
+
}
|
|
48969
|
+
}
|
|
48970
|
+
|
|
48971
|
+
var CallTypeEnum;
|
|
48972
|
+
(function (CallTypeEnum) {
|
|
48973
|
+
CallTypeEnum["callAndBackfeed"] = "callAndBack";
|
|
48974
|
+
CallTypeEnum["callAndListen"] = "callAndListen";
|
|
48975
|
+
})(CallTypeEnum || (CallTypeEnum = {}));
|
|
48976
|
+
const $window = window;
|
|
48977
|
+
/**
|
|
48978
|
+
*
|
|
48979
|
+
* 将原本 JSBridgeApp 中的逻辑均聚合至此 Controller 实现,
|
|
48980
|
+
* 目的是规避太多的引用对象被暴露(防止因引用对象被'篡改'造成未知异常)。
|
|
48981
|
+
*
|
|
48982
|
+
*/
|
|
48983
|
+
class WKWebViewController {
|
|
48984
|
+
constructor() {
|
|
48985
|
+
this.checkBridgeReady();
|
|
48986
|
+
}
|
|
48987
|
+
checkBridgeReady(timeout = 6000) {
|
|
48988
|
+
if (this.worker)
|
|
48989
|
+
return true;
|
|
48990
|
+
const start = performance.now();
|
|
48991
|
+
return new Promise((resolve, reject) => {
|
|
48992
|
+
const check = () => {
|
|
48993
|
+
if (this.worker)
|
|
48994
|
+
return resolve(true);
|
|
48995
|
+
if ($window.webkit && $window.webkit.messageHandlers && $window.webkit.messageHandlers.realsee) {
|
|
48996
|
+
const worker = $window.webkit.messageHandlers.realsee;
|
|
48997
|
+
worker.postMessage(JSON.stringify({
|
|
48998
|
+
type: 'getStaticData',
|
|
48999
|
+
param: JSON.stringify({
|
|
49000
|
+
functionName: registerGlobalValue('HYBRID_BRIDGE_NAME', (data) => {
|
|
49001
|
+
this.deviceInfo = JSON.parse(data);
|
|
49002
|
+
this.worker = worker;
|
|
49003
|
+
return resolve(true);
|
|
49004
|
+
})
|
|
49005
|
+
})
|
|
49006
|
+
}));
|
|
49007
|
+
return;
|
|
49008
|
+
}
|
|
49009
|
+
if (performance.now() - start > (timeout || 6000)) {
|
|
49010
|
+
// console.warn('HybridBridge 初始化超时~')
|
|
49011
|
+
return reject(new Error('HybridBridge 初始化超时~'));
|
|
49012
|
+
}
|
|
49013
|
+
// 逐帧监测
|
|
49014
|
+
requestAnimationFrame(check);
|
|
49015
|
+
};
|
|
49016
|
+
// 开启监测
|
|
49017
|
+
check();
|
|
49018
|
+
});
|
|
49019
|
+
}
|
|
49020
|
+
async checkReady(timeout = 6000) {
|
|
49021
|
+
const res = [null, null];
|
|
49022
|
+
if (this.worker) {
|
|
49023
|
+
res[0] = true;
|
|
49024
|
+
return res;
|
|
49025
|
+
}
|
|
49026
|
+
try {
|
|
49027
|
+
res[0] = await this.checkBridgeReady(timeout);
|
|
49028
|
+
}
|
|
49029
|
+
catch (error) {
|
|
49030
|
+
res[0] = false;
|
|
49031
|
+
res[1] = error;
|
|
49032
|
+
}
|
|
49033
|
+
return res;
|
|
49034
|
+
}
|
|
49035
|
+
get ready() {
|
|
49036
|
+
return !!this.worker;
|
|
49037
|
+
}
|
|
49038
|
+
get scheme() {
|
|
49039
|
+
var _a;
|
|
49040
|
+
return ((_a = this.deviceInfo) === null || _a === void 0 ? void 0 : _a.scheme) || '';
|
|
49041
|
+
}
|
|
49042
|
+
createSchemeLink(schemeUrl) {
|
|
49043
|
+
if (schemeUrl.startsWith(this.scheme)) {
|
|
49044
|
+
return schemeUrl;
|
|
49045
|
+
}
|
|
49046
|
+
return this.scheme + '://' + schemeUrl;
|
|
49047
|
+
}
|
|
49048
|
+
async callAndBackfeed(scheme) {
|
|
49049
|
+
const res = [false, null];
|
|
49050
|
+
const [ready, readyError] = await this.checkReady();
|
|
49051
|
+
if (!ready) {
|
|
49052
|
+
res[0] = false;
|
|
49053
|
+
res[1] = readyError;
|
|
49054
|
+
return res;
|
|
49055
|
+
}
|
|
49056
|
+
return await new Promise(async (resolve) => {
|
|
49057
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
49058
|
+
const msg = JSON.stringify({
|
|
49059
|
+
actionUrl,
|
|
49060
|
+
functionName: registerGlobalValue(this.createSchemeLink(scheme), (data) => {
|
|
49061
|
+
const d = JSON.parse(data);
|
|
49062
|
+
res[0] = (() => {
|
|
49063
|
+
if (d === 1)
|
|
49064
|
+
return true;
|
|
49065
|
+
if (d === 0)
|
|
49066
|
+
return false;
|
|
49067
|
+
return d;
|
|
49068
|
+
})();
|
|
49069
|
+
resolve(res);
|
|
49070
|
+
})
|
|
49071
|
+
});
|
|
49072
|
+
this.worker.postMessage(JSON.stringify({
|
|
49073
|
+
type: 'callAndBackfeed',
|
|
49074
|
+
param: msg
|
|
49075
|
+
}));
|
|
49076
|
+
});
|
|
49077
|
+
}
|
|
49078
|
+
async callAndListen(scheme, callback) {
|
|
49079
|
+
const res = [false, null];
|
|
49080
|
+
const [ready, readyError] = await this.checkReady();
|
|
49081
|
+
if (!ready) {
|
|
49082
|
+
res[0] = false;
|
|
49083
|
+
res[1] = readyError;
|
|
49084
|
+
return res;
|
|
49085
|
+
}
|
|
49086
|
+
return await new Promise(async (resolve) => {
|
|
49087
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
49088
|
+
const _callback = (data) => {
|
|
49089
|
+
const d = JSON.parse(data);
|
|
49090
|
+
const callbackParam = (() => {
|
|
49091
|
+
if (d === 1)
|
|
49092
|
+
return true;
|
|
49093
|
+
if (d === 0)
|
|
49094
|
+
return false;
|
|
49095
|
+
return d;
|
|
49096
|
+
})();
|
|
49097
|
+
callback(callbackParam);
|
|
49098
|
+
res[0] = () => {
|
|
49099
|
+
// 清理掉当前的回调引用
|
|
49100
|
+
const callbacks = cache[actionUrl];
|
|
49101
|
+
if (!callbacks)
|
|
49102
|
+
return;
|
|
49103
|
+
const idx = callbacks.queue.findIndex((func) => func.callback === _callback);
|
|
49104
|
+
if (idx !== -1) {
|
|
49105
|
+
callbacks.queue.splice(idx, 1);
|
|
49106
|
+
}
|
|
49107
|
+
};
|
|
49108
|
+
resolve(res);
|
|
49109
|
+
};
|
|
49110
|
+
const msg = JSON.stringify({
|
|
49111
|
+
actionUrl,
|
|
49112
|
+
functionName: registerGlobalValue(actionUrl, _callback, false)
|
|
49113
|
+
});
|
|
49114
|
+
this.worker.postMessage(JSON.stringify({
|
|
49115
|
+
type: 'callAndListen',
|
|
49116
|
+
param: msg,
|
|
49117
|
+
}));
|
|
49118
|
+
});
|
|
49119
|
+
}
|
|
49120
|
+
}
|
|
49121
|
+
|
|
49122
|
+
// uuid
|
|
49123
|
+
function S4() {
|
|
49124
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
49125
|
+
}
|
|
49126
|
+
/**
|
|
49127
|
+
* 随机生成一个uuid值
|
|
49128
|
+
*/
|
|
49129
|
+
function uuid() {
|
|
49130
|
+
// then to call it, plus stitch in '4' in the third group
|
|
49131
|
+
return (S4() + S4() + '-' + S4() + '-4' + S4().substr(0, 3) +
|
|
49132
|
+
'-' + S4() + '-' + S4() + S4() + S4()).toLowerCase();
|
|
49133
|
+
}
|
|
49134
|
+
|
|
49135
|
+
/**
|
|
49136
|
+
* 事件消息
|
|
49137
|
+
*/
|
|
49138
|
+
var WeappBridgeMessage;
|
|
49139
|
+
(function (WeappBridgeMessage) {
|
|
49140
|
+
WeappBridgeMessage["isReady"] = "Are You OK?";
|
|
49141
|
+
WeappBridgeMessage["ready"] = "I`m OK!";
|
|
49142
|
+
WeappBridgeMessage["ping"] = "ping";
|
|
49143
|
+
WeappBridgeMessage["pong"] = "pong";
|
|
49144
|
+
WeappBridgeMessage["alive"] = "I`m alive!";
|
|
49145
|
+
})(WeappBridgeMessage || (WeappBridgeMessage = {}));
|
|
49146
|
+
|
|
49147
|
+
/**
|
|
49148
|
+
* ws的状态
|
|
49149
|
+
* 参考https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
|
|
49150
|
+
*/
|
|
49151
|
+
var WebSocketState;
|
|
49152
|
+
(function (WebSocketState) {
|
|
49153
|
+
WebSocketState[WebSocketState["CONNECTING"] = 0] = "CONNECTING";
|
|
49154
|
+
WebSocketState[WebSocketState["OPEN"] = 1] = "OPEN";
|
|
49155
|
+
WebSocketState[WebSocketState["CLOSING"] = 2] = "CLOSING";
|
|
49156
|
+
WebSocketState[WebSocketState["CLOSED"] = 3] = "CLOSED";
|
|
49157
|
+
})(WebSocketState || (WebSocketState = {}));
|
|
49158
|
+
|
|
49159
|
+
/**
|
|
49160
|
+
* ws 关闭的原因
|
|
49161
|
+
*/
|
|
49162
|
+
const WebSocketCloseOptions = {
|
|
49163
|
+
/**
|
|
49164
|
+
* 重连关闭
|
|
49165
|
+
*/
|
|
49166
|
+
reconnect: { code: 1000, reason: 'close websocket when reconnecting' },
|
|
49167
|
+
/**
|
|
49168
|
+
* 主动关闭
|
|
49169
|
+
*/
|
|
49170
|
+
normalClosure: { code: 1000, reason: 'normal closure' },
|
|
49171
|
+
/**
|
|
49172
|
+
* 强制关闭
|
|
49173
|
+
*/
|
|
49174
|
+
forceClosure: { code: 1000, reason: 'force closure' },
|
|
49175
|
+
/**
|
|
49176
|
+
* 切换到后台,被微信杀掉,需要重连连接
|
|
49177
|
+
*/
|
|
49178
|
+
interrupted: { code: 1000, reason: 'interrupted' },
|
|
49179
|
+
/**
|
|
49180
|
+
* 服务端拒绝连接
|
|
49181
|
+
*/
|
|
49182
|
+
streamEndEncountered: { code: 1000, reason: 'stream end encountered' },
|
|
49183
|
+
/**
|
|
49184
|
+
* 丢失心跳
|
|
49185
|
+
* @deprecated
|
|
49186
|
+
*/
|
|
49187
|
+
lostHeartbeat: { code: 1000, reason: 'lost heartbeat' },
|
|
49188
|
+
};
|
|
49189
|
+
|
|
49190
|
+
const EVENT_SYMBOL = '$$REALSEE_JSBRIDGE_EVENT$$';
|
|
49191
|
+
function __generateEventIfNotExisted(instance) {
|
|
49192
|
+
if (!instance[EVENT_SYMBOL]) {
|
|
49193
|
+
instance[EVENT_SYMBOL] = {};
|
|
49194
|
+
}
|
|
49195
|
+
return instance[EVENT_SYMBOL];
|
|
49196
|
+
}
|
|
49197
|
+
function __removeEventIfNotExisted(instance) {
|
|
49198
|
+
if (!instance[EVENT_SYMBOL]) {
|
|
49199
|
+
delete instance[EVENT_SYMBOL];
|
|
49200
|
+
}
|
|
49201
|
+
}
|
|
49202
|
+
/**
|
|
49203
|
+
* 监听者模式
|
|
49204
|
+
* @template T 预设的监听回调类型
|
|
49205
|
+
* @example
|
|
49206
|
+
* ```
|
|
49207
|
+
* new Subscribe<{
|
|
49208
|
+
* "foo": [arg1: number, arg2: string],
|
|
49209
|
+
* "bar": [arg: boolean],
|
|
49210
|
+
* }>()
|
|
49211
|
+
* ```
|
|
49212
|
+
*/
|
|
49213
|
+
class Subscribe {
|
|
49214
|
+
/**
|
|
49215
|
+
* 判断是否注册了事件
|
|
49216
|
+
* @param name 事件类型
|
|
49217
|
+
*/
|
|
49218
|
+
hasListener(name) {
|
|
49219
|
+
const events = __generateEventIfNotExisted(this);
|
|
49220
|
+
return events && events[name] && events[name].length > 0;
|
|
49221
|
+
}
|
|
49222
|
+
/**
|
|
49223
|
+
* 注册事件
|
|
49224
|
+
* @param name 事件类型
|
|
49225
|
+
* @param callback 事件回调函数
|
|
49226
|
+
* @param once 是否只执行一次
|
|
49227
|
+
* @returns 解除事件
|
|
49228
|
+
* @template K 预设的监听事件名称
|
|
49229
|
+
* @template C 回调函数函数上下文
|
|
49230
|
+
*/
|
|
49231
|
+
on(name, callback, once) {
|
|
49232
|
+
const events = __generateEventIfNotExisted(this);
|
|
49233
|
+
if (!events[name])
|
|
49234
|
+
events[name] = [];
|
|
49235
|
+
events[name].push([callback, once || false]);
|
|
49236
|
+
return () => this.off(name, callback);
|
|
49237
|
+
}
|
|
49238
|
+
/**
|
|
49239
|
+
* 注册事件(是否只执行一次)
|
|
49240
|
+
* @param name 事件类型
|
|
49241
|
+
* @param callback 事件回调函数
|
|
49242
|
+
* @returns 解除事件
|
|
49243
|
+
* @template K 预设的监听事件名称
|
|
49244
|
+
* @template C 回调函数函数上下文
|
|
49245
|
+
*/
|
|
49246
|
+
once(name, callback) {
|
|
49247
|
+
return this.on(name, callback, true);
|
|
49248
|
+
}
|
|
49249
|
+
/**
|
|
49250
|
+
* 解除事件
|
|
49251
|
+
*
|
|
49252
|
+
* 如果 name 不传的话解除对应所有事件
|
|
49253
|
+
* 如果 name, callback 不传的话解除所有name的所有事件
|
|
49254
|
+
* @param name 事件类型
|
|
49255
|
+
* @param callback 事件回调函数
|
|
49256
|
+
* @template K 预设的监听事件名称
|
|
49257
|
+
*/
|
|
49258
|
+
off(name, callback) {
|
|
49259
|
+
if (name === undefined) {
|
|
49260
|
+
__removeEventIfNotExisted(this);
|
|
49261
|
+
return;
|
|
49262
|
+
}
|
|
49263
|
+
const events = __generateEventIfNotExisted(this);
|
|
49264
|
+
if (!events[name])
|
|
49265
|
+
events[name] = [];
|
|
49266
|
+
if (callback === undefined) {
|
|
49267
|
+
events[name].length = 0;
|
|
49268
|
+
return;
|
|
49269
|
+
}
|
|
49270
|
+
let index = 0;
|
|
49271
|
+
for (; index < events[name].length; index++) {
|
|
49272
|
+
if (events[name][index][0] === callback)
|
|
49273
|
+
break;
|
|
49274
|
+
}
|
|
49275
|
+
if (index < events[name].length) {
|
|
49276
|
+
events[name].splice(index, 1);
|
|
49277
|
+
}
|
|
49278
|
+
}
|
|
49279
|
+
/**
|
|
49280
|
+
* 触发事件
|
|
49281
|
+
* @param name 事件类型
|
|
49282
|
+
* @param data 触发事件的数据
|
|
49283
|
+
* @returns canceled 是否被触发取消
|
|
49284
|
+
* @template K 预设的监听事件名称
|
|
49285
|
+
*/
|
|
49286
|
+
emit(name, ...data) {
|
|
49287
|
+
let canceled = false;
|
|
49288
|
+
const events = __generateEventIfNotExisted(this);
|
|
49289
|
+
const event = events[name] || [];
|
|
49290
|
+
for (const one of event.slice()) {
|
|
49291
|
+
const [callback, once = false] = one;
|
|
49292
|
+
const result = callback(...data);
|
|
49293
|
+
if (once)
|
|
49294
|
+
this.off(name, callback);
|
|
49295
|
+
if (result === false)
|
|
49296
|
+
canceled = true;
|
|
49297
|
+
}
|
|
49298
|
+
return canceled;
|
|
49299
|
+
}
|
|
49300
|
+
}
|
|
49301
|
+
|
|
49302
|
+
/**
|
|
49303
|
+
* ws的事件
|
|
49304
|
+
*/
|
|
49305
|
+
var WebSocketEvent;
|
|
49306
|
+
(function (WebSocketEvent) {
|
|
49307
|
+
WebSocketEvent["open"] = "open";
|
|
49308
|
+
WebSocketEvent["close"] = "close";
|
|
49309
|
+
WebSocketEvent["error"] = "error";
|
|
49310
|
+
WebSocketEvent["message"] = "message";
|
|
49311
|
+
})(WebSocketEvent || (WebSocketEvent = {}));
|
|
49312
|
+
|
|
49313
|
+
class Ws4Webview extends Subscribe {
|
|
49314
|
+
constructor() {
|
|
49315
|
+
super(...arguments);
|
|
49316
|
+
this._state = null;
|
|
49317
|
+
/**
|
|
49318
|
+
* @description 注册ws接通事件回调
|
|
49319
|
+
* @param listener 事件回调函数
|
|
49320
|
+
* @param once 是否只执行一次
|
|
49321
|
+
* @returns
|
|
49322
|
+
*/
|
|
49323
|
+
this.onOpen = (listener, once) => once ? this.once(WebSocketEvent.open, listener) : this.on(WebSocketEvent.open, listener);
|
|
49324
|
+
/**
|
|
49325
|
+
* @description 注册一次ws接通事件回调
|
|
49326
|
+
* @param listener 事件回调函数
|
|
49327
|
+
*/
|
|
49328
|
+
this.onceOpen = (listener) => this.onOpen(listener, true);
|
|
49329
|
+
/**
|
|
49330
|
+
* @description 移除ws接通事件回调
|
|
49331
|
+
* @param listener 事件回调函数
|
|
49332
|
+
* @returns
|
|
49333
|
+
*/
|
|
49334
|
+
this.offOpen = (listener) => this.hasListener(WebSocketEvent.open) && this.off(WebSocketEvent.open, listener);
|
|
49335
|
+
/**
|
|
49336
|
+
* @description 注册ws消息事件回调
|
|
49337
|
+
* @param listener 事件回调函数
|
|
49338
|
+
* @param once 是否只执行一次
|
|
49339
|
+
* @returns
|
|
49340
|
+
*/
|
|
49341
|
+
this.onMessage = (listener, once) => once ? this.once(WebSocketEvent.message, listener) : this.on(WebSocketEvent.message, listener);
|
|
49342
|
+
/**
|
|
49343
|
+
* @description 注册一次ws消息事件回调
|
|
49344
|
+
* @param listener 事件回调函数
|
|
49345
|
+
*/
|
|
49346
|
+
this.onceMessage = (listener) => this.onMessage(listener, true);
|
|
49347
|
+
/**
|
|
49348
|
+
* @description 移除ws接通事件回调
|
|
49349
|
+
* @param listener 事件回调函数
|
|
49350
|
+
* @returns
|
|
49351
|
+
*/
|
|
49352
|
+
this.offMessage = (listener) => this.hasListener(WebSocketEvent.message) && this.off(WebSocketEvent.message, listener);
|
|
49353
|
+
/**
|
|
49354
|
+
* @description 注册ws错误事件回调
|
|
49355
|
+
* @param listener 事件回调函数
|
|
49356
|
+
* @param once 是否只执行一次
|
|
49357
|
+
* @returns
|
|
49358
|
+
*/
|
|
49359
|
+
this.onError = (listener, once) => once ? this.once(WebSocketEvent.error, listener) : this.on(WebSocketEvent.error, listener);
|
|
49360
|
+
/**
|
|
49361
|
+
* @description 注册一次ws消息事件回调
|
|
49362
|
+
* @param listener 事件回调函数
|
|
49363
|
+
*/
|
|
49364
|
+
this.onceError = (listener) => this.onError(listener, true);
|
|
49365
|
+
/**
|
|
49366
|
+
* @description 移除ws接通事件回调
|
|
49367
|
+
* @param listener 事件回调函数
|
|
49368
|
+
* @returns
|
|
49369
|
+
*/
|
|
49370
|
+
this.offError = (listener) => this.hasListener(WebSocketEvent.error) && this.off(WebSocketEvent.error, listener);
|
|
49371
|
+
/**
|
|
49372
|
+
* @description 注册ws错误事件回调
|
|
49373
|
+
* @param listener 事件回调函数
|
|
49374
|
+
* @param once 是否只执行一次
|
|
49375
|
+
* @returns
|
|
49376
|
+
*/
|
|
49377
|
+
this.onClose = (listener, once) => once ? this.once(WebSocketEvent.close, listener) : this.on(WebSocketEvent.close, listener);
|
|
49378
|
+
/**
|
|
49379
|
+
* @description 注册一次ws消息事件回调
|
|
49380
|
+
* @param listener 事件回调函数
|
|
49381
|
+
*/
|
|
49382
|
+
this.onceClose = (listener) => this.onClose(listener, true);
|
|
49383
|
+
/**
|
|
49384
|
+
* @description 移除ws接通事件回调
|
|
49385
|
+
* @param listener 事件回调函数
|
|
49386
|
+
* @returns
|
|
49387
|
+
*/
|
|
49388
|
+
this.offClose = (listener) => this.hasListener(WebSocketEvent.close) && this.off(WebSocketEvent.close, listener);
|
|
49389
|
+
}
|
|
49390
|
+
get readyState() {
|
|
49391
|
+
return this._state;
|
|
49392
|
+
}
|
|
49393
|
+
/**
|
|
49394
|
+
* 连接ws
|
|
49395
|
+
* @param options
|
|
49396
|
+
*/
|
|
49397
|
+
connect(options) {
|
|
49398
|
+
if (this._state === WebSocketState.CONNECTING || this._state === WebSocketState.OPEN)
|
|
49399
|
+
return Promise.reject("\u5DF2\u5B58\u5728\u4E00\u4E2A\u8FDE\u63A5\u4E2D\u6216\u6253\u5F00\u72B6\u6001\u7684websocket\u5B9E\u4F8B" /* ErrorMessage.WsAlreadyExists */);
|
|
49400
|
+
return new Promise((resolve, reject) => {
|
|
49401
|
+
const { url } = options;
|
|
49402
|
+
if (!url)
|
|
49403
|
+
throw new Error("\u975E\u6CD5\u7684websocket\u94FE\u63A5" /* ErrorMessage.WsUrlInvalid */);
|
|
49404
|
+
this._wsOptions = options;
|
|
49405
|
+
this._state = WebSocketState.CONNECTING;
|
|
49406
|
+
this._wsTask = new WebSocket(url);
|
|
49407
|
+
this.registerEventHandler();
|
|
49408
|
+
this.handleConnected();
|
|
49409
|
+
this.onceOpen(() => resolve(true));
|
|
49410
|
+
this.onceError((err) => reject(err));
|
|
49411
|
+
});
|
|
49412
|
+
}
|
|
49413
|
+
/**
|
|
49414
|
+
* 重连websocket
|
|
49415
|
+
* @returns
|
|
49416
|
+
*/
|
|
49417
|
+
async reconnect() {
|
|
49418
|
+
this.close(WebSocketCloseOptions.reconnect);
|
|
49419
|
+
if (this._wsOptions)
|
|
49420
|
+
this.connect(this._wsOptions);
|
|
49421
|
+
}
|
|
49422
|
+
/**
|
|
49423
|
+
* @description 发送消息
|
|
49424
|
+
* @param data 消息体
|
|
49425
|
+
*/
|
|
49426
|
+
send(data) {
|
|
49427
|
+
try {
|
|
49428
|
+
if (this._wsTask && this.readyState === WebSocketState.OPEN) {
|
|
49429
|
+
this._wsTask.send(data);
|
|
49430
|
+
}
|
|
49431
|
+
else if (this._wsTask && this.readyState === WebSocketState.CONNECTING) {
|
|
49432
|
+
this.once(WebSocketEvent.open, () => { var _a; return (_a = this._wsTask) === null || _a === void 0 ? void 0 : _a.send(data); });
|
|
49433
|
+
}
|
|
49434
|
+
else {
|
|
49435
|
+
this.once(WebSocketEvent.open, () => this.send(data));
|
|
49436
|
+
this.reconnect();
|
|
49437
|
+
}
|
|
49438
|
+
}
|
|
49439
|
+
catch (e) {
|
|
49440
|
+
this.once(WebSocketEvent.open, () => this.send(data));
|
|
49441
|
+
this.reconnect();
|
|
49442
|
+
}
|
|
49443
|
+
}
|
|
49444
|
+
/**
|
|
49445
|
+
* @description 手动关闭ws
|
|
49446
|
+
* @param options 关闭ws的配置参数
|
|
49447
|
+
*/
|
|
49448
|
+
close(options) {
|
|
49449
|
+
var _a;
|
|
49450
|
+
this._state = WebSocketState.CLOSING;
|
|
49451
|
+
(_a = this._wsTask) === null || _a === void 0 ? void 0 : _a.close(options.code, options.reason);
|
|
49452
|
+
}
|
|
49453
|
+
/**
|
|
49454
|
+
* 处理连接后的事件绑定
|
|
49455
|
+
*/
|
|
49456
|
+
handleConnected() {
|
|
49457
|
+
this.onceOpen(() => (this._state = WebSocketState.OPEN));
|
|
49458
|
+
this.onClose(() => (this._state = WebSocketState.CLOSED));
|
|
49459
|
+
}
|
|
49460
|
+
/**
|
|
49461
|
+
* 注册websocket事件
|
|
49462
|
+
*/
|
|
49463
|
+
registerEventHandler() {
|
|
49464
|
+
var _a, _b, _c, _d;
|
|
49465
|
+
(_a = this._wsTask) === null || _a === void 0 ? void 0 : _a.addEventListener(WebSocketEvent.open, (ev) => this.emit(WebSocketEvent.open, ev));
|
|
49466
|
+
(_b = this._wsTask) === null || _b === void 0 ? void 0 : _b.addEventListener(WebSocketEvent.message, (result) => {
|
|
49467
|
+
let data = result.data;
|
|
49468
|
+
try {
|
|
49469
|
+
if (typeof result.data === 'string') {
|
|
49470
|
+
data = JSON.parse(result.data);
|
|
49471
|
+
}
|
|
49472
|
+
}
|
|
49473
|
+
catch (e) {
|
|
49474
|
+
/** 不可序列化的数据不用处理 */
|
|
49475
|
+
}
|
|
49476
|
+
this.emit(WebSocketEvent.message, data);
|
|
49477
|
+
});
|
|
49478
|
+
(_c = this._wsTask) === null || _c === void 0 ? void 0 : _c.addEventListener(WebSocketEvent.close, (ev) => this.emit(WebSocketEvent.close, ev));
|
|
49479
|
+
(_d = this._wsTask) === null || _d === void 0 ? void 0 : _d.addEventListener(WebSocketEvent.error, (ev) => this.emit(WebSocketEvent.error, ev));
|
|
49480
|
+
}
|
|
49481
|
+
}
|
|
49482
|
+
var Ws4Webview$1 = Ws4Webview;
|
|
49483
|
+
|
|
49484
|
+
const endpoint = 'wss://ws.realsee.com';
|
|
49485
|
+
var defaultWsEndpoint = endpoint;
|
|
49486
|
+
|
|
49487
|
+
/**
|
|
49488
|
+
* 拼接ws链接
|
|
49489
|
+
* @param tpl
|
|
49490
|
+
* @param params
|
|
49491
|
+
* @returns
|
|
49492
|
+
*/
|
|
49493
|
+
const generateWssUrl = (tpl, params) => {
|
|
49494
|
+
const url = Object.keys(params).reduce((res, curr) => res.replace(`{{${curr}}}`, `${params[curr]}`), tpl);
|
|
49495
|
+
return encodeURI(url);
|
|
49496
|
+
};
|
|
49497
|
+
var generateWssUrl$1 = generateWssUrl;
|
|
49498
|
+
|
|
49499
|
+
const isValidKey = (key, object) => key in object;
|
|
49500
|
+
var isValidKey$1 = isValidKey;
|
|
49501
|
+
|
|
49502
|
+
/**
|
|
49503
|
+
* 解析参数
|
|
49504
|
+
* @param query
|
|
49505
|
+
* @returns
|
|
49506
|
+
*/
|
|
49507
|
+
const parseQuery = (query = '') => query
|
|
49508
|
+
.replace('?', '')
|
|
49509
|
+
.split('&')
|
|
49510
|
+
.map((qs) => {
|
|
49511
|
+
const [k, v] = qs.split('=');
|
|
49512
|
+
return { [k]: decodeURIComponent(v) };
|
|
49513
|
+
})
|
|
49514
|
+
.reduce((result, curr) => ({ ...result, ...curr }), {});
|
|
49515
|
+
var parseQuery$1 = parseQuery;
|
|
49516
|
+
|
|
49517
|
+
const ws = (() => new Ws4Webview$1())();
|
|
49518
|
+
class HybridBridge {
|
|
49519
|
+
constructor() {
|
|
49520
|
+
/**
|
|
49521
|
+
* @deprecated 兼容旧逻辑
|
|
49522
|
+
*/
|
|
49523
|
+
this._rsWeappBridgeMethodAdapter = {};
|
|
49524
|
+
this._forceClose = false;
|
|
49525
|
+
/**
|
|
49526
|
+
* 进行jsbridge的初始化,即打通ws通道
|
|
49527
|
+
* @param timeout 超时计时
|
|
49528
|
+
* @returns
|
|
49529
|
+
*/
|
|
49530
|
+
this.initialize = async (timeout = 6000) => {
|
|
49531
|
+
const res = [false, null];
|
|
49532
|
+
const { wssid, wstsp, wssig, wsmnt = defaultWsEndpoint, } = parseQuery$1(globalThis.location.search);
|
|
49533
|
+
if (!(wssid && wstsp && wssig && wsmnt)) {
|
|
49534
|
+
res[1] = new Error('HybridBridge 参数缺失,初始化失败~');
|
|
49535
|
+
return res;
|
|
49536
|
+
}
|
|
49537
|
+
const url = generateWssUrl$1('{{origin}}/{{endpoint}}/{{uuid}}/{{member}}/{{ak}}/{{ts}}/{{sign}}', {
|
|
49538
|
+
origin: wsmnt,
|
|
49539
|
+
endpoint: 'proxy',
|
|
49540
|
+
uuid: wssid,
|
|
49541
|
+
member: 'webview',
|
|
49542
|
+
ak: 'vr_live_miniapp',
|
|
49543
|
+
ts: wstsp,
|
|
49544
|
+
sign: wssig,
|
|
49545
|
+
});
|
|
49546
|
+
try {
|
|
49547
|
+
const result = await ws.connect({ url });
|
|
49548
|
+
if (result) {
|
|
49549
|
+
this.initBuiltInHandlers();
|
|
49550
|
+
res[0] = await this.waitReady(timeout);
|
|
49551
|
+
}
|
|
49552
|
+
else {
|
|
49553
|
+
res[1] = new Error('HybridBridge ws未连接,初始化失败~');
|
|
49554
|
+
}
|
|
49555
|
+
}
|
|
49556
|
+
catch (e) {
|
|
49557
|
+
res[1] = e;
|
|
49558
|
+
}
|
|
49559
|
+
return res;
|
|
49560
|
+
};
|
|
49561
|
+
this.getStaticData = (callbackFunctionName) => {
|
|
49562
|
+
this.callAndBackfeed(JSON.stringify({
|
|
49563
|
+
actionUrl: 'common/staticData',
|
|
49564
|
+
functionName: callbackFunctionName,
|
|
49565
|
+
}));
|
|
49566
|
+
};
|
|
49567
|
+
/**
|
|
49568
|
+
* 处理一次性执行的方法
|
|
49569
|
+
* @param msg JSON.stringify({ actionUrl: string, functionName: string })
|
|
49570
|
+
*/
|
|
49571
|
+
this.callAndBackfeed = (msg) => {
|
|
49572
|
+
const { actionUrl = '', functionName = '' } = JSON.parse(msg);
|
|
49573
|
+
if (!actionUrl)
|
|
49574
|
+
throw new Error('callAndBackfeed actionUrl is empty!');
|
|
49575
|
+
if (!functionName)
|
|
49576
|
+
throw new Error('callAndBackfeed functionName is empty!');
|
|
49577
|
+
const callback = (result) => {
|
|
49578
|
+
if (typeof globalThis[functionName] === 'function') {
|
|
49579
|
+
globalThis[functionName](result);
|
|
49580
|
+
}
|
|
49581
|
+
};
|
|
49582
|
+
this._callAndBackfeed(actionUrl, callback);
|
|
49583
|
+
};
|
|
49584
|
+
/**
|
|
49585
|
+
* 处理监听
|
|
49586
|
+
* @param msg JSON.stringify({ actionUrl: string, functionName: string })
|
|
49587
|
+
*/
|
|
49588
|
+
this.callAndListen = (msg) => {
|
|
49589
|
+
const { actionUrl, functionName } = JSON.parse(msg);
|
|
49590
|
+
if (!actionUrl)
|
|
49591
|
+
throw new Error('callAndListen actionUrl is empty!');
|
|
49592
|
+
if (!functionName)
|
|
49593
|
+
throw new Error('callAndListen functionName is empty!');
|
|
49594
|
+
const callback = (result) => {
|
|
49595
|
+
if (typeof globalThis[functionName] === 'function') {
|
|
49596
|
+
globalThis[functionName](result);
|
|
49597
|
+
}
|
|
49598
|
+
};
|
|
49599
|
+
try {
|
|
49600
|
+
this._callAndListen(actionUrl, callback);
|
|
49601
|
+
}
|
|
49602
|
+
catch (e) {
|
|
49603
|
+
console.warn(e);
|
|
49604
|
+
callback(false);
|
|
49605
|
+
}
|
|
49606
|
+
};
|
|
49607
|
+
}
|
|
49608
|
+
get isReady() {
|
|
49609
|
+
return ws.readyState === WebSocketState.OPEN;
|
|
49610
|
+
}
|
|
49611
|
+
/**
|
|
49612
|
+
* 内建的处理函数
|
|
49613
|
+
*/
|
|
49614
|
+
initBuiltInHandlers() {
|
|
49615
|
+
this._registerLifecycleHandler();
|
|
49616
|
+
this._registerHeartbeatHandler();
|
|
49617
|
+
this._registerMessageHandler();
|
|
49618
|
+
this._registerBridgeRequestHandler();
|
|
49619
|
+
this._registerReadyHandler();
|
|
49620
|
+
}
|
|
49621
|
+
/**
|
|
49622
|
+
* 注册生命周期回调
|
|
49623
|
+
*/
|
|
49624
|
+
_registerLifecycleHandler() {
|
|
49625
|
+
ws.onOpen(() => console.log('RsWeappBridge open'));
|
|
49626
|
+
ws.onClose((res) => {
|
|
49627
|
+
console.log('RsWeappBridge close');
|
|
49628
|
+
if (res.code === 1000) {
|
|
49629
|
+
switch ((res.reason + '').toLowerCase()) {
|
|
49630
|
+
case WebSocketCloseOptions.lostHeartbeat.reason: {
|
|
49631
|
+
// 心跳丢失
|
|
49632
|
+
ws.reconnect();
|
|
49633
|
+
break;
|
|
49634
|
+
}
|
|
49635
|
+
// case WebSocketCloseOptions.normalClosure.reason: // 主动关闭
|
|
49636
|
+
case WebSocketCloseOptions.interrupted.reason: // 切换到后台,被微信杀掉,需要重连连接
|
|
49637
|
+
case WebSocketCloseOptions.streamEndEncountered.reason: // 服务端拒绝连接
|
|
49638
|
+
default: {
|
|
49639
|
+
if (!this._forceClose) {
|
|
49640
|
+
ws.reconnect();
|
|
49641
|
+
}
|
|
49642
|
+
break;
|
|
49643
|
+
}
|
|
49644
|
+
}
|
|
49645
|
+
}
|
|
49646
|
+
if (res.code !== 1000 && !this._forceClose) {
|
|
49647
|
+
ws.reconnect();
|
|
49648
|
+
}
|
|
49649
|
+
if (this._forceClose)
|
|
49650
|
+
this._forceClose = false;
|
|
49651
|
+
});
|
|
49652
|
+
ws.onError((err) => console.error(err));
|
|
49653
|
+
}
|
|
49654
|
+
/**
|
|
49655
|
+
* 注册心跳的回调
|
|
49656
|
+
* @deprecated 兼容老的容器SDK
|
|
49657
|
+
*/
|
|
49658
|
+
_registerHeartbeatHandler() {
|
|
49659
|
+
// 收到ping时回复pong
|
|
49660
|
+
this._receivedMessage(WeappBridgeMessage.ping, () => ws.send(WeappBridgeMessage.pong));
|
|
49661
|
+
// 收到pong时回复ping
|
|
49662
|
+
this._receivedMessage(WeappBridgeMessage.pong, () => ws.send(WeappBridgeMessage.ping));
|
|
49663
|
+
}
|
|
49664
|
+
/**
|
|
49665
|
+
* 当收到某消息时
|
|
49666
|
+
* @param targetMessage 目标消息
|
|
49667
|
+
* @param handler 回调
|
|
49668
|
+
* @param once 是否一次性处理
|
|
49669
|
+
*/
|
|
49670
|
+
_receivedMessage(targetMessage, handler, once) {
|
|
49671
|
+
const msgHandler = (msg) => {
|
|
49672
|
+
if (msg === targetMessage) {
|
|
49673
|
+
handler();
|
|
49674
|
+
if (once) {
|
|
49675
|
+
ws.offMessage(msgHandler);
|
|
49676
|
+
}
|
|
49677
|
+
}
|
|
49678
|
+
};
|
|
49679
|
+
ws.onMessage(msgHandler);
|
|
49680
|
+
}
|
|
49681
|
+
/**
|
|
49682
|
+
* 强制关闭ws
|
|
49683
|
+
* @param options
|
|
49684
|
+
*/
|
|
49685
|
+
forceClose(options) {
|
|
49686
|
+
this._forceClose = true;
|
|
49687
|
+
ws.close(options);
|
|
49688
|
+
}
|
|
49689
|
+
/**
|
|
49690
|
+
* 注册准备就绪的回调
|
|
49691
|
+
*/
|
|
49692
|
+
_registerReadyHandler() {
|
|
49693
|
+
// 收到就绪询问时回复已就绪
|
|
49694
|
+
this._receivedMessage(WeappBridgeMessage.isReady, () => ws.send(WeappBridgeMessage.ready));
|
|
49695
|
+
}
|
|
49696
|
+
/**
|
|
49697
|
+
* 发送消息
|
|
49698
|
+
*/
|
|
49699
|
+
send(data) {
|
|
49700
|
+
ws.send(data);
|
|
49701
|
+
}
|
|
49702
|
+
/**
|
|
49703
|
+
* 等待响应
|
|
49704
|
+
* @param timeout 超时计时
|
|
49705
|
+
* @returns
|
|
49706
|
+
*/
|
|
49707
|
+
waitReady(timeout = 6000) {
|
|
49708
|
+
return new Promise((resolve, reject) => {
|
|
49709
|
+
this._receivedMessage(WeappBridgeMessage.ready, () => resolve(true));
|
|
49710
|
+
this.send(WeappBridgeMessage.isReady);
|
|
49711
|
+
setTimeout(() => reject('HybridBridge 初始化超时~'), timeout);
|
|
49712
|
+
});
|
|
49713
|
+
}
|
|
49714
|
+
/**
|
|
49715
|
+
* 注册消息投递回调
|
|
49716
|
+
* @deprecated 兼容老方法
|
|
49717
|
+
*/
|
|
49718
|
+
_registerMessageHandler() {
|
|
49719
|
+
ws.onMessage((message) => {
|
|
49720
|
+
if (typeof message === 'object') {
|
|
49721
|
+
const { id, command, data } = message;
|
|
49722
|
+
if (command === 'message' &&
|
|
49723
|
+
typeof this._rsWeappBridgeMethodAdapter.bindMessage === 'function') {
|
|
49724
|
+
this._rsWeappBridgeMethodAdapter.bindMessage({ id, data });
|
|
49725
|
+
}
|
|
49726
|
+
}
|
|
49727
|
+
});
|
|
49728
|
+
}
|
|
49729
|
+
/**
|
|
49730
|
+
* 注册bridge方法回调
|
|
49731
|
+
* @deprecated 兼容老方法
|
|
49732
|
+
*/
|
|
49733
|
+
_registerBridgeRequestHandler() {
|
|
49734
|
+
ws.onMessage(async (request) => {
|
|
49735
|
+
if (typeof request === 'object') {
|
|
49736
|
+
const { id, method, args, command } = request;
|
|
49737
|
+
if (command === 'request') {
|
|
49738
|
+
if (method) {
|
|
49739
|
+
let result = null;
|
|
49740
|
+
let error = null;
|
|
49741
|
+
let _method = null;
|
|
49742
|
+
if (typeof this._rsWeappBridgeMethodAdapter[method] === 'function') {
|
|
49743
|
+
// 优先读 _rsWeappBridgeMethodAdapter 上注册的方法
|
|
49744
|
+
_method = this._rsWeappBridgeMethodAdapter[method];
|
|
49745
|
+
}
|
|
49746
|
+
else if (globalThis && isValidKey$1(method, globalThis)) {
|
|
49747
|
+
// 再读 globalThis 下的方法
|
|
49748
|
+
_method = globalThis[method];
|
|
49749
|
+
}
|
|
49750
|
+
if (typeof _method === 'function') {
|
|
49751
|
+
try {
|
|
49752
|
+
result = await _method(args);
|
|
49753
|
+
}
|
|
49754
|
+
catch (e) {
|
|
49755
|
+
error = e.message || e;
|
|
49756
|
+
}
|
|
49757
|
+
}
|
|
49758
|
+
else {
|
|
49759
|
+
error = 'Method not implemented.';
|
|
49760
|
+
}
|
|
49761
|
+
this.send(JSON.stringify({
|
|
49762
|
+
id,
|
|
49763
|
+
method,
|
|
49764
|
+
result,
|
|
49765
|
+
error,
|
|
49766
|
+
command: 'response',
|
|
49767
|
+
}));
|
|
49768
|
+
}
|
|
49769
|
+
}
|
|
49770
|
+
}
|
|
49771
|
+
});
|
|
49772
|
+
}
|
|
49773
|
+
/**
|
|
49774
|
+
* 处理 callAndBackfeed
|
|
49775
|
+
* @param actionUrl
|
|
49776
|
+
* @param backfeed
|
|
49777
|
+
*/
|
|
49778
|
+
_callAndBackfeed(actionUrl, backfeed) {
|
|
49779
|
+
const reqId = uuid();
|
|
49780
|
+
const data = JSON.stringify({
|
|
49781
|
+
id: reqId,
|
|
49782
|
+
actionUrl,
|
|
49783
|
+
command: 'rsSchemeRequest',
|
|
49784
|
+
type: 'callAndBackfeed',
|
|
49785
|
+
});
|
|
49786
|
+
let timer = null;
|
|
49787
|
+
const callback = (message) => {
|
|
49788
|
+
const { id, result, errmsg, command } = message;
|
|
49789
|
+
if (command === 'rsSchemeResponse' && id === reqId) {
|
|
49790
|
+
ws.offMessage(callback);
|
|
49791
|
+
if (timer)
|
|
49792
|
+
clearTimeout(timer);
|
|
49793
|
+
if (errmsg) {
|
|
49794
|
+
console.warn(errmsg);
|
|
49795
|
+
backfeed(0);
|
|
49796
|
+
}
|
|
49797
|
+
else {
|
|
49798
|
+
backfeed(result);
|
|
49799
|
+
}
|
|
49800
|
+
}
|
|
49801
|
+
};
|
|
49802
|
+
ws.onMessage(callback);
|
|
49803
|
+
this.send(data);
|
|
49804
|
+
// 30s超时处理
|
|
49805
|
+
timer = globalThis.setTimeout(() => {
|
|
49806
|
+
console.warn('callAndBackfeed timeout');
|
|
49807
|
+
backfeed(0);
|
|
49808
|
+
}, 30000);
|
|
49809
|
+
}
|
|
49810
|
+
/**
|
|
49811
|
+
* 处理 _callAndListen
|
|
49812
|
+
* @param actionUrl
|
|
49813
|
+
* @param fn
|
|
49814
|
+
*/
|
|
49815
|
+
_callAndListen(actionUrl, fn) {
|
|
49816
|
+
const reqId = uuid();
|
|
49817
|
+
const data = JSON.stringify({
|
|
49818
|
+
id: reqId,
|
|
49819
|
+
actionUrl,
|
|
49820
|
+
command: 'rsSchemeRequest',
|
|
49821
|
+
type: 'callAndListen',
|
|
49822
|
+
});
|
|
49823
|
+
const callback = (message) => {
|
|
49824
|
+
const { id, result, errmsg, command } = message;
|
|
49825
|
+
if (command === 'rsSchemeResponse' && id === reqId) {
|
|
49826
|
+
if (errmsg) {
|
|
49827
|
+
console.warn(errmsg);
|
|
49828
|
+
fn(false);
|
|
49829
|
+
}
|
|
49830
|
+
else {
|
|
49831
|
+
fn(result);
|
|
49832
|
+
}
|
|
49833
|
+
}
|
|
49834
|
+
};
|
|
49835
|
+
ws.onMessage(callback);
|
|
49836
|
+
this.send(data);
|
|
49837
|
+
}
|
|
49838
|
+
/**
|
|
49839
|
+
* 执行bridge上的方法
|
|
49840
|
+
* @param method 方法名
|
|
49841
|
+
* @param args 传递的参数
|
|
49842
|
+
* @returns
|
|
49843
|
+
*/
|
|
49844
|
+
async invoke(method, args) {
|
|
49845
|
+
return new Promise((success, fail) => {
|
|
49846
|
+
const reqId = uuid();
|
|
49847
|
+
const data = JSON.stringify({
|
|
49848
|
+
id: reqId,
|
|
49849
|
+
method,
|
|
49850
|
+
args,
|
|
49851
|
+
command: 'request',
|
|
49852
|
+
});
|
|
49853
|
+
let timer = null;
|
|
49854
|
+
const callback = (message) => {
|
|
49855
|
+
const { id, result, error, command } = message;
|
|
49856
|
+
if (command === 'response' &&
|
|
49857
|
+
id === reqId &&
|
|
49858
|
+
message.method === method) {
|
|
49859
|
+
ws.offMessage(callback);
|
|
49860
|
+
if (timer)
|
|
49861
|
+
clearTimeout(timer);
|
|
49862
|
+
if (error) {
|
|
49863
|
+
fail(error);
|
|
49864
|
+
}
|
|
49865
|
+
else {
|
|
49866
|
+
success(result);
|
|
49867
|
+
}
|
|
49868
|
+
}
|
|
49869
|
+
};
|
|
49870
|
+
ws.onMessage(callback);
|
|
49871
|
+
this.send(data);
|
|
49872
|
+
// 30s超时处理
|
|
49873
|
+
timer = setTimeout(() => fail('method invoke timeout'), 30000);
|
|
49874
|
+
});
|
|
49875
|
+
}
|
|
49876
|
+
}
|
|
49877
|
+
|
|
49878
|
+
/**
|
|
49879
|
+
* Android WebView 控件。
|
|
49880
|
+
*/
|
|
49881
|
+
class WxMiniprogramController extends BaseController {
|
|
49882
|
+
constructor() {
|
|
49883
|
+
super();
|
|
49884
|
+
this.initializing = false;
|
|
49885
|
+
Promise.resolve().then(async () => {
|
|
49886
|
+
try {
|
|
49887
|
+
await this.checkBridgeReady();
|
|
49888
|
+
}
|
|
49889
|
+
catch (error) {
|
|
49890
|
+
console.warn(error);
|
|
49891
|
+
}
|
|
49892
|
+
});
|
|
49893
|
+
}
|
|
49894
|
+
checkBridgeReady(timeout = 6000) {
|
|
49895
|
+
if (this.ready)
|
|
49896
|
+
return true;
|
|
49897
|
+
return new Promise(async (resolve, reject) => {
|
|
49898
|
+
if (this.ready)
|
|
49899
|
+
return resolve(true);
|
|
49900
|
+
if (this.initializing) {
|
|
49901
|
+
// 正在初始化中的时候
|
|
49902
|
+
const check = () => {
|
|
49903
|
+
if (this.ready)
|
|
49904
|
+
return resolve(true);
|
|
49905
|
+
requestAnimationFrame(check);
|
|
49906
|
+
};
|
|
49907
|
+
check();
|
|
49908
|
+
}
|
|
49909
|
+
else {
|
|
49910
|
+
this.initializing = true;
|
|
49911
|
+
const hybridBridge = new HybridBridge();
|
|
49912
|
+
const [res, error] = await hybridBridge.initialize(timeout);
|
|
49913
|
+
if (!res || error) {
|
|
49914
|
+
throw error || new Error('HybridBridge 初始化失败~');
|
|
49915
|
+
}
|
|
49916
|
+
hybridBridge === null || hybridBridge === void 0 ? void 0 : hybridBridge.getStaticData(registerGlobalValue('HYBRID_BRIDGE_NAME', (data) => {
|
|
49917
|
+
this.deviceInfo = (() => {
|
|
49918
|
+
try {
|
|
49919
|
+
return JSON.parse(data);
|
|
49920
|
+
}
|
|
49921
|
+
catch (e) {
|
|
49922
|
+
return data;
|
|
49923
|
+
}
|
|
49924
|
+
})();
|
|
49925
|
+
this.hybridBridge = hybridBridge;
|
|
49926
|
+
this.initializing = false;
|
|
49927
|
+
return resolve(true);
|
|
49928
|
+
}));
|
|
49929
|
+
}
|
|
49930
|
+
});
|
|
49931
|
+
}
|
|
49932
|
+
async checkReady(timeout = 6000) {
|
|
49933
|
+
const res = [null, null];
|
|
49934
|
+
if (this.ready) {
|
|
49935
|
+
res[0] = true;
|
|
49936
|
+
return res;
|
|
49937
|
+
}
|
|
49938
|
+
try {
|
|
49939
|
+
res[0] = await this.checkBridgeReady(timeout);
|
|
49940
|
+
}
|
|
49941
|
+
catch (error) {
|
|
49942
|
+
res[0] = false;
|
|
49943
|
+
res[1] = error;
|
|
49944
|
+
}
|
|
49945
|
+
return res;
|
|
49946
|
+
}
|
|
49947
|
+
get ready() {
|
|
49948
|
+
var _a;
|
|
49949
|
+
return !!((_a = this.hybridBridge) === null || _a === void 0 ? void 0 : _a.isReady);
|
|
49950
|
+
}
|
|
49951
|
+
get scheme() {
|
|
49952
|
+
var _a;
|
|
49953
|
+
return ((_a = this.deviceInfo) === null || _a === void 0 ? void 0 : _a.scheme) || '';
|
|
49954
|
+
}
|
|
49955
|
+
createSchemeLink(schemeUrl) {
|
|
49956
|
+
if (schemeUrl.startsWith(this.scheme)) {
|
|
49957
|
+
return schemeUrl;
|
|
49958
|
+
}
|
|
49959
|
+
return this.scheme + '://' + schemeUrl;
|
|
49960
|
+
}
|
|
49961
|
+
async callAndBackfeed(scheme) {
|
|
49962
|
+
const res = [false, null];
|
|
49963
|
+
const [ready, readyError] = await this.checkReady();
|
|
49964
|
+
if (!ready) {
|
|
49965
|
+
res[0] = false;
|
|
49966
|
+
res[1] = readyError;
|
|
49967
|
+
return res;
|
|
49968
|
+
}
|
|
49969
|
+
return await new Promise(async (resolve) => {
|
|
49970
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
49971
|
+
const msg = JSON.stringify({
|
|
49972
|
+
actionUrl,
|
|
49973
|
+
functionName: registerGlobalValue(this.createSchemeLink(scheme), (data) => {
|
|
49974
|
+
let d = data;
|
|
49975
|
+
try {
|
|
49976
|
+
d = JSON.parse(data);
|
|
49977
|
+
}
|
|
49978
|
+
catch (e) {
|
|
49979
|
+
/** no-care */
|
|
49980
|
+
}
|
|
49981
|
+
res[0] = (() => {
|
|
49982
|
+
if (d === 1)
|
|
49983
|
+
return true;
|
|
49984
|
+
if (d === 0)
|
|
49985
|
+
return false;
|
|
49986
|
+
return d;
|
|
49987
|
+
})();
|
|
49988
|
+
resolve(res);
|
|
49989
|
+
}),
|
|
49990
|
+
});
|
|
49991
|
+
this.hybridBridge.callAndBackfeed(msg);
|
|
49992
|
+
});
|
|
49993
|
+
}
|
|
49994
|
+
async callAndListen(scheme, callback) {
|
|
49995
|
+
const res = [false, null];
|
|
49996
|
+
const [ready, readyError] = await this.checkReady();
|
|
49997
|
+
if (!ready) {
|
|
49998
|
+
res[0] = false;
|
|
49999
|
+
res[1] = readyError;
|
|
50000
|
+
return res;
|
|
50001
|
+
}
|
|
50002
|
+
return await new Promise(async (resolve) => {
|
|
50003
|
+
const actionUrl = this.createSchemeLink(scheme);
|
|
50004
|
+
const _callback = (data) => {
|
|
50005
|
+
let d = data;
|
|
50006
|
+
try {
|
|
50007
|
+
d = JSON.parse(data);
|
|
50008
|
+
}
|
|
50009
|
+
catch (e) {
|
|
50010
|
+
/** no-care */
|
|
50011
|
+
}
|
|
50012
|
+
const callbackParam = (() => {
|
|
50013
|
+
if (d === 1)
|
|
50014
|
+
return true;
|
|
50015
|
+
if (d === 0)
|
|
50016
|
+
return false;
|
|
50017
|
+
return d;
|
|
50018
|
+
})();
|
|
50019
|
+
callback(callbackParam);
|
|
50020
|
+
res[0] = () => {
|
|
50021
|
+
// 清理掉当前的回调引用
|
|
50022
|
+
const callbacks = cache[actionUrl];
|
|
50023
|
+
if (!callbacks)
|
|
50024
|
+
return;
|
|
50025
|
+
const idx = callbacks.queue.findIndex((func) => func.callback === _callback);
|
|
50026
|
+
if (idx !== -1) {
|
|
50027
|
+
callbacks.queue.splice(idx, 1);
|
|
50028
|
+
}
|
|
50029
|
+
};
|
|
50030
|
+
resolve(res);
|
|
50031
|
+
};
|
|
50032
|
+
const msg = JSON.stringify({
|
|
50033
|
+
actionUrl,
|
|
50034
|
+
functionName: registerGlobalValue(actionUrl, _callback, false),
|
|
50035
|
+
});
|
|
50036
|
+
this.hybridBridge.callAndListen(msg);
|
|
50037
|
+
});
|
|
50038
|
+
}
|
|
50039
|
+
async invoke(method, data) {
|
|
50040
|
+
var _a, _b;
|
|
50041
|
+
const [ready, readyError] = await this.checkReady();
|
|
50042
|
+
if (!ready) {
|
|
50043
|
+
throw readyError;
|
|
50044
|
+
}
|
|
50045
|
+
else {
|
|
50046
|
+
return (await ((_b = (_a = this.hybridBridge).invoke) === null || _b === void 0 ? void 0 : _b.call(_a, method, data)));
|
|
50047
|
+
}
|
|
50048
|
+
}
|
|
50049
|
+
}
|
|
50050
|
+
|
|
50051
|
+
/**
|
|
50052
|
+
* WebView 类型枚举。
|
|
50053
|
+
*/
|
|
50054
|
+
var WebViewTypeEnum;
|
|
50055
|
+
(function (WebViewTypeEnum) {
|
|
50056
|
+
/**
|
|
50057
|
+
* WebKit Android
|
|
50058
|
+
*/
|
|
50059
|
+
WebViewTypeEnum["WebView"] = "WebKit";
|
|
50060
|
+
/**
|
|
50061
|
+
* WKWebview iOS
|
|
50062
|
+
*/
|
|
50063
|
+
WebViewTypeEnum["WKWebview"] = "WKWebview";
|
|
50064
|
+
/**
|
|
50065
|
+
* UIWebview iOS
|
|
50066
|
+
*
|
|
50067
|
+
* @deprecated 性能因素被抛弃
|
|
50068
|
+
*/
|
|
50069
|
+
WebViewTypeEnum["UIWebview"] = "UIWebview";
|
|
50070
|
+
/**
|
|
50071
|
+
* Browser
|
|
50072
|
+
*
|
|
50073
|
+
* @description 浏览器
|
|
50074
|
+
*
|
|
50075
|
+
*/
|
|
50076
|
+
WebViewTypeEnum["Browser"] = "Browser";
|
|
50077
|
+
/**
|
|
50078
|
+
* WeChatMPWebView
|
|
50079
|
+
*/
|
|
50080
|
+
WebViewTypeEnum["WeChatMPWebView"] = "WxMiniProgramWebView";
|
|
50081
|
+
/**
|
|
50082
|
+
* Unsupported
|
|
50083
|
+
* @description 未支持的容器
|
|
50084
|
+
*/
|
|
50085
|
+
WebViewTypeEnum["Unsupported"] = "Unsupported";
|
|
50086
|
+
})(WebViewTypeEnum || (WebViewTypeEnum = {}));
|
|
50087
|
+
|
|
50088
|
+
/**
|
|
50089
|
+
* jsBridge 基础类
|
|
50090
|
+
*/
|
|
50091
|
+
class JSBridgeCore extends Subscribe {
|
|
50092
|
+
constructor() {
|
|
50093
|
+
super(...arguments);
|
|
50094
|
+
this.webViewType = WebViewTypeEnum.Unsupported;
|
|
50095
|
+
}
|
|
50096
|
+
}
|
|
50097
|
+
|
|
50098
|
+
const userAgent$1 = globalThis.navigator.userAgent;
|
|
50099
|
+
const isAndroid$1 = /android/gi.test(userAgent$1);
|
|
50100
|
+
const isIOS$1 = /iPhone|iPad\s+OS/gi.test(userAgent$1);
|
|
50101
|
+
const isWxMiniProgram$1 = /MicroMessenger/gi.test(userAgent$1) && /miniProgram/gi.test(userAgent$1);
|
|
50102
|
+
const isRealseeVRWebview$1 = /realsee/gi.test(userAgent$1);
|
|
50103
|
+
|
|
50104
|
+
const defaultOptions$1 = {
|
|
50105
|
+
timeout: 6000,
|
|
50106
|
+
};
|
|
50107
|
+
/**
|
|
50108
|
+
* App 客户端(iOS [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview) 或 Android [WebView](https://developer.android.google.cn/guide/webapps/webview))JSBridge。
|
|
50109
|
+
*/
|
|
50110
|
+
class JSBridgeApp extends JSBridgeCore {
|
|
50111
|
+
constructor(options = {}) {
|
|
50112
|
+
super();
|
|
50113
|
+
this.options = Object.assign(defaultOptions$1, options);
|
|
50114
|
+
if (!isRealseeVRWebview$1) {
|
|
50115
|
+
console.warn('未知容器:此版本 `jsBridge` 不支持当前 WebView 容器 ... ');
|
|
50116
|
+
}
|
|
50117
|
+
this.webViewType = (() => {
|
|
50118
|
+
if (isAndroid$1)
|
|
50119
|
+
return WebViewTypeEnum.WebView;
|
|
50120
|
+
if (isIOS$1)
|
|
50121
|
+
return WebViewTypeEnum.WKWebview;
|
|
50122
|
+
return WebViewTypeEnum.Browser;
|
|
50123
|
+
})();
|
|
50124
|
+
this._controller = (() => {
|
|
50125
|
+
if (isAndroid$1)
|
|
50126
|
+
return new WebViewController();
|
|
50127
|
+
if (isIOS$1)
|
|
50128
|
+
return new WKWebViewController();
|
|
50129
|
+
return new BaseController();
|
|
50130
|
+
})();
|
|
50131
|
+
this.callAndListen('common/webViewState', (webviewState) => {
|
|
50132
|
+
this.emit('webViewStateChange', webviewState);
|
|
50133
|
+
});
|
|
50134
|
+
this.callAndListen('common/webViewError', (errorInfo) => {
|
|
50135
|
+
this.emit('error', errorInfo);
|
|
50136
|
+
});
|
|
50137
|
+
}
|
|
50138
|
+
async ready() {
|
|
50139
|
+
return await this._controller.checkReady(this.options.timeout);
|
|
50140
|
+
}
|
|
50141
|
+
async callAndBackfeed(schemeUrl) {
|
|
50142
|
+
return await this._controller.callAndBackfeed(schemeUrl);
|
|
50143
|
+
}
|
|
50144
|
+
async callAndListen(schemeUrl, callback) {
|
|
50145
|
+
var _a;
|
|
50146
|
+
return await ((_a = this._controller) === null || _a === void 0 ? void 0 : _a.callAndListen(schemeUrl, callback));
|
|
50147
|
+
}
|
|
50148
|
+
async setLeftTopBackButton(enable) {
|
|
50149
|
+
if (this.webViewType === WebViewTypeEnum.WebView) {
|
|
50150
|
+
return [true, null];
|
|
50151
|
+
}
|
|
50152
|
+
return await this.callAndBackfeed(`common/setLeftTopBackButton?enable=${enable ? 1 : 0}`);
|
|
50153
|
+
}
|
|
50154
|
+
async getBangsHeight() {
|
|
50155
|
+
return await this.callAndBackfeed('common/getBangsHeight');
|
|
50156
|
+
}
|
|
50157
|
+
async shock(duration = 4) {
|
|
50158
|
+
return await this.callAndBackfeed(`common/shock?duration=${duration}`);
|
|
50159
|
+
}
|
|
50160
|
+
async minimize() {
|
|
50161
|
+
return await this.callAndBackfeed(`common/minimize`);
|
|
50162
|
+
}
|
|
50163
|
+
async loadProgress(progress) {
|
|
50164
|
+
progress = progress < 0 ? 0 : progress > 100 ? 100 : progress;
|
|
50165
|
+
return await this.callAndBackfeed(`common/loadProgress?progress=${progress}`);
|
|
50166
|
+
}
|
|
50167
|
+
async closeLoading() {
|
|
50168
|
+
return await this.callAndBackfeed(`common/closeLoading`);
|
|
50169
|
+
}
|
|
50170
|
+
async setOrientation(orientation) {
|
|
50171
|
+
return await this.callAndBackfeed(`common/setOrientation?orientation=${orientation}`);
|
|
50172
|
+
}
|
|
50173
|
+
async keepScreenLight(enable) {
|
|
50174
|
+
return await this.callAndBackfeed(`common/keepScreenLight?enable=${enable ? 1 : 0}`);
|
|
50175
|
+
}
|
|
50176
|
+
async closeWebView() {
|
|
50177
|
+
return await this.callAndBackfeed(`common/closeWebView`);
|
|
50178
|
+
}
|
|
50179
|
+
async openWebView(url, way) {
|
|
50180
|
+
return await this.callAndBackfeed(`common/openWebView?way=${way}&url=${encodeURIComponent(url)}`);
|
|
50181
|
+
}
|
|
50182
|
+
async saveImage2Album(base64) {
|
|
50183
|
+
return await this.callAndBackfeed(`common/saveImage2Album?base64=${base64}`);
|
|
50184
|
+
}
|
|
50185
|
+
async actionShare(shareConfig) {
|
|
50186
|
+
return await this.callAndBackfeed(`common/actionShare?json=${JSON.stringify(shareConfig)}`);
|
|
50187
|
+
}
|
|
50188
|
+
async getDeviceInfo() {
|
|
50189
|
+
return await this.callAndBackfeed(`common/getDeviceInfo`);
|
|
50190
|
+
}
|
|
50191
|
+
async getUserInfo() {
|
|
50192
|
+
return await this.callAndBackfeed(`common/getUserInfo`);
|
|
50193
|
+
}
|
|
50194
|
+
async getWebViewState() {
|
|
50195
|
+
return await this.callAndBackfeed(`common/getWebViewState`);
|
|
50196
|
+
}
|
|
50197
|
+
async login() {
|
|
50198
|
+
const res = await this.callAndBackfeed(`common/login`);
|
|
50199
|
+
if (res[0]) {
|
|
50200
|
+
return await this.getUserInfo();
|
|
50201
|
+
}
|
|
50202
|
+
return res;
|
|
50203
|
+
}
|
|
50204
|
+
async logout() {
|
|
50205
|
+
return await this.callAndBackfeed(`common/logout`);
|
|
50206
|
+
}
|
|
50207
|
+
async detectMicro() {
|
|
50208
|
+
return await this.callAndBackfeed(`common/detectMicro`);
|
|
50209
|
+
}
|
|
50210
|
+
async preload(urls) {
|
|
50211
|
+
urls = urls.map((url) => {
|
|
50212
|
+
if (url.startsWith('//')) {
|
|
50213
|
+
return 'https:' + url;
|
|
50214
|
+
}
|
|
50215
|
+
return url;
|
|
50216
|
+
});
|
|
50217
|
+
return await this.callAndBackfeed(`common/preload?urls=${JSON.stringify(urls)}`);
|
|
50218
|
+
}
|
|
50219
|
+
createCacheProxyUrl(urls) {
|
|
50220
|
+
urls = Array.isArray(urls) ? urls : [urls];
|
|
50221
|
+
const userAgent = window.navigator.userAgent;
|
|
50222
|
+
// 不支持缓存代理
|
|
50223
|
+
if (!/supportCache/i.test(userAgent)) {
|
|
50224
|
+
return urls;
|
|
50225
|
+
}
|
|
50226
|
+
const proxyCache = (url) => {
|
|
50227
|
+
if (this.webViewType === WebViewTypeEnum.WKWebview) {
|
|
50228
|
+
return url.replace(/https*:/, '').replace(/\/\//, 'realseeproxycache://');
|
|
50229
|
+
}
|
|
50230
|
+
else if (this.webViewType === WebViewTypeEnum.WebView) {
|
|
50231
|
+
return url + (url.indexOf('?') !== -1 ? '&' : '?') + 'realseeproxycache=1';
|
|
50232
|
+
}
|
|
50233
|
+
return url;
|
|
50234
|
+
};
|
|
50235
|
+
return urls.map(proxyCache);
|
|
50236
|
+
}
|
|
50237
|
+
}
|
|
50238
|
+
|
|
50239
|
+
var OpenWebViewEnum;
|
|
50240
|
+
(function (OpenWebViewEnum) {
|
|
50241
|
+
/**
|
|
50242
|
+
* 在开启的 `VRWebView` 栈中追加一个 `WebView`。
|
|
50243
|
+
*/
|
|
50244
|
+
OpenWebViewEnum["Append"] = "Append";
|
|
50245
|
+
/**
|
|
50246
|
+
* 强制 先关闭当前的 `VRWebiView` 然后开启新的 `VRWebView`。
|
|
50247
|
+
*/
|
|
50248
|
+
OpenWebViewEnum["Replace"] = "Replace";
|
|
50249
|
+
/**
|
|
50250
|
+
* 删除所有的 `VRWebView`,仅保留本次新开启的 `VRWebView`。
|
|
50251
|
+
*/
|
|
50252
|
+
OpenWebViewEnum["Single"] = "Single";
|
|
50253
|
+
})(OpenWebViewEnum || (OpenWebViewEnum = {}));
|
|
50254
|
+
|
|
50255
|
+
/**
|
|
50256
|
+
* 浏览器端的jsbridge
|
|
50257
|
+
*/
|
|
50258
|
+
class JSBridgeBrowser extends JSBridgeCore {
|
|
50259
|
+
constructor() {
|
|
50260
|
+
super(...arguments);
|
|
50261
|
+
this.webViewType = WebViewTypeEnum.Browser;
|
|
50262
|
+
}
|
|
50263
|
+
ready() {
|
|
50264
|
+
return Promise.resolve([true, null]);
|
|
50265
|
+
}
|
|
50266
|
+
callAndBackfeed(schemeUrl) {
|
|
50267
|
+
return Promise.resolve([false, null]);
|
|
50268
|
+
}
|
|
50269
|
+
callAndListen(schemeUrl, callback) {
|
|
50270
|
+
return Promise.resolve([() => void 0, null]);
|
|
50271
|
+
}
|
|
50272
|
+
loadProgress(progress) {
|
|
50273
|
+
return Promise.resolve([true, null]);
|
|
50274
|
+
}
|
|
50275
|
+
closeLoading() {
|
|
50276
|
+
return Promise.resolve([true, null]);
|
|
50277
|
+
}
|
|
50278
|
+
getDeviceInfo() {
|
|
50279
|
+
return Promise.resolve([false, null]);
|
|
50280
|
+
}
|
|
50281
|
+
getWebViewState() {
|
|
50282
|
+
return Promise.resolve([false, null]);
|
|
50283
|
+
}
|
|
50284
|
+
setLeftTopBackButton(enable) {
|
|
50285
|
+
return Promise.resolve([false, null]);
|
|
50286
|
+
}
|
|
50287
|
+
login() {
|
|
50288
|
+
return Promise.resolve([false, null]);
|
|
50289
|
+
}
|
|
50290
|
+
logout() {
|
|
50291
|
+
return Promise.resolve([false, null]);
|
|
50292
|
+
}
|
|
50293
|
+
getUserInfo() {
|
|
50294
|
+
return Promise.resolve([false, null]);
|
|
50295
|
+
}
|
|
50296
|
+
openWebView(url, way) {
|
|
50297
|
+
switch (way) {
|
|
50298
|
+
case OpenWebViewEnum.Replace:
|
|
50299
|
+
case OpenWebViewEnum.Single: {
|
|
50300
|
+
setTimeout(() => globalThis.location.replace(url), 200);
|
|
50301
|
+
break;
|
|
50302
|
+
}
|
|
50303
|
+
case OpenWebViewEnum.Append:
|
|
50304
|
+
default: {
|
|
50305
|
+
setTimeout(() => (globalThis.location.href = url), 200);
|
|
50306
|
+
break;
|
|
50307
|
+
}
|
|
50308
|
+
}
|
|
50309
|
+
return Promise.resolve([true, null]);
|
|
50310
|
+
}
|
|
50311
|
+
closeWebView() {
|
|
50312
|
+
globalThis.close();
|
|
50313
|
+
return Promise.resolve([true, null]);
|
|
50314
|
+
}
|
|
50315
|
+
getBangsHeight() {
|
|
50316
|
+
return Promise.resolve([0, null]);
|
|
50317
|
+
}
|
|
50318
|
+
setOrientation(orientation) {
|
|
50319
|
+
return Promise.resolve([false, null]);
|
|
50320
|
+
}
|
|
50321
|
+
keepScreenLight(enable) {
|
|
50322
|
+
return Promise.resolve([false, null]);
|
|
50323
|
+
}
|
|
50324
|
+
shock(duration) {
|
|
50325
|
+
return Promise.resolve([false, null]);
|
|
50326
|
+
}
|
|
50327
|
+
minimize() {
|
|
50328
|
+
return Promise.resolve([false, null]);
|
|
50329
|
+
}
|
|
50330
|
+
saveImage2Album(base64) {
|
|
50331
|
+
return Promise.resolve([false, null]);
|
|
50332
|
+
}
|
|
50333
|
+
detectMicro() {
|
|
50334
|
+
return new Promise((resolve) => {
|
|
50335
|
+
const rule = { audio: true, video: false };
|
|
50336
|
+
try {
|
|
50337
|
+
globalThis.navigator.mediaDevices
|
|
50338
|
+
.getUserMedia(rule)
|
|
50339
|
+
.then(() => resolve([true, null]))
|
|
50340
|
+
.catch((e) => resolve([false, e]));
|
|
50341
|
+
}
|
|
50342
|
+
catch (e) {
|
|
50343
|
+
console.error(e);
|
|
50344
|
+
resolve([false, e]);
|
|
50345
|
+
}
|
|
50346
|
+
});
|
|
50347
|
+
}
|
|
50348
|
+
actionShare(shareConfig) {
|
|
50349
|
+
return Promise.resolve([false, null]);
|
|
50350
|
+
}
|
|
50351
|
+
preload(urls) {
|
|
50352
|
+
return Promise.resolve([false, null]);
|
|
50353
|
+
}
|
|
50354
|
+
createCacheProxyUrl(urls) {
|
|
50355
|
+
return [];
|
|
50356
|
+
}
|
|
50357
|
+
}
|
|
50358
|
+
|
|
50359
|
+
const defaultOptions = {
|
|
50360
|
+
timeout: 6000,
|
|
50361
|
+
};
|
|
50362
|
+
/**
|
|
50363
|
+
* 小程序 [web-view](https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html) JSBridge。
|
|
50364
|
+
*/
|
|
50365
|
+
class JSBridgeMiniprogram extends JSBridgeCore {
|
|
50366
|
+
constructor(options = {}) {
|
|
50367
|
+
super();
|
|
50368
|
+
this._controller = new WxMiniprogramController();
|
|
50369
|
+
this.options = Object.assign(defaultOptions, options);
|
|
50370
|
+
if (!isWxMiniProgram$1) {
|
|
50371
|
+
console.warn('未知容器:此版本 `jsBridge` 不支持当前 WebView 容器 ... ');
|
|
50372
|
+
}
|
|
50373
|
+
this.webViewType = WebViewTypeEnum.WeChatMPWebView;
|
|
50374
|
+
this.callAndListen('common/webViewState', (webviewState) => {
|
|
50375
|
+
this.emit('webViewStateChange', webviewState);
|
|
50376
|
+
});
|
|
50377
|
+
this.callAndListen('common/webViewError', (errorInfo) => {
|
|
50378
|
+
this.emit('error', errorInfo);
|
|
50379
|
+
});
|
|
50380
|
+
}
|
|
50381
|
+
async ready() {
|
|
50382
|
+
return await this._controller.checkReady(this.options.timeout);
|
|
50383
|
+
}
|
|
50384
|
+
async callAndBackfeed(schemeUrl) {
|
|
50385
|
+
return await this._controller.callAndBackfeed(schemeUrl);
|
|
50386
|
+
}
|
|
50387
|
+
async callAndListen(schemeUrl, callback) {
|
|
50388
|
+
return await this._controller.callAndListen(schemeUrl, callback);
|
|
50389
|
+
}
|
|
50390
|
+
async setLeftTopBackButton(enable) {
|
|
50391
|
+
if (this.webViewType === WebViewTypeEnum.WebView) {
|
|
50392
|
+
return [true, null];
|
|
50393
|
+
}
|
|
50394
|
+
return await this.callAndBackfeed(`common/setLeftTopBackButton?enable=${enable ? 1 : 0}`);
|
|
50395
|
+
}
|
|
50396
|
+
async getBangsHeight() {
|
|
50397
|
+
return await this.callAndBackfeed('common/getBangsHeight');
|
|
50398
|
+
}
|
|
50399
|
+
async shock(duration = 4) {
|
|
50400
|
+
return await this.callAndBackfeed(`common/shock?duration=${duration}`);
|
|
50401
|
+
}
|
|
50402
|
+
async minimize() {
|
|
50403
|
+
return await this.callAndBackfeed(`common/minimize`);
|
|
50404
|
+
}
|
|
50405
|
+
async loadProgress(progress) {
|
|
50406
|
+
progress = progress < 0 ? 0 : progress > 100 ? 100 : progress;
|
|
50407
|
+
return await this.callAndBackfeed(`common/loadProgress?progress=${progress}`);
|
|
50408
|
+
}
|
|
50409
|
+
async closeLoading() {
|
|
50410
|
+
return await this.callAndBackfeed(`common/closeLoading`);
|
|
50411
|
+
}
|
|
50412
|
+
async setOrientation(orientation) {
|
|
50413
|
+
return await this.callAndBackfeed(`common/setOrientation?orientation=${orientation}`);
|
|
50414
|
+
}
|
|
50415
|
+
async keepScreenLight(enable) {
|
|
50416
|
+
return await this.callAndBackfeed(`common/keepScreenLight?enable=${enable ? 1 : 0}`);
|
|
50417
|
+
}
|
|
50418
|
+
async closeWebView() {
|
|
50419
|
+
return await this.callAndBackfeed(`common/closeWebView`);
|
|
50420
|
+
}
|
|
50421
|
+
async openWebView(url, way) {
|
|
50422
|
+
return await this.callAndBackfeed(`common/openWebView?way=${way}&url=${encodeURIComponent(url)}`);
|
|
50423
|
+
}
|
|
50424
|
+
async saveImage2Album(base64) {
|
|
50425
|
+
return await this.callAndBackfeed(`common/saveImage2Album?base64=${base64}`);
|
|
50426
|
+
}
|
|
50427
|
+
async actionShare(shareConfig) {
|
|
50428
|
+
var _a, _b, _c;
|
|
50429
|
+
const config = {
|
|
50430
|
+
path: (_a = shareConfig.miniprogram) === null || _a === void 0 ? void 0 : _a[0].path,
|
|
50431
|
+
title: (_b = shareConfig.miniprogram) === null || _b === void 0 ? void 0 : _b[0].title,
|
|
50432
|
+
imageUrl: (_c = shareConfig.miniprogram) === null || _c === void 0 ? void 0 : _c[0].hdImageData,
|
|
50433
|
+
};
|
|
50434
|
+
return await this.callAndBackfeed(`common/actionShare?json=${JSON.stringify(config)}`);
|
|
50435
|
+
}
|
|
50436
|
+
async getDeviceInfo() {
|
|
50437
|
+
return await this.callAndBackfeed(`common/getDeviceInfo`);
|
|
50438
|
+
}
|
|
50439
|
+
async getUserInfo() {
|
|
50440
|
+
return await this.callAndBackfeed(`common/getUserInfo`);
|
|
50441
|
+
}
|
|
50442
|
+
async getWebViewState() {
|
|
50443
|
+
return await this.callAndBackfeed(`common/getWebViewState`);
|
|
50444
|
+
}
|
|
50445
|
+
async login() {
|
|
50446
|
+
const res = await this.callAndBackfeed(`common/login`);
|
|
50447
|
+
if (res[0]) {
|
|
50448
|
+
return await this.getUserInfo();
|
|
50449
|
+
}
|
|
50450
|
+
return res;
|
|
50451
|
+
}
|
|
50452
|
+
async logout() {
|
|
50453
|
+
return await this.callAndBackfeed(`common/logout`);
|
|
50454
|
+
}
|
|
50455
|
+
async detectMicro() {
|
|
50456
|
+
return await this.callAndBackfeed(`common/detectMicro`);
|
|
50457
|
+
}
|
|
50458
|
+
async preload(urls) {
|
|
50459
|
+
urls = urls.map((url) => {
|
|
50460
|
+
if (url.startsWith('//')) {
|
|
50461
|
+
return 'https:' + url;
|
|
50462
|
+
}
|
|
50463
|
+
return url;
|
|
50464
|
+
});
|
|
50465
|
+
return await this.callAndBackfeed(`common/preload?urls=${JSON.stringify(urls)}`);
|
|
50466
|
+
}
|
|
50467
|
+
createCacheProxyUrl(urls) {
|
|
50468
|
+
urls = Array.isArray(urls) ? urls : [urls];
|
|
50469
|
+
const userAgent = window.navigator.userAgent;
|
|
50470
|
+
// 不支持缓存代理
|
|
50471
|
+
if (!/supportCache/i.test(userAgent)) {
|
|
50472
|
+
return urls;
|
|
50473
|
+
}
|
|
50474
|
+
const proxyCache = (url) => {
|
|
50475
|
+
if (this.webViewType === WebViewTypeEnum.WKWebview) {
|
|
50476
|
+
return url.replace(/https*:/, '').replace(/\/\//, 'realseeproxycache://');
|
|
50477
|
+
}
|
|
50478
|
+
else if (this.webViewType === WebViewTypeEnum.WebView) {
|
|
50479
|
+
return url + (url.indexOf('?') !== -1 ? '&' : '?') + 'realseeproxycache=1';
|
|
50480
|
+
}
|
|
50481
|
+
return url;
|
|
50482
|
+
};
|
|
50483
|
+
return urls.map(proxyCache);
|
|
50484
|
+
}
|
|
50485
|
+
async invokeNativeApi(method, data) {
|
|
50486
|
+
return await this._controller.invoke(method, data);
|
|
50487
|
+
}
|
|
50488
|
+
}
|
|
50489
|
+
|
|
50490
|
+
/**
|
|
50491
|
+
* 平台相关的jsBridge类,根据平台自动加载不同的jsBridge实例
|
|
50492
|
+
*/
|
|
50493
|
+
// @ts-ignore
|
|
50494
|
+
class JSBridge extends JSBridgeCore {
|
|
50495
|
+
constructor(options = {}) {
|
|
50496
|
+
super();
|
|
50497
|
+
if (isRealseeVRWebview$1 && (isAndroid$1 || isIOS$1))
|
|
50498
|
+
return new JSBridgeApp(options);
|
|
50499
|
+
if (isWxMiniProgram$1)
|
|
50500
|
+
return new JSBridgeMiniprogram(options);
|
|
50501
|
+
return new JSBridgeBrowser();
|
|
50502
|
+
}
|
|
50503
|
+
}
|
|
50504
|
+
|
|
48777
50505
|
function appendUri(uri, query) {
|
|
48778
50506
|
const hasQuery = uri.indexOf('?') !== -1;
|
|
48779
50507
|
const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
|
|
48780
50508
|
return uri + newQuery;
|
|
48781
50509
|
}
|
|
48782
50510
|
|
|
50511
|
+
const userAgent = globalThis.navigator.userAgent;
|
|
50512
|
+
const isAndroid = /android/gi.test(userAgent);
|
|
50513
|
+
const isIOS = /iPhone|iPad\s+OS/gi.test(userAgent);
|
|
50514
|
+
const isWxMiniProgram = /MicroMessenger/gi.test(userAgent) && /miniProgram/gi.test(userAgent);
|
|
50515
|
+
const isRealseeVRWebview = /realsee/gi.test(userAgent);
|
|
50516
|
+
|
|
48783
50517
|
/**
|
|
48784
50518
|
* 判断是否是真实的对象类型
|
|
48785
50519
|
* @param value
|
|
@@ -49140,13 +50874,17 @@
|
|
|
49140
50874
|
: [];
|
|
49141
50875
|
if (toUserIds)
|
|
49142
50876
|
data['to_user_ids'] = toUserIds;
|
|
49143
|
-
return { command, front_request_id: uuid(), data };
|
|
50877
|
+
return { command, front_request_id: uuid$1(), data };
|
|
49144
50878
|
};
|
|
49145
|
-
class LiveTpl extends Subscribe {
|
|
50879
|
+
class LiveTpl extends Subscribe$1 {
|
|
49146
50880
|
constructor() {
|
|
49147
|
-
var _a;
|
|
50881
|
+
var _a, _b, _c;
|
|
49148
50882
|
super();
|
|
49149
|
-
this.keyframes = new Subscribe();
|
|
50883
|
+
this.keyframes = new Subscribe$1();
|
|
50884
|
+
const jsBridge = ((_a = options.jsBridge) !== null && _a !== void 0 ? _a : options.useBuiltInJsBridge)
|
|
50885
|
+
? new JSBridge()
|
|
50886
|
+
: undefined;
|
|
50887
|
+
liveController.options.jsBridge = jsBridge;
|
|
49150
50888
|
// 没有传rtc实例时
|
|
49151
50889
|
if (!options.rtc) {
|
|
49152
50890
|
// 取指定的内部rtc类型
|
|
@@ -49154,15 +50892,15 @@
|
|
|
49154
50892
|
if (!options.getVoiceSign) {
|
|
49155
50893
|
throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
|
|
49156
50894
|
}
|
|
49157
|
-
const getVoiceSign = (
|
|
50895
|
+
const getVoiceSign = (_b = options.getVoiceSign) !== null && _b !== void 0 ? _b : unimplementedGetVoiceSign;
|
|
49158
50896
|
switch (options.rtcType) {
|
|
49159
50897
|
case exports.RTCType.RealseeVRWebViewRTC: {
|
|
49160
50898
|
// 内置的 VRWebViewRTC
|
|
49161
|
-
if (!
|
|
50899
|
+
if (!jsBridge) {
|
|
49162
50900
|
throw new Error('JsBridge instance must be passed when using built-in VRWebViewRTC instances');
|
|
49163
50901
|
}
|
|
49164
50902
|
liveController.options.rtc = new VRWebViewRTC({
|
|
49165
|
-
jsBridge
|
|
50903
|
+
jsBridge,
|
|
49166
50904
|
getVoiceSign,
|
|
49167
50905
|
});
|
|
49168
50906
|
break;
|
|
@@ -49187,6 +50925,30 @@
|
|
|
49187
50925
|
}
|
|
49188
50926
|
}
|
|
49189
50927
|
}
|
|
50928
|
+
// 都不满足时取内置
|
|
50929
|
+
if (options.useBuiltInRTC) {
|
|
50930
|
+
if (!options.getVoiceSign) {
|
|
50931
|
+
throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
|
|
50932
|
+
}
|
|
50933
|
+
const getVoiceSign = (_c = options.getVoiceSign) !== null && _c !== void 0 ? _c : unimplementedGetVoiceSign;
|
|
50934
|
+
if (!jsBridge) {
|
|
50935
|
+
throw new Error('jsBridge instance must be passed when using built-in RTC instances');
|
|
50936
|
+
}
|
|
50937
|
+
// vrwebview 默认
|
|
50938
|
+
if ((isRealseeVRWebview && (isAndroid || isIOS)) || isWxMiniProgram) {
|
|
50939
|
+
liveController.options.rtc = new VRWebViewRTC({
|
|
50940
|
+
jsBridge,
|
|
50941
|
+
getVoiceSign,
|
|
50942
|
+
});
|
|
50943
|
+
}
|
|
50944
|
+
else {
|
|
50945
|
+
// 其它终端使用
|
|
50946
|
+
liveController.options.rtc =
|
|
50947
|
+
options.builtInRTCType === exports.BuiltInRTCType.RealseeXChimeRTC
|
|
50948
|
+
? new BrowserRTC4Chime({ getVoiceSign })
|
|
50949
|
+
: new BrowserRTC({ getVoiceSign });
|
|
50950
|
+
}
|
|
50951
|
+
}
|
|
49190
50952
|
}
|
|
49191
50953
|
if (!liveController.options.rtc) {
|
|
49192
50954
|
console.warn('unused rtc');
|
|
@@ -49234,6 +50996,9 @@
|
|
|
49234
50996
|
get $RTC() {
|
|
49235
50997
|
return liveController.options.rtc;
|
|
49236
50998
|
}
|
|
50999
|
+
get jsBridge() {
|
|
51000
|
+
return liveController.options.jsBridge;
|
|
51001
|
+
}
|
|
49237
51002
|
async setSelfInfo(userInfo) {
|
|
49238
51003
|
if (this.readyState !== exports.WebSocketState.OPEN) {
|
|
49239
51004
|
return new Error('The connection is not open and ready to communicate.');
|
|
@@ -49474,8 +51239,98 @@
|
|
|
49474
51239
|
return live;
|
|
49475
51240
|
}
|
|
49476
51241
|
|
|
49477
|
-
|
|
49478
|
-
|
|
51242
|
+
/*
|
|
51243
|
+
object-assign
|
|
51244
|
+
(c) Sindre Sorhus
|
|
51245
|
+
@license MIT
|
|
51246
|
+
*/
|
|
51247
|
+
/* eslint-disable no-unused-vars */
|
|
51248
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
51249
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
51250
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
51251
|
+
|
|
51252
|
+
function toObject(val) {
|
|
51253
|
+
if (val === null || val === undefined) {
|
|
51254
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
51255
|
+
}
|
|
51256
|
+
|
|
51257
|
+
return Object(val);
|
|
51258
|
+
}
|
|
51259
|
+
|
|
51260
|
+
function shouldUseNative() {
|
|
51261
|
+
try {
|
|
51262
|
+
if (!Object.assign) {
|
|
51263
|
+
return false;
|
|
51264
|
+
}
|
|
51265
|
+
|
|
51266
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
51267
|
+
|
|
51268
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
51269
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
51270
|
+
test1[5] = 'de';
|
|
51271
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
51272
|
+
return false;
|
|
51273
|
+
}
|
|
51274
|
+
|
|
51275
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
51276
|
+
var test2 = {};
|
|
51277
|
+
for (var i = 0; i < 10; i++) {
|
|
51278
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
51279
|
+
}
|
|
51280
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
51281
|
+
return test2[n];
|
|
51282
|
+
});
|
|
51283
|
+
if (order2.join('') !== '0123456789') {
|
|
51284
|
+
return false;
|
|
51285
|
+
}
|
|
51286
|
+
|
|
51287
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
51288
|
+
var test3 = {};
|
|
51289
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
51290
|
+
test3[letter] = letter;
|
|
51291
|
+
});
|
|
51292
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
51293
|
+
'abcdefghijklmnopqrst') {
|
|
51294
|
+
return false;
|
|
51295
|
+
}
|
|
51296
|
+
|
|
51297
|
+
return true;
|
|
51298
|
+
} catch (err) {
|
|
51299
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
51300
|
+
return false;
|
|
51301
|
+
}
|
|
51302
|
+
}
|
|
51303
|
+
|
|
51304
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
51305
|
+
var from;
|
|
51306
|
+
var to = toObject(target);
|
|
51307
|
+
var symbols;
|
|
51308
|
+
|
|
51309
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
51310
|
+
from = Object(arguments[s]);
|
|
51311
|
+
|
|
51312
|
+
for (var key in from) {
|
|
51313
|
+
if (hasOwnProperty.call(from, key)) {
|
|
51314
|
+
to[key] = from[key];
|
|
51315
|
+
}
|
|
51316
|
+
}
|
|
51317
|
+
|
|
51318
|
+
if (getOwnPropertySymbols) {
|
|
51319
|
+
symbols = getOwnPropertySymbols(from);
|
|
51320
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
51321
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
51322
|
+
to[symbols[i]] = from[symbols[i]];
|
|
51323
|
+
}
|
|
51324
|
+
}
|
|
51325
|
+
}
|
|
51326
|
+
}
|
|
51327
|
+
|
|
51328
|
+
return to;
|
|
51329
|
+
};
|
|
51330
|
+
|
|
51331
|
+
var require$$0 = objectAssign;
|
|
51332
|
+
|
|
51333
|
+
/** @license React v17.0.2
|
|
49479
51334
|
* react.development.js
|
|
49480
51335
|
*
|
|
49481
51336
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -49489,44 +51344,59 @@
|
|
|
49489
51344
|
{
|
|
49490
51345
|
(function() {
|
|
49491
51346
|
|
|
49492
|
-
|
|
49493
|
-
if (
|
|
49494
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
49495
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
49496
|
-
'function'
|
|
49497
|
-
) {
|
|
49498
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
49499
|
-
}
|
|
49500
|
-
var ReactVersion = '18.1.0';
|
|
49501
|
-
|
|
49502
|
-
// -----------------------------------------------------------------------------
|
|
49503
|
-
|
|
49504
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
49505
|
-
var enableCacheElement = false;
|
|
49506
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
51347
|
+
var _assign = require$$0;
|
|
49507
51348
|
|
|
49508
|
-
|
|
49509
|
-
|
|
49510
|
-
// issues in DEV builds.
|
|
49511
|
-
|
|
49512
|
-
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
51349
|
+
// TODO: this is special because it gets imported during build.
|
|
51350
|
+
var ReactVersion = '17.0.2';
|
|
49513
51351
|
|
|
49514
51352
|
// ATTENTION
|
|
49515
|
-
|
|
49516
|
-
|
|
49517
|
-
|
|
49518
|
-
|
|
49519
|
-
var
|
|
49520
|
-
var
|
|
49521
|
-
|
|
49522
|
-
|
|
49523
|
-
|
|
49524
|
-
var
|
|
49525
|
-
var
|
|
49526
|
-
var
|
|
49527
|
-
|
|
49528
|
-
var
|
|
49529
|
-
var
|
|
51353
|
+
// When adding new symbols to this file,
|
|
51354
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
51355
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
51356
|
+
// nor polyfill, then a plain number is used for performance.
|
|
51357
|
+
var REACT_ELEMENT_TYPE = 0xeac7;
|
|
51358
|
+
var REACT_PORTAL_TYPE = 0xeaca;
|
|
51359
|
+
exports.Fragment = 0xeacb;
|
|
51360
|
+
exports.StrictMode = 0xeacc;
|
|
51361
|
+
exports.Profiler = 0xead2;
|
|
51362
|
+
var REACT_PROVIDER_TYPE = 0xeacd;
|
|
51363
|
+
var REACT_CONTEXT_TYPE = 0xeace;
|
|
51364
|
+
var REACT_FORWARD_REF_TYPE = 0xead0;
|
|
51365
|
+
exports.Suspense = 0xead1;
|
|
51366
|
+
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
|
51367
|
+
var REACT_MEMO_TYPE = 0xead3;
|
|
51368
|
+
var REACT_LAZY_TYPE = 0xead4;
|
|
51369
|
+
var REACT_BLOCK_TYPE = 0xead9;
|
|
51370
|
+
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
|
51371
|
+
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
|
51372
|
+
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
51373
|
+
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
51374
|
+
|
|
51375
|
+
if (typeof Symbol === 'function' && Symbol.for) {
|
|
51376
|
+
var symbolFor = Symbol.for;
|
|
51377
|
+
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
51378
|
+
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
51379
|
+
exports.Fragment = symbolFor('react.fragment');
|
|
51380
|
+
exports.StrictMode = symbolFor('react.strict_mode');
|
|
51381
|
+
exports.Profiler = symbolFor('react.profiler');
|
|
51382
|
+
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
51383
|
+
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
51384
|
+
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
51385
|
+
exports.Suspense = symbolFor('react.suspense');
|
|
51386
|
+
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
51387
|
+
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
51388
|
+
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
51389
|
+
REACT_BLOCK_TYPE = symbolFor('react.block');
|
|
51390
|
+
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
|
51391
|
+
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
|
51392
|
+
symbolFor('react.scope');
|
|
51393
|
+
symbolFor('react.opaque.id');
|
|
51394
|
+
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
51395
|
+
symbolFor('react.offscreen');
|
|
51396
|
+
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
51397
|
+
}
|
|
51398
|
+
|
|
51399
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
49530
51400
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
49531
51401
|
function getIteratorFn(maybeIterable) {
|
|
49532
51402
|
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
@@ -49558,14 +51428,7 @@
|
|
|
49558
51428
|
* should suspend for if it needs to.
|
|
49559
51429
|
*/
|
|
49560
51430
|
var ReactCurrentBatchConfig = {
|
|
49561
|
-
transition:
|
|
49562
|
-
};
|
|
49563
|
-
|
|
49564
|
-
var ReactCurrentActQueue = {
|
|
49565
|
-
current: null,
|
|
49566
|
-
// Used to reproduce behavior of `batchedUpdates` in legacy mode.
|
|
49567
|
-
isBatchingLegacy: false,
|
|
49568
|
-
didScheduleLegacyUpdate: false
|
|
51431
|
+
transition: 0
|
|
49569
51432
|
};
|
|
49570
51433
|
|
|
49571
51434
|
/**
|
|
@@ -49618,15 +51481,24 @@
|
|
|
49618
51481
|
};
|
|
49619
51482
|
}
|
|
49620
51483
|
|
|
51484
|
+
/**
|
|
51485
|
+
* Used by act() to track whether you're inside an act() scope.
|
|
51486
|
+
*/
|
|
51487
|
+
var IsSomeRendererActing = {
|
|
51488
|
+
current: false
|
|
51489
|
+
};
|
|
51490
|
+
|
|
49621
51491
|
var ReactSharedInternals = {
|
|
49622
51492
|
ReactCurrentDispatcher: ReactCurrentDispatcher,
|
|
49623
51493
|
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
|
|
49624
|
-
ReactCurrentOwner: ReactCurrentOwner
|
|
51494
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
|
51495
|
+
IsSomeRendererActing: IsSomeRendererActing,
|
|
51496
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
51497
|
+
assign: _assign
|
|
49625
51498
|
};
|
|
49626
51499
|
|
|
49627
51500
|
{
|
|
49628
51501
|
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
|
|
49629
|
-
ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
|
|
49630
51502
|
}
|
|
49631
51503
|
|
|
49632
51504
|
// by calls to these methods by a Babel plugin.
|
|
@@ -49636,24 +51508,20 @@
|
|
|
49636
51508
|
|
|
49637
51509
|
function warn(format) {
|
|
49638
51510
|
{
|
|
49639
|
-
{
|
|
49640
|
-
|
|
49641
|
-
args[_key - 1] = arguments[_key];
|
|
49642
|
-
}
|
|
49643
|
-
|
|
49644
|
-
printWarning('warn', format, args);
|
|
51511
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
51512
|
+
args[_key - 1] = arguments[_key];
|
|
49645
51513
|
}
|
|
51514
|
+
|
|
51515
|
+
printWarning('warn', format, args);
|
|
49646
51516
|
}
|
|
49647
51517
|
}
|
|
49648
51518
|
function error(format) {
|
|
49649
51519
|
{
|
|
49650
|
-
{
|
|
49651
|
-
|
|
49652
|
-
args[_key2 - 1] = arguments[_key2];
|
|
49653
|
-
}
|
|
49654
|
-
|
|
49655
|
-
printWarning('error', format, args);
|
|
51520
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
51521
|
+
args[_key2 - 1] = arguments[_key2];
|
|
49656
51522
|
}
|
|
51523
|
+
|
|
51524
|
+
printWarning('error', format, args);
|
|
49657
51525
|
}
|
|
49658
51526
|
}
|
|
49659
51527
|
|
|
@@ -49667,11 +51535,10 @@
|
|
|
49667
51535
|
if (stack !== '') {
|
|
49668
51536
|
format += '%s';
|
|
49669
51537
|
args = args.concat([stack]);
|
|
49670
|
-
}
|
|
49671
|
-
|
|
51538
|
+
}
|
|
49672
51539
|
|
|
49673
51540
|
var argsWithFormat = args.map(function (item) {
|
|
49674
|
-
return
|
|
51541
|
+
return '' + item;
|
|
49675
51542
|
}); // Careful: RN currently depends on this prefix
|
|
49676
51543
|
|
|
49677
51544
|
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
@@ -49769,8 +51636,6 @@
|
|
|
49769
51636
|
}
|
|
49770
51637
|
};
|
|
49771
51638
|
|
|
49772
|
-
var assign = Object.assign;
|
|
49773
|
-
|
|
49774
51639
|
var emptyObject = {};
|
|
49775
51640
|
|
|
49776
51641
|
{
|
|
@@ -49819,8 +51684,10 @@
|
|
|
49819
51684
|
*/
|
|
49820
51685
|
|
|
49821
51686
|
Component.prototype.setState = function (partialState, callback) {
|
|
49822
|
-
if (typeof partialState
|
|
49823
|
-
|
|
51687
|
+
if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
|
|
51688
|
+
{
|
|
51689
|
+
throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." );
|
|
51690
|
+
}
|
|
49824
51691
|
}
|
|
49825
51692
|
|
|
49826
51693
|
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
|
@@ -49892,7 +51759,8 @@
|
|
|
49892
51759
|
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
49893
51760
|
pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
|
|
49894
51761
|
|
|
49895
|
-
|
|
51762
|
+
_assign(pureComponentPrototype, Component.prototype);
|
|
51763
|
+
|
|
49896
51764
|
pureComponentPrototype.isPureReactComponent = true;
|
|
49897
51765
|
|
|
49898
51766
|
// an immutable object with a single mutable value
|
|
@@ -49908,96 +51776,16 @@
|
|
|
49908
51776
|
return refObject;
|
|
49909
51777
|
}
|
|
49910
51778
|
|
|
49911
|
-
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
49912
|
-
|
|
49913
|
-
function isArray(a) {
|
|
49914
|
-
return isArrayImpl(a);
|
|
49915
|
-
}
|
|
49916
|
-
|
|
49917
|
-
/*
|
|
49918
|
-
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
|
|
49919
|
-
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
49920
|
-
*
|
|
49921
|
-
* The functions in this module will throw an easier-to-understand,
|
|
49922
|
-
* easier-to-debug exception with a clear errors message message explaining the
|
|
49923
|
-
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
49924
|
-
* of the `value` object).
|
|
49925
|
-
*/
|
|
49926
|
-
// $FlowFixMe only called in DEV, so void return is not possible.
|
|
49927
|
-
function typeName(value) {
|
|
49928
|
-
{
|
|
49929
|
-
// toStringTag is needed for namespaced types like Temporal.Instant
|
|
49930
|
-
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
|
49931
|
-
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
|
49932
|
-
return type;
|
|
49933
|
-
}
|
|
49934
|
-
} // $FlowFixMe only called in DEV, so void return is not possible.
|
|
49935
|
-
|
|
49936
|
-
|
|
49937
|
-
function willCoercionThrow(value) {
|
|
49938
|
-
{
|
|
49939
|
-
try {
|
|
49940
|
-
return false;
|
|
49941
|
-
} catch (e) {
|
|
49942
|
-
return true;
|
|
49943
|
-
}
|
|
49944
|
-
}
|
|
49945
|
-
}
|
|
49946
|
-
|
|
49947
|
-
function testStringCoercion(value) {
|
|
49948
|
-
// If you ended up here by following an exception call stack, here's what's
|
|
49949
|
-
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
49950
|
-
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
49951
|
-
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
49952
|
-
//
|
|
49953
|
-
// The most common types that will cause this exception are `Symbol` instances
|
|
49954
|
-
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
49955
|
-
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
49956
|
-
// exception. (Library authors do this to prevent users from using built-in
|
|
49957
|
-
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
49958
|
-
// methods are needed to perform accurate arithmetic or comparison.)
|
|
49959
|
-
//
|
|
49960
|
-
// To fix the problem, coerce this object or symbol value to a string before
|
|
49961
|
-
// passing it to React. The most reliable way is usually `String(value)`.
|
|
49962
|
-
//
|
|
49963
|
-
// To find which value is throwing, check the browser or debugger console.
|
|
49964
|
-
// Before this exception was thrown, there should be `console.error` output
|
|
49965
|
-
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
49966
|
-
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
49967
|
-
// In most cases, this console output also shows the component and its
|
|
49968
|
-
// ancestor components where the exception happened.
|
|
49969
|
-
//
|
|
49970
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
49971
|
-
return '' + value;
|
|
49972
|
-
}
|
|
49973
|
-
function checkKeyStringCoercion(value) {
|
|
49974
|
-
{
|
|
49975
|
-
if (willCoercionThrow()) {
|
|
49976
|
-
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
|
|
49977
|
-
|
|
49978
|
-
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
49979
|
-
}
|
|
49980
|
-
}
|
|
49981
|
-
}
|
|
49982
|
-
|
|
49983
51779
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
49984
|
-
var displayName = outerType.displayName;
|
|
49985
|
-
|
|
49986
|
-
if (displayName) {
|
|
49987
|
-
return displayName;
|
|
49988
|
-
}
|
|
49989
|
-
|
|
49990
51780
|
var functionName = innerType.displayName || innerType.name || '';
|
|
49991
|
-
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
49992
|
-
}
|
|
49993
|
-
|
|
51781
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
51782
|
+
}
|
|
49994
51783
|
|
|
49995
51784
|
function getContextName(type) {
|
|
49996
51785
|
return type.displayName || 'Context';
|
|
49997
|
-
}
|
|
49998
|
-
|
|
51786
|
+
}
|
|
49999
51787
|
|
|
50000
|
-
function
|
|
51788
|
+
function getComponentName(type) {
|
|
50001
51789
|
if (type == null) {
|
|
50002
51790
|
// Host root, text node or just invalid type.
|
|
50003
51791
|
return null;
|
|
@@ -50005,7 +51793,7 @@
|
|
|
50005
51793
|
|
|
50006
51794
|
{
|
|
50007
51795
|
if (typeof type.tag === 'number') {
|
|
50008
|
-
error('Received an unexpected object in
|
|
51796
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
50009
51797
|
}
|
|
50010
51798
|
}
|
|
50011
51799
|
|
|
@@ -50018,24 +51806,23 @@
|
|
|
50018
51806
|
}
|
|
50019
51807
|
|
|
50020
51808
|
switch (type) {
|
|
50021
|
-
case
|
|
51809
|
+
case exports.Fragment:
|
|
50022
51810
|
return 'Fragment';
|
|
50023
51811
|
|
|
50024
51812
|
case REACT_PORTAL_TYPE:
|
|
50025
51813
|
return 'Portal';
|
|
50026
51814
|
|
|
50027
|
-
case
|
|
51815
|
+
case exports.Profiler:
|
|
50028
51816
|
return 'Profiler';
|
|
50029
51817
|
|
|
50030
|
-
case
|
|
51818
|
+
case exports.StrictMode:
|
|
50031
51819
|
return 'StrictMode';
|
|
50032
51820
|
|
|
50033
|
-
case
|
|
51821
|
+
case exports.Suspense:
|
|
50034
51822
|
return 'Suspense';
|
|
50035
51823
|
|
|
50036
51824
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
50037
51825
|
return 'SuspenseList';
|
|
50038
|
-
|
|
50039
51826
|
}
|
|
50040
51827
|
|
|
50041
51828
|
if (typeof type === 'object') {
|
|
@@ -50052,13 +51839,10 @@
|
|
|
50052
51839
|
return getWrappedName(type, type.render, 'ForwardRef');
|
|
50053
51840
|
|
|
50054
51841
|
case REACT_MEMO_TYPE:
|
|
50055
|
-
|
|
51842
|
+
return getComponentName(type.type);
|
|
50056
51843
|
|
|
50057
|
-
|
|
50058
|
-
|
|
50059
|
-
}
|
|
50060
|
-
|
|
50061
|
-
return getComponentNameFromType(type.type) || 'Memo';
|
|
51844
|
+
case REACT_BLOCK_TYPE:
|
|
51845
|
+
return getComponentName(type._render);
|
|
50062
51846
|
|
|
50063
51847
|
case REACT_LAZY_TYPE:
|
|
50064
51848
|
{
|
|
@@ -50067,13 +51851,11 @@
|
|
|
50067
51851
|
var init = lazyComponent._init;
|
|
50068
51852
|
|
|
50069
51853
|
try {
|
|
50070
|
-
return
|
|
51854
|
+
return getComponentName(init(payload));
|
|
50071
51855
|
} catch (x) {
|
|
50072
51856
|
return null;
|
|
50073
51857
|
}
|
|
50074
51858
|
}
|
|
50075
|
-
|
|
50076
|
-
// eslint-disable-next-line no-fallthrough
|
|
50077
51859
|
}
|
|
50078
51860
|
}
|
|
50079
51861
|
|
|
@@ -50081,7 +51863,6 @@
|
|
|
50081
51863
|
}
|
|
50082
51864
|
|
|
50083
51865
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
50084
|
-
|
|
50085
51866
|
var RESERVED_PROPS = {
|
|
50086
51867
|
key: true,
|
|
50087
51868
|
ref: true,
|
|
@@ -50161,7 +51942,7 @@
|
|
|
50161
51942
|
function warnIfStringRefCannotBeAutoConverted(config) {
|
|
50162
51943
|
{
|
|
50163
51944
|
if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
|
|
50164
|
-
var componentName =
|
|
51945
|
+
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
50165
51946
|
|
|
50166
51947
|
if (!didWarnAboutStringRefs[componentName]) {
|
|
50167
51948
|
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
|
|
@@ -50270,10 +52051,6 @@
|
|
|
50270
52051
|
}
|
|
50271
52052
|
|
|
50272
52053
|
if (hasValidKey(config)) {
|
|
50273
|
-
{
|
|
50274
|
-
checkKeyStringCoercion(config.key);
|
|
50275
|
-
}
|
|
50276
|
-
|
|
50277
52054
|
key = '' + config.key;
|
|
50278
52055
|
}
|
|
50279
52056
|
|
|
@@ -50346,13 +52123,16 @@
|
|
|
50346
52123
|
*/
|
|
50347
52124
|
|
|
50348
52125
|
function cloneElement(element, config, children) {
|
|
50349
|
-
if (element === null || element === undefined) {
|
|
50350
|
-
|
|
52126
|
+
if (!!(element === null || element === undefined)) {
|
|
52127
|
+
{
|
|
52128
|
+
throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." );
|
|
52129
|
+
}
|
|
50351
52130
|
}
|
|
50352
52131
|
|
|
50353
52132
|
var propName; // Original props are copied
|
|
50354
52133
|
|
|
50355
|
-
var props =
|
|
52134
|
+
var props = _assign({}, element.props); // Reserved names are extracted
|
|
52135
|
+
|
|
50356
52136
|
|
|
50357
52137
|
var key = element.key;
|
|
50358
52138
|
var ref = element.ref; // Self is preserved since the owner is preserved.
|
|
@@ -50373,10 +52153,6 @@
|
|
|
50373
52153
|
}
|
|
50374
52154
|
|
|
50375
52155
|
if (hasValidKey(config)) {
|
|
50376
|
-
{
|
|
50377
|
-
checkKeyStringCoercion(config.key);
|
|
50378
|
-
}
|
|
50379
|
-
|
|
50380
52156
|
key = '' + config.key;
|
|
50381
52157
|
} // Remaining properties override existing props
|
|
50382
52158
|
|
|
@@ -50475,10 +52251,6 @@
|
|
|
50475
52251
|
// that we don't block potential future ES APIs.
|
|
50476
52252
|
if (typeof element === 'object' && element !== null && element.key != null) {
|
|
50477
52253
|
// Explicit key
|
|
50478
|
-
{
|
|
50479
|
-
checkKeyStringCoercion(element.key);
|
|
50480
|
-
}
|
|
50481
|
-
|
|
50482
52254
|
return escape('' + element.key);
|
|
50483
52255
|
} // Implicit key determined by the index in the set
|
|
50484
52256
|
|
|
@@ -50522,7 +52294,7 @@
|
|
|
50522
52294
|
|
|
50523
52295
|
var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
|
|
50524
52296
|
|
|
50525
|
-
if (isArray(mappedChild)) {
|
|
52297
|
+
if (Array.isArray(mappedChild)) {
|
|
50526
52298
|
var escapedChildKey = '';
|
|
50527
52299
|
|
|
50528
52300
|
if (childKey != null) {
|
|
@@ -50534,20 +52306,10 @@
|
|
|
50534
52306
|
});
|
|
50535
52307
|
} else if (mappedChild != null) {
|
|
50536
52308
|
if (isValidElement(mappedChild)) {
|
|
50537
|
-
{
|
|
50538
|
-
// The `if` statement here prevents auto-disabling of the safe
|
|
50539
|
-
// coercion ESLint rule, so we must manually disable it below.
|
|
50540
|
-
// $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
|
|
50541
|
-
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
|
|
50542
|
-
checkKeyStringCoercion(mappedChild.key);
|
|
50543
|
-
}
|
|
50544
|
-
}
|
|
50545
|
-
|
|
50546
52309
|
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
|
|
50547
52310
|
// traverseAllChildren used to do for objects as children
|
|
50548
52311
|
escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
|
|
50549
52312
|
mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
|
|
50550
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
50551
52313
|
escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
|
|
50552
52314
|
}
|
|
50553
52315
|
|
|
@@ -50563,7 +52325,7 @@
|
|
|
50563
52325
|
|
|
50564
52326
|
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
50565
52327
|
|
|
50566
|
-
if (isArray(children)) {
|
|
52328
|
+
if (Array.isArray(children)) {
|
|
50567
52329
|
for (var i = 0; i < children.length; i++) {
|
|
50568
52330
|
child = children[i];
|
|
50569
52331
|
nextName = nextNamePrefix + getElementKey(child, i);
|
|
@@ -50596,9 +52358,13 @@
|
|
|
50596
52358
|
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
|
50597
52359
|
}
|
|
50598
52360
|
} else if (type === 'object') {
|
|
50599
|
-
|
|
50600
|
-
|
|
50601
|
-
|
|
52361
|
+
var childrenString = '' + children;
|
|
52362
|
+
|
|
52363
|
+
{
|
|
52364
|
+
{
|
|
52365
|
+
throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). If you meant to render a collection of children, use an array instead." );
|
|
52366
|
+
}
|
|
52367
|
+
}
|
|
50602
52368
|
}
|
|
50603
52369
|
}
|
|
50604
52370
|
|
|
@@ -50697,17 +52463,28 @@
|
|
|
50697
52463
|
|
|
50698
52464
|
function onlyChild(children) {
|
|
50699
52465
|
if (!isValidElement(children)) {
|
|
50700
|
-
|
|
52466
|
+
{
|
|
52467
|
+
throw Error( "React.Children.only expected to receive a single React element child." );
|
|
52468
|
+
}
|
|
50701
52469
|
}
|
|
50702
52470
|
|
|
50703
52471
|
return children;
|
|
50704
52472
|
}
|
|
50705
52473
|
|
|
50706
|
-
function createContext(defaultValue) {
|
|
50707
|
-
|
|
50708
|
-
|
|
52474
|
+
function createContext(defaultValue, calculateChangedBits) {
|
|
52475
|
+
if (calculateChangedBits === undefined) {
|
|
52476
|
+
calculateChangedBits = null;
|
|
52477
|
+
} else {
|
|
52478
|
+
{
|
|
52479
|
+
if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
|
|
52480
|
+
error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
|
|
52481
|
+
}
|
|
52482
|
+
}
|
|
52483
|
+
}
|
|
52484
|
+
|
|
50709
52485
|
var context = {
|
|
50710
52486
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
52487
|
+
_calculateChangedBits: calculateChangedBits,
|
|
50711
52488
|
// As a workaround to support multiple concurrent renderers, we categorize
|
|
50712
52489
|
// some renderers as primary and others as secondary. We only expect
|
|
50713
52490
|
// there to be two concurrent renderers at most: React Native (primary) and
|
|
@@ -50720,10 +52497,7 @@
|
|
|
50720
52497
|
_threadCount: 0,
|
|
50721
52498
|
// These are circular
|
|
50722
52499
|
Provider: null,
|
|
50723
|
-
Consumer: null
|
|
50724
|
-
// Add these to use same hidden class in VM as ServerContext
|
|
50725
|
-
_defaultValue: null,
|
|
50726
|
-
_globalName: null
|
|
52500
|
+
Consumer: null
|
|
50727
52501
|
};
|
|
50728
52502
|
context.Provider = {
|
|
50729
52503
|
$$typeof: REACT_PROVIDER_TYPE,
|
|
@@ -50739,7 +52513,8 @@
|
|
|
50739
52513
|
// warn for the incorrect usage of Context as a Consumer.
|
|
50740
52514
|
var Consumer = {
|
|
50741
52515
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
50742
|
-
_context: context
|
|
52516
|
+
_context: context,
|
|
52517
|
+
_calculateChangedBits: context._calculateChangedBits
|
|
50743
52518
|
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
|
|
50744
52519
|
|
|
50745
52520
|
Object.defineProperties(Consumer, {
|
|
@@ -50826,54 +52601,38 @@
|
|
|
50826
52601
|
if (payload._status === Uninitialized) {
|
|
50827
52602
|
var ctor = payload._result;
|
|
50828
52603
|
var thenable = ctor(); // Transition to the next state.
|
|
50829
|
-
// This might throw either because it's missing or throws. If so, we treat it
|
|
50830
|
-
// as still uninitialized and try again next time. Which is the same as what
|
|
50831
|
-
// happens if the ctor or any wrappers processing the ctor throws. This might
|
|
50832
|
-
// end up fixing it if the resolution was a concurrency bug.
|
|
50833
52604
|
|
|
52605
|
+
var pending = payload;
|
|
52606
|
+
pending._status = Pending;
|
|
52607
|
+
pending._result = thenable;
|
|
50834
52608
|
thenable.then(function (moduleObject) {
|
|
50835
|
-
if (payload._status === Pending
|
|
50836
|
-
|
|
52609
|
+
if (payload._status === Pending) {
|
|
52610
|
+
var defaultExport = moduleObject.default;
|
|
52611
|
+
|
|
52612
|
+
{
|
|
52613
|
+
if (defaultExport === undefined) {
|
|
52614
|
+
error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
|
52615
|
+
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
|
|
52616
|
+
}
|
|
52617
|
+
} // Transition to the next state.
|
|
52618
|
+
|
|
52619
|
+
|
|
50837
52620
|
var resolved = payload;
|
|
50838
52621
|
resolved._status = Resolved;
|
|
50839
|
-
resolved._result =
|
|
52622
|
+
resolved._result = defaultExport;
|
|
50840
52623
|
}
|
|
50841
52624
|
}, function (error) {
|
|
50842
|
-
if (payload._status === Pending
|
|
52625
|
+
if (payload._status === Pending) {
|
|
50843
52626
|
// Transition to the next state.
|
|
50844
52627
|
var rejected = payload;
|
|
50845
52628
|
rejected._status = Rejected;
|
|
50846
52629
|
rejected._result = error;
|
|
50847
52630
|
}
|
|
50848
52631
|
});
|
|
50849
|
-
|
|
50850
|
-
if (payload._status === Uninitialized) {
|
|
50851
|
-
// In case, we're still uninitialized, then we're waiting for the thenable
|
|
50852
|
-
// to resolve. Set it as pending in the meantime.
|
|
50853
|
-
var pending = payload;
|
|
50854
|
-
pending._status = Pending;
|
|
50855
|
-
pending._result = thenable;
|
|
50856
|
-
}
|
|
50857
52632
|
}
|
|
50858
52633
|
|
|
50859
52634
|
if (payload._status === Resolved) {
|
|
50860
|
-
|
|
50861
|
-
|
|
50862
|
-
{
|
|
50863
|
-
if (moduleObject === undefined) {
|
|
50864
|
-
error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
|
50865
|
-
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
|
|
50866
|
-
}
|
|
50867
|
-
}
|
|
50868
|
-
|
|
50869
|
-
{
|
|
50870
|
-
if (!('default' in moduleObject)) {
|
|
50871
|
-
error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
|
50872
|
-
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
|
|
50873
|
-
}
|
|
50874
|
-
}
|
|
50875
|
-
|
|
50876
|
-
return moduleObject.default;
|
|
52635
|
+
return payload._result;
|
|
50877
52636
|
} else {
|
|
50878
52637
|
throw payload._result;
|
|
50879
52638
|
}
|
|
@@ -50882,7 +52641,7 @@
|
|
|
50882
52641
|
function lazy(ctor) {
|
|
50883
52642
|
var payload = {
|
|
50884
52643
|
// We use these fields to store the result.
|
|
50885
|
-
_status:
|
|
52644
|
+
_status: -1,
|
|
50886
52645
|
_result: ctor
|
|
50887
52646
|
};
|
|
50888
52647
|
var lazyType = {
|
|
@@ -50968,15 +52727,9 @@
|
|
|
50968
52727
|
return ownName;
|
|
50969
52728
|
},
|
|
50970
52729
|
set: function (name) {
|
|
50971
|
-
ownName = name;
|
|
50972
|
-
|
|
50973
|
-
|
|
50974
|
-
// so that our component-stack generation logic will display their frames.
|
|
50975
|
-
// An anonymous function generally suggests a pattern like:
|
|
50976
|
-
// React.forwardRef((props, ref) => {...});
|
|
50977
|
-
// This kind of inner function is not used elsewhere so the side effect is okay.
|
|
50978
|
-
|
|
50979
|
-
if (!render.name && !render.displayName) {
|
|
52730
|
+
ownName = name;
|
|
52731
|
+
|
|
52732
|
+
if (render.displayName == null) {
|
|
50980
52733
|
render.displayName = name;
|
|
50981
52734
|
}
|
|
50982
52735
|
}
|
|
@@ -50986,11 +52739,9 @@
|
|
|
50986
52739
|
return elementType;
|
|
50987
52740
|
}
|
|
50988
52741
|
|
|
50989
|
-
|
|
52742
|
+
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
|
50990
52743
|
|
|
50991
|
-
|
|
50992
|
-
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
50993
|
-
}
|
|
52744
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
50994
52745
|
|
|
50995
52746
|
function isValidElementType(type) {
|
|
50996
52747
|
if (typeof type === 'string' || typeof type === 'function') {
|
|
@@ -50998,16 +52749,12 @@
|
|
|
50998
52749
|
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
50999
52750
|
|
|
51000
52751
|
|
|
51001
|
-
if (type ===
|
|
52752
|
+
if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
|
51002
52753
|
return true;
|
|
51003
52754
|
}
|
|
51004
52755
|
|
|
51005
52756
|
if (typeof type === 'object' && type !== null) {
|
|
51006
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
51007
|
-
// types supported by any Flight configuration anywhere since
|
|
51008
|
-
// we don't know which Flight build this will end up being used
|
|
51009
|
-
// with.
|
|
51010
|
-
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
52757
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
|
51011
52758
|
return true;
|
|
51012
52759
|
}
|
|
51013
52760
|
}
|
|
@@ -51037,15 +52784,9 @@
|
|
|
51037
52784
|
return ownName;
|
|
51038
52785
|
},
|
|
51039
52786
|
set: function (name) {
|
|
51040
|
-
ownName = name;
|
|
51041
|
-
|
|
51042
|
-
|
|
51043
|
-
// so that our component-stack generation logic will display their frames.
|
|
51044
|
-
// An anonymous function generally suggests a pattern like:
|
|
51045
|
-
// React.memo((props) => {...});
|
|
51046
|
-
// This kind of inner function is not used elsewhere so the side effect is okay.
|
|
51047
|
-
|
|
51048
|
-
if (!type.name && !type.displayName) {
|
|
52787
|
+
ownName = name;
|
|
52788
|
+
|
|
52789
|
+
if (type.displayName == null) {
|
|
51049
52790
|
type.displayName = name;
|
|
51050
52791
|
}
|
|
51051
52792
|
}
|
|
@@ -51058,22 +52799,24 @@
|
|
|
51058
52799
|
function resolveDispatcher() {
|
|
51059
52800
|
var dispatcher = ReactCurrentDispatcher.current;
|
|
51060
52801
|
|
|
51061
|
-
{
|
|
51062
|
-
|
|
51063
|
-
|
|
52802
|
+
if (!(dispatcher !== null)) {
|
|
52803
|
+
{
|
|
52804
|
+
throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." );
|
|
51064
52805
|
}
|
|
51065
|
-
}
|
|
51066
|
-
// intentionally don't throw our own error because this is in a hot path.
|
|
51067
|
-
// Also helps ensure this is inlined.
|
|
51068
|
-
|
|
52806
|
+
}
|
|
51069
52807
|
|
|
51070
52808
|
return dispatcher;
|
|
51071
52809
|
}
|
|
51072
|
-
|
|
52810
|
+
|
|
52811
|
+
function useContext(Context, unstable_observedBits) {
|
|
51073
52812
|
var dispatcher = resolveDispatcher();
|
|
51074
52813
|
|
|
51075
52814
|
{
|
|
51076
|
-
|
|
52815
|
+
if (unstable_observedBits !== undefined) {
|
|
52816
|
+
error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://reactjs.org/link/rules-of-hooks' : '');
|
|
52817
|
+
} // TODO: add a more generic warning for invalid values.
|
|
52818
|
+
|
|
52819
|
+
|
|
51077
52820
|
if (Context._context !== undefined) {
|
|
51078
52821
|
var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
|
|
51079
52822
|
// and nobody should be using this in existing code.
|
|
@@ -51086,7 +52829,7 @@
|
|
|
51086
52829
|
}
|
|
51087
52830
|
}
|
|
51088
52831
|
|
|
51089
|
-
return dispatcher.useContext(Context);
|
|
52832
|
+
return dispatcher.useContext(Context, unstable_observedBits);
|
|
51090
52833
|
}
|
|
51091
52834
|
function useState(initialState) {
|
|
51092
52835
|
var dispatcher = resolveDispatcher();
|
|
@@ -51104,10 +52847,6 @@
|
|
|
51104
52847
|
var dispatcher = resolveDispatcher();
|
|
51105
52848
|
return dispatcher.useEffect(create, deps);
|
|
51106
52849
|
}
|
|
51107
|
-
function useInsertionEffect(create, deps) {
|
|
51108
|
-
var dispatcher = resolveDispatcher();
|
|
51109
|
-
return dispatcher.useInsertionEffect(create, deps);
|
|
51110
|
-
}
|
|
51111
52850
|
function useLayoutEffect(create, deps) {
|
|
51112
52851
|
var dispatcher = resolveDispatcher();
|
|
51113
52852
|
return dispatcher.useLayoutEffect(create, deps);
|
|
@@ -51130,22 +52869,6 @@
|
|
|
51130
52869
|
return dispatcher.useDebugValue(value, formatterFn);
|
|
51131
52870
|
}
|
|
51132
52871
|
}
|
|
51133
|
-
function useTransition() {
|
|
51134
|
-
var dispatcher = resolveDispatcher();
|
|
51135
|
-
return dispatcher.useTransition();
|
|
51136
|
-
}
|
|
51137
|
-
function useDeferredValue(value) {
|
|
51138
|
-
var dispatcher = resolveDispatcher();
|
|
51139
|
-
return dispatcher.useDeferredValue(value);
|
|
51140
|
-
}
|
|
51141
|
-
function useId() {
|
|
51142
|
-
var dispatcher = resolveDispatcher();
|
|
51143
|
-
return dispatcher.useId();
|
|
51144
|
-
}
|
|
51145
|
-
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
51146
|
-
var dispatcher = resolveDispatcher();
|
|
51147
|
-
return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
51148
|
-
}
|
|
51149
52872
|
|
|
51150
52873
|
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
51151
52874
|
// replaying on render function. This currently only patches the object
|
|
@@ -51210,25 +52933,25 @@
|
|
|
51210
52933
|
}; // $FlowFixMe Flow thinks console is immutable.
|
|
51211
52934
|
|
|
51212
52935
|
Object.defineProperties(console, {
|
|
51213
|
-
log:
|
|
52936
|
+
log: _assign({}, props, {
|
|
51214
52937
|
value: prevLog
|
|
51215
52938
|
}),
|
|
51216
|
-
info:
|
|
52939
|
+
info: _assign({}, props, {
|
|
51217
52940
|
value: prevInfo
|
|
51218
52941
|
}),
|
|
51219
|
-
warn:
|
|
52942
|
+
warn: _assign({}, props, {
|
|
51220
52943
|
value: prevWarn
|
|
51221
52944
|
}),
|
|
51222
|
-
error:
|
|
52945
|
+
error: _assign({}, props, {
|
|
51223
52946
|
value: prevError
|
|
51224
52947
|
}),
|
|
51225
|
-
group:
|
|
52948
|
+
group: _assign({}, props, {
|
|
51226
52949
|
value: prevGroup
|
|
51227
52950
|
}),
|
|
51228
|
-
groupCollapsed:
|
|
52951
|
+
groupCollapsed: _assign({}, props, {
|
|
51229
52952
|
value: prevGroupCollapsed
|
|
51230
52953
|
}),
|
|
51231
|
-
groupEnd:
|
|
52954
|
+
groupEnd: _assign({}, props, {
|
|
51232
52955
|
value: prevGroupEnd
|
|
51233
52956
|
})
|
|
51234
52957
|
});
|
|
@@ -51269,7 +52992,7 @@
|
|
|
51269
52992
|
|
|
51270
52993
|
function describeNativeComponentFrame(fn, construct) {
|
|
51271
52994
|
// If something asked for a stack inside a fake render, it should get ignored.
|
|
51272
|
-
if (
|
|
52995
|
+
if (!fn || reentry) {
|
|
51273
52996
|
return '';
|
|
51274
52997
|
}
|
|
51275
52998
|
|
|
@@ -51378,14 +53101,7 @@
|
|
|
51378
53101
|
|
|
51379
53102
|
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
51380
53103
|
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
51381
|
-
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
|
|
51382
|
-
// but we have a user-provided "displayName"
|
|
51383
|
-
// splice it in to make the stack more readable.
|
|
51384
|
-
|
|
51385
|
-
|
|
51386
|
-
if (fn.displayName && _frame.includes('<anonymous>')) {
|
|
51387
|
-
_frame = _frame.replace('<anonymous>', fn.displayName);
|
|
51388
|
-
}
|
|
53104
|
+
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
|
|
51389
53105
|
|
|
51390
53106
|
{
|
|
51391
53107
|
if (typeof fn === 'function') {
|
|
@@ -51454,7 +53170,7 @@
|
|
|
51454
53170
|
}
|
|
51455
53171
|
|
|
51456
53172
|
switch (type) {
|
|
51457
|
-
case
|
|
53173
|
+
case exports.Suspense:
|
|
51458
53174
|
return describeBuiltInComponentFrame('Suspense');
|
|
51459
53175
|
|
|
51460
53176
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
@@ -51470,6 +53186,9 @@
|
|
|
51470
53186
|
// Memo may contain any component type so we recursively resolve it.
|
|
51471
53187
|
return describeUnknownElementTypeFrameInDEV(type.type);
|
|
51472
53188
|
|
|
53189
|
+
case REACT_BLOCK_TYPE:
|
|
53190
|
+
return describeFunctionComponentFrame(type._render);
|
|
53191
|
+
|
|
51473
53192
|
case REACT_LAZY_TYPE:
|
|
51474
53193
|
{
|
|
51475
53194
|
var lazyComponent = type;
|
|
@@ -51504,7 +53223,7 @@
|
|
|
51504
53223
|
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
51505
53224
|
{
|
|
51506
53225
|
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
51507
|
-
var has = Function.call.bind(hasOwnProperty);
|
|
53226
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
51508
53227
|
|
|
51509
53228
|
for (var typeSpecName in typeSpecs) {
|
|
51510
53229
|
if (has(typeSpecs, typeSpecName)) {
|
|
@@ -51516,7 +53235,6 @@
|
|
|
51516
53235
|
// This is intentionally an invariant that gets caught. It's the same
|
|
51517
53236
|
// behavior as without this statement except with a better message.
|
|
51518
53237
|
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
51519
|
-
// eslint-disable-next-line react-internal/prod-error-codes
|
|
51520
53238
|
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
51521
53239
|
err.name = 'Invariant Violation';
|
|
51522
53240
|
throw err;
|
|
@@ -51569,7 +53287,7 @@
|
|
|
51569
53287
|
|
|
51570
53288
|
function getDeclarationErrorAddendum() {
|
|
51571
53289
|
if (ReactCurrentOwner.current) {
|
|
51572
|
-
var name =
|
|
53290
|
+
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
51573
53291
|
|
|
51574
53292
|
if (name) {
|
|
51575
53293
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
@@ -51651,7 +53369,7 @@
|
|
|
51651
53369
|
|
|
51652
53370
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
51653
53371
|
// Give the component that originally created this child.
|
|
51654
|
-
childOwner = " It was passed a child from " +
|
|
53372
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
51655
53373
|
}
|
|
51656
53374
|
|
|
51657
53375
|
{
|
|
@@ -51678,7 +53396,7 @@
|
|
|
51678
53396
|
return;
|
|
51679
53397
|
}
|
|
51680
53398
|
|
|
51681
|
-
if (isArray(node)) {
|
|
53399
|
+
if (Array.isArray(node)) {
|
|
51682
53400
|
for (var i = 0; i < node.length; i++) {
|
|
51683
53401
|
var child = node[i];
|
|
51684
53402
|
|
|
@@ -51740,12 +53458,12 @@
|
|
|
51740
53458
|
|
|
51741
53459
|
if (propTypes) {
|
|
51742
53460
|
// Intentionally inside to avoid triggering lazy initializers:
|
|
51743
|
-
var name =
|
|
53461
|
+
var name = getComponentName(type);
|
|
51744
53462
|
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
51745
53463
|
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
51746
53464
|
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
51747
53465
|
|
|
51748
|
-
var _name =
|
|
53466
|
+
var _name = getComponentName(type);
|
|
51749
53467
|
|
|
51750
53468
|
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
51751
53469
|
}
|
|
@@ -51810,10 +53528,10 @@
|
|
|
51810
53528
|
|
|
51811
53529
|
if (type === null) {
|
|
51812
53530
|
typeString = 'null';
|
|
51813
|
-
} else if (isArray(type)) {
|
|
53531
|
+
} else if (Array.isArray(type)) {
|
|
51814
53532
|
typeString = 'array';
|
|
51815
53533
|
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
51816
|
-
typeString = "<" + (
|
|
53534
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
51817
53535
|
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
51818
53536
|
} else {
|
|
51819
53537
|
typeString = typeof type;
|
|
@@ -51842,7 +53560,7 @@
|
|
|
51842
53560
|
}
|
|
51843
53561
|
}
|
|
51844
53562
|
|
|
51845
|
-
if (type ===
|
|
53563
|
+
if (type === exports.Fragment) {
|
|
51846
53564
|
validateFragmentProps(element);
|
|
51847
53565
|
} else {
|
|
51848
53566
|
validatePropTypes(element);
|
|
@@ -51889,263 +53607,12 @@
|
|
|
51889
53607
|
return newElement;
|
|
51890
53608
|
}
|
|
51891
53609
|
|
|
51892
|
-
|
|
51893
|
-
var prevTransition = ReactCurrentBatchConfig.transition;
|
|
51894
|
-
ReactCurrentBatchConfig.transition = {};
|
|
51895
|
-
var currentTransition = ReactCurrentBatchConfig.transition;
|
|
51896
|
-
|
|
51897
|
-
{
|
|
51898
|
-
ReactCurrentBatchConfig.transition._updatedFibers = new Set();
|
|
51899
|
-
}
|
|
53610
|
+
{
|
|
51900
53611
|
|
|
51901
53612
|
try {
|
|
51902
|
-
|
|
51903
|
-
|
|
51904
|
-
|
|
51905
|
-
|
|
51906
|
-
{
|
|
51907
|
-
if (prevTransition === null && currentTransition._updatedFibers) {
|
|
51908
|
-
var updatedFibersCount = currentTransition._updatedFibers.size;
|
|
51909
|
-
|
|
51910
|
-
if (updatedFibersCount > 10) {
|
|
51911
|
-
warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
|
|
51912
|
-
}
|
|
51913
|
-
|
|
51914
|
-
currentTransition._updatedFibers.clear();
|
|
51915
|
-
}
|
|
51916
|
-
}
|
|
51917
|
-
}
|
|
51918
|
-
}
|
|
51919
|
-
|
|
51920
|
-
var didWarnAboutMessageChannel = false;
|
|
51921
|
-
var enqueueTaskImpl = null;
|
|
51922
|
-
function enqueueTask(task) {
|
|
51923
|
-
if (enqueueTaskImpl === null) {
|
|
51924
|
-
try {
|
|
51925
|
-
// read require off the module object to get around the bundlers.
|
|
51926
|
-
// we don't want them to detect a require and bundle a Node polyfill.
|
|
51927
|
-
var requireString = ('require' + Math.random()).slice(0, 7);
|
|
51928
|
-
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
|
|
51929
|
-
// version of setImmediate, bypassing fake timers if any.
|
|
51930
|
-
|
|
51931
|
-
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
|
51932
|
-
} catch (_err) {
|
|
51933
|
-
// we're in a browser
|
|
51934
|
-
// we can't use regular timers because they may still be faked
|
|
51935
|
-
// so we try MessageChannel+postMessage instead
|
|
51936
|
-
enqueueTaskImpl = function (callback) {
|
|
51937
|
-
{
|
|
51938
|
-
if (didWarnAboutMessageChannel === false) {
|
|
51939
|
-
didWarnAboutMessageChannel = true;
|
|
51940
|
-
|
|
51941
|
-
if (typeof MessageChannel === 'undefined') {
|
|
51942
|
-
error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
|
|
51943
|
-
}
|
|
51944
|
-
}
|
|
51945
|
-
}
|
|
51946
|
-
|
|
51947
|
-
var channel = new MessageChannel();
|
|
51948
|
-
channel.port1.onmessage = callback;
|
|
51949
|
-
channel.port2.postMessage(undefined);
|
|
51950
|
-
};
|
|
51951
|
-
}
|
|
51952
|
-
}
|
|
51953
|
-
|
|
51954
|
-
return enqueueTaskImpl(task);
|
|
51955
|
-
}
|
|
51956
|
-
|
|
51957
|
-
var actScopeDepth = 0;
|
|
51958
|
-
var didWarnNoAwaitAct = false;
|
|
51959
|
-
function act(callback) {
|
|
51960
|
-
{
|
|
51961
|
-
// `act` calls can be nested, so we track the depth. This represents the
|
|
51962
|
-
// number of `act` scopes on the stack.
|
|
51963
|
-
var prevActScopeDepth = actScopeDepth;
|
|
51964
|
-
actScopeDepth++;
|
|
51965
|
-
|
|
51966
|
-
if (ReactCurrentActQueue.current === null) {
|
|
51967
|
-
// This is the outermost `act` scope. Initialize the queue. The reconciler
|
|
51968
|
-
// will detect the queue and use it instead of Scheduler.
|
|
51969
|
-
ReactCurrentActQueue.current = [];
|
|
51970
|
-
}
|
|
51971
|
-
|
|
51972
|
-
var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
|
|
51973
|
-
var result;
|
|
51974
|
-
|
|
51975
|
-
try {
|
|
51976
|
-
// Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
|
|
51977
|
-
// set to `true` while the given callback is executed, not for updates
|
|
51978
|
-
// triggered during an async event, because this is how the legacy
|
|
51979
|
-
// implementation of `act` behaved.
|
|
51980
|
-
ReactCurrentActQueue.isBatchingLegacy = true;
|
|
51981
|
-
result = callback(); // Replicate behavior of original `act` implementation in legacy mode,
|
|
51982
|
-
// which flushed updates immediately after the scope function exits, even
|
|
51983
|
-
// if it's an async function.
|
|
51984
|
-
|
|
51985
|
-
if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
|
|
51986
|
-
var queue = ReactCurrentActQueue.current;
|
|
51987
|
-
|
|
51988
|
-
if (queue !== null) {
|
|
51989
|
-
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
|
|
51990
|
-
flushActQueue(queue);
|
|
51991
|
-
}
|
|
51992
|
-
}
|
|
51993
|
-
} catch (error) {
|
|
51994
|
-
popActScope(prevActScopeDepth);
|
|
51995
|
-
throw error;
|
|
51996
|
-
} finally {
|
|
51997
|
-
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
|
|
51998
|
-
}
|
|
51999
|
-
|
|
52000
|
-
if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
|
|
52001
|
-
var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait
|
|
52002
|
-
// for it to resolve before exiting the current scope.
|
|
52003
|
-
|
|
52004
|
-
var wasAwaited = false;
|
|
52005
|
-
var thenable = {
|
|
52006
|
-
then: function (resolve, reject) {
|
|
52007
|
-
wasAwaited = true;
|
|
52008
|
-
thenableResult.then(function (returnValue) {
|
|
52009
|
-
popActScope(prevActScopeDepth);
|
|
52010
|
-
|
|
52011
|
-
if (actScopeDepth === 0) {
|
|
52012
|
-
// We've exited the outermost act scope. Recursively flush the
|
|
52013
|
-
// queue until there's no remaining work.
|
|
52014
|
-
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
52015
|
-
} else {
|
|
52016
|
-
resolve(returnValue);
|
|
52017
|
-
}
|
|
52018
|
-
}, function (error) {
|
|
52019
|
-
// The callback threw an error.
|
|
52020
|
-
popActScope(prevActScopeDepth);
|
|
52021
|
-
reject(error);
|
|
52022
|
-
});
|
|
52023
|
-
}
|
|
52024
|
-
};
|
|
52025
|
-
|
|
52026
|
-
{
|
|
52027
|
-
if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {
|
|
52028
|
-
// eslint-disable-next-line no-undef
|
|
52029
|
-
Promise.resolve().then(function () {}).then(function () {
|
|
52030
|
-
if (!wasAwaited) {
|
|
52031
|
-
didWarnNoAwaitAct = true;
|
|
52032
|
-
|
|
52033
|
-
error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');
|
|
52034
|
-
}
|
|
52035
|
-
});
|
|
52036
|
-
}
|
|
52037
|
-
}
|
|
52038
|
-
|
|
52039
|
-
return thenable;
|
|
52040
|
-
} else {
|
|
52041
|
-
var returnValue = result; // The callback is not an async function. Exit the current scope
|
|
52042
|
-
// immediately, without awaiting.
|
|
52043
|
-
|
|
52044
|
-
popActScope(prevActScopeDepth);
|
|
52045
|
-
|
|
52046
|
-
if (actScopeDepth === 0) {
|
|
52047
|
-
// Exiting the outermost act scope. Flush the queue.
|
|
52048
|
-
var _queue = ReactCurrentActQueue.current;
|
|
52049
|
-
|
|
52050
|
-
if (_queue !== null) {
|
|
52051
|
-
flushActQueue(_queue);
|
|
52052
|
-
ReactCurrentActQueue.current = null;
|
|
52053
|
-
} // Return a thenable. If the user awaits it, we'll flush again in
|
|
52054
|
-
// case additional work was scheduled by a microtask.
|
|
52055
|
-
|
|
52056
|
-
|
|
52057
|
-
var _thenable = {
|
|
52058
|
-
then: function (resolve, reject) {
|
|
52059
|
-
// Confirm we haven't re-entered another `act` scope, in case
|
|
52060
|
-
// the user does something weird like await the thenable
|
|
52061
|
-
// multiple times.
|
|
52062
|
-
if (ReactCurrentActQueue.current === null) {
|
|
52063
|
-
// Recursively flush the queue until there's no remaining work.
|
|
52064
|
-
ReactCurrentActQueue.current = [];
|
|
52065
|
-
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
52066
|
-
} else {
|
|
52067
|
-
resolve(returnValue);
|
|
52068
|
-
}
|
|
52069
|
-
}
|
|
52070
|
-
};
|
|
52071
|
-
return _thenable;
|
|
52072
|
-
} else {
|
|
52073
|
-
// Since we're inside a nested `act` scope, the returned thenable
|
|
52074
|
-
// immediately resolves. The outer scope will flush the queue.
|
|
52075
|
-
var _thenable2 = {
|
|
52076
|
-
then: function (resolve, reject) {
|
|
52077
|
-
resolve(returnValue);
|
|
52078
|
-
}
|
|
52079
|
-
};
|
|
52080
|
-
return _thenable2;
|
|
52081
|
-
}
|
|
52082
|
-
}
|
|
52083
|
-
}
|
|
52084
|
-
}
|
|
52085
|
-
|
|
52086
|
-
function popActScope(prevActScopeDepth) {
|
|
52087
|
-
{
|
|
52088
|
-
if (prevActScopeDepth !== actScopeDepth - 1) {
|
|
52089
|
-
error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
|
52090
|
-
}
|
|
52091
|
-
|
|
52092
|
-
actScopeDepth = prevActScopeDepth;
|
|
52093
|
-
}
|
|
52094
|
-
}
|
|
52095
|
-
|
|
52096
|
-
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
52097
|
-
{
|
|
52098
|
-
var queue = ReactCurrentActQueue.current;
|
|
52099
|
-
|
|
52100
|
-
if (queue !== null) {
|
|
52101
|
-
try {
|
|
52102
|
-
flushActQueue(queue);
|
|
52103
|
-
enqueueTask(function () {
|
|
52104
|
-
if (queue.length === 0) {
|
|
52105
|
-
// No additional work was scheduled. Finish.
|
|
52106
|
-
ReactCurrentActQueue.current = null;
|
|
52107
|
-
resolve(returnValue);
|
|
52108
|
-
} else {
|
|
52109
|
-
// Keep flushing work until there's none left.
|
|
52110
|
-
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
52111
|
-
}
|
|
52112
|
-
});
|
|
52113
|
-
} catch (error) {
|
|
52114
|
-
reject(error);
|
|
52115
|
-
}
|
|
52116
|
-
} else {
|
|
52117
|
-
resolve(returnValue);
|
|
52118
|
-
}
|
|
52119
|
-
}
|
|
52120
|
-
}
|
|
52121
|
-
|
|
52122
|
-
var isFlushing = false;
|
|
52123
|
-
|
|
52124
|
-
function flushActQueue(queue) {
|
|
52125
|
-
{
|
|
52126
|
-
if (!isFlushing) {
|
|
52127
|
-
// Prevent re-entrance.
|
|
52128
|
-
isFlushing = true;
|
|
52129
|
-
var i = 0;
|
|
52130
|
-
|
|
52131
|
-
try {
|
|
52132
|
-
for (; i < queue.length; i++) {
|
|
52133
|
-
var callback = queue[i];
|
|
52134
|
-
|
|
52135
|
-
do {
|
|
52136
|
-
callback = callback(true);
|
|
52137
|
-
} while (callback !== null);
|
|
52138
|
-
}
|
|
52139
|
-
|
|
52140
|
-
queue.length = 0;
|
|
52141
|
-
} catch (error) {
|
|
52142
|
-
// If something throws, leave the remaining callbacks on the queue.
|
|
52143
|
-
queue = queue.slice(i + 1);
|
|
52144
|
-
throw error;
|
|
52145
|
-
} finally {
|
|
52146
|
-
isFlushing = false;
|
|
52147
|
-
}
|
|
52148
|
-
}
|
|
53613
|
+
Object.freeze({});
|
|
53614
|
+
/* eslint-enable no-new */
|
|
53615
|
+
} catch (e) {
|
|
52149
53616
|
}
|
|
52150
53617
|
}
|
|
52151
53618
|
|
|
@@ -52162,11 +53629,7 @@
|
|
|
52162
53629
|
|
|
52163
53630
|
exports.Children = Children;
|
|
52164
53631
|
exports.Component = Component;
|
|
52165
|
-
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
52166
|
-
exports.Profiler = REACT_PROFILER_TYPE;
|
|
52167
53632
|
exports.PureComponent = PureComponent;
|
|
52168
|
-
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
52169
|
-
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
52170
53633
|
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
|
|
52171
53634
|
exports.cloneElement = cloneElement$1;
|
|
52172
53635
|
exports.createContext = createContext;
|
|
@@ -52177,33 +53640,17 @@
|
|
|
52177
53640
|
exports.isValidElement = isValidElement;
|
|
52178
53641
|
exports.lazy = lazy;
|
|
52179
53642
|
exports.memo = memo;
|
|
52180
|
-
exports.startTransition = startTransition;
|
|
52181
|
-
exports.unstable_act = act;
|
|
52182
53643
|
exports.useCallback = useCallback;
|
|
52183
53644
|
exports.useContext = useContext;
|
|
52184
53645
|
exports.useDebugValue = useDebugValue;
|
|
52185
|
-
exports.useDeferredValue = useDeferredValue;
|
|
52186
53646
|
exports.useEffect = useEffect;
|
|
52187
|
-
exports.useId = useId;
|
|
52188
53647
|
exports.useImperativeHandle = useImperativeHandle;
|
|
52189
|
-
exports.useInsertionEffect = useInsertionEffect;
|
|
52190
53648
|
exports.useLayoutEffect = useLayoutEffect;
|
|
52191
53649
|
exports.useMemo = useMemo;
|
|
52192
53650
|
exports.useReducer = useReducer;
|
|
52193
53651
|
exports.useRef = useRef;
|
|
52194
53652
|
exports.useState = useState;
|
|
52195
|
-
exports.useSyncExternalStore = useSyncExternalStore;
|
|
52196
|
-
exports.useTransition = useTransition;
|
|
52197
53653
|
exports.version = ReactVersion;
|
|
52198
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
52199
|
-
if (
|
|
52200
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
52201
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
52202
|
-
'function'
|
|
52203
|
-
) {
|
|
52204
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
52205
|
-
}
|
|
52206
|
-
|
|
52207
53654
|
})();
|
|
52208
53655
|
}
|
|
52209
53656
|
});
|
|
@@ -52225,6 +53672,7 @@
|
|
|
52225
53672
|
function createLiveReact(options) {
|
|
52226
53673
|
const LiveContext = React.createContext(null);
|
|
52227
53674
|
const live = createLive(options);
|
|
53675
|
+
const jsBridge = live.jsBridge;
|
|
52228
53676
|
function LiveProvider(props) {
|
|
52229
53677
|
return (React.createElement(LiveContext.Provider, { value: props.live || live }, props.children));
|
|
52230
53678
|
}
|
|
@@ -52420,6 +53868,7 @@
|
|
|
52420
53868
|
}
|
|
52421
53869
|
return {
|
|
52422
53870
|
live,
|
|
53871
|
+
jsBridge,
|
|
52423
53872
|
LiveProvider,
|
|
52424
53873
|
unsafe__useLiveInstance,
|
|
52425
53874
|
unsafe__useRTCInstance,
|