@byteplus/react-native-live-pull 1.0.3-rc.1 → 1.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/AndroidManifest.xml +7 -1
- package/android/src/main/AndroidManifestNew.xml +15 -1
- package/android/src/main/java/com/volcengine/velive/rn/pull/VolcLiveModule.java +28 -20
- package/android/src/main/java/com/volcengine/velive/rn/pull/VolcView.java +7 -8
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/FloatingWindowHelper.java +224 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/FloatingWindowService.java +198 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/IFloatingWindowHelper.java +80 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/PictureInPictureManager.java +257 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/pictureInpicture/VeLiveRefManager.java +119 -0
- package/android/src/main/res/drawable/button_close.xml +9 -0
- package/android/src/main/res/drawable/new_window.xml +16 -0
- package/android/src/main/res/layout/floating_window_layout.xml +29 -0
- package/ios/VeLivePlayerMultiObserver.h +54 -0
- package/ios/VeLivePlayerMultiObserver.m +324 -0
- package/ios/pictureInpicture/PictureInPictureManager.h +29 -0
- package/ios/pictureInpicture/PictureInPictureManager.m +274 -0
- package/ios/pictureInpicture/VeLivePictureInPictureController.h +207 -0
- package/ios/pictureInpicture/VeLivePictureInPictureController.m +3393 -0
- package/lib/commonjs/index.js +1690 -1955
- package/lib/module/index.js +1690 -1955
- package/lib/typescript/codegen/pack/errorcode.d.ts +24 -24
- package/lib/typescript/codegen/pack/types.d.ts +1 -1
- package/lib/typescript/core/api.d.ts +88 -1
- package/lib/typescript/core/callback.d.ts +52 -0
- package/lib/typescript/platforms/android/extends.d.ts +1 -1
- package/lib/typescript/platforms/android/pictureInpicture.d.ts +26 -0
- package/lib/typescript/platforms/ios/pictureInpicture.d.ts +32 -0
- package/package.json +1 -1
package/lib/commonjs/index.js
CHANGED
|
@@ -274,162 +274,27 @@ const gBase64 = {
|
|
|
274
274
|
extendBuiltins: extendBuiltins
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
(_a = Symbol.metadata) !== null && _a !== void 0 ? _a : (Symbol.metadata = Symbol('Symbol.metadata'));
|
|
277
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol('Symbol.metadata'));
|
|
279
278
|
|
|
280
|
-
|
|
281
|
-
Copyright (c) Microsoft Corporation.
|
|
282
|
-
|
|
283
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
284
|
-
purpose with or without fee is hereby granted.
|
|
285
|
-
|
|
286
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
287
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
288
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
289
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
290
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
291
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
292
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
293
|
-
***************************************************************************** */
|
|
294
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
295
|
-
|
|
296
|
-
var extendStatics$1 = function(d, b) {
|
|
297
|
-
extendStatics$1 = Object.setPrototypeOf ||
|
|
298
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
299
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
300
|
-
return extendStatics$1(d, b);
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
function __extends$1(d, b) {
|
|
304
|
-
if (typeof b !== "function" && b !== null)
|
|
305
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
306
|
-
extendStatics$1(d, b);
|
|
307
|
-
function __() { this.constructor = d; }
|
|
308
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function __esDecorate$1(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
312
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
313
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
314
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
315
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
316
|
-
var _, done = false;
|
|
317
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
318
|
-
var context = {};
|
|
319
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
320
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
321
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
322
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
323
|
-
if (kind === "accessor") {
|
|
324
|
-
if (result === void 0) continue;
|
|
325
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
326
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
327
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
328
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
329
|
-
}
|
|
330
|
-
else if (_ = accept(result)) {
|
|
331
|
-
if (kind === "field") initializers.unshift(_);
|
|
332
|
-
else descriptor[key] = _;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
336
|
-
done = true;
|
|
337
|
-
}
|
|
338
|
-
function __runInitializers$1(thisArg, initializers, value) {
|
|
339
|
-
var useValue = arguments.length > 2;
|
|
340
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
341
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
342
|
-
}
|
|
343
|
-
return useValue ? value : void 0;
|
|
344
|
-
}
|
|
345
|
-
function __setFunctionName$1(f, name, prefix) {
|
|
346
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
347
|
-
return Object.defineProperty(f, "name", { configurable: true, value: name });
|
|
348
|
-
}
|
|
349
|
-
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
350
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
351
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
352
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
353
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
354
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
355
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function __generator$1(thisArg, body) {
|
|
360
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
361
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
362
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
363
|
-
function step(op) {
|
|
364
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
365
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
366
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
367
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
368
|
-
switch (op[0]) {
|
|
369
|
-
case 0: case 1: t = op; break;
|
|
370
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
371
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
372
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
373
|
-
default:
|
|
374
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
375
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
376
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
377
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
378
|
-
if (t[2]) _.ops.pop();
|
|
379
|
-
_.trys.pop(); continue;
|
|
380
|
-
}
|
|
381
|
-
op = body.call(thisArg, _);
|
|
382
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
383
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function __spreadArray$1(to, from, pack) {
|
|
388
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
389
|
-
if (ar || !(i in from)) {
|
|
390
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
391
|
-
ar[i] = from[i];
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
398
|
-
var e = new Error(message);
|
|
399
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
var DISABLE_INIT = Symbol();
|
|
279
|
+
const DISABLE_INIT = Symbol();
|
|
403
280
|
function PackClass() {
|
|
404
|
-
return
|
|
405
|
-
return
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
args[_i] = arguments[_i];
|
|
411
|
-
}
|
|
412
|
-
var _this = _super.apply(this, args) || this;
|
|
413
|
-
var _init = function () {
|
|
414
|
-
var _a, _b;
|
|
415
|
-
(_b = (_a = _this).__init) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray$1([_a], args, false));
|
|
281
|
+
return (target, ctx) => {
|
|
282
|
+
return class extends target {
|
|
283
|
+
constructor(...args) {
|
|
284
|
+
super(...args);
|
|
285
|
+
const _init = () => {
|
|
286
|
+
this.__init?.(...args);
|
|
416
287
|
};
|
|
417
|
-
|
|
288
|
+
const isDisableInit = args.includes(DISABLE_INIT);
|
|
418
289
|
if (!isDisableInit) {
|
|
419
290
|
_init();
|
|
420
291
|
}
|
|
421
|
-
Object.defineProperty(
|
|
292
|
+
Object.defineProperty(this, '$$pack', {
|
|
422
293
|
value: true,
|
|
423
294
|
enumerable: false,
|
|
424
295
|
});
|
|
425
|
-
return _this;
|
|
426
296
|
}
|
|
427
|
-
|
|
428
|
-
var _a, _b;
|
|
429
|
-
(_b = (_a = this._instance).__destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
430
|
-
};
|
|
431
|
-
return class_1;
|
|
432
|
-
}(target));
|
|
297
|
+
};
|
|
433
298
|
};
|
|
434
299
|
}
|
|
435
300
|
|
|
@@ -444,7 +309,7 @@ function packObject(receiver, ctor) {
|
|
|
444
309
|
if (isPrimateValue(receiver)) {
|
|
445
310
|
return receiver;
|
|
446
311
|
}
|
|
447
|
-
|
|
312
|
+
const ins = new ctor(DISABLE_INIT);
|
|
448
313
|
Object.defineProperty(ins, '_instance', {
|
|
449
314
|
value: receiver,
|
|
450
315
|
enumerable: false,
|
|
@@ -459,7 +324,7 @@ function unpackObject(proxyInstance, _nativeClass) {
|
|
|
459
324
|
}
|
|
460
325
|
|
|
461
326
|
function findProto(ctor, name) {
|
|
462
|
-
|
|
327
|
+
let proto = ctor.prototype;
|
|
463
328
|
while (proto) {
|
|
464
329
|
if (Object.getOwnPropertyDescriptor(proto, name)) {
|
|
465
330
|
return proto;
|
|
@@ -468,27 +333,33 @@ function findProto(ctor, name) {
|
|
|
468
333
|
}
|
|
469
334
|
return undefined;
|
|
470
335
|
}
|
|
336
|
+
function extendsClassMethod(ctor, methodName, overrideFn) {
|
|
337
|
+
const proto = ctor.prototype;
|
|
338
|
+
const originalFn = ctor.prototype[methodName];
|
|
339
|
+
proto[methodName] = function (...args) {
|
|
340
|
+
return overrideFn(originalFn?.bind(this)).apply(this, args);
|
|
341
|
+
};
|
|
342
|
+
}
|
|
471
343
|
function extendsClassMember(ctor, memberName) {
|
|
472
|
-
return
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
var originalDesc = targetProto
|
|
344
|
+
return (handler) => {
|
|
345
|
+
const targetProto = findProto(ctor, memberName);
|
|
346
|
+
const originalDesc = targetProto
|
|
476
347
|
? Object.getOwnPropertyDescriptor(targetProto, memberName)
|
|
477
348
|
: undefined;
|
|
478
|
-
|
|
479
|
-
getter: originalDesc
|
|
480
|
-
setter: originalDesc
|
|
349
|
+
const newDesc = handler({
|
|
350
|
+
getter: originalDesc?.get,
|
|
351
|
+
setter: originalDesc?.set,
|
|
481
352
|
});
|
|
482
353
|
Object.defineProperty(ctor.prototype, memberName, {
|
|
483
|
-
enumerable:
|
|
484
|
-
configurable:
|
|
485
|
-
get: newDesc.getter ||
|
|
486
|
-
set: newDesc.setter ||
|
|
354
|
+
enumerable: originalDesc?.enumerable ?? true,
|
|
355
|
+
configurable: originalDesc?.configurable ?? true,
|
|
356
|
+
get: newDesc.getter || originalDesc?.get,
|
|
357
|
+
set: newDesc.setter || originalDesc?.set,
|
|
487
358
|
});
|
|
488
359
|
};
|
|
489
360
|
}
|
|
490
361
|
|
|
491
|
-
|
|
362
|
+
let impl;
|
|
492
363
|
function setupEnv(e) {
|
|
493
364
|
impl = e;
|
|
494
365
|
}
|
|
@@ -506,11 +377,10 @@ var env = /*#__PURE__*/Object.freeze({
|
|
|
506
377
|
setupEnv: setupEnv
|
|
507
378
|
});
|
|
508
379
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
var prefix = namespace.slice(0, 24);
|
|
380
|
+
const SIZE = 32;
|
|
381
|
+
const getUuid = (namespace = '') => {
|
|
382
|
+
const random = String(Math.random()).slice(2);
|
|
383
|
+
const prefix = namespace.slice(0, 24);
|
|
514
384
|
return '@js#' + prefix + '#' + random.slice(0, SIZE - prefix.length - 1);
|
|
515
385
|
};
|
|
516
386
|
|
|
@@ -561,10 +431,6 @@ var CALL_TYPE$1;
|
|
|
561
431
|
* 事件执行后的返回值
|
|
562
432
|
*/
|
|
563
433
|
CALL_TYPE["INSTANCE_EVENT_RESULT"] = "instance_event_result";
|
|
564
|
-
/**
|
|
565
|
-
* 销毁实例
|
|
566
|
-
*/
|
|
567
|
-
CALL_TYPE["DESTROY_INSTANCE"] = "destroy_instance";
|
|
568
434
|
/**
|
|
569
435
|
* 触发事件
|
|
570
436
|
*/
|
|
@@ -576,82 +442,133 @@ var RETURN_STATUS$1;
|
|
|
576
442
|
RETURN_STATUS["FAILED"] = "failed";
|
|
577
443
|
RETURN_STATUS["NOT_IMPLEMENTED"] = "not_implemented";
|
|
578
444
|
})(RETURN_STATUS$1 || (RETURN_STATUS$1 = {}));
|
|
579
|
-
var INSTANCE_TYPE$1;
|
|
580
|
-
(function (INSTANCE_TYPE) {
|
|
581
|
-
/**
|
|
582
|
-
* 自动 GC 类型
|
|
583
|
-
*/
|
|
584
|
-
INSTANCE_TYPE[INSTANCE_TYPE["AUTOMATIC"] = 0] = "AUTOMATIC";
|
|
585
|
-
/**
|
|
586
|
-
* 手动 GC 类型
|
|
587
|
-
*/
|
|
588
|
-
INSTANCE_TYPE[INSTANCE_TYPE["MANUAL"] = 1] = "MANUAL";
|
|
589
|
-
})(INSTANCE_TYPE$1 || (INSTANCE_TYPE$1 = {}));
|
|
590
445
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
DefaultBridgeImpl.prototype.call = function () {
|
|
595
|
-
return new Promise(function (resolve, reject) {
|
|
446
|
+
class DefaultBridgeImpl {
|
|
447
|
+
call() {
|
|
448
|
+
return new Promise((resolve, reject) => {
|
|
596
449
|
resolve({
|
|
597
450
|
status: 'success',
|
|
598
451
|
msg: null,
|
|
599
452
|
});
|
|
600
453
|
});
|
|
601
|
-
}
|
|
602
|
-
|
|
454
|
+
}
|
|
455
|
+
callSync() {
|
|
603
456
|
return {
|
|
604
457
|
status: 'success',
|
|
605
458
|
msg: null,
|
|
606
459
|
};
|
|
607
|
-
}
|
|
608
|
-
|
|
460
|
+
}
|
|
461
|
+
registerHandler(handlerName, handler) {
|
|
609
462
|
// dsBridge.register(handlerName, handler);
|
|
610
|
-
}
|
|
611
|
-
|
|
463
|
+
}
|
|
464
|
+
registerAsyncHandler(handlerName, handler) {
|
|
612
465
|
//
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
}());
|
|
466
|
+
}
|
|
467
|
+
}
|
|
616
468
|
|
|
617
|
-
|
|
469
|
+
const createJSBridge = () => {
|
|
618
470
|
return new DefaultBridgeImpl();
|
|
619
471
|
};
|
|
620
472
|
|
|
473
|
+
/******************************************************************************
|
|
474
|
+
Copyright (c) Microsoft Corporation.
|
|
475
|
+
|
|
476
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
477
|
+
purpose with or without fee is hereby granted.
|
|
478
|
+
|
|
479
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
480
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
481
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
482
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
483
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
484
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
485
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
486
|
+
***************************************************************************** */
|
|
487
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
function __esDecorate$1(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
491
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
492
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
493
|
+
var target = ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
494
|
+
var descriptor = (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
495
|
+
var _, done = false;
|
|
496
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
497
|
+
var context = {};
|
|
498
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
499
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
500
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
501
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
502
|
+
if (kind === "accessor") {
|
|
503
|
+
if (result === void 0) continue;
|
|
504
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
505
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
506
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
507
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
508
|
+
}
|
|
509
|
+
else if (_ = accept(result)) {
|
|
510
|
+
if (kind === "field") initializers.unshift(_);
|
|
511
|
+
else descriptor[key] = _;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
515
|
+
done = true;
|
|
516
|
+
}
|
|
517
|
+
function __runInitializers$1(thisArg, initializers, value) {
|
|
518
|
+
var useValue = arguments.length > 2;
|
|
519
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
520
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
521
|
+
}
|
|
522
|
+
return useValue ? value : void 0;
|
|
523
|
+
}
|
|
524
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
525
|
+
var e = new Error(message);
|
|
526
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
527
|
+
};
|
|
528
|
+
|
|
621
529
|
function assert(expression, msg) {
|
|
622
530
|
if (!expression) {
|
|
623
531
|
throw new Error(msg);
|
|
624
532
|
}
|
|
625
533
|
}
|
|
626
534
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
};
|
|
630
|
-
var isInstance = function (value) {
|
|
535
|
+
const isArray = (value) => Array.isArray(value);
|
|
536
|
+
const isInstance = (value) => {
|
|
631
537
|
if (typeof value !== 'object' || value === null) {
|
|
632
538
|
return false;
|
|
633
539
|
}
|
|
634
540
|
if ('instanceId' in value || '_instanceId' in value) {
|
|
635
541
|
return true;
|
|
636
542
|
}
|
|
637
|
-
|
|
543
|
+
const proto = Object.getPrototypeOf(value);
|
|
638
544
|
return (!!proto &&
|
|
639
545
|
proto.constructor.name !== 'Array' &&
|
|
640
546
|
proto.constructor.name !== 'Object');
|
|
641
547
|
};
|
|
642
|
-
|
|
548
|
+
const isCallback = (value) => {
|
|
643
549
|
return typeof value === 'function';
|
|
644
550
|
};
|
|
645
|
-
|
|
551
|
+
const isPlainObject = (value) => {
|
|
646
552
|
return typeof value === 'object' && value !== null;
|
|
647
553
|
};
|
|
648
|
-
|
|
554
|
+
const isInstanceArg = (value) => {
|
|
649
555
|
return (isPlainObject(value) && value._type === "instance" /* ARG_TYPE.INSTANCE */);
|
|
650
556
|
};
|
|
651
557
|
|
|
558
|
+
function safeStringify(val) {
|
|
559
|
+
try {
|
|
560
|
+
if (val instanceof Error) {
|
|
561
|
+
return `Error: ${val.message}`;
|
|
562
|
+
}
|
|
563
|
+
return JSON.stringify(val);
|
|
564
|
+
}
|
|
565
|
+
catch (er) {
|
|
566
|
+
return String(val);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
652
570
|
function fromPairs(entries) {
|
|
653
|
-
return entries.reduce(
|
|
654
|
-
var k = _a[0], v = _a[1];
|
|
571
|
+
return entries.reduce((acc, [k, v]) => {
|
|
655
572
|
acc[k] = v;
|
|
656
573
|
return acc;
|
|
657
574
|
}, {});
|
|
@@ -660,32 +577,17 @@ function toPairs(obj) {
|
|
|
660
577
|
return Object.entries(obj);
|
|
661
578
|
}
|
|
662
579
|
function mapValues(data, fn) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
var k = _a[0], v = _a[1];
|
|
666
|
-
return [k, fn(v, k)];
|
|
667
|
-
});
|
|
580
|
+
const paris = toPairs(data);
|
|
581
|
+
const mappedPairs = paris.map(([k, v]) => [k, fn(v, k)]);
|
|
668
582
|
return fromPairs(mappedPairs);
|
|
669
583
|
}
|
|
670
584
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
?
|
|
674
|
-
: isInstanceArg(instanceOrId)
|
|
675
|
-
? instanceOrId._instanceId
|
|
676
|
-
: undefined;
|
|
677
|
-
if (!id) {
|
|
678
|
-
throw new Error('instanceOrId is not an instance');
|
|
679
|
-
}
|
|
680
|
-
return id;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
var keyPathVisitor = function (obj, path, defaultValue) {
|
|
684
|
-
var getResult = obj
|
|
685
|
-
? path.reduce(function (pre, next) {
|
|
585
|
+
const keyPathVisitor = (obj, path, defaultValue) => {
|
|
586
|
+
const getResult = obj
|
|
587
|
+
? path.reduce((pre, next) => {
|
|
686
588
|
if (pre && pre !== defaultValue) {
|
|
687
|
-
|
|
688
|
-
|
|
589
|
+
const preValue = pre;
|
|
590
|
+
const nextvalue = preValue[next];
|
|
689
591
|
return !nextvalue ? defaultValue : nextvalue;
|
|
690
592
|
}
|
|
691
593
|
return defaultValue;
|
|
@@ -694,9 +596,9 @@ var keyPathVisitor = function (obj, path, defaultValue) {
|
|
|
694
596
|
return getResult;
|
|
695
597
|
};
|
|
696
598
|
|
|
697
|
-
|
|
599
|
+
const Bind = (target, context) => {
|
|
698
600
|
context.addInitializer(function () {
|
|
699
|
-
|
|
601
|
+
const fnName = context.name;
|
|
700
602
|
this[fnName] = this[fnName].bind(this);
|
|
701
603
|
});
|
|
702
604
|
return target;
|
|
@@ -704,1061 +606,340 @@ var Bind = function (target, context) {
|
|
|
704
606
|
|
|
705
607
|
var LogLevel;
|
|
706
608
|
(function (LogLevel) {
|
|
707
|
-
LogLevel[LogLevel["
|
|
708
|
-
LogLevel[LogLevel["
|
|
709
|
-
LogLevel[LogLevel["
|
|
710
|
-
LogLevel[LogLevel["
|
|
711
|
-
LogLevel[LogLevel["
|
|
609
|
+
LogLevel[LogLevel["verbose"] = 0] = "verbose";
|
|
610
|
+
LogLevel[LogLevel["debug"] = 1] = "debug";
|
|
611
|
+
LogLevel[LogLevel["info"] = 2] = "info";
|
|
612
|
+
LogLevel[LogLevel["warn"] = 3] = "warn";
|
|
613
|
+
LogLevel[LogLevel["error"] = 4] = "error";
|
|
712
614
|
})(LogLevel || (LogLevel = {}));
|
|
713
615
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this.
|
|
616
|
+
class LoggerImpl {
|
|
617
|
+
constructor() {
|
|
618
|
+
this._enablePrintVerbose = false;
|
|
717
619
|
this._consumers = [];
|
|
718
620
|
}
|
|
719
|
-
|
|
720
|
-
if (!LoggerImpl.instance) {
|
|
721
|
-
LoggerImpl.instance = new LoggerImpl();
|
|
722
|
-
}
|
|
723
|
-
return LoggerImpl.instance;
|
|
724
|
-
};
|
|
725
|
-
LoggerImpl.prototype.init = function (opt) {
|
|
621
|
+
init(opt) {
|
|
726
622
|
this.options = opt;
|
|
727
|
-
if (opt.logLevel) {
|
|
728
|
-
this._logLevel = opt.logLevel;
|
|
729
|
-
}
|
|
730
|
-
};
|
|
731
|
-
LoggerImpl.prototype.setLogLevel = function (level) {
|
|
732
|
-
this._logLevel = level;
|
|
733
|
-
};
|
|
734
|
-
LoggerImpl.prototype.registerConsumer = function (consumer) {
|
|
735
|
-
this._consumers.push(consumer);
|
|
736
|
-
};
|
|
737
|
-
LoggerImpl.prototype._shouldLog = function (level) {
|
|
738
|
-
return level >= this._logLevel;
|
|
739
|
-
};
|
|
740
|
-
LoggerImpl.prototype._formatMessage = function (args) {
|
|
741
|
-
try {
|
|
742
|
-
var message = args
|
|
743
|
-
.map(function (arg) {
|
|
744
|
-
if (typeof arg === 'object') {
|
|
745
|
-
return JSON.stringify(arg, null, 2);
|
|
746
|
-
}
|
|
747
|
-
return String(arg);
|
|
748
|
-
})
|
|
749
|
-
.join(' ');
|
|
750
|
-
if (message.length > LoggerImpl.MAX_LOG_LENGTH) {
|
|
751
|
-
return message.substring(0, LoggerImpl.MAX_LOG_LENGTH);
|
|
752
|
-
}
|
|
753
|
-
return message;
|
|
754
|
-
}
|
|
755
|
-
catch (e) {
|
|
756
|
-
if (e instanceof Error) {
|
|
757
|
-
return "[Format Error] ".concat(args.join(' '), " - ").concat(e.message);
|
|
758
|
-
}
|
|
759
|
-
return "[Format Error] ".concat(args.join(' '));
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
LoggerImpl.prototype._formatDate = function (date) {
|
|
763
|
-
var pad = function (n) { return (n < 10 ? '0' + n : n); };
|
|
764
|
-
return "".concat(pad(date.getHours()), ":").concat(pad(date.getMinutes()), ":").concat(pad(date.getSeconds()));
|
|
765
|
-
};
|
|
766
|
-
LoggerImpl.prototype._getCurrentTimestamp = function () {
|
|
767
|
-
return this._formatDate(new Date());
|
|
768
|
-
};
|
|
769
|
-
LoggerImpl.prototype._log = function (level, args) {
|
|
770
|
-
var _this = this;
|
|
771
|
-
if (!this._shouldLog(level)) {
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
var timestamp = this._getCurrentTimestamp();
|
|
775
|
-
var message = this._formatMessage(args);
|
|
776
|
-
var logMsg = {
|
|
777
|
-
level: level,
|
|
778
|
-
content: ["".concat(timestamp, " ").concat(message)],
|
|
779
|
-
};
|
|
780
|
-
// 发送给消费者
|
|
781
|
-
this._consumers.forEach(function (c) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
782
|
-
return __generator$1(this, function (_a) {
|
|
783
|
-
switch (_a.label) {
|
|
784
|
-
case 0:
|
|
785
|
-
_a.trys.push([0, 2, , 3]);
|
|
786
|
-
return [4 /*yield*/, c(logMsg)];
|
|
787
|
-
case 1:
|
|
788
|
-
_a.sent();
|
|
789
|
-
return [3 /*break*/, 3];
|
|
790
|
-
case 2:
|
|
791
|
-
_a.sent();
|
|
792
|
-
return [3 /*break*/, 3];
|
|
793
|
-
case 3: return [2 /*return*/];
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
}); });
|
|
797
|
-
// 控制台输出
|
|
798
|
-
switch (level) {
|
|
799
|
-
case LogLevel.ERROR:
|
|
800
|
-
console.error("".concat(timestamp, " ").concat(message));
|
|
801
|
-
break;
|
|
802
|
-
case LogLevel.WARN:
|
|
803
|
-
console.warn("".concat(timestamp, " ").concat(message));
|
|
804
|
-
break;
|
|
805
|
-
case LogLevel.INFO:
|
|
806
|
-
console.log("".concat(timestamp, " ").concat(message));
|
|
807
|
-
break;
|
|
808
|
-
case LogLevel.DEBUG:
|
|
809
|
-
console.debug("".concat(timestamp, " ").concat(message));
|
|
810
|
-
break;
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
LoggerImpl.prototype.debug = function () {
|
|
814
|
-
var args = [];
|
|
815
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
816
|
-
args[_i] = arguments[_i];
|
|
817
|
-
}
|
|
818
|
-
this._log(LogLevel.DEBUG, args);
|
|
819
|
-
};
|
|
820
|
-
LoggerImpl.prototype.info = function () {
|
|
821
|
-
var args = [];
|
|
822
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
823
|
-
args[_i] = arguments[_i];
|
|
824
|
-
}
|
|
825
|
-
this._log(LogLevel.INFO, args);
|
|
826
|
-
};
|
|
827
|
-
LoggerImpl.prototype.warn = function () {
|
|
828
|
-
var args = [];
|
|
829
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
830
|
-
args[_i] = arguments[_i];
|
|
831
|
-
}
|
|
832
|
-
this._log(LogLevel.WARN, args);
|
|
833
|
-
};
|
|
834
|
-
LoggerImpl.prototype.error = function () {
|
|
835
|
-
var args = [];
|
|
836
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
837
|
-
args[_i] = arguments[_i];
|
|
838
|
-
}
|
|
839
|
-
this._log(LogLevel.ERROR, args);
|
|
840
|
-
};
|
|
841
|
-
LoggerImpl.MAX_LOG_LENGTH = 4096;
|
|
842
|
-
return LoggerImpl;
|
|
843
|
-
}());
|
|
844
|
-
|
|
845
|
-
function assertReturn(ret) {
|
|
846
|
-
if (!ret || typeof ret !== 'object') {
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
if (ret.status === RETURN_STATUS$1.FAILED) {
|
|
850
|
-
throw new Error(String(ret.msg));
|
|
851
|
-
}
|
|
852
|
-
return ret.decoded || ret.msg;
|
|
853
|
-
}
|
|
854
|
-
function isPromiseLike(val) {
|
|
855
|
-
if (typeof val === 'object' && val !== null) {
|
|
856
|
-
if (typeof val.then === 'function') {
|
|
857
|
-
return true;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
return false;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
var KEY_NAMESPACE = Symbol.for('#namespace');
|
|
864
|
-
var KEY_NATIVE_CLASS_NAME = Symbol.for('#nativeClassName');
|
|
865
|
-
function findNamespace(ctor) {
|
|
866
|
-
var obj = ctor;
|
|
867
|
-
var desc;
|
|
868
|
-
while (!desc && obj) {
|
|
869
|
-
desc = Object.getOwnPropertyDescriptor(obj, KEY_NAMESPACE);
|
|
870
|
-
obj = Object.getPrototypeOf(obj);
|
|
871
|
-
}
|
|
872
|
-
return desc === null || desc === void 0 ? void 0 : desc.value;
|
|
873
|
-
}
|
|
874
|
-
function findMethods(ins, opt) {
|
|
875
|
-
if (opt === void 0) { opt = {}; }
|
|
876
|
-
var methodNames = [];
|
|
877
|
-
var proto = Object.getPrototypeOf(ins);
|
|
878
|
-
while (proto && proto !== Object.prototype) {
|
|
879
|
-
var ownMethods = Object.getOwnPropertyNames(proto)
|
|
880
|
-
.filter(function (name) { return name !== 'constructor'; })
|
|
881
|
-
.map(function (name) { return opt[name] || name; });
|
|
882
|
-
methodNames.push.apply(methodNames, ownMethods);
|
|
883
|
-
proto = Object.getPrototypeOf(proto);
|
|
884
|
-
}
|
|
885
|
-
return methodNames;
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* 垃圾回收检查器,JS 对象被回收后,清除 Native 中的实例
|
|
889
|
-
*/
|
|
890
|
-
var getRegistry = function () {
|
|
891
|
-
if (typeof FinalizationRegistry !== 'undefined') {
|
|
892
|
-
try {
|
|
893
|
-
return new FinalizationRegistry(function (heldValue) {
|
|
894
|
-
var _a = heldValue.split('::'), instanceId = _a[0], namespace = _a[1];
|
|
895
|
-
if (instanceId) {
|
|
896
|
-
getMessageClient(instanceId).sendDestroyInstance(instanceId, namespace || '');
|
|
897
|
-
logger.debug('instance has been destroyed', instanceId);
|
|
898
|
-
}
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
catch (e) {
|
|
902
|
-
logger.warn('Failed to create FinalizationRegistry', e);
|
|
903
|
-
return null;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
return null;
|
|
907
|
-
};
|
|
908
|
-
var NativeObserverClass = function (className, opt) {
|
|
909
|
-
if (opt === void 0) { opt = {
|
|
910
|
-
instanceType: INSTANCE_TYPE$1.AUTOMATIC,
|
|
911
|
-
}; }
|
|
912
|
-
return function (target, ctx) {
|
|
913
|
-
ctx.addInitializer(function () {
|
|
914
|
-
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
915
|
-
value: className,
|
|
916
|
-
writable: true,
|
|
917
|
-
});
|
|
918
|
-
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
919
|
-
});
|
|
920
|
-
// @ts-ignore
|
|
921
|
-
return /** @class */ (function (_super) {
|
|
922
|
-
__extends$1(class_1, _super);
|
|
923
|
-
function class_1() {
|
|
924
|
-
var args = [];
|
|
925
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
926
|
-
args[_i] = arguments[_i];
|
|
927
|
-
}
|
|
928
|
-
var _a;
|
|
929
|
-
var _this = _super.apply(this, args) || this;
|
|
930
|
-
var t = _this;
|
|
931
|
-
var instanceId = getUuid(className);
|
|
932
|
-
t.namespace = className;
|
|
933
|
-
t.instanceId = instanceId;
|
|
934
|
-
t.messageClient = getMessageClient(t);
|
|
935
|
-
t.options = opt;
|
|
936
|
-
t.instanceType = opt.instanceType || INSTANCE_TYPE$1.AUTOMATIC;
|
|
937
|
-
(_a = getRegistry()) === null || _a === void 0 ? void 0 : _a.register(_this, "".concat(instanceId, "::").concat(className));
|
|
938
|
-
// custom consume native event
|
|
939
|
-
/**
|
|
940
|
-
* @param this
|
|
941
|
-
* @param name native method name
|
|
942
|
-
* @param params
|
|
943
|
-
*/
|
|
944
|
-
t.emit = function (name) {
|
|
945
|
-
var _a;
|
|
946
|
-
var params = [];
|
|
947
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
948
|
-
params[_i - 1] = arguments[_i];
|
|
949
|
-
}
|
|
950
|
-
var curName = ((_a = Object.entries(opt).find(function (_a) {
|
|
951
|
-
var v = _a[1];
|
|
952
|
-
return v === name;
|
|
953
|
-
})) === null || _a === void 0 ? void 0 : _a[0]) || name;
|
|
954
|
-
var fn = this[curName];
|
|
955
|
-
if (typeof fn === 'function') {
|
|
956
|
-
return fn.apply(this, params);
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
var _init = function () {
|
|
960
|
-
var events = findMethods(_this, opt);
|
|
961
|
-
t.messageClient.sendNewInstanceCall(className, [events], instanceId, t);
|
|
962
|
-
};
|
|
963
|
-
// proxy native created class
|
|
964
|
-
if (!args.includes(DISABLE_INIT)) {
|
|
965
|
-
_init();
|
|
966
|
-
}
|
|
967
|
-
return _this;
|
|
968
|
-
}
|
|
969
|
-
class_1.prototype.__destroy = function () {
|
|
970
|
-
var _a;
|
|
971
|
-
var t = this;
|
|
972
|
-
(_a = t.messageClient) === null || _a === void 0 ? void 0 : _a.sendDestroyInstance(t, t.namespace || '');
|
|
973
|
-
};
|
|
974
|
-
return class_1;
|
|
975
|
-
}(target));
|
|
976
|
-
};
|
|
977
|
-
};
|
|
978
|
-
var NativeClass = function (className, opt) {
|
|
979
|
-
if (opt === void 0) { opt = {
|
|
980
|
-
instanceType: INSTANCE_TYPE$1.AUTOMATIC,
|
|
981
|
-
}; }
|
|
982
|
-
return function (target, ctx) {
|
|
983
|
-
ctx.addInitializer(function () {
|
|
984
|
-
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
985
|
-
value: className,
|
|
986
|
-
writable: true,
|
|
987
|
-
});
|
|
988
|
-
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
989
|
-
});
|
|
990
|
-
// @ts-ignore
|
|
991
|
-
return /** @class */ (function (_super) {
|
|
992
|
-
__extends$1(class_2, _super);
|
|
993
|
-
function class_2() {
|
|
994
|
-
var args = [];
|
|
995
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
996
|
-
args[_i] = arguments[_i];
|
|
997
|
-
}
|
|
998
|
-
var _a;
|
|
999
|
-
var _this = _super.apply(this, args) || this;
|
|
1000
|
-
var t = _this;
|
|
1001
|
-
var instanceId = getUuid(className);
|
|
1002
|
-
t.namespace = className;
|
|
1003
|
-
t.instanceId = instanceId;
|
|
1004
|
-
t.messageClient = getMessageClient(t);
|
|
1005
|
-
t.instanceType = opt.instanceType || INSTANCE_TYPE$1.AUTOMATIC;
|
|
1006
|
-
(_a = getRegistry()) === null || _a === void 0 ? void 0 : _a.register(_this, "".concat(instanceId, "::").concat(className));
|
|
1007
|
-
var _init = function () {
|
|
1008
|
-
t.messageClient.sendNewInstanceCall(className, args.filter(function (v) { return v !== undefined; }), instanceId, t);
|
|
1009
|
-
if (getOS() === "ios" /* OS.ios */ &&
|
|
1010
|
-
typeof _this.init === 'function') {
|
|
1011
|
-
_this.init();
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
// proxy native created class
|
|
1015
|
-
if (!args.includes(DISABLE_INIT)) {
|
|
1016
|
-
_init();
|
|
1017
|
-
}
|
|
1018
|
-
return _this;
|
|
1019
|
-
}
|
|
1020
|
-
class_2.prototype.__destroy = function () {
|
|
1021
|
-
var _a;
|
|
1022
|
-
var t = this;
|
|
1023
|
-
(_a = t.messageClient) === null || _a === void 0 ? void 0 : _a.sendDestroyInstance(t, t.namespace || '');
|
|
1024
|
-
};
|
|
1025
|
-
return class_2;
|
|
1026
|
-
}(target));
|
|
1027
|
-
};
|
|
1028
|
-
};
|
|
1029
|
-
var NativeStaticMethod = function (methodSelector) {
|
|
1030
|
-
return function (target, ctx) {
|
|
1031
|
-
var name = ctx.name;
|
|
1032
|
-
return function impl() {
|
|
1033
|
-
var args = [];
|
|
1034
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1035
|
-
args[_i] = arguments[_i];
|
|
1036
|
-
}
|
|
1037
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1038
|
-
var namespace, client, returnValue, data;
|
|
1039
|
-
return __generator$1(this, function (_a) {
|
|
1040
|
-
switch (_a.label) {
|
|
1041
|
-
case 0:
|
|
1042
|
-
namespace = findNamespace(this);
|
|
1043
|
-
client = getMessageClient(this);
|
|
1044
|
-
return [4 /*yield*/, client.sendStaticCall(namespace || '', methodSelector || name, args)];
|
|
1045
|
-
case 1:
|
|
1046
|
-
returnValue = _a.sent();
|
|
1047
|
-
data = assertReturn(returnValue);
|
|
1048
|
-
return [2 /*return*/, data];
|
|
1049
|
-
}
|
|
1050
|
-
});
|
|
1051
|
-
});
|
|
1052
|
-
};
|
|
1053
|
-
};
|
|
1054
|
-
};
|
|
1055
|
-
var NativeStaticMethodSync = function (methodSelector) {
|
|
1056
|
-
return function (target, ctx) {
|
|
1057
|
-
var name = ctx.name;
|
|
1058
|
-
return function impl() {
|
|
1059
|
-
var args = [];
|
|
1060
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1061
|
-
args[_i] = arguments[_i];
|
|
1062
|
-
}
|
|
1063
|
-
var namespace = findNamespace(this);
|
|
1064
|
-
var client = getMessageClient(this);
|
|
1065
|
-
var returnValue = client.sendStaticCallSync(namespace || '', methodSelector || name, args);
|
|
1066
|
-
var data = assertReturn(returnValue);
|
|
1067
|
-
return data;
|
|
1068
|
-
};
|
|
1069
|
-
};
|
|
1070
|
-
};
|
|
1071
|
-
var ReturnClass = function (getCtor) {
|
|
1072
|
-
return function (target, ctx) {
|
|
1073
|
-
// TODO: impl
|
|
1074
|
-
return function impl() {
|
|
1075
|
-
var args = [];
|
|
1076
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1077
|
-
args[_i] = arguments[_i];
|
|
1078
|
-
}
|
|
1079
|
-
var returnValue = target.apply(this, args);
|
|
1080
|
-
if (isPromiseLike(returnValue)) {
|
|
1081
|
-
return returnValue.then(function (v) {
|
|
1082
|
-
return proxyNativeInstance(v, getCtor());
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
return proxyNativeInstance(returnValue, getCtor());
|
|
1086
|
-
};
|
|
1087
|
-
};
|
|
1088
|
-
};
|
|
1089
|
-
var NativeMember = function (_a) {
|
|
1090
|
-
var _b = {} , cache = _b.cache, readonly = _b.readonly;
|
|
1091
|
-
return function (_, ctx) {
|
|
1092
|
-
ctx.addInitializer(function () {
|
|
1093
|
-
var _this = this;
|
|
1094
|
-
var field = ctx.name;
|
|
1095
|
-
var key = Symbol.for(ctx.name);
|
|
1096
|
-
Object.defineProperty(this, field, {
|
|
1097
|
-
get: function () {
|
|
1098
|
-
if (cache && _this[key] !== undefined) {
|
|
1099
|
-
return _this[key];
|
|
1100
|
-
}
|
|
1101
|
-
var _a = _this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1102
|
-
var ret = getMessageClient(_this).sendInstanceGet(instanceId, namespace || '', field);
|
|
1103
|
-
var value = assertReturn(ret);
|
|
1104
|
-
_this[key] = value;
|
|
1105
|
-
return value;
|
|
1106
|
-
},
|
|
1107
|
-
set: function (v) {
|
|
1108
|
-
if (readonly) {
|
|
1109
|
-
throw new Error("field ".concat(field, " is readonly."));
|
|
1110
|
-
}
|
|
1111
|
-
_this[key] = v;
|
|
1112
|
-
var _a = _this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1113
|
-
getMessageClient(_this).sendInstanceSet(instanceId, namespace || '', field, v);
|
|
1114
|
-
},
|
|
1115
|
-
});
|
|
1116
|
-
});
|
|
1117
|
-
return _;
|
|
1118
|
-
};
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
var key = Symbol.for('args');
|
|
1122
|
-
function processArg(method) {
|
|
1123
|
-
var _a;
|
|
1124
|
-
var args = (_a = method[key]) !== null && _a !== void 0 ? _a : [];
|
|
1125
|
-
return function (arg, idx) {
|
|
1126
|
-
var _a, _b;
|
|
1127
|
-
return (_b = (_a = args[idx]) === null || _a === void 0 ? void 0 : _a.transform(arg)) !== null && _b !== void 0 ? _b : arg;
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
var NativeMethod = function (methodSelector, opt) {
|
|
1131
|
-
return function (_, ctx) {
|
|
1132
|
-
var name = ctx.name;
|
|
1133
|
-
function impl() {
|
|
1134
|
-
var args = [];
|
|
1135
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1136
|
-
args[_i] = arguments[_i];
|
|
1137
|
-
}
|
|
1138
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1139
|
-
var _a, instanceId, namespace, returnValue, data;
|
|
1140
|
-
return __generator$1(this, function (_b) {
|
|
1141
|
-
switch (_b.label) {
|
|
1142
|
-
case 0:
|
|
1143
|
-
_a = this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1144
|
-
return [4 /*yield*/, getMessageClient(this).sendInstanceCall(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(function (v) { return v !== undefined; }), opt)];
|
|
1145
|
-
case 1:
|
|
1146
|
-
returnValue = _b.sent();
|
|
1147
|
-
data = assertReturn(returnValue);
|
|
1148
|
-
return [2 /*return*/, data];
|
|
1149
|
-
}
|
|
1150
|
-
});
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
return impl;
|
|
1154
|
-
};
|
|
1155
|
-
};
|
|
1156
|
-
var NativeMethodSync = function (methodSelector, opt) {
|
|
1157
|
-
return function (_, ctx) {
|
|
1158
|
-
var name = ctx.name;
|
|
1159
|
-
function impl() {
|
|
1160
|
-
var args = [];
|
|
1161
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1162
|
-
args[_i] = arguments[_i];
|
|
1163
|
-
}
|
|
1164
|
-
var _a = this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1165
|
-
var returnValue = getMessageClient(this).sendInstanceCallSync(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(function (v) { return v !== undefined; }), opt);
|
|
1166
|
-
var data = assertReturn(returnValue);
|
|
1167
|
-
return data;
|
|
1168
|
-
}
|
|
1169
|
-
return impl;
|
|
1170
|
-
};
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
var NativeVar = function (varName, ctor) {
|
|
1174
|
-
return function (_, ctx) {
|
|
1175
|
-
return function impl() {
|
|
1176
|
-
var args = [];
|
|
1177
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1178
|
-
args[_i] = arguments[_i];
|
|
1179
|
-
}
|
|
1180
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1181
|
-
var client, ret, ins;
|
|
1182
|
-
return __generator$1(this, function (_a) {
|
|
1183
|
-
switch (_a.label) {
|
|
1184
|
-
case 0:
|
|
1185
|
-
client = getMessageClient(this);
|
|
1186
|
-
return [4 /*yield*/, client.sendVarGet(varName, args)];
|
|
1187
|
-
case 1:
|
|
1188
|
-
ret = _a.sent();
|
|
1189
|
-
ins = new ctor(DISABLE_INIT);
|
|
1190
|
-
ins.instanceId = ret.msg._instanceId;
|
|
1191
|
-
ins.messageClient = client;
|
|
1192
|
-
ins.namespace = '$var';
|
|
1193
|
-
return [2 /*return*/, ins];
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
});
|
|
1197
|
-
};
|
|
1198
|
-
};
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
(function () {
|
|
1202
|
-
var _a;
|
|
1203
|
-
var _instanceExtraInitializers = [];
|
|
1204
|
-
var _on_decorators;
|
|
1205
|
-
var _emit_decorators;
|
|
1206
|
-
return _a = /** @class */ (function () {
|
|
1207
|
-
function NativeObserver(className) {
|
|
1208
|
-
this._events = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1209
|
-
this.namespace = className;
|
|
1210
|
-
this.instanceId = getUuid(className);
|
|
1211
|
-
this.messageClient = getGlobalMessageClient();
|
|
1212
|
-
this._events = {};
|
|
1213
|
-
}
|
|
1214
|
-
NativeObserver.prototype.on = function (ev, handler) {
|
|
1215
|
-
var handlers = this._events[ev];
|
|
1216
|
-
if (!handlers) {
|
|
1217
|
-
handlers = [];
|
|
1218
|
-
this._events[ev] = handlers;
|
|
1219
|
-
}
|
|
1220
|
-
if (handlers.length === 0) {
|
|
1221
|
-
// 第一次,通知 native 注册
|
|
1222
|
-
this.messageClient.sendInstanceEventAdd(this.instanceId, this.namespace || '', ev);
|
|
1223
|
-
}
|
|
1224
|
-
handlers.push(handler);
|
|
1225
|
-
};
|
|
1226
|
-
NativeObserver.prototype.emit = function (ev) {
|
|
1227
|
-
var args = [];
|
|
1228
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1229
|
-
args[_i - 1] = arguments[_i];
|
|
1230
|
-
}
|
|
1231
|
-
var handlers = this._events[ev];
|
|
1232
|
-
// console.log('emit:', ev, args.length);
|
|
1233
|
-
handlers === null || handlers === void 0 ? void 0 : handlers.forEach(function (cb) {
|
|
1234
|
-
cb.apply(void 0, args);
|
|
1235
|
-
});
|
|
1236
|
-
};
|
|
1237
|
-
return NativeObserver;
|
|
1238
|
-
}()),
|
|
1239
|
-
(function () {
|
|
1240
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1241
|
-
_on_decorators = [Bind];
|
|
1242
|
-
_emit_decorators = [Bind];
|
|
1243
|
-
__esDecorate$1(_a, null, _on_decorators, { kind: "method", name: "on", static: false, private: false, access: { has: function (obj) { return "on" in obj; }, get: function (obj) { return obj.on; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1244
|
-
__esDecorate$1(_a, null, _emit_decorators, { kind: "method", name: "emit", static: false, private: false, access: { has: function (obj) { return "emit" in obj; }, get: function (obj) { return obj.emit; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1245
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1246
|
-
})(),
|
|
1247
|
-
_a;
|
|
1248
|
-
})();
|
|
1249
|
-
(function () {
|
|
1250
|
-
var _a;
|
|
1251
|
-
var _instanceExtraInitializers = [];
|
|
1252
|
-
var _on_decorators;
|
|
1253
|
-
var _emit_decorators;
|
|
1254
|
-
return _a = /** @class */ (function () {
|
|
1255
|
-
function NativeObserverProxy() {
|
|
1256
|
-
this.__observer = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1257
|
-
}
|
|
1258
|
-
NativeObserverProxy.prototype.on = function (ev, handler) {
|
|
1259
|
-
this.__observer.on(ev, handler);
|
|
1260
|
-
};
|
|
1261
|
-
NativeObserverProxy.prototype.emit = function (ev) {
|
|
1262
|
-
var _b;
|
|
1263
|
-
var args = [];
|
|
1264
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1265
|
-
args[_i - 1] = arguments[_i];
|
|
1266
|
-
}
|
|
1267
|
-
(_b = this.__observer).emit.apply(_b, __spreadArray$1([ev], args, false));
|
|
1268
|
-
};
|
|
1269
|
-
return NativeObserverProxy;
|
|
1270
|
-
}()),
|
|
1271
|
-
(function () {
|
|
1272
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1273
|
-
_on_decorators = [Bind];
|
|
1274
|
-
_emit_decorators = [Bind];
|
|
1275
|
-
__esDecorate$1(_a, null, _on_decorators, { kind: "method", name: "on", static: false, private: false, access: { has: function (obj) { return "on" in obj; }, get: function (obj) { return obj.on; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1276
|
-
__esDecorate$1(_a, null, _emit_decorators, { kind: "method", name: "emit", static: false, private: false, access: { has: function (obj) { return "emit" in obj; }, get: function (obj) { return obj.emit; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1277
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1278
|
-
})(),
|
|
1279
|
-
_a;
|
|
1280
|
-
})();
|
|
1281
|
-
|
|
1282
|
-
var NativeView = /** @class */ (function () {
|
|
1283
|
-
function NativeView(viewId) {
|
|
1284
|
-
this.viewId = viewId;
|
|
1285
|
-
initViewProxyObject(this, viewId);
|
|
1286
623
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
var ins = initViewProxyObject(_ins, viewId);
|
|
1290
|
-
return ins;
|
|
1291
|
-
};
|
|
1292
|
-
return NativeView;
|
|
1293
|
-
}());
|
|
1294
|
-
function initViewProxyObject(obj, viewId) {
|
|
1295
|
-
obj.instanceId = obj._instanceId = viewId;
|
|
1296
|
-
obj.namespace = obj._serviceName = '$View';
|
|
1297
|
-
obj._type = "instance" /* ARG_TYPE.INSTANCE */;
|
|
1298
|
-
return obj;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
var NativeInstanceManager$1 = function () {
|
|
1302
|
-
var _classDecorators = [NativeClass('com.volcengine.VolcApiEngine.runtime.ProtoImpl')];
|
|
1303
|
-
var _classDescriptor;
|
|
1304
|
-
var _classExtraInitializers = [];
|
|
1305
|
-
var _classThis;
|
|
1306
|
-
var _staticExtraInitializers = [];
|
|
1307
|
-
var _static_isInstanceDestroyed_decorators;
|
|
1308
|
-
_classThis = /** @class */ (function () {
|
|
1309
|
-
function NativeInstanceManager_1() {
|
|
1310
|
-
}
|
|
1311
|
-
NativeInstanceManager_1.isInstanceDestroyed = function (instanceId) {
|
|
1312
|
-
throw new Error('not implemented');
|
|
1313
|
-
};
|
|
1314
|
-
return NativeInstanceManager_1;
|
|
1315
|
-
}());
|
|
1316
|
-
__setFunctionName$1(_classThis, "NativeInstanceManager");
|
|
1317
|
-
(function () {
|
|
1318
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1319
|
-
_static_isInstanceDestroyed_decorators = [NativeStaticMethodSync()];
|
|
1320
|
-
__esDecorate$1(_classThis, null, _static_isInstanceDestroyed_decorators, { kind: "method", name: "isInstanceDestroyed", static: true, private: false, access: { has: function (obj) { return "isInstanceDestroyed" in obj; }, get: function (obj) { return obj.isInstanceDestroyed; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
1321
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1322
|
-
_classThis = _classDescriptor.value;
|
|
1323
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1324
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1325
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1326
|
-
})();
|
|
1327
|
-
return _classThis;
|
|
1328
|
-
}();
|
|
1329
|
-
|
|
1330
|
-
var NativeLoggerManager$1 = function () {
|
|
1331
|
-
var _classDecorators = [NativeClass('com.volcengine.VolcApiEngine.logger.VolcLogger')];
|
|
1332
|
-
var _classDescriptor;
|
|
1333
|
-
var _classExtraInitializers = [];
|
|
1334
|
-
var _classThis;
|
|
1335
|
-
var _staticExtraInitializers = [];
|
|
1336
|
-
var _static_setLogLevel_decorators;
|
|
1337
|
-
_classThis = /** @class */ (function () {
|
|
1338
|
-
function NativeLoggerManager_1() {
|
|
1339
|
-
}
|
|
1340
|
-
NativeLoggerManager_1.setLogLevel = function (instanceId) {
|
|
1341
|
-
throw new Error('not implemented');
|
|
1342
|
-
};
|
|
1343
|
-
return NativeLoggerManager_1;
|
|
1344
|
-
}());
|
|
1345
|
-
__setFunctionName$1(_classThis, "NativeLoggerManager");
|
|
1346
|
-
(function () {
|
|
1347
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1348
|
-
_static_setLogLevel_decorators = [NativeStaticMethod()];
|
|
1349
|
-
__esDecorate$1(_classThis, null, _static_setLogLevel_decorators, { kind: "method", name: "setLogLevel", static: true, private: false, access: { has: function (obj) { return "setLogLevel" in obj; }, get: function (obj) { return obj.setLogLevel; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
1350
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1351
|
-
_classThis = _classDescriptor.value;
|
|
1352
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1353
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1354
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1355
|
-
})();
|
|
1356
|
-
return _classThis;
|
|
1357
|
-
}();
|
|
1358
|
-
|
|
1359
|
-
var NativeInstanceManager = function () {
|
|
1360
|
-
var _classDecorators = [NativeClass('ApiEngineProtocol')];
|
|
1361
|
-
var _classDescriptor;
|
|
1362
|
-
var _classExtraInitializers = [];
|
|
1363
|
-
var _classThis;
|
|
1364
|
-
var _staticExtraInitializers = [];
|
|
1365
|
-
var _static_isInstanceDestroyed_decorators;
|
|
1366
|
-
_classThis = /** @class */ (function () {
|
|
1367
|
-
function NativeInstanceManager_1() {
|
|
1368
|
-
}
|
|
1369
|
-
NativeInstanceManager_1.isInstanceDestroyed = function (instanceId) {
|
|
1370
|
-
throw new Error('not implemented');
|
|
1371
|
-
};
|
|
1372
|
-
return NativeInstanceManager_1;
|
|
1373
|
-
}());
|
|
1374
|
-
__setFunctionName$1(_classThis, "NativeInstanceManager");
|
|
1375
|
-
(function () {
|
|
1376
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1377
|
-
_static_isInstanceDestroyed_decorators = [NativeStaticMethodSync('isInstanceDestroyed:')];
|
|
1378
|
-
__esDecorate$1(_classThis, null, _static_isInstanceDestroyed_decorators, { kind: "method", name: "isInstanceDestroyed", static: true, private: false, access: { has: function (obj) { return "isInstanceDestroyed" in obj; }, get: function (obj) { return obj.isInstanceDestroyed; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
1379
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1380
|
-
_classThis = _classDescriptor.value;
|
|
1381
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1382
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1383
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1384
|
-
})();
|
|
1385
|
-
return _classThis;
|
|
1386
|
-
}();
|
|
1387
|
-
|
|
1388
|
-
var NativeLoggerManager = function () {
|
|
1389
|
-
var _classDecorators = [NativeClass('VolcLogger')];
|
|
1390
|
-
var _classDescriptor;
|
|
1391
|
-
var _classExtraInitializers = [];
|
|
1392
|
-
var _classThis;
|
|
1393
|
-
var _staticExtraInitializers = [];
|
|
1394
|
-
var _static_setLogLevel_decorators;
|
|
1395
|
-
_classThis = /** @class */ (function () {
|
|
1396
|
-
function NativeLoggerManager_1() {
|
|
1397
|
-
}
|
|
1398
|
-
NativeLoggerManager_1.setLogLevel = function (level) {
|
|
1399
|
-
throw new Error('not implemented');
|
|
1400
|
-
};
|
|
1401
|
-
return NativeLoggerManager_1;
|
|
1402
|
-
}());
|
|
1403
|
-
__setFunctionName$1(_classThis, "NativeLoggerManager");
|
|
1404
|
-
(function () {
|
|
1405
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1406
|
-
_static_setLogLevel_decorators = [NativeStaticMethod('setLogLevel:')];
|
|
1407
|
-
__esDecorate$1(_classThis, null, _static_setLogLevel_decorators, { kind: "method", name: "setLogLevel", static: true, private: false, access: { has: function (obj) { return "setLogLevel" in obj; }, get: function (obj) { return obj.setLogLevel; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
1408
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1409
|
-
_classThis = _classDescriptor.value;
|
|
1410
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1411
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1412
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1413
|
-
})();
|
|
1414
|
-
return _classThis;
|
|
1415
|
-
}();
|
|
1416
|
-
|
|
1417
|
-
/** @class */ ((function () {
|
|
1418
|
-
function InstanceManager() {
|
|
624
|
+
enableVerbose(enable) {
|
|
625
|
+
this._enablePrintVerbose = enable;
|
|
1419
626
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
this.logger.debug('[instance-manager] isInstanceDestroyed', instanceId);
|
|
1423
|
-
if (getOS() === 'android') {
|
|
1424
|
-
return NativeInstanceManager$1.isInstanceDestroyed(instanceId);
|
|
1425
|
-
}
|
|
1426
|
-
else if (getOS() === 'ios') {
|
|
1427
|
-
return NativeInstanceManager.isInstanceDestroyed(instanceId);
|
|
1428
|
-
}
|
|
1429
|
-
throw new Error('not implemented');
|
|
1430
|
-
};
|
|
1431
|
-
InstanceManager.logger = LoggerImpl.getInstance();
|
|
1432
|
-
return InstanceManager;
|
|
1433
|
-
})());
|
|
1434
|
-
|
|
1435
|
-
/** @class */ ((function () {
|
|
1436
|
-
function LoggerManager() {
|
|
627
|
+
registerConsumer(consumer) {
|
|
628
|
+
this._consumers.push(consumer);
|
|
1437
629
|
}
|
|
1438
|
-
|
|
1439
|
-
this.
|
|
1440
|
-
|
|
1441
|
-
if (getOS() === 'android') {
|
|
1442
|
-
NativeLoggerManager$1.setLogLevel(level);
|
|
1443
|
-
}
|
|
1444
|
-
else if (getOS() === 'ios') {
|
|
1445
|
-
NativeLoggerManager.setLogLevel(level);
|
|
630
|
+
verbose(...args) {
|
|
631
|
+
if (this._enablePrintVerbose) {
|
|
632
|
+
console.debug('[verbose]', ...args);
|
|
1446
633
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
634
|
+
}
|
|
635
|
+
debug(...args) {
|
|
636
|
+
const msg = {
|
|
637
|
+
level: LogLevel.debug,
|
|
638
|
+
content: args,
|
|
639
|
+
};
|
|
640
|
+
this._log(msg);
|
|
641
|
+
if (this._enablePrintVerbose) {
|
|
642
|
+
console.debug('[debug]', ...args);
|
|
1449
643
|
}
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
644
|
+
}
|
|
645
|
+
info(...args) {
|
|
646
|
+
const msg = {
|
|
647
|
+
level: LogLevel.info,
|
|
648
|
+
content: args,
|
|
649
|
+
};
|
|
650
|
+
this._log(msg);
|
|
651
|
+
console.log(...args);
|
|
652
|
+
}
|
|
653
|
+
warn(...args) {
|
|
654
|
+
const msg = {
|
|
655
|
+
level: LogLevel.warn,
|
|
656
|
+
content: args,
|
|
657
|
+
};
|
|
658
|
+
this._log(msg);
|
|
659
|
+
console.warn(...args);
|
|
660
|
+
}
|
|
661
|
+
error(...args) {
|
|
662
|
+
const msg = {
|
|
663
|
+
level: LogLevel.error,
|
|
664
|
+
content: args,
|
|
665
|
+
};
|
|
666
|
+
this._log(msg);
|
|
667
|
+
console.error(...args);
|
|
668
|
+
}
|
|
669
|
+
_log(msg) {
|
|
670
|
+
this._consumers.forEach(async (c) => {
|
|
671
|
+
try {
|
|
672
|
+
await c(msg);
|
|
673
|
+
}
|
|
674
|
+
catch (ignore) {
|
|
675
|
+
//
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
1454
680
|
|
|
1455
|
-
|
|
681
|
+
const logger = new LoggerImpl();
|
|
1456
682
|
|
|
1457
|
-
|
|
1458
|
-
|
|
683
|
+
class ApiCallSpan {
|
|
684
|
+
constructor(tracer, action) {
|
|
1459
685
|
this.tracer = tracer;
|
|
1460
686
|
this.action = action;
|
|
1461
687
|
this.startTimestamp = Date.now();
|
|
1462
688
|
this.status = 'unknown';
|
|
1463
|
-
|
|
689
|
+
const record = {
|
|
1464
690
|
ts: Date.now(),
|
|
1465
691
|
type: 'call',
|
|
1466
692
|
data: action,
|
|
1467
693
|
traceId: action.traceId,
|
|
1468
694
|
};
|
|
1469
|
-
|
|
695
|
+
const msg = `<TO ${action.target}> ${action.callType} call:${action.serviceName || ''}.${action.methodName || action.memberName || ''} args=${safeStringify(action.args)}`;
|
|
1470
696
|
this.tracer.report(record, msg, {
|
|
1471
697
|
serviceName: action.serviceName,
|
|
1472
698
|
});
|
|
1473
699
|
}
|
|
1474
|
-
|
|
700
|
+
setReturnValue(value) {
|
|
1475
701
|
this.action.return = value;
|
|
1476
|
-
}
|
|
1477
|
-
|
|
702
|
+
}
|
|
703
|
+
success(value) {
|
|
1478
704
|
this.setReturnValue(value);
|
|
1479
705
|
this.status = 'success';
|
|
1480
706
|
this.finish();
|
|
1481
|
-
}
|
|
1482
|
-
|
|
707
|
+
}
|
|
708
|
+
fail(error) {
|
|
1483
709
|
this.setReturnValue(error);
|
|
1484
710
|
this.status = 'fail';
|
|
1485
711
|
this.finish();
|
|
1486
|
-
}
|
|
1487
|
-
|
|
712
|
+
}
|
|
713
|
+
finish() {
|
|
1488
714
|
this.endTimestamp = Date.now();
|
|
1489
715
|
this._report();
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
var action = this.action;
|
|
1495
|
-
var record = {
|
|
716
|
+
}
|
|
717
|
+
_report() {
|
|
718
|
+
const { action } = this;
|
|
719
|
+
const record = {
|
|
1496
720
|
ts: Date.now(),
|
|
1497
721
|
type: 'call',
|
|
1498
722
|
data: action,
|
|
1499
723
|
traceId: this.action.traceId,
|
|
1500
724
|
};
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
this.tracer.report(record, msg,
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
var Tracer = /** @class */ (function () {
|
|
1518
|
-
function Tracer() {
|
|
1519
|
-
this._logger = LoggerImpl.getInstance();
|
|
725
|
+
const msg = `<${action.target} Return> ${action.callType} call:${action.serviceName}.${action.methodName || action.memberName || ''} args=${safeStringify(action.args)} return=${safeStringify(action.return)}`;
|
|
726
|
+
const cost = this.endTimestamp - this.startTimestamp;
|
|
727
|
+
this.tracer.report(record, msg, {
|
|
728
|
+
level: this.status === 'fail' ||
|
|
729
|
+
this.action.return?.status === 'failed'
|
|
730
|
+
? 'warn'
|
|
731
|
+
: 'debug',
|
|
732
|
+
serviceName: action.serviceName,
|
|
733
|
+
cost,
|
|
734
|
+
status: this.status,
|
|
735
|
+
[this.status]: '1',
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
class Tracer {
|
|
740
|
+
constructor() {
|
|
1520
741
|
this._consumers = [];
|
|
1521
742
|
}
|
|
1522
|
-
|
|
743
|
+
registerConsumer(consumer) {
|
|
1523
744
|
this._consumers.push(consumer);
|
|
1524
|
-
}
|
|
1525
|
-
|
|
745
|
+
}
|
|
746
|
+
init(opt) {
|
|
1526
747
|
this.options = opt;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
|
|
748
|
+
}
|
|
749
|
+
collectApiCall(action) {
|
|
750
|
+
const span = new ApiCallSpan(this, action);
|
|
1530
751
|
return span;
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
|
|
752
|
+
}
|
|
753
|
+
collectEventEmit(action) {
|
|
754
|
+
const record = {
|
|
1534
755
|
ts: Date.now(),
|
|
1535
756
|
type: 'event_emit',
|
|
1536
757
|
data: action,
|
|
1537
758
|
};
|
|
1538
|
-
|
|
1539
|
-
|
|
759
|
+
const { eventName, eventData } = action;
|
|
760
|
+
const msg = `<TO ${action.target}> emit:${eventName} event=${safeStringify(eventData)}`;
|
|
1540
761
|
this.report(record, msg, {
|
|
1541
762
|
callType: 'event_emit',
|
|
1542
763
|
eventName: eventName,
|
|
1543
764
|
});
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
|
|
765
|
+
}
|
|
766
|
+
collectEventEmitResult(action) {
|
|
767
|
+
const record = {
|
|
1547
768
|
ts: Date.now(),
|
|
1548
769
|
type: 'event_emit_result',
|
|
1549
770
|
data: action,
|
|
1550
771
|
};
|
|
1551
|
-
|
|
1552
|
-
|
|
772
|
+
const { eventName, eventData } = action;
|
|
773
|
+
const msg = `<TO ${action.target}> emit:${eventName} result=${safeStringify(eventData)}`;
|
|
1553
774
|
this.report(record, msg, {
|
|
1554
775
|
callType: 'event_emit_result',
|
|
1555
776
|
eventName: eventName,
|
|
1556
777
|
});
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
|
|
778
|
+
}
|
|
779
|
+
collectEventOn(action) {
|
|
780
|
+
const record = {
|
|
1560
781
|
ts: Date.now(),
|
|
1561
782
|
type: 'event_on',
|
|
1562
783
|
data: action,
|
|
1563
784
|
};
|
|
1564
|
-
|
|
1565
|
-
|
|
785
|
+
const { eventName } = action;
|
|
786
|
+
const msg = `<TO ${action.target}> on:${eventName}`;
|
|
1566
787
|
this.report(record, msg, {
|
|
1567
788
|
callType: 'event_on',
|
|
1568
|
-
eventName
|
|
789
|
+
eventName,
|
|
1569
790
|
});
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
|
|
791
|
+
}
|
|
792
|
+
collectEventOff(action) {
|
|
793
|
+
const record = {
|
|
1573
794
|
ts: Date.now(),
|
|
1574
795
|
type: 'event_off',
|
|
1575
796
|
data: action,
|
|
1576
797
|
};
|
|
1577
|
-
|
|
1578
|
-
|
|
798
|
+
const { eventName } = action;
|
|
799
|
+
const msg = `<TO ${action.target}> off:${eventName}`;
|
|
1579
800
|
this.report(record, msg, {
|
|
1580
801
|
callType: 'event_off',
|
|
1581
|
-
eventName
|
|
802
|
+
eventName,
|
|
1582
803
|
});
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
|
|
804
|
+
}
|
|
805
|
+
collectCallbackEmit(action) {
|
|
806
|
+
const record = {
|
|
1586
807
|
ts: Date.now(),
|
|
1587
808
|
type: 'callback_emit',
|
|
1588
809
|
data: action,
|
|
1589
810
|
};
|
|
1590
|
-
|
|
1591
|
-
|
|
811
|
+
const { eventName, eventData } = action;
|
|
812
|
+
const msg = `<TO ${action.target}> emit callback:${eventName} event=${safeStringify(eventData)}`;
|
|
1592
813
|
this.report(record, msg, {
|
|
1593
814
|
callType: 'callback_emit',
|
|
1594
815
|
eventName: eventName,
|
|
1595
816
|
});
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
return [4 /*yield*/, c(record, msg, extra)];
|
|
1605
|
-
case 1:
|
|
1606
|
-
_a.sent();
|
|
1607
|
-
return [3 /*break*/, 3];
|
|
1608
|
-
case 2:
|
|
1609
|
-
_a.sent();
|
|
1610
|
-
return [3 /*break*/, 3];
|
|
1611
|
-
case 3: return [2 /*return*/];
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
1614
|
-
}); });
|
|
1615
|
-
try {
|
|
1616
|
-
var level = extra.level || 'info';
|
|
1617
|
-
if (level === 'warn') {
|
|
1618
|
-
this._logger.warn("[Trace] ".concat(msg));
|
|
817
|
+
}
|
|
818
|
+
report(record, msg, extra) {
|
|
819
|
+
this._consumers.forEach(async (c) => {
|
|
820
|
+
try {
|
|
821
|
+
await c(record, msg, extra);
|
|
822
|
+
}
|
|
823
|
+
catch (ignore) {
|
|
824
|
+
//
|
|
1619
825
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
826
|
+
});
|
|
827
|
+
try {
|
|
828
|
+
const level = extra.level || 'info';
|
|
829
|
+
if (level === 'warn' || level === 'error') {
|
|
830
|
+
console.warn(`[Trace] ${level} `, msg);
|
|
1622
831
|
}
|
|
1623
832
|
else if (false) ;
|
|
1624
833
|
}
|
|
1625
834
|
catch (err) {
|
|
1626
835
|
//
|
|
1627
836
|
}
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
}());
|
|
837
|
+
}
|
|
838
|
+
}
|
|
1631
839
|
|
|
1632
|
-
|
|
840
|
+
const globalTracer = new Tracer();
|
|
1633
841
|
|
|
1634
|
-
|
|
842
|
+
let MessageSenderImpl = (() => {
|
|
1635
843
|
var _a;
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
function MessageSenderImpl(proto, bridge) {
|
|
844
|
+
let _instanceExtraInitializers = [];
|
|
845
|
+
let _sendVarGet_decorators;
|
|
846
|
+
let _sendStaticCall_decorators;
|
|
847
|
+
let _sendStaticCallSync_decorators;
|
|
848
|
+
let _sendNewInstanceCall_decorators;
|
|
849
|
+
let _sendInstanceCall_decorators;
|
|
850
|
+
let _sendInstanceCallSync_decorators;
|
|
851
|
+
let _sendInstanceSet_decorators;
|
|
852
|
+
let _sendInstanceGet_decorators;
|
|
853
|
+
let _sendInstanceEventAdd_decorators;
|
|
854
|
+
let _sendInstanceEventRemove_decorators;
|
|
855
|
+
let _sendEventEmit_decorators;
|
|
856
|
+
let _sendEventEmitResult_decorators;
|
|
857
|
+
return _a = class MessageSenderImpl {
|
|
858
|
+
constructor(proto, bridge) {
|
|
1652
859
|
this.proto = (__runInitializers$1(this, _instanceExtraInitializers), proto);
|
|
1653
860
|
this.bridge = bridge;
|
|
1654
|
-
this.logger =
|
|
861
|
+
this.logger = logger;
|
|
1655
862
|
this.tracer = globalTracer;
|
|
1656
863
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
serviceName: '$var',
|
|
1676
|
-
memberName: varName,
|
|
1677
|
-
args: encodeArgs,
|
|
1678
|
-
traceId: traceId,
|
|
1679
|
-
callType: params.callType,
|
|
1680
|
-
});
|
|
1681
|
-
_b.label = 1;
|
|
1682
|
-
case 1:
|
|
1683
|
-
_b.trys.push([1, 3, , 4]);
|
|
1684
|
-
return [4 /*yield*/, this._send(params)];
|
|
1685
|
-
case 2:
|
|
1686
|
-
res = _b.sent();
|
|
1687
|
-
span.success(res);
|
|
1688
|
-
return [2 /*return*/, res];
|
|
1689
|
-
case 3:
|
|
1690
|
-
err_1 = _b.sent();
|
|
1691
|
-
span.fail(err_1);
|
|
1692
|
-
throw err_1;
|
|
1693
|
-
case 4: return [2 /*return*/];
|
|
1694
|
-
}
|
|
1695
|
-
});
|
|
864
|
+
async sendVarGet(varName, args) {
|
|
865
|
+
const traceId = getUuid('trace');
|
|
866
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
867
|
+
const params = {
|
|
868
|
+
serviceName: varName,
|
|
869
|
+
memberName: varName,
|
|
870
|
+
args: encodeArgs,
|
|
871
|
+
callType: CALL_TYPE$1.VAR_GETTER,
|
|
872
|
+
_traceId: traceId,
|
|
873
|
+
};
|
|
874
|
+
const span = this.tracer.collectApiCall({
|
|
875
|
+
source: 'js',
|
|
876
|
+
target: 'native',
|
|
877
|
+
serviceName: '$var',
|
|
878
|
+
memberName: varName,
|
|
879
|
+
args: encodeArgs,
|
|
880
|
+
traceId,
|
|
881
|
+
callType: params.callType,
|
|
1696
882
|
});
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
_b.trys.push([1, 3, , 4]);
|
|
1726
|
-
return [4 /*yield*/, this._send(params)];
|
|
1727
|
-
case 2:
|
|
1728
|
-
res = _b.sent();
|
|
1729
|
-
span.success(res);
|
|
1730
|
-
return [2 /*return*/, res];
|
|
1731
|
-
case 3:
|
|
1732
|
-
err_2 = _b.sent();
|
|
1733
|
-
span.fail(err_2);
|
|
1734
|
-
throw err_2;
|
|
1735
|
-
case 4: return [2 /*return*/];
|
|
1736
|
-
}
|
|
1737
|
-
});
|
|
883
|
+
try {
|
|
884
|
+
const res = await this._send(params);
|
|
885
|
+
span.success(res);
|
|
886
|
+
return res;
|
|
887
|
+
}
|
|
888
|
+
catch (err) {
|
|
889
|
+
span.fail(err);
|
|
890
|
+
throw err;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
async sendStaticCall(serviceName, methodName, args) {
|
|
894
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
895
|
+
const traceId = getUuid('trace');
|
|
896
|
+
const params = {
|
|
897
|
+
serviceName,
|
|
898
|
+
methodName,
|
|
899
|
+
args: encodeArgs,
|
|
900
|
+
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
901
|
+
_traceId: traceId,
|
|
902
|
+
};
|
|
903
|
+
const span = this.tracer.collectApiCall({
|
|
904
|
+
source: 'js',
|
|
905
|
+
target: 'native',
|
|
906
|
+
serviceName,
|
|
907
|
+
methodName,
|
|
908
|
+
args,
|
|
909
|
+
traceId,
|
|
910
|
+
callType: params.callType,
|
|
1738
911
|
});
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
912
|
+
try {
|
|
913
|
+
const res = await this._send(params);
|
|
914
|
+
span.success(res);
|
|
915
|
+
return res;
|
|
916
|
+
}
|
|
917
|
+
catch (err) {
|
|
918
|
+
span.fail(err);
|
|
919
|
+
throw err;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
sendStaticCallSync(serviceName, methodName, args) {
|
|
923
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
924
|
+
const traceId = getUuid('trace');
|
|
925
|
+
const params = {
|
|
926
|
+
serviceName,
|
|
927
|
+
methodName,
|
|
1746
928
|
args: encodeArgs,
|
|
1747
929
|
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
1748
930
|
_traceId: traceId,
|
|
1749
|
-
runOnMainThread: true,
|
|
1750
931
|
};
|
|
1751
|
-
|
|
932
|
+
const span = this.tracer.collectApiCall({
|
|
1752
933
|
source: 'js',
|
|
1753
934
|
target: 'native',
|
|
1754
|
-
serviceName
|
|
1755
|
-
methodName
|
|
1756
|
-
args
|
|
1757
|
-
traceId
|
|
935
|
+
serviceName,
|
|
936
|
+
methodName,
|
|
937
|
+
args,
|
|
938
|
+
traceId,
|
|
1758
939
|
callType: params.callType,
|
|
1759
940
|
});
|
|
1760
941
|
try {
|
|
1761
|
-
|
|
942
|
+
const res = this._sendSync(params);
|
|
1762
943
|
span.success(res);
|
|
1763
944
|
return res;
|
|
1764
945
|
}
|
|
@@ -1766,30 +947,28 @@ var MessageSenderImpl = function () {
|
|
|
1766
947
|
span.fail(err);
|
|
1767
948
|
throw err;
|
|
1768
949
|
}
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
serviceName
|
|
950
|
+
}
|
|
951
|
+
sendNewInstanceCall(serviceName, args, instanceId, instance) {
|
|
952
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
953
|
+
const traceId = getUuid('trace');
|
|
954
|
+
const params = {
|
|
955
|
+
serviceName,
|
|
1775
956
|
args: encodeArgs,
|
|
1776
957
|
callType: CALL_TYPE$1.NEW_INSTANCE,
|
|
1777
958
|
_instanceId: instanceId,
|
|
1778
|
-
_instanceType: instance.instanceType,
|
|
1779
959
|
_traceId: traceId,
|
|
1780
|
-
runOnMainThread: true,
|
|
1781
960
|
};
|
|
1782
|
-
|
|
961
|
+
const span = this.tracer.collectApiCall({
|
|
1783
962
|
source: 'js',
|
|
1784
963
|
target: 'native',
|
|
1785
|
-
serviceName
|
|
1786
|
-
args
|
|
1787
|
-
traceId
|
|
964
|
+
serviceName,
|
|
965
|
+
args,
|
|
966
|
+
traceId,
|
|
1788
967
|
callType: params.callType,
|
|
1789
968
|
});
|
|
1790
969
|
try {
|
|
1791
970
|
this.proto.registerProxyInstance(instanceId, instance);
|
|
1792
|
-
|
|
971
|
+
const res = this._sendSync(params);
|
|
1793
972
|
span.success(res);
|
|
1794
973
|
return res;
|
|
1795
974
|
}
|
|
@@ -1797,79 +976,63 @@ var MessageSenderImpl = function () {
|
|
|
1797
976
|
span.fail(err);
|
|
1798
977
|
throw err;
|
|
1799
978
|
}
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
var instanceId, encodeArgs, traceId, params, span, res, err_3;
|
|
1804
|
-
if (args === void 0) { args = []; }
|
|
1805
|
-
return __generator$1(this, function (_b) {
|
|
1806
|
-
switch (_b.label) {
|
|
1807
|
-
case 0:
|
|
1808
|
-
instanceId = this._resolveInstanceId(instanceOrId);
|
|
1809
|
-
assert(!!instanceId, 'unknown instance');
|
|
1810
|
-
encodeArgs = this.proto.encodeArgs(args);
|
|
1811
|
-
traceId = getUuid('trace');
|
|
1812
|
-
params = {
|
|
1813
|
-
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1814
|
-
_instanceId: instanceId,
|
|
1815
|
-
serviceName: serviceName,
|
|
1816
|
-
methodName: methodName,
|
|
1817
|
-
args: encodeArgs,
|
|
1818
|
-
_traceId: traceId,
|
|
1819
|
-
runOnMainThread: true,
|
|
1820
|
-
};
|
|
1821
|
-
span = this.tracer.collectApiCall({
|
|
1822
|
-
source: 'js',
|
|
1823
|
-
target: 'native',
|
|
1824
|
-
serviceName: serviceName,
|
|
1825
|
-
methodName: methodName,
|
|
1826
|
-
args: args,
|
|
1827
|
-
traceId: traceId,
|
|
1828
|
-
callType: params.callType,
|
|
1829
|
-
});
|
|
1830
|
-
_b.label = 1;
|
|
1831
|
-
case 1:
|
|
1832
|
-
_b.trys.push([1, 3, , 4]);
|
|
1833
|
-
return [4 /*yield*/, this._send(params)];
|
|
1834
|
-
case 2:
|
|
1835
|
-
res = _b.sent();
|
|
1836
|
-
span.success(res);
|
|
1837
|
-
return [2 /*return*/, res];
|
|
1838
|
-
case 3:
|
|
1839
|
-
err_3 = _b.sent();
|
|
1840
|
-
span.fail(err_3);
|
|
1841
|
-
throw err_3;
|
|
1842
|
-
case 4: return [2 /*return*/];
|
|
1843
|
-
}
|
|
1844
|
-
});
|
|
1845
|
-
});
|
|
1846
|
-
};
|
|
1847
|
-
MessageSenderImpl.prototype.sendInstanceCallSync = function (instanceOrId, serviceName, methodName, args, meta) {
|
|
1848
|
-
if (args === void 0) { args = []; }
|
|
1849
|
-
var instanceId = this._resolveInstanceId(instanceOrId);
|
|
979
|
+
}
|
|
980
|
+
async sendInstanceCall(instanceOrId, serviceName, methodName, args = [], meta) {
|
|
981
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1850
982
|
assert(!!instanceId, 'unknown instance');
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
983
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
984
|
+
const traceId = getUuid('trace');
|
|
985
|
+
const params = {
|
|
1854
986
|
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1855
987
|
_instanceId: instanceId,
|
|
1856
988
|
serviceName: serviceName,
|
|
989
|
+
methodName,
|
|
1857
990
|
args: encodeArgs,
|
|
1858
|
-
methodName: methodName,
|
|
1859
991
|
_traceId: traceId,
|
|
1860
|
-
runOnMainThread: true,
|
|
1861
992
|
};
|
|
1862
|
-
|
|
993
|
+
const span = this.tracer.collectApiCall({
|
|
1863
994
|
source: 'js',
|
|
1864
995
|
target: 'native',
|
|
996
|
+
serviceName,
|
|
997
|
+
methodName,
|
|
998
|
+
args,
|
|
999
|
+
traceId,
|
|
1000
|
+
callType: params.callType,
|
|
1001
|
+
});
|
|
1002
|
+
try {
|
|
1003
|
+
const res = await this._send(params);
|
|
1004
|
+
span.success(res);
|
|
1005
|
+
return res;
|
|
1006
|
+
}
|
|
1007
|
+
catch (err) {
|
|
1008
|
+
span.fail(err);
|
|
1009
|
+
throw err;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
sendInstanceCallSync(instanceOrId, serviceName, methodName, args = [], meta) {
|
|
1013
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1014
|
+
assert(!!instanceId, 'unknown instance');
|
|
1015
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
1016
|
+
const traceId = getUuid('trace');
|
|
1017
|
+
const params = {
|
|
1018
|
+
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1019
|
+
_instanceId: instanceId,
|
|
1865
1020
|
serviceName: serviceName,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1021
|
+
args: encodeArgs,
|
|
1022
|
+
methodName,
|
|
1023
|
+
_traceId: traceId,
|
|
1024
|
+
};
|
|
1025
|
+
const span = this.tracer.collectApiCall({
|
|
1026
|
+
source: 'js',
|
|
1027
|
+
target: 'native',
|
|
1028
|
+
serviceName,
|
|
1029
|
+
methodName,
|
|
1030
|
+
args,
|
|
1031
|
+
traceId,
|
|
1869
1032
|
callType: params.callType,
|
|
1870
1033
|
});
|
|
1871
1034
|
try {
|
|
1872
|
-
|
|
1035
|
+
const res = this._sendSync(params);
|
|
1873
1036
|
span.success(res);
|
|
1874
1037
|
return res;
|
|
1875
1038
|
}
|
|
@@ -1877,31 +1040,31 @@ var MessageSenderImpl = function () {
|
|
|
1877
1040
|
span.fail(err);
|
|
1878
1041
|
throw err;
|
|
1879
1042
|
}
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1043
|
+
}
|
|
1044
|
+
sendInstanceSet(instanceOrId, serviceName, memberName, value) {
|
|
1045
|
+
const arg = this.proto.encodeArg(value);
|
|
1046
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1884
1047
|
assert(!!instanceId, 'unknown instance');
|
|
1885
|
-
|
|
1886
|
-
|
|
1048
|
+
const traceId = getUuid('trace');
|
|
1049
|
+
const params = {
|
|
1887
1050
|
callType: CALL_TYPE$1.INSTANCE_MEMBER_SET,
|
|
1888
1051
|
_instanceId: instanceId,
|
|
1889
|
-
serviceName
|
|
1890
|
-
memberName
|
|
1052
|
+
serviceName,
|
|
1053
|
+
memberName,
|
|
1891
1054
|
args: [arg],
|
|
1892
1055
|
_traceId: traceId,
|
|
1893
1056
|
};
|
|
1894
|
-
|
|
1057
|
+
const span = this.tracer.collectApiCall({
|
|
1895
1058
|
source: 'js',
|
|
1896
1059
|
target: 'native',
|
|
1897
1060
|
serviceName: memberName,
|
|
1898
|
-
memberName
|
|
1061
|
+
memberName,
|
|
1899
1062
|
args: [arg],
|
|
1900
|
-
traceId
|
|
1063
|
+
traceId,
|
|
1901
1064
|
callType: params.callType,
|
|
1902
1065
|
});
|
|
1903
1066
|
try {
|
|
1904
|
-
|
|
1067
|
+
const res = this._sendSync(params);
|
|
1905
1068
|
span.success(res);
|
|
1906
1069
|
return res;
|
|
1907
1070
|
}
|
|
@@ -1909,30 +1072,30 @@ var MessageSenderImpl = function () {
|
|
|
1909
1072
|
span.fail(err);
|
|
1910
1073
|
throw err;
|
|
1911
1074
|
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
|
|
1075
|
+
}
|
|
1076
|
+
sendInstanceGet(instanceOrId, serviceName, memberName) {
|
|
1077
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1915
1078
|
assert(!!instanceId, 'unknown instance');
|
|
1916
|
-
|
|
1917
|
-
|
|
1079
|
+
const traceId = getUuid('trace');
|
|
1080
|
+
const params = {
|
|
1918
1081
|
callType: CALL_TYPE$1.INSTANCE_MEMBER_GET,
|
|
1919
1082
|
_instanceId: instanceId,
|
|
1920
|
-
serviceName
|
|
1921
|
-
memberName
|
|
1083
|
+
serviceName,
|
|
1084
|
+
memberName,
|
|
1922
1085
|
args: [],
|
|
1923
1086
|
_traceId: traceId,
|
|
1924
1087
|
};
|
|
1925
|
-
|
|
1088
|
+
const span = this.tracer.collectApiCall({
|
|
1926
1089
|
source: 'js',
|
|
1927
1090
|
target: 'native',
|
|
1928
1091
|
serviceName: memberName,
|
|
1929
|
-
memberName
|
|
1092
|
+
memberName,
|
|
1930
1093
|
args: [],
|
|
1931
|
-
traceId
|
|
1094
|
+
traceId,
|
|
1932
1095
|
callType: params.callType,
|
|
1933
1096
|
});
|
|
1934
1097
|
try {
|
|
1935
|
-
|
|
1098
|
+
const res = this._sendSync(params);
|
|
1936
1099
|
span.success(res);
|
|
1937
1100
|
return res;
|
|
1938
1101
|
}
|
|
@@ -1940,12 +1103,12 @@ var MessageSenderImpl = function () {
|
|
|
1940
1103
|
span.fail(err);
|
|
1941
1104
|
throw err;
|
|
1942
1105
|
}
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1106
|
+
}
|
|
1107
|
+
sendInstanceEventAdd(instanceOrId, serviceName, eventName) {
|
|
1108
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1946
1109
|
assert(!!instanceId, 'unknown instance');
|
|
1947
1110
|
// const encodeCallback = this.proto.encodeCallback(callback);
|
|
1948
|
-
|
|
1111
|
+
const params = {
|
|
1949
1112
|
callType: CALL_TYPE$1.INSTANCE_EVENT_LISTENER_ADD,
|
|
1950
1113
|
_instanceId: instanceId,
|
|
1951
1114
|
serviceName: serviceName,
|
|
@@ -1958,12 +1121,12 @@ var MessageSenderImpl = function () {
|
|
|
1958
1121
|
eventName: serviceName,
|
|
1959
1122
|
});
|
|
1960
1123
|
return this._sendSync(params);
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1124
|
+
}
|
|
1125
|
+
sendInstanceEventRemove(instanceOrId, serviceName, eventName) {
|
|
1126
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1964
1127
|
assert(!!instanceId, 'unknown instance');
|
|
1965
1128
|
// const encodeCallback = this.proto.encodeCallback(callback);
|
|
1966
|
-
|
|
1129
|
+
const params = {
|
|
1967
1130
|
callType: CALL_TYPE$1.INSTANCE_EVENT_LISTENER_REMOVE,
|
|
1968
1131
|
_instanceId: instanceId,
|
|
1969
1132
|
serviceName: serviceName,
|
|
@@ -1976,124 +1139,77 @@ var MessageSenderImpl = function () {
|
|
|
1976
1139
|
eventName: serviceName,
|
|
1977
1140
|
});
|
|
1978
1141
|
return this._sendSync(params);
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
callType: CALL_TYPE$1.DESTROY_INSTANCE,
|
|
1142
|
+
}
|
|
1143
|
+
async sendEventEmit(instanceId, serviceName, callbackId, args) {
|
|
1144
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
1145
|
+
const params = {
|
|
1146
|
+
callType: CALL_TYPE$1.INSTANCE_EVENT_EMIT,
|
|
1985
1147
|
_instanceId: instanceId,
|
|
1986
1148
|
serviceName: serviceName,
|
|
1149
|
+
args: [
|
|
1150
|
+
{
|
|
1151
|
+
callback_id: callbackId,
|
|
1152
|
+
},
|
|
1153
|
+
...encodeArgs,
|
|
1154
|
+
],
|
|
1987
1155
|
};
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
return __generator$1(this, function (_b) {
|
|
1994
|
-
encodeArgs = this.proto.encodeArgs(args);
|
|
1995
|
-
params = {
|
|
1996
|
-
callType: CALL_TYPE$1.INSTANCE_EVENT_EMIT,
|
|
1997
|
-
_instanceId: instanceId,
|
|
1998
|
-
serviceName: serviceName,
|
|
1999
|
-
args: __spreadArray$1([
|
|
2000
|
-
{
|
|
2001
|
-
callback_id: callbackId,
|
|
2002
|
-
}
|
|
2003
|
-
], encodeArgs, true),
|
|
2004
|
-
};
|
|
2005
|
-
this.tracer.collectEventEmit({
|
|
2006
|
-
source: 'js',
|
|
2007
|
-
target: 'native',
|
|
2008
|
-
eventName: serviceName,
|
|
2009
|
-
eventData: encodeArgs,
|
|
2010
|
-
});
|
|
2011
|
-
return [2 /*return*/, this._send(params)];
|
|
2012
|
-
});
|
|
2013
|
-
});
|
|
2014
|
-
};
|
|
2015
|
-
MessageSenderImpl.prototype.sendEventEmitResult = function (instanceId, serviceName, ret) {
|
|
2016
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
2017
|
-
var params;
|
|
2018
|
-
return __generator$1(this, function (_b) {
|
|
2019
|
-
params = {
|
|
2020
|
-
callType: CALL_TYPE$1.INSTANCE_EVENT_RESULT,
|
|
2021
|
-
_instanceId: instanceId,
|
|
2022
|
-
serviceName: serviceName,
|
|
2023
|
-
args: [ret],
|
|
2024
|
-
_traceId: ret._traceId,
|
|
2025
|
-
};
|
|
2026
|
-
this.tracer.collectEventEmitResult({
|
|
2027
|
-
source: 'js',
|
|
2028
|
-
target: 'native',
|
|
2029
|
-
eventName: serviceName,
|
|
2030
|
-
eventData: ret,
|
|
2031
|
-
});
|
|
2032
|
-
return [2 /*return*/, this._send(params)];
|
|
2033
|
-
});
|
|
1156
|
+
this.tracer.collectEventEmit({
|
|
1157
|
+
source: 'js',
|
|
1158
|
+
target: 'native',
|
|
1159
|
+
eventName: serviceName,
|
|
1160
|
+
eventData: encodeArgs,
|
|
2034
1161
|
});
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
}
|
|
2051
|
-
});
|
|
1162
|
+
return this._send(params);
|
|
1163
|
+
}
|
|
1164
|
+
async sendEventEmitResult(instanceId, serviceName, ret) {
|
|
1165
|
+
const params = {
|
|
1166
|
+
callType: CALL_TYPE$1.INSTANCE_EVENT_RESULT,
|
|
1167
|
+
_instanceId: instanceId,
|
|
1168
|
+
serviceName: serviceName,
|
|
1169
|
+
args: [ret],
|
|
1170
|
+
_traceId: ret._traceId,
|
|
1171
|
+
};
|
|
1172
|
+
this.tracer.collectEventEmitResult({
|
|
1173
|
+
source: 'js',
|
|
1174
|
+
target: 'native',
|
|
1175
|
+
eventName: serviceName,
|
|
1176
|
+
eventData: ret,
|
|
2052
1177
|
});
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
1178
|
+
return this._send(params);
|
|
1179
|
+
}
|
|
1180
|
+
async _send(params) {
|
|
1181
|
+
const traceId = params._traceId || getUuid('trace');
|
|
2056
1182
|
params._traceId = traceId;
|
|
2057
|
-
this.
|
|
2058
|
-
var res = this.bridge.callSync(params);
|
|
2059
|
-
this.logger.info('[message-sender] Received sync response:', res);
|
|
1183
|
+
const res = await this.bridge.call(params);
|
|
2060
1184
|
return this._resolveReturn(res, params);
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
this.logger.error('[message-sender] Native method not implemented:', req);
|
|
2076
|
-
break;
|
|
2077
|
-
case RETURN_STATUS$1.FAILED:
|
|
2078
|
-
this.logger.error('[message-sender] Decode return failed:', res);
|
|
2079
|
-
break;
|
|
2080
|
-
default:
|
|
2081
|
-
this.logger.warn('[message-sender] Unknown return status:', res);
|
|
2082
|
-
break;
|
|
1185
|
+
}
|
|
1186
|
+
_sendSync(params) {
|
|
1187
|
+
const traceId = params._traceId || getUuid('trace');
|
|
1188
|
+
params._traceId = traceId;
|
|
1189
|
+
const res = this.bridge.callSync(params);
|
|
1190
|
+
return this._resolveReturn(res, params);
|
|
1191
|
+
}
|
|
1192
|
+
_resolveReturn(res, req) {
|
|
1193
|
+
if (res.status === RETURN_STATUS$1.SUCCESS && res.msg) {
|
|
1194
|
+
Object.defineProperty(res, 'decoded', {
|
|
1195
|
+
value: this.proto.decodeArg(res.msg),
|
|
1196
|
+
enumerable: false,
|
|
1197
|
+
writable: true,
|
|
1198
|
+
});
|
|
2083
1199
|
}
|
|
2084
1200
|
return res;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
this.logger.warn('[message-sender] Failed to resolve instance id:', instanceOrId);
|
|
1201
|
+
}
|
|
1202
|
+
_resolveInstanceId(instanceOrId) {
|
|
1203
|
+
if (typeof instanceOrId === 'string') {
|
|
1204
|
+
return instanceOrId;
|
|
2090
1205
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
1206
|
+
if (isInstanceArg(instanceOrId)) {
|
|
1207
|
+
return instanceOrId._instanceId;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
(() => {
|
|
1212
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
2097
1213
|
_sendVarGet_decorators = [Bind];
|
|
2098
1214
|
_sendStaticCall_decorators = [Bind];
|
|
2099
1215
|
_sendStaticCallSync_decorators = [Bind];
|
|
@@ -2104,343 +1220,247 @@ var MessageSenderImpl = function () {
|
|
|
2104
1220
|
_sendInstanceGet_decorators = [Bind];
|
|
2105
1221
|
_sendInstanceEventAdd_decorators = [Bind];
|
|
2106
1222
|
_sendInstanceEventRemove_decorators = [Bind];
|
|
2107
|
-
_sendDestroyInstance_decorators = [Bind];
|
|
2108
1223
|
_sendEventEmit_decorators = [Bind];
|
|
2109
1224
|
_sendEventEmitResult_decorators = [Bind];
|
|
2110
|
-
__esDecorate$1(_a, null, _sendVarGet_decorators, { kind: "method", name: "sendVarGet", static: false, private: false, access: { has:
|
|
2111
|
-
__esDecorate$1(_a, null, _sendStaticCall_decorators, { kind: "method", name: "sendStaticCall", static: false, private: false, access: { has:
|
|
2112
|
-
__esDecorate$1(_a, null, _sendStaticCallSync_decorators, { kind: "method", name: "sendStaticCallSync", static: false, private: false, access: { has:
|
|
2113
|
-
__esDecorate$1(_a, null, _sendNewInstanceCall_decorators, { kind: "method", name: "sendNewInstanceCall", static: false, private: false, access: { has:
|
|
2114
|
-
__esDecorate$1(_a, null, _sendInstanceCall_decorators, { kind: "method", name: "sendInstanceCall", static: false, private: false, access: { has:
|
|
2115
|
-
__esDecorate$1(_a, null, _sendInstanceCallSync_decorators, { kind: "method", name: "sendInstanceCallSync", static: false, private: false, access: { has:
|
|
2116
|
-
__esDecorate$1(_a, null, _sendInstanceSet_decorators, { kind: "method", name: "sendInstanceSet", static: false, private: false, access: { has:
|
|
2117
|
-
__esDecorate$1(_a, null, _sendInstanceGet_decorators, { kind: "method", name: "sendInstanceGet", static: false, private: false, access: { has:
|
|
2118
|
-
__esDecorate$1(_a, null, _sendInstanceEventAdd_decorators, { kind: "method", name: "sendInstanceEventAdd", static: false, private: false, access: { has:
|
|
2119
|
-
__esDecorate$1(_a, null, _sendInstanceEventRemove_decorators, { kind: "method", name: "sendInstanceEventRemove", static: false, private: false, access: { has:
|
|
2120
|
-
__esDecorate$1(_a, null,
|
|
2121
|
-
__esDecorate$1(_a, null,
|
|
2122
|
-
__esDecorate$1(_a, null, _sendEventEmitResult_decorators, { kind: "method", name: "sendEventEmitResult", static: false, private: false, access: { has: function (obj) { return "sendEventEmitResult" in obj; }, get: function (obj) { return obj.sendEventEmitResult; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1225
|
+
__esDecorate$1(_a, null, _sendVarGet_decorators, { kind: "method", name: "sendVarGet", static: false, private: false, access: { has: obj => "sendVarGet" in obj, get: obj => obj.sendVarGet }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1226
|
+
__esDecorate$1(_a, null, _sendStaticCall_decorators, { kind: "method", name: "sendStaticCall", static: false, private: false, access: { has: obj => "sendStaticCall" in obj, get: obj => obj.sendStaticCall }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1227
|
+
__esDecorate$1(_a, null, _sendStaticCallSync_decorators, { kind: "method", name: "sendStaticCallSync", static: false, private: false, access: { has: obj => "sendStaticCallSync" in obj, get: obj => obj.sendStaticCallSync }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1228
|
+
__esDecorate$1(_a, null, _sendNewInstanceCall_decorators, { kind: "method", name: "sendNewInstanceCall", static: false, private: false, access: { has: obj => "sendNewInstanceCall" in obj, get: obj => obj.sendNewInstanceCall }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1229
|
+
__esDecorate$1(_a, null, _sendInstanceCall_decorators, { kind: "method", name: "sendInstanceCall", static: false, private: false, access: { has: obj => "sendInstanceCall" in obj, get: obj => obj.sendInstanceCall }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1230
|
+
__esDecorate$1(_a, null, _sendInstanceCallSync_decorators, { kind: "method", name: "sendInstanceCallSync", static: false, private: false, access: { has: obj => "sendInstanceCallSync" in obj, get: obj => obj.sendInstanceCallSync }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1231
|
+
__esDecorate$1(_a, null, _sendInstanceSet_decorators, { kind: "method", name: "sendInstanceSet", static: false, private: false, access: { has: obj => "sendInstanceSet" in obj, get: obj => obj.sendInstanceSet }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1232
|
+
__esDecorate$1(_a, null, _sendInstanceGet_decorators, { kind: "method", name: "sendInstanceGet", static: false, private: false, access: { has: obj => "sendInstanceGet" in obj, get: obj => obj.sendInstanceGet }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1233
|
+
__esDecorate$1(_a, null, _sendInstanceEventAdd_decorators, { kind: "method", name: "sendInstanceEventAdd", static: false, private: false, access: { has: obj => "sendInstanceEventAdd" in obj, get: obj => obj.sendInstanceEventAdd }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1234
|
+
__esDecorate$1(_a, null, _sendInstanceEventRemove_decorators, { kind: "method", name: "sendInstanceEventRemove", static: false, private: false, access: { has: obj => "sendInstanceEventRemove" in obj, get: obj => obj.sendInstanceEventRemove }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1235
|
+
__esDecorate$1(_a, null, _sendEventEmit_decorators, { kind: "method", name: "sendEventEmit", static: false, private: false, access: { has: obj => "sendEventEmit" in obj, get: obj => obj.sendEventEmit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1236
|
+
__esDecorate$1(_a, null, _sendEventEmitResult_decorators, { kind: "method", name: "sendEventEmitResult", static: false, private: false, access: { has: obj => "sendEventEmitResult" in obj, get: obj => obj.sendEventEmitResult }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2123
1237
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2124
1238
|
})(),
|
|
2125
1239
|
_a;
|
|
2126
|
-
}();
|
|
1240
|
+
})();
|
|
2127
1241
|
|
|
2128
|
-
|
|
1242
|
+
let MessageClientImpl = (() => {
|
|
2129
1243
|
var _a;
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
return _a =
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
}
|
|
2142
|
-
MessageClientImpl.prototype.registerService = function (name, service) {
|
|
2143
|
-
this.logger.debug("[message-client] Register service: ".concat(name));
|
|
1244
|
+
let _classSuper = MessageSenderImpl;
|
|
1245
|
+
let _instanceExtraInitializers = [];
|
|
1246
|
+
let _registerService_decorators;
|
|
1247
|
+
let _registerInstance_decorators;
|
|
1248
|
+
let _handlerMessage_decorators;
|
|
1249
|
+
return _a = class MessageClientImpl extends _classSuper {
|
|
1250
|
+
constructor() {
|
|
1251
|
+
super(...arguments);
|
|
1252
|
+
this._globalScope = (__runInitializers$1(this, _instanceExtraInitializers), {});
|
|
1253
|
+
}
|
|
1254
|
+
registerService(name, service) {
|
|
2144
1255
|
this._globalScope[name] = service;
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
this.logger.debug("[message-client] Register instance: ".concat(id));
|
|
1256
|
+
}
|
|
1257
|
+
registerInstance(id, instance) {
|
|
2148
1258
|
this.proto.registerProxyInstance(id, instance);
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
root = this._globalScope;
|
|
2190
|
-
target = keyPathVisitor(root, paths);
|
|
2191
|
-
assert(!!target, "can\"t find static api, please check serviceName ".concat(serviceName));
|
|
2192
|
-
api = Reflect.get(target, property);
|
|
2193
|
-
assert(!!api, "can\"t find static api ".concat(target, ".").concat(property, ", please check serviceName ").concat(serviceName));
|
|
2194
|
-
decodeArgs = this.proto.decodeArgs(args);
|
|
2195
|
-
span = this.tracer.collectApiCall({
|
|
2196
|
-
source: 'native',
|
|
2197
|
-
target: 'js',
|
|
2198
|
-
serviceName: serviceName,
|
|
2199
|
-
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
2200
|
-
args: args,
|
|
2201
|
-
});
|
|
2202
|
-
_d.label = 1;
|
|
2203
|
-
case 1:
|
|
2204
|
-
_d.trys.push([1, 5, , 6]);
|
|
2205
|
-
if (!(typeof api === 'function')) return [3 /*break*/, 3];
|
|
2206
|
-
return [4 /*yield*/, api.apply(target, decodeArgs)];
|
|
2207
|
-
case 2:
|
|
2208
|
-
_c = _d.sent();
|
|
2209
|
-
return [3 /*break*/, 4];
|
|
2210
|
-
case 3:
|
|
2211
|
-
_c = api;
|
|
2212
|
-
_d.label = 4;
|
|
2213
|
-
case 4:
|
|
2214
|
-
value = _c;
|
|
2215
|
-
res = this._returnHandler(value);
|
|
2216
|
-
span.success(res);
|
|
2217
|
-
this.logger.debug("[message-client] Static API call success: ".concat(serviceName));
|
|
2218
|
-
return [2 /*return*/, res];
|
|
2219
|
-
case 5:
|
|
2220
|
-
err_1 = _d.sent();
|
|
2221
|
-
this.logger.error("[message-client] Static API call failed: ".concat(serviceName), err_1);
|
|
2222
|
-
span.fail(err_1);
|
|
2223
|
-
throw err_1;
|
|
2224
|
-
case 6: return [2 /*return*/];
|
|
2225
|
-
}
|
|
2226
|
-
});
|
|
1259
|
+
}
|
|
1260
|
+
async handlerMessage(req) {
|
|
1261
|
+
try {
|
|
1262
|
+
const { callType } = req;
|
|
1263
|
+
switch (callType) {
|
|
1264
|
+
case CALL_TYPE$1.PLAIN_API_CALL:
|
|
1265
|
+
return this._onCallStaticApi(req);
|
|
1266
|
+
case CALL_TYPE$1.INSTANCE_METHOD_INVOKE:
|
|
1267
|
+
return this._onCallInstanceApi(req);
|
|
1268
|
+
case CALL_TYPE$1.INSTANCE_EVENT_LISTENER_ADD:
|
|
1269
|
+
return this._onCallEventRegister(req);
|
|
1270
|
+
case CALL_TYPE$1.INSTANCE_EVENT_EMIT:
|
|
1271
|
+
return this._onCallEventEmit(req);
|
|
1272
|
+
case CALL_TYPE$1.CALLBACK_EMIT:
|
|
1273
|
+
return this._onCallbackEmit(req);
|
|
1274
|
+
default:
|
|
1275
|
+
throw new Error(`unknown callType "${callType}"`);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
catch (err) {
|
|
1279
|
+
this.logger.warn('handle remote call fail:', req, err);
|
|
1280
|
+
throw err;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
async _onCallStaticApi(req) {
|
|
1284
|
+
const { serviceName, args = [] } = req;
|
|
1285
|
+
const paths = serviceName.split('.');
|
|
1286
|
+
const property = paths.pop();
|
|
1287
|
+
const root = this._globalScope;
|
|
1288
|
+
const target = keyPathVisitor(root, paths);
|
|
1289
|
+
assert(!!target, `can"t find static api, please check serviceName ${serviceName}`);
|
|
1290
|
+
const api = Reflect.get(target, property);
|
|
1291
|
+
assert(!!api, `can"t find static api ${target}.${property}, please check serviceName ${serviceName}`);
|
|
1292
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1293
|
+
const span = this.tracer.collectApiCall({
|
|
1294
|
+
source: 'native',
|
|
1295
|
+
target: 'js',
|
|
1296
|
+
serviceName: serviceName,
|
|
1297
|
+
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
1298
|
+
args,
|
|
2227
1299
|
});
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
property = paths.pop();
|
|
2247
|
-
assert(typeof property === 'string', "incorrect serviceName \"".concat(serviceName, "\""));
|
|
2248
|
-
target = keyPathVisitor(instance, paths);
|
|
2249
|
-
assert(!!target, "can\"t find instance@".concat(_instanceId, " api, please check serviceName \"").concat(serviceName, "\" ").concat(target));
|
|
2250
|
-
api = Reflect.get(target, property, target);
|
|
2251
|
-
assert(!!api, "can\"t find instance@".concat(_instanceId, " api, please check serviceName \"").concat(serviceName, "\" ").concat(target, ".").concat(api));
|
|
2252
|
-
decodeArgs = args.map(function (arg) {
|
|
2253
|
-
if (isPlainObject(arg) &&
|
|
2254
|
-
arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
2255
|
-
return _this.proto.decodeInstance(arg);
|
|
2256
|
-
}
|
|
2257
|
-
if (isPlainObject(arg) &&
|
|
2258
|
-
arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
2259
|
-
return function () {
|
|
2260
|
-
var eventData = [];
|
|
2261
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2262
|
-
eventData[_i] = arguments[_i];
|
|
2263
|
-
}
|
|
2264
|
-
_this.sendEventEmit(_instanceId, serviceName, arg._callbackId, eventData);
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
|
-
return arg;
|
|
2268
|
-
});
|
|
2269
|
-
span = this.tracer.collectApiCall({
|
|
2270
|
-
source: 'native',
|
|
2271
|
-
target: 'js',
|
|
2272
|
-
serviceName: serviceName,
|
|
2273
|
-
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
2274
|
-
args: args,
|
|
2275
|
-
});
|
|
2276
|
-
_d.label = 1;
|
|
2277
|
-
case 1:
|
|
2278
|
-
_d.trys.push([1, 5, , 6]);
|
|
2279
|
-
if (!(typeof api === 'function')) return [3 /*break*/, 3];
|
|
2280
|
-
return [4 /*yield*/, api.apply(target, decodeArgs)];
|
|
2281
|
-
case 2:
|
|
2282
|
-
_c = _d.sent();
|
|
2283
|
-
return [3 /*break*/, 4];
|
|
2284
|
-
case 3:
|
|
2285
|
-
_c = api;
|
|
2286
|
-
_d.label = 4;
|
|
2287
|
-
case 4:
|
|
2288
|
-
value = _c;
|
|
2289
|
-
res = this._returnHandler(value);
|
|
2290
|
-
span.success(res);
|
|
2291
|
-
this.logger.debug("[message-client] Instance API call success: ".concat(serviceName));
|
|
2292
|
-
return [2 /*return*/, res];
|
|
2293
|
-
case 5:
|
|
2294
|
-
err_2 = _d.sent();
|
|
2295
|
-
this.logger.error("[message-client] Instance API call failed: ".concat(serviceName), err_2);
|
|
2296
|
-
span.fail(err_2);
|
|
2297
|
-
throw err_2;
|
|
2298
|
-
case 6: return [2 /*return*/];
|
|
2299
|
-
}
|
|
2300
|
-
});
|
|
1300
|
+
try {
|
|
1301
|
+
const value = typeof api === 'function' ? await api.apply(target, decodeArgs) : api;
|
|
1302
|
+
const res = this._returnHandler(value);
|
|
1303
|
+
span.success(res);
|
|
1304
|
+
return res;
|
|
1305
|
+
}
|
|
1306
|
+
catch (err) {
|
|
1307
|
+
span.fail(err);
|
|
1308
|
+
throw err;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
async _onCallInstanceApi(req) {
|
|
1312
|
+
const { serviceName, args = [], _instanceId } = req;
|
|
1313
|
+
const paths = serviceName.split('.');
|
|
1314
|
+
assert(!!_instanceId, 'callType is instanceCall, but missing _instanceId Params');
|
|
1315
|
+
const instance = this.proto.decodeInstance({
|
|
1316
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1317
|
+
_instanceId,
|
|
2301
1318
|
});
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
target: 'js',
|
|
2320
|
-
eventName: serviceName,
|
|
2321
|
-
});
|
|
2322
|
-
remoteCallbackId = args[0]._callbackId;
|
|
2323
|
-
proxyCallback = function () {
|
|
2324
|
-
var eventData = [];
|
|
2325
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2326
|
-
eventData[_i] = arguments[_i];
|
|
2327
|
-
}
|
|
2328
|
-
_this.sendEventEmit(_instanceId, serviceName, remoteCallbackId, eventData);
|
|
1319
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1320
|
+
paths.shift();
|
|
1321
|
+
const property = paths.pop();
|
|
1322
|
+
assert(typeof property === 'string', `incorrect serviceName "${serviceName}"`);
|
|
1323
|
+
const target = keyPathVisitor(instance, paths);
|
|
1324
|
+
assert(!!target, `can"t find instance@${_instanceId} api, please check serviceName "${serviceName}" ${target}`);
|
|
1325
|
+
const api = Reflect.get(target, property, target);
|
|
1326
|
+
assert(!!api, `can"t find instance@${_instanceId} api, please check serviceName "${serviceName}" ${target}.${api}`);
|
|
1327
|
+
const decodeArgs = args.map(arg => {
|
|
1328
|
+
if (isPlainObject(arg) &&
|
|
1329
|
+
arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
1330
|
+
return this.proto.decodeInstance(arg);
|
|
1331
|
+
}
|
|
1332
|
+
if (isPlainObject(arg) &&
|
|
1333
|
+
arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
1334
|
+
return (...eventData) => {
|
|
1335
|
+
this.sendEventEmit(_instanceId, serviceName, arg._callbackId, eventData);
|
|
2329
1336
|
};
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
instance.on(eventName, proxyCallback);
|
|
2333
|
-
this.logger.debug("[message-client] Event listener registered: ".concat(eventName));
|
|
2334
|
-
return [2 /*return*/, this._returnHandler(null)];
|
|
2335
|
-
});
|
|
1337
|
+
}
|
|
1338
|
+
return arg;
|
|
2336
1339
|
});
|
|
2337
|
-
|
|
1340
|
+
const span = this.tracer.collectApiCall({
|
|
1341
|
+
source: 'native',
|
|
1342
|
+
target: 'js',
|
|
1343
|
+
serviceName: serviceName,
|
|
1344
|
+
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1345
|
+
args,
|
|
1346
|
+
});
|
|
1347
|
+
try {
|
|
1348
|
+
const value = typeof api === 'function' ? await api.apply(target, decodeArgs) : api;
|
|
1349
|
+
const res = this._returnHandler(value);
|
|
1350
|
+
span.success(res);
|
|
1351
|
+
return res;
|
|
1352
|
+
}
|
|
1353
|
+
catch (err) {
|
|
1354
|
+
span.fail(err);
|
|
1355
|
+
throw err;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
async _onCallEventRegister(req) {
|
|
1359
|
+
const { args = [], _instanceId, serviceName } = req;
|
|
1360
|
+
assert(!!_instanceId, 'callType is "instance_event_register", but missing _instanceId Params');
|
|
1361
|
+
const instance = this.proto.decodeInstance({
|
|
1362
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1363
|
+
_instanceId,
|
|
1364
|
+
});
|
|
1365
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1366
|
+
assert(typeof instance.on === 'function', 'instance can"t "on"');
|
|
1367
|
+
this.tracer.collectEventOn({
|
|
1368
|
+
source: 'native',
|
|
1369
|
+
target: 'js',
|
|
1370
|
+
eventName: serviceName,
|
|
1371
|
+
});
|
|
1372
|
+
const remoteCallbackId = args[0]._callbackId;
|
|
1373
|
+
const proxyCallback = (...eventData) => {
|
|
1374
|
+
this.sendEventEmit(_instanceId, serviceName, remoteCallbackId, eventData);
|
|
1375
|
+
};
|
|
1376
|
+
const paths = serviceName.split('.');
|
|
1377
|
+
const eventName = paths[paths.length - 1];
|
|
1378
|
+
instance.on(eventName, proxyCallback);
|
|
1379
|
+
return this._returnHandler(null);
|
|
1380
|
+
}
|
|
2338
1381
|
/**
|
|
2339
1382
|
* 触发事件,优先通过 callbackId 找 callback,找不到通过 instanceId 找实例 emit
|
|
2340
1383
|
* @param req
|
|
2341
1384
|
* @returns
|
|
2342
1385
|
*/
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
source: 'native',
|
|
2353
|
-
target: 'js',
|
|
2354
|
-
eventName: eventName,
|
|
2355
|
-
eventData: decodeArgs,
|
|
2356
|
-
});
|
|
2357
|
-
assert(!!_instanceId, 'callType is "instance_event_emit", but missing "_instanceId" Params');
|
|
2358
|
-
instance = this.proto.decodeInstance({
|
|
2359
|
-
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
2360
|
-
_instanceId: _instanceId,
|
|
2361
|
-
});
|
|
2362
|
-
assert(!!instance, "can\"t find instance, instanceId ".concat(_instanceId, " incorrect"));
|
|
2363
|
-
returnParams = null;
|
|
2364
|
-
res = null;
|
|
2365
|
-
try {
|
|
2366
|
-
if (typeof instance.emit === 'function') {
|
|
2367
|
-
res = instance.emit.apply(instance, __spreadArray$1([eventName], decodeArgs, false));
|
|
2368
|
-
returnParams = this._returnHandler(res);
|
|
2369
|
-
this.logger.debug("[message-client] Event emitted successfully: ".concat(eventName));
|
|
2370
|
-
}
|
|
2371
|
-
else if (typeof instance[eventName] === 'function') {
|
|
2372
|
-
res = instance[eventName].apply(instance, decodeArgs);
|
|
2373
|
-
returnParams = this._returnHandler(res);
|
|
2374
|
-
this.logger.debug("[message-client] Event handler executed: ".concat(eventName));
|
|
2375
|
-
}
|
|
2376
|
-
else {
|
|
2377
|
-
this.logger.debug("[message-client] Unknown event \"".concat(eventName, "\""));
|
|
2378
|
-
returnParams = {
|
|
2379
|
-
status: RETURN_STATUS$1.NOT_IMPLEMENTED,
|
|
2380
|
-
msg: {},
|
|
2381
|
-
};
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
catch (err) {
|
|
2385
|
-
this.logger.error("[message-client] Event emit failed: ".concat(eventName), err);
|
|
2386
|
-
returnParams = {
|
|
2387
|
-
status: RETURN_STATUS$1.FAILED,
|
|
2388
|
-
msg: {
|
|
2389
|
-
errorMessage: (err === null || err === void 0 ? void 0 : err.message) || '',
|
|
2390
|
-
errorCode: -1,
|
|
2391
|
-
},
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
returnParams._traceId = _traceId;
|
|
2395
|
-
if (waitResult) {
|
|
2396
|
-
this.sendEventEmitResult(_instanceId, serviceName, returnParams);
|
|
2397
|
-
}
|
|
2398
|
-
return [2 /*return*/, returnParams];
|
|
2399
|
-
});
|
|
1386
|
+
async _onCallEventEmit(req) {
|
|
1387
|
+
const { args = [], serviceName, methodName, waitResult, _traceId, _instanceId, } = req;
|
|
1388
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1389
|
+
const eventName = methodName || serviceName;
|
|
1390
|
+
this.tracer.collectEventEmit({
|
|
1391
|
+
source: 'native',
|
|
1392
|
+
target: 'js',
|
|
1393
|
+
eventName: eventName,
|
|
1394
|
+
eventData: decodeArgs,
|
|
2400
1395
|
});
|
|
2401
|
-
|
|
1396
|
+
assert(!!_instanceId, 'callType is "instance_event_emit", but missing "_instanceId" Params');
|
|
1397
|
+
const instance = this.proto.decodeInstance({
|
|
1398
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1399
|
+
_instanceId,
|
|
1400
|
+
});
|
|
1401
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1402
|
+
let returnParams = null;
|
|
1403
|
+
let res = null;
|
|
1404
|
+
try {
|
|
1405
|
+
if (typeof instance.emit === 'function') {
|
|
1406
|
+
res = instance.emit(eventName, ...decodeArgs);
|
|
1407
|
+
returnParams = this._returnHandler(res);
|
|
1408
|
+
}
|
|
1409
|
+
else if (typeof instance[eventName] === 'function') {
|
|
1410
|
+
res = instance[eventName].apply(instance, decodeArgs);
|
|
1411
|
+
returnParams = this._returnHandler(res);
|
|
1412
|
+
}
|
|
1413
|
+
else {
|
|
1414
|
+
this.logger.warn(`unknown event "${eventName}"`);
|
|
1415
|
+
returnParams = {
|
|
1416
|
+
status: RETURN_STATUS$1.NOT_IMPLEMENTED,
|
|
1417
|
+
msg: {},
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
catch (err) {
|
|
1422
|
+
returnParams = {
|
|
1423
|
+
status: RETURN_STATUS$1.FAILED,
|
|
1424
|
+
msg: {
|
|
1425
|
+
errorMessage: err?.message || '',
|
|
1426
|
+
errorCode: -1,
|
|
1427
|
+
},
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
returnParams._traceId = _traceId;
|
|
1431
|
+
if (waitResult) {
|
|
1432
|
+
this.sendEventEmitResult(_instanceId, serviceName, returnParams);
|
|
1433
|
+
}
|
|
1434
|
+
return returnParams;
|
|
1435
|
+
}
|
|
2402
1436
|
/**
|
|
2403
1437
|
* 触发回调,优先通过 callbackId 找 callback,找不到通过 instanceId 找实例 emit
|
|
2404
1438
|
* @param req
|
|
2405
1439
|
* @returns
|
|
2406
1440
|
*/
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
source: 'native',
|
|
2417
|
-
target: 'js',
|
|
2418
|
-
eventName: eventName,
|
|
2419
|
-
eventData: decodeArgs,
|
|
2420
|
-
});
|
|
2421
|
-
assert(!!_instanceId, 'callType is "callback_emit", but missing "_instanceId" Params');
|
|
2422
|
-
callback = this.proto.decodeCallback({
|
|
2423
|
-
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
2424
|
-
_callbackId: _instanceId,
|
|
2425
|
-
});
|
|
2426
|
-
assert(typeof callback === 'function', "can\"t find callback, callback_id ".concat(_instanceId, " incorrect"));
|
|
2427
|
-
try {
|
|
2428
|
-
callback.apply(null, decodeArgs);
|
|
2429
|
-
this.logger.debug("[message-client] Callback executed successfully: ".concat(eventName));
|
|
2430
|
-
return [2 /*return*/, this._returnHandler(null)];
|
|
2431
|
-
}
|
|
2432
|
-
catch (err) {
|
|
2433
|
-
this.logger.error("[message-client] Callback execution failed: ".concat(eventName), err);
|
|
2434
|
-
throw err;
|
|
2435
|
-
}
|
|
2436
|
-
return [2 /*return*/];
|
|
2437
|
-
});
|
|
1441
|
+
async _onCallbackEmit(req) {
|
|
1442
|
+
const { args = [], serviceName, methodName, _instanceId } = req;
|
|
1443
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1444
|
+
const eventName = methodName || serviceName;
|
|
1445
|
+
this.tracer.collectCallbackEmit({
|
|
1446
|
+
source: 'native',
|
|
1447
|
+
target: 'js',
|
|
1448
|
+
eventName: eventName,
|
|
1449
|
+
eventData: decodeArgs,
|
|
2438
1450
|
});
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
1451
|
+
assert(!!_instanceId, 'callType is "callback_emit", but missing "_instanceId" Params');
|
|
1452
|
+
const callback = this.proto.decodeCallback({
|
|
1453
|
+
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
1454
|
+
_callbackId: _instanceId,
|
|
1455
|
+
});
|
|
1456
|
+
assert(typeof callback === 'function', `can"t find callback, callback_id ${_instanceId} incorrect`);
|
|
1457
|
+
callback.apply(null, decodeArgs);
|
|
1458
|
+
return this._returnHandler(null);
|
|
1459
|
+
}
|
|
1460
|
+
_returnHandler(response) {
|
|
1461
|
+
this.logger.verbose('response:', response);
|
|
1462
|
+
const encodeResponse = this.proto.encodeArg(response);
|
|
1463
|
+
const returnVal = {
|
|
2444
1464
|
status: RETURN_STATUS$1.SUCCESS,
|
|
2445
1465
|
msg: encodeResponse === undefined
|
|
2446
1466
|
? null
|
|
@@ -2449,22 +1469,20 @@ var MessageClientImpl = function () {
|
|
|
2449
1469
|
: encodeResponse,
|
|
2450
1470
|
};
|
|
2451
1471
|
return returnVal;
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
var _b;
|
|
2457
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
(() => {
|
|
1475
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
2458
1476
|
_registerService_decorators = [Bind];
|
|
2459
1477
|
_registerInstance_decorators = [Bind];
|
|
2460
1478
|
_handlerMessage_decorators = [Bind];
|
|
2461
|
-
__esDecorate$1(_a, null, _registerService_decorators, { kind: "method", name: "registerService", static: false, private: false, access: { has:
|
|
2462
|
-
__esDecorate$1(_a, null, _registerInstance_decorators, { kind: "method", name: "registerInstance", static: false, private: false, access: { has:
|
|
2463
|
-
__esDecorate$1(_a, null, _handlerMessage_decorators, { kind: "method", name: "handlerMessage", static: false, private: false, access: { has:
|
|
1479
|
+
__esDecorate$1(_a, null, _registerService_decorators, { kind: "method", name: "registerService", static: false, private: false, access: { has: obj => "registerService" in obj, get: obj => obj.registerService }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1480
|
+
__esDecorate$1(_a, null, _registerInstance_decorators, { kind: "method", name: "registerInstance", static: false, private: false, access: { has: obj => "registerInstance" in obj, get: obj => obj.registerInstance }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1481
|
+
__esDecorate$1(_a, null, _handlerMessage_decorators, { kind: "method", name: "handlerMessage", static: false, private: false, access: { has: obj => "handlerMessage" in obj, get: obj => obj.handlerMessage }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2464
1482
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2465
1483
|
})(),
|
|
2466
1484
|
_a;
|
|
2467
|
-
}();
|
|
1485
|
+
})();
|
|
2468
1486
|
|
|
2469
1487
|
function createProxyInstance(raw) {
|
|
2470
1488
|
Object.defineProperty(raw, '$$native', {
|
|
@@ -2488,85 +1506,74 @@ function isArrayBuffer(val) {
|
|
|
2488
1506
|
function isBuffer(val) {
|
|
2489
1507
|
return isArrayBuffer(val) || isDateView(val);
|
|
2490
1508
|
}
|
|
2491
|
-
|
|
1509
|
+
let MessageProtoImpl = (() => {
|
|
2492
1510
|
var _a;
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
return _a =
|
|
2505
|
-
|
|
1511
|
+
let _instanceExtraInitializers = [];
|
|
1512
|
+
let _encodeArgs_decorators;
|
|
1513
|
+
let _encodeInstance_decorators;
|
|
1514
|
+
let _decodeInstance_decorators;
|
|
1515
|
+
let _encodeCallback_decorators;
|
|
1516
|
+
let _decodeCallback_decorators;
|
|
1517
|
+
let _encodeBase64_decorators;
|
|
1518
|
+
let _decodeBase64_decorators;
|
|
1519
|
+
let _encodeArg_decorators;
|
|
1520
|
+
let _decodeArgs_decorators;
|
|
1521
|
+
let _decodeArg_decorators;
|
|
1522
|
+
return _a = class MessageProtoImpl {
|
|
1523
|
+
constructor() {
|
|
2506
1524
|
this._idMapInstance = (__runInitializers$1(this, _instanceExtraInitializers), {});
|
|
2507
1525
|
this._instanceMapId = new WeakMap();
|
|
2508
1526
|
this._idMapCallback = {};
|
|
2509
1527
|
this._callbackMapId = new WeakMap();
|
|
2510
|
-
this._logger = LoggerImpl.getInstance();
|
|
2511
1528
|
}
|
|
2512
|
-
|
|
2513
|
-
this._logger.debug("[message-proto] Registering proxy instance with id: ".concat(id));
|
|
1529
|
+
registerProxyInstance(id, instance) {
|
|
2514
1530
|
this._idMapInstance[id] = instance;
|
|
2515
1531
|
this._instanceMapId.set(instance, id);
|
|
2516
|
-
}
|
|
2517
|
-
|
|
1532
|
+
}
|
|
1533
|
+
encodeArgs(args) {
|
|
2518
1534
|
return args.map(this.encodeArg);
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
var instanceId = this._findOrCreateInstanceId(arg);
|
|
2522
|
-
this._logger.debug("[message-proto] Encoding instance with id: ".concat(instanceId));
|
|
1535
|
+
}
|
|
1536
|
+
encodeInstance(arg) {
|
|
2523
1537
|
return {
|
|
2524
1538
|
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
2525
|
-
_instanceId:
|
|
1539
|
+
_instanceId: this._findOrCreateInstanceId(arg),
|
|
2526
1540
|
_serviceName: arg.namespace ||
|
|
2527
1541
|
arg._namespace ||
|
|
2528
1542
|
arg._serviceName,
|
|
2529
1543
|
};
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
var instance = this._findInstance(arg._instanceId);
|
|
1544
|
+
}
|
|
1545
|
+
decodeInstance(arg) {
|
|
1546
|
+
let instance = this._findInstance(arg._instanceId);
|
|
2534
1547
|
if (!instance) {
|
|
2535
|
-
|
|
1548
|
+
// TODO:
|
|
2536
1549
|
instance = createProxyInstance(arg);
|
|
2537
1550
|
this._idMapInstance[arg._instanceId] = instance;
|
|
2538
1551
|
}
|
|
2539
1552
|
return instance;
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
var callbackId = this._findOrCreateCallbackId(arg);
|
|
2543
|
-
this._logger.debug("[message-proto] Encoding callback with id: ".concat(callbackId));
|
|
1553
|
+
}
|
|
1554
|
+
encodeCallback(arg) {
|
|
2544
1555
|
return {
|
|
2545
1556
|
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
2546
|
-
_callbackId:
|
|
1557
|
+
_callbackId: this._findOrCreateCallbackId(arg),
|
|
2547
1558
|
};
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
this._logger.debug("[message-proto] Decoding callback with id: ".concat(arg._callbackId));
|
|
1559
|
+
}
|
|
1560
|
+
decodeCallback(arg) {
|
|
2551
1561
|
return this._findCallback(arg._callbackId) || arg;
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
var buf = bufferLike.buffer || bufferLike;
|
|
1562
|
+
}
|
|
1563
|
+
encodeBase64(bufferLike) {
|
|
1564
|
+
const buf = bufferLike.buffer || bufferLike;
|
|
2556
1565
|
return {
|
|
2557
1566
|
_type: "base64" /* ARG_TYPE.BASE64 */,
|
|
2558
1567
|
_value: buf2base64(buf),
|
|
2559
1568
|
};
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
var buf = uint8.buffer;
|
|
1569
|
+
}
|
|
1570
|
+
decodeBase64(arg) {
|
|
1571
|
+
const base64 = arg._value;
|
|
1572
|
+
const uint8 = gBase64.toUint8Array(base64);
|
|
1573
|
+
const buf = uint8.buffer;
|
|
2566
1574
|
return buf;
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
var _this = this;
|
|
1575
|
+
}
|
|
1576
|
+
encodeArg(arg) {
|
|
2570
1577
|
if (isBuffer(arg)) {
|
|
2571
1578
|
return this.encodeBase64(arg);
|
|
2572
1579
|
}
|
|
@@ -2580,26 +1587,23 @@ var MessageProtoImpl = function () {
|
|
|
2580
1587
|
return this.encodeInstance(arg);
|
|
2581
1588
|
}
|
|
2582
1589
|
if (isPlainObject(arg)) {
|
|
2583
|
-
return mapValues(arg,
|
|
2584
|
-
return
|
|
1590
|
+
return mapValues(arg, (value) => {
|
|
1591
|
+
return this.encodeArg(value);
|
|
2585
1592
|
});
|
|
2586
1593
|
}
|
|
2587
1594
|
return arg;
|
|
2588
|
-
}
|
|
2589
|
-
|
|
1595
|
+
}
|
|
1596
|
+
decodeArgs(args) {
|
|
2590
1597
|
return args.map(this.decodeArg);
|
|
2591
|
-
}
|
|
1598
|
+
}
|
|
2592
1599
|
// @CatchError
|
|
2593
|
-
|
|
2594
|
-
var _this = this;
|
|
1600
|
+
decodeArg(arg) {
|
|
2595
1601
|
if (isPlainObject(arg) &&
|
|
2596
1602
|
arg._type === "base64" /* ARG_TYPE.BASE64 */) {
|
|
2597
1603
|
return this.decodeBase64(arg);
|
|
2598
1604
|
}
|
|
2599
1605
|
if (isPlainObject(arg) && arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
2600
|
-
|
|
2601
|
-
Object.assign(ins, arg);
|
|
2602
|
-
return ins;
|
|
1606
|
+
return this.decodeInstance(arg);
|
|
2603
1607
|
}
|
|
2604
1608
|
if (isPlainObject(arg) && arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
2605
1609
|
return this.decodeCallback(arg);
|
|
@@ -2608,54 +1612,42 @@ var MessageProtoImpl = function () {
|
|
|
2608
1612
|
return arg.map(this.decodeArg);
|
|
2609
1613
|
}
|
|
2610
1614
|
if (isPlainObject(arg)) {
|
|
2611
|
-
return mapValues(arg,
|
|
2612
|
-
return
|
|
1615
|
+
return mapValues(arg, (value) => {
|
|
1616
|
+
return this.decodeArg(value);
|
|
2613
1617
|
});
|
|
2614
1618
|
}
|
|
2615
1619
|
return arg;
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
return instance;
|
|
2623
|
-
};
|
|
2624
|
-
MessageProtoImpl.prototype._findOrCreateInstanceId = function (instance) {
|
|
2625
|
-
var _b;
|
|
2626
|
-
var id = this._instanceMapId.get(instance);
|
|
1620
|
+
}
|
|
1621
|
+
_findInstance(id) {
|
|
1622
|
+
return this._idMapInstance[id];
|
|
1623
|
+
}
|
|
1624
|
+
_findOrCreateInstanceId(instance) {
|
|
1625
|
+
let id = this._instanceMapId.get(instance);
|
|
2627
1626
|
if (id === undefined) {
|
|
2628
1627
|
id =
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
getUuid(
|
|
2632
|
-
this._logger.debug("[message-proto] Created new instance id: ".concat(id));
|
|
1628
|
+
instance?.instanceId ||
|
|
1629
|
+
instance?._instanceId ||
|
|
1630
|
+
getUuid(instance?.constructor?.name);
|
|
2633
1631
|
this._instanceMapId.set(instance, id);
|
|
2634
1632
|
this._idMapInstance[id] = instance;
|
|
2635
1633
|
}
|
|
2636
1634
|
return id;
|
|
2637
|
-
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
return callback;
|
|
2644
|
-
};
|
|
2645
|
-
MessageProtoImpl.prototype._findOrCreateCallbackId = function (value) {
|
|
2646
|
-
var id = this._callbackMapId.get(value);
|
|
1635
|
+
}
|
|
1636
|
+
_findCallback(id) {
|
|
1637
|
+
return this._idMapCallback[id];
|
|
1638
|
+
}
|
|
1639
|
+
_findOrCreateCallbackId(value) {
|
|
1640
|
+
let id = this._callbackMapId.get(value);
|
|
2647
1641
|
if (id === undefined) {
|
|
2648
|
-
id = getUuid(value
|
|
2649
|
-
this._logger.debug("[message-proto] Created new callback id: ".concat(id));
|
|
1642
|
+
id = getUuid(value?.name);
|
|
2650
1643
|
this._callbackMapId.set(value, id);
|
|
2651
1644
|
this._idMapCallback[id] = value;
|
|
2652
1645
|
}
|
|
2653
1646
|
return id;
|
|
2654
|
-
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
(() => {
|
|
1650
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
2659
1651
|
_encodeArgs_decorators = [Bind];
|
|
2660
1652
|
_encodeInstance_decorators = [Bind];
|
|
2661
1653
|
_decodeInstance_decorators = [Bind];
|
|
@@ -2666,50 +1658,48 @@ var MessageProtoImpl = function () {
|
|
|
2666
1658
|
_encodeArg_decorators = [Bind];
|
|
2667
1659
|
_decodeArgs_decorators = [Bind];
|
|
2668
1660
|
_decodeArg_decorators = [Bind];
|
|
2669
|
-
__esDecorate$1(_a, null, _encodeArgs_decorators, { kind: "method", name: "encodeArgs", static: false, private: false, access: { has:
|
|
2670
|
-
__esDecorate$1(_a, null, _encodeInstance_decorators, { kind: "method", name: "encodeInstance", static: false, private: false, access: { has:
|
|
2671
|
-
__esDecorate$1(_a, null, _decodeInstance_decorators, { kind: "method", name: "decodeInstance", static: false, private: false, access: { has:
|
|
2672
|
-
__esDecorate$1(_a, null, _encodeCallback_decorators, { kind: "method", name: "encodeCallback", static: false, private: false, access: { has:
|
|
2673
|
-
__esDecorate$1(_a, null, _decodeCallback_decorators, { kind: "method", name: "decodeCallback", static: false, private: false, access: { has:
|
|
2674
|
-
__esDecorate$1(_a, null, _encodeBase64_decorators, { kind: "method", name: "encodeBase64", static: false, private: false, access: { has:
|
|
2675
|
-
__esDecorate$1(_a, null, _decodeBase64_decorators, { kind: "method", name: "decodeBase64", static: false, private: false, access: { has:
|
|
2676
|
-
__esDecorate$1(_a, null, _encodeArg_decorators, { kind: "method", name: "encodeArg", static: false, private: false, access: { has:
|
|
2677
|
-
__esDecorate$1(_a, null, _decodeArgs_decorators, { kind: "method", name: "decodeArgs", static: false, private: false, access: { has:
|
|
2678
|
-
__esDecorate$1(_a, null, _decodeArg_decorators, { kind: "method", name: "decodeArg", static: false, private: false, access: { has:
|
|
1661
|
+
__esDecorate$1(_a, null, _encodeArgs_decorators, { kind: "method", name: "encodeArgs", static: false, private: false, access: { has: obj => "encodeArgs" in obj, get: obj => obj.encodeArgs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1662
|
+
__esDecorate$1(_a, null, _encodeInstance_decorators, { kind: "method", name: "encodeInstance", static: false, private: false, access: { has: obj => "encodeInstance" in obj, get: obj => obj.encodeInstance }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1663
|
+
__esDecorate$1(_a, null, _decodeInstance_decorators, { kind: "method", name: "decodeInstance", static: false, private: false, access: { has: obj => "decodeInstance" in obj, get: obj => obj.decodeInstance }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1664
|
+
__esDecorate$1(_a, null, _encodeCallback_decorators, { kind: "method", name: "encodeCallback", static: false, private: false, access: { has: obj => "encodeCallback" in obj, get: obj => obj.encodeCallback }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1665
|
+
__esDecorate$1(_a, null, _decodeCallback_decorators, { kind: "method", name: "decodeCallback", static: false, private: false, access: { has: obj => "decodeCallback" in obj, get: obj => obj.decodeCallback }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1666
|
+
__esDecorate$1(_a, null, _encodeBase64_decorators, { kind: "method", name: "encodeBase64", static: false, private: false, access: { has: obj => "encodeBase64" in obj, get: obj => obj.encodeBase64 }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1667
|
+
__esDecorate$1(_a, null, _decodeBase64_decorators, { kind: "method", name: "decodeBase64", static: false, private: false, access: { has: obj => "decodeBase64" in obj, get: obj => obj.decodeBase64 }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1668
|
+
__esDecorate$1(_a, null, _encodeArg_decorators, { kind: "method", name: "encodeArg", static: false, private: false, access: { has: obj => "encodeArg" in obj, get: obj => obj.encodeArg }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1669
|
+
__esDecorate$1(_a, null, _decodeArgs_decorators, { kind: "method", name: "decodeArgs", static: false, private: false, access: { has: obj => "decodeArgs" in obj, get: obj => obj.decodeArgs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1670
|
+
__esDecorate$1(_a, null, _decodeArg_decorators, { kind: "method", name: "decodeArg", static: false, private: false, access: { has: obj => "decodeArg" in obj, get: obj => obj.decodeArg }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2679
1671
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2680
1672
|
})(),
|
|
2681
1673
|
_a;
|
|
2682
|
-
}();
|
|
1674
|
+
})();
|
|
2683
1675
|
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
1676
|
+
const createMessageClient = (jsBridge) => {
|
|
1677
|
+
const proto = new MessageProtoImpl();
|
|
1678
|
+
const client = new MessageClientImpl(proto, jsBridge);
|
|
2687
1679
|
return client;
|
|
2688
1680
|
};
|
|
2689
1681
|
|
|
2690
|
-
|
|
2691
|
-
|
|
1682
|
+
let jsBridge = createJSBridge();
|
|
1683
|
+
const globalMessageClient = createMessageClient(jsBridge);
|
|
2692
1684
|
function getGlobalMessageClient() {
|
|
2693
1685
|
return globalMessageClient;
|
|
2694
1686
|
}
|
|
2695
1687
|
function setupJSBridge(impl) {
|
|
2696
1688
|
jsBridge = impl;
|
|
2697
1689
|
globalMessageClient.bridge = impl;
|
|
2698
|
-
impl.registerAsyncHandler('emitEvent',
|
|
1690
|
+
impl.registerAsyncHandler('emitEvent', (params) => {
|
|
2699
1691
|
return globalMessageClient.handlerMessage(params);
|
|
2700
1692
|
});
|
|
2701
1693
|
}
|
|
2702
1694
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
if (messageClient === void 0) { messageClient = getGlobalMessageClient(); }
|
|
1695
|
+
class NativeProxyService {
|
|
1696
|
+
constructor(messageClient = getGlobalMessageClient()) {
|
|
2706
1697
|
this.messageClient = messageClient;
|
|
2707
1698
|
this.namespace = '';
|
|
2708
1699
|
this.instanceId = getUuid(this.namespace);
|
|
2709
1700
|
this._instanced = this.instanceId;
|
|
2710
1701
|
}
|
|
2711
|
-
|
|
2712
|
-
}());
|
|
1702
|
+
}
|
|
2713
1703
|
function getMessageClient(impl) {
|
|
2714
1704
|
if (typeof impl === 'object' &&
|
|
2715
1705
|
!!impl &&
|
|
@@ -2729,8 +1719,8 @@ function isNativeCreatedInstance(val) {
|
|
|
2729
1719
|
return false;
|
|
2730
1720
|
}
|
|
2731
1721
|
function proxyValue(val, ctor) {
|
|
2732
|
-
|
|
2733
|
-
|
|
1722
|
+
const client = getMessageClient(val);
|
|
1723
|
+
const service = new ctor(DISABLE_INIT);
|
|
2734
1724
|
service.messageClient = client;
|
|
2735
1725
|
service.instanceId = val._instanceId;
|
|
2736
1726
|
// @ts-ignore
|
|
@@ -2745,6 +1735,298 @@ function proxyNativeInstance(value, ctor) {
|
|
|
2745
1735
|
return value;
|
|
2746
1736
|
}
|
|
2747
1737
|
|
|
1738
|
+
function assertReturn(ret) {
|
|
1739
|
+
if (!ret || typeof ret !== 'object') {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
if (ret.status === RETURN_STATUS$1.FAILED) {
|
|
1743
|
+
throw new Error(String(ret.msg));
|
|
1744
|
+
}
|
|
1745
|
+
return ret.decoded || ret.msg;
|
|
1746
|
+
}
|
|
1747
|
+
function isPromiseLike(val) {
|
|
1748
|
+
if (typeof val === 'object' && val !== null) {
|
|
1749
|
+
if (typeof val.then === 'function') {
|
|
1750
|
+
return true;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return false;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
const KEY_NAMESPACE = Symbol.for('#namespace');
|
|
1757
|
+
const KEY_NATIVE_CLASS_NAME = Symbol.for('#nativeClassName');
|
|
1758
|
+
function findNamespace(ctor) {
|
|
1759
|
+
let obj = ctor;
|
|
1760
|
+
let desc;
|
|
1761
|
+
while (!desc && obj) {
|
|
1762
|
+
desc = Object.getOwnPropertyDescriptor(obj, KEY_NAMESPACE);
|
|
1763
|
+
obj = Object.getPrototypeOf(obj);
|
|
1764
|
+
}
|
|
1765
|
+
return desc?.value;
|
|
1766
|
+
}
|
|
1767
|
+
function findMethods(ins, opt = {}) {
|
|
1768
|
+
let methodNames = [];
|
|
1769
|
+
let proto = Object.getPrototypeOf(ins);
|
|
1770
|
+
while (proto && proto !== Object.prototype) {
|
|
1771
|
+
const ownMethods = Object.getOwnPropertyNames(proto)
|
|
1772
|
+
.filter(name => name !== 'constructor')
|
|
1773
|
+
.map(name => opt[name] || name);
|
|
1774
|
+
methodNames.push(...ownMethods);
|
|
1775
|
+
proto = Object.getPrototypeOf(proto);
|
|
1776
|
+
}
|
|
1777
|
+
return methodNames;
|
|
1778
|
+
}
|
|
1779
|
+
const NativeObserverClass = (className, opt = {}) => (target, ctx) => {
|
|
1780
|
+
ctx.addInitializer(function () {
|
|
1781
|
+
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
1782
|
+
value: className,
|
|
1783
|
+
writable: true,
|
|
1784
|
+
});
|
|
1785
|
+
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
1786
|
+
});
|
|
1787
|
+
// @ts-ignore
|
|
1788
|
+
return class extends target {
|
|
1789
|
+
constructor(...args) {
|
|
1790
|
+
super(...args);
|
|
1791
|
+
const t = this;
|
|
1792
|
+
const instanceId = getUuid(className);
|
|
1793
|
+
t.namespace = className;
|
|
1794
|
+
t.instanceId = instanceId;
|
|
1795
|
+
t.messageClient = getMessageClient(t);
|
|
1796
|
+
t.options = opt;
|
|
1797
|
+
// custom consume native event
|
|
1798
|
+
/**
|
|
1799
|
+
* @param this
|
|
1800
|
+
* @param name native method name
|
|
1801
|
+
* @param params
|
|
1802
|
+
*/
|
|
1803
|
+
t.emit = function (name, ...params) {
|
|
1804
|
+
const curName = Object.entries(opt).find(([, v]) => v === name)?.[0] || name;
|
|
1805
|
+
const fn = this[curName];
|
|
1806
|
+
if (typeof fn === 'function') {
|
|
1807
|
+
return fn.apply(this, params);
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
const _init = () => {
|
|
1811
|
+
const events = findMethods(this, opt);
|
|
1812
|
+
t.messageClient.sendNewInstanceCall(className, [events], instanceId, this);
|
|
1813
|
+
};
|
|
1814
|
+
// proxy native created class
|
|
1815
|
+
if (!args.includes(DISABLE_INIT)) {
|
|
1816
|
+
_init();
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
};
|
|
1821
|
+
const NativeClass = (className, opt = {}) => (target, ctx) => {
|
|
1822
|
+
ctx.addInitializer(function () {
|
|
1823
|
+
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
1824
|
+
value: className,
|
|
1825
|
+
writable: true,
|
|
1826
|
+
});
|
|
1827
|
+
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
1828
|
+
});
|
|
1829
|
+
// @ts-ignore
|
|
1830
|
+
return class extends target {
|
|
1831
|
+
constructor(...args) {
|
|
1832
|
+
super(...args);
|
|
1833
|
+
const t = this;
|
|
1834
|
+
const instanceId = getUuid(className);
|
|
1835
|
+
t.namespace = className;
|
|
1836
|
+
t.instanceId = instanceId;
|
|
1837
|
+
t.messageClient = getMessageClient(t);
|
|
1838
|
+
const _init = () => {
|
|
1839
|
+
t.messageClient.sendNewInstanceCall(className, args.filter(v => v !== undefined), instanceId, this);
|
|
1840
|
+
if (getOS() === "ios" /* OS.ios */ &&
|
|
1841
|
+
typeof this.init === 'function') {
|
|
1842
|
+
this.init();
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
// proxy native created class
|
|
1846
|
+
if (!args.includes(DISABLE_INIT)) {
|
|
1847
|
+
_init();
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
};
|
|
1852
|
+
const NativeStaticMethodSync = (methodSelector) => (target, ctx) => {
|
|
1853
|
+
const name = ctx.name;
|
|
1854
|
+
return function impl(...args) {
|
|
1855
|
+
const namespace = findNamespace(this);
|
|
1856
|
+
const client = getMessageClient(this);
|
|
1857
|
+
const returnValue = client.sendStaticCallSync(namespace || '', methodSelector || name, args);
|
|
1858
|
+
const data = assertReturn(returnValue);
|
|
1859
|
+
return data;
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
const ReturnClass = (getCtor) => (target, ctx) => {
|
|
1863
|
+
// TODO: impl
|
|
1864
|
+
return function impl(...args) {
|
|
1865
|
+
const returnValue = target.apply(this, args);
|
|
1866
|
+
if (isPromiseLike(returnValue)) {
|
|
1867
|
+
return returnValue.then(v => {
|
|
1868
|
+
return proxyNativeInstance(v, getCtor());
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
return proxyNativeInstance(returnValue, getCtor());
|
|
1872
|
+
};
|
|
1873
|
+
};
|
|
1874
|
+
const NativeMember = ({ cache, readonly } = {}) => (_, ctx) => {
|
|
1875
|
+
ctx.addInitializer(function () {
|
|
1876
|
+
const field = ctx.name;
|
|
1877
|
+
const key = Symbol.for(ctx.name);
|
|
1878
|
+
Object.defineProperty(this, field, {
|
|
1879
|
+
get: () => {
|
|
1880
|
+
if (cache && this[key] !== undefined) {
|
|
1881
|
+
return this[key];
|
|
1882
|
+
}
|
|
1883
|
+
const { instanceId, namespace } = this;
|
|
1884
|
+
const ret = getMessageClient(this).sendInstanceGet(instanceId, namespace || '', field);
|
|
1885
|
+
const value = assertReturn(ret);
|
|
1886
|
+
this[key] = value;
|
|
1887
|
+
return value;
|
|
1888
|
+
},
|
|
1889
|
+
set: v => {
|
|
1890
|
+
if (readonly) {
|
|
1891
|
+
throw new Error(`field ${field} is readonly.`);
|
|
1892
|
+
}
|
|
1893
|
+
this[key] = v;
|
|
1894
|
+
const { instanceId, namespace } = this;
|
|
1895
|
+
getMessageClient(this).sendInstanceSet(instanceId, namespace || '', field, v);
|
|
1896
|
+
},
|
|
1897
|
+
});
|
|
1898
|
+
});
|
|
1899
|
+
return _;
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
const key = Symbol.for('args');
|
|
1903
|
+
function processArg(method) {
|
|
1904
|
+
const args = method[key] ?? [];
|
|
1905
|
+
return (arg, idx) => {
|
|
1906
|
+
return args[idx]?.transform(arg) ?? arg;
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
const NativeMethod = (methodSelector, opt) => (_, ctx) => {
|
|
1910
|
+
const name = ctx.name;
|
|
1911
|
+
async function impl(...args) {
|
|
1912
|
+
const { instanceId, namespace } = this;
|
|
1913
|
+
const returnValue = await getMessageClient(this).sendInstanceCall(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(v => v !== undefined), opt);
|
|
1914
|
+
const data = assertReturn(returnValue);
|
|
1915
|
+
return data;
|
|
1916
|
+
}
|
|
1917
|
+
return impl;
|
|
1918
|
+
};
|
|
1919
|
+
const NativeMethodSync = (methodSelector, opt) => (_, ctx) => {
|
|
1920
|
+
const name = ctx.name;
|
|
1921
|
+
function impl(...args) {
|
|
1922
|
+
const { instanceId, namespace } = this;
|
|
1923
|
+
const returnValue = getMessageClient(this).sendInstanceCallSync(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(v => v !== undefined), opt);
|
|
1924
|
+
const data = assertReturn(returnValue);
|
|
1925
|
+
return data;
|
|
1926
|
+
}
|
|
1927
|
+
return impl;
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
const NativeVar = (varName, ctor) => (_, ctx) => {
|
|
1931
|
+
return async function impl(...args) {
|
|
1932
|
+
const client = getMessageClient(this);
|
|
1933
|
+
const ret = await client.sendVarGet(varName, args);
|
|
1934
|
+
const ins = new ctor(DISABLE_INIT);
|
|
1935
|
+
ins.instanceId = ret.msg._instanceId;
|
|
1936
|
+
ins.messageClient = client;
|
|
1937
|
+
ins.namespace = '$var';
|
|
1938
|
+
return ins;
|
|
1939
|
+
};
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1942
|
+
(() => {
|
|
1943
|
+
var _a;
|
|
1944
|
+
let _instanceExtraInitializers = [];
|
|
1945
|
+
let _on_decorators;
|
|
1946
|
+
let _emit_decorators;
|
|
1947
|
+
return _a = class NativeObserver {
|
|
1948
|
+
constructor(className) {
|
|
1949
|
+
this._events = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1950
|
+
this.namespace = className;
|
|
1951
|
+
this.instanceId = getUuid(className);
|
|
1952
|
+
this.messageClient = getGlobalMessageClient();
|
|
1953
|
+
this._events = {};
|
|
1954
|
+
}
|
|
1955
|
+
on(ev, handler) {
|
|
1956
|
+
let handlers = this._events[ev];
|
|
1957
|
+
if (!handlers) {
|
|
1958
|
+
handlers = [];
|
|
1959
|
+
this._events[ev] = handlers;
|
|
1960
|
+
}
|
|
1961
|
+
if (handlers.length === 0) {
|
|
1962
|
+
// 第一次,通知 native 注册
|
|
1963
|
+
this.messageClient.sendInstanceEventAdd(this.instanceId, this.namespace || '', ev);
|
|
1964
|
+
}
|
|
1965
|
+
handlers.push(handler);
|
|
1966
|
+
}
|
|
1967
|
+
emit(ev, ...args) {
|
|
1968
|
+
const handlers = this._events[ev];
|
|
1969
|
+
// console.log('emit:', ev, args.length);
|
|
1970
|
+
handlers?.forEach(cb => {
|
|
1971
|
+
cb(...args);
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
},
|
|
1975
|
+
(() => {
|
|
1976
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1977
|
+
_on_decorators = [Bind];
|
|
1978
|
+
_emit_decorators = [Bind];
|
|
1979
|
+
__esDecorate$1(_a, null, _on_decorators, { kind: "method", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1980
|
+
__esDecorate$1(_a, null, _emit_decorators, { kind: "method", name: "emit", static: false, private: false, access: { has: obj => "emit" in obj, get: obj => obj.emit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
1981
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1982
|
+
})(),
|
|
1983
|
+
_a;
|
|
1984
|
+
})();
|
|
1985
|
+
(() => {
|
|
1986
|
+
var _a;
|
|
1987
|
+
let _instanceExtraInitializers = [];
|
|
1988
|
+
let _on_decorators;
|
|
1989
|
+
let _emit_decorators;
|
|
1990
|
+
return _a = class NativeObserverProxy {
|
|
1991
|
+
constructor() {
|
|
1992
|
+
this.__observer = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1993
|
+
}
|
|
1994
|
+
on(ev, handler) {
|
|
1995
|
+
this.__observer.on(ev, handler);
|
|
1996
|
+
}
|
|
1997
|
+
emit(ev, ...args) {
|
|
1998
|
+
this.__observer.emit(ev, ...args);
|
|
1999
|
+
}
|
|
2000
|
+
},
|
|
2001
|
+
(() => {
|
|
2002
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
2003
|
+
_on_decorators = [Bind];
|
|
2004
|
+
_emit_decorators = [Bind];
|
|
2005
|
+
__esDecorate$1(_a, null, _on_decorators, { kind: "method", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2006
|
+
__esDecorate$1(_a, null, _emit_decorators, { kind: "method", name: "emit", static: false, private: false, access: { has: obj => "emit" in obj, get: obj => obj.emit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2007
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2008
|
+
})(),
|
|
2009
|
+
_a;
|
|
2010
|
+
})();
|
|
2011
|
+
|
|
2012
|
+
class NativeView {
|
|
2013
|
+
static getView(viewId, ctor) {
|
|
2014
|
+
const _ins = new ctor(viewId);
|
|
2015
|
+
const ins = initViewProxyObject(_ins, viewId);
|
|
2016
|
+
return ins;
|
|
2017
|
+
}
|
|
2018
|
+
constructor(viewId) {
|
|
2019
|
+
this.viewId = viewId;
|
|
2020
|
+
initViewProxyObject(this, viewId);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
function initViewProxyObject(obj, viewId) {
|
|
2024
|
+
obj.instanceId = obj._instanceId = viewId;
|
|
2025
|
+
obj.namespace = obj._serviceName = '$View';
|
|
2026
|
+
obj._type = "instance" /* ARG_TYPE.INSTANCE */;
|
|
2027
|
+
return obj;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2748
2030
|
var BRIDGE_NATIVE_API;
|
|
2749
2031
|
(function (BRIDGE_NATIVE_API) {
|
|
2750
2032
|
BRIDGE_NATIVE_API["CALL_API"] = "callApi";
|
|
@@ -2792,10 +2074,6 @@ var CALL_TYPE;
|
|
|
2792
2074
|
* 事件执行后的返回值
|
|
2793
2075
|
*/
|
|
2794
2076
|
CALL_TYPE["INSTANCE_EVENT_RESULT"] = "instance_event_result";
|
|
2795
|
-
/**
|
|
2796
|
-
* 销毁实例
|
|
2797
|
-
*/
|
|
2798
|
-
CALL_TYPE["DESTROY_INSTANCE"] = "destroy_instance";
|
|
2799
2077
|
/**
|
|
2800
2078
|
* 触发事件
|
|
2801
2079
|
*/
|
|
@@ -2807,58 +2085,44 @@ var RETURN_STATUS;
|
|
|
2807
2085
|
RETURN_STATUS["FAILED"] = "failed";
|
|
2808
2086
|
RETURN_STATUS["NOT_IMPLEMENTED"] = "not_implemented";
|
|
2809
2087
|
})(RETURN_STATUS || (RETURN_STATUS = {}));
|
|
2810
|
-
var INSTANCE_TYPE;
|
|
2811
|
-
(function (INSTANCE_TYPE) {
|
|
2812
|
-
/**
|
|
2813
|
-
* 自动 GC 类型
|
|
2814
|
-
*/
|
|
2815
|
-
INSTANCE_TYPE[INSTANCE_TYPE["AUTOMATIC"] = 0] = "AUTOMATIC";
|
|
2816
|
-
/**
|
|
2817
|
-
* 手动 GC 类型
|
|
2818
|
-
*/
|
|
2819
|
-
INSTANCE_TYPE[INSTANCE_TYPE["MANUAL"] = 1] = "MANUAL";
|
|
2820
|
-
})(INSTANCE_TYPE || (INSTANCE_TYPE = {}));
|
|
2821
2088
|
|
|
2822
|
-
|
|
2823
|
-
|
|
2089
|
+
class ReactNativeBridge {
|
|
2090
|
+
constructor(BridgeModule, NativeEventName) {
|
|
2824
2091
|
this.BridgeModule = BridgeModule;
|
|
2825
2092
|
this.NativeEventName = NativeEventName;
|
|
2826
2093
|
this._handlers = {};
|
|
2827
2094
|
if (BridgeModule === undefined) {
|
|
2828
|
-
throw new Error(
|
|
2095
|
+
throw new Error(`can't find module "${BridgeModule}", please enure install the module correctly`);
|
|
2829
2096
|
}
|
|
2830
2097
|
this._nativeEventEmitter = new reactNative.NativeEventEmitter(BridgeModule);
|
|
2831
2098
|
this._init();
|
|
2832
2099
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
this._nativeEventEmitter.addListener(this.NativeEventName, function (ev) {
|
|
2836
|
-
var _a, _b;
|
|
2100
|
+
_init() {
|
|
2101
|
+
this._nativeEventEmitter.addListener(this.NativeEventName, (ev) => {
|
|
2837
2102
|
try {
|
|
2838
|
-
|
|
2839
|
-
|
|
2103
|
+
const eventName = ev.event;
|
|
2104
|
+
const eventData = typeof ev.data === 'string' ? JSON.parse(ev.data) : ev.data;
|
|
2840
2105
|
// console.log(`handle native event:`, ev, eventData);
|
|
2841
|
-
|
|
2106
|
+
this._handlers[eventName]?.(eventData);
|
|
2842
2107
|
}
|
|
2843
2108
|
catch (err) {
|
|
2844
2109
|
console.error('handle native event fail:', err);
|
|
2845
2110
|
}
|
|
2846
2111
|
});
|
|
2847
|
-
}
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
return new Promise(function (resolve, reject) {
|
|
2112
|
+
}
|
|
2113
|
+
call(params) {
|
|
2114
|
+
return new Promise((resolve, reject) => {
|
|
2851
2115
|
// console.debug(`<Bridge> js call native "${handlerName}()":`, ...args);
|
|
2852
2116
|
try {
|
|
2853
|
-
|
|
2854
|
-
|
|
2117
|
+
let resolved = false;
|
|
2118
|
+
this.BridgeModule[BRIDGE_NATIVE_API.CALL_API]({ params: JSON.stringify(params) }, (res) => {
|
|
2855
2119
|
// console.log('async call value:', res);
|
|
2856
|
-
|
|
2857
|
-
|
|
2120
|
+
const val = typeof res === 'string' ? JSON.parse(res) : res;
|
|
2121
|
+
resolved = true;
|
|
2858
2122
|
resolve(val);
|
|
2859
2123
|
});
|
|
2860
|
-
setTimeout(
|
|
2861
|
-
if (
|
|
2124
|
+
setTimeout(() => {
|
|
2125
|
+
if (resolved) {
|
|
2862
2126
|
return;
|
|
2863
2127
|
}
|
|
2864
2128
|
resolve({
|
|
@@ -2872,11 +2136,11 @@ var ReactNativeBridge = /** @class */ (function () {
|
|
|
2872
2136
|
reject(err);
|
|
2873
2137
|
}
|
|
2874
2138
|
});
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2139
|
+
}
|
|
2140
|
+
callSync(params) {
|
|
2877
2141
|
// console.debug(`<Bridge> js call native "${handlerName}()":`, ...args);
|
|
2878
2142
|
try {
|
|
2879
|
-
|
|
2143
|
+
const res = this.BridgeModule[BRIDGE_NATIVE_API.CALL_API_SYNC]({
|
|
2880
2144
|
params: JSON.stringify(params),
|
|
2881
2145
|
});
|
|
2882
2146
|
// console.debug(`<Bridge> native return "${handlerName}()":`, res, args)
|
|
@@ -2886,61 +2150,27 @@ var ReactNativeBridge = /** @class */ (function () {
|
|
|
2886
2150
|
// console.error(`<RNBridge> call native "${handlerName}()" fail`, err);
|
|
2887
2151
|
throw err;
|
|
2888
2152
|
}
|
|
2889
|
-
}
|
|
2890
|
-
|
|
2153
|
+
}
|
|
2154
|
+
registerHandler(handlerName, handler) {
|
|
2891
2155
|
this._handlers[handlerName] = handler;
|
|
2892
|
-
}
|
|
2893
|
-
|
|
2156
|
+
}
|
|
2157
|
+
registerAsyncHandler(handlerName, handler) {
|
|
2894
2158
|
this._handlers[handlerName] = handler;
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
}());
|
|
2898
|
-
|
|
2899
|
-
/******************************************************************************
|
|
2900
|
-
Copyright (c) Microsoft Corporation.
|
|
2901
|
-
|
|
2902
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2903
|
-
purpose with or without fee is hereby granted.
|
|
2904
|
-
|
|
2905
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2906
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2907
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2908
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2909
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2910
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2911
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2912
|
-
***************************************************************************** */
|
|
2913
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
var __assign = function() {
|
|
2917
|
-
__assign = Object.assign || function __assign(t) {
|
|
2918
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2919
|
-
s = arguments[i];
|
|
2920
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2921
|
-
}
|
|
2922
|
-
return t;
|
|
2923
|
-
};
|
|
2924
|
-
return __assign.apply(this, arguments);
|
|
2925
|
-
};
|
|
2926
|
-
|
|
2927
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2928
|
-
var e = new Error(message);
|
|
2929
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2930
|
-
};
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2931
2161
|
|
|
2932
|
-
|
|
2933
|
-
|
|
2162
|
+
class ReactNativeEnv {
|
|
2163
|
+
resolveImageResource(input) {
|
|
2164
|
+
const r = reactNative.Image.resolveAssetSource(input);
|
|
2165
|
+
return {
|
|
2166
|
+
...r,
|
|
2167
|
+
_type: "image_resource" /* ARG_TYPE.IMAGE_RESOURCE */,
|
|
2168
|
+
};
|
|
2934
2169
|
}
|
|
2935
|
-
|
|
2936
|
-
var r = reactNative.Image.resolveAssetSource(input);
|
|
2937
|
-
return __assign(__assign({}, r), { _type: "image_resource" /* ARG_TYPE.IMAGE_RESOURCE */ });
|
|
2938
|
-
};
|
|
2939
|
-
ReactNativeEnv.prototype.os = function () {
|
|
2170
|
+
os() {
|
|
2940
2171
|
return reactNative.Platform.OS;
|
|
2941
|
-
}
|
|
2942
|
-
|
|
2943
|
-
}());
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2944
2174
|
|
|
2945
2175
|
/******************************************************************************
|
|
2946
2176
|
Copyright (c) Microsoft Corporation.
|
|
@@ -12954,7 +12184,7 @@ var VeLivePlayerErrorCode;
|
|
|
12954
12184
|
* @brief The SDK license is invalid. This error may occur due to incorrect integration of the license or if the license has expired. Review how the license was integrated and ensure that it is still valid.
|
|
12955
12185
|
*
|
|
12956
12186
|
*/
|
|
12957
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerInvalidLicense"] = 1] = "VeLivePlayerInvalidLicense";
|
|
12187
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerInvalidLicense"] = -1] = "VeLivePlayerInvalidLicense";
|
|
12958
12188
|
/** {zh}
|
|
12959
12189
|
* @brief 调用时传入的参数不合法。请检查入参,并重新调用。
|
|
12960
12190
|
*
|
|
@@ -12963,7 +12193,7 @@ var VeLivePlayerErrorCode;
|
|
|
12963
12193
|
* @brief Invalid parameters. Check the input parameter and call the method again.
|
|
12964
12194
|
*
|
|
12965
12195
|
*/
|
|
12966
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerInvalidParameter"] = 2] = "VeLivePlayerInvalidParameter";
|
|
12196
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerInvalidParameter"] = -2] = "VeLivePlayerInvalidParameter";
|
|
12967
12197
|
/** {zh}
|
|
12968
12198
|
* @brief 调用被拒绝。方法调用时机不合法,请检查调用时机。
|
|
12969
12199
|
*
|
|
@@ -12972,7 +12202,7 @@ var VeLivePlayerErrorCode;
|
|
|
12972
12202
|
* @brief The method call has been rejected. This error occurs when the method is called at an incorrect time.
|
|
12973
12203
|
*
|
|
12974
12204
|
*/
|
|
12975
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorRefused"] = 3] = "VeLivePlayerErrorRefused";
|
|
12205
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorRefused"] = -3] = "VeLivePlayerErrorRefused";
|
|
12976
12206
|
/** {zh}
|
|
12977
12207
|
* @brief 加载库文件失败。可能是 SDK 集成错误,请检查 SDK 集成方式。
|
|
12978
12208
|
*
|
|
@@ -12981,7 +12211,7 @@ var VeLivePlayerErrorCode;
|
|
|
12981
12211
|
* @brief Failed to load the library file. This error may occur due to incorrect integration of the SDK.
|
|
12982
12212
|
*
|
|
12983
12213
|
*/
|
|
12984
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorLibraryLoadFailed"] = 4] = "VeLivePlayerErrorLibraryLoadFailed";
|
|
12214
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorLibraryLoadFailed"] = -4] = "VeLivePlayerErrorLibraryLoadFailed";
|
|
12985
12215
|
/** {zh}
|
|
12986
12216
|
* @brief 播放地址不存在或无效。可能是播放地址为空、地址格式不合法或地址长度不合法,请检查播放地址。
|
|
12987
12217
|
*
|
|
@@ -12990,7 +12220,7 @@ var VeLivePlayerErrorCode;
|
|
|
12990
12220
|
* @brief The pull stream address does not exist or is invalid. This error may occur if the pull stream address is empty, or if the format or length of the address is invalid.
|
|
12991
12221
|
*
|
|
12992
12222
|
*/
|
|
12993
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorPlayUrl"] =
|
|
12223
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorPlayUrl"] = -100] = "VeLivePlayerErrorPlayUrl";
|
|
12994
12224
|
/** {zh}
|
|
12995
12225
|
* @brief 无法获取流数据。可能是直播流不存在、直播流中断或直播已结束,请检查直播状态。
|
|
12996
12226
|
*
|
|
@@ -12999,7 +12229,7 @@ var VeLivePlayerErrorCode;
|
|
|
12999
12229
|
* @brief Unable to get the stream data. This error may occur if the live stream does not exist, is interrupted, or has ended. Please check the status of the live stream.
|
|
13000
12230
|
*
|
|
13001
12231
|
*/
|
|
13002
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorNoStreamData"] =
|
|
12232
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorNoStreamData"] = -101] = "VeLivePlayerErrorNoStreamData";
|
|
13003
12233
|
/** {zh}
|
|
13004
12234
|
* @brief 内部播放重试。可能由于播放器内部错误触发了重试。
|
|
13005
12235
|
*
|
|
@@ -13008,7 +12238,7 @@ var VeLivePlayerErrorCode;
|
|
|
13008
12238
|
* @brief An internal retry to play the live stream, which might happen due to an internal player error.
|
|
13009
12239
|
*
|
|
13010
12240
|
*/
|
|
13011
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternalRetryStart"] =
|
|
12241
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternalRetryStart"] = -102] = "VeLivePlayerErrorInternalRetryStart";
|
|
13012
12242
|
/** {zh}
|
|
13013
12243
|
* @brief 内部重试失败。内部重试次数达到最大限制,播放器停止重试,您可以尝试重新播放。
|
|
13014
12244
|
*
|
|
@@ -13017,7 +12247,7 @@ var VeLivePlayerErrorCode;
|
|
|
13017
12247
|
* @brief An internal retry failed and the maximum number of internal retries is reached. The player has stopped retrying. You may attempt a manual retry.
|
|
13018
12248
|
*
|
|
13019
12249
|
*/
|
|
13020
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternalRetryFailed"] =
|
|
12250
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternalRetryFailed"] = -103] = "VeLivePlayerErrorInternalRetryFailed";
|
|
13021
12251
|
/** {zh}
|
|
13022
12252
|
* @brief DNS 解析失败。可能是播放地址异常或客户端网络异常,请您检查播放地址和网络情况,如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13023
12253
|
*
|
|
@@ -13026,7 +12256,7 @@ var VeLivePlayerErrorCode;
|
|
|
13026
12256
|
* @brief DNS parsing failed. This error may occur due to an error in the pull stream address or the client's network conditions. If the error persists after you verify the pull stream address and network conditions, contact BytePlus technical support for assistance.
|
|
13027
12257
|
*
|
|
13028
12258
|
*/
|
|
13029
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDnsParseFailed"] =
|
|
12259
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDnsParseFailed"] = -200] = "VeLivePlayerErrorDnsParseFailed";
|
|
13030
12260
|
/** {zh}
|
|
13031
12261
|
* @brief 网络请求失败。请检查网络情况,如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13032
12262
|
*
|
|
@@ -13035,7 +12265,7 @@ var VeLivePlayerErrorCode;
|
|
|
13035
12265
|
* @brief The network request failed. Check the network conditions. If the error persists, contact BytePlus technical support for assistance.
|
|
13036
12266
|
*
|
|
13037
12267
|
*/
|
|
13038
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorNetworkRequestFailed"] =
|
|
12268
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorNetworkRequestFailed"] = -201] = "VeLivePlayerErrorNetworkRequestFailed";
|
|
13039
12269
|
/** {zh}
|
|
13040
12270
|
* @brief 直播格式解封装失败。可能是使用了不支持的直播流格式和协议,或音视频流错误;请检查流格式,如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13041
12271
|
*
|
|
@@ -13044,7 +12274,7 @@ var VeLivePlayerErrorCode;
|
|
|
13044
12274
|
* @brief Video decapsulation failed. This error may occur if the live stream uses an unsupported format or protocol, or if there is an audio or video error. If the error persists, contact BytePlus technical support for assistance.
|
|
13045
12275
|
*
|
|
13046
12276
|
*/
|
|
13047
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDemuxFailed"] =
|
|
12277
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDemuxFailed"] = -300] = "VeLivePlayerErrorDemuxFailed";
|
|
13048
12278
|
/** {zh}
|
|
13049
12279
|
* @brief 视频解码失败。可能使用了不支持的直播流音视频格式,或解码器出错;请检查音视频格式,如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13050
12280
|
*
|
|
@@ -13053,7 +12283,7 @@ var VeLivePlayerErrorCode;
|
|
|
13053
12283
|
* @brief Decoding failed. This error may occur if the live stream uses an unsupported audio or video format. If the error persists, contact BytePlus technical support for assistance.
|
|
13054
12284
|
*
|
|
13055
12285
|
*/
|
|
13056
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDecodeFailed"] =
|
|
12286
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorDecodeFailed"] = -301] = "VeLivePlayerErrorDecodeFailed";
|
|
13057
12287
|
/** {zh}
|
|
13058
12288
|
* @brief 渲染失败。可能是音视频输出设备异常,请重试;如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13059
12289
|
*
|
|
@@ -13062,7 +12292,7 @@ var VeLivePlayerErrorCode;
|
|
|
13062
12292
|
* @brief Rendering failed. This error may occur if there is an issue with the audio or video output devices. If the error persists, contact BytePlus technical support for assistance.
|
|
13063
12293
|
*
|
|
13064
12294
|
*/
|
|
13065
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorAVOutputFailed"] =
|
|
12295
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorAVOutputFailed"] = -302] = "VeLivePlayerErrorAVOutputFailed";
|
|
13066
12296
|
/** {zh}
|
|
13067
12297
|
* @brief 该台设备不支持超分能力,不在超分机型白名单内;如果有疑问,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13068
12298
|
*
|
|
@@ -13071,7 +12301,7 @@ var VeLivePlayerErrorCode;
|
|
|
13071
12301
|
* @brief The device model does not support super resolution. Contact BytePlus technical support for any assistance you may need.
|
|
13072
12302
|
*
|
|
13073
12303
|
*/
|
|
13074
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRDeviceUnsupported"] =
|
|
12304
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRDeviceUnsupported"] = -303] = "VeLivePlayerErrorSRDeviceUnsupported";
|
|
13075
12305
|
/** {zh}
|
|
13076
12306
|
* @brief 当前分辨率高于超分开启限制的最大分辨率。如果有疑问,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13077
12307
|
*
|
|
@@ -13080,7 +12310,7 @@ var VeLivePlayerErrorCode;
|
|
|
13080
12310
|
* @brief The current resolution exceeds the upper limit allowed for super resolution. Contact BytePlus technical support for any assistance you may need.
|
|
13081
12311
|
*
|
|
13082
12312
|
*/
|
|
13083
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRResolutionUnsupported"] =
|
|
12313
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRResolutionUnsupported"] = -304] = "VeLivePlayerErrorSRResolutionUnsupported";
|
|
13084
12314
|
/** {zh}
|
|
13085
12315
|
* @brief 当前帧率高于超分开启限制的最大帧率。如果有疑问,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13086
12316
|
*
|
|
@@ -13089,7 +12319,7 @@ var VeLivePlayerErrorCode;
|
|
|
13089
12319
|
* @brief The current frame rate exceeds the upper limit allowed for super resolution. Contact BytePlus technical support for any assistance you may need.
|
|
13090
12320
|
*
|
|
13091
12321
|
*/
|
|
13092
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRFpsUnsupported"] =
|
|
12322
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRFpsUnsupported"] = -305] = "VeLivePlayerErrorSRFpsUnsupported";
|
|
13093
12323
|
/** {zh}
|
|
13094
12324
|
* @brief 超分初始化失败。可能超分参数配置错误,或版本不兼容;如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13095
12325
|
*
|
|
@@ -13098,7 +12328,7 @@ var VeLivePlayerErrorCode;
|
|
|
13098
12328
|
* @brief Fails to initialize super resolution. Contact BytePlus technical support if the error persists.
|
|
13099
12329
|
*
|
|
13100
12330
|
*/
|
|
13101
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRInitFail"] =
|
|
12331
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRInitFail"] = -306] = "VeLivePlayerErrorSRInitFail";
|
|
13102
12332
|
/** {zh}
|
|
13103
12333
|
* @brief 超分执行失败,可能超分参数配置错误,或版本不兼容;如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13104
12334
|
*
|
|
@@ -13107,7 +12337,7 @@ var VeLivePlayerErrorCode;
|
|
|
13107
12337
|
* @brief Fails to apply super resolution to the video. Contact BytePlus technical support if the error persists.
|
|
13108
12338
|
*
|
|
13109
12339
|
*/
|
|
13110
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRExecuteFail"] =
|
|
12340
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorSRExecuteFail"] = -307] = "VeLivePlayerErrorSRExecuteFail";
|
|
13111
12341
|
/** {zh}
|
|
13112
12342
|
* @brief 您使用的基础版 License 暂不支持 H.265 硬件解码,请登录火山引擎[视频直播控制台](https://console.volcengine.com/live/main/sdk)获取高级版 License。
|
|
13113
12343
|
*
|
|
@@ -13116,26 +12346,26 @@ var VeLivePlayerErrorCode;
|
|
|
13116
12346
|
* @brief The current SDK license does not provide support for the H.265 feature.
|
|
13117
12347
|
*
|
|
13118
12348
|
*/
|
|
13119
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerLicenseUnsupportedH265"] =
|
|
13120
|
-
/** {zh}
|
|
13121
|
-
* @brief 内部错误。请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
13122
|
-
*
|
|
13123
|
-
*/
|
|
13124
|
-
/** {en}
|
|
13125
|
-
* @brief Internal error. Please contact BytePlus technical support for assistance.
|
|
13126
|
-
*
|
|
13127
|
-
*/
|
|
13128
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternal"] = 20] = "VeLivePlayerErrorInternal";
|
|
12349
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerLicenseUnsupportedH265"] = -308] = "VeLivePlayerLicenseUnsupportedH265";
|
|
13129
12350
|
/** {zh}
|
|
13130
12351
|
* @platform ios
|
|
13131
12352
|
* @brief DRM 鉴权失败。
|
|
13132
12353
|
*/
|
|
13133
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerDRMFetchCKCFailed"] =
|
|
12354
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerDRMFetchCKCFailed"] = -400] = "VeLivePlayerDRMFetchCKCFailed";
|
|
13134
12355
|
/** {zh}
|
|
13135
12356
|
* @platform ios
|
|
13136
12357
|
* @brief 服务器播放上下文(SPC)生成失败。
|
|
13137
12358
|
*/
|
|
13138
|
-
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerDRMFetchSPCFailed"] =
|
|
12359
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerDRMFetchSPCFailed"] = -401] = "VeLivePlayerDRMFetchSPCFailed";
|
|
12360
|
+
/** {zh}
|
|
12361
|
+
* @brief 内部错误。请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=2&SubProductID=P00000076)。
|
|
12362
|
+
*
|
|
12363
|
+
*/
|
|
12364
|
+
/** {en}
|
|
12365
|
+
* @brief Internal error. Please contact BytePlus technical support for assistance.
|
|
12366
|
+
*
|
|
12367
|
+
*/
|
|
12368
|
+
VeLivePlayerErrorCode[VeLivePlayerErrorCode["VeLivePlayerErrorInternal"] = -999] = "VeLivePlayerErrorInternal";
|
|
13139
12369
|
})(VeLivePlayerErrorCode || (VeLivePlayerErrorCode = {}));
|
|
13140
12370
|
/** {zh}
|
|
13141
12371
|
* @detail errorcode
|
|
@@ -14469,6 +13699,505 @@ var VeLivePlayer = function () {
|
|
|
14469
13699
|
return _classThis;
|
|
14470
13700
|
}();
|
|
14471
13701
|
|
|
13702
|
+
var PictureInPictureManagerListener = function () {
|
|
13703
|
+
var _classDecorators = [NativeObserverClass('com.volcengine.velive.rn.pull.pictureInpicture.PictureInPictureManager$Listener')];
|
|
13704
|
+
var _classDescriptor;
|
|
13705
|
+
var _classExtraInitializers = [];
|
|
13706
|
+
var _classThis;
|
|
13707
|
+
_classThis = /** @class */ (function () {
|
|
13708
|
+
function PictureInPictureManagerListener_1() {
|
|
13709
|
+
}
|
|
13710
|
+
return PictureInPictureManagerListener_1;
|
|
13711
|
+
}());
|
|
13712
|
+
__setFunctionName(_classThis, "PictureInPictureManagerListener");
|
|
13713
|
+
(function () {
|
|
13714
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
13715
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
13716
|
+
_classThis = _classDescriptor.value;
|
|
13717
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
13718
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
13719
|
+
})();
|
|
13720
|
+
return _classThis;
|
|
13721
|
+
}();
|
|
13722
|
+
var android_PictureInPictureListener = /** @class */ (function (_super) {
|
|
13723
|
+
__extends(android_PictureInPictureListener, _super);
|
|
13724
|
+
function android_PictureInPictureListener(_instance) {
|
|
13725
|
+
var _this = _super.call(this) || this;
|
|
13726
|
+
_this._instance = _instance;
|
|
13727
|
+
return _this;
|
|
13728
|
+
}
|
|
13729
|
+
android_PictureInPictureListener.prototype.onStartPictureInPicture = function () {
|
|
13730
|
+
if (!this._instance.onStartPictureInPicture) {
|
|
13731
|
+
return;
|
|
13732
|
+
}
|
|
13733
|
+
return this._instance.onStartPictureInPicture();
|
|
13734
|
+
};
|
|
13735
|
+
android_PictureInPictureListener.prototype.onStopPictureInPicture = function () {
|
|
13736
|
+
if (!this._instance.onStopPictureInPicture) {
|
|
13737
|
+
return;
|
|
13738
|
+
}
|
|
13739
|
+
return this._instance.onStopPictureInPicture();
|
|
13740
|
+
};
|
|
13741
|
+
android_PictureInPictureListener.prototype.onClickPictureInPicture = function () {
|
|
13742
|
+
if (!this._instance.onClickPictureInPicture) {
|
|
13743
|
+
return;
|
|
13744
|
+
}
|
|
13745
|
+
return this._instance.onClickPictureInPicture();
|
|
13746
|
+
};
|
|
13747
|
+
android_PictureInPictureListener.prototype.onError = function (code, extraData) {
|
|
13748
|
+
if (!this._instance.onError) {
|
|
13749
|
+
return;
|
|
13750
|
+
}
|
|
13751
|
+
return this._instance.onError(code, extraData);
|
|
13752
|
+
};
|
|
13753
|
+
return android_PictureInPictureListener;
|
|
13754
|
+
}(PictureInPictureManagerListener));
|
|
13755
|
+
var PictureInPictureManager = function () {
|
|
13756
|
+
var _classDecorators = [NativeClass('com.volcengine.velive.rn.pull.pictureInpicture.PictureInPictureManager')];
|
|
13757
|
+
var _classDescriptor;
|
|
13758
|
+
var _classExtraInitializers = [];
|
|
13759
|
+
var _classThis;
|
|
13760
|
+
var _classSuper = NativeProxyService;
|
|
13761
|
+
var _staticExtraInitializers = [];
|
|
13762
|
+
var _instanceExtraInitializers = [];
|
|
13763
|
+
var _static_getInstance_decorators;
|
|
13764
|
+
var _isPictureInPictureSupported_decorators;
|
|
13765
|
+
var _setupConfig_decorators;
|
|
13766
|
+
var _setListener_decorators;
|
|
13767
|
+
var _startPictureInPicture_decorators;
|
|
13768
|
+
var _stopPictureInPicture_decorators;
|
|
13769
|
+
var _setupPlayer_decorators;
|
|
13770
|
+
var PictureInPictureManager = _classThis = /** @class */ (function (_super) {
|
|
13771
|
+
__extends(PictureInPictureManager_1, _super);
|
|
13772
|
+
function PictureInPictureManager_1() {
|
|
13773
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
13774
|
+
__runInitializers(_this, _instanceExtraInitializers);
|
|
13775
|
+
return _this;
|
|
13776
|
+
}
|
|
13777
|
+
PictureInPictureManager_1.getInstance = function () {
|
|
13778
|
+
throw new Error('');
|
|
13779
|
+
};
|
|
13780
|
+
PictureInPictureManager_1.prototype.isPictureInPictureSupported = function () {
|
|
13781
|
+
throw new Error('');
|
|
13782
|
+
};
|
|
13783
|
+
PictureInPictureManager_1.prototype.setupConfig = function (aspectRatio, x, y) {
|
|
13784
|
+
throw new Error('');
|
|
13785
|
+
};
|
|
13786
|
+
PictureInPictureManager_1.prototype.setListener = function (listener) {
|
|
13787
|
+
throw new Error('');
|
|
13788
|
+
};
|
|
13789
|
+
PictureInPictureManager_1.prototype.startPictureInPicture = function (aspectRatio, x, y) {
|
|
13790
|
+
throw new Error('');
|
|
13791
|
+
};
|
|
13792
|
+
PictureInPictureManager_1.prototype.stopPictureInPicture = function () {
|
|
13793
|
+
throw new Error('');
|
|
13794
|
+
};
|
|
13795
|
+
PictureInPictureManager_1.prototype.setupPlayer = function (player, context, surfaceView) {
|
|
13796
|
+
throw new Error('');
|
|
13797
|
+
};
|
|
13798
|
+
return PictureInPictureManager_1;
|
|
13799
|
+
}(_classSuper));
|
|
13800
|
+
__setFunctionName(_classThis, "PictureInPictureManager");
|
|
13801
|
+
(function () {
|
|
13802
|
+
var _a;
|
|
13803
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
13804
|
+
_static_getInstance_decorators = [ReturnClass(function () { return PictureInPictureManager; }), NativeStaticMethodSync()];
|
|
13805
|
+
_isPictureInPictureSupported_decorators = [NativeMethodSync()];
|
|
13806
|
+
_setupConfig_decorators = [NativeMethodSync()];
|
|
13807
|
+
_setListener_decorators = [NativeMethodSync()];
|
|
13808
|
+
_startPictureInPicture_decorators = [NativeMethod()];
|
|
13809
|
+
_stopPictureInPicture_decorators = [NativeMethod()];
|
|
13810
|
+
_setupPlayer_decorators = [NativeMethod()];
|
|
13811
|
+
__esDecorate(_classThis, null, _static_getInstance_decorators, { kind: "method", name: "getInstance", static: true, private: false, access: { has: function (obj) { return "getInstance" in obj; }, get: function (obj) { return obj.getInstance; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
13812
|
+
__esDecorate(_classThis, null, _isPictureInPictureSupported_decorators, { kind: "method", name: "isPictureInPictureSupported", static: false, private: false, access: { has: function (obj) { return "isPictureInPictureSupported" in obj; }, get: function (obj) { return obj.isPictureInPictureSupported; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13813
|
+
__esDecorate(_classThis, null, _setupConfig_decorators, { kind: "method", name: "setupConfig", static: false, private: false, access: { has: function (obj) { return "setupConfig" in obj; }, get: function (obj) { return obj.setupConfig; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13814
|
+
__esDecorate(_classThis, null, _setListener_decorators, { kind: "method", name: "setListener", static: false, private: false, access: { has: function (obj) { return "setListener" in obj; }, get: function (obj) { return obj.setListener; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13815
|
+
__esDecorate(_classThis, null, _startPictureInPicture_decorators, { kind: "method", name: "startPictureInPicture", static: false, private: false, access: { has: function (obj) { return "startPictureInPicture" in obj; }, get: function (obj) { return obj.startPictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13816
|
+
__esDecorate(_classThis, null, _stopPictureInPicture_decorators, { kind: "method", name: "stopPictureInPicture", static: false, private: false, access: { has: function (obj) { return "stopPictureInPicture" in obj; }, get: function (obj) { return obj.stopPictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13817
|
+
__esDecorate(_classThis, null, _setupPlayer_decorators, { kind: "method", name: "setupPlayer", static: false, private: false, access: { has: function (obj) { return "setupPlayer" in obj; }, get: function (obj) { return obj.setupPlayer; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13818
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
13819
|
+
PictureInPictureManager = _classThis = _classDescriptor.value;
|
|
13820
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
13821
|
+
__runInitializers(_classThis, _staticExtraInitializers);
|
|
13822
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
13823
|
+
})();
|
|
13824
|
+
return PictureInPictureManager = _classThis;
|
|
13825
|
+
}();
|
|
13826
|
+
|
|
13827
|
+
var VeLivePictureInPictureManager = function () {
|
|
13828
|
+
var _classDecorators = [NativeClass('VeLivePictureInPictureManager')];
|
|
13829
|
+
var _classDescriptor;
|
|
13830
|
+
var _classExtraInitializers = [];
|
|
13831
|
+
var _classThis;
|
|
13832
|
+
var _staticExtraInitializers = [];
|
|
13833
|
+
var _instanceExtraInitializers = [];
|
|
13834
|
+
var _static_getInstance_decorators;
|
|
13835
|
+
var _isPictureInPictureSupported_decorators;
|
|
13836
|
+
var _setupPlayer_decorators;
|
|
13837
|
+
var _startPictureInPicture_decorators;
|
|
13838
|
+
var _stopPictureInPicture_decorators;
|
|
13839
|
+
var _enablePictureInPicture_decorators;
|
|
13840
|
+
var _disablePictureInPicture_decorators;
|
|
13841
|
+
var _destroyPictureInPicture_decorators;
|
|
13842
|
+
var _setListener_decorators;
|
|
13843
|
+
var VeLivePictureInPictureManager = _classThis = /** @class */ (function () {
|
|
13844
|
+
function VeLivePictureInPictureManager_1() {
|
|
13845
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
13846
|
+
}
|
|
13847
|
+
VeLivePictureInPictureManager_1.getInstance = function () {
|
|
13848
|
+
throw new Error('');
|
|
13849
|
+
};
|
|
13850
|
+
VeLivePictureInPictureManager_1.prototype.isPictureInPictureSupported = function () {
|
|
13851
|
+
throw new Error('');
|
|
13852
|
+
};
|
|
13853
|
+
VeLivePictureInPictureManager_1.prototype.setupPlayer = function (player) {
|
|
13854
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13855
|
+
return __generator(this, function (_a) {
|
|
13856
|
+
throw new Error('');
|
|
13857
|
+
});
|
|
13858
|
+
});
|
|
13859
|
+
};
|
|
13860
|
+
VeLivePictureInPictureManager_1.prototype.startPictureInPicture = function () {
|
|
13861
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13862
|
+
return __generator(this, function (_a) {
|
|
13863
|
+
throw new Error('');
|
|
13864
|
+
});
|
|
13865
|
+
});
|
|
13866
|
+
};
|
|
13867
|
+
VeLivePictureInPictureManager_1.prototype.stopPictureInPicture = function () {
|
|
13868
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13869
|
+
return __generator(this, function (_a) {
|
|
13870
|
+
throw new Error('');
|
|
13871
|
+
});
|
|
13872
|
+
});
|
|
13873
|
+
};
|
|
13874
|
+
VeLivePictureInPictureManager_1.prototype.enablePictureInPicture = function () {
|
|
13875
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13876
|
+
return __generator(this, function (_a) {
|
|
13877
|
+
throw new Error('');
|
|
13878
|
+
});
|
|
13879
|
+
});
|
|
13880
|
+
};
|
|
13881
|
+
VeLivePictureInPictureManager_1.prototype.disablePictureInPicture = function () {
|
|
13882
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13883
|
+
return __generator(this, function (_a) {
|
|
13884
|
+
throw new Error('');
|
|
13885
|
+
});
|
|
13886
|
+
});
|
|
13887
|
+
};
|
|
13888
|
+
VeLivePictureInPictureManager_1.prototype.destroyPictureInPicture = function () {
|
|
13889
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13890
|
+
return __generator(this, function (_a) {
|
|
13891
|
+
throw new Error('');
|
|
13892
|
+
});
|
|
13893
|
+
});
|
|
13894
|
+
};
|
|
13895
|
+
VeLivePictureInPictureManager_1.prototype.setListener = function (listener) {
|
|
13896
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13897
|
+
return __generator(this, function (_a) {
|
|
13898
|
+
throw new Error('');
|
|
13899
|
+
});
|
|
13900
|
+
});
|
|
13901
|
+
};
|
|
13902
|
+
return VeLivePictureInPictureManager_1;
|
|
13903
|
+
}());
|
|
13904
|
+
__setFunctionName(_classThis, "VeLivePictureInPictureManager");
|
|
13905
|
+
(function () {
|
|
13906
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
13907
|
+
_static_getInstance_decorators = [ReturnClass(function () { return VeLivePictureInPictureManager; }), NativeStaticMethodSync('getInstance')];
|
|
13908
|
+
_isPictureInPictureSupported_decorators = [NativeMethodSync('isPictureInPictureSupported')];
|
|
13909
|
+
_setupPlayer_decorators = [NativeMethod('setupPlayer:')];
|
|
13910
|
+
_startPictureInPicture_decorators = [NativeMethod('startPictureInPicture')];
|
|
13911
|
+
_stopPictureInPicture_decorators = [NativeMethod('stopPictureInPicture')];
|
|
13912
|
+
_enablePictureInPicture_decorators = [NativeMethodSync('enablePictureInPicture')];
|
|
13913
|
+
_disablePictureInPicture_decorators = [NativeMethodSync('disablePictureInPicture')];
|
|
13914
|
+
_destroyPictureInPicture_decorators = [NativeMethodSync('destroyPictureInPicture')];
|
|
13915
|
+
_setListener_decorators = [NativeMethodSync('setListener:')];
|
|
13916
|
+
__esDecorate(_classThis, null, _static_getInstance_decorators, { kind: "method", name: "getInstance", static: true, private: false, access: { has: function (obj) { return "getInstance" in obj; }, get: function (obj) { return obj.getInstance; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
13917
|
+
__esDecorate(_classThis, null, _isPictureInPictureSupported_decorators, { kind: "method", name: "isPictureInPictureSupported", static: false, private: false, access: { has: function (obj) { return "isPictureInPictureSupported" in obj; }, get: function (obj) { return obj.isPictureInPictureSupported; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13918
|
+
__esDecorate(_classThis, null, _setupPlayer_decorators, { kind: "method", name: "setupPlayer", static: false, private: false, access: { has: function (obj) { return "setupPlayer" in obj; }, get: function (obj) { return obj.setupPlayer; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13919
|
+
__esDecorate(_classThis, null, _startPictureInPicture_decorators, { kind: "method", name: "startPictureInPicture", static: false, private: false, access: { has: function (obj) { return "startPictureInPicture" in obj; }, get: function (obj) { return obj.startPictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13920
|
+
__esDecorate(_classThis, null, _stopPictureInPicture_decorators, { kind: "method", name: "stopPictureInPicture", static: false, private: false, access: { has: function (obj) { return "stopPictureInPicture" in obj; }, get: function (obj) { return obj.stopPictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13921
|
+
__esDecorate(_classThis, null, _enablePictureInPicture_decorators, { kind: "method", name: "enablePictureInPicture", static: false, private: false, access: { has: function (obj) { return "enablePictureInPicture" in obj; }, get: function (obj) { return obj.enablePictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13922
|
+
__esDecorate(_classThis, null, _disablePictureInPicture_decorators, { kind: "method", name: "disablePictureInPicture", static: false, private: false, access: { has: function (obj) { return "disablePictureInPicture" in obj; }, get: function (obj) { return obj.disablePictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13923
|
+
__esDecorate(_classThis, null, _destroyPictureInPicture_decorators, { kind: "method", name: "destroyPictureInPicture", static: false, private: false, access: { has: function (obj) { return "destroyPictureInPicture" in obj; }, get: function (obj) { return obj.destroyPictureInPicture; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13924
|
+
__esDecorate(_classThis, null, _setListener_decorators, { kind: "method", name: "setListener", static: false, private: false, access: { has: function (obj) { return "setListener" in obj; }, get: function (obj) { return obj.setListener; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13925
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
13926
|
+
VeLivePictureInPictureManager = _classThis = _classDescriptor.value;
|
|
13927
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
13928
|
+
__runInitializers(_classThis, _staticExtraInitializers);
|
|
13929
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
13930
|
+
})();
|
|
13931
|
+
return VeLivePictureInPictureManager = _classThis;
|
|
13932
|
+
}();
|
|
13933
|
+
var VeLivePlayerMultiObserver = function () {
|
|
13934
|
+
var _classDecorators = [NativeClass('VeLivePlayerMultiObserver')];
|
|
13935
|
+
var _classDescriptor;
|
|
13936
|
+
var _classExtraInitializers = [];
|
|
13937
|
+
var _classThis;
|
|
13938
|
+
var _staticExtraInitializers = [];
|
|
13939
|
+
var _instanceExtraInitializers = [];
|
|
13940
|
+
var _static_getInstance_decorators;
|
|
13941
|
+
var _setupPlayer_decorators;
|
|
13942
|
+
var _addObserver_decorators;
|
|
13943
|
+
var _removeObserver_decorators;
|
|
13944
|
+
var VeLivePlayerMultiObserver = _classThis = /** @class */ (function () {
|
|
13945
|
+
function VeLivePlayerMultiObserver_1() {
|
|
13946
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
13947
|
+
}
|
|
13948
|
+
VeLivePlayerMultiObserver_1.getInstance = function () {
|
|
13949
|
+
throw new Error('');
|
|
13950
|
+
};
|
|
13951
|
+
VeLivePlayerMultiObserver_1.prototype.setupPlayer = function (player) {
|
|
13952
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13953
|
+
return __generator(this, function (_a) {
|
|
13954
|
+
throw new Error('');
|
|
13955
|
+
});
|
|
13956
|
+
});
|
|
13957
|
+
};
|
|
13958
|
+
VeLivePlayerMultiObserver_1.prototype.addObserver = function (observerId, observer) {
|
|
13959
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13960
|
+
return __generator(this, function (_a) {
|
|
13961
|
+
throw new Error('');
|
|
13962
|
+
});
|
|
13963
|
+
});
|
|
13964
|
+
};
|
|
13965
|
+
VeLivePlayerMultiObserver_1.prototype.removeObserver = function (observerId) {
|
|
13966
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13967
|
+
return __generator(this, function (_a) {
|
|
13968
|
+
throw new Error('');
|
|
13969
|
+
});
|
|
13970
|
+
});
|
|
13971
|
+
};
|
|
13972
|
+
return VeLivePlayerMultiObserver_1;
|
|
13973
|
+
}());
|
|
13974
|
+
__setFunctionName(_classThis, "VeLivePlayerMultiObserver");
|
|
13975
|
+
(function () {
|
|
13976
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
13977
|
+
_static_getInstance_decorators = [ReturnClass(function () { return VeLivePlayerMultiObserver; }), NativeStaticMethodSync('getInstance')];
|
|
13978
|
+
_setupPlayer_decorators = [NativeMethod('setupPlayer:')];
|
|
13979
|
+
_addObserver_decorators = [NativeMethod('addObserver:observer:')];
|
|
13980
|
+
_removeObserver_decorators = [NativeMethod('removeObserver:')];
|
|
13981
|
+
__esDecorate(_classThis, null, _static_getInstance_decorators, { kind: "method", name: "getInstance", static: true, private: false, access: { has: function (obj) { return "getInstance" in obj; }, get: function (obj) { return obj.getInstance; } }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
13982
|
+
__esDecorate(_classThis, null, _setupPlayer_decorators, { kind: "method", name: "setupPlayer", static: false, private: false, access: { has: function (obj) { return "setupPlayer" in obj; }, get: function (obj) { return obj.setupPlayer; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13983
|
+
__esDecorate(_classThis, null, _addObserver_decorators, { kind: "method", name: "addObserver", static: false, private: false, access: { has: function (obj) { return "addObserver" in obj; }, get: function (obj) { return obj.addObserver; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13984
|
+
__esDecorate(_classThis, null, _removeObserver_decorators, { kind: "method", name: "removeObserver", static: false, private: false, access: { has: function (obj) { return "removeObserver" in obj; }, get: function (obj) { return obj.removeObserver; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
13985
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
13986
|
+
VeLivePlayerMultiObserver = _classThis = _classDescriptor.value;
|
|
13987
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
13988
|
+
__runInitializers(_classThis, _staticExtraInitializers);
|
|
13989
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
13990
|
+
})();
|
|
13991
|
+
return VeLivePlayerMultiObserver = _classThis;
|
|
13992
|
+
}();
|
|
13993
|
+
var VeLivePictureInPictureManagerListener = function () {
|
|
13994
|
+
var _classDecorators = [NativeObserverClass('VeLivePictureInPictureManagerListener', {
|
|
13995
|
+
onStartPictureInPicture: 'onStartPictureInPicture',
|
|
13996
|
+
onStopPictureInPicture: 'onStopPictureInPicture',
|
|
13997
|
+
onClickPictureInPicture: 'onClickPictureInPicture',
|
|
13998
|
+
onError$code$extraData: 'onError:code:extraData:',
|
|
13999
|
+
})];
|
|
14000
|
+
var _classDescriptor;
|
|
14001
|
+
var _classExtraInitializers = [];
|
|
14002
|
+
var _classThis;
|
|
14003
|
+
_classThis = /** @class */ (function () {
|
|
14004
|
+
function VeLivePictureInPictureManagerListener_1() {
|
|
14005
|
+
}
|
|
14006
|
+
return VeLivePictureInPictureManagerListener_1;
|
|
14007
|
+
}());
|
|
14008
|
+
__setFunctionName(_classThis, "VeLivePictureInPictureManagerListener");
|
|
14009
|
+
(function () {
|
|
14010
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
14011
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
14012
|
+
_classThis = _classDescriptor.value;
|
|
14013
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
14014
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
14015
|
+
})();
|
|
14016
|
+
return _classThis;
|
|
14017
|
+
}();
|
|
14018
|
+
var ios_PictureInPictureManagerListener = /** @class */ (function (_super) {
|
|
14019
|
+
__extends(ios_PictureInPictureManagerListener, _super);
|
|
14020
|
+
function ios_PictureInPictureManagerListener(_instance) {
|
|
14021
|
+
var _this = _super.call(this) || this;
|
|
14022
|
+
_this._instance = _instance;
|
|
14023
|
+
return _this;
|
|
14024
|
+
}
|
|
14025
|
+
ios_PictureInPictureManagerListener.prototype.onStartPictureInPicture = function () {
|
|
14026
|
+
if (!this._instance.onStartPictureInPicture) {
|
|
14027
|
+
return;
|
|
14028
|
+
}
|
|
14029
|
+
return this._instance.onStartPictureInPicture();
|
|
14030
|
+
};
|
|
14031
|
+
ios_PictureInPictureManagerListener.prototype.onStopPictureInPicture = function () {
|
|
14032
|
+
if (!this._instance.onStopPictureInPicture) {
|
|
14033
|
+
return;
|
|
14034
|
+
}
|
|
14035
|
+
return this._instance.onStopPictureInPicture();
|
|
14036
|
+
};
|
|
14037
|
+
ios_PictureInPictureManagerListener.prototype.onClickPictureInPicture = function () {
|
|
14038
|
+
if (!this._instance.onClickPictureInPicture) {
|
|
14039
|
+
return;
|
|
14040
|
+
}
|
|
14041
|
+
return this._instance.onClickPictureInPicture();
|
|
14042
|
+
};
|
|
14043
|
+
ios_PictureInPictureManagerListener.prototype.onError$code$extraData = function (code, extraData) {
|
|
14044
|
+
if (!this._instance.onError$code$extraData) {
|
|
14045
|
+
return;
|
|
14046
|
+
}
|
|
14047
|
+
return this._instance.onError$code$extraData(code, extraData);
|
|
14048
|
+
};
|
|
14049
|
+
return ios_PictureInPictureManagerListener;
|
|
14050
|
+
}(VeLivePictureInPictureManagerListener));
|
|
14051
|
+
|
|
14052
|
+
function runImpl(context, androidImpl, iosImpl) {
|
|
14053
|
+
if (env.getOS() === 'android') {
|
|
14054
|
+
var androidEngine = unpackObject(context);
|
|
14055
|
+
return androidImpl(androidEngine);
|
|
14056
|
+
}
|
|
14057
|
+
else if (env.getOS() === 'ios') {
|
|
14058
|
+
var iosEngine = unpackObject(context);
|
|
14059
|
+
return iosImpl(iosEngine);
|
|
14060
|
+
}
|
|
14061
|
+
else {
|
|
14062
|
+
throw new Error("not support: ".concat(env.getOS()));
|
|
14063
|
+
}
|
|
14064
|
+
}
|
|
14065
|
+
extendsClassMethod(VeLivePlayer, 'startPictureInPicture', function () {
|
|
14066
|
+
return function startPictureInPicture() {
|
|
14067
|
+
var args = [];
|
|
14068
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14069
|
+
args[_i] = arguments[_i];
|
|
14070
|
+
}
|
|
14071
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14072
|
+
var _this = this;
|
|
14073
|
+
return __generator(this, function (_a) {
|
|
14074
|
+
return [2 /*return*/, runImpl(this, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14075
|
+
var manager;
|
|
14076
|
+
return __generator(this, function (_a) {
|
|
14077
|
+
manager = PictureInPictureManager.getInstance();
|
|
14078
|
+
return [2 /*return*/, manager.startPictureInPicture.apply(manager, args)];
|
|
14079
|
+
});
|
|
14080
|
+
}); }, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14081
|
+
var manager;
|
|
14082
|
+
return __generator(this, function (_a) {
|
|
14083
|
+
manager = VeLivePictureInPictureManager.getInstance();
|
|
14084
|
+
return [2 /*return*/, manager.startPictureInPicture()];
|
|
14085
|
+
});
|
|
14086
|
+
}); })];
|
|
14087
|
+
});
|
|
14088
|
+
});
|
|
14089
|
+
};
|
|
14090
|
+
});
|
|
14091
|
+
extendsClassMethod(VeLivePlayer, 'stopPictureInPicture', function () {
|
|
14092
|
+
return function stopPictureInPicture() {
|
|
14093
|
+
var _this = this;
|
|
14094
|
+
return runImpl(this, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14095
|
+
var manager;
|
|
14096
|
+
return __generator(this, function (_a) {
|
|
14097
|
+
manager = PictureInPictureManager.getInstance();
|
|
14098
|
+
return [2 /*return*/, manager.stopPictureInPicture()];
|
|
14099
|
+
});
|
|
14100
|
+
}); }, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14101
|
+
var manager;
|
|
14102
|
+
return __generator(this, function (_a) {
|
|
14103
|
+
manager = VeLivePictureInPictureManager.getInstance();
|
|
14104
|
+
return [2 /*return*/, manager.stopPictureInPicture()];
|
|
14105
|
+
});
|
|
14106
|
+
}); });
|
|
14107
|
+
};
|
|
14108
|
+
});
|
|
14109
|
+
extendsClassMethod(VeLivePlayer, 'setObserver', function (origin) {
|
|
14110
|
+
return function setObserver(observer) {
|
|
14111
|
+
return runImpl(this, function () {
|
|
14112
|
+
return origin(observer);
|
|
14113
|
+
}, function () {
|
|
14114
|
+
var _observer = packObject(observer, ios_VeLivePlayerObserver);
|
|
14115
|
+
var multiObserver = VeLivePlayerMultiObserver.getInstance();
|
|
14116
|
+
// Here we need to add a unique key for the observer, and don't modify prefix "rn-"
|
|
14117
|
+
multiObserver.addObserver('rn-observer', _observer);
|
|
14118
|
+
});
|
|
14119
|
+
};
|
|
14120
|
+
});
|
|
14121
|
+
extendsClassMethod(VeLivePlayer, 'setPictureInPictureListener', function () {
|
|
14122
|
+
return function setPictureInPictureListener(listener) {
|
|
14123
|
+
return runImpl(this, function () {
|
|
14124
|
+
var PictureInPictureManager$1 = PictureInPictureManager.getInstance();
|
|
14125
|
+
PictureInPictureManager$1.setListener(packObject(listener, android_PictureInPictureListener));
|
|
14126
|
+
}, function () {
|
|
14127
|
+
var manager = VeLivePictureInPictureManager.getInstance();
|
|
14128
|
+
manager.setListener(packObject(listener, ios_PictureInPictureManagerListener));
|
|
14129
|
+
});
|
|
14130
|
+
};
|
|
14131
|
+
});
|
|
14132
|
+
extendsClassMethod(VeLivePlayer, 'isPictureInPictureSupported', function () {
|
|
14133
|
+
return function isPictureInPictureSupported() {
|
|
14134
|
+
return runImpl(this, function () {
|
|
14135
|
+
var manager = PictureInPictureManager.getInstance();
|
|
14136
|
+
return manager.isPictureInPictureSupported();
|
|
14137
|
+
}, function () {
|
|
14138
|
+
var manager = VeLivePictureInPictureManager.getInstance();
|
|
14139
|
+
return manager.isPictureInPictureSupported();
|
|
14140
|
+
});
|
|
14141
|
+
};
|
|
14142
|
+
});
|
|
14143
|
+
extendsClassMethod(VeLivePlayer, 'enablePictureInPicture', function () {
|
|
14144
|
+
return function enablePictureInPicture() {
|
|
14145
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14146
|
+
return __generator(this, function (_a) {
|
|
14147
|
+
return [2 /*return*/, runImpl(this, function () { }, function () {
|
|
14148
|
+
var manager = VeLivePictureInPictureManager.getInstance();
|
|
14149
|
+
return manager.enablePictureInPicture();
|
|
14150
|
+
})];
|
|
14151
|
+
});
|
|
14152
|
+
});
|
|
14153
|
+
};
|
|
14154
|
+
});
|
|
14155
|
+
extendsClassMethod(VeLivePlayer, 'disablePictureInPicture', function () {
|
|
14156
|
+
return function disablePictureInPicture() {
|
|
14157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14158
|
+
return __generator(this, function (_a) {
|
|
14159
|
+
return [2 /*return*/, runImpl(this, function () { }, function () {
|
|
14160
|
+
var manager = VeLivePictureInPictureManager.getInstance();
|
|
14161
|
+
return manager.disablePictureInPicture();
|
|
14162
|
+
})];
|
|
14163
|
+
});
|
|
14164
|
+
});
|
|
14165
|
+
};
|
|
14166
|
+
});
|
|
14167
|
+
extendsClassMethod(VeLivePlayer, 'destroy', function (origin) {
|
|
14168
|
+
return function destroy() {
|
|
14169
|
+
var _this = this;
|
|
14170
|
+
return runImpl(this, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14171
|
+
return __generator(this, function (_a) {
|
|
14172
|
+
origin();
|
|
14173
|
+
return [2 /*return*/];
|
|
14174
|
+
});
|
|
14175
|
+
}); }, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14176
|
+
var manager;
|
|
14177
|
+
return __generator(this, function (_a) {
|
|
14178
|
+
origin();
|
|
14179
|
+
manager = VeLivePictureInPictureManager.getInstance();
|
|
14180
|
+
return [2 /*return*/, manager.destroyPictureInPicture()];
|
|
14181
|
+
});
|
|
14182
|
+
}); });
|
|
14183
|
+
};
|
|
14184
|
+
});
|
|
14185
|
+
|
|
14186
|
+
extendsClassMethod(android_VeLivePlayerObserver, 'onVideoSizeChanged', function (original) {
|
|
14187
|
+
return function onVideoSizeChanged(player, width, height) {
|
|
14188
|
+
original(player, width, height);
|
|
14189
|
+
if (reactNative.Platform.OS === 'android') {
|
|
14190
|
+
var androidPictureInPictureManager = PictureInPictureManager.getInstance();
|
|
14191
|
+
if (androidPictureInPictureManager) {
|
|
14192
|
+
androidPictureInPictureManager.setupConfig(width / height, 0, 0);
|
|
14193
|
+
}
|
|
14194
|
+
}
|
|
14195
|
+
else if (reactNative.Platform.OS === 'ios') {
|
|
14196
|
+
VeLivePictureInPictureManager.getInstance();
|
|
14197
|
+
}
|
|
14198
|
+
};
|
|
14199
|
+
});
|
|
14200
|
+
|
|
14472
14201
|
extendsClassMember(VeLivePlayerStatistics, 'format')(function () {
|
|
14473
14202
|
return {
|
|
14474
14203
|
getter: function () {
|
|
@@ -14684,23 +14413,25 @@ var defaultConfig = {
|
|
|
14684
14413
|
};
|
|
14685
14414
|
function initAndroidPlayer(options) {
|
|
14686
14415
|
return __awaiter(this, void 0, void 0, function () {
|
|
14687
|
-
var viewId, option,
|
|
14688
|
-
return __generator(this, function (
|
|
14689
|
-
switch (
|
|
14416
|
+
var viewId, option, context, player, view, _a, _b, config, manager;
|
|
14417
|
+
return __generator(this, function (_c) {
|
|
14418
|
+
switch (_c.label) {
|
|
14690
14419
|
case 0:
|
|
14691
14420
|
viewId = options.viewId, option = __rest(options, ["viewId"]);
|
|
14692
|
-
_a = VeLivePlayer.bind;
|
|
14693
14421
|
return [4 /*yield*/, NativeVariables.getApplicationContext()];
|
|
14694
14422
|
case 1:
|
|
14695
|
-
|
|
14423
|
+
context = _c.sent();
|
|
14424
|
+
player = new VeLivePlayer(context);
|
|
14696
14425
|
view = NativeView.getView(viewId, NativeSurfaceView);
|
|
14697
|
-
|
|
14426
|
+
_b = (_a = player).android_setSurfaceHolder;
|
|
14698
14427
|
return [4 /*yield*/, view.getHolder()];
|
|
14699
14428
|
case 2:
|
|
14700
|
-
|
|
14429
|
+
_b.apply(_a, [(_c.sent())]);
|
|
14701
14430
|
config = new VeLivePlayerConfiguration();
|
|
14702
14431
|
Object.assign(config, defaultConfig, option);
|
|
14703
14432
|
player.setConfig(config);
|
|
14433
|
+
manager = PictureInPictureManager.getInstance();
|
|
14434
|
+
manager.setupPlayer(unpackObject(player), context, view);
|
|
14704
14435
|
return [2 /*return*/, player];
|
|
14705
14436
|
}
|
|
14706
14437
|
});
|
|
@@ -14708,7 +14439,7 @@ function initAndroidPlayer(options) {
|
|
|
14708
14439
|
}
|
|
14709
14440
|
function initIOSPlayer(options) {
|
|
14710
14441
|
return __awaiter(this, void 0, void 0, function () {
|
|
14711
|
-
var viewId, option, player, config, uiView;
|
|
14442
|
+
var viewId, option, player, config, uiView, multiObserver, manager;
|
|
14712
14443
|
return __generator(this, function (_a) {
|
|
14713
14444
|
switch (_a.label) {
|
|
14714
14445
|
case 0:
|
|
@@ -14721,6 +14452,10 @@ function initIOSPlayer(options) {
|
|
|
14721
14452
|
return [4 /*yield*/, uiView.insertSubview(player.ios_playerView, 0)];
|
|
14722
14453
|
case 1:
|
|
14723
14454
|
_a.sent();
|
|
14455
|
+
multiObserver = VeLivePlayerMultiObserver.getInstance();
|
|
14456
|
+
multiObserver.setupPlayer(unpackObject(player));
|
|
14457
|
+
manager = VeLivePictureInPictureManager.getInstance();
|
|
14458
|
+
manager.setupPlayer(unpackObject(player));
|
|
14724
14459
|
return [2 /*return*/, player];
|
|
14725
14460
|
}
|
|
14726
14461
|
});
|