@byteplus/react-native-live-push 1.4.0 → 1.5.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.
Files changed (36) hide show
  1. package/android/build.gradle +15 -3
  2. package/android/src/main/java/com/volcengine/velive/rn/push/EnvHelper.java +1 -1
  3. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushImpl.java +73 -0
  4. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushPackage.java +36 -11
  5. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushView.java +1 -0
  6. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/TextureMgr.java +1 -1
  7. package/android/src/newarch/com/volcengine/velive/rn/push/VeLivePushModule.java +92 -0
  8. package/android/src/{main/java → oldarch}/com/volcengine/velive/rn/push/VeLivePushModule.java +12 -48
  9. package/ios/RCTVeLivePush/RCTVeLivePush.h +22 -0
  10. package/ios/RCTVeLivePush/RCTVeLivePush.mm +141 -0
  11. package/ios/VeLivePushImpl.h +38 -0
  12. package/ios/VeLivePushImpl.m +51 -0
  13. package/lib/commonjs/index.js +462 -256
  14. package/lib/commonjs/typescript/index.d.ts +1 -0
  15. package/lib/commonjs/typescript/module.d.ts +4 -0
  16. package/lib/commonjs/typescript/platforms/TurboModule/NativeVeLivePush.d.ts +193 -0
  17. package/lib/commonjs/typescript/platforms/TurboModule/index.d.ts +1 -0
  18. package/lib/commonjs/typescript/utils/index.d.ts +1 -0
  19. package/lib/module/index.js +486 -282
  20. package/lib/module/typescript/index.d.ts +1 -0
  21. package/lib/module/typescript/module.d.ts +4 -0
  22. package/lib/module/typescript/platforms/TurboModule/NativeVeLivePush.d.ts +193 -0
  23. package/lib/module/typescript/platforms/TurboModule/index.d.ts +1 -0
  24. package/lib/module/typescript/utils/index.d.ts +1 -0
  25. package/lib/typescript/index.d.ts +1 -0
  26. package/lib/typescript/module.d.ts +4 -0
  27. package/lib/typescript/platforms/TurboModule/NativeVeLivePush.d.ts +193 -0
  28. package/lib/typescript/platforms/TurboModule/index.d.ts +1 -0
  29. package/lib/typescript/utils/index.d.ts +1 -0
  30. package/package.json +14 -5
  31. package/react-native-velive-push.podspec +9 -5
  32. package/src/platforms/TurboModule/NativeVeLivePush.ts +242 -0
  33. package/src/platforms/TurboModule/index.ts +1 -0
  34. package/ios/VeLivePushSDK.h +0 -24
  35. package/ios/VeLivePushSDK.m +0 -98
  36. /package/android/src/{main/java → oldarch}/com/volcengine/velive/rn/push/VeLivePushModuleSpec.java +0 -0
@@ -0,0 +1,242 @@
1
+
2
+ import {TurboModuleRegistry} from 'react-native';
3
+ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
4
+ export enum CALL_TYPE {
5
+ /**
6
+ * 获取动态变量
7
+ */
8
+ VAR_GETTER = 'var_get',
9
+ /**
10
+ * 调用静态方法
11
+ */
12
+ PLAIN_API_CALL = 'plain_api_call',
13
+ /**
14
+ * 实例化对象
15
+ */
16
+ NEW_INSTANCE = 'new_instance',
17
+ /**
18
+ * 调用 api 上的方法
19
+ */
20
+ INSTANCE_METHOD_INVOKE = 'instance_method_invoke',
21
+ /**
22
+ * 设置属性
23
+ */
24
+ INSTANCE_MEMBER_SET = 'instance_member_set',
25
+ /**
26
+ * 设置属性
27
+ */
28
+ INSTANCE_MEMBER_GET = 'instance_member_get',
29
+ /**
30
+ * 注册回调函数
31
+ */
32
+ INSTANCE_EVENT_LISTENER_ADD = 'instance_event_add',
33
+ /**
34
+ * 移除回调函数
35
+ */
36
+ INSTANCE_EVENT_LISTENER_REMOVE = 'instance_event_remove',
37
+ /**
38
+ * 触发事件
39
+ */
40
+ INSTANCE_EVENT_EMIT = 'instance_event_emit',
41
+ /**
42
+ * 事件执行后的返回值
43
+ */
44
+ INSTANCE_EVENT_RESULT = 'instance_event_result',
45
+ /**
46
+ * 销毁实例
47
+ */
48
+ DESTROY_INSTANCE = 'destroy_instance',
49
+ /**
50
+ * 触发事件
51
+ */
52
+ CALLBACK_EMIT = 'callback_emit',
53
+ }
54
+
55
+ const enum ARG_TYPE {
56
+ /**
57
+ * 类的实例
58
+ */
59
+ INSTANCE = 'instance',
60
+ /**
61
+ * callback 函数
62
+ */
63
+ CALLBACK = 'callback',
64
+ /**
65
+ * 枚举
66
+ */
67
+ ENUM = 'enum',
68
+ /**
69
+ * 运行时变量
70
+ * 比如:android 的 ApplicationContext
71
+ */
72
+ VARIABLE = 'variable',
73
+ /**
74
+ * 二进制数据
75
+ */
76
+ BASE64 = 'base64',
77
+ /**
78
+ *
79
+ */
80
+ IMAGE_RESOURCE = 'image_resource',
81
+ }
82
+
83
+ /**
84
+ * 对象实例,随机分配 id
85
+ */
86
+ interface IInstance {
87
+ _type: ARG_TYPE.INSTANCE;
88
+ _instanceId: string;
89
+ _serviceName?: string;
90
+ }
91
+
92
+ /**
93
+ * 回调函数,随机分配 id
94
+ */
95
+ interface ICallback {
96
+ _type: ARG_TYPE.CALLBACK;
97
+ _callbackId: string;
98
+ }
99
+
100
+ /**
101
+ * 对象实例,随机分配 id
102
+ */
103
+ interface IEnum {
104
+ _type: ARG_TYPE.ENUM;
105
+ _enumName?: string;
106
+ _name?: string;
107
+ _value?: string | number;
108
+ }
109
+
110
+ /**
111
+ * 回调函数,随机分配 id
112
+ */
113
+ interface IBinaryBase64 {
114
+ _type: ARG_TYPE.BASE64;
115
+ _value: string;
116
+ }
117
+
118
+ /**
119
+ * json 支持的数据类型
120
+ * 包括:object, array, string, number, null
121
+ */
122
+ export type IJsonDataType =
123
+ | object
124
+ | Array<IJsonDataType>
125
+ | string
126
+ | number
127
+ | null;
128
+
129
+ export type IMixinData =
130
+ | IInstance
131
+ | ICallback
132
+ | IEnum
133
+ | IBinaryBase64
134
+ | IJsonDataType;
135
+
136
+ export interface ICallParams {
137
+ /**
138
+ * 调用类型
139
+ */
140
+ callType: CALL_TYPE;
141
+ /**
142
+ * 实例对象 id,调用实例上的方法、设置实例上属性时需要
143
+ */
144
+ _instanceId?: string;
145
+ /**
146
+ * 实例类型,GC 时需要
147
+ */
148
+ _instanceType?: INSTANCE_TYPE;
149
+ /**
150
+ * 方法名称或者属性名称,需要传入完整路径
151
+ * @example com.xx.class.doSome
152
+ */
153
+ serviceName: string;
154
+ /**
155
+ * 方法名称
156
+ */
157
+ methodName?: string;
158
+ /**
159
+ * 属性名称
160
+ */
161
+ memberName?: string;
162
+ /**
163
+ * api 的入参,解析后传给对应的 api
164
+ */
165
+ args?: Array<IMixinData>;
166
+
167
+ /**
168
+ * 是否需要等待结果返回
169
+ * for: 部分 android/ios 回调需要同步执行
170
+ */
171
+ waitResult?: boolean;
172
+
173
+ _traceId?: string;
174
+
175
+ /** 是否在主线程执行 */
176
+ runOnMainThread?: boolean;
177
+ }
178
+
179
+ enum RETURN_STATUS {
180
+ SUCCESS = 'success',
181
+ FAILED = 'failed',
182
+ NOT_IMPLEMENTED = 'not_implemented',
183
+ }
184
+
185
+ /**
186
+ * 调用 Api 后的返回的结构体
187
+ */
188
+ interface IReturnParams {
189
+ status: RETURN_STATUS;
190
+ msg: IMixinData;
191
+ decoded?: string;
192
+ _traceId?: string;
193
+ }
194
+
195
+ export enum INSTANCE_TYPE {
196
+ /**
197
+ * 自动 GC 类型
198
+ */
199
+ AUTOMATIC = 0,
200
+ /**
201
+ * 手动 GC 类型
202
+ */
203
+ MANUAL = 1,
204
+ }
205
+
206
+ /**
207
+ * NativeBridgeModule规范接口
208
+ * TODO 适配方案:
209
+ * 1. 生成在nodemodules内部,路径要稳定,单独chunk,建议不要被打包,直接作为JS或者Native代码调用
210
+ * 2. 代码生成方式, 生成一个Spec
211
+ */
212
+ export interface Spec extends TurboModule {
213
+ /**
214
+ * 异步调用原生方法
215
+ * @param params 调用参数
216
+ * @returns 调用结果
217
+ */
218
+ callSync(params: string): string;
219
+
220
+ /**
221
+ * 同步调用原生方法
222
+ * @param params 调用参数
223
+ * @param callback 结果回调函数
224
+ */
225
+ call(params: string, callback: (res: string) => void): void;
226
+
227
+ newApiEngine(): boolean;
228
+
229
+ destroyApiEngine(): boolean;
230
+
231
+
232
+ // https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/swift-event-emitter
233
+
234
+ //Note: The addListener and removeListeners implementations will be provided by React Native.
235
+ addListener: (eventType: string) => void;
236
+ removeListeners: (count: number) => void;
237
+ }
238
+
239
+ /**
240
+ * 获取NativeBridgeModule实例
241
+ */
242
+ export default TurboModuleRegistry.get<Spec>('VeLivePush') as Spec | null;;
@@ -0,0 +1 @@
1
+ export {default as VeLivePush, CALL_TYPE} from './NativeVeLivePush';
@@ -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 RCTVeLivePushModule : RCTEventEmitter <RCTBridgeModule>
17
-
18
- @property(nonatomic, strong) VolcApiEngine *apiEngine;
19
-
20
- + (instancetype)shareInstance;
21
-
22
- @end
23
-
24
- #endif /* VeLivePullSDK_h */
@@ -1,98 +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 "VeLivePushSDK.h"
14
- #import "VolcApiEngine/VolcEventObserver.h"
15
-
16
- #define EVENT_NAME @"VeLivePush:onEvent"
17
-
18
- @interface RCTVeLivePushModule () <EventObserver>
19
-
20
- @end
21
-
22
- @interface RCTVeLivePushModule () <VeLiveMediaPlayerListener>
23
-
24
- @end
25
-
26
- static RCTVeLivePushModule *instance = nil;
27
-
28
- @implementation RCTVeLivePushModule {
29
- bool hasListeners;
30
- }
31
-
32
- + (instancetype)shareInstance {
33
- return instance;
34
- }
35
-
36
- + (BOOL)requiresMainQueueSetup {
37
- return YES;
38
- }
39
-
40
- // + (void)_unsedForKeepOnly {
41
- // Protocol *unused = @protocol(VeLivePlayerObserver);
42
- // NSLog(@"Loaded Protocol: %p", unused);
43
- // }
44
-
45
- - (dispatch_queue_t)methodQueue {
46
- return dispatch_get_main_queue();
47
- }
48
-
49
- - (instancetype)init {
50
- self = [super init];
51
- if (self != nil) {
52
- self.apiEngine = nil;
53
- instance = self;
54
- }
55
- return instance;
56
- }
57
-
58
- - (NSArray<NSString *> *)supportedEvents {
59
- return @[ EVENT_NAME ];
60
- }
61
-
62
- - (void)onEvent:(NSString *)eventName data:(id)eventData {
63
- NSDictionary *dic = @{@"event" : eventName, @"data" : eventData};
64
- [self sendEventWithName:EVENT_NAME body:dic];
65
- }
66
-
67
- RCT_EXPORT_MODULE();
68
-
69
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(newApiEngine) {
70
- if (self.apiEngine == nil) {
71
- self.apiEngine = [[VolcApiEngine alloc] init];
72
- [self.apiEngine setObserver:self];
73
- }
74
- return nil;
75
- }
76
-
77
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(destroyApiEngine) {
78
- //
79
- return nil;
80
- }
81
-
82
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(callApiSync
83
- : (nonnull NSDictionary *)args) {
84
- [self newApiEngine];
85
- return [instance.apiEngine callApi:args];
86
- }
87
-
88
- RCT_EXPORT_METHOD(callApi
89
- : (nonnull NSDictionary *)args callback
90
- : (RCTResponseSenderBlock)callback) {
91
- [self newApiEngine];
92
- dispatch_async(dispatch_get_main_queue(), ^{
93
- id _val = [self.apiEngine callApi:args];
94
- callback(@[ _val ]);
95
- });
96
- }
97
-
98
- @end