@byteplus/react-native-live-pull 1.4.0-rc.0 → 1.5.1-rc.0
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/build.gradle +19 -3
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/volcengine/velive/rn/pull/EnvHelper.java +1 -1
- package/android/src/main/java/com/volcengine/velive/rn/pull/VeLivePullImpl.java +66 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/VeLivePullPackage.java +61 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/{VolcView.java → VeLivePullView.java} +12 -3
- package/android/src/main/java/com/volcengine/velive/rn/pull/{VolcViewManager.java → VeLivePullViewManager.java} +34 -19
- package/android/src/newarch/com/volcengine/velive/rn/pull/VeLivePullModule.java +83 -0
- package/android/src/{main/java/com/volcengine/velive/rn/pull/VolcLiveModule.java → oldarch/com/volcengine/velive/rn/pull/VeLivePullModule.java} +17 -47
- package/android/src/{main/java/com/volcengine/velive/rn/pull/VolcLiveModuleSpec.java → oldarch/com/volcengine/velive/rn/pull/VeLivePullModuleSpec.java} +4 -4
- package/ios/RCTVeLivePull/RCTVeLivePull.h +21 -0
- package/ios/RCTVeLivePull/RCTVeLivePull.mm +119 -0
- package/ios/VeLivePullImpl.h +29 -0
- package/ios/VeLivePullImpl.m +49 -0
- package/ios/VeLivePullView.h +3 -3
- package/ios/VeLivePullView.m +2 -2
- package/ios/VeLivePullViewManager.m +13 -9
- package/lib/commonjs/index.js +142 -22
- package/lib/module/index.js +143 -23
- package/lib/typescript/codegen/ios/errorcode.d.ts +2 -2
- package/lib/typescript/module.d.ts +4 -0
- package/lib/typescript/platforms/TurboModule/NativeVeLivePull.d.ts +29 -0
- package/lib/typescript/platforms/TurboModule/index.d.ts +1 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/package.json +6 -5
- package/react-native-velive-pull.podspec +29 -24
- package/src/platforms/TurboModule/NativeVeLivePull.ts +38 -0
- package/src/platforms/TurboModule/index.ts +1 -0
- package/android/src/main/java/com/volcengine/velive/rn/pull/VolcLivePackage.java +0 -27
- package/ios/VeLivePullSDK.h +0 -24
- package/ios/VeLivePullSDK.m +0 -89
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeEventEmitter, Image, Platform, requireNativeComponent, AppState
|
|
1
|
+
import { NativeEventEmitter, Image, Platform, TurboModuleRegistry, NativeModules, requireNativeComponent, AppState } from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -2573,6 +2573,7 @@ var MessageProtoImpl = function () {
|
|
|
2573
2573
|
var buf = bufferLike.buffer || bufferLike;
|
|
2574
2574
|
return {
|
|
2575
2575
|
_type: "base64" /* ARG_TYPE.BASE64 */,
|
|
2576
|
+
// @ts-ignore
|
|
2576
2577
|
_value: buf2base64(buf),
|
|
2577
2578
|
};
|
|
2578
2579
|
};
|
|
@@ -2914,6 +2915,77 @@ var ReactNativeBridge = /** @class */ (function () {
|
|
|
2914
2915
|
return ReactNativeBridge;
|
|
2915
2916
|
}());
|
|
2916
2917
|
|
|
2918
|
+
var ReactNativeTurboBridge = /** @class */ (function () {
|
|
2919
|
+
function ReactNativeTurboBridge(BridgeModule, NativeEventName) {
|
|
2920
|
+
this.BridgeModule = BridgeModule;
|
|
2921
|
+
this.NativeEventName = NativeEventName;
|
|
2922
|
+
this._handlers = {};
|
|
2923
|
+
if (BridgeModule === undefined) {
|
|
2924
|
+
throw new Error("can't find module \"".concat(BridgeModule, "\", please enure install the module correctly"));
|
|
2925
|
+
}
|
|
2926
|
+
// this._nativeEventEmitter = new NativeEventEmitter(BridgeModule);
|
|
2927
|
+
this._nativeEventEmitter = new NativeEventEmitter(BridgeModule);
|
|
2928
|
+
this._init();
|
|
2929
|
+
}
|
|
2930
|
+
ReactNativeTurboBridge.prototype._init = function () {
|
|
2931
|
+
var _this = this;
|
|
2932
|
+
this._nativeEventEmitter.addListener(this.NativeEventName, function (ev) {
|
|
2933
|
+
var _a, _b;
|
|
2934
|
+
try {
|
|
2935
|
+
var eventName = ev.event;
|
|
2936
|
+
var eventData = typeof ev.data === 'string' ? JSON.parse(ev.data) : ev.data;
|
|
2937
|
+
(_b = (_a = _this._handlers)[eventName]) === null || _b === void 0 ? void 0 : _b.call(_a, eventData);
|
|
2938
|
+
}
|
|
2939
|
+
catch (err) {
|
|
2940
|
+
console.error('handle native event fail:', err);
|
|
2941
|
+
}
|
|
2942
|
+
});
|
|
2943
|
+
};
|
|
2944
|
+
ReactNativeTurboBridge.prototype.call = function (params) {
|
|
2945
|
+
var _this = this;
|
|
2946
|
+
return new Promise(function (resolve, reject) {
|
|
2947
|
+
try {
|
|
2948
|
+
var resolved_1 = false;
|
|
2949
|
+
_this.BridgeModule.call(JSON.stringify(params), function (res) {
|
|
2950
|
+
var val = typeof res === 'string' ? JSON.parse(res) : res;
|
|
2951
|
+
resolved_1 = true;
|
|
2952
|
+
resolve(val);
|
|
2953
|
+
});
|
|
2954
|
+
setTimeout(function () {
|
|
2955
|
+
if (resolved_1) {
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
resolve({
|
|
2959
|
+
status: RETURN_STATUS.SUCCESS,
|
|
2960
|
+
msg: 'over timeout and auto success',
|
|
2961
|
+
});
|
|
2962
|
+
}, 1000 * 60 * 5);
|
|
2963
|
+
}
|
|
2964
|
+
catch (err) {
|
|
2965
|
+
// console.error(`<RNBridge> call native "${handlerName}()" fail`, err);
|
|
2966
|
+
reject(err);
|
|
2967
|
+
}
|
|
2968
|
+
});
|
|
2969
|
+
};
|
|
2970
|
+
ReactNativeTurboBridge.prototype.callSync = function (params) {
|
|
2971
|
+
try {
|
|
2972
|
+
var res = this.BridgeModule.callSync(JSON.stringify(params));
|
|
2973
|
+
return typeof res === 'string' ? JSON.parse(res) : res;
|
|
2974
|
+
}
|
|
2975
|
+
catch (err) {
|
|
2976
|
+
// console.error(`<RNBridge> call native "${handlerName}()" fail`, err);
|
|
2977
|
+
throw err;
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
ReactNativeTurboBridge.prototype.registerHandler = function (handlerName, handler) {
|
|
2981
|
+
this._handlers[handlerName] = handler;
|
|
2982
|
+
};
|
|
2983
|
+
ReactNativeTurboBridge.prototype.registerAsyncHandler = function (handlerName, handler) {
|
|
2984
|
+
this._handlers[handlerName] = handler;
|
|
2985
|
+
};
|
|
2986
|
+
return ReactNativeTurboBridge;
|
|
2987
|
+
}());
|
|
2988
|
+
|
|
2917
2989
|
/******************************************************************************
|
|
2918
2990
|
Copyright (c) Microsoft Corporation.
|
|
2919
2991
|
|
|
@@ -2960,6 +3032,42 @@ var ReactNativeEnv = /** @class */ (function () {
|
|
|
2960
3032
|
return ReactNativeEnv;
|
|
2961
3033
|
}());
|
|
2962
3034
|
|
|
3035
|
+
/**
|
|
3036
|
+
* 获取NativeBridgeModule实例
|
|
3037
|
+
*/
|
|
3038
|
+
var NativeVeLivePull = TurboModuleRegistry.get('VeLivePull');
|
|
3039
|
+
|
|
3040
|
+
var _isNewArch;
|
|
3041
|
+
function isNewArch() {
|
|
3042
|
+
if (_isNewArch !== undefined) {
|
|
3043
|
+
return _isNewArch;
|
|
3044
|
+
}
|
|
3045
|
+
else {
|
|
3046
|
+
try {
|
|
3047
|
+
// Check for Fabric UI Manager
|
|
3048
|
+
var hasFabricUIManager = Boolean(global === null || global === void 0 ? void 0 : global.nativeFabricUIManager);
|
|
3049
|
+
// Check for TurboModule system
|
|
3050
|
+
var hasTurboModule = Boolean(global === null || global === void 0 ? void 0 : global.__turboModuleProxy);
|
|
3051
|
+
_isNewArch = hasFabricUIManager || hasTurboModule;
|
|
3052
|
+
}
|
|
3053
|
+
catch (_a) {
|
|
3054
|
+
_isNewArch = true;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
return _isNewArch;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
var isTurboModuleEnabled = isNewArch();
|
|
3061
|
+
var VeLivePull = isTurboModuleEnabled
|
|
3062
|
+
? NativeVeLivePull
|
|
3063
|
+
: NativeModules.VeLivePull;
|
|
3064
|
+
if (isTurboModuleEnabled) {
|
|
3065
|
+
console.log('[RN Module] TurboModule Enable', NativeVeLivePull);
|
|
3066
|
+
}
|
|
3067
|
+
else {
|
|
3068
|
+
console.log('[RN Module] NativeModule Enable', NativeModules.VeLivePull);
|
|
3069
|
+
}
|
|
3070
|
+
|
|
2963
3071
|
/******************************************************************************
|
|
2964
3072
|
Copyright (c) Microsoft Corporation.
|
|
2965
3073
|
|
|
@@ -3105,7 +3213,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
3105
3213
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
3106
3214
|
};
|
|
3107
3215
|
|
|
3108
|
-
var VolcView = requireNativeComponent('
|
|
3216
|
+
var VolcView = requireNativeComponent('VeLivePullView');
|
|
3109
3217
|
var NativeViewComponent = /** @class */ (function (_super) {
|
|
3110
3218
|
__extends(NativeViewComponent, _super);
|
|
3111
3219
|
function NativeViewComponent() {
|
|
@@ -6746,12 +6854,12 @@ var VeLivePlayerObserver = function () {
|
|
|
6746
6854
|
var _classExtraInitializers = [];
|
|
6747
6855
|
var _classThis;
|
|
6748
6856
|
var _instanceExtraInitializers = [];
|
|
6749
|
-
var
|
|
6750
|
-
var
|
|
6751
|
-
var
|
|
6752
|
-
var
|
|
6753
|
-
var
|
|
6754
|
-
var
|
|
6857
|
+
var _code_decorators;
|
|
6858
|
+
var _code_initializers = [];
|
|
6859
|
+
var _code_extraInitializers = [];
|
|
6860
|
+
var _message_decorators;
|
|
6861
|
+
var _message_initializers = [];
|
|
6862
|
+
var _message_extraInitializers = [];
|
|
6755
6863
|
var _init_decorators;
|
|
6756
6864
|
_classThis = /** @class */ (function () {
|
|
6757
6865
|
function VeLivePlayerError_1() {
|
|
@@ -6761,15 +6869,15 @@ var VeLivePlayerObserver = function () {
|
|
|
6761
6869
|
/** {en}
|
|
6762
6870
|
* @brief The error code.
|
|
6763
6871
|
*/
|
|
6764
|
-
this.
|
|
6872
|
+
this.code = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _code_initializers, void 0));
|
|
6765
6873
|
/** {zh}
|
|
6766
6874
|
* @brief 直播播放错误信息。
|
|
6767
6875
|
*/
|
|
6768
6876
|
/** {en}
|
|
6769
6877
|
* @brief The error message.
|
|
6770
6878
|
*/
|
|
6771
|
-
this.
|
|
6772
|
-
__runInitializers(this,
|
|
6879
|
+
this.message = (__runInitializers(this, _code_extraInitializers), __runInitializers(this, _message_initializers, void 0));
|
|
6880
|
+
__runInitializers(this, _message_extraInitializers);
|
|
6773
6881
|
}
|
|
6774
6882
|
VeLivePlayerError_1.prototype.init = function () {
|
|
6775
6883
|
throw new Error('not implement');
|
|
@@ -6779,12 +6887,12 @@ var VeLivePlayerObserver = function () {
|
|
|
6779
6887
|
__setFunctionName(_classThis, "VeLivePlayerError");
|
|
6780
6888
|
(function () {
|
|
6781
6889
|
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
6782
|
-
|
|
6783
|
-
|
|
6890
|
+
_code_decorators = [NativeMember()];
|
|
6891
|
+
_message_decorators = [NativeMember()];
|
|
6784
6892
|
_init_decorators = [NativeMethodSync('init')];
|
|
6785
6893
|
__esDecorate(_classThis, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: function (obj) { return "init" in obj; }, get: function (obj) { return obj.init; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
6786
|
-
__esDecorate(null, null,
|
|
6787
|
-
__esDecorate(null, null,
|
|
6894
|
+
__esDecorate(null, null, _code_decorators, { kind: "field", name: "code", static: false, private: false, access: { has: function (obj) { return "code" in obj; }, get: function (obj) { return obj.code; }, set: function (obj, value) { obj.code = value; } }, metadata: _metadata }, _code_initializers, _code_extraInitializers);
|
|
6895
|
+
__esDecorate(null, null, _message_decorators, { kind: "field", name: "message", static: false, private: false, access: { has: function (obj) { return "message" in obj; }, get: function (obj) { return obj.message; }, set: function (obj, value) { obj.message = value; } }, metadata: _metadata }, _message_initializers, _message_extraInitializers);
|
|
6788
6896
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
6789
6897
|
_classThis = _classDescriptor.value;
|
|
6790
6898
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -12372,7 +12480,7 @@ var VeLivePlayerError = function () {
|
|
|
12372
12480
|
return Number(this._instance.mErrorCode);
|
|
12373
12481
|
}
|
|
12374
12482
|
else if ($os === 'ios') {
|
|
12375
|
-
return Number(this._instance.
|
|
12483
|
+
return Number(this._instance.code);
|
|
12376
12484
|
}
|
|
12377
12485
|
else {
|
|
12378
12486
|
throw new Error('Not Support Platform ' + $os);
|
|
@@ -12396,7 +12504,7 @@ var VeLivePlayerError = function () {
|
|
|
12396
12504
|
return String(this._instance.mErrorMsg);
|
|
12397
12505
|
}
|
|
12398
12506
|
else if ($os === 'ios') {
|
|
12399
|
-
return String(this._instance.
|
|
12507
|
+
return String(this._instance.message);
|
|
12400
12508
|
}
|
|
12401
12509
|
else {
|
|
12402
12510
|
throw new Error('Not Support Platform ' + $os);
|
|
@@ -14116,6 +14224,7 @@ function removePlayer(player) {
|
|
|
14116
14224
|
playerPool.delete(player);
|
|
14117
14225
|
}
|
|
14118
14226
|
|
|
14227
|
+
var defaultHeaders = { 'User-Agent': 'rn' };
|
|
14119
14228
|
function runImpl(context, androidImpl, iosImpl) {
|
|
14120
14229
|
if (env.getOS() === 'android') {
|
|
14121
14230
|
var androidEngine = unpackObject(context);
|
|
@@ -14262,7 +14371,8 @@ extendsClassMethod(VeLivePlayer, 'setEnableIgnoreAudioInterruption', function ()
|
|
|
14262
14371
|
});
|
|
14263
14372
|
extendsClassMethod(VeLivePlayer, 'addExtraHttpRequestHeadersByUser', function () {
|
|
14264
14373
|
return function addExtraHttpRequestHeadersByUser(headers) {
|
|
14265
|
-
|
|
14374
|
+
// @ts-ignore
|
|
14375
|
+
this._customHeaders = headers || {};
|
|
14266
14376
|
return runImpl(this, function (engine) {
|
|
14267
14377
|
engine.addExtraHttpRequestHeadersByUser(__assign(__assign({}, defaultHeaders), headers));
|
|
14268
14378
|
}, function (engine) {
|
|
@@ -14272,11 +14382,13 @@ extendsClassMethod(VeLivePlayer, 'addExtraHttpRequestHeadersByUser', function ()
|
|
|
14272
14382
|
});
|
|
14273
14383
|
extendsClassMethod(VeLivePlayer, 'play', function () {
|
|
14274
14384
|
return function play() {
|
|
14385
|
+
// @ts-ignore
|
|
14386
|
+
var headers = __assign(__assign({}, defaultHeaders), (this._customHeaders || {}));
|
|
14275
14387
|
return runImpl(this, function (engine) {
|
|
14276
|
-
engine.addExtraHttpRequestHeadersByUser(
|
|
14388
|
+
engine.addExtraHttpRequestHeadersByUser(headers);
|
|
14277
14389
|
engine.play();
|
|
14278
14390
|
}, function (engine) {
|
|
14279
|
-
engine.addExtraHttpRequestHeadersByUser(
|
|
14391
|
+
engine.addExtraHttpRequestHeadersByUser(headers);
|
|
14280
14392
|
engine.play();
|
|
14281
14393
|
});
|
|
14282
14394
|
};
|
|
@@ -14444,7 +14556,7 @@ function initAndroidEnv(config) {
|
|
|
14444
14556
|
.setLicenseUri(config.LicenseUri.android);
|
|
14445
14557
|
androidEnv = builder.build();
|
|
14446
14558
|
EnvHelper.init(androidEnv, {
|
|
14447
|
-
hybrid_ua: "rn|pull|".concat("1.
|
|
14559
|
+
hybrid_ua: "rn|pull|".concat("1.5.0"),
|
|
14448
14560
|
});
|
|
14449
14561
|
Env.openAppLog(config.openLog);
|
|
14450
14562
|
return [2 /*return*/];
|
|
@@ -14455,7 +14567,7 @@ function initAndroidEnv(config) {
|
|
|
14455
14567
|
function initIOSEnv(config) {
|
|
14456
14568
|
return __awaiter(this, void 0, void 0, function () {
|
|
14457
14569
|
return __generator(this, function (_a) {
|
|
14458
|
-
VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: '500808' , hybrid_ua: "rn|pull|".concat("1.
|
|
14570
|
+
VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: '500808' , hybrid_ua: "rn|pull|".concat("1.5.0") }));
|
|
14459
14571
|
return [2 /*return*/];
|
|
14460
14572
|
});
|
|
14461
14573
|
});
|
|
@@ -14496,6 +14608,7 @@ function initEnv(config) {
|
|
|
14496
14608
|
|
|
14497
14609
|
var defaultConfig = {
|
|
14498
14610
|
enableStatisticsCallback: true,
|
|
14611
|
+
enableLiveDNS: false,
|
|
14499
14612
|
};
|
|
14500
14613
|
function initAndroidPlayer(options) {
|
|
14501
14614
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -14602,7 +14715,14 @@ function initPlayer(options) {
|
|
|
14602
14715
|
});
|
|
14603
14716
|
}
|
|
14604
14717
|
|
|
14605
|
-
|
|
14718
|
+
if (isTurboModuleEnabled) {
|
|
14719
|
+
console.log('[VeLivePull] TurboModule Enable', VeLivePull);
|
|
14720
|
+
setupJSBridge(new ReactNativeTurboBridge(VeLivePull, 'VeLivePull:onEvent'));
|
|
14721
|
+
}
|
|
14722
|
+
else {
|
|
14723
|
+
console.log('[VeLivePull] NativeModule Enable', NativeModules.VeLivePull);
|
|
14724
|
+
setupJSBridge(new ReactNativeBridge(VeLivePull, 'VeLivePull:onEvent'));
|
|
14725
|
+
}
|
|
14606
14726
|
setupEnv(new ReactNativeEnv());
|
|
14607
14727
|
|
|
14608
14728
|
export { LogLevel, NativeViewComponent, VeLivePlayer, VeLivePlayerAudioBufferType, VeLivePlayerAudioFrame, VeLivePlayerConfiguration, VeLivePlayerFillMode, VeLivePlayerFormat, VeLivePlayerLogLevel, VeLivePlayerMirror, VeLivePlayerPixelFormat, VeLivePlayerProtocol, VeLivePlayerResolution, VeLivePlayerResolutionSwitchReason, VeLivePlayerRotation, VeLivePlayerStatistics, VeLivePlayerStatus, VeLivePlayerStream, VeLivePlayerStreamData, VeLivePlayerStreamType, VeLivePlayerVideoBufferType, VeLivePlayerVideoFrame, initEnv, initPlayer, setupLogger };
|
|
@@ -4,12 +4,12 @@ export declare class VeLivePlayerError {
|
|
|
4
4
|
/** {en}
|
|
5
5
|
* @brief The error code.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
code: NSInteger;
|
|
8
8
|
|
|
9
9
|
/** {en}
|
|
10
10
|
* @brief The error message.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
message: NSString;
|
|
13
13
|
init(): this;
|
|
14
14
|
}
|
|
15
15
|
export declare enum VeLivePlayerErrorCode {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* NativeBridgeModule规范接口
|
|
4
|
+
* TODO 适配方案:
|
|
5
|
+
* 1. 生成在nodemodules内部,路径要稳定,单独chunk,建议不要被打包,直接作为JS或者Native代码调用
|
|
6
|
+
* 2. 代码生成方式, 生成一个Spec
|
|
7
|
+
*/
|
|
8
|
+
export interface Spec extends TurboModule {
|
|
9
|
+
/**
|
|
10
|
+
* 异步调用原生方法
|
|
11
|
+
* @param params 调用参数
|
|
12
|
+
* @returns 调用结果
|
|
13
|
+
*/
|
|
14
|
+
callSync(params: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* 同步调用原生方法
|
|
17
|
+
* @param params 调用参数
|
|
18
|
+
* @param callback 结果回调函数
|
|
19
|
+
*/
|
|
20
|
+
call(params: string, callback: (res: string) => void): void;
|
|
21
|
+
newApiEngine(): boolean;
|
|
22
|
+
addListener: (eventType: string) => void;
|
|
23
|
+
removeListeners: (count: number) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 获取NativeBridgeModule实例
|
|
27
|
+
*/
|
|
28
|
+
declare const _default: Spec | null;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NativeBridge } from './NativeVeLivePull';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isNewArch(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byteplus/react-native-live-pull",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1-rc.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "*",
|
|
6
6
|
"react-native": "*"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"ios",
|
|
14
14
|
"*.podspec",
|
|
15
15
|
"lib",
|
|
16
|
+
"./src/platforms/TurboModule",
|
|
16
17
|
"!**/__tests__",
|
|
17
18
|
"!**/__fixtures__",
|
|
18
19
|
"!**/__mocks__",
|
|
@@ -33,12 +34,12 @@
|
|
|
33
34
|
},
|
|
34
35
|
"nativeVersion": {
|
|
35
36
|
"volc": {
|
|
36
|
-
"android": "1.
|
|
37
|
-
"ios": "1.
|
|
37
|
+
"android": "1.48.2.10",
|
|
38
|
+
"ios": "1.48.2.3-premium"
|
|
38
39
|
},
|
|
39
40
|
"byteplus": {
|
|
40
|
-
"android": "1.
|
|
41
|
-
"ios": "1.
|
|
41
|
+
"android": "1.48.200.1",
|
|
42
|
+
"ios": "1.48.200.2-premium"
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
4
|
+
# folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
5
|
is_bp = package['name'].start_with?('@byteplus')
|
|
6
6
|
|
|
7
7
|
Pod::Spec.new do |s|
|
|
8
8
|
s.name = "react-native-velive-pull"
|
|
9
9
|
s.version = package["version"]
|
|
10
10
|
s.summary = package["description"]
|
|
11
|
+
s.description = package["description"]
|
|
11
12
|
s.homepage = package["homepage"]
|
|
12
13
|
s.license = package["license"]
|
|
13
14
|
s.authors = package["author"]
|
|
@@ -15,10 +16,11 @@ Pod::Spec.new do |s|
|
|
|
15
16
|
s.platforms = { :ios => min_ios_version_supported }
|
|
16
17
|
s.source = { :git => "https://github.com/volcengine/volcengine-specs.git", :tag => "#{s.version}" }
|
|
17
18
|
|
|
18
|
-
s.source_files = "ios/**/*.{h,m,mm}"
|
|
19
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
20
|
+
|
|
19
21
|
s.static_framework = true
|
|
20
22
|
s.preserve_paths = ['ios/include/react-native-velive-pull.modulemap']
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
s.pod_target_xcconfig = {
|
|
23
25
|
'DEFINES_MODULE' => 'YES',
|
|
24
26
|
'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/ios/include',
|
|
@@ -26,31 +28,34 @@ Pod::Spec.new do |s|
|
|
|
26
28
|
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES'
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
install_modules_dependencies(s)
|
|
31
|
+
if defined?(install_modules_dependencies()) != nil
|
|
32
|
+
## 输出 ok
|
|
33
|
+
puts 'install_modules_dependencies'
|
|
34
|
+
install_modules_dependencies(s);
|
|
33
35
|
else
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
36
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
37
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
38
|
+
s.pod_target_xcconfig = {
|
|
39
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
40
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
41
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
42
|
+
}
|
|
43
|
+
s.dependency "React-Codegen"
|
|
44
|
+
s.dependency "RCT-Folly"
|
|
45
|
+
s.dependency "RCTRequired"
|
|
46
|
+
s.dependency "RCTTypeSafety"
|
|
47
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
48
|
+
else
|
|
49
|
+
s.dependency "React-Core"
|
|
50
|
+
end
|
|
50
51
|
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
55
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
51
56
|
|
|
52
57
|
# Version configuration through environment variables
|
|
53
|
-
volc_api_engine_version = ENV['VOLC_API_ENGINE_VERSION_FOR_LIVE_PULL'] || '1.6.
|
|
58
|
+
volc_api_engine_version = ENV['VOLC_API_ENGINE_VERSION_FOR_LIVE_PULL'] || '1.6.6'
|
|
54
59
|
ttsdk_framework_version = ENV['TTSDK_FRAMEWORK_VERSION_FOR_LIVE_PULL'] || (is_bp ? package['nativeVersion']['byteplus']['ios'] : package['nativeVersion']['volc']['ios'])
|
|
55
60
|
|
|
56
61
|
use_rtc = ENV['USE_RTC_FOR_LIVE_PULL'] || 'true'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
2
|
+
import type {TurboModule} from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* NativeBridgeModule规范接口
|
|
6
|
+
* TODO 适配方案:
|
|
7
|
+
* 1. 生成在nodemodules内部,路径要稳定,单独chunk,建议不要被打包,直接作为JS或者Native代码调用
|
|
8
|
+
* 2. 代码生成方式, 生成一个Spec
|
|
9
|
+
*/
|
|
10
|
+
export interface Spec extends TurboModule {
|
|
11
|
+
/**
|
|
12
|
+
* 异步调用原生方法
|
|
13
|
+
* @param params 调用参数
|
|
14
|
+
* @returns 调用结果
|
|
15
|
+
*/
|
|
16
|
+
callSync(params: string): string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 同步调用原生方法
|
|
20
|
+
* @param params 调用参数
|
|
21
|
+
* @param callback 结果回调函数
|
|
22
|
+
*/
|
|
23
|
+
call(params: string, callback: (res: string) => void): void;
|
|
24
|
+
|
|
25
|
+
newApiEngine(): boolean;
|
|
26
|
+
|
|
27
|
+
//
|
|
28
|
+
//eventEmitter See: https://github.com/reactwg/react-native-new-architecture/discussions/144
|
|
29
|
+
|
|
30
|
+
//Note: The addListener and removeListeners implementations will be provided by React Native.
|
|
31
|
+
addListener: (eventType: string) => void;
|
|
32
|
+
removeListeners: (count: number) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 获取NativeBridgeModule实例
|
|
37
|
+
*/
|
|
38
|
+
export default TurboModuleRegistry.get<Spec>('VeLivePull') as Spec | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as NativeBridge} from './NativeVeLivePull';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package com.volcengine.velive.rn.pull;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
-
import com.facebook.react.bridge.NativeModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
|
|
13
|
-
public class VolcLivePackage implements ReactPackage {
|
|
14
|
-
@Override
|
|
15
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
16
|
-
List<ViewManager> viewManagers = new ArrayList<>();
|
|
17
|
-
viewManagers.add(new VolcViewManager());
|
|
18
|
-
return viewManagers;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Override
|
|
22
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
23
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
24
|
-
modules.add(new VolcLiveModule(reactContext));
|
|
25
|
-
return modules;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/ios/VeLivePullSDK.h
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// VeLivePullSDK.h
|
|
3
|
-
// rn
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2024/4/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#ifndef VeLivePullSDK_h
|
|
9
|
-
#define VeLivePullSDK_h
|
|
10
|
-
|
|
11
|
-
#import <Foundation/Foundation.h>
|
|
12
|
-
#import <React/RCTBridgeModule.h>
|
|
13
|
-
#import <React/RCTEventEmitter.h>
|
|
14
|
-
#import "VolcApiEngine/Engine.h"
|
|
15
|
-
|
|
16
|
-
@interface RCTVolcLiveModule : RCTEventEmitter <RCTBridgeModule>
|
|
17
|
-
|
|
18
|
-
@property(nonatomic, strong) VolcApiEngine *volcApiEngine;
|
|
19
|
-
|
|
20
|
-
+ (instancetype)shareInstance;
|
|
21
|
-
|
|
22
|
-
@end
|
|
23
|
-
|
|
24
|
-
#endif /* VeLivePullSDK_h */
|
package/ios/VeLivePullSDK.m
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// VeLivePullSDK.m
|
|
3
|
-
// rn
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2024/4/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <UIKit/UIKit.h>
|
|
10
|
-
|
|
11
|
-
#import <TTSDKFramework/TTSDKFramework.h>
|
|
12
|
-
|
|
13
|
-
#import "VeLivePullSDK.h"
|
|
14
|
-
#import "VolcApiEngine/VolcEventObserver.h"
|
|
15
|
-
|
|
16
|
-
#define EVENT_NAME @"VolcLive:onEvent"
|
|
17
|
-
|
|
18
|
-
@interface RCTVolcLiveModule () <EventObserver>
|
|
19
|
-
|
|
20
|
-
@end
|
|
21
|
-
|
|
22
|
-
static RCTVolcLiveModule *instance = nil;
|
|
23
|
-
|
|
24
|
-
@implementation RCTVolcLiveModule {
|
|
25
|
-
bool hasListeners;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
+ (instancetype)shareInstance {
|
|
29
|
-
return instance;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
33
|
-
return YES;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// + (void)_unsedForKeepOnly {
|
|
37
|
-
// Protocol *unused = @protocol(VeLivePlayerObserver);
|
|
38
|
-
// NSLog(@"Loaded Protocol: %p", unused);
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
- (dispatch_queue_t)methodQueue {
|
|
42
|
-
return dispatch_get_main_queue();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
- (instancetype)init {
|
|
46
|
-
self = [super init];
|
|
47
|
-
if (self != nil) {
|
|
48
|
-
self.volcApiEngine = nil;
|
|
49
|
-
instance = self;
|
|
50
|
-
}
|
|
51
|
-
return instance;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
- (NSArray<NSString *> *)supportedEvents {
|
|
55
|
-
return @[ EVENT_NAME ];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
- (void)onEvent:(NSString *)eventName data:(id)eventData {
|
|
59
|
-
NSDictionary *dic = @{@"event" : eventName, @"data" : eventData};
|
|
60
|
-
[self sendEventWithName:EVENT_NAME body:dic];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
RCT_EXPORT_MODULE();
|
|
64
|
-
|
|
65
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(newApiEngine) {
|
|
66
|
-
if (self.volcApiEngine == nil) {
|
|
67
|
-
self.volcApiEngine = [[VolcApiEngine alloc] init];
|
|
68
|
-
[self.volcApiEngine setObserver:self];
|
|
69
|
-
}
|
|
70
|
-
return nil;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(callApiSync
|
|
74
|
-
: (nonnull NSDictionary *)args) {
|
|
75
|
-
[self newApiEngine];
|
|
76
|
-
return [instance.volcApiEngine callApi:args];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
RCT_EXPORT_METHOD(callApi
|
|
80
|
-
: (nonnull NSDictionary *)args callback
|
|
81
|
-
: (RCTResponseSenderBlock)callback) {
|
|
82
|
-
[self newApiEngine];
|
|
83
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
84
|
-
id _val = [self.volcApiEngine callApi:args];
|
|
85
|
-
callback(@[ _val ]);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@end
|