@byteplus/react-native-live-push 1.0.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/android/build.gradle +92 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +16 -0
  6. package/android/src/main/AndroidManifestNew.xml +16 -0
  7. package/android/src/main/java/com/volcengine/velive/rn/push/ExternalSourceHelper.java +58 -0
  8. package/android/src/main/java/com/volcengine/velive/rn/push/NativeVariableManager.java +19 -0
  9. package/android/src/main/java/com/volcengine/velive/rn/push/ScreenCaptureHelper.java +73 -0
  10. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModule.java +182 -0
  11. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModuleSpec.java +16 -0
  12. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushPackage.java +27 -0
  13. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushView.java +45 -0
  14. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushViewManager.java +87 -0
  15. package/ios/VeLivePushSDK.h +24 -0
  16. package/ios/VeLivePushSDK.m +109 -0
  17. package/ios/VeLivePushView.h +24 -0
  18. package/ios/VeLivePushView.m +74 -0
  19. package/ios/VeLivePushViewManager.m +59 -0
  20. package/lib/commonjs/index.js +24238 -0
  21. package/lib/module/index.js +24186 -0
  22. package/lib/typescript/android/index.d.ts +44 -0
  23. package/lib/typescript/codegen/android/api.d.ts +372 -0
  24. package/lib/typescript/codegen/android/callback.d.ts +91 -0
  25. package/lib/typescript/codegen/android/errorcode.d.ts +26 -0
  26. package/lib/typescript/codegen/android/index.d.ts +5 -0
  27. package/lib/typescript/codegen/android/keytype.d.ts +469 -0
  28. package/lib/typescript/codegen/android/types.d.ts +32 -0
  29. package/lib/typescript/codegen/ios/api.d.ts +257 -0
  30. package/lib/typescript/codegen/ios/callback.d.ts +88 -0
  31. package/lib/typescript/codegen/ios/errorcode.d.ts +54 -0
  32. package/lib/typescript/codegen/ios/index.d.ts +5 -0
  33. package/lib/typescript/codegen/ios/keytype.d.ts +488 -0
  34. package/lib/typescript/codegen/ios/types.d.ts +35 -0
  35. package/lib/typescript/codegen/pack/api.d.ts +1933 -0
  36. package/lib/typescript/codegen/pack/callback.d.ts +542 -0
  37. package/lib/typescript/codegen/pack/errorcode.d.ts +174 -0
  38. package/lib/typescript/codegen/pack/index.d.ts +5 -0
  39. package/lib/typescript/codegen/pack/keytype.d.ts +1952 -0
  40. package/lib/typescript/codegen/pack/types.d.ts +1 -0
  41. package/lib/typescript/codegen/type-shim.d.ts +6 -0
  42. package/lib/typescript/component.d.ts +8 -0
  43. package/lib/typescript/core/api.d.ts +2 -0
  44. package/lib/typescript/core/callback.d.ts +2 -0
  45. package/lib/typescript/core/env.d.ts +29 -0
  46. package/lib/typescript/core/errorcode.d.ts +2 -0
  47. package/lib/typescript/core/index.d.ts +6 -0
  48. package/lib/typescript/core/keytype.d.ts +7 -0
  49. package/lib/typescript/core/pusher.d.ts +16 -0
  50. package/lib/typescript/index.d.ts +2 -0
  51. package/lib/typescript/ios/extends.d.ts +41 -0
  52. package/lib/typescript/runtime.d.ts +1 -0
  53. package/package.json +31 -0
  54. package/react-native-velive-push.podspec +45 -0
@@ -0,0 +1,24 @@
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 */
@@ -0,0 +1,109 @@
1
+ //
2
+ // VeLivePullSDK.m
3
+ // rn
4
+ //
5
+ // Created by ByteDance on 2024/4/10.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import <TTSDKFramework/TTSDKFramework.h>
12
+ #import <TTSDKFramework/TTSDKFramework/VeLiveMediaPlayer.h>
13
+
14
+ #import "VolcApiEngine/VolcEventObserver.h"
15
+ #import "VeLivePushSDK.h"
16
+
17
+ #define EVENT_NAME @"VeLivePush:onEvent"
18
+
19
+ @interface RCTVeLivePushModule () <EventObserver>
20
+
21
+ @end
22
+
23
+ static RCTVeLivePushModule *instance = nil;
24
+
25
+ @implementation RCTVeLivePushModule
26
+ {
27
+ bool hasListeners;
28
+ }
29
+
30
+ + (instancetype)shareInstance {
31
+ return instance;
32
+ }
33
+
34
+ + (BOOL)requiresMainQueueSetup {
35
+ return YES;
36
+ }
37
+
38
+ + (void)_unsedForKeepOnly {
39
+ Protocol *unused = @protocol(VeLivePlayerObserver);
40
+ NSLog(@"Loaded Protocol: %p", unused);
41
+ }
42
+
43
+ - (dispatch_queue_t)methodQueue {
44
+ return dispatch_get_main_queue();
45
+ }
46
+
47
+ - (instancetype)init {
48
+ self = [super init];
49
+ if (self != nil) {
50
+ self.apiEngine = nil;
51
+ instance = self;
52
+ }
53
+ return instance;
54
+ }
55
+
56
+ - (NSArray<NSString *> *)supportedEvents {
57
+ return @[ EVENT_NAME ];
58
+ }
59
+
60
+ - (void)onEvent:(NSString *)eventName data:(id)eventData
61
+ {
62
+ NSDictionary * dic = @{ @"event": eventName, @"data": eventData };
63
+ [self sendEventWithName:EVENT_NAME body:dic];
64
+ }
65
+
66
+ RCT_EXPORT_MODULE();
67
+
68
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(newApiEngine)
69
+ {
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
+ //
80
+ return nil;
81
+ }
82
+
83
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(callApiSync:(nonnull NSDictionary *) args)
84
+ {
85
+ [self newApiEngine];
86
+ return [instance.apiEngine callApi:args];
87
+ }
88
+
89
+ RCT_EXPORT_METHOD(callApi:(nonnull NSDictionary *)args callback:(RCTResponseSenderBlock) callback)
90
+ {
91
+ [self newApiEngine];
92
+ dispatch_async(dispatch_get_main_queue(), ^{
93
+ id _val = [self.apiEngine callApi:args];
94
+ callback(@[_val]);
95
+ });
96
+ }
97
+
98
+ RCT_EXPORT_METHOD(test)
99
+ {
100
+ Protocol *p = @protocol(VeLiveMediaPlayerListener);
101
+ NSString *str = NSStringFromProtocol(p);
102
+ NSLog(@"protocol name %@", str);
103
+
104
+ Protocol *p2 = @protocol(VeLivePusherObserver);
105
+ NSString *str2 = NSStringFromProtocol(p2);
106
+ NSLog(@"protocol name %@", str2);
107
+ }
108
+
109
+ @end
@@ -0,0 +1,24 @@
1
+ //
2
+ // VeLivePushUIView.h
3
+ //
4
+ // Created by ByteDance on 2024/3/27.
5
+ //
6
+
7
+ #import <Foundation/Foundation.h>
8
+ #import <UIKit/UIKit.h>
9
+ #import <React/RCTComponent.h>
10
+
11
+ #ifndef VeLivePushUIView_h
12
+ #define VeLivePushUIView_h
13
+
14
+ @interface VeLivePushUIView : UIView
15
+
16
+ @property (nonatomic, strong) NSString* viewId;
17
+
18
+ @property (nonatomic) BOOL hasRegister;
19
+
20
+ @property (nonatomic, copy) RCTBubblingEventBlock onLoad;
21
+
22
+ @end
23
+
24
+ #endif /* VeUIView_h */
@@ -0,0 +1,74 @@
1
+ //
2
+ // VeUIView.m
3
+ // rn
4
+ //
5
+ // Created by ByteDance on 2024/5/20.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "VeLivePushView.h"
10
+
11
+ @implementation VeLivePushUIView
12
+
13
+ - (instancetype) init {
14
+ self = [super init];
15
+ if (self != nil) {
16
+ self.clipsToBounds = YES;
17
+ }
18
+ return self;
19
+ }
20
+
21
+ - (void) setViewId:(NSString *)viewId {
22
+ if ([_viewId isEqualToString:viewId]) {
23
+ return;
24
+ }
25
+
26
+ _viewId = viewId;
27
+ self.hasRegister = TRUE;
28
+ self.accessibilityLabel = [NSString stringWithFormat:@"VeLivePushUIView@%@", viewId];
29
+
30
+ [self emitLoaded];
31
+ }
32
+
33
+ - (void) setOnLoad:(RCTBubblingEventBlock)onLoad {
34
+ _onLoad = onLoad;
35
+
36
+ [self emitLoaded];
37
+ }
38
+
39
+ - (void) emitLoaded
40
+ {
41
+ if (_onLoad != nil && _hasRegister == TRUE) {
42
+ _onLoad(@{});
43
+ }
44
+ }
45
+
46
+ - (void) insertSubview:(UIView *)view atIndex:(NSInteger)index {
47
+ // NSLog(@"insert playview, self bounds=%f x %f", self.bounds.size.width, self.bounds.size.height);
48
+ // NSLog(@"insert playview, view frame=%f x %f", view.frame.size.width, view.frame.size.height);
49
+
50
+ dispatch_async(dispatch_get_main_queue(), ^{
51
+ [super insertSubview:view atIndex:index];
52
+ [self setSubViewLayout:view];
53
+ });
54
+ }
55
+
56
+ - (void) addSubview:(UIView *)view {
57
+ dispatch_async(dispatch_get_main_queue(), ^{
58
+ [super addSubview:view];
59
+ [self setSubViewLayout:view];
60
+ });
61
+ }
62
+
63
+ // 设置 Auto Layout,确保 subView 始终匹配 view 尺寸
64
+ - (void) setSubViewLayout:(UIView *)view {
65
+ view.translatesAutoresizingMaskIntoConstraints = NO;
66
+ [NSLayoutConstraint activateConstraints:@[
67
+ [view.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
68
+ [view.trailingAnchor constraintEqualToAnchor:self.trailingAnchor],
69
+ [view.topAnchor constraintEqualToAnchor:self.topAnchor],
70
+ [view.bottomAnchor constraintEqualToAnchor:self.bottomAnchor]
71
+ ]];
72
+ }
73
+
74
+ @end
@@ -0,0 +1,59 @@
1
+ //
2
+ // VeUIView.m
3
+ // rn
4
+ //
5
+ // Created by ByteDance on 2024/3/27.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTViewManager.h>
10
+ #import "VolcApiEngine/VolcViewManager.h"
11
+ #import "VeLivePushView.h"
12
+
13
+ @interface VeLivePushViewManager : RCTViewManager
14
+
15
+ @end
16
+
17
+ @implementation VeLivePushViewManager
18
+
19
+ RCT_EXPORT_MODULE(VeLivePushView)
20
+
21
+ // 导出 events
22
+ RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTBubblingEventBlock)
23
+
24
+ // 导出 events
25
+ RCT_CUSTOM_VIEW_PROPERTY(viewId, NSString, VeLivePushUIView)
26
+ {
27
+ if (json == nil) {
28
+ return;
29
+ }
30
+
31
+ NSString * viewId = [RCTConvert NSString:json];
32
+ [view setViewId:viewId];
33
+ [VolcViewManager registerView:viewId view:view];
34
+ NSLog(@"[View] register view success viewId=%@", viewId);
35
+ }
36
+
37
+ RCT_CUSTOM_VIEW_PROPERTY(kind, NSString, VeLivePushUIView)
38
+ {
39
+ if (json == nil) {
40
+ return;
41
+ }
42
+
43
+ // NSString *viewKind = [RCTConvert NSString:json];
44
+ // if ([viewKind isEqualToString:@"UIView"]) {
45
+ // UIView *sub = [[UIView alloc] init];
46
+ // [view insertSubview:sub atIndex:0];
47
+ // NSLog(@"[View] insert view with kind=%@", viewKind);
48
+ // }
49
+ }
50
+
51
+ - (VeLivePushUIView *)view
52
+ {
53
+ VeLivePushUIView *view = [[VeLivePushUIView alloc] init];
54
+ view.accessibilityLabel = @"VeLivePushUIView";
55
+ NSLog(@"[View] create VeLivePushUIView success");
56
+ return view;
57
+ }
58
+
59
+ @end