@byteplus/react-native-live-push 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/java/com/volcengine/velive/rn/push/VeLivePushView.java +86 -11
- package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushViewManager.java +22 -38
- package/lib/commonjs/index.js +1278 -2076
- package/lib/module/index.js +1278 -2076
- package/lib/typescript/codegen/android/errorcode.d.ts +11 -11
- package/lib/typescript/codegen/pack/errorcode.d.ts +11 -11
- package/lib/typescript/codegen/pack/keytype.d.ts +19 -19
- package/package.json +1 -1
package/lib/commonjs/index.js
CHANGED
|
@@ -274,173 +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
|
-
var __assign$1 = function() {
|
|
312
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
313
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
314
|
-
s = arguments[i];
|
|
315
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
316
|
-
}
|
|
317
|
-
return t;
|
|
318
|
-
};
|
|
319
|
-
return __assign$1.apply(this, arguments);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
function __esDecorate$1(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
323
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
324
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
325
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
326
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
327
|
-
var _, done = false;
|
|
328
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
329
|
-
var context = {};
|
|
330
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
331
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
332
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
333
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
334
|
-
if (kind === "accessor") {
|
|
335
|
-
if (result === void 0) continue;
|
|
336
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
337
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
338
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
339
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
340
|
-
}
|
|
341
|
-
else if (_ = accept(result)) {
|
|
342
|
-
if (kind === "field") initializers.unshift(_);
|
|
343
|
-
else descriptor[key] = _;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
347
|
-
done = true;
|
|
348
|
-
}
|
|
349
|
-
function __runInitializers$1(thisArg, initializers, value) {
|
|
350
|
-
var useValue = arguments.length > 2;
|
|
351
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
352
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
353
|
-
}
|
|
354
|
-
return useValue ? value : void 0;
|
|
355
|
-
}
|
|
356
|
-
function __setFunctionName$1(f, name, prefix) {
|
|
357
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
358
|
-
return Object.defineProperty(f, "name", { configurable: true, value: name });
|
|
359
|
-
}
|
|
360
|
-
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
361
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
362
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
363
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
364
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
365
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
366
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
function __generator$1(thisArg, body) {
|
|
371
|
-
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);
|
|
372
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
373
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
374
|
-
function step(op) {
|
|
375
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
376
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
377
|
-
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;
|
|
378
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
379
|
-
switch (op[0]) {
|
|
380
|
-
case 0: case 1: t = op; break;
|
|
381
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
382
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
383
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
384
|
-
default:
|
|
385
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
386
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
387
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
388
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
389
|
-
if (t[2]) _.ops.pop();
|
|
390
|
-
_.trys.pop(); continue;
|
|
391
|
-
}
|
|
392
|
-
op = body.call(thisArg, _);
|
|
393
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
394
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function __spreadArray$1(to, from, pack) {
|
|
399
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
400
|
-
if (ar || !(i in from)) {
|
|
401
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
402
|
-
ar[i] = from[i];
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
409
|
-
var e = new Error(message);
|
|
410
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
var DISABLE_INIT = Symbol();
|
|
279
|
+
const DISABLE_INIT = Symbol();
|
|
414
280
|
function PackClass() {
|
|
415
|
-
return
|
|
416
|
-
return
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
args[_i] = arguments[_i];
|
|
422
|
-
}
|
|
423
|
-
var _this = _super.apply(this, args) || this;
|
|
424
|
-
var _init = function () {
|
|
425
|
-
var _a, _b;
|
|
426
|
-
(_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);
|
|
427
287
|
};
|
|
428
|
-
|
|
288
|
+
const isDisableInit = args.includes(DISABLE_INIT);
|
|
429
289
|
if (!isDisableInit) {
|
|
430
290
|
_init();
|
|
431
291
|
}
|
|
432
|
-
Object.defineProperty(
|
|
292
|
+
Object.defineProperty(this, '$$pack', {
|
|
433
293
|
value: true,
|
|
434
294
|
enumerable: false,
|
|
435
295
|
});
|
|
436
|
-
return _this;
|
|
437
296
|
}
|
|
438
|
-
|
|
439
|
-
var _a, _b;
|
|
440
|
-
(_b = (_a = this._instance).__destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
441
|
-
};
|
|
442
|
-
return class_1;
|
|
443
|
-
}(target));
|
|
297
|
+
};
|
|
444
298
|
};
|
|
445
299
|
}
|
|
446
300
|
|
|
@@ -455,7 +309,7 @@ function packObject(receiver, ctor) {
|
|
|
455
309
|
if (isPrimateValue(receiver)) {
|
|
456
310
|
return receiver;
|
|
457
311
|
}
|
|
458
|
-
|
|
312
|
+
const ins = new ctor(DISABLE_INIT);
|
|
459
313
|
Object.defineProperty(ins, '_instance', {
|
|
460
314
|
value: receiver,
|
|
461
315
|
enumerable: false,
|
|
@@ -470,23 +324,19 @@ function unpackObject(proxyInstance, _nativeClass) {
|
|
|
470
324
|
}
|
|
471
325
|
|
|
472
326
|
function fn2AndroidClass(tsFn, nativeClass, methodName) {
|
|
473
|
-
|
|
327
|
+
const ins = new nativeClass();
|
|
474
328
|
ins[methodName] = tsFn;
|
|
475
329
|
return ins;
|
|
476
330
|
}
|
|
477
331
|
function extendsClassMethod(ctor, methodName, overrideFn) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
proto[methodName] = function () {
|
|
481
|
-
|
|
482
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
483
|
-
args[_i] = arguments[_i];
|
|
484
|
-
}
|
|
485
|
-
return overrideFn(originalFn === null || originalFn === void 0 ? void 0 : originalFn.bind(this)).apply(this, args);
|
|
332
|
+
const proto = ctor.prototype;
|
|
333
|
+
const originalFn = ctor.prototype[methodName];
|
|
334
|
+
proto[methodName] = function (...args) {
|
|
335
|
+
return overrideFn(originalFn?.bind(this)).apply(this, args);
|
|
486
336
|
};
|
|
487
337
|
}
|
|
488
338
|
|
|
489
|
-
|
|
339
|
+
let impl;
|
|
490
340
|
function setupEnv(e) {
|
|
491
341
|
impl = e;
|
|
492
342
|
}
|
|
@@ -504,11 +354,10 @@ var env = /*#__PURE__*/Object.freeze({
|
|
|
504
354
|
setupEnv: setupEnv
|
|
505
355
|
});
|
|
506
356
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
var prefix = namespace.slice(0, 24);
|
|
357
|
+
const SIZE = 32;
|
|
358
|
+
const getUuid = (namespace = '') => {
|
|
359
|
+
const random = String(Math.random()).slice(2);
|
|
360
|
+
const prefix = namespace.slice(0, 24);
|
|
512
361
|
return '@js#' + prefix + '#' + random.slice(0, SIZE - prefix.length - 1);
|
|
513
362
|
};
|
|
514
363
|
|
|
@@ -559,10 +408,6 @@ var CALL_TYPE$1;
|
|
|
559
408
|
* 事件执行后的返回值
|
|
560
409
|
*/
|
|
561
410
|
CALL_TYPE["INSTANCE_EVENT_RESULT"] = "instance_event_result";
|
|
562
|
-
/**
|
|
563
|
-
* 销毁实例
|
|
564
|
-
*/
|
|
565
|
-
CALL_TYPE["DESTROY_INSTANCE"] = "destroy_instance";
|
|
566
411
|
/**
|
|
567
412
|
* 触发事件
|
|
568
413
|
*/
|
|
@@ -574,82 +419,133 @@ var RETURN_STATUS$1;
|
|
|
574
419
|
RETURN_STATUS["FAILED"] = "failed";
|
|
575
420
|
RETURN_STATUS["NOT_IMPLEMENTED"] = "not_implemented";
|
|
576
421
|
})(RETURN_STATUS$1 || (RETURN_STATUS$1 = {}));
|
|
577
|
-
var INSTANCE_TYPE$1;
|
|
578
|
-
(function (INSTANCE_TYPE) {
|
|
579
|
-
/**
|
|
580
|
-
* 自动 GC 类型
|
|
581
|
-
*/
|
|
582
|
-
INSTANCE_TYPE[INSTANCE_TYPE["AUTOMATIC"] = 0] = "AUTOMATIC";
|
|
583
|
-
/**
|
|
584
|
-
* 手动 GC 类型
|
|
585
|
-
*/
|
|
586
|
-
INSTANCE_TYPE[INSTANCE_TYPE["MANUAL"] = 1] = "MANUAL";
|
|
587
|
-
})(INSTANCE_TYPE$1 || (INSTANCE_TYPE$1 = {}));
|
|
588
422
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
DefaultBridgeImpl.prototype.call = function () {
|
|
593
|
-
return new Promise(function (resolve, reject) {
|
|
423
|
+
class DefaultBridgeImpl {
|
|
424
|
+
call() {
|
|
425
|
+
return new Promise((resolve, reject) => {
|
|
594
426
|
resolve({
|
|
595
427
|
status: 'success',
|
|
596
428
|
msg: null,
|
|
597
429
|
});
|
|
598
430
|
});
|
|
599
|
-
}
|
|
600
|
-
|
|
431
|
+
}
|
|
432
|
+
callSync() {
|
|
601
433
|
return {
|
|
602
434
|
status: 'success',
|
|
603
435
|
msg: null,
|
|
604
436
|
};
|
|
605
|
-
}
|
|
606
|
-
|
|
437
|
+
}
|
|
438
|
+
registerHandler(handlerName, handler) {
|
|
607
439
|
// dsBridge.register(handlerName, handler);
|
|
608
|
-
}
|
|
609
|
-
|
|
440
|
+
}
|
|
441
|
+
registerAsyncHandler(handlerName, handler) {
|
|
610
442
|
//
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
}());
|
|
443
|
+
}
|
|
444
|
+
}
|
|
614
445
|
|
|
615
|
-
|
|
446
|
+
const createJSBridge = () => {
|
|
616
447
|
return new DefaultBridgeImpl();
|
|
617
448
|
};
|
|
618
449
|
|
|
450
|
+
/******************************************************************************
|
|
451
|
+
Copyright (c) Microsoft Corporation.
|
|
452
|
+
|
|
453
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
454
|
+
purpose with or without fee is hereby granted.
|
|
455
|
+
|
|
456
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
457
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
458
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
459
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
460
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
461
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
462
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
463
|
+
***************************************************************************** */
|
|
464
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
function __esDecorate$1(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
468
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
469
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
470
|
+
var target = ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
471
|
+
var descriptor = (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
472
|
+
var _, done = false;
|
|
473
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
474
|
+
var context = {};
|
|
475
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
476
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
477
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
478
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
479
|
+
if (kind === "accessor") {
|
|
480
|
+
if (result === void 0) continue;
|
|
481
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
482
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
483
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
484
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
485
|
+
}
|
|
486
|
+
else if (_ = accept(result)) {
|
|
487
|
+
if (kind === "field") initializers.unshift(_);
|
|
488
|
+
else descriptor[key] = _;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
492
|
+
done = true;
|
|
493
|
+
}
|
|
494
|
+
function __runInitializers$1(thisArg, initializers, value) {
|
|
495
|
+
var useValue = arguments.length > 2;
|
|
496
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
497
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
498
|
+
}
|
|
499
|
+
return useValue ? value : void 0;
|
|
500
|
+
}
|
|
501
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
502
|
+
var e = new Error(message);
|
|
503
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
504
|
+
};
|
|
505
|
+
|
|
619
506
|
function assert(expression, msg) {
|
|
620
507
|
if (!expression) {
|
|
621
508
|
throw new Error(msg);
|
|
622
509
|
}
|
|
623
510
|
}
|
|
624
511
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
};
|
|
628
|
-
var isInstance = function (value) {
|
|
512
|
+
const isArray = (value) => Array.isArray(value);
|
|
513
|
+
const isInstance = (value) => {
|
|
629
514
|
if (typeof value !== 'object' || value === null) {
|
|
630
515
|
return false;
|
|
631
516
|
}
|
|
632
517
|
if ('instanceId' in value || '_instanceId' in value) {
|
|
633
518
|
return true;
|
|
634
519
|
}
|
|
635
|
-
|
|
520
|
+
const proto = Object.getPrototypeOf(value);
|
|
636
521
|
return (!!proto &&
|
|
637
522
|
proto.constructor.name !== 'Array' &&
|
|
638
523
|
proto.constructor.name !== 'Object');
|
|
639
524
|
};
|
|
640
|
-
|
|
525
|
+
const isCallback = (value) => {
|
|
641
526
|
return typeof value === 'function';
|
|
642
527
|
};
|
|
643
|
-
|
|
528
|
+
const isPlainObject = (value) => {
|
|
644
529
|
return typeof value === 'object' && value !== null;
|
|
645
530
|
};
|
|
646
|
-
|
|
531
|
+
const isInstanceArg = (value) => {
|
|
647
532
|
return (isPlainObject(value) && value._type === "instance" /* ARG_TYPE.INSTANCE */);
|
|
648
533
|
};
|
|
649
534
|
|
|
535
|
+
function safeStringify(val) {
|
|
536
|
+
try {
|
|
537
|
+
if (val instanceof Error) {
|
|
538
|
+
return `Error: ${val.message}`;
|
|
539
|
+
}
|
|
540
|
+
return JSON.stringify(val);
|
|
541
|
+
}
|
|
542
|
+
catch (er) {
|
|
543
|
+
return String(val);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
650
547
|
function fromPairs(entries) {
|
|
651
|
-
return entries.reduce(
|
|
652
|
-
var k = _a[0], v = _a[1];
|
|
548
|
+
return entries.reduce((acc, [k, v]) => {
|
|
653
549
|
acc[k] = v;
|
|
654
550
|
return acc;
|
|
655
551
|
}, {});
|
|
@@ -658,32 +554,17 @@ function toPairs(obj) {
|
|
|
658
554
|
return Object.entries(obj);
|
|
659
555
|
}
|
|
660
556
|
function mapValues(data, fn) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
var k = _a[0], v = _a[1];
|
|
664
|
-
return [k, fn(v, k)];
|
|
665
|
-
});
|
|
557
|
+
const paris = toPairs(data);
|
|
558
|
+
const mappedPairs = paris.map(([k, v]) => [k, fn(v, k)]);
|
|
666
559
|
return fromPairs(mappedPairs);
|
|
667
560
|
}
|
|
668
561
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
?
|
|
672
|
-
: isInstanceArg(instanceOrId)
|
|
673
|
-
? instanceOrId._instanceId
|
|
674
|
-
: undefined;
|
|
675
|
-
if (!id) {
|
|
676
|
-
throw new Error('instanceOrId is not an instance');
|
|
677
|
-
}
|
|
678
|
-
return id;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
var keyPathVisitor = function (obj, path, defaultValue) {
|
|
682
|
-
var getResult = obj
|
|
683
|
-
? path.reduce(function (pre, next) {
|
|
562
|
+
const keyPathVisitor = (obj, path, defaultValue) => {
|
|
563
|
+
const getResult = obj
|
|
564
|
+
? path.reduce((pre, next) => {
|
|
684
565
|
if (pre && pre !== defaultValue) {
|
|
685
|
-
|
|
686
|
-
|
|
566
|
+
const preValue = pre;
|
|
567
|
+
const nextvalue = preValue[next];
|
|
687
568
|
return !nextvalue ? defaultValue : nextvalue;
|
|
688
569
|
}
|
|
689
570
|
return defaultValue;
|
|
@@ -692,9 +573,9 @@ var keyPathVisitor = function (obj, path, defaultValue) {
|
|
|
692
573
|
return getResult;
|
|
693
574
|
};
|
|
694
575
|
|
|
695
|
-
|
|
576
|
+
const Bind = (target, context) => {
|
|
696
577
|
context.addInitializer(function () {
|
|
697
|
-
|
|
578
|
+
const fnName = context.name;
|
|
698
579
|
this[fnName] = this[fnName].bind(this);
|
|
699
580
|
});
|
|
700
581
|
return target;
|
|
@@ -702,1094 +583,343 @@ var Bind = function (target, context) {
|
|
|
702
583
|
|
|
703
584
|
var LogLevel;
|
|
704
585
|
(function (LogLevel) {
|
|
705
|
-
LogLevel[LogLevel["
|
|
706
|
-
LogLevel[LogLevel["
|
|
707
|
-
LogLevel[LogLevel["
|
|
708
|
-
LogLevel[LogLevel["
|
|
709
|
-
LogLevel[LogLevel["
|
|
586
|
+
LogLevel[LogLevel["verbose"] = 0] = "verbose";
|
|
587
|
+
LogLevel[LogLevel["debug"] = 1] = "debug";
|
|
588
|
+
LogLevel[LogLevel["info"] = 2] = "info";
|
|
589
|
+
LogLevel[LogLevel["warn"] = 3] = "warn";
|
|
590
|
+
LogLevel[LogLevel["error"] = 4] = "error";
|
|
710
591
|
})(LogLevel || (LogLevel = {}));
|
|
711
592
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
this.
|
|
593
|
+
class LoggerImpl {
|
|
594
|
+
constructor() {
|
|
595
|
+
this._enablePrintVerbose = false;
|
|
715
596
|
this._consumers = [];
|
|
716
597
|
}
|
|
717
|
-
|
|
718
|
-
if (!LoggerImpl.instance) {
|
|
719
|
-
LoggerImpl.instance = new LoggerImpl();
|
|
720
|
-
}
|
|
721
|
-
return LoggerImpl.instance;
|
|
722
|
-
};
|
|
723
|
-
LoggerImpl.prototype.init = function (opt) {
|
|
598
|
+
init(opt) {
|
|
724
599
|
this.options = opt;
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
this._logLevel = level;
|
|
731
|
-
};
|
|
732
|
-
LoggerImpl.prototype.registerConsumer = function (consumer) {
|
|
600
|
+
}
|
|
601
|
+
enableVerbose(enable) {
|
|
602
|
+
this._enablePrintVerbose = enable;
|
|
603
|
+
}
|
|
604
|
+
registerConsumer(consumer) {
|
|
733
605
|
this._consumers.push(consumer);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
LoggerImpl.prototype._formatMessage = function (args) {
|
|
739
|
-
try {
|
|
740
|
-
var message = args
|
|
741
|
-
.map(function (arg) {
|
|
742
|
-
if (typeof arg === 'object') {
|
|
743
|
-
return JSON.stringify(arg, null, 2);
|
|
744
|
-
}
|
|
745
|
-
return String(arg);
|
|
746
|
-
})
|
|
747
|
-
.join(' ');
|
|
748
|
-
if (message.length > LoggerImpl.MAX_LOG_LENGTH) {
|
|
749
|
-
return message.substring(0, LoggerImpl.MAX_LOG_LENGTH);
|
|
750
|
-
}
|
|
751
|
-
return message;
|
|
752
|
-
}
|
|
753
|
-
catch (e) {
|
|
754
|
-
if (e instanceof Error) {
|
|
755
|
-
return "[Format Error] ".concat(args.join(' '), " - ").concat(e.message);
|
|
756
|
-
}
|
|
757
|
-
return "[Format Error] ".concat(args.join(' '));
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
LoggerImpl.prototype._formatDate = function (date) {
|
|
761
|
-
var pad = function (n) { return (n < 10 ? '0' + n : n); };
|
|
762
|
-
return "".concat(pad(date.getHours()), ":").concat(pad(date.getMinutes()), ":").concat(pad(date.getSeconds()));
|
|
763
|
-
};
|
|
764
|
-
LoggerImpl.prototype._getCurrentTimestamp = function () {
|
|
765
|
-
return this._formatDate(new Date());
|
|
766
|
-
};
|
|
767
|
-
LoggerImpl.prototype._log = function (level, args) {
|
|
768
|
-
var _this = this;
|
|
769
|
-
if (!this._shouldLog(level)) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
var timestamp = this._getCurrentTimestamp();
|
|
773
|
-
var message = this._formatMessage(args);
|
|
774
|
-
var logMsg = {
|
|
775
|
-
level: level,
|
|
776
|
-
content: ["".concat(timestamp, " ").concat(message)],
|
|
777
|
-
};
|
|
778
|
-
// 发送给消费者
|
|
779
|
-
this._consumers.forEach(function (c) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
780
|
-
return __generator$1(this, function (_a) {
|
|
781
|
-
switch (_a.label) {
|
|
782
|
-
case 0:
|
|
783
|
-
_a.trys.push([0, 2, , 3]);
|
|
784
|
-
return [4 /*yield*/, c(logMsg)];
|
|
785
|
-
case 1:
|
|
786
|
-
_a.sent();
|
|
787
|
-
return [3 /*break*/, 3];
|
|
788
|
-
case 2:
|
|
789
|
-
_a.sent();
|
|
790
|
-
return [3 /*break*/, 3];
|
|
791
|
-
case 3: return [2 /*return*/];
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
}); });
|
|
795
|
-
// 控制台输出
|
|
796
|
-
switch (level) {
|
|
797
|
-
case LogLevel.ERROR:
|
|
798
|
-
console.error("".concat(timestamp, " ").concat(message));
|
|
799
|
-
break;
|
|
800
|
-
case LogLevel.WARN:
|
|
801
|
-
console.warn("".concat(timestamp, " ").concat(message));
|
|
802
|
-
break;
|
|
803
|
-
case LogLevel.INFO:
|
|
804
|
-
console.log("".concat(timestamp, " ").concat(message));
|
|
805
|
-
break;
|
|
806
|
-
case LogLevel.DEBUG:
|
|
807
|
-
console.debug("".concat(timestamp, " ").concat(message));
|
|
808
|
-
break;
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
LoggerImpl.prototype.debug = function () {
|
|
812
|
-
var args = [];
|
|
813
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
814
|
-
args[_i] = arguments[_i];
|
|
815
|
-
}
|
|
816
|
-
this._log(LogLevel.DEBUG, args);
|
|
817
|
-
};
|
|
818
|
-
LoggerImpl.prototype.info = function () {
|
|
819
|
-
var args = [];
|
|
820
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
821
|
-
args[_i] = arguments[_i];
|
|
822
|
-
}
|
|
823
|
-
this._log(LogLevel.INFO, args);
|
|
824
|
-
};
|
|
825
|
-
LoggerImpl.prototype.warn = function () {
|
|
826
|
-
var args = [];
|
|
827
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
828
|
-
args[_i] = arguments[_i];
|
|
606
|
+
}
|
|
607
|
+
verbose(...args) {
|
|
608
|
+
if (this._enablePrintVerbose) {
|
|
609
|
+
console.debug('[verbose]', ...args);
|
|
829
610
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
611
|
+
}
|
|
612
|
+
debug(...args) {
|
|
613
|
+
const msg = {
|
|
614
|
+
level: LogLevel.debug,
|
|
615
|
+
content: args,
|
|
616
|
+
};
|
|
617
|
+
this._log(msg);
|
|
618
|
+
if (this._enablePrintVerbose) {
|
|
619
|
+
console.debug('[debug]', ...args);
|
|
836
620
|
}
|
|
837
|
-
this._log(LogLevel.ERROR, args);
|
|
838
|
-
};
|
|
839
|
-
LoggerImpl.MAX_LOG_LENGTH = 4096;
|
|
840
|
-
return LoggerImpl;
|
|
841
|
-
}());
|
|
842
|
-
|
|
843
|
-
function assertReturn(ret) {
|
|
844
|
-
if (!ret || typeof ret !== 'object') {
|
|
845
|
-
return;
|
|
846
621
|
}
|
|
847
|
-
|
|
848
|
-
|
|
622
|
+
info(...args) {
|
|
623
|
+
const msg = {
|
|
624
|
+
level: LogLevel.info,
|
|
625
|
+
content: args,
|
|
626
|
+
};
|
|
627
|
+
this._log(msg);
|
|
628
|
+
console.log(...args);
|
|
849
629
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
630
|
+
warn(...args) {
|
|
631
|
+
const msg = {
|
|
632
|
+
level: LogLevel.warn,
|
|
633
|
+
content: args,
|
|
634
|
+
};
|
|
635
|
+
this._log(msg);
|
|
636
|
+
console.warn(...args);
|
|
637
|
+
}
|
|
638
|
+
error(...args) {
|
|
639
|
+
const msg = {
|
|
640
|
+
level: LogLevel.error,
|
|
641
|
+
content: args,
|
|
642
|
+
};
|
|
643
|
+
this._log(msg);
|
|
644
|
+
console.error(...args);
|
|
645
|
+
}
|
|
646
|
+
_log(msg) {
|
|
647
|
+
this._consumers.forEach(async (c) => {
|
|
648
|
+
try {
|
|
649
|
+
await c(msg);
|
|
650
|
+
}
|
|
651
|
+
catch (ignore) {
|
|
652
|
+
//
|
|
653
|
+
}
|
|
654
|
+
});
|
|
857
655
|
}
|
|
858
|
-
return false;
|
|
859
656
|
}
|
|
860
657
|
|
|
861
|
-
|
|
862
|
-
var KEY_NATIVE_CLASS_NAME = Symbol.for('#nativeClassName');
|
|
863
|
-
function findNamespace(ctor) {
|
|
864
|
-
var obj = ctor;
|
|
865
|
-
var desc;
|
|
866
|
-
while (!desc && obj) {
|
|
867
|
-
desc = Object.getOwnPropertyDescriptor(obj, KEY_NAMESPACE);
|
|
868
|
-
obj = Object.getPrototypeOf(obj);
|
|
869
|
-
}
|
|
870
|
-
return desc === null || desc === void 0 ? void 0 : desc.value;
|
|
871
|
-
}
|
|
872
|
-
function findMethods(ins, opt) {
|
|
873
|
-
if (opt === void 0) { opt = {}; }
|
|
874
|
-
var methodNames = [];
|
|
875
|
-
var proto = Object.getPrototypeOf(ins);
|
|
876
|
-
while (proto && proto !== Object.prototype) {
|
|
877
|
-
var ownMethods = Object.getOwnPropertyNames(proto)
|
|
878
|
-
.filter(function (name) { return name !== 'constructor'; })
|
|
879
|
-
.map(function (name) { return opt[name] || name; });
|
|
880
|
-
methodNames.push.apply(methodNames, ownMethods);
|
|
881
|
-
proto = Object.getPrototypeOf(proto);
|
|
882
|
-
}
|
|
883
|
-
return methodNames;
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* 垃圾回收检查器,JS 对象被回收后,清除 Native 中的实例
|
|
887
|
-
*/
|
|
888
|
-
var getRegistry = function () {
|
|
889
|
-
if (typeof FinalizationRegistry !== 'undefined') {
|
|
890
|
-
try {
|
|
891
|
-
return new FinalizationRegistry(function (heldValue) {
|
|
892
|
-
var _a = heldValue.split('::'), instanceId = _a[0], namespace = _a[1];
|
|
893
|
-
if (instanceId) {
|
|
894
|
-
getMessageClient(instanceId).sendDestroyInstance(instanceId, namespace || '');
|
|
895
|
-
logger.debug('instance has been destroyed', instanceId);
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
catch (e) {
|
|
900
|
-
logger.warn('Failed to create FinalizationRegistry', e);
|
|
901
|
-
return null;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
return null;
|
|
905
|
-
};
|
|
906
|
-
var NativeObserverClass = function (className, opt) {
|
|
907
|
-
if (opt === void 0) { opt = {
|
|
908
|
-
instanceType: INSTANCE_TYPE$1.AUTOMATIC,
|
|
909
|
-
}; }
|
|
910
|
-
return function (target, ctx) {
|
|
911
|
-
ctx.addInitializer(function () {
|
|
912
|
-
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
913
|
-
value: className,
|
|
914
|
-
writable: true,
|
|
915
|
-
});
|
|
916
|
-
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
917
|
-
});
|
|
918
|
-
// @ts-ignore
|
|
919
|
-
return /** @class */ (function (_super) {
|
|
920
|
-
__extends$1(class_1, _super);
|
|
921
|
-
function class_1() {
|
|
922
|
-
var args = [];
|
|
923
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
924
|
-
args[_i] = arguments[_i];
|
|
925
|
-
}
|
|
926
|
-
var _a;
|
|
927
|
-
var _this = _super.apply(this, args) || this;
|
|
928
|
-
var t = _this;
|
|
929
|
-
var instanceId = getUuid(className);
|
|
930
|
-
t.namespace = className;
|
|
931
|
-
t.instanceId = instanceId;
|
|
932
|
-
t.messageClient = getMessageClient(t);
|
|
933
|
-
t.options = opt;
|
|
934
|
-
t.instanceType = opt.instanceType || INSTANCE_TYPE$1.AUTOMATIC;
|
|
935
|
-
(_a = getRegistry()) === null || _a === void 0 ? void 0 : _a.register(_this, "".concat(instanceId, "::").concat(className));
|
|
936
|
-
// custom consume native event
|
|
937
|
-
/**
|
|
938
|
-
* @param this
|
|
939
|
-
* @param name native method name
|
|
940
|
-
* @param params
|
|
941
|
-
*/
|
|
942
|
-
t.emit = function (name) {
|
|
943
|
-
var _a;
|
|
944
|
-
var params = [];
|
|
945
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
946
|
-
params[_i - 1] = arguments[_i];
|
|
947
|
-
}
|
|
948
|
-
var curName = ((_a = Object.entries(opt).find(function (_a) {
|
|
949
|
-
var v = _a[1];
|
|
950
|
-
return v === name;
|
|
951
|
-
})) === null || _a === void 0 ? void 0 : _a[0]) || name;
|
|
952
|
-
var fn = this[curName];
|
|
953
|
-
if (typeof fn === 'function') {
|
|
954
|
-
return fn.apply(this, params);
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
var _init = function () {
|
|
958
|
-
var events = findMethods(_this, opt);
|
|
959
|
-
t.messageClient.sendNewInstanceCall(className, [events], instanceId, t);
|
|
960
|
-
};
|
|
961
|
-
// proxy native created class
|
|
962
|
-
if (!args.includes(DISABLE_INIT)) {
|
|
963
|
-
_init();
|
|
964
|
-
}
|
|
965
|
-
return _this;
|
|
966
|
-
}
|
|
967
|
-
class_1.prototype.__destroy = function () {
|
|
968
|
-
var _a;
|
|
969
|
-
var t = this;
|
|
970
|
-
(_a = t.messageClient) === null || _a === void 0 ? void 0 : _a.sendDestroyInstance(t, t.namespace || '');
|
|
971
|
-
};
|
|
972
|
-
return class_1;
|
|
973
|
-
}(target));
|
|
974
|
-
};
|
|
975
|
-
};
|
|
976
|
-
var NativeClass = function (className, opt) {
|
|
977
|
-
if (opt === void 0) { opt = {
|
|
978
|
-
instanceType: INSTANCE_TYPE$1.AUTOMATIC,
|
|
979
|
-
}; }
|
|
980
|
-
return function (target, ctx) {
|
|
981
|
-
ctx.addInitializer(function () {
|
|
982
|
-
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
983
|
-
value: className,
|
|
984
|
-
writable: true,
|
|
985
|
-
});
|
|
986
|
-
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
987
|
-
});
|
|
988
|
-
// @ts-ignore
|
|
989
|
-
return /** @class */ (function (_super) {
|
|
990
|
-
__extends$1(class_2, _super);
|
|
991
|
-
function class_2() {
|
|
992
|
-
var args = [];
|
|
993
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
994
|
-
args[_i] = arguments[_i];
|
|
995
|
-
}
|
|
996
|
-
var _a;
|
|
997
|
-
var _this = _super.apply(this, args) || this;
|
|
998
|
-
var t = _this;
|
|
999
|
-
var instanceId = getUuid(className);
|
|
1000
|
-
t.namespace = className;
|
|
1001
|
-
t.instanceId = instanceId;
|
|
1002
|
-
t.messageClient = getMessageClient(t);
|
|
1003
|
-
t.instanceType = opt.instanceType || INSTANCE_TYPE$1.AUTOMATIC;
|
|
1004
|
-
(_a = getRegistry()) === null || _a === void 0 ? void 0 : _a.register(_this, "".concat(instanceId, "::").concat(className));
|
|
1005
|
-
var _init = function () {
|
|
1006
|
-
t.messageClient.sendNewInstanceCall(className, args.filter(function (v) { return v !== undefined; }), instanceId, t);
|
|
1007
|
-
if (getOS() === "ios" /* OS.ios */ &&
|
|
1008
|
-
typeof _this.init === 'function') {
|
|
1009
|
-
_this.init();
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
// proxy native created class
|
|
1013
|
-
if (!args.includes(DISABLE_INIT)) {
|
|
1014
|
-
_init();
|
|
1015
|
-
}
|
|
1016
|
-
return _this;
|
|
1017
|
-
}
|
|
1018
|
-
class_2.prototype.__destroy = function () {
|
|
1019
|
-
var _a;
|
|
1020
|
-
var t = this;
|
|
1021
|
-
(_a = t.messageClient) === null || _a === void 0 ? void 0 : _a.sendDestroyInstance(t, t.namespace || '');
|
|
1022
|
-
};
|
|
1023
|
-
return class_2;
|
|
1024
|
-
}(target));
|
|
1025
|
-
};
|
|
1026
|
-
};
|
|
1027
|
-
var NativeStaticMethod = function (methodSelector) {
|
|
1028
|
-
return function (target, ctx) {
|
|
1029
|
-
var name = ctx.name;
|
|
1030
|
-
return function impl() {
|
|
1031
|
-
var args = [];
|
|
1032
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1033
|
-
args[_i] = arguments[_i];
|
|
1034
|
-
}
|
|
1035
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1036
|
-
var namespace, client, returnValue, data;
|
|
1037
|
-
return __generator$1(this, function (_a) {
|
|
1038
|
-
switch (_a.label) {
|
|
1039
|
-
case 0:
|
|
1040
|
-
namespace = findNamespace(this);
|
|
1041
|
-
client = getMessageClient(this);
|
|
1042
|
-
return [4 /*yield*/, client.sendStaticCall(namespace || '', methodSelector || name, args)];
|
|
1043
|
-
case 1:
|
|
1044
|
-
returnValue = _a.sent();
|
|
1045
|
-
data = assertReturn(returnValue);
|
|
1046
|
-
return [2 /*return*/, data];
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
});
|
|
1050
|
-
};
|
|
1051
|
-
};
|
|
1052
|
-
};
|
|
1053
|
-
var NativeStaticMethodSync = function (methodSelector) {
|
|
1054
|
-
return function (target, ctx) {
|
|
1055
|
-
var name = ctx.name;
|
|
1056
|
-
return function impl() {
|
|
1057
|
-
var args = [];
|
|
1058
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1059
|
-
args[_i] = arguments[_i];
|
|
1060
|
-
}
|
|
1061
|
-
var namespace = findNamespace(this);
|
|
1062
|
-
var client = getMessageClient(this);
|
|
1063
|
-
var returnValue = client.sendStaticCallSync(namespace || '', methodSelector || name, args);
|
|
1064
|
-
var data = assertReturn(returnValue);
|
|
1065
|
-
return data;
|
|
1066
|
-
};
|
|
1067
|
-
};
|
|
1068
|
-
};
|
|
1069
|
-
var ReturnClass = function (getCtor) {
|
|
1070
|
-
return function (target, ctx) {
|
|
1071
|
-
// TODO: impl
|
|
1072
|
-
return function impl() {
|
|
1073
|
-
var args = [];
|
|
1074
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1075
|
-
args[_i] = arguments[_i];
|
|
1076
|
-
}
|
|
1077
|
-
var returnValue = target.apply(this, args);
|
|
1078
|
-
if (isPromiseLike(returnValue)) {
|
|
1079
|
-
return returnValue.then(function (v) {
|
|
1080
|
-
return proxyNativeInstance(v, getCtor());
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
return proxyNativeInstance(returnValue, getCtor());
|
|
1084
|
-
};
|
|
1085
|
-
};
|
|
1086
|
-
};
|
|
1087
|
-
var NativeMember = function (_a) {
|
|
1088
|
-
var _b = {} , cache = _b.cache, readonly = _b.readonly;
|
|
1089
|
-
return function (_, ctx) {
|
|
1090
|
-
ctx.addInitializer(function () {
|
|
1091
|
-
var _this = this;
|
|
1092
|
-
var field = ctx.name;
|
|
1093
|
-
var key = Symbol.for(ctx.name);
|
|
1094
|
-
Object.defineProperty(this, field, {
|
|
1095
|
-
get: function () {
|
|
1096
|
-
if (cache && _this[key] !== undefined) {
|
|
1097
|
-
return _this[key];
|
|
1098
|
-
}
|
|
1099
|
-
var _a = _this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1100
|
-
var ret = getMessageClient(_this).sendInstanceGet(instanceId, namespace || '', field);
|
|
1101
|
-
var value = assertReturn(ret);
|
|
1102
|
-
_this[key] = value;
|
|
1103
|
-
return value;
|
|
1104
|
-
},
|
|
1105
|
-
set: function (v) {
|
|
1106
|
-
if (readonly) {
|
|
1107
|
-
throw new Error("field ".concat(field, " is readonly."));
|
|
1108
|
-
}
|
|
1109
|
-
_this[key] = v;
|
|
1110
|
-
var _a = _this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1111
|
-
getMessageClient(_this).sendInstanceSet(instanceId, namespace || '', field, v);
|
|
1112
|
-
},
|
|
1113
|
-
});
|
|
1114
|
-
});
|
|
1115
|
-
return _;
|
|
1116
|
-
};
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
var key = Symbol.for('args');
|
|
1120
|
-
function NativeArgType(argIndex, type) {
|
|
1121
|
-
return function (method, ctx) {
|
|
1122
|
-
var _a;
|
|
1123
|
-
var args = ((_a = method[key]) !== null && _a !== void 0 ? _a : (method[key] = []));
|
|
1124
|
-
args[argIndex] = type;
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
function processArg(method) {
|
|
1128
|
-
var _a;
|
|
1129
|
-
var args = (_a = method[key]) !== null && _a !== void 0 ? _a : [];
|
|
1130
|
-
return function (arg, idx) {
|
|
1131
|
-
var _a, _b;
|
|
1132
|
-
return (_b = (_a = args[idx]) === null || _a === void 0 ? void 0 : _a.transform(arg)) !== null && _b !== void 0 ? _b : arg;
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
var NativeMethod = function (methodSelector, opt) {
|
|
1136
|
-
return function (_, ctx) {
|
|
1137
|
-
var name = ctx.name;
|
|
1138
|
-
function impl() {
|
|
1139
|
-
var args = [];
|
|
1140
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1141
|
-
args[_i] = arguments[_i];
|
|
1142
|
-
}
|
|
1143
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1144
|
-
var _a, instanceId, namespace, returnValue, data;
|
|
1145
|
-
return __generator$1(this, function (_b) {
|
|
1146
|
-
switch (_b.label) {
|
|
1147
|
-
case 0:
|
|
1148
|
-
_a = this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1149
|
-
return [4 /*yield*/, getMessageClient(this).sendInstanceCall(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(function (v) { return v !== undefined; }), opt)];
|
|
1150
|
-
case 1:
|
|
1151
|
-
returnValue = _b.sent();
|
|
1152
|
-
data = assertReturn(returnValue);
|
|
1153
|
-
return [2 /*return*/, data];
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
return impl;
|
|
1159
|
-
};
|
|
1160
|
-
};
|
|
1161
|
-
var NativeMethodSync = function (methodSelector, opt) {
|
|
1162
|
-
return function (_, ctx) {
|
|
1163
|
-
var name = ctx.name;
|
|
1164
|
-
function impl() {
|
|
1165
|
-
var args = [];
|
|
1166
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1167
|
-
args[_i] = arguments[_i];
|
|
1168
|
-
}
|
|
1169
|
-
var _a = this, instanceId = _a.instanceId, namespace = _a.namespace;
|
|
1170
|
-
var returnValue = getMessageClient(this).sendInstanceCallSync(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(function (v) { return v !== undefined; }), opt);
|
|
1171
|
-
var data = assertReturn(returnValue);
|
|
1172
|
-
return data;
|
|
1173
|
-
}
|
|
1174
|
-
return impl;
|
|
1175
|
-
};
|
|
1176
|
-
};
|
|
1177
|
-
|
|
1178
|
-
var NativeVar = function (varName, ctor) {
|
|
1179
|
-
return function (_, ctx) {
|
|
1180
|
-
return function impl() {
|
|
1181
|
-
var args = [];
|
|
1182
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1183
|
-
args[_i] = arguments[_i];
|
|
1184
|
-
}
|
|
1185
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
1186
|
-
var client, ret, ins;
|
|
1187
|
-
return __generator$1(this, function (_a) {
|
|
1188
|
-
switch (_a.label) {
|
|
1189
|
-
case 0:
|
|
1190
|
-
client = getMessageClient(this);
|
|
1191
|
-
return [4 /*yield*/, client.sendVarGet(varName, args)];
|
|
1192
|
-
case 1:
|
|
1193
|
-
ret = _a.sent();
|
|
1194
|
-
ins = new ctor(DISABLE_INIT);
|
|
1195
|
-
ins.instanceId = ret.msg._instanceId;
|
|
1196
|
-
ins.messageClient = client;
|
|
1197
|
-
ins.namespace = '$var';
|
|
1198
|
-
return [2 /*return*/, ins];
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
});
|
|
1202
|
-
};
|
|
1203
|
-
};
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
(function () {
|
|
1207
|
-
var _a;
|
|
1208
|
-
var _instanceExtraInitializers = [];
|
|
1209
|
-
var _on_decorators;
|
|
1210
|
-
var _emit_decorators;
|
|
1211
|
-
return _a = /** @class */ (function () {
|
|
1212
|
-
function NativeObserver(className) {
|
|
1213
|
-
this._events = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1214
|
-
this.namespace = className;
|
|
1215
|
-
this.instanceId = getUuid(className);
|
|
1216
|
-
this.messageClient = getGlobalMessageClient();
|
|
1217
|
-
this._events = {};
|
|
1218
|
-
}
|
|
1219
|
-
NativeObserver.prototype.on = function (ev, handler) {
|
|
1220
|
-
var handlers = this._events[ev];
|
|
1221
|
-
if (!handlers) {
|
|
1222
|
-
handlers = [];
|
|
1223
|
-
this._events[ev] = handlers;
|
|
1224
|
-
}
|
|
1225
|
-
if (handlers.length === 0) {
|
|
1226
|
-
// 第一次,通知 native 注册
|
|
1227
|
-
this.messageClient.sendInstanceEventAdd(this.instanceId, this.namespace || '', ev);
|
|
1228
|
-
}
|
|
1229
|
-
handlers.push(handler);
|
|
1230
|
-
};
|
|
1231
|
-
NativeObserver.prototype.emit = function (ev) {
|
|
1232
|
-
var args = [];
|
|
1233
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1234
|
-
args[_i - 1] = arguments[_i];
|
|
1235
|
-
}
|
|
1236
|
-
var handlers = this._events[ev];
|
|
1237
|
-
// console.log('emit:', ev, args.length);
|
|
1238
|
-
handlers === null || handlers === void 0 ? void 0 : handlers.forEach(function (cb) {
|
|
1239
|
-
cb.apply(void 0, args);
|
|
1240
|
-
});
|
|
1241
|
-
};
|
|
1242
|
-
return NativeObserver;
|
|
1243
|
-
}()),
|
|
1244
|
-
(function () {
|
|
1245
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1246
|
-
_on_decorators = [Bind];
|
|
1247
|
-
_emit_decorators = [Bind];
|
|
1248
|
-
__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);
|
|
1249
|
-
__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);
|
|
1250
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1251
|
-
})(),
|
|
1252
|
-
_a;
|
|
1253
|
-
})();
|
|
1254
|
-
(function () {
|
|
1255
|
-
var _a;
|
|
1256
|
-
var _instanceExtraInitializers = [];
|
|
1257
|
-
var _on_decorators;
|
|
1258
|
-
var _emit_decorators;
|
|
1259
|
-
return _a = /** @class */ (function () {
|
|
1260
|
-
function NativeObserverProxy() {
|
|
1261
|
-
this.__observer = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1262
|
-
}
|
|
1263
|
-
NativeObserverProxy.prototype.on = function (ev, handler) {
|
|
1264
|
-
this.__observer.on(ev, handler);
|
|
1265
|
-
};
|
|
1266
|
-
NativeObserverProxy.prototype.emit = function (ev) {
|
|
1267
|
-
var _b;
|
|
1268
|
-
var args = [];
|
|
1269
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1270
|
-
args[_i - 1] = arguments[_i];
|
|
1271
|
-
}
|
|
1272
|
-
(_b = this.__observer).emit.apply(_b, __spreadArray$1([ev], args, false));
|
|
1273
|
-
};
|
|
1274
|
-
return NativeObserverProxy;
|
|
1275
|
-
}()),
|
|
1276
|
-
(function () {
|
|
1277
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1278
|
-
_on_decorators = [Bind];
|
|
1279
|
-
_emit_decorators = [Bind];
|
|
1280
|
-
__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);
|
|
1281
|
-
__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);
|
|
1282
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1283
|
-
})(),
|
|
1284
|
-
_a;
|
|
1285
|
-
})();
|
|
1286
|
-
|
|
1287
|
-
var NativeView = /** @class */ (function () {
|
|
1288
|
-
function NativeView(viewId) {
|
|
1289
|
-
this.viewId = viewId;
|
|
1290
|
-
initViewProxyObject(this, viewId);
|
|
1291
|
-
}
|
|
1292
|
-
NativeView.getView = function (viewId, ctor) {
|
|
1293
|
-
var _ins = new ctor(viewId);
|
|
1294
|
-
var ins = initViewProxyObject(_ins, viewId);
|
|
1295
|
-
return ins;
|
|
1296
|
-
};
|
|
1297
|
-
return NativeView;
|
|
1298
|
-
}());
|
|
1299
|
-
function initViewProxyObject(obj, viewId) {
|
|
1300
|
-
obj.instanceId = obj._instanceId = viewId;
|
|
1301
|
-
obj.namespace = obj._serviceName = '$View';
|
|
1302
|
-
obj._type = "instance" /* ARG_TYPE.INSTANCE */;
|
|
1303
|
-
return obj;
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
var NativeImageResource = {
|
|
1307
|
-
transform: function (origin) {
|
|
1308
|
-
var r = __assign$1({}, resolveImageResource(origin));
|
|
1309
|
-
return r;
|
|
1310
|
-
},
|
|
1311
|
-
};
|
|
1312
|
-
// ios
|
|
1313
|
-
var UIImage = NativeImageResource;
|
|
1314
|
-
// android
|
|
1315
|
-
var Bitmap = NativeImageResource;
|
|
1316
|
-
|
|
1317
|
-
var nativeType = /*#__PURE__*/Object.freeze({
|
|
1318
|
-
__proto__: null,
|
|
1319
|
-
Bitmap: Bitmap,
|
|
1320
|
-
NativeImageResource: NativeImageResource,
|
|
1321
|
-
UIImage: UIImage
|
|
1322
|
-
});
|
|
1323
|
-
|
|
1324
|
-
var NativeInstanceManager$1 = function () {
|
|
1325
|
-
var _classDecorators = [NativeClass('com.volcengine.VolcApiEngine.runtime.ProtoImpl')];
|
|
1326
|
-
var _classDescriptor;
|
|
1327
|
-
var _classExtraInitializers = [];
|
|
1328
|
-
var _classThis;
|
|
1329
|
-
var _staticExtraInitializers = [];
|
|
1330
|
-
var _static_isInstanceDestroyed_decorators;
|
|
1331
|
-
_classThis = /** @class */ (function () {
|
|
1332
|
-
function NativeInstanceManager_1() {
|
|
1333
|
-
}
|
|
1334
|
-
NativeInstanceManager_1.isInstanceDestroyed = function (instanceId) {
|
|
1335
|
-
throw new Error('not implemented');
|
|
1336
|
-
};
|
|
1337
|
-
return NativeInstanceManager_1;
|
|
1338
|
-
}());
|
|
1339
|
-
__setFunctionName$1(_classThis, "NativeInstanceManager");
|
|
1340
|
-
(function () {
|
|
1341
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1342
|
-
_static_isInstanceDestroyed_decorators = [NativeStaticMethodSync()];
|
|
1343
|
-
__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);
|
|
1344
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1345
|
-
_classThis = _classDescriptor.value;
|
|
1346
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1347
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1348
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1349
|
-
})();
|
|
1350
|
-
return _classThis;
|
|
1351
|
-
}();
|
|
1352
|
-
|
|
1353
|
-
var NativeLoggerManager$1 = function () {
|
|
1354
|
-
var _classDecorators = [NativeClass('com.volcengine.VolcApiEngine.logger.VolcLogger')];
|
|
1355
|
-
var _classDescriptor;
|
|
1356
|
-
var _classExtraInitializers = [];
|
|
1357
|
-
var _classThis;
|
|
1358
|
-
var _staticExtraInitializers = [];
|
|
1359
|
-
var _static_setLogLevel_decorators;
|
|
1360
|
-
_classThis = /** @class */ (function () {
|
|
1361
|
-
function NativeLoggerManager_1() {
|
|
1362
|
-
}
|
|
1363
|
-
NativeLoggerManager_1.setLogLevel = function (instanceId) {
|
|
1364
|
-
throw new Error('not implemented');
|
|
1365
|
-
};
|
|
1366
|
-
return NativeLoggerManager_1;
|
|
1367
|
-
}());
|
|
1368
|
-
__setFunctionName$1(_classThis, "NativeLoggerManager");
|
|
1369
|
-
(function () {
|
|
1370
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1371
|
-
_static_setLogLevel_decorators = [NativeStaticMethod()];
|
|
1372
|
-
__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);
|
|
1373
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1374
|
-
_classThis = _classDescriptor.value;
|
|
1375
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1376
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1377
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1378
|
-
})();
|
|
1379
|
-
return _classThis;
|
|
1380
|
-
}();
|
|
1381
|
-
|
|
1382
|
-
var NativeInstanceManager = function () {
|
|
1383
|
-
var _classDecorators = [NativeClass('ApiEngineProtocol')];
|
|
1384
|
-
var _classDescriptor;
|
|
1385
|
-
var _classExtraInitializers = [];
|
|
1386
|
-
var _classThis;
|
|
1387
|
-
var _staticExtraInitializers = [];
|
|
1388
|
-
var _static_isInstanceDestroyed_decorators;
|
|
1389
|
-
_classThis = /** @class */ (function () {
|
|
1390
|
-
function NativeInstanceManager_1() {
|
|
1391
|
-
}
|
|
1392
|
-
NativeInstanceManager_1.isInstanceDestroyed = function (instanceId) {
|
|
1393
|
-
throw new Error('not implemented');
|
|
1394
|
-
};
|
|
1395
|
-
return NativeInstanceManager_1;
|
|
1396
|
-
}());
|
|
1397
|
-
__setFunctionName$1(_classThis, "NativeInstanceManager");
|
|
1398
|
-
(function () {
|
|
1399
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1400
|
-
_static_isInstanceDestroyed_decorators = [NativeStaticMethodSync('isInstanceDestroyed:')];
|
|
1401
|
-
__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);
|
|
1402
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1403
|
-
_classThis = _classDescriptor.value;
|
|
1404
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1405
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1406
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1407
|
-
})();
|
|
1408
|
-
return _classThis;
|
|
1409
|
-
}();
|
|
1410
|
-
|
|
1411
|
-
var NativeLoggerManager = function () {
|
|
1412
|
-
var _classDecorators = [NativeClass('VolcLogger')];
|
|
1413
|
-
var _classDescriptor;
|
|
1414
|
-
var _classExtraInitializers = [];
|
|
1415
|
-
var _classThis;
|
|
1416
|
-
var _staticExtraInitializers = [];
|
|
1417
|
-
var _static_setLogLevel_decorators;
|
|
1418
|
-
_classThis = /** @class */ (function () {
|
|
1419
|
-
function NativeLoggerManager_1() {
|
|
1420
|
-
}
|
|
1421
|
-
NativeLoggerManager_1.setLogLevel = function (level) {
|
|
1422
|
-
throw new Error('not implemented');
|
|
1423
|
-
};
|
|
1424
|
-
return NativeLoggerManager_1;
|
|
1425
|
-
}());
|
|
1426
|
-
__setFunctionName$1(_classThis, "NativeLoggerManager");
|
|
1427
|
-
(function () {
|
|
1428
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1429
|
-
_static_setLogLevel_decorators = [NativeStaticMethod('setLogLevel:')];
|
|
1430
|
-
__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);
|
|
1431
|
-
__esDecorate$1(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1432
|
-
_classThis = _classDescriptor.value;
|
|
1433
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1434
|
-
__runInitializers$1(_classThis, _staticExtraInitializers);
|
|
1435
|
-
__runInitializers$1(_classThis, _classExtraInitializers);
|
|
1436
|
-
})();
|
|
1437
|
-
return _classThis;
|
|
1438
|
-
}();
|
|
1439
|
-
|
|
1440
|
-
/** @class */ ((function () {
|
|
1441
|
-
function InstanceManager() {
|
|
1442
|
-
}
|
|
1443
|
-
InstanceManager.isInstanceDestroyed = function (instanceOrId) {
|
|
1444
|
-
var instanceId = resolveInstance(instanceOrId);
|
|
1445
|
-
this.logger.debug('[instance-manager] isInstanceDestroyed', instanceId);
|
|
1446
|
-
if (getOS() === 'android') {
|
|
1447
|
-
return NativeInstanceManager$1.isInstanceDestroyed(instanceId);
|
|
1448
|
-
}
|
|
1449
|
-
else if (getOS() === 'ios') {
|
|
1450
|
-
return NativeInstanceManager.isInstanceDestroyed(instanceId);
|
|
1451
|
-
}
|
|
1452
|
-
throw new Error('not implemented');
|
|
1453
|
-
};
|
|
1454
|
-
InstanceManager.logger = LoggerImpl.getInstance();
|
|
1455
|
-
return InstanceManager;
|
|
1456
|
-
})());
|
|
1457
|
-
|
|
1458
|
-
var LoggerManager = /** @class */ (function () {
|
|
1459
|
-
function LoggerManager() {
|
|
1460
|
-
}
|
|
1461
|
-
LoggerManager.setLogLevel = function (level) {
|
|
1462
|
-
this.logger.setLogLevel(level);
|
|
1463
|
-
this.logger.debug('[logger-manager] setLogLevel', LogLevel[level]);
|
|
1464
|
-
if (getOS() === 'android') {
|
|
1465
|
-
NativeLoggerManager$1.setLogLevel(level);
|
|
1466
|
-
}
|
|
1467
|
-
else if (getOS() === 'ios') {
|
|
1468
|
-
NativeLoggerManager.setLogLevel(level);
|
|
1469
|
-
}
|
|
1470
|
-
else {
|
|
1471
|
-
throw new Error('env has not been set');
|
|
1472
|
-
}
|
|
1473
|
-
};
|
|
1474
|
-
LoggerManager.logger = LoggerImpl.getInstance();
|
|
1475
|
-
return LoggerManager;
|
|
1476
|
-
}());
|
|
1477
|
-
|
|
1478
|
-
var logger = LoggerImpl.getInstance();
|
|
658
|
+
const logger = new LoggerImpl();
|
|
1479
659
|
function setupLogger(opt) {
|
|
1480
|
-
|
|
1481
|
-
LoggerManager.setLogLevel(opt.level);
|
|
1482
|
-
}
|
|
1483
|
-
if (opt.customer !== undefined) {
|
|
1484
|
-
logger.registerConsumer(opt.customer);
|
|
1485
|
-
}
|
|
660
|
+
logger.registerConsumer(opt.customer);
|
|
1486
661
|
}
|
|
1487
662
|
|
|
1488
|
-
|
|
1489
|
-
|
|
663
|
+
class ApiCallSpan {
|
|
664
|
+
constructor(tracer, action) {
|
|
1490
665
|
this.tracer = tracer;
|
|
1491
666
|
this.action = action;
|
|
1492
667
|
this.startTimestamp = Date.now();
|
|
1493
668
|
this.status = 'unknown';
|
|
1494
|
-
|
|
669
|
+
const record = {
|
|
1495
670
|
ts: Date.now(),
|
|
1496
671
|
type: 'call',
|
|
1497
672
|
data: action,
|
|
1498
673
|
traceId: action.traceId,
|
|
1499
674
|
};
|
|
1500
|
-
|
|
675
|
+
const msg = `<TO ${action.target}> ${action.callType} call:${action.serviceName || ''}.${action.methodName || action.memberName || ''} args=${safeStringify(action.args)}`;
|
|
1501
676
|
this.tracer.report(record, msg, {
|
|
1502
677
|
serviceName: action.serviceName,
|
|
1503
678
|
});
|
|
1504
679
|
}
|
|
1505
|
-
|
|
680
|
+
setReturnValue(value) {
|
|
1506
681
|
this.action.return = value;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
682
|
+
}
|
|
683
|
+
success(value) {
|
|
1509
684
|
this.setReturnValue(value);
|
|
1510
685
|
this.status = 'success';
|
|
1511
686
|
this.finish();
|
|
1512
|
-
}
|
|
1513
|
-
|
|
687
|
+
}
|
|
688
|
+
fail(error) {
|
|
1514
689
|
this.setReturnValue(error);
|
|
1515
690
|
this.status = 'fail';
|
|
1516
691
|
this.finish();
|
|
1517
|
-
}
|
|
1518
|
-
|
|
692
|
+
}
|
|
693
|
+
finish() {
|
|
1519
694
|
this.endTimestamp = Date.now();
|
|
1520
695
|
this._report();
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
var action = this.action;
|
|
1526
|
-
var record = {
|
|
696
|
+
}
|
|
697
|
+
_report() {
|
|
698
|
+
const { action } = this;
|
|
699
|
+
const record = {
|
|
1527
700
|
ts: Date.now(),
|
|
1528
701
|
type: 'call',
|
|
1529
702
|
data: action,
|
|
1530
703
|
traceId: this.action.traceId,
|
|
1531
704
|
};
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
this.tracer.report(record, msg,
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
var Tracer = /** @class */ (function () {
|
|
1549
|
-
function Tracer() {
|
|
1550
|
-
this._logger = LoggerImpl.getInstance();
|
|
705
|
+
const msg = `<${action.target} Return> ${action.callType} call:${action.serviceName}.${action.methodName || action.memberName || ''} args=${safeStringify(action.args)} return=${safeStringify(action.return)}`;
|
|
706
|
+
const cost = this.endTimestamp - this.startTimestamp;
|
|
707
|
+
this.tracer.report(record, msg, {
|
|
708
|
+
level: this.status === 'fail' ||
|
|
709
|
+
this.action.return?.status === 'failed'
|
|
710
|
+
? 'warn'
|
|
711
|
+
: 'debug',
|
|
712
|
+
serviceName: action.serviceName,
|
|
713
|
+
cost,
|
|
714
|
+
status: this.status,
|
|
715
|
+
[this.status]: '1',
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
class Tracer {
|
|
720
|
+
constructor() {
|
|
1551
721
|
this._consumers = [];
|
|
1552
722
|
}
|
|
1553
|
-
|
|
723
|
+
registerConsumer(consumer) {
|
|
1554
724
|
this._consumers.push(consumer);
|
|
1555
|
-
}
|
|
1556
|
-
|
|
725
|
+
}
|
|
726
|
+
init(opt) {
|
|
1557
727
|
this.options = opt;
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
|
|
728
|
+
}
|
|
729
|
+
collectApiCall(action) {
|
|
730
|
+
const span = new ApiCallSpan(this, action);
|
|
1561
731
|
return span;
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
|
|
732
|
+
}
|
|
733
|
+
collectEventEmit(action) {
|
|
734
|
+
const record = {
|
|
1565
735
|
ts: Date.now(),
|
|
1566
736
|
type: 'event_emit',
|
|
1567
737
|
data: action,
|
|
1568
738
|
};
|
|
1569
|
-
|
|
1570
|
-
|
|
739
|
+
const { eventName, eventData } = action;
|
|
740
|
+
const msg = `<TO ${action.target}> emit:${eventName} event=${safeStringify(eventData)}`;
|
|
1571
741
|
this.report(record, msg, {
|
|
1572
742
|
callType: 'event_emit',
|
|
1573
743
|
eventName: eventName,
|
|
1574
744
|
});
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
|
|
745
|
+
}
|
|
746
|
+
collectEventEmitResult(action) {
|
|
747
|
+
const record = {
|
|
1578
748
|
ts: Date.now(),
|
|
1579
749
|
type: 'event_emit_result',
|
|
1580
750
|
data: action,
|
|
1581
751
|
};
|
|
1582
|
-
|
|
1583
|
-
|
|
752
|
+
const { eventName, eventData } = action;
|
|
753
|
+
const msg = `<TO ${action.target}> emit:${eventName} result=${safeStringify(eventData)}`;
|
|
1584
754
|
this.report(record, msg, {
|
|
1585
755
|
callType: 'event_emit_result',
|
|
1586
756
|
eventName: eventName,
|
|
1587
757
|
});
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
758
|
+
}
|
|
759
|
+
collectEventOn(action) {
|
|
760
|
+
const record = {
|
|
1591
761
|
ts: Date.now(),
|
|
1592
762
|
type: 'event_on',
|
|
1593
763
|
data: action,
|
|
1594
764
|
};
|
|
1595
|
-
|
|
1596
|
-
|
|
765
|
+
const { eventName } = action;
|
|
766
|
+
const msg = `<TO ${action.target}> on:${eventName}`;
|
|
1597
767
|
this.report(record, msg, {
|
|
1598
768
|
callType: 'event_on',
|
|
1599
|
-
eventName
|
|
769
|
+
eventName,
|
|
1600
770
|
});
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
|
|
771
|
+
}
|
|
772
|
+
collectEventOff(action) {
|
|
773
|
+
const record = {
|
|
1604
774
|
ts: Date.now(),
|
|
1605
775
|
type: 'event_off',
|
|
1606
776
|
data: action,
|
|
1607
777
|
};
|
|
1608
|
-
|
|
1609
|
-
|
|
778
|
+
const { eventName } = action;
|
|
779
|
+
const msg = `<TO ${action.target}> off:${eventName}`;
|
|
1610
780
|
this.report(record, msg, {
|
|
1611
781
|
callType: 'event_off',
|
|
1612
|
-
eventName
|
|
782
|
+
eventName,
|
|
1613
783
|
});
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
|
|
784
|
+
}
|
|
785
|
+
collectCallbackEmit(action) {
|
|
786
|
+
const record = {
|
|
1617
787
|
ts: Date.now(),
|
|
1618
788
|
type: 'callback_emit',
|
|
1619
789
|
data: action,
|
|
1620
790
|
};
|
|
1621
|
-
|
|
1622
|
-
|
|
791
|
+
const { eventName, eventData } = action;
|
|
792
|
+
const msg = `<TO ${action.target}> emit callback:${eventName} event=${safeStringify(eventData)}`;
|
|
1623
793
|
this.report(record, msg, {
|
|
1624
794
|
callType: 'callback_emit',
|
|
1625
795
|
eventName: eventName,
|
|
1626
796
|
});
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
switch (_a.label) {
|
|
1633
|
-
case 0:
|
|
1634
|
-
_a.trys.push([0, 2, , 3]);
|
|
1635
|
-
return [4 /*yield*/, c(record, msg, extra)];
|
|
1636
|
-
case 1:
|
|
1637
|
-
_a.sent();
|
|
1638
|
-
return [3 /*break*/, 3];
|
|
1639
|
-
case 2:
|
|
1640
|
-
_a.sent();
|
|
1641
|
-
return [3 /*break*/, 3];
|
|
1642
|
-
case 3: return [2 /*return*/];
|
|
1643
|
-
}
|
|
1644
|
-
});
|
|
1645
|
-
}); });
|
|
1646
|
-
try {
|
|
1647
|
-
var level = extra.level || 'info';
|
|
1648
|
-
if (level === 'warn') {
|
|
1649
|
-
this._logger.warn("[Trace] ".concat(msg));
|
|
797
|
+
}
|
|
798
|
+
report(record, msg, extra) {
|
|
799
|
+
this._consumers.forEach(async (c) => {
|
|
800
|
+
try {
|
|
801
|
+
await c(record, msg, extra);
|
|
1650
802
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
803
|
+
catch (ignore) {
|
|
804
|
+
//
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
try {
|
|
808
|
+
const level = extra.level || 'info';
|
|
809
|
+
if (level === 'warn' || level === 'error') {
|
|
810
|
+
console.warn(`[Trace] ${level} `, msg);
|
|
1653
811
|
}
|
|
1654
812
|
else if (false) ;
|
|
1655
813
|
}
|
|
1656
814
|
catch (err) {
|
|
1657
815
|
//
|
|
1658
816
|
}
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
|
-
}());
|
|
817
|
+
}
|
|
818
|
+
}
|
|
1662
819
|
|
|
1663
|
-
|
|
820
|
+
const globalTracer = new Tracer();
|
|
1664
821
|
|
|
1665
|
-
|
|
822
|
+
let MessageSenderImpl = (() => {
|
|
1666
823
|
var _a;
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
function MessageSenderImpl(proto, bridge) {
|
|
824
|
+
let _instanceExtraInitializers = [];
|
|
825
|
+
let _sendVarGet_decorators;
|
|
826
|
+
let _sendStaticCall_decorators;
|
|
827
|
+
let _sendStaticCallSync_decorators;
|
|
828
|
+
let _sendNewInstanceCall_decorators;
|
|
829
|
+
let _sendInstanceCall_decorators;
|
|
830
|
+
let _sendInstanceCallSync_decorators;
|
|
831
|
+
let _sendInstanceSet_decorators;
|
|
832
|
+
let _sendInstanceGet_decorators;
|
|
833
|
+
let _sendInstanceEventAdd_decorators;
|
|
834
|
+
let _sendInstanceEventRemove_decorators;
|
|
835
|
+
let _sendEventEmit_decorators;
|
|
836
|
+
let _sendEventEmitResult_decorators;
|
|
837
|
+
return _a = class MessageSenderImpl {
|
|
838
|
+
constructor(proto, bridge) {
|
|
1683
839
|
this.proto = (__runInitializers$1(this, _instanceExtraInitializers), proto);
|
|
1684
840
|
this.bridge = bridge;
|
|
1685
|
-
this.logger =
|
|
841
|
+
this.logger = logger;
|
|
1686
842
|
this.tracer = globalTracer;
|
|
1687
843
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
serviceName: '$var',
|
|
1707
|
-
memberName: varName,
|
|
1708
|
-
args: encodeArgs,
|
|
1709
|
-
traceId: traceId,
|
|
1710
|
-
callType: params.callType,
|
|
1711
|
-
});
|
|
1712
|
-
_b.label = 1;
|
|
1713
|
-
case 1:
|
|
1714
|
-
_b.trys.push([1, 3, , 4]);
|
|
1715
|
-
return [4 /*yield*/, this._send(params)];
|
|
1716
|
-
case 2:
|
|
1717
|
-
res = _b.sent();
|
|
1718
|
-
span.success(res);
|
|
1719
|
-
return [2 /*return*/, res];
|
|
1720
|
-
case 3:
|
|
1721
|
-
err_1 = _b.sent();
|
|
1722
|
-
span.fail(err_1);
|
|
1723
|
-
throw err_1;
|
|
1724
|
-
case 4: return [2 /*return*/];
|
|
1725
|
-
}
|
|
1726
|
-
});
|
|
844
|
+
async sendVarGet(varName, args) {
|
|
845
|
+
const traceId = getUuid('trace');
|
|
846
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
847
|
+
const params = {
|
|
848
|
+
serviceName: varName,
|
|
849
|
+
memberName: varName,
|
|
850
|
+
args: encodeArgs,
|
|
851
|
+
callType: CALL_TYPE$1.VAR_GETTER,
|
|
852
|
+
_traceId: traceId,
|
|
853
|
+
};
|
|
854
|
+
const span = this.tracer.collectApiCall({
|
|
855
|
+
source: 'js',
|
|
856
|
+
target: 'native',
|
|
857
|
+
serviceName: '$var',
|
|
858
|
+
memberName: varName,
|
|
859
|
+
args: encodeArgs,
|
|
860
|
+
traceId,
|
|
861
|
+
callType: params.callType,
|
|
1727
862
|
});
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
_b.trys.push([1, 3, , 4]);
|
|
1757
|
-
return [4 /*yield*/, this._send(params)];
|
|
1758
|
-
case 2:
|
|
1759
|
-
res = _b.sent();
|
|
1760
|
-
span.success(res);
|
|
1761
|
-
return [2 /*return*/, res];
|
|
1762
|
-
case 3:
|
|
1763
|
-
err_2 = _b.sent();
|
|
1764
|
-
span.fail(err_2);
|
|
1765
|
-
throw err_2;
|
|
1766
|
-
case 4: return [2 /*return*/];
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
863
|
+
try {
|
|
864
|
+
const res = await this._send(params);
|
|
865
|
+
span.success(res);
|
|
866
|
+
return res;
|
|
867
|
+
}
|
|
868
|
+
catch (err) {
|
|
869
|
+
span.fail(err);
|
|
870
|
+
throw err;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async sendStaticCall(serviceName, methodName, args) {
|
|
874
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
875
|
+
const traceId = getUuid('trace');
|
|
876
|
+
const params = {
|
|
877
|
+
serviceName,
|
|
878
|
+
methodName,
|
|
879
|
+
args: encodeArgs,
|
|
880
|
+
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
881
|
+
_traceId: traceId,
|
|
882
|
+
};
|
|
883
|
+
const span = this.tracer.collectApiCall({
|
|
884
|
+
source: 'js',
|
|
885
|
+
target: 'native',
|
|
886
|
+
serviceName,
|
|
887
|
+
methodName,
|
|
888
|
+
args,
|
|
889
|
+
traceId,
|
|
890
|
+
callType: params.callType,
|
|
1769
891
|
});
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
892
|
+
try {
|
|
893
|
+
const res = await this._send(params);
|
|
894
|
+
span.success(res);
|
|
895
|
+
return res;
|
|
896
|
+
}
|
|
897
|
+
catch (err) {
|
|
898
|
+
span.fail(err);
|
|
899
|
+
throw err;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
sendStaticCallSync(serviceName, methodName, args) {
|
|
903
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
904
|
+
const traceId = getUuid('trace');
|
|
905
|
+
const params = {
|
|
906
|
+
serviceName,
|
|
907
|
+
methodName,
|
|
1777
908
|
args: encodeArgs,
|
|
1778
909
|
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
1779
910
|
_traceId: traceId,
|
|
1780
|
-
runOnMainThread: true,
|
|
1781
911
|
};
|
|
1782
|
-
|
|
912
|
+
const span = this.tracer.collectApiCall({
|
|
1783
913
|
source: 'js',
|
|
1784
914
|
target: 'native',
|
|
1785
|
-
serviceName
|
|
1786
|
-
methodName
|
|
1787
|
-
args
|
|
1788
|
-
traceId
|
|
915
|
+
serviceName,
|
|
916
|
+
methodName,
|
|
917
|
+
args,
|
|
918
|
+
traceId,
|
|
1789
919
|
callType: params.callType,
|
|
1790
920
|
});
|
|
1791
921
|
try {
|
|
1792
|
-
|
|
922
|
+
const res = this._sendSync(params);
|
|
1793
923
|
span.success(res);
|
|
1794
924
|
return res;
|
|
1795
925
|
}
|
|
@@ -1797,30 +927,28 @@ var MessageSenderImpl = function () {
|
|
|
1797
927
|
span.fail(err);
|
|
1798
928
|
throw err;
|
|
1799
929
|
}
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
serviceName
|
|
930
|
+
}
|
|
931
|
+
sendNewInstanceCall(serviceName, args, instanceId, instance) {
|
|
932
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
933
|
+
const traceId = getUuid('trace');
|
|
934
|
+
const params = {
|
|
935
|
+
serviceName,
|
|
1806
936
|
args: encodeArgs,
|
|
1807
937
|
callType: CALL_TYPE$1.NEW_INSTANCE,
|
|
1808
938
|
_instanceId: instanceId,
|
|
1809
|
-
_instanceType: instance.instanceType,
|
|
1810
939
|
_traceId: traceId,
|
|
1811
|
-
runOnMainThread: true,
|
|
1812
940
|
};
|
|
1813
|
-
|
|
941
|
+
const span = this.tracer.collectApiCall({
|
|
1814
942
|
source: 'js',
|
|
1815
943
|
target: 'native',
|
|
1816
|
-
serviceName
|
|
1817
|
-
args
|
|
1818
|
-
traceId
|
|
944
|
+
serviceName,
|
|
945
|
+
args,
|
|
946
|
+
traceId,
|
|
1819
947
|
callType: params.callType,
|
|
1820
948
|
});
|
|
1821
949
|
try {
|
|
1822
950
|
this.proto.registerProxyInstance(instanceId, instance);
|
|
1823
|
-
|
|
951
|
+
const res = this._sendSync(params);
|
|
1824
952
|
span.success(res);
|
|
1825
953
|
return res;
|
|
1826
954
|
}
|
|
@@ -1828,79 +956,63 @@ var MessageSenderImpl = function () {
|
|
|
1828
956
|
span.fail(err);
|
|
1829
957
|
throw err;
|
|
1830
958
|
}
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
var instanceId, encodeArgs, traceId, params, span, res, err_3;
|
|
1835
|
-
if (args === void 0) { args = []; }
|
|
1836
|
-
return __generator$1(this, function (_b) {
|
|
1837
|
-
switch (_b.label) {
|
|
1838
|
-
case 0:
|
|
1839
|
-
instanceId = this._resolveInstanceId(instanceOrId);
|
|
1840
|
-
assert(!!instanceId, 'unknown instance');
|
|
1841
|
-
encodeArgs = this.proto.encodeArgs(args);
|
|
1842
|
-
traceId = getUuid('trace');
|
|
1843
|
-
params = {
|
|
1844
|
-
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1845
|
-
_instanceId: instanceId,
|
|
1846
|
-
serviceName: serviceName,
|
|
1847
|
-
methodName: methodName,
|
|
1848
|
-
args: encodeArgs,
|
|
1849
|
-
_traceId: traceId,
|
|
1850
|
-
runOnMainThread: true,
|
|
1851
|
-
};
|
|
1852
|
-
span = this.tracer.collectApiCall({
|
|
1853
|
-
source: 'js',
|
|
1854
|
-
target: 'native',
|
|
1855
|
-
serviceName: serviceName,
|
|
1856
|
-
methodName: methodName,
|
|
1857
|
-
args: args,
|
|
1858
|
-
traceId: traceId,
|
|
1859
|
-
callType: params.callType,
|
|
1860
|
-
});
|
|
1861
|
-
_b.label = 1;
|
|
1862
|
-
case 1:
|
|
1863
|
-
_b.trys.push([1, 3, , 4]);
|
|
1864
|
-
return [4 /*yield*/, this._send(params)];
|
|
1865
|
-
case 2:
|
|
1866
|
-
res = _b.sent();
|
|
1867
|
-
span.success(res);
|
|
1868
|
-
return [2 /*return*/, res];
|
|
1869
|
-
case 3:
|
|
1870
|
-
err_3 = _b.sent();
|
|
1871
|
-
span.fail(err_3);
|
|
1872
|
-
throw err_3;
|
|
1873
|
-
case 4: return [2 /*return*/];
|
|
1874
|
-
}
|
|
1875
|
-
});
|
|
1876
|
-
});
|
|
1877
|
-
};
|
|
1878
|
-
MessageSenderImpl.prototype.sendInstanceCallSync = function (instanceOrId, serviceName, methodName, args, meta) {
|
|
1879
|
-
if (args === void 0) { args = []; }
|
|
1880
|
-
var instanceId = this._resolveInstanceId(instanceOrId);
|
|
959
|
+
}
|
|
960
|
+
async sendInstanceCall(instanceOrId, serviceName, methodName, args = [], meta) {
|
|
961
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1881
962
|
assert(!!instanceId, 'unknown instance');
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
963
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
964
|
+
const traceId = getUuid('trace');
|
|
965
|
+
const params = {
|
|
1885
966
|
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1886
967
|
_instanceId: instanceId,
|
|
1887
968
|
serviceName: serviceName,
|
|
969
|
+
methodName,
|
|
1888
970
|
args: encodeArgs,
|
|
1889
|
-
methodName: methodName,
|
|
1890
971
|
_traceId: traceId,
|
|
1891
|
-
runOnMainThread: true,
|
|
1892
972
|
};
|
|
1893
|
-
|
|
973
|
+
const span = this.tracer.collectApiCall({
|
|
1894
974
|
source: 'js',
|
|
1895
975
|
target: 'native',
|
|
976
|
+
serviceName,
|
|
977
|
+
methodName,
|
|
978
|
+
args,
|
|
979
|
+
traceId,
|
|
980
|
+
callType: params.callType,
|
|
981
|
+
});
|
|
982
|
+
try {
|
|
983
|
+
const res = await this._send(params);
|
|
984
|
+
span.success(res);
|
|
985
|
+
return res;
|
|
986
|
+
}
|
|
987
|
+
catch (err) {
|
|
988
|
+
span.fail(err);
|
|
989
|
+
throw err;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
sendInstanceCallSync(instanceOrId, serviceName, methodName, args = [], meta) {
|
|
993
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
994
|
+
assert(!!instanceId, 'unknown instance');
|
|
995
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
996
|
+
const traceId = getUuid('trace');
|
|
997
|
+
const params = {
|
|
998
|
+
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
999
|
+
_instanceId: instanceId,
|
|
1896
1000
|
serviceName: serviceName,
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1001
|
+
args: encodeArgs,
|
|
1002
|
+
methodName,
|
|
1003
|
+
_traceId: traceId,
|
|
1004
|
+
};
|
|
1005
|
+
const span = this.tracer.collectApiCall({
|
|
1006
|
+
source: 'js',
|
|
1007
|
+
target: 'native',
|
|
1008
|
+
serviceName,
|
|
1009
|
+
methodName,
|
|
1010
|
+
args,
|
|
1011
|
+
traceId,
|
|
1900
1012
|
callType: params.callType,
|
|
1901
1013
|
});
|
|
1902
1014
|
try {
|
|
1903
|
-
|
|
1015
|
+
const res = this._sendSync(params);
|
|
1904
1016
|
span.success(res);
|
|
1905
1017
|
return res;
|
|
1906
1018
|
}
|
|
@@ -1908,31 +1020,31 @@ var MessageSenderImpl = function () {
|
|
|
1908
1020
|
span.fail(err);
|
|
1909
1021
|
throw err;
|
|
1910
1022
|
}
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1023
|
+
}
|
|
1024
|
+
sendInstanceSet(instanceOrId, serviceName, memberName, value) {
|
|
1025
|
+
const arg = this.proto.encodeArg(value);
|
|
1026
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1915
1027
|
assert(!!instanceId, 'unknown instance');
|
|
1916
|
-
|
|
1917
|
-
|
|
1028
|
+
const traceId = getUuid('trace');
|
|
1029
|
+
const params = {
|
|
1918
1030
|
callType: CALL_TYPE$1.INSTANCE_MEMBER_SET,
|
|
1919
1031
|
_instanceId: instanceId,
|
|
1920
|
-
serviceName
|
|
1921
|
-
memberName
|
|
1032
|
+
serviceName,
|
|
1033
|
+
memberName,
|
|
1922
1034
|
args: [arg],
|
|
1923
1035
|
_traceId: traceId,
|
|
1924
1036
|
};
|
|
1925
|
-
|
|
1037
|
+
const span = this.tracer.collectApiCall({
|
|
1926
1038
|
source: 'js',
|
|
1927
1039
|
target: 'native',
|
|
1928
1040
|
serviceName: memberName,
|
|
1929
|
-
memberName
|
|
1041
|
+
memberName,
|
|
1930
1042
|
args: [arg],
|
|
1931
|
-
traceId
|
|
1043
|
+
traceId,
|
|
1932
1044
|
callType: params.callType,
|
|
1933
1045
|
});
|
|
1934
1046
|
try {
|
|
1935
|
-
|
|
1047
|
+
const res = this._sendSync(params);
|
|
1936
1048
|
span.success(res);
|
|
1937
1049
|
return res;
|
|
1938
1050
|
}
|
|
@@ -1940,30 +1052,30 @@ var MessageSenderImpl = function () {
|
|
|
1940
1052
|
span.fail(err);
|
|
1941
1053
|
throw err;
|
|
1942
1054
|
}
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1055
|
+
}
|
|
1056
|
+
sendInstanceGet(instanceOrId, serviceName, memberName) {
|
|
1057
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1946
1058
|
assert(!!instanceId, 'unknown instance');
|
|
1947
|
-
|
|
1948
|
-
|
|
1059
|
+
const traceId = getUuid('trace');
|
|
1060
|
+
const params = {
|
|
1949
1061
|
callType: CALL_TYPE$1.INSTANCE_MEMBER_GET,
|
|
1950
1062
|
_instanceId: instanceId,
|
|
1951
|
-
serviceName
|
|
1952
|
-
memberName
|
|
1063
|
+
serviceName,
|
|
1064
|
+
memberName,
|
|
1953
1065
|
args: [],
|
|
1954
1066
|
_traceId: traceId,
|
|
1955
1067
|
};
|
|
1956
|
-
|
|
1068
|
+
const span = this.tracer.collectApiCall({
|
|
1957
1069
|
source: 'js',
|
|
1958
1070
|
target: 'native',
|
|
1959
1071
|
serviceName: memberName,
|
|
1960
|
-
memberName
|
|
1072
|
+
memberName,
|
|
1961
1073
|
args: [],
|
|
1962
|
-
traceId
|
|
1074
|
+
traceId,
|
|
1963
1075
|
callType: params.callType,
|
|
1964
1076
|
});
|
|
1965
1077
|
try {
|
|
1966
|
-
|
|
1078
|
+
const res = this._sendSync(params);
|
|
1967
1079
|
span.success(res);
|
|
1968
1080
|
return res;
|
|
1969
1081
|
}
|
|
@@ -1971,12 +1083,12 @@ var MessageSenderImpl = function () {
|
|
|
1971
1083
|
span.fail(err);
|
|
1972
1084
|
throw err;
|
|
1973
1085
|
}
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1086
|
+
}
|
|
1087
|
+
sendInstanceEventAdd(instanceOrId, serviceName, eventName) {
|
|
1088
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1977
1089
|
assert(!!instanceId, 'unknown instance');
|
|
1978
1090
|
// const encodeCallback = this.proto.encodeCallback(callback);
|
|
1979
|
-
|
|
1091
|
+
const params = {
|
|
1980
1092
|
callType: CALL_TYPE$1.INSTANCE_EVENT_LISTENER_ADD,
|
|
1981
1093
|
_instanceId: instanceId,
|
|
1982
1094
|
serviceName: serviceName,
|
|
@@ -1989,12 +1101,12 @@ var MessageSenderImpl = function () {
|
|
|
1989
1101
|
eventName: serviceName,
|
|
1990
1102
|
});
|
|
1991
1103
|
return this._sendSync(params);
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1104
|
+
}
|
|
1105
|
+
sendInstanceEventRemove(instanceOrId, serviceName, eventName) {
|
|
1106
|
+
const instanceId = this._resolveInstanceId(instanceOrId);
|
|
1995
1107
|
assert(!!instanceId, 'unknown instance');
|
|
1996
1108
|
// const encodeCallback = this.proto.encodeCallback(callback);
|
|
1997
|
-
|
|
1109
|
+
const params = {
|
|
1998
1110
|
callType: CALL_TYPE$1.INSTANCE_EVENT_LISTENER_REMOVE,
|
|
1999
1111
|
_instanceId: instanceId,
|
|
2000
1112
|
serviceName: serviceName,
|
|
@@ -2007,124 +1119,77 @@ var MessageSenderImpl = function () {
|
|
|
2007
1119
|
eventName: serviceName,
|
|
2008
1120
|
});
|
|
2009
1121
|
return this._sendSync(params);
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
callType: CALL_TYPE$1.DESTROY_INSTANCE,
|
|
1122
|
+
}
|
|
1123
|
+
async sendEventEmit(instanceId, serviceName, callbackId, args) {
|
|
1124
|
+
const encodeArgs = this.proto.encodeArgs(args);
|
|
1125
|
+
const params = {
|
|
1126
|
+
callType: CALL_TYPE$1.INSTANCE_EVENT_EMIT,
|
|
2016
1127
|
_instanceId: instanceId,
|
|
2017
1128
|
serviceName: serviceName,
|
|
1129
|
+
args: [
|
|
1130
|
+
{
|
|
1131
|
+
callback_id: callbackId,
|
|
1132
|
+
},
|
|
1133
|
+
...encodeArgs,
|
|
1134
|
+
],
|
|
2018
1135
|
};
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
return __generator$1(this, function (_b) {
|
|
2025
|
-
encodeArgs = this.proto.encodeArgs(args);
|
|
2026
|
-
params = {
|
|
2027
|
-
callType: CALL_TYPE$1.INSTANCE_EVENT_EMIT,
|
|
2028
|
-
_instanceId: instanceId,
|
|
2029
|
-
serviceName: serviceName,
|
|
2030
|
-
args: __spreadArray$1([
|
|
2031
|
-
{
|
|
2032
|
-
callback_id: callbackId,
|
|
2033
|
-
}
|
|
2034
|
-
], encodeArgs, true),
|
|
2035
|
-
};
|
|
2036
|
-
this.tracer.collectEventEmit({
|
|
2037
|
-
source: 'js',
|
|
2038
|
-
target: 'native',
|
|
2039
|
-
eventName: serviceName,
|
|
2040
|
-
eventData: encodeArgs,
|
|
2041
|
-
});
|
|
2042
|
-
return [2 /*return*/, this._send(params)];
|
|
2043
|
-
});
|
|
2044
|
-
});
|
|
2045
|
-
};
|
|
2046
|
-
MessageSenderImpl.prototype.sendEventEmitResult = function (instanceId, serviceName, ret) {
|
|
2047
|
-
return __awaiter$1(this, void 0, void 0, function () {
|
|
2048
|
-
var params;
|
|
2049
|
-
return __generator$1(this, function (_b) {
|
|
2050
|
-
params = {
|
|
2051
|
-
callType: CALL_TYPE$1.INSTANCE_EVENT_RESULT,
|
|
2052
|
-
_instanceId: instanceId,
|
|
2053
|
-
serviceName: serviceName,
|
|
2054
|
-
args: [ret],
|
|
2055
|
-
_traceId: ret._traceId,
|
|
2056
|
-
};
|
|
2057
|
-
this.tracer.collectEventEmitResult({
|
|
2058
|
-
source: 'js',
|
|
2059
|
-
target: 'native',
|
|
2060
|
-
eventName: serviceName,
|
|
2061
|
-
eventData: ret,
|
|
2062
|
-
});
|
|
2063
|
-
return [2 /*return*/, this._send(params)];
|
|
2064
|
-
});
|
|
1136
|
+
this.tracer.collectEventEmit({
|
|
1137
|
+
source: 'js',
|
|
1138
|
+
target: 'native',
|
|
1139
|
+
eventName: serviceName,
|
|
1140
|
+
eventData: encodeArgs,
|
|
2065
1141
|
});
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
}
|
|
2082
|
-
});
|
|
1142
|
+
return this._send(params);
|
|
1143
|
+
}
|
|
1144
|
+
async sendEventEmitResult(instanceId, serviceName, ret) {
|
|
1145
|
+
const params = {
|
|
1146
|
+
callType: CALL_TYPE$1.INSTANCE_EVENT_RESULT,
|
|
1147
|
+
_instanceId: instanceId,
|
|
1148
|
+
serviceName: serviceName,
|
|
1149
|
+
args: [ret],
|
|
1150
|
+
_traceId: ret._traceId,
|
|
1151
|
+
};
|
|
1152
|
+
this.tracer.collectEventEmitResult({
|
|
1153
|
+
source: 'js',
|
|
1154
|
+
target: 'native',
|
|
1155
|
+
eventName: serviceName,
|
|
1156
|
+
eventData: ret,
|
|
2083
1157
|
});
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1158
|
+
return this._send(params);
|
|
1159
|
+
}
|
|
1160
|
+
async _send(params) {
|
|
1161
|
+
const traceId = params._traceId || getUuid('trace');
|
|
2087
1162
|
params._traceId = traceId;
|
|
2088
|
-
this.
|
|
2089
|
-
var res = this.bridge.callSync(params);
|
|
2090
|
-
this.logger.info('[message-sender] Received sync response:', res);
|
|
1163
|
+
const res = await this.bridge.call(params);
|
|
2091
1164
|
return this._resolveReturn(res, params);
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
this.logger.error('[message-sender] Native method not implemented:', req);
|
|
2107
|
-
break;
|
|
2108
|
-
case RETURN_STATUS$1.FAILED:
|
|
2109
|
-
this.logger.error('[message-sender] Decode return failed:', res);
|
|
2110
|
-
break;
|
|
2111
|
-
default:
|
|
2112
|
-
this.logger.warn('[message-sender] Unknown return status:', res);
|
|
2113
|
-
break;
|
|
1165
|
+
}
|
|
1166
|
+
_sendSync(params) {
|
|
1167
|
+
const traceId = params._traceId || getUuid('trace');
|
|
1168
|
+
params._traceId = traceId;
|
|
1169
|
+
const res = this.bridge.callSync(params);
|
|
1170
|
+
return this._resolveReturn(res, params);
|
|
1171
|
+
}
|
|
1172
|
+
_resolveReturn(res, req) {
|
|
1173
|
+
if (res.status === RETURN_STATUS$1.SUCCESS && res.msg) {
|
|
1174
|
+
Object.defineProperty(res, 'decoded', {
|
|
1175
|
+
value: this.proto.decodeArg(res.msg),
|
|
1176
|
+
enumerable: false,
|
|
1177
|
+
writable: true,
|
|
1178
|
+
});
|
|
2114
1179
|
}
|
|
2115
1180
|
return res;
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
this.logger.warn('[message-sender] Failed to resolve instance id:', instanceOrId);
|
|
1181
|
+
}
|
|
1182
|
+
_resolveInstanceId(instanceOrId) {
|
|
1183
|
+
if (typeof instanceOrId === 'string') {
|
|
1184
|
+
return instanceOrId;
|
|
2121
1185
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
1186
|
+
if (isInstanceArg(instanceOrId)) {
|
|
1187
|
+
return instanceOrId._instanceId;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
(() => {
|
|
1192
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
2128
1193
|
_sendVarGet_decorators = [Bind];
|
|
2129
1194
|
_sendStaticCall_decorators = [Bind];
|
|
2130
1195
|
_sendStaticCallSync_decorators = [Bind];
|
|
@@ -2135,343 +1200,247 @@ var MessageSenderImpl = function () {
|
|
|
2135
1200
|
_sendInstanceGet_decorators = [Bind];
|
|
2136
1201
|
_sendInstanceEventAdd_decorators = [Bind];
|
|
2137
1202
|
_sendInstanceEventRemove_decorators = [Bind];
|
|
2138
|
-
_sendDestroyInstance_decorators = [Bind];
|
|
2139
1203
|
_sendEventEmit_decorators = [Bind];
|
|
2140
1204
|
_sendEventEmitResult_decorators = [Bind];
|
|
2141
|
-
__esDecorate$1(_a, null, _sendVarGet_decorators, { kind: "method", name: "sendVarGet", static: false, private: false, access: { has:
|
|
2142
|
-
__esDecorate$1(_a, null, _sendStaticCall_decorators, { kind: "method", name: "sendStaticCall", static: false, private: false, access: { has:
|
|
2143
|
-
__esDecorate$1(_a, null, _sendStaticCallSync_decorators, { kind: "method", name: "sendStaticCallSync", static: false, private: false, access: { has:
|
|
2144
|
-
__esDecorate$1(_a, null, _sendNewInstanceCall_decorators, { kind: "method", name: "sendNewInstanceCall", static: false, private: false, access: { has:
|
|
2145
|
-
__esDecorate$1(_a, null, _sendInstanceCall_decorators, { kind: "method", name: "sendInstanceCall", static: false, private: false, access: { has:
|
|
2146
|
-
__esDecorate$1(_a, null, _sendInstanceCallSync_decorators, { kind: "method", name: "sendInstanceCallSync", static: false, private: false, access: { has:
|
|
2147
|
-
__esDecorate$1(_a, null, _sendInstanceSet_decorators, { kind: "method", name: "sendInstanceSet", static: false, private: false, access: { has:
|
|
2148
|
-
__esDecorate$1(_a, null, _sendInstanceGet_decorators, { kind: "method", name: "sendInstanceGet", static: false, private: false, access: { has:
|
|
2149
|
-
__esDecorate$1(_a, null, _sendInstanceEventAdd_decorators, { kind: "method", name: "sendInstanceEventAdd", static: false, private: false, access: { has:
|
|
2150
|
-
__esDecorate$1(_a, null, _sendInstanceEventRemove_decorators, { kind: "method", name: "sendInstanceEventRemove", static: false, private: false, access: { has:
|
|
2151
|
-
__esDecorate$1(_a, null,
|
|
2152
|
-
__esDecorate$1(_a, null,
|
|
2153
|
-
__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);
|
|
1205
|
+
__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);
|
|
1206
|
+
__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);
|
|
1207
|
+
__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);
|
|
1208
|
+
__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);
|
|
1209
|
+
__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);
|
|
1210
|
+
__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);
|
|
1211
|
+
__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);
|
|
1212
|
+
__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);
|
|
1213
|
+
__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);
|
|
1214
|
+
__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);
|
|
1215
|
+
__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);
|
|
1216
|
+
__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);
|
|
2154
1217
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2155
1218
|
})(),
|
|
2156
1219
|
_a;
|
|
2157
|
-
}();
|
|
1220
|
+
})();
|
|
2158
1221
|
|
|
2159
|
-
|
|
1222
|
+
let MessageClientImpl = (() => {
|
|
2160
1223
|
var _a;
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
return _a =
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
}
|
|
2173
|
-
MessageClientImpl.prototype.registerService = function (name, service) {
|
|
2174
|
-
this.logger.debug("[message-client] Register service: ".concat(name));
|
|
1224
|
+
let _classSuper = MessageSenderImpl;
|
|
1225
|
+
let _instanceExtraInitializers = [];
|
|
1226
|
+
let _registerService_decorators;
|
|
1227
|
+
let _registerInstance_decorators;
|
|
1228
|
+
let _handlerMessage_decorators;
|
|
1229
|
+
return _a = class MessageClientImpl extends _classSuper {
|
|
1230
|
+
constructor() {
|
|
1231
|
+
super(...arguments);
|
|
1232
|
+
this._globalScope = (__runInitializers$1(this, _instanceExtraInitializers), {});
|
|
1233
|
+
}
|
|
1234
|
+
registerService(name, service) {
|
|
2175
1235
|
this._globalScope[name] = service;
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
this.logger.debug("[message-client] Register instance: ".concat(id));
|
|
1236
|
+
}
|
|
1237
|
+
registerInstance(id, instance) {
|
|
2179
1238
|
this.proto.registerProxyInstance(id, instance);
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
root = this._globalScope;
|
|
2221
|
-
target = keyPathVisitor(root, paths);
|
|
2222
|
-
assert(!!target, "can\"t find static api, please check serviceName ".concat(serviceName));
|
|
2223
|
-
api = Reflect.get(target, property);
|
|
2224
|
-
assert(!!api, "can\"t find static api ".concat(target, ".").concat(property, ", please check serviceName ").concat(serviceName));
|
|
2225
|
-
decodeArgs = this.proto.decodeArgs(args);
|
|
2226
|
-
span = this.tracer.collectApiCall({
|
|
2227
|
-
source: 'native',
|
|
2228
|
-
target: 'js',
|
|
2229
|
-
serviceName: serviceName,
|
|
2230
|
-
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
2231
|
-
args: args,
|
|
2232
|
-
});
|
|
2233
|
-
_d.label = 1;
|
|
2234
|
-
case 1:
|
|
2235
|
-
_d.trys.push([1, 5, , 6]);
|
|
2236
|
-
if (!(typeof api === 'function')) return [3 /*break*/, 3];
|
|
2237
|
-
return [4 /*yield*/, api.apply(target, decodeArgs)];
|
|
2238
|
-
case 2:
|
|
2239
|
-
_c = _d.sent();
|
|
2240
|
-
return [3 /*break*/, 4];
|
|
2241
|
-
case 3:
|
|
2242
|
-
_c = api;
|
|
2243
|
-
_d.label = 4;
|
|
2244
|
-
case 4:
|
|
2245
|
-
value = _c;
|
|
2246
|
-
res = this._returnHandler(value);
|
|
2247
|
-
span.success(res);
|
|
2248
|
-
this.logger.debug("[message-client] Static API call success: ".concat(serviceName));
|
|
2249
|
-
return [2 /*return*/, res];
|
|
2250
|
-
case 5:
|
|
2251
|
-
err_1 = _d.sent();
|
|
2252
|
-
this.logger.error("[message-client] Static API call failed: ".concat(serviceName), err_1);
|
|
2253
|
-
span.fail(err_1);
|
|
2254
|
-
throw err_1;
|
|
2255
|
-
case 6: return [2 /*return*/];
|
|
2256
|
-
}
|
|
2257
|
-
});
|
|
1239
|
+
}
|
|
1240
|
+
async handlerMessage(req) {
|
|
1241
|
+
try {
|
|
1242
|
+
const { callType } = req;
|
|
1243
|
+
switch (callType) {
|
|
1244
|
+
case CALL_TYPE$1.PLAIN_API_CALL:
|
|
1245
|
+
return this._onCallStaticApi(req);
|
|
1246
|
+
case CALL_TYPE$1.INSTANCE_METHOD_INVOKE:
|
|
1247
|
+
return this._onCallInstanceApi(req);
|
|
1248
|
+
case CALL_TYPE$1.INSTANCE_EVENT_LISTENER_ADD:
|
|
1249
|
+
return this._onCallEventRegister(req);
|
|
1250
|
+
case CALL_TYPE$1.INSTANCE_EVENT_EMIT:
|
|
1251
|
+
return this._onCallEventEmit(req);
|
|
1252
|
+
case CALL_TYPE$1.CALLBACK_EMIT:
|
|
1253
|
+
return this._onCallbackEmit(req);
|
|
1254
|
+
default:
|
|
1255
|
+
throw new Error(`unknown callType "${callType}"`);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
catch (err) {
|
|
1259
|
+
this.logger.warn('handle remote call fail:', req, err);
|
|
1260
|
+
throw err;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
async _onCallStaticApi(req) {
|
|
1264
|
+
const { serviceName, args = [] } = req;
|
|
1265
|
+
const paths = serviceName.split('.');
|
|
1266
|
+
const property = paths.pop();
|
|
1267
|
+
const root = this._globalScope;
|
|
1268
|
+
const target = keyPathVisitor(root, paths);
|
|
1269
|
+
assert(!!target, `can"t find static api, please check serviceName ${serviceName}`);
|
|
1270
|
+
const api = Reflect.get(target, property);
|
|
1271
|
+
assert(!!api, `can"t find static api ${target}.${property}, please check serviceName ${serviceName}`);
|
|
1272
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1273
|
+
const span = this.tracer.collectApiCall({
|
|
1274
|
+
source: 'native',
|
|
1275
|
+
target: 'js',
|
|
1276
|
+
serviceName: serviceName,
|
|
1277
|
+
callType: CALL_TYPE$1.PLAIN_API_CALL,
|
|
1278
|
+
args,
|
|
2258
1279
|
});
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
property = paths.pop();
|
|
2278
|
-
assert(typeof property === 'string', "incorrect serviceName \"".concat(serviceName, "\""));
|
|
2279
|
-
target = keyPathVisitor(instance, paths);
|
|
2280
|
-
assert(!!target, "can\"t find instance@".concat(_instanceId, " api, please check serviceName \"").concat(serviceName, "\" ").concat(target));
|
|
2281
|
-
api = Reflect.get(target, property, target);
|
|
2282
|
-
assert(!!api, "can\"t find instance@".concat(_instanceId, " api, please check serviceName \"").concat(serviceName, "\" ").concat(target, ".").concat(api));
|
|
2283
|
-
decodeArgs = args.map(function (arg) {
|
|
2284
|
-
if (isPlainObject(arg) &&
|
|
2285
|
-
arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
2286
|
-
return _this.proto.decodeInstance(arg);
|
|
2287
|
-
}
|
|
2288
|
-
if (isPlainObject(arg) &&
|
|
2289
|
-
arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
2290
|
-
return function () {
|
|
2291
|
-
var eventData = [];
|
|
2292
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2293
|
-
eventData[_i] = arguments[_i];
|
|
2294
|
-
}
|
|
2295
|
-
_this.sendEventEmit(_instanceId, serviceName, arg._callbackId, eventData);
|
|
2296
|
-
};
|
|
2297
|
-
}
|
|
2298
|
-
return arg;
|
|
2299
|
-
});
|
|
2300
|
-
span = this.tracer.collectApiCall({
|
|
2301
|
-
source: 'native',
|
|
2302
|
-
target: 'js',
|
|
2303
|
-
serviceName: serviceName,
|
|
2304
|
-
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
2305
|
-
args: args,
|
|
2306
|
-
});
|
|
2307
|
-
_d.label = 1;
|
|
2308
|
-
case 1:
|
|
2309
|
-
_d.trys.push([1, 5, , 6]);
|
|
2310
|
-
if (!(typeof api === 'function')) return [3 /*break*/, 3];
|
|
2311
|
-
return [4 /*yield*/, api.apply(target, decodeArgs)];
|
|
2312
|
-
case 2:
|
|
2313
|
-
_c = _d.sent();
|
|
2314
|
-
return [3 /*break*/, 4];
|
|
2315
|
-
case 3:
|
|
2316
|
-
_c = api;
|
|
2317
|
-
_d.label = 4;
|
|
2318
|
-
case 4:
|
|
2319
|
-
value = _c;
|
|
2320
|
-
res = this._returnHandler(value);
|
|
2321
|
-
span.success(res);
|
|
2322
|
-
this.logger.debug("[message-client] Instance API call success: ".concat(serviceName));
|
|
2323
|
-
return [2 /*return*/, res];
|
|
2324
|
-
case 5:
|
|
2325
|
-
err_2 = _d.sent();
|
|
2326
|
-
this.logger.error("[message-client] Instance API call failed: ".concat(serviceName), err_2);
|
|
2327
|
-
span.fail(err_2);
|
|
2328
|
-
throw err_2;
|
|
2329
|
-
case 6: return [2 /*return*/];
|
|
2330
|
-
}
|
|
2331
|
-
});
|
|
1280
|
+
try {
|
|
1281
|
+
const value = typeof api === 'function' ? await api.apply(target, decodeArgs) : api;
|
|
1282
|
+
const res = this._returnHandler(value);
|
|
1283
|
+
span.success(res);
|
|
1284
|
+
return res;
|
|
1285
|
+
}
|
|
1286
|
+
catch (err) {
|
|
1287
|
+
span.fail(err);
|
|
1288
|
+
throw err;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
async _onCallInstanceApi(req) {
|
|
1292
|
+
const { serviceName, args = [], _instanceId } = req;
|
|
1293
|
+
const paths = serviceName.split('.');
|
|
1294
|
+
assert(!!_instanceId, 'callType is instanceCall, but missing _instanceId Params');
|
|
1295
|
+
const instance = this.proto.decodeInstance({
|
|
1296
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1297
|
+
_instanceId,
|
|
2332
1298
|
});
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
target: 'js',
|
|
2351
|
-
eventName: serviceName,
|
|
2352
|
-
});
|
|
2353
|
-
remoteCallbackId = args[0]._callbackId;
|
|
2354
|
-
proxyCallback = function () {
|
|
2355
|
-
var eventData = [];
|
|
2356
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2357
|
-
eventData[_i] = arguments[_i];
|
|
2358
|
-
}
|
|
2359
|
-
_this.sendEventEmit(_instanceId, serviceName, remoteCallbackId, eventData);
|
|
1299
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1300
|
+
paths.shift();
|
|
1301
|
+
const property = paths.pop();
|
|
1302
|
+
assert(typeof property === 'string', `incorrect serviceName "${serviceName}"`);
|
|
1303
|
+
const target = keyPathVisitor(instance, paths);
|
|
1304
|
+
assert(!!target, `can"t find instance@${_instanceId} api, please check serviceName "${serviceName}" ${target}`);
|
|
1305
|
+
const api = Reflect.get(target, property, target);
|
|
1306
|
+
assert(!!api, `can"t find instance@${_instanceId} api, please check serviceName "${serviceName}" ${target}.${api}`);
|
|
1307
|
+
const decodeArgs = args.map(arg => {
|
|
1308
|
+
if (isPlainObject(arg) &&
|
|
1309
|
+
arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
1310
|
+
return this.proto.decodeInstance(arg);
|
|
1311
|
+
}
|
|
1312
|
+
if (isPlainObject(arg) &&
|
|
1313
|
+
arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
1314
|
+
return (...eventData) => {
|
|
1315
|
+
this.sendEventEmit(_instanceId, serviceName, arg._callbackId, eventData);
|
|
2360
1316
|
};
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
instance.on(eventName, proxyCallback);
|
|
2364
|
-
this.logger.debug("[message-client] Event listener registered: ".concat(eventName));
|
|
2365
|
-
return [2 /*return*/, this._returnHandler(null)];
|
|
2366
|
-
});
|
|
1317
|
+
}
|
|
1318
|
+
return arg;
|
|
2367
1319
|
});
|
|
2368
|
-
|
|
1320
|
+
const span = this.tracer.collectApiCall({
|
|
1321
|
+
source: 'native',
|
|
1322
|
+
target: 'js',
|
|
1323
|
+
serviceName: serviceName,
|
|
1324
|
+
callType: CALL_TYPE$1.INSTANCE_METHOD_INVOKE,
|
|
1325
|
+
args,
|
|
1326
|
+
});
|
|
1327
|
+
try {
|
|
1328
|
+
const value = typeof api === 'function' ? await api.apply(target, decodeArgs) : api;
|
|
1329
|
+
const res = this._returnHandler(value);
|
|
1330
|
+
span.success(res);
|
|
1331
|
+
return res;
|
|
1332
|
+
}
|
|
1333
|
+
catch (err) {
|
|
1334
|
+
span.fail(err);
|
|
1335
|
+
throw err;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
async _onCallEventRegister(req) {
|
|
1339
|
+
const { args = [], _instanceId, serviceName } = req;
|
|
1340
|
+
assert(!!_instanceId, 'callType is "instance_event_register", but missing _instanceId Params');
|
|
1341
|
+
const instance = this.proto.decodeInstance({
|
|
1342
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1343
|
+
_instanceId,
|
|
1344
|
+
});
|
|
1345
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1346
|
+
assert(typeof instance.on === 'function', 'instance can"t "on"');
|
|
1347
|
+
this.tracer.collectEventOn({
|
|
1348
|
+
source: 'native',
|
|
1349
|
+
target: 'js',
|
|
1350
|
+
eventName: serviceName,
|
|
1351
|
+
});
|
|
1352
|
+
const remoteCallbackId = args[0]._callbackId;
|
|
1353
|
+
const proxyCallback = (...eventData) => {
|
|
1354
|
+
this.sendEventEmit(_instanceId, serviceName, remoteCallbackId, eventData);
|
|
1355
|
+
};
|
|
1356
|
+
const paths = serviceName.split('.');
|
|
1357
|
+
const eventName = paths[paths.length - 1];
|
|
1358
|
+
instance.on(eventName, proxyCallback);
|
|
1359
|
+
return this._returnHandler(null);
|
|
1360
|
+
}
|
|
2369
1361
|
/**
|
|
2370
1362
|
* 触发事件,优先通过 callbackId 找 callback,找不到通过 instanceId 找实例 emit
|
|
2371
1363
|
* @param req
|
|
2372
1364
|
* @returns
|
|
2373
1365
|
*/
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
source: 'native',
|
|
2384
|
-
target: 'js',
|
|
2385
|
-
eventName: eventName,
|
|
2386
|
-
eventData: decodeArgs,
|
|
2387
|
-
});
|
|
2388
|
-
assert(!!_instanceId, 'callType is "instance_event_emit", but missing "_instanceId" Params');
|
|
2389
|
-
instance = this.proto.decodeInstance({
|
|
2390
|
-
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
2391
|
-
_instanceId: _instanceId,
|
|
2392
|
-
});
|
|
2393
|
-
assert(!!instance, "can\"t find instance, instanceId ".concat(_instanceId, " incorrect"));
|
|
2394
|
-
returnParams = null;
|
|
2395
|
-
res = null;
|
|
2396
|
-
try {
|
|
2397
|
-
if (typeof instance.emit === 'function') {
|
|
2398
|
-
res = instance.emit.apply(instance, __spreadArray$1([eventName], decodeArgs, false));
|
|
2399
|
-
returnParams = this._returnHandler(res);
|
|
2400
|
-
this.logger.debug("[message-client] Event emitted successfully: ".concat(eventName));
|
|
2401
|
-
}
|
|
2402
|
-
else if (typeof instance[eventName] === 'function') {
|
|
2403
|
-
res = instance[eventName].apply(instance, decodeArgs);
|
|
2404
|
-
returnParams = this._returnHandler(res);
|
|
2405
|
-
this.logger.debug("[message-client] Event handler executed: ".concat(eventName));
|
|
2406
|
-
}
|
|
2407
|
-
else {
|
|
2408
|
-
this.logger.debug("[message-client] Unknown event \"".concat(eventName, "\""));
|
|
2409
|
-
returnParams = {
|
|
2410
|
-
status: RETURN_STATUS$1.NOT_IMPLEMENTED,
|
|
2411
|
-
msg: {},
|
|
2412
|
-
};
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
catch (err) {
|
|
2416
|
-
this.logger.error("[message-client] Event emit failed: ".concat(eventName), err);
|
|
2417
|
-
returnParams = {
|
|
2418
|
-
status: RETURN_STATUS$1.FAILED,
|
|
2419
|
-
msg: {
|
|
2420
|
-
errorMessage: (err === null || err === void 0 ? void 0 : err.message) || '',
|
|
2421
|
-
errorCode: -1,
|
|
2422
|
-
},
|
|
2423
|
-
};
|
|
2424
|
-
}
|
|
2425
|
-
returnParams._traceId = _traceId;
|
|
2426
|
-
if (waitResult) {
|
|
2427
|
-
this.sendEventEmitResult(_instanceId, serviceName, returnParams);
|
|
2428
|
-
}
|
|
2429
|
-
return [2 /*return*/, returnParams];
|
|
2430
|
-
});
|
|
1366
|
+
async _onCallEventEmit(req) {
|
|
1367
|
+
const { args = [], serviceName, methodName, waitResult, _traceId, _instanceId, } = req;
|
|
1368
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1369
|
+
const eventName = methodName || serviceName;
|
|
1370
|
+
this.tracer.collectEventEmit({
|
|
1371
|
+
source: 'native',
|
|
1372
|
+
target: 'js',
|
|
1373
|
+
eventName: eventName,
|
|
1374
|
+
eventData: decodeArgs,
|
|
2431
1375
|
});
|
|
2432
|
-
|
|
1376
|
+
assert(!!_instanceId, 'callType is "instance_event_emit", but missing "_instanceId" Params');
|
|
1377
|
+
const instance = this.proto.decodeInstance({
|
|
1378
|
+
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
1379
|
+
_instanceId,
|
|
1380
|
+
});
|
|
1381
|
+
assert(!!instance, `can"t find instance, instanceId ${_instanceId} incorrect`);
|
|
1382
|
+
let returnParams = null;
|
|
1383
|
+
let res = null;
|
|
1384
|
+
try {
|
|
1385
|
+
if (typeof instance.emit === 'function') {
|
|
1386
|
+
res = instance.emit(eventName, ...decodeArgs);
|
|
1387
|
+
returnParams = this._returnHandler(res);
|
|
1388
|
+
}
|
|
1389
|
+
else if (typeof instance[eventName] === 'function') {
|
|
1390
|
+
res = instance[eventName].apply(instance, decodeArgs);
|
|
1391
|
+
returnParams = this._returnHandler(res);
|
|
1392
|
+
}
|
|
1393
|
+
else {
|
|
1394
|
+
this.logger.warn(`unknown event "${eventName}"`);
|
|
1395
|
+
returnParams = {
|
|
1396
|
+
status: RETURN_STATUS$1.NOT_IMPLEMENTED,
|
|
1397
|
+
msg: {},
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
catch (err) {
|
|
1402
|
+
returnParams = {
|
|
1403
|
+
status: RETURN_STATUS$1.FAILED,
|
|
1404
|
+
msg: {
|
|
1405
|
+
errorMessage: err?.message || '',
|
|
1406
|
+
errorCode: -1,
|
|
1407
|
+
},
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
returnParams._traceId = _traceId;
|
|
1411
|
+
if (waitResult) {
|
|
1412
|
+
this.sendEventEmitResult(_instanceId, serviceName, returnParams);
|
|
1413
|
+
}
|
|
1414
|
+
return returnParams;
|
|
1415
|
+
}
|
|
2433
1416
|
/**
|
|
2434
1417
|
* 触发回调,优先通过 callbackId 找 callback,找不到通过 instanceId 找实例 emit
|
|
2435
1418
|
* @param req
|
|
2436
1419
|
* @returns
|
|
2437
1420
|
*/
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
source: 'native',
|
|
2448
|
-
target: 'js',
|
|
2449
|
-
eventName: eventName,
|
|
2450
|
-
eventData: decodeArgs,
|
|
2451
|
-
});
|
|
2452
|
-
assert(!!_instanceId, 'callType is "callback_emit", but missing "_instanceId" Params');
|
|
2453
|
-
callback = this.proto.decodeCallback({
|
|
2454
|
-
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
2455
|
-
_callbackId: _instanceId,
|
|
2456
|
-
});
|
|
2457
|
-
assert(typeof callback === 'function', "can\"t find callback, callback_id ".concat(_instanceId, " incorrect"));
|
|
2458
|
-
try {
|
|
2459
|
-
callback.apply(null, decodeArgs);
|
|
2460
|
-
this.logger.debug("[message-client] Callback executed successfully: ".concat(eventName));
|
|
2461
|
-
return [2 /*return*/, this._returnHandler(null)];
|
|
2462
|
-
}
|
|
2463
|
-
catch (err) {
|
|
2464
|
-
this.logger.error("[message-client] Callback execution failed: ".concat(eventName), err);
|
|
2465
|
-
throw err;
|
|
2466
|
-
}
|
|
2467
|
-
return [2 /*return*/];
|
|
2468
|
-
});
|
|
1421
|
+
async _onCallbackEmit(req) {
|
|
1422
|
+
const { args = [], serviceName, methodName, _instanceId } = req;
|
|
1423
|
+
const decodeArgs = this.proto.decodeArgs(args);
|
|
1424
|
+
const eventName = methodName || serviceName;
|
|
1425
|
+
this.tracer.collectCallbackEmit({
|
|
1426
|
+
source: 'native',
|
|
1427
|
+
target: 'js',
|
|
1428
|
+
eventName: eventName,
|
|
1429
|
+
eventData: decodeArgs,
|
|
2469
1430
|
});
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
1431
|
+
assert(!!_instanceId, 'callType is "callback_emit", but missing "_instanceId" Params');
|
|
1432
|
+
const callback = this.proto.decodeCallback({
|
|
1433
|
+
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
1434
|
+
_callbackId: _instanceId,
|
|
1435
|
+
});
|
|
1436
|
+
assert(typeof callback === 'function', `can"t find callback, callback_id ${_instanceId} incorrect`);
|
|
1437
|
+
callback.apply(null, decodeArgs);
|
|
1438
|
+
return this._returnHandler(null);
|
|
1439
|
+
}
|
|
1440
|
+
_returnHandler(response) {
|
|
1441
|
+
this.logger.verbose('response:', response);
|
|
1442
|
+
const encodeResponse = this.proto.encodeArg(response);
|
|
1443
|
+
const returnVal = {
|
|
2475
1444
|
status: RETURN_STATUS$1.SUCCESS,
|
|
2476
1445
|
msg: encodeResponse === undefined
|
|
2477
1446
|
? null
|
|
@@ -2480,22 +1449,20 @@ var MessageClientImpl = function () {
|
|
|
2480
1449
|
: encodeResponse,
|
|
2481
1450
|
};
|
|
2482
1451
|
return returnVal;
|
|
2483
|
-
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
var _b;
|
|
2488
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
1452
|
+
}
|
|
1453
|
+
},
|
|
1454
|
+
(() => {
|
|
1455
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
2489
1456
|
_registerService_decorators = [Bind];
|
|
2490
1457
|
_registerInstance_decorators = [Bind];
|
|
2491
1458
|
_handlerMessage_decorators = [Bind];
|
|
2492
|
-
__esDecorate$1(_a, null, _registerService_decorators, { kind: "method", name: "registerService", static: false, private: false, access: { has:
|
|
2493
|
-
__esDecorate$1(_a, null, _registerInstance_decorators, { kind: "method", name: "registerInstance", static: false, private: false, access: { has:
|
|
2494
|
-
__esDecorate$1(_a, null, _handlerMessage_decorators, { kind: "method", name: "handlerMessage", static: false, private: false, access: { has:
|
|
1459
|
+
__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);
|
|
1460
|
+
__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);
|
|
1461
|
+
__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);
|
|
2495
1462
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2496
1463
|
})(),
|
|
2497
1464
|
_a;
|
|
2498
|
-
}();
|
|
1465
|
+
})();
|
|
2499
1466
|
|
|
2500
1467
|
function createProxyInstance(raw) {
|
|
2501
1468
|
Object.defineProperty(raw, '$$native', {
|
|
@@ -2519,85 +1486,74 @@ function isArrayBuffer(val) {
|
|
|
2519
1486
|
function isBuffer(val) {
|
|
2520
1487
|
return isArrayBuffer(val) || isDateView(val);
|
|
2521
1488
|
}
|
|
2522
|
-
|
|
1489
|
+
let MessageProtoImpl = (() => {
|
|
2523
1490
|
var _a;
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
return _a =
|
|
2536
|
-
|
|
1491
|
+
let _instanceExtraInitializers = [];
|
|
1492
|
+
let _encodeArgs_decorators;
|
|
1493
|
+
let _encodeInstance_decorators;
|
|
1494
|
+
let _decodeInstance_decorators;
|
|
1495
|
+
let _encodeCallback_decorators;
|
|
1496
|
+
let _decodeCallback_decorators;
|
|
1497
|
+
let _encodeBase64_decorators;
|
|
1498
|
+
let _decodeBase64_decorators;
|
|
1499
|
+
let _encodeArg_decorators;
|
|
1500
|
+
let _decodeArgs_decorators;
|
|
1501
|
+
let _decodeArg_decorators;
|
|
1502
|
+
return _a = class MessageProtoImpl {
|
|
1503
|
+
constructor() {
|
|
2537
1504
|
this._idMapInstance = (__runInitializers$1(this, _instanceExtraInitializers), {});
|
|
2538
1505
|
this._instanceMapId = new WeakMap();
|
|
2539
1506
|
this._idMapCallback = {};
|
|
2540
1507
|
this._callbackMapId = new WeakMap();
|
|
2541
|
-
this._logger = LoggerImpl.getInstance();
|
|
2542
1508
|
}
|
|
2543
|
-
|
|
2544
|
-
this._logger.debug("[message-proto] Registering proxy instance with id: ".concat(id));
|
|
1509
|
+
registerProxyInstance(id, instance) {
|
|
2545
1510
|
this._idMapInstance[id] = instance;
|
|
2546
1511
|
this._instanceMapId.set(instance, id);
|
|
2547
|
-
}
|
|
2548
|
-
|
|
1512
|
+
}
|
|
1513
|
+
encodeArgs(args) {
|
|
2549
1514
|
return args.map(this.encodeArg);
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
var instanceId = this._findOrCreateInstanceId(arg);
|
|
2553
|
-
this._logger.debug("[message-proto] Encoding instance with id: ".concat(instanceId));
|
|
1515
|
+
}
|
|
1516
|
+
encodeInstance(arg) {
|
|
2554
1517
|
return {
|
|
2555
1518
|
_type: "instance" /* ARG_TYPE.INSTANCE */,
|
|
2556
|
-
_instanceId:
|
|
1519
|
+
_instanceId: this._findOrCreateInstanceId(arg),
|
|
2557
1520
|
_serviceName: arg.namespace ||
|
|
2558
1521
|
arg._namespace ||
|
|
2559
1522
|
arg._serviceName,
|
|
2560
1523
|
};
|
|
2561
|
-
}
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
var instance = this._findInstance(arg._instanceId);
|
|
1524
|
+
}
|
|
1525
|
+
decodeInstance(arg) {
|
|
1526
|
+
let instance = this._findInstance(arg._instanceId);
|
|
2565
1527
|
if (!instance) {
|
|
2566
|
-
|
|
1528
|
+
// TODO:
|
|
2567
1529
|
instance = createProxyInstance(arg);
|
|
2568
1530
|
this._idMapInstance[arg._instanceId] = instance;
|
|
2569
1531
|
}
|
|
2570
1532
|
return instance;
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
var callbackId = this._findOrCreateCallbackId(arg);
|
|
2574
|
-
this._logger.debug("[message-proto] Encoding callback with id: ".concat(callbackId));
|
|
1533
|
+
}
|
|
1534
|
+
encodeCallback(arg) {
|
|
2575
1535
|
return {
|
|
2576
1536
|
_type: "callback" /* ARG_TYPE.CALLBACK */,
|
|
2577
|
-
_callbackId:
|
|
1537
|
+
_callbackId: this._findOrCreateCallbackId(arg),
|
|
2578
1538
|
};
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
this._logger.debug("[message-proto] Decoding callback with id: ".concat(arg._callbackId));
|
|
1539
|
+
}
|
|
1540
|
+
decodeCallback(arg) {
|
|
2582
1541
|
return this._findCallback(arg._callbackId) || arg;
|
|
2583
|
-
}
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
var buf = bufferLike.buffer || bufferLike;
|
|
1542
|
+
}
|
|
1543
|
+
encodeBase64(bufferLike) {
|
|
1544
|
+
const buf = bufferLike.buffer || bufferLike;
|
|
2587
1545
|
return {
|
|
2588
1546
|
_type: "base64" /* ARG_TYPE.BASE64 */,
|
|
2589
1547
|
_value: buf2base64(buf),
|
|
2590
1548
|
};
|
|
2591
|
-
}
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
var buf = uint8.buffer;
|
|
1549
|
+
}
|
|
1550
|
+
decodeBase64(arg) {
|
|
1551
|
+
const base64 = arg._value;
|
|
1552
|
+
const uint8 = gBase64.toUint8Array(base64);
|
|
1553
|
+
const buf = uint8.buffer;
|
|
2597
1554
|
return buf;
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
var _this = this;
|
|
1555
|
+
}
|
|
1556
|
+
encodeArg(arg) {
|
|
2601
1557
|
if (isBuffer(arg)) {
|
|
2602
1558
|
return this.encodeBase64(arg);
|
|
2603
1559
|
}
|
|
@@ -2611,26 +1567,23 @@ var MessageProtoImpl = function () {
|
|
|
2611
1567
|
return this.encodeInstance(arg);
|
|
2612
1568
|
}
|
|
2613
1569
|
if (isPlainObject(arg)) {
|
|
2614
|
-
return mapValues(arg,
|
|
2615
|
-
return
|
|
1570
|
+
return mapValues(arg, (value) => {
|
|
1571
|
+
return this.encodeArg(value);
|
|
2616
1572
|
});
|
|
2617
1573
|
}
|
|
2618
1574
|
return arg;
|
|
2619
|
-
}
|
|
2620
|
-
|
|
1575
|
+
}
|
|
1576
|
+
decodeArgs(args) {
|
|
2621
1577
|
return args.map(this.decodeArg);
|
|
2622
|
-
}
|
|
1578
|
+
}
|
|
2623
1579
|
// @CatchError
|
|
2624
|
-
|
|
2625
|
-
var _this = this;
|
|
1580
|
+
decodeArg(arg) {
|
|
2626
1581
|
if (isPlainObject(arg) &&
|
|
2627
1582
|
arg._type === "base64" /* ARG_TYPE.BASE64 */) {
|
|
2628
1583
|
return this.decodeBase64(arg);
|
|
2629
1584
|
}
|
|
2630
1585
|
if (isPlainObject(arg) && arg._type === "instance" /* ARG_TYPE.INSTANCE */) {
|
|
2631
|
-
|
|
2632
|
-
Object.assign(ins, arg);
|
|
2633
|
-
return ins;
|
|
1586
|
+
return this.decodeInstance(arg);
|
|
2634
1587
|
}
|
|
2635
1588
|
if (isPlainObject(arg) && arg._type === "callback" /* ARG_TYPE.CALLBACK */) {
|
|
2636
1589
|
return this.decodeCallback(arg);
|
|
@@ -2639,54 +1592,42 @@ var MessageProtoImpl = function () {
|
|
|
2639
1592
|
return arg.map(this.decodeArg);
|
|
2640
1593
|
}
|
|
2641
1594
|
if (isPlainObject(arg)) {
|
|
2642
|
-
return mapValues(arg,
|
|
2643
|
-
return
|
|
1595
|
+
return mapValues(arg, (value) => {
|
|
1596
|
+
return this.decodeArg(value);
|
|
2644
1597
|
});
|
|
2645
1598
|
}
|
|
2646
1599
|
return arg;
|
|
2647
|
-
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
return instance;
|
|
2654
|
-
};
|
|
2655
|
-
MessageProtoImpl.prototype._findOrCreateInstanceId = function (instance) {
|
|
2656
|
-
var _b;
|
|
2657
|
-
var id = this._instanceMapId.get(instance);
|
|
1600
|
+
}
|
|
1601
|
+
_findInstance(id) {
|
|
1602
|
+
return this._idMapInstance[id];
|
|
1603
|
+
}
|
|
1604
|
+
_findOrCreateInstanceId(instance) {
|
|
1605
|
+
let id = this._instanceMapId.get(instance);
|
|
2658
1606
|
if (id === undefined) {
|
|
2659
1607
|
id =
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
getUuid(
|
|
2663
|
-
this._logger.debug("[message-proto] Created new instance id: ".concat(id));
|
|
1608
|
+
instance?.instanceId ||
|
|
1609
|
+
instance?._instanceId ||
|
|
1610
|
+
getUuid(instance?.constructor?.name);
|
|
2664
1611
|
this._instanceMapId.set(instance, id);
|
|
2665
1612
|
this._idMapInstance[id] = instance;
|
|
2666
1613
|
}
|
|
2667
1614
|
return id;
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
return callback;
|
|
2675
|
-
};
|
|
2676
|
-
MessageProtoImpl.prototype._findOrCreateCallbackId = function (value) {
|
|
2677
|
-
var id = this._callbackMapId.get(value);
|
|
1615
|
+
}
|
|
1616
|
+
_findCallback(id) {
|
|
1617
|
+
return this._idMapCallback[id];
|
|
1618
|
+
}
|
|
1619
|
+
_findOrCreateCallbackId(value) {
|
|
1620
|
+
let id = this._callbackMapId.get(value);
|
|
2678
1621
|
if (id === undefined) {
|
|
2679
|
-
id = getUuid(value
|
|
2680
|
-
this._logger.debug("[message-proto] Created new callback id: ".concat(id));
|
|
1622
|
+
id = getUuid(value?.name);
|
|
2681
1623
|
this._callbackMapId.set(value, id);
|
|
2682
1624
|
this._idMapCallback[id] = value;
|
|
2683
1625
|
}
|
|
2684
1626
|
return id;
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
(() => {
|
|
1630
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
2690
1631
|
_encodeArgs_decorators = [Bind];
|
|
2691
1632
|
_encodeInstance_decorators = [Bind];
|
|
2692
1633
|
_decodeInstance_decorators = [Bind];
|
|
@@ -2697,50 +1638,48 @@ var MessageProtoImpl = function () {
|
|
|
2697
1638
|
_encodeArg_decorators = [Bind];
|
|
2698
1639
|
_decodeArgs_decorators = [Bind];
|
|
2699
1640
|
_decodeArg_decorators = [Bind];
|
|
2700
|
-
__esDecorate$1(_a, null, _encodeArgs_decorators, { kind: "method", name: "encodeArgs", static: false, private: false, access: { has:
|
|
2701
|
-
__esDecorate$1(_a, null, _encodeInstance_decorators, { kind: "method", name: "encodeInstance", static: false, private: false, access: { has:
|
|
2702
|
-
__esDecorate$1(_a, null, _decodeInstance_decorators, { kind: "method", name: "decodeInstance", static: false, private: false, access: { has:
|
|
2703
|
-
__esDecorate$1(_a, null, _encodeCallback_decorators, { kind: "method", name: "encodeCallback", static: false, private: false, access: { has:
|
|
2704
|
-
__esDecorate$1(_a, null, _decodeCallback_decorators, { kind: "method", name: "decodeCallback", static: false, private: false, access: { has:
|
|
2705
|
-
__esDecorate$1(_a, null, _encodeBase64_decorators, { kind: "method", name: "encodeBase64", static: false, private: false, access: { has:
|
|
2706
|
-
__esDecorate$1(_a, null, _decodeBase64_decorators, { kind: "method", name: "decodeBase64", static: false, private: false, access: { has:
|
|
2707
|
-
__esDecorate$1(_a, null, _encodeArg_decorators, { kind: "method", name: "encodeArg", static: false, private: false, access: { has:
|
|
2708
|
-
__esDecorate$1(_a, null, _decodeArgs_decorators, { kind: "method", name: "decodeArgs", static: false, private: false, access: { has:
|
|
2709
|
-
__esDecorate$1(_a, null, _decodeArg_decorators, { kind: "method", name: "decodeArg", static: false, private: false, access: { has:
|
|
1641
|
+
__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);
|
|
1642
|
+
__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);
|
|
1643
|
+
__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);
|
|
1644
|
+
__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);
|
|
1645
|
+
__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);
|
|
1646
|
+
__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);
|
|
1647
|
+
__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);
|
|
1648
|
+
__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);
|
|
1649
|
+
__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);
|
|
1650
|
+
__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);
|
|
2710
1651
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2711
1652
|
})(),
|
|
2712
1653
|
_a;
|
|
2713
|
-
}();
|
|
1654
|
+
})();
|
|
2714
1655
|
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
1656
|
+
const createMessageClient = (jsBridge) => {
|
|
1657
|
+
const proto = new MessageProtoImpl();
|
|
1658
|
+
const client = new MessageClientImpl(proto, jsBridge);
|
|
2718
1659
|
return client;
|
|
2719
1660
|
};
|
|
2720
1661
|
|
|
2721
|
-
|
|
2722
|
-
|
|
1662
|
+
let jsBridge = createJSBridge();
|
|
1663
|
+
const globalMessageClient = createMessageClient(jsBridge);
|
|
2723
1664
|
function getGlobalMessageClient() {
|
|
2724
1665
|
return globalMessageClient;
|
|
2725
1666
|
}
|
|
2726
1667
|
function setupJSBridge(impl) {
|
|
2727
1668
|
jsBridge = impl;
|
|
2728
1669
|
globalMessageClient.bridge = impl;
|
|
2729
|
-
impl.registerAsyncHandler('emitEvent',
|
|
1670
|
+
impl.registerAsyncHandler('emitEvent', (params) => {
|
|
2730
1671
|
return globalMessageClient.handlerMessage(params);
|
|
2731
1672
|
});
|
|
2732
1673
|
}
|
|
2733
1674
|
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
if (messageClient === void 0) { messageClient = getGlobalMessageClient(); }
|
|
1675
|
+
class NativeProxyService {
|
|
1676
|
+
constructor(messageClient = getGlobalMessageClient()) {
|
|
2737
1677
|
this.messageClient = messageClient;
|
|
2738
1678
|
this.namespace = '';
|
|
2739
1679
|
this.instanceId = getUuid(this.namespace);
|
|
2740
1680
|
this._instanced = this.instanceId;
|
|
2741
1681
|
}
|
|
2742
|
-
|
|
2743
|
-
}());
|
|
1682
|
+
}
|
|
2744
1683
|
function getMessageClient(impl) {
|
|
2745
1684
|
if (typeof impl === 'object' &&
|
|
2746
1685
|
!!impl &&
|
|
@@ -2760,8 +1699,8 @@ function isNativeCreatedInstance(val) {
|
|
|
2760
1699
|
return false;
|
|
2761
1700
|
}
|
|
2762
1701
|
function proxyValue(val, ctor) {
|
|
2763
|
-
|
|
2764
|
-
|
|
1702
|
+
const client = getMessageClient(val);
|
|
1703
|
+
const service = new ctor(DISABLE_INIT);
|
|
2765
1704
|
service.messageClient = client;
|
|
2766
1705
|
service.instanceId = val._instanceId;
|
|
2767
1706
|
// @ts-ignore
|
|
@@ -2776,6 +1715,324 @@ function proxyNativeInstance(value, ctor) {
|
|
|
2776
1715
|
return value;
|
|
2777
1716
|
}
|
|
2778
1717
|
|
|
1718
|
+
function assertReturn(ret) {
|
|
1719
|
+
if (!ret || typeof ret !== 'object') {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
if (ret.status === RETURN_STATUS$1.FAILED) {
|
|
1723
|
+
throw new Error(String(ret.msg));
|
|
1724
|
+
}
|
|
1725
|
+
return ret.decoded || ret.msg;
|
|
1726
|
+
}
|
|
1727
|
+
function isPromiseLike(val) {
|
|
1728
|
+
if (typeof val === 'object' && val !== null) {
|
|
1729
|
+
if (typeof val.then === 'function') {
|
|
1730
|
+
return true;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return false;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
const KEY_NAMESPACE = Symbol.for('#namespace');
|
|
1737
|
+
const KEY_NATIVE_CLASS_NAME = Symbol.for('#nativeClassName');
|
|
1738
|
+
function findNamespace(ctor) {
|
|
1739
|
+
let obj = ctor;
|
|
1740
|
+
let desc;
|
|
1741
|
+
while (!desc && obj) {
|
|
1742
|
+
desc = Object.getOwnPropertyDescriptor(obj, KEY_NAMESPACE);
|
|
1743
|
+
obj = Object.getPrototypeOf(obj);
|
|
1744
|
+
}
|
|
1745
|
+
return desc?.value;
|
|
1746
|
+
}
|
|
1747
|
+
function findMethods(ins, opt = {}) {
|
|
1748
|
+
let methodNames = [];
|
|
1749
|
+
let proto = Object.getPrototypeOf(ins);
|
|
1750
|
+
while (proto && proto !== Object.prototype) {
|
|
1751
|
+
const ownMethods = Object.getOwnPropertyNames(proto)
|
|
1752
|
+
.filter(name => name !== 'constructor')
|
|
1753
|
+
.map(name => opt[name] || name);
|
|
1754
|
+
methodNames.push(...ownMethods);
|
|
1755
|
+
proto = Object.getPrototypeOf(proto);
|
|
1756
|
+
}
|
|
1757
|
+
return methodNames;
|
|
1758
|
+
}
|
|
1759
|
+
const NativeObserverClass = (className, opt = {}) => (target, ctx) => {
|
|
1760
|
+
ctx.addInitializer(function () {
|
|
1761
|
+
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
1762
|
+
value: className,
|
|
1763
|
+
writable: true,
|
|
1764
|
+
});
|
|
1765
|
+
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
1766
|
+
});
|
|
1767
|
+
// @ts-ignore
|
|
1768
|
+
return class extends target {
|
|
1769
|
+
constructor(...args) {
|
|
1770
|
+
super(...args);
|
|
1771
|
+
const t = this;
|
|
1772
|
+
const instanceId = getUuid(className);
|
|
1773
|
+
t.namespace = className;
|
|
1774
|
+
t.instanceId = instanceId;
|
|
1775
|
+
t.messageClient = getMessageClient(t);
|
|
1776
|
+
t.options = opt;
|
|
1777
|
+
// custom consume native event
|
|
1778
|
+
/**
|
|
1779
|
+
* @param this
|
|
1780
|
+
* @param name native method name
|
|
1781
|
+
* @param params
|
|
1782
|
+
*/
|
|
1783
|
+
t.emit = function (name, ...params) {
|
|
1784
|
+
const curName = Object.entries(opt).find(([, v]) => v === name)?.[0] || name;
|
|
1785
|
+
const fn = this[curName];
|
|
1786
|
+
if (typeof fn === 'function') {
|
|
1787
|
+
return fn.apply(this, params);
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
const _init = () => {
|
|
1791
|
+
const events = findMethods(this, opt);
|
|
1792
|
+
t.messageClient.sendNewInstanceCall(className, [events], instanceId, this);
|
|
1793
|
+
};
|
|
1794
|
+
// proxy native created class
|
|
1795
|
+
if (!args.includes(DISABLE_INIT)) {
|
|
1796
|
+
_init();
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
};
|
|
1801
|
+
const NativeClass = (className, opt = {}) => (target, ctx) => {
|
|
1802
|
+
ctx.addInitializer(function () {
|
|
1803
|
+
Object.defineProperty(this, KEY_NAMESPACE, {
|
|
1804
|
+
value: className,
|
|
1805
|
+
writable: true,
|
|
1806
|
+
});
|
|
1807
|
+
Object.defineProperty(this, KEY_NATIVE_CLASS_NAME, { value: className });
|
|
1808
|
+
});
|
|
1809
|
+
// @ts-ignore
|
|
1810
|
+
return class extends target {
|
|
1811
|
+
constructor(...args) {
|
|
1812
|
+
super(...args);
|
|
1813
|
+
const t = this;
|
|
1814
|
+
const instanceId = getUuid(className);
|
|
1815
|
+
t.namespace = className;
|
|
1816
|
+
t.instanceId = instanceId;
|
|
1817
|
+
t.messageClient = getMessageClient(t);
|
|
1818
|
+
const _init = () => {
|
|
1819
|
+
t.messageClient.sendNewInstanceCall(className, args.filter(v => v !== undefined), instanceId, this);
|
|
1820
|
+
if (getOS() === "ios" /* OS.ios */ &&
|
|
1821
|
+
typeof this.init === 'function') {
|
|
1822
|
+
this.init();
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
// proxy native created class
|
|
1826
|
+
if (!args.includes(DISABLE_INIT)) {
|
|
1827
|
+
_init();
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1832
|
+
const NativeStaticMethodSync = (methodSelector) => (target, ctx) => {
|
|
1833
|
+
const name = ctx.name;
|
|
1834
|
+
return function impl(...args) {
|
|
1835
|
+
const namespace = findNamespace(this);
|
|
1836
|
+
const client = getMessageClient(this);
|
|
1837
|
+
const returnValue = client.sendStaticCallSync(namespace || '', methodSelector || name, args);
|
|
1838
|
+
const data = assertReturn(returnValue);
|
|
1839
|
+
return data;
|
|
1840
|
+
};
|
|
1841
|
+
};
|
|
1842
|
+
const ReturnClass = (getCtor) => (target, ctx) => {
|
|
1843
|
+
// TODO: impl
|
|
1844
|
+
return function impl(...args) {
|
|
1845
|
+
const returnValue = target.apply(this, args);
|
|
1846
|
+
if (isPromiseLike(returnValue)) {
|
|
1847
|
+
return returnValue.then(v => {
|
|
1848
|
+
return proxyNativeInstance(v, getCtor());
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
return proxyNativeInstance(returnValue, getCtor());
|
|
1852
|
+
};
|
|
1853
|
+
};
|
|
1854
|
+
const NativeMember = ({ cache, readonly } = {}) => (_, ctx) => {
|
|
1855
|
+
ctx.addInitializer(function () {
|
|
1856
|
+
const field = ctx.name;
|
|
1857
|
+
const key = Symbol.for(ctx.name);
|
|
1858
|
+
Object.defineProperty(this, field, {
|
|
1859
|
+
get: () => {
|
|
1860
|
+
if (cache && this[key] !== undefined) {
|
|
1861
|
+
return this[key];
|
|
1862
|
+
}
|
|
1863
|
+
const { instanceId, namespace } = this;
|
|
1864
|
+
const ret = getMessageClient(this).sendInstanceGet(instanceId, namespace || '', field);
|
|
1865
|
+
const value = assertReturn(ret);
|
|
1866
|
+
this[key] = value;
|
|
1867
|
+
return value;
|
|
1868
|
+
},
|
|
1869
|
+
set: v => {
|
|
1870
|
+
if (readonly) {
|
|
1871
|
+
throw new Error(`field ${field} is readonly.`);
|
|
1872
|
+
}
|
|
1873
|
+
this[key] = v;
|
|
1874
|
+
const { instanceId, namespace } = this;
|
|
1875
|
+
getMessageClient(this).sendInstanceSet(instanceId, namespace || '', field, v);
|
|
1876
|
+
},
|
|
1877
|
+
});
|
|
1878
|
+
});
|
|
1879
|
+
return _;
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
const key = Symbol.for('args');
|
|
1883
|
+
function NativeArgType(argIndex, type) {
|
|
1884
|
+
return function (method, ctx) {
|
|
1885
|
+
const args = (method[key] ?? (method[key] = []));
|
|
1886
|
+
args[argIndex] = type;
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
function processArg(method) {
|
|
1890
|
+
const args = method[key] ?? [];
|
|
1891
|
+
return (arg, idx) => {
|
|
1892
|
+
return args[idx]?.transform(arg) ?? arg;
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
const NativeMethod = (methodSelector, opt) => (_, ctx) => {
|
|
1896
|
+
const name = ctx.name;
|
|
1897
|
+
async function impl(...args) {
|
|
1898
|
+
const { instanceId, namespace } = this;
|
|
1899
|
+
const returnValue = await getMessageClient(this).sendInstanceCall(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(v => v !== undefined), opt);
|
|
1900
|
+
const data = assertReturn(returnValue);
|
|
1901
|
+
return data;
|
|
1902
|
+
}
|
|
1903
|
+
return impl;
|
|
1904
|
+
};
|
|
1905
|
+
const NativeMethodSync = (methodSelector, opt) => (_, ctx) => {
|
|
1906
|
+
const name = ctx.name;
|
|
1907
|
+
function impl(...args) {
|
|
1908
|
+
const { instanceId, namespace } = this;
|
|
1909
|
+
const returnValue = getMessageClient(this).sendInstanceCallSync(instanceId, namespace || '', methodSelector || name, args.map(processArg(_)).filter(v => v !== undefined), opt);
|
|
1910
|
+
const data = assertReturn(returnValue);
|
|
1911
|
+
return data;
|
|
1912
|
+
}
|
|
1913
|
+
return impl;
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1916
|
+
const NativeVar = (varName, ctor) => (_, ctx) => {
|
|
1917
|
+
return async function impl(...args) {
|
|
1918
|
+
const client = getMessageClient(this);
|
|
1919
|
+
const ret = await client.sendVarGet(varName, args);
|
|
1920
|
+
const ins = new ctor(DISABLE_INIT);
|
|
1921
|
+
ins.instanceId = ret.msg._instanceId;
|
|
1922
|
+
ins.messageClient = client;
|
|
1923
|
+
ins.namespace = '$var';
|
|
1924
|
+
return ins;
|
|
1925
|
+
};
|
|
1926
|
+
};
|
|
1927
|
+
|
|
1928
|
+
(() => {
|
|
1929
|
+
var _a;
|
|
1930
|
+
let _instanceExtraInitializers = [];
|
|
1931
|
+
let _on_decorators;
|
|
1932
|
+
let _emit_decorators;
|
|
1933
|
+
return _a = class NativeObserver {
|
|
1934
|
+
constructor(className) {
|
|
1935
|
+
this._events = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1936
|
+
this.namespace = className;
|
|
1937
|
+
this.instanceId = getUuid(className);
|
|
1938
|
+
this.messageClient = getGlobalMessageClient();
|
|
1939
|
+
this._events = {};
|
|
1940
|
+
}
|
|
1941
|
+
on(ev, handler) {
|
|
1942
|
+
let handlers = this._events[ev];
|
|
1943
|
+
if (!handlers) {
|
|
1944
|
+
handlers = [];
|
|
1945
|
+
this._events[ev] = handlers;
|
|
1946
|
+
}
|
|
1947
|
+
if (handlers.length === 0) {
|
|
1948
|
+
// 第一次,通知 native 注册
|
|
1949
|
+
this.messageClient.sendInstanceEventAdd(this.instanceId, this.namespace || '', ev);
|
|
1950
|
+
}
|
|
1951
|
+
handlers.push(handler);
|
|
1952
|
+
}
|
|
1953
|
+
emit(ev, ...args) {
|
|
1954
|
+
const handlers = this._events[ev];
|
|
1955
|
+
// console.log('emit:', ev, args.length);
|
|
1956
|
+
handlers?.forEach(cb => {
|
|
1957
|
+
cb(...args);
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
(() => {
|
|
1962
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1963
|
+
_on_decorators = [Bind];
|
|
1964
|
+
_emit_decorators = [Bind];
|
|
1965
|
+
__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);
|
|
1966
|
+
__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);
|
|
1967
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1968
|
+
})(),
|
|
1969
|
+
_a;
|
|
1970
|
+
})();
|
|
1971
|
+
(() => {
|
|
1972
|
+
var _a;
|
|
1973
|
+
let _instanceExtraInitializers = [];
|
|
1974
|
+
let _on_decorators;
|
|
1975
|
+
let _emit_decorators;
|
|
1976
|
+
return _a = class NativeObserverProxy {
|
|
1977
|
+
constructor() {
|
|
1978
|
+
this.__observer = __runInitializers$1(this, _instanceExtraInitializers);
|
|
1979
|
+
}
|
|
1980
|
+
on(ev, handler) {
|
|
1981
|
+
this.__observer.on(ev, handler);
|
|
1982
|
+
}
|
|
1983
|
+
emit(ev, ...args) {
|
|
1984
|
+
this.__observer.emit(ev, ...args);
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
(() => {
|
|
1988
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
1989
|
+
_on_decorators = [Bind];
|
|
1990
|
+
_emit_decorators = [Bind];
|
|
1991
|
+
__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);
|
|
1992
|
+
__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);
|
|
1993
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1994
|
+
})(),
|
|
1995
|
+
_a;
|
|
1996
|
+
})();
|
|
1997
|
+
|
|
1998
|
+
class NativeView {
|
|
1999
|
+
static getView(viewId, ctor) {
|
|
2000
|
+
const _ins = new ctor(viewId);
|
|
2001
|
+
const ins = initViewProxyObject(_ins, viewId);
|
|
2002
|
+
return ins;
|
|
2003
|
+
}
|
|
2004
|
+
constructor(viewId) {
|
|
2005
|
+
this.viewId = viewId;
|
|
2006
|
+
initViewProxyObject(this, viewId);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function initViewProxyObject(obj, viewId) {
|
|
2010
|
+
obj.instanceId = obj._instanceId = viewId;
|
|
2011
|
+
obj.namespace = obj._serviceName = '$View';
|
|
2012
|
+
obj._type = "instance" /* ARG_TYPE.INSTANCE */;
|
|
2013
|
+
return obj;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
const NativeImageResource = {
|
|
2017
|
+
transform(origin) {
|
|
2018
|
+
const r = {
|
|
2019
|
+
...resolveImageResource(origin),
|
|
2020
|
+
};
|
|
2021
|
+
return r;
|
|
2022
|
+
},
|
|
2023
|
+
};
|
|
2024
|
+
// ios
|
|
2025
|
+
const UIImage = NativeImageResource;
|
|
2026
|
+
// android
|
|
2027
|
+
const Bitmap = NativeImageResource;
|
|
2028
|
+
|
|
2029
|
+
var nativeType = /*#__PURE__*/Object.freeze({
|
|
2030
|
+
__proto__: null,
|
|
2031
|
+
Bitmap: Bitmap,
|
|
2032
|
+
NativeImageResource: NativeImageResource,
|
|
2033
|
+
UIImage: UIImage
|
|
2034
|
+
});
|
|
2035
|
+
|
|
2779
2036
|
var BRIDGE_NATIVE_API;
|
|
2780
2037
|
(function (BRIDGE_NATIVE_API) {
|
|
2781
2038
|
BRIDGE_NATIVE_API["CALL_API"] = "callApi";
|
|
@@ -2823,10 +2080,6 @@ var CALL_TYPE;
|
|
|
2823
2080
|
* 事件执行后的返回值
|
|
2824
2081
|
*/
|
|
2825
2082
|
CALL_TYPE["INSTANCE_EVENT_RESULT"] = "instance_event_result";
|
|
2826
|
-
/**
|
|
2827
|
-
* 销毁实例
|
|
2828
|
-
*/
|
|
2829
|
-
CALL_TYPE["DESTROY_INSTANCE"] = "destroy_instance";
|
|
2830
2083
|
/**
|
|
2831
2084
|
* 触发事件
|
|
2832
2085
|
*/
|
|
@@ -2838,58 +2091,44 @@ var RETURN_STATUS;
|
|
|
2838
2091
|
RETURN_STATUS["FAILED"] = "failed";
|
|
2839
2092
|
RETURN_STATUS["NOT_IMPLEMENTED"] = "not_implemented";
|
|
2840
2093
|
})(RETURN_STATUS || (RETURN_STATUS = {}));
|
|
2841
|
-
var INSTANCE_TYPE;
|
|
2842
|
-
(function (INSTANCE_TYPE) {
|
|
2843
|
-
/**
|
|
2844
|
-
* 自动 GC 类型
|
|
2845
|
-
*/
|
|
2846
|
-
INSTANCE_TYPE[INSTANCE_TYPE["AUTOMATIC"] = 0] = "AUTOMATIC";
|
|
2847
|
-
/**
|
|
2848
|
-
* 手动 GC 类型
|
|
2849
|
-
*/
|
|
2850
|
-
INSTANCE_TYPE[INSTANCE_TYPE["MANUAL"] = 1] = "MANUAL";
|
|
2851
|
-
})(INSTANCE_TYPE || (INSTANCE_TYPE = {}));
|
|
2852
2094
|
|
|
2853
|
-
|
|
2854
|
-
|
|
2095
|
+
class ReactNativeBridge {
|
|
2096
|
+
constructor(BridgeModule, NativeEventName) {
|
|
2855
2097
|
this.BridgeModule = BridgeModule;
|
|
2856
2098
|
this.NativeEventName = NativeEventName;
|
|
2857
2099
|
this._handlers = {};
|
|
2858
2100
|
if (BridgeModule === undefined) {
|
|
2859
|
-
throw new Error(
|
|
2101
|
+
throw new Error(`can't find module "${BridgeModule}", please enure install the module correctly`);
|
|
2860
2102
|
}
|
|
2861
2103
|
this._nativeEventEmitter = new reactNative.NativeEventEmitter(BridgeModule);
|
|
2862
2104
|
this._init();
|
|
2863
2105
|
}
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
this._nativeEventEmitter.addListener(this.NativeEventName, function (ev) {
|
|
2867
|
-
var _a, _b;
|
|
2106
|
+
_init() {
|
|
2107
|
+
this._nativeEventEmitter.addListener(this.NativeEventName, (ev) => {
|
|
2868
2108
|
try {
|
|
2869
|
-
|
|
2870
|
-
|
|
2109
|
+
const eventName = ev.event;
|
|
2110
|
+
const eventData = typeof ev.data === 'string' ? JSON.parse(ev.data) : ev.data;
|
|
2871
2111
|
// console.log(`handle native event:`, ev, eventData);
|
|
2872
|
-
|
|
2112
|
+
this._handlers[eventName]?.(eventData);
|
|
2873
2113
|
}
|
|
2874
2114
|
catch (err) {
|
|
2875
2115
|
console.error('handle native event fail:', err);
|
|
2876
2116
|
}
|
|
2877
2117
|
});
|
|
2878
|
-
}
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
return new Promise(function (resolve, reject) {
|
|
2118
|
+
}
|
|
2119
|
+
call(params) {
|
|
2120
|
+
return new Promise((resolve, reject) => {
|
|
2882
2121
|
// console.debug(`<Bridge> js call native "${handlerName}()":`, ...args);
|
|
2883
2122
|
try {
|
|
2884
|
-
|
|
2885
|
-
|
|
2123
|
+
let resolved = false;
|
|
2124
|
+
this.BridgeModule[BRIDGE_NATIVE_API.CALL_API]({ params: JSON.stringify(params) }, (res) => {
|
|
2886
2125
|
// console.log('async call value:', res);
|
|
2887
|
-
|
|
2888
|
-
|
|
2126
|
+
const val = typeof res === 'string' ? JSON.parse(res) : res;
|
|
2127
|
+
resolved = true;
|
|
2889
2128
|
resolve(val);
|
|
2890
2129
|
});
|
|
2891
|
-
setTimeout(
|
|
2892
|
-
if (
|
|
2130
|
+
setTimeout(() => {
|
|
2131
|
+
if (resolved) {
|
|
2893
2132
|
return;
|
|
2894
2133
|
}
|
|
2895
2134
|
resolve({
|
|
@@ -2903,11 +2142,11 @@ var ReactNativeBridge = /** @class */ (function () {
|
|
|
2903
2142
|
reject(err);
|
|
2904
2143
|
}
|
|
2905
2144
|
});
|
|
2906
|
-
}
|
|
2907
|
-
|
|
2145
|
+
}
|
|
2146
|
+
callSync(params) {
|
|
2908
2147
|
// console.debug(`<Bridge> js call native "${handlerName}()":`, ...args);
|
|
2909
2148
|
try {
|
|
2910
|
-
|
|
2149
|
+
const res = this.BridgeModule[BRIDGE_NATIVE_API.CALL_API_SYNC]({
|
|
2911
2150
|
params: JSON.stringify(params),
|
|
2912
2151
|
});
|
|
2913
2152
|
// console.debug(`<Bridge> native return "${handlerName}()":`, res, args)
|
|
@@ -2917,61 +2156,27 @@ var ReactNativeBridge = /** @class */ (function () {
|
|
|
2917
2156
|
// console.error(`<RNBridge> call native "${handlerName}()" fail`, err);
|
|
2918
2157
|
throw err;
|
|
2919
2158
|
}
|
|
2920
|
-
}
|
|
2921
|
-
|
|
2159
|
+
}
|
|
2160
|
+
registerHandler(handlerName, handler) {
|
|
2922
2161
|
this._handlers[handlerName] = handler;
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2162
|
+
}
|
|
2163
|
+
registerAsyncHandler(handlerName, handler) {
|
|
2925
2164
|
this._handlers[handlerName] = handler;
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
|
-
}());
|
|
2929
|
-
|
|
2930
|
-
/******************************************************************************
|
|
2931
|
-
Copyright (c) Microsoft Corporation.
|
|
2932
|
-
|
|
2933
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2934
|
-
purpose with or without fee is hereby granted.
|
|
2935
|
-
|
|
2936
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2937
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2938
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2939
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2940
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2941
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2942
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2943
|
-
***************************************************************************** */
|
|
2944
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
var __assign = function() {
|
|
2948
|
-
__assign = Object.assign || function __assign(t) {
|
|
2949
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2950
|
-
s = arguments[i];
|
|
2951
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2952
|
-
}
|
|
2953
|
-
return t;
|
|
2954
|
-
};
|
|
2955
|
-
return __assign.apply(this, arguments);
|
|
2956
|
-
};
|
|
2957
|
-
|
|
2958
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2959
|
-
var e = new Error(message);
|
|
2960
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2961
|
-
};
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2962
2167
|
|
|
2963
|
-
|
|
2964
|
-
|
|
2168
|
+
class ReactNativeEnv {
|
|
2169
|
+
resolveImageResource(input) {
|
|
2170
|
+
const r = reactNative.Image.resolveAssetSource(input);
|
|
2171
|
+
return {
|
|
2172
|
+
...r,
|
|
2173
|
+
_type: "image_resource" /* ARG_TYPE.IMAGE_RESOURCE */,
|
|
2174
|
+
};
|
|
2965
2175
|
}
|
|
2966
|
-
|
|
2967
|
-
var r = reactNative.Image.resolveAssetSource(input);
|
|
2968
|
-
return __assign(__assign({}, r), { _type: "image_resource" /* ARG_TYPE.IMAGE_RESOURCE */ });
|
|
2969
|
-
};
|
|
2970
|
-
ReactNativeEnv.prototype.os = function () {
|
|
2176
|
+
os() {
|
|
2971
2177
|
return reactNative.Platform.OS;
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
}());
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2975
2180
|
|
|
2976
2181
|
/******************************************************************************
|
|
2977
2182
|
Copyright (c) Microsoft Corporation.
|
|
@@ -12324,57 +11529,57 @@ var VeLivePusherErrorCode$1;
|
|
|
12324
11529
|
* @brief License 错误,可能 License 集成错误或 License 过期,请检查 License 集成方式和有效性。
|
|
12325
11530
|
*
|
|
12326
11531
|
*/
|
|
12327
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidLicense"] = 1] = "VeLivePusherInvalidLicense";
|
|
11532
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidLicense"] = -1] = "VeLivePusherInvalidLicense";
|
|
12328
11533
|
/** {zh}
|
|
12329
11534
|
* @brief 参数错误,请检查入参,并重新调用。
|
|
12330
11535
|
*
|
|
12331
11536
|
*/
|
|
12332
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidParameter"] = 2] = "VeLivePusherInvalidParameter";
|
|
11537
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidParameter"] = -2] = "VeLivePusherInvalidParameter";
|
|
12333
11538
|
/** {zh}
|
|
12334
11539
|
* @brief 视频采集错误,可能未开启设备视频采集权限,请检查权限是否获取。
|
|
12335
11540
|
*
|
|
12336
11541
|
*/
|
|
12337
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoCaptureError"] = 3] = "VeLivePusherVideoCaptureError";
|
|
11542
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoCaptureError"] = -3] = "VeLivePusherVideoCaptureError";
|
|
12338
11543
|
/** {zh}
|
|
12339
11544
|
* @brief 音频采集错误,可能未开启设备麦克风采集权限,请检查权限是否获取。
|
|
12340
11545
|
*
|
|
12341
11546
|
*/
|
|
12342
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioCaptureError"] = 4] = "VeLivePusherAudioCaptureError";
|
|
11547
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioCaptureError"] = -4] = "VeLivePusherAudioCaptureError";
|
|
12343
11548
|
/** {zh}
|
|
12344
11549
|
* @brief 视频编码错误,可能配置了当前设备不支持的视频编码方式,请检查编码参数,并重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12345
11550
|
*
|
|
12346
11551
|
*/
|
|
12347
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEncoderError"] = 5] = "VeLivePusherVideoEncoderError";
|
|
11552
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEncoderError"] = -5] = "VeLivePusherVideoEncoderError";
|
|
12348
11553
|
/** {zh}
|
|
12349
11554
|
* @brief 音频编码错误,可能配置了当前设备不支持的音频编码方式,请检查编码参数,并重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12350
11555
|
*
|
|
12351
11556
|
*/
|
|
12352
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioEncoderError"] = 6] = "VeLivePusherAudioEncoderError";
|
|
11557
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioEncoderError"] = -6] = "VeLivePusherAudioEncoderError";
|
|
12353
11558
|
/** {zh}
|
|
12354
11559
|
* @brief 网络发送错误,可能当前网络链路不通,或者开启了代理和关闭了网络权限,请检查网络后重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12355
11560
|
*
|
|
12356
11561
|
*/
|
|
12357
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherTransportError"] = 7] = "VeLivePusherTransportError";
|
|
11562
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherTransportError"] = -7] = "VeLivePusherTransportError";
|
|
12358
11563
|
/** {zh}
|
|
12359
11564
|
* @brief 视频特效错误,请检查视频特效 SDK 是否已经集成并且初试化成功。检查特效资源路径是否配置正确。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12360
11565
|
*
|
|
12361
11566
|
*/
|
|
12362
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEffectError"] = 8] = "VeLivePusherVideoEffectError";
|
|
11567
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEffectError"] = -8] = "VeLivePusherVideoEffectError";
|
|
12363
11568
|
/** {zh}
|
|
12364
11569
|
* @brief 音频模块错误,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12365
11570
|
*
|
|
12366
11571
|
*/
|
|
12367
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioDeviceError"] = 9] = "VeLivePusherAudioDeviceError";
|
|
11572
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioDeviceError"] = -9] = "VeLivePusherAudioDeviceError";
|
|
12368
11573
|
/** {zh}
|
|
12369
11574
|
* @brief 您使用的基础版 License 暂不支持 H.265 硬件编码,请登录火山引擎控制台获取高级版 License。
|
|
12370
11575
|
*
|
|
12371
11576
|
*/
|
|
12372
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherLicenseUnsupportedH265"] = 10] = "VeLivePusherLicenseUnsupportedH265";
|
|
11577
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherLicenseUnsupportedH265"] = -10] = "VeLivePusherLicenseUnsupportedH265";
|
|
12373
11578
|
/** {zh}
|
|
12374
11579
|
* @brief 其他错误类型,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
12375
11580
|
*
|
|
12376
11581
|
*/
|
|
12377
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherError"] =
|
|
11582
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherError"] = -100] = "VeLivePusherError";
|
|
12378
11583
|
})(VeLivePusherErrorCode$1 || (VeLivePusherErrorCode$1 = {}));
|
|
12379
11584
|
|
|
12380
11585
|
(function () {
|
|
@@ -16853,39 +16058,6 @@ exports.VeLiveAudioBufferType = void 0;
|
|
|
16853
16058
|
*/
|
|
16854
16059
|
VeLiveAudioBufferType[VeLiveAudioBufferType["VeLiveAudioBufferTypeNSData"] = 3] = "VeLiveAudioBufferTypeNSData";
|
|
16855
16060
|
})(exports.VeLiveAudioBufferType || (exports.VeLiveAudioBufferType = {}));
|
|
16856
|
-
/** {zh}
|
|
16857
|
-
* @detail keytype
|
|
16858
|
-
* @brief 定义了推流中首帧的类型,包括音视频的采集首帧、渲染首帧、编码完成首帧和发送首帧。
|
|
16859
|
-
*
|
|
16860
|
-
*/
|
|
16861
|
-
exports.VeLiveFirstFrameType = void 0;
|
|
16862
|
-
(function (VeLiveFirstFrameType) {
|
|
16863
|
-
/** {zh}
|
|
16864
|
-
* @brief 视频/音频采集首帧,采集首帧是从音频设备或视频设备(如麦克风、摄像头)获取的第一帧数据。
|
|
16865
|
-
*
|
|
16866
|
-
*/
|
|
16867
|
-
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstCaptureFrame"] = 0] = "VeLiveFirstCaptureFrame";
|
|
16868
|
-
/** {zh}
|
|
16869
|
-
* @brief 视频渲染首帧,渲染首帧是在渲染过程中在屏幕上显示的第一帧视频数据。
|
|
16870
|
-
*
|
|
16871
|
-
*/
|
|
16872
|
-
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstRenderFrame"] = 1] = "VeLiveFirstRenderFrame";
|
|
16873
|
-
/** {zh}
|
|
16874
|
-
* @brief 视频/音频编码完成首帧,编码完成首帧是编码为某种特定格式的第一帧数据。
|
|
16875
|
-
*
|
|
16876
|
-
*/
|
|
16877
|
-
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstEncodedFrame"] = 2] = "VeLiveFirstEncodedFrame";
|
|
16878
|
-
/** {zh}
|
|
16879
|
-
* @brief 视频/音频发送首帧,发送首帧是在发送过程中,通过网络传输的第一帧数据。
|
|
16880
|
-
*
|
|
16881
|
-
*/
|
|
16882
|
-
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstSendFrame"] = 3] = "VeLiveFirstSendFrame";
|
|
16883
|
-
/** {zh}
|
|
16884
|
-
* @platform ios
|
|
16885
|
-
* @brief 录屏采集开始后,获得的第一个 app 音频帧。
|
|
16886
|
-
*/
|
|
16887
|
-
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstAppAudioCaptureFrame"] = 4] = "VeLiveFirstAppAudioCaptureFrame";
|
|
16888
|
-
})(exports.VeLiveFirstFrameType || (exports.VeLiveFirstFrameType = {}));
|
|
16889
16061
|
/** {zh}
|
|
16890
16062
|
* @detail keytype
|
|
16891
16063
|
* @brief 视频采集类型。
|
|
@@ -18531,6 +17703,39 @@ exports.VeLiveAudioChannel = void 0;
|
|
|
18531
17703
|
*/
|
|
18532
17704
|
VeLiveAudioChannel[VeLiveAudioChannel["VeLiveAudioChannelStereo"] = 1] = "VeLiveAudioChannelStereo";
|
|
18533
17705
|
})(exports.VeLiveAudioChannel || (exports.VeLiveAudioChannel = {}));
|
|
17706
|
+
/** {zh}
|
|
17707
|
+
* @detail keytype
|
|
17708
|
+
* @brief 定义了推流中首帧的类型,包括音视频的采集首帧、渲染首帧、编码完成首帧和发送首帧。
|
|
17709
|
+
*
|
|
17710
|
+
*/
|
|
17711
|
+
exports.VeLiveFirstFrameType = void 0;
|
|
17712
|
+
(function (VeLiveFirstFrameType) {
|
|
17713
|
+
/** {zh}
|
|
17714
|
+
* @brief 视频/音频采集首帧,采集首帧是从音频设备或视频设备(如麦克风、摄像头)获取的第一帧数据。
|
|
17715
|
+
*
|
|
17716
|
+
*/
|
|
17717
|
+
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstCaptureFrame"] = 0] = "VeLiveFirstCaptureFrame";
|
|
17718
|
+
/** {zh}
|
|
17719
|
+
* @brief 视频渲染首帧,渲染首帧是在渲染过程中在屏幕上显示的第一帧视频数据。
|
|
17720
|
+
*
|
|
17721
|
+
*/
|
|
17722
|
+
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstRenderFrame"] = 1] = "VeLiveFirstRenderFrame";
|
|
17723
|
+
/** {zh}
|
|
17724
|
+
* @brief 视频/音频编码完成首帧,编码完成首帧是编码为某种特定格式的第一帧数据。
|
|
17725
|
+
*
|
|
17726
|
+
*/
|
|
17727
|
+
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstEncodedFrame"] = 2] = "VeLiveFirstEncodedFrame";
|
|
17728
|
+
/** {zh}
|
|
17729
|
+
* @brief 视频/音频发送首帧,发送首帧是在发送过程中,通过网络传输的第一帧数据。
|
|
17730
|
+
*
|
|
17731
|
+
*/
|
|
17732
|
+
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstSendFrame"] = 3] = "VeLiveFirstSendFrame";
|
|
17733
|
+
/** {zh}
|
|
17734
|
+
* @platform ios
|
|
17735
|
+
* @brief 录屏采集开始后,获得的第一个 app 音频帧。
|
|
17736
|
+
*/
|
|
17737
|
+
VeLiveFirstFrameType[VeLiveFirstFrameType["VeLiveFirstAppAudioCaptureFrame"] = 4] = "VeLiveFirstAppAudioCaptureFrame";
|
|
17738
|
+
})(exports.VeLiveFirstFrameType || (exports.VeLiveFirstFrameType = {}));
|
|
18534
17739
|
/** {zh}
|
|
18535
17740
|
* @detail keytype
|
|
18536
17741
|
* @brief 视频帧来源。
|
|
@@ -20373,69 +19578,6 @@ var t_VeLiveAudioBufferType = /** @class */ (function () {
|
|
|
20373
19578
|
};
|
|
20374
19579
|
return t_VeLiveAudioBufferType;
|
|
20375
19580
|
}());
|
|
20376
|
-
var t_VeLiveFirstFrameType = /** @class */ (function () {
|
|
20377
|
-
function t_VeLiveFirstFrameType() {
|
|
20378
|
-
}
|
|
20379
|
-
t_VeLiveFirstFrameType.ts_to_android = function (value) {
|
|
20380
|
-
var _a;
|
|
20381
|
-
var $m = (_a = {},
|
|
20382
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = VeLiveFirstFrameType$1.VeLiveFirstCaptureFrame,
|
|
20383
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame] = VeLiveFirstFrameType$1.VeLiveFirstRenderFrame,
|
|
20384
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = VeLiveFirstFrameType$1.VeLiveFirstEncodedFrame,
|
|
20385
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstSendFrame] = VeLiveFirstFrameType$1.VeLiveFirstSendFrame,
|
|
20386
|
-
_a);
|
|
20387
|
-
if (!(value in $m)) {
|
|
20388
|
-
throw new Error('android not support:' + value);
|
|
20389
|
-
}
|
|
20390
|
-
// @ts-ignore
|
|
20391
|
-
return $m[value];
|
|
20392
|
-
};
|
|
20393
|
-
t_VeLiveFirstFrameType.android_to_ts = function (value) {
|
|
20394
|
-
var _a;
|
|
20395
|
-
var $m = (_a = {},
|
|
20396
|
-
_a[VeLiveFirstFrameType$1.VeLiveFirstCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20397
|
-
_a[VeLiveFirstFrameType$1.VeLiveFirstRenderFrame] = exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20398
|
-
_a[VeLiveFirstFrameType$1.VeLiveFirstEncodedFrame] = exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20399
|
-
_a[VeLiveFirstFrameType$1.VeLiveFirstSendFrame] = exports.VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20400
|
-
_a);
|
|
20401
|
-
if (!(value in $m)) {
|
|
20402
|
-
throw new Error('invalid value:' + value);
|
|
20403
|
-
}
|
|
20404
|
-
// @ts-ignore
|
|
20405
|
-
return $m[value];
|
|
20406
|
-
};
|
|
20407
|
-
t_VeLiveFirstFrameType.ts_to_ios = function (value) {
|
|
20408
|
-
var _a;
|
|
20409
|
-
var $m = (_a = {},
|
|
20410
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20411
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame] = VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20412
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20413
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstSendFrame] = VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20414
|
-
_a[exports.VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame] = VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame,
|
|
20415
|
-
_a);
|
|
20416
|
-
if (!(value in $m)) {
|
|
20417
|
-
throw new Error('ios not support:' + value);
|
|
20418
|
-
}
|
|
20419
|
-
// @ts-ignore
|
|
20420
|
-
return $m[value];
|
|
20421
|
-
};
|
|
20422
|
-
t_VeLiveFirstFrameType.ios_to_ts = function (value) {
|
|
20423
|
-
var _a;
|
|
20424
|
-
var $m = (_a = {},
|
|
20425
|
-
_a[VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20426
|
-
_a[VeLiveFirstFrameType.VeLiveFirstRenderFrame] = exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20427
|
-
_a[VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20428
|
-
_a[VeLiveFirstFrameType.VeLiveFirstSendFrame] = exports.VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20429
|
-
_a[VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame,
|
|
20430
|
-
_a);
|
|
20431
|
-
if (!(value in $m)) {
|
|
20432
|
-
throw new Error('invalid value:' + value);
|
|
20433
|
-
}
|
|
20434
|
-
// @ts-ignore
|
|
20435
|
-
return $m[value];
|
|
20436
|
-
};
|
|
20437
|
-
return t_VeLiveFirstFrameType;
|
|
20438
|
-
}());
|
|
20439
19581
|
var t_VeLiveVideoCaptureType = /** @class */ (function () {
|
|
20440
19582
|
function t_VeLiveVideoCaptureType() {
|
|
20441
19583
|
}
|
|
@@ -21025,6 +20167,69 @@ var t_VeLiveVideoCodec = /** @class */ (function () {
|
|
|
21025
20167
|
};
|
|
21026
20168
|
return t_VeLiveVideoCodec;
|
|
21027
20169
|
}());
|
|
20170
|
+
var t_VeLiveFirstFrameType = /** @class */ (function () {
|
|
20171
|
+
function t_VeLiveFirstFrameType() {
|
|
20172
|
+
}
|
|
20173
|
+
t_VeLiveFirstFrameType.ts_to_android = function (value) {
|
|
20174
|
+
var _a;
|
|
20175
|
+
var $m = (_a = {},
|
|
20176
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = VeLiveFirstFrameType$1.VeLiveFirstCaptureFrame,
|
|
20177
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame] = VeLiveFirstFrameType$1.VeLiveFirstRenderFrame,
|
|
20178
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = VeLiveFirstFrameType$1.VeLiveFirstEncodedFrame,
|
|
20179
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstSendFrame] = VeLiveFirstFrameType$1.VeLiveFirstSendFrame,
|
|
20180
|
+
_a);
|
|
20181
|
+
if (!(value in $m)) {
|
|
20182
|
+
throw new Error('android not support:' + value);
|
|
20183
|
+
}
|
|
20184
|
+
// @ts-ignore
|
|
20185
|
+
return $m[value];
|
|
20186
|
+
};
|
|
20187
|
+
t_VeLiveFirstFrameType.android_to_ts = function (value) {
|
|
20188
|
+
var _a;
|
|
20189
|
+
var $m = (_a = {},
|
|
20190
|
+
_a[VeLiveFirstFrameType$1.VeLiveFirstCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20191
|
+
_a[VeLiveFirstFrameType$1.VeLiveFirstRenderFrame] = exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20192
|
+
_a[VeLiveFirstFrameType$1.VeLiveFirstEncodedFrame] = exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20193
|
+
_a[VeLiveFirstFrameType$1.VeLiveFirstSendFrame] = exports.VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20194
|
+
_a);
|
|
20195
|
+
if (!(value in $m)) {
|
|
20196
|
+
throw new Error('invalid value:' + value);
|
|
20197
|
+
}
|
|
20198
|
+
// @ts-ignore
|
|
20199
|
+
return $m[value];
|
|
20200
|
+
};
|
|
20201
|
+
t_VeLiveFirstFrameType.ts_to_ios = function (value) {
|
|
20202
|
+
var _a;
|
|
20203
|
+
var $m = (_a = {},
|
|
20204
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20205
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame] = VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20206
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20207
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstSendFrame] = VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20208
|
+
_a[exports.VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame] = VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame,
|
|
20209
|
+
_a);
|
|
20210
|
+
if (!(value in $m)) {
|
|
20211
|
+
throw new Error('ios not support:' + value);
|
|
20212
|
+
}
|
|
20213
|
+
// @ts-ignore
|
|
20214
|
+
return $m[value];
|
|
20215
|
+
};
|
|
20216
|
+
t_VeLiveFirstFrameType.ios_to_ts = function (value) {
|
|
20217
|
+
var _a;
|
|
20218
|
+
var $m = (_a = {},
|
|
20219
|
+
_a[VeLiveFirstFrameType.VeLiveFirstCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstCaptureFrame,
|
|
20220
|
+
_a[VeLiveFirstFrameType.VeLiveFirstRenderFrame] = exports.VeLiveFirstFrameType.VeLiveFirstRenderFrame,
|
|
20221
|
+
_a[VeLiveFirstFrameType.VeLiveFirstEncodedFrame] = exports.VeLiveFirstFrameType.VeLiveFirstEncodedFrame,
|
|
20222
|
+
_a[VeLiveFirstFrameType.VeLiveFirstSendFrame] = exports.VeLiveFirstFrameType.VeLiveFirstSendFrame,
|
|
20223
|
+
_a[VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame] = exports.VeLiveFirstFrameType.VeLiveFirstAppAudioCaptureFrame,
|
|
20224
|
+
_a);
|
|
20225
|
+
if (!(value in $m)) {
|
|
20226
|
+
throw new Error('invalid value:' + value);
|
|
20227
|
+
}
|
|
20228
|
+
// @ts-ignore
|
|
20229
|
+
return $m[value];
|
|
20230
|
+
};
|
|
20231
|
+
return t_VeLiveFirstFrameType;
|
|
20232
|
+
}());
|
|
21028
20233
|
var t_VeLiveVideoMirrorType = /** @class */ (function () {
|
|
21029
20234
|
function t_VeLiveVideoMirrorType() {
|
|
21030
20235
|
}
|
|
@@ -27324,58 +26529,58 @@ exports.VeLivePusherErrorCode = void 0;
|
|
|
27324
26529
|
* @brief License 错误,可能 License 集成错误或 License 过期,请检查 License 集成方式和有效性。
|
|
27325
26530
|
*
|
|
27326
26531
|
*/
|
|
27327
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidLicense"] = 1] = "VeLivePusherInvalidLicense";
|
|
26532
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidLicense"] = -1] = "VeLivePusherInvalidLicense";
|
|
27328
26533
|
/** {zh}
|
|
27329
26534
|
* @brief 参数错误,请检查入参,并重新调用。
|
|
27330
26535
|
*
|
|
27331
26536
|
*/
|
|
27332
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidParameter"] = 2] = "VeLivePusherInvalidParameter";
|
|
26537
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherInvalidParameter"] = -2] = "VeLivePusherInvalidParameter";
|
|
27333
26538
|
/** {zh}
|
|
27334
26539
|
* @brief 视频采集错误,可能未开启设备视频采集权限,请检查权限是否获取。
|
|
27335
26540
|
*
|
|
27336
26541
|
*/
|
|
27337
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoCaptureError"] = 3] = "VeLivePusherVideoCaptureError";
|
|
26542
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoCaptureError"] = -3] = "VeLivePusherVideoCaptureError";
|
|
27338
26543
|
/** {zh}
|
|
27339
26544
|
* @brief 音频采集错误,可能未开启设备麦克风采集权限,请检查权限是否获取。
|
|
27340
26545
|
*
|
|
27341
26546
|
*/
|
|
27342
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioCaptureError"] = 4] = "VeLivePusherAudioCaptureError";
|
|
26547
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioCaptureError"] = -4] = "VeLivePusherAudioCaptureError";
|
|
27343
26548
|
/** {zh}
|
|
27344
26549
|
* @brief 视频编码错误,可能配置了当前设备不支持的视频编码方式,请检查编码参数,并重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27345
26550
|
*
|
|
27346
26551
|
*/
|
|
27347
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEncoderError"] = 5] = "VeLivePusherVideoEncoderError";
|
|
26552
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEncoderError"] = -5] = "VeLivePusherVideoEncoderError";
|
|
27348
26553
|
/** {zh}
|
|
27349
26554
|
* @brief 音频编码错误,可能配置了当前设备不支持的音频编码方式,请检查编码参数,并重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27350
26555
|
*
|
|
27351
26556
|
*/
|
|
27352
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioEncoderError"] = 6] = "VeLivePusherAudioEncoderError";
|
|
26557
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioEncoderError"] = -6] = "VeLivePusherAudioEncoderError";
|
|
27353
26558
|
/** {zh}
|
|
27354
26559
|
* @brief 网络发送错误,可能当前网络链路不通,或者开启了代理和关闭了网络权限,请检查网络后重新调用。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27355
26560
|
*
|
|
27356
26561
|
*/
|
|
27357
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherTransportError"] = 7] = "VeLivePusherTransportError";
|
|
26562
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherTransportError"] = -7] = "VeLivePusherTransportError";
|
|
27358
26563
|
/** {zh}
|
|
27359
26564
|
* @brief 视频特效错误,请检查视频特效 SDK 是否已经集成并且初试化成功。检查特效资源路径是否配置正确。如果故障未排除,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27360
26565
|
*
|
|
27361
26566
|
*/
|
|
27362
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEffectError"] = 8] = "VeLivePusherVideoEffectError";
|
|
26567
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherVideoEffectError"] = -8] = "VeLivePusherVideoEffectError";
|
|
27363
26568
|
/** {zh}
|
|
27364
26569
|
* @brief 音频模块错误,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27365
26570
|
*
|
|
27366
26571
|
*/
|
|
27367
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioDeviceError"] = 9] = "VeLivePusherAudioDeviceError";
|
|
26572
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherAudioDeviceError"] = -9] = "VeLivePusherAudioDeviceError";
|
|
27368
26573
|
/** {zh}
|
|
27369
26574
|
* @platform android
|
|
27370
26575
|
* @brief 您使用的基础版 License 暂不支持 H.265 硬件编码,请登录火山引擎控制台获取高级版 License。
|
|
27371
26576
|
*
|
|
27372
26577
|
*/
|
|
27373
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherLicenseUnsupportedH265"] = 10] = "VeLivePusherLicenseUnsupportedH265";
|
|
26578
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherLicenseUnsupportedH265"] = -10] = "VeLivePusherLicenseUnsupportedH265";
|
|
27374
26579
|
/** {zh}
|
|
27375
26580
|
* @brief 其他错误类型,请联系火山引擎[技术支持](https://console.volcengine.com/workorder/create?step=3&SubProductID=P00000076)。
|
|
27376
26581
|
*
|
|
27377
26582
|
*/
|
|
27378
|
-
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherError"] =
|
|
26583
|
+
VeLivePusherErrorCode[VeLivePusherErrorCode["VeLivePusherError"] = -100] = "VeLivePusherError";
|
|
27379
26584
|
})(exports.VeLivePusherErrorCode || (exports.VeLivePusherErrorCode = {}));
|
|
27380
26585
|
|
|
27381
26586
|
var AndroidSurfaceView = function () {
|
|
@@ -28053,10 +27258,7 @@ function initAndroidPusher(options) {
|
|
|
28053
27258
|
case 2:
|
|
28054
27259
|
_d.sent();
|
|
28055
27260
|
viewTag = reactNative.findNodeHandle(element);
|
|
28056
|
-
reactNative.UIManager.dispatchViewManagerCommand(viewTag, '
|
|
28057
|
-
setTimeout(function () {
|
|
28058
|
-
reactNative.UIManager.dispatchViewManagerCommand(viewTag, 'setVisible', [true]);
|
|
28059
|
-
}, 1000);
|
|
27261
|
+
reactNative.UIManager.dispatchViewManagerCommand(viewTag, 'resetSurface', []);
|
|
28060
27262
|
return [2 /*return*/, packObject(pusher, VeLivePusher)];
|
|
28061
27263
|
}
|
|
28062
27264
|
});
|