@norcy/react-native-toolkit 0.1.127 → 0.1.128

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/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,15 @@
1
+ //
2
+ // MethodSwizzleHelper.h
3
+ // ReactNativeToolkit
4
+ //
5
+ // Created by Norcy on 2024/12/19.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <objc/runtime.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector);
14
+
15
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,35 @@
1
+ //
2
+ // MethodSwizzleHelper.m
3
+ // ReactNativeToolkit
4
+ //
5
+ // Created by Norcy on 2024/12/19.
6
+ //
7
+
8
+ #import "MethodSwizzleHelper.h"
9
+
10
+ void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector)
11
+ {
12
+ // 获取 Method
13
+ Method originalMethod = class_getInstanceMethod(class, originalSelector);
14
+ Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
15
+
16
+ // 确保这两个方法一定存在(要么在本类,要么在其父类里)
17
+ if (originalMethod && swizzledMethod)
18
+ {
19
+ // 如果本类没有 origin 方法,则给 originalSelector 添加 swizzled 实现(origin 方法在父类,因为 originalMethod 不为空),返回 YES
20
+ // 如果本类有 origin 方法,则添加失败,返回 NO
21
+ BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
22
+
23
+ if (didAddMethod)
24
+ {
25
+ // 添加成功,表示已实现 originalSelector -> swizzledIMP
26
+ // 接下来实现 swizzledSelector -> originalIMP
27
+ class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
28
+ }
29
+ else
30
+ {
31
+ // 添加失败,表示类里原本就有 originalIMP,只需要交换这两个方法的实现即可
32
+ method_exchangeImplementations(originalMethod, swizzledMethod);
33
+ }
34
+ }
35
+ }
@@ -6,7 +6,7 @@
6
6
  //
7
7
 
8
8
  #import "NSURLSession+DisableProxy.h"
9
- #import <objc/runtime.h>
9
+ #import "MethodSwizzleHelper.h"
10
10
 
11
11
  static BOOL isDisableHttpProxy = NO;
12
12
 
@@ -54,31 +54,4 @@ static BOOL isDisableHttpProxy = NO;
54
54
  return [self dp_sessionWithConfiguration:configuration];
55
55
  }
56
56
 
57
- void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector)
58
- {
59
- // 获取 Method
60
- Method originalMethod = class_getInstanceMethod(class, originalSelector);
61
- Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
62
-
63
- // 确保这两个方法一定存在(要么在本类,要么在其父类里)
64
- if (originalMethod && swizzledMethod)
65
- {
66
- // 如果本类没有 origin 方法,则给 originalSelector 添加 swizzled 实现(origin 方法在父类,因为 originalMethod 不为空),返回 YES
67
- // 如果本类有 origin 方法,则添加失败,返回 NO
68
- BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
69
-
70
- if (didAddMethod)
71
- {
72
- // 添加成功,表示已实现 originalSelector -> swizzledIMP
73
- // 接下来实现 swizzledSelector -> originalIMP
74
- class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
75
- }
76
- else
77
- {
78
- // 添加失败,表示类里原本就有 originalIMP,只需要交换这两个方法的实现即可
79
- method_exchangeImplementations(originalMethod, swizzledMethod);
80
- }
81
- }
82
- }
83
-
84
57
  @end
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>ReactNativeToolkit.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,16 @@
1
+ //
2
+ // UIApplication+OpenURLHook.h
3
+ // ReactNativeToolkit
4
+ //
5
+ // Created by Norcy on 2024/12/19.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface UIApplication (OpenURLHook)
13
+
14
+ @end
15
+
16
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
1
+ //
2
+ // UIApplication+OpenURLHook.m
3
+ // ReactNativeToolkit
4
+ //
5
+ // Created by Norcy on 2024/12/19.
6
+ //
7
+
8
+ #import "UIApplication+OpenURLHook.h"
9
+ #import <objc/runtime.h>
10
+ #import "MethodSwizzleHelper.h"
11
+
12
+ @implementation UIApplication (OpenURLHook)
13
+
14
+ + (void)load
15
+ {
16
+ static dispatch_once_t onceToken;
17
+ dispatch_once(&onceToken, ^{
18
+ swizzleMethod(self, @selector(openURL:), @selector(hook_openURL:));
19
+ });
20
+ }
21
+
22
+ - (BOOL)hook_openURL:(NSURL *)url
23
+ {
24
+ [self openURL:url options:@{} completionHandler:nil];
25
+ return YES;
26
+ }
27
+
28
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norcy/react-native-toolkit",
3
- "version": "0.1.127",
3
+ "version": "0.1.128",
4
4
  "description": "My Toolkit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",