@norcy/react-native-toolkit 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Norcy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @norcy/react-native-toolkit
2
+
3
+ My Toolkit
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @norcy/react-native-toolkit
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import ReactNativeToolkit from "@norcy/react-native-toolkit";
15
+
16
+ // ...
17
+
18
+ const result = await ReactNativeToolkit.multiply(3, 7);
19
+ ```
20
+
21
+ ## Contributing
22
+
23
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
24
+
25
+ ## License
26
+
27
+ MIT
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android_</name>
4
+ <comment>Project android_ created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.0))
5
+ connection.project.dir=
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -0,0 +1,130 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeToolkit_kotlinVersion']
4
+
5
+ repositories {
6
+ google()
7
+ jcenter()
8
+ }
9
+
10
+ dependencies {
11
+ classpath 'com.android.tools.build:gradle:3.2.1'
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ apply plugin: 'com.android.library'
18
+ apply plugin: 'kotlin-android'
19
+
20
+ def getExtOrDefault(name) {
21
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeToolkit_' + name]
22
+ }
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeToolkit_' + name]).toInteger()
26
+ }
27
+
28
+ android {
29
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
30
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
31
+ defaultConfig {
32
+ minSdkVersion 16
33
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
34
+ versionCode 1
35
+ versionName "1.0"
36
+
37
+ }
38
+
39
+ buildTypes {
40
+ release {
41
+ minifyEnabled false
42
+ }
43
+ }
44
+ lintOptions {
45
+ disable 'GradleCompatible'
46
+ }
47
+ compileOptions {
48
+ sourceCompatibility JavaVersion.VERSION_1_8
49
+ targetCompatibility JavaVersion.VERSION_1_8
50
+ }
51
+ }
52
+
53
+ repositories {
54
+ mavenCentral()
55
+ jcenter()
56
+ google()
57
+
58
+ def found = false
59
+ def defaultDir = null
60
+ def androidSourcesName = 'React Native sources'
61
+
62
+ if (rootProject.ext.has('reactNativeAndroidRoot')) {
63
+ defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
64
+ } else {
65
+ defaultDir = new File(
66
+ projectDir,
67
+ '/../../../node_modules/react-native/android'
68
+ )
69
+ }
70
+
71
+ if (defaultDir.exists()) {
72
+ maven {
73
+ url defaultDir.toString()
74
+ name androidSourcesName
75
+ }
76
+
77
+ logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
78
+ found = true
79
+ } else {
80
+ def parentDir = rootProject.projectDir
81
+
82
+ 1.upto(5, {
83
+ if (found) return true
84
+ parentDir = parentDir.parentFile
85
+
86
+ def androidSourcesDir = new File(
87
+ parentDir,
88
+ 'node_modules/react-native'
89
+ )
90
+
91
+ def androidPrebuiltBinaryDir = new File(
92
+ parentDir,
93
+ 'node_modules/react-native/android'
94
+ )
95
+
96
+ if (androidPrebuiltBinaryDir.exists()) {
97
+ maven {
98
+ url androidPrebuiltBinaryDir.toString()
99
+ name androidSourcesName
100
+ }
101
+
102
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
103
+ found = true
104
+ } else if (androidSourcesDir.exists()) {
105
+ maven {
106
+ url androidSourcesDir.toString()
107
+ name androidSourcesName
108
+ }
109
+
110
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
111
+ found = true
112
+ }
113
+ })
114
+ }
115
+
116
+ if (!found) {
117
+ throw new GradleException(
118
+ "${project.name}: unable to locate React Native android sources. " +
119
+ "Ensure you have you installed React Native as a dependency in your project and try again."
120
+ )
121
+ }
122
+ }
123
+
124
+ def kotlin_version = getExtOrDefault('kotlinVersion')
125
+
126
+ dependencies {
127
+ // noinspection GradleDynamicVersion
128
+ api 'com.facebook.react:react-native:+'
129
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
130
+ }
@@ -0,0 +1,4 @@
1
+ ReactNativeToolkit_kotlinVersion=1.3.50
2
+ ReactNativeToolkit_compileSdkVersion=28
3
+ ReactNativeToolkit_buildToolsVersion=28.0.3
4
+ ReactNativeToolkit_targetSdkVersion=28
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.norcyreactnativetoolkit">
3
+
4
+ </manifest>
@@ -0,0 +1,24 @@
1
+ package com.norcyreactnativetoolkit
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+
8
+ class ReactNativeToolkitModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
9
+
10
+ override fun getName(): String {
11
+ return "ReactNativeToolkit"
12
+ }
13
+
14
+ // Example method
15
+ // See https://facebook.github.io/react-native/docs/native-modules-android
16
+ @ReactMethod
17
+ fun multiply(a: Int, b: Int, promise: Promise) {
18
+
19
+ promise.resolve(a * b)
20
+
21
+ }
22
+
23
+
24
+ }
@@ -0,0 +1,20 @@
1
+ package com.norcyreactnativetoolkit
2
+
3
+ import java.util.Arrays
4
+ import java.util.Collections
5
+
6
+ import com.facebook.react.ReactPackage
7
+ import com.facebook.react.bridge.NativeModule
8
+ import com.facebook.react.bridge.ReactApplicationContext
9
+ import com.facebook.react.uimanager.ViewManager
10
+ import com.facebook.react.bridge.JavaScriptModule
11
+
12
+ class ReactNativeToolkitPackage : ReactPackage {
13
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
14
+ return Arrays.asList<NativeModule>(ReactNativeToolkitModule(reactContext))
15
+ }
16
+
17
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
18
+ return emptyList<ViewManager<*, *>>()
19
+ }
20
+ }
@@ -0,0 +1,17 @@
1
+ //
2
+ // NCYAPI.h
3
+ // iRead
4
+ //
5
+ // Created by Nx on 2023/7/31.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTBridgeModule.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface NCYReport : NSObject <RCTBridgeModule>
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,35 @@
1
+ //
2
+ // NCYAPI.m
3
+ // iRead
4
+ //
5
+ // Created by Nx on 2023/7/31.
6
+ //
7
+
8
+ #import "NCYReport.h"
9
+ #import <UMCommon/MobClick.h>
10
+
11
+ @implementation NCYReport
12
+
13
+ RCT_EXPORT_MODULE();
14
+
15
+ RCT_EXPORT_METHOD(report:(NSString *)key params:(NSDictionary *)params) {
16
+ [MobClick event:key attributes:params];
17
+ }
18
+
19
+ RCT_EXPORT_METHOD(signIn:(NSString *)userId) {
20
+ [MobClick profileSignInWithPUID:userId];
21
+ }
22
+
23
+ RCT_EXPORT_METHOD(signOut) {
24
+ [MobClick profileSignOff];
25
+ }
26
+
27
+ RCT_EXPORT_METHOD(enterPage:(NSString *)pageName) {
28
+ [MobClick beginLogPageView:pageName];
29
+ }
30
+
31
+ RCT_EXPORT_METHOD(leavePage:(NSString *)pageName) {
32
+ [MobClick endLogPageView:pageName];
33
+ }
34
+
35
+ @end
package/ios/NCYShare.h ADDED
@@ -0,0 +1,17 @@
1
+ //
2
+ // NCYShare.h
3
+ // Paxxword
4
+ //
5
+ // Created by Norcy on 2021/1/17.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTBridgeModule.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface NCYShare : NSObject <RCTBridgeModule>
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
package/ios/NCYShare.m ADDED
@@ -0,0 +1,80 @@
1
+ //
2
+ // NCYShare.m
3
+ // Paxxword
4
+ //
5
+ // Created by Norcy on 2021/1/17.
6
+ //
7
+
8
+ #import "NCYShare.h"
9
+ #import <React/RCTConvert.h>
10
+
11
+ @implementation NCYShare
12
+ RCT_EXPORT_MODULE()
13
+
14
+ - (dispatch_queue_t)methodQueue
15
+ {
16
+ return dispatch_get_main_queue();
17
+ }
18
+
19
+ RCT_EXPORT_METHOD(share:(NSDictionary *)options)
20
+ {
21
+ NSMutableArray<id> *items = [NSMutableArray array];
22
+ NSString *message = options[@"message"];
23
+ if (message)
24
+ {
25
+ [items addObject:message];
26
+ }
27
+
28
+ NSURL *URL = [RCTConvert NSURL:options[@"url"]];
29
+ if (URL)
30
+ {
31
+ [items addObject:URL];
32
+ }
33
+
34
+ UIImage *shareImage = nil;
35
+ NSString *localImage = options[@"localImage"];
36
+ if (localImage.length)
37
+ {
38
+ shareImage = [UIImage imageNamed:localImage];
39
+ if (!shareImage)
40
+ {
41
+ shareImage = [UIImage imageWithContentsOfFile:localImage];
42
+ }
43
+ }
44
+
45
+ if (!shareImage)
46
+ {
47
+ NSString *webImage = options[@"webImage"];
48
+ NSURL *imageURL = [NSURL URLWithString:webImage];
49
+ shareImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
50
+ }
51
+
52
+ if (shareImage)
53
+ {
54
+ [items addObject:shareImage];
55
+ }
56
+
57
+ if (items.count == 0)
58
+ {
59
+ RCTLogError(@"No `url` or `message` or `image` to share");
60
+ return;
61
+ }
62
+
63
+ UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
64
+
65
+ UIViewController *controller = RCTPresentedViewController();
66
+ [self presentViewController:shareController onParentViewController:controller];
67
+ }
68
+
69
+ - (void)presentViewController:(UIViewController *)alertController
70
+ onParentViewController:(UIViewController *)parentViewController
71
+ {
72
+ alertController.modalPresentationStyle = UIModalPresentationPopover;
73
+ UIView *sourceView = parentViewController.view;
74
+
75
+ alertController.popoverPresentationController.permittedArrowDirections = 0;
76
+ alertController.popoverPresentationController.sourceView = sourceView;
77
+ alertController.popoverPresentationController.sourceRect = sourceView.bounds;
78
+ [parentViewController presentViewController:alertController animated:YES completion:nil];
79
+ }
80
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // NCYVibration.h
3
+ // iRead
4
+ //
5
+ // Created by Norcy on 2021/10/23.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTBridgeModule.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface NCYVibration : NSObject <RCTBridgeModule>
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,38 @@
1
+ //
2
+ // NCYVibration.m
3
+ // iRead
4
+ //
5
+ // Created by Norcy on 2021/10/23.
6
+ //
7
+
8
+ #import "NCYVibration.h"
9
+ #import <UIKit/UIImpactFeedbackGenerator.h>
10
+
11
+ @interface NCYVibration()
12
+ @property (nonatomic, strong) UIImpactFeedbackGenerator *feedBackGenertor;
13
+ @end
14
+
15
+ @implementation NCYVibration
16
+ RCT_EXPORT_MODULE();
17
+
18
+ - (instancetype)init
19
+ {
20
+ if (self = [super init])
21
+ {
22
+ self.feedBackGenertor = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
23
+ }
24
+ return self;
25
+ }
26
+
27
+ + (BOOL)requiresMainQueueSetup
28
+ {
29
+ return YES;
30
+ }
31
+
32
+ RCT_EXPORT_METHOD(vibrate)
33
+ {
34
+ dispatch_async(dispatch_get_main_queue(), ^{
35
+ [self.feedBackGenertor impactOccurred];
36
+ });
37
+ }
38
+ @end
@@ -0,0 +1,20 @@
1
+ //
2
+ // NSURLSession+DisableProxy.h
3
+ // iRead
4
+ //
5
+ // Created by Nx on 2022/6/13.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface NSURLSession (DisableProxy)
13
+
14
+ + (void)disableHttpProxy;
15
+
16
+ + (void)enableHttpProxy;
17
+
18
+ @end
19
+
20
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,84 @@
1
+ //
2
+ // NSURLSession+DisableProxy.m
3
+ // iRead
4
+ //
5
+ // Created by Nx on 2022/6/13.
6
+ //
7
+
8
+ #import "NSURLSession+DisableProxy.h"
9
+ #import <objc/runtime.h>
10
+
11
+ static BOOL isDisableHttpProxy = NO;
12
+
13
+ @implementation NSURLSession (DisableProxy)
14
+ + (void)load
15
+ {
16
+ static dispatch_once_t onceToken;
17
+ dispatch_once(&onceToken, ^{
18
+ swizzleMethod(object_getClass(self), @selector(sessionWithConfiguration:delegate:delegateQueue:), @selector(dp_sessionWithConfiguration:delegate:delegateQueue:));
19
+ swizzleMethod(object_getClass(self), @selector(sessionWithConfiguration:), @selector(dp_sessionWithConfiguration:));
20
+ });
21
+ }
22
+
23
+ + (void)disableHttpProxy
24
+ {
25
+ isDisableHttpProxy = YES;
26
+ }
27
+
28
+ + (void)enableHttpProxy
29
+ {
30
+ isDisableHttpProxy = NO;
31
+ }
32
+
33
+ + (NSURLSession *)dp_sessionWithConfiguration:(NSURLSessionConfiguration *)configuration
34
+ delegate:(nullable id<NSURLSessionDelegate>)delegate
35
+ delegateQueue:(nullable NSOperationQueue *)queue
36
+ {
37
+ if (!configuration)
38
+ {
39
+ configuration = [[NSURLSessionConfiguration alloc] init];
40
+ }
41
+ if (isDisableHttpProxy)
42
+ {
43
+ configuration.connectionProxyDictionary = @{};
44
+ }
45
+ return [self dp_sessionWithConfiguration:configuration delegate:delegate delegateQueue:queue];
46
+ }
47
+
48
+ + (NSURLSession *)dp_sessionWithConfiguration:(NSURLSessionConfiguration *)configuration
49
+ {
50
+ if (configuration && isDisableHttpProxy)
51
+ {
52
+ configuration.connectionProxyDictionary = @{};
53
+ }
54
+ return [self dp_sessionWithConfiguration:configuration];
55
+ }
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
+ @end
@@ -0,0 +1,285 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+
11
+
12
+ 5E555C0D2413F4C50049A1A2 /* ReactNativeToolkit.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* ReactNativeToolkit.mm */; };
13
+ /* End PBXBuildFile section */
14
+
15
+ /* Begin PBXCopyFilesBuildPhase section */
16
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
17
+ isa = PBXCopyFilesBuildPhase;
18
+ buildActionMask = 2147483647;
19
+ dstPath = "include/$(PRODUCT_NAME)";
20
+ dstSubfolderSpec = 16;
21
+ files = (
22
+ );
23
+ runOnlyForDeploymentPostprocessing = 0;
24
+ };
25
+ /* End PBXCopyFilesBuildPhase section */
26
+
27
+ /* Begin PBXFileReference section */
28
+ 134814201AA4EA6300B7C361 /* libReactNativeToolkit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNativeToolkit.a; sourceTree = BUILT_PRODUCTS_DIR; };
29
+
30
+
31
+ B3E7B5881CC2AC0600A0062D /* ReactNativeToolkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReactNativeToolkit.h; sourceTree = "<group>"; };
32
+ B3E7B5891CC2AC0600A0062D /* ReactNativeToolkit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ReactNativeToolkit.mm; sourceTree = "<group>"; };
33
+
34
+ /* End PBXFileReference section */
35
+
36
+ /* Begin PBXFrameworksBuildPhase section */
37
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
38
+ isa = PBXFrameworksBuildPhase;
39
+ buildActionMask = 2147483647;
40
+ files = (
41
+ );
42
+ runOnlyForDeploymentPostprocessing = 0;
43
+ };
44
+ /* End PBXFrameworksBuildPhase section */
45
+
46
+ /* Begin PBXGroup section */
47
+ 134814211AA4EA7D00B7C361 /* Products */ = {
48
+ isa = PBXGroup;
49
+ children = (
50
+ 134814201AA4EA6300B7C361 /* libReactNativeToolkit.a */,
51
+ );
52
+ name = Products;
53
+ sourceTree = "<group>";
54
+ };
55
+ 58B511D21A9E6C8500147676 = {
56
+ isa = PBXGroup;
57
+ children = (
58
+
59
+
60
+ B3E7B5881CC2AC0600A0062D /* ReactNativeToolkit.h */,
61
+ B3E7B5891CC2AC0600A0062D /* ReactNativeToolkit.mm */,
62
+
63
+ 134814211AA4EA7D00B7C361 /* Products */,
64
+ );
65
+ sourceTree = "<group>";
66
+ };
67
+ /* End PBXGroup section */
68
+
69
+ /* Begin PBXNativeTarget section */
70
+ 58B511DA1A9E6C8500147676 /* ReactNativeToolkit */ = {
71
+ isa = PBXNativeTarget;
72
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "ReactNativeToolkit" */;
73
+ buildPhases = (
74
+ 58B511D71A9E6C8500147676 /* Sources */,
75
+ 58B511D81A9E6C8500147676 /* Frameworks */,
76
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
77
+ );
78
+ buildRules = (
79
+ );
80
+ dependencies = (
81
+ );
82
+ name = ReactNativeToolkit;
83
+ productName = RCTDataManager;
84
+ productReference = 134814201AA4EA6300B7C361 /* libReactNativeToolkit.a */;
85
+ productType = "com.apple.product-type.library.static";
86
+ };
87
+ /* End PBXNativeTarget section */
88
+
89
+ /* Begin PBXProject section */
90
+ 58B511D31A9E6C8500147676 /* Project object */ = {
91
+ isa = PBXProject;
92
+ attributes = {
93
+ LastUpgradeCheck = 0920;
94
+ ORGANIZATIONNAME = Facebook;
95
+ TargetAttributes = {
96
+ 58B511DA1A9E6C8500147676 = {
97
+ CreatedOnToolsVersion = 6.1.1;
98
+ };
99
+ };
100
+ };
101
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "ReactNativeToolkit" */;
102
+ compatibilityVersion = "Xcode 3.2";
103
+ developmentRegion = English;
104
+ hasScannedForEncodings = 0;
105
+ knownRegions = (
106
+ English,
107
+ en,
108
+ );
109
+ mainGroup = 58B511D21A9E6C8500147676;
110
+ productRefGroup = 58B511D21A9E6C8500147676;
111
+ projectDirPath = "";
112
+ projectRoot = "";
113
+ targets = (
114
+ 58B511DA1A9E6C8500147676 /* ReactNativeToolkit */,
115
+ );
116
+ };
117
+ /* End PBXProject section */
118
+
119
+ /* Begin PBXSourcesBuildPhase section */
120
+ 58B511D71A9E6C8500147676 /* Sources */ = {
121
+ isa = PBXSourcesBuildPhase;
122
+ buildActionMask = 2147483647;
123
+ files = (
124
+
125
+
126
+ 5E555C0D2413F4C50049A1A2 /* ReactNativeToolkit.mm in Sources */,
127
+
128
+ );
129
+ runOnlyForDeploymentPostprocessing = 0;
130
+ };
131
+ /* End PBXSourcesBuildPhase section */
132
+
133
+ /* Begin XCBuildConfiguration section */
134
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
135
+ isa = XCBuildConfiguration;
136
+ buildSettings = {
137
+ ALWAYS_SEARCH_USER_PATHS = NO;
138
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139
+ CLANG_CXX_LIBRARY = "libc++";
140
+ CLANG_ENABLE_MODULES = YES;
141
+ CLANG_ENABLE_OBJC_ARC = YES;
142
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
143
+ CLANG_WARN_BOOL_CONVERSION = YES;
144
+ CLANG_WARN_COMMA = YES;
145
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
146
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
147
+ CLANG_WARN_EMPTY_BODY = YES;
148
+ CLANG_WARN_ENUM_CONVERSION = YES;
149
+ CLANG_WARN_INFINITE_RECURSION = YES;
150
+ CLANG_WARN_INT_CONVERSION = YES;
151
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
152
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
153
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
154
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
155
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
156
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
157
+ CLANG_WARN_UNREACHABLE_CODE = YES;
158
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
159
+ COPY_PHASE_STRIP = NO;
160
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
161
+ ENABLE_TESTABILITY = YES;
162
+ GCC_C_LANGUAGE_STANDARD = gnu99;
163
+ GCC_DYNAMIC_NO_PIC = NO;
164
+ GCC_NO_COMMON_BLOCKS = YES;
165
+ GCC_OPTIMIZATION_LEVEL = 0;
166
+ GCC_PREPROCESSOR_DEFINITIONS = (
167
+ "DEBUG=1",
168
+ "$(inherited)",
169
+ );
170
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
171
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
172
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
173
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
174
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
175
+ GCC_WARN_UNUSED_FUNCTION = YES;
176
+ GCC_WARN_UNUSED_VARIABLE = YES;
177
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
178
+ MTL_ENABLE_DEBUG_INFO = YES;
179
+ ONLY_ACTIVE_ARCH = YES;
180
+ SDKROOT = iphoneos;
181
+ };
182
+ name = Debug;
183
+ };
184
+ 58B511EE1A9E6C8500147676 /* Release */ = {
185
+ isa = XCBuildConfiguration;
186
+ buildSettings = {
187
+ ALWAYS_SEARCH_USER_PATHS = NO;
188
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
189
+ CLANG_CXX_LIBRARY = "libc++";
190
+ CLANG_ENABLE_MODULES = YES;
191
+ CLANG_ENABLE_OBJC_ARC = YES;
192
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
193
+ CLANG_WARN_BOOL_CONVERSION = YES;
194
+ CLANG_WARN_COMMA = YES;
195
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
196
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
197
+ CLANG_WARN_EMPTY_BODY = YES;
198
+ CLANG_WARN_ENUM_CONVERSION = YES;
199
+ CLANG_WARN_INFINITE_RECURSION = YES;
200
+ CLANG_WARN_INT_CONVERSION = YES;
201
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
202
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
203
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
204
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
205
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
206
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
207
+ CLANG_WARN_UNREACHABLE_CODE = YES;
208
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
209
+ COPY_PHASE_STRIP = YES;
210
+ ENABLE_NS_ASSERTIONS = NO;
211
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
212
+ GCC_C_LANGUAGE_STANDARD = gnu99;
213
+ GCC_NO_COMMON_BLOCKS = YES;
214
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
215
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
216
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
217
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
218
+ GCC_WARN_UNUSED_FUNCTION = YES;
219
+ GCC_WARN_UNUSED_VARIABLE = YES;
220
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
221
+ MTL_ENABLE_DEBUG_INFO = NO;
222
+ SDKROOT = iphoneos;
223
+ VALIDATE_PRODUCT = YES;
224
+ };
225
+ name = Release;
226
+ };
227
+ 58B511F01A9E6C8500147676 /* Debug */ = {
228
+ isa = XCBuildConfiguration;
229
+ buildSettings = {
230
+ HEADER_SEARCH_PATHS = (
231
+ "$(inherited)",
232
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
233
+ "$(SRCROOT)/../../../React/**",
234
+ "$(SRCROOT)/../../react-native/React/**",
235
+ );
236
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
237
+ OTHER_LDFLAGS = "-ObjC";
238
+ PRODUCT_NAME = ReactNativeToolkit;
239
+ SKIP_INSTALL = YES;
240
+
241
+ };
242
+ name = Debug;
243
+ };
244
+ 58B511F11A9E6C8500147676 /* Release */ = {
245
+ isa = XCBuildConfiguration;
246
+ buildSettings = {
247
+ HEADER_SEARCH_PATHS = (
248
+ "$(inherited)",
249
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
250
+ "$(SRCROOT)/../../../React/**",
251
+ "$(SRCROOT)/../../react-native/React/**",
252
+ );
253
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
254
+ OTHER_LDFLAGS = "-ObjC";
255
+ PRODUCT_NAME = ReactNativeToolkit;
256
+ SKIP_INSTALL = YES;
257
+
258
+ };
259
+ name = Release;
260
+ };
261
+ /* End XCBuildConfiguration section */
262
+
263
+ /* Begin XCConfigurationList section */
264
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "ReactNativeToolkit" */ = {
265
+ isa = XCConfigurationList;
266
+ buildConfigurations = (
267
+ 58B511ED1A9E6C8500147676 /* Debug */,
268
+ 58B511EE1A9E6C8500147676 /* Release */,
269
+ );
270
+ defaultConfigurationIsVisible = 0;
271
+ defaultConfigurationName = Release;
272
+ };
273
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "ReactNativeToolkit" */ = {
274
+ isa = XCConfigurationList;
275
+ buildConfigurations = (
276
+ 58B511F01A9E6C8500147676 /* Debug */,
277
+ 58B511F11A9E6C8500147676 /* Release */,
278
+ );
279
+ defaultConfigurationIsVisible = 0;
280
+ defaultConfigurationName = Release;
281
+ };
282
+ /* End XCConfigurationList section */
283
+ };
284
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
285
+ }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ </Workspace>
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setPrefString = exports.getPrefString = void 0;
7
+ var _reactNative = require("react-native");
8
+ const setPrefString = (key, value) => {
9
+ if (_reactNative.Platform.OS === 'ios') {
10
+ _reactNative.Settings.set({
11
+ [key]: value
12
+ });
13
+ } else {
14
+ if (!_reactNative.NativeModules.NCYAPI) {
15
+ return;
16
+ }
17
+ _reactNative.NativeModules.NCYAPI.setData(key, value);
18
+ }
19
+ };
20
+ exports.setPrefString = setPrefString;
21
+ const getPrefString = key => {
22
+ if (_reactNative.Platform.OS === 'ios') {
23
+ return _reactNative.Settings.get(key);
24
+ } else {
25
+ if (!_reactNative.NativeModules.NCYAPI) {
26
+ return '';
27
+ }
28
+ return _reactNative.NativeModules.NCYAPI.getData(key);
29
+ }
30
+ };
31
+ exports.getPrefString = getPrefString;
32
+ //# sourceMappingURL=SyncPrefData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","setPrefString","key","value","Platform","OS","Settings","set","NativeModules","NCYAPI","setData","exports","getPrefString","get","getData"],"sources":["SyncPrefData.ts"],"sourcesContent":["import { NativeModules, Platform, Settings } from 'react-native';\n\nexport const setPrefString = (key: string, value: string) => {\n if (Platform.OS === 'ios') {\n Settings.set({ [key]: value });\n } else {\n if (!NativeModules.NCYAPI) {\n return;\n }\n NativeModules.NCYAPI.setData(key, value);\n }\n};\n\nexport const getPrefString = (key: string): string => {\n if (Platform.OS === 'ios') {\n return Settings.get(key);\n } else {\n if (!NativeModules.NCYAPI) {\n return '';\n }\n return NativeModules.NCYAPI.getData(key);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,aAAa,GAAGA,CAACC,GAAW,EAAEC,KAAa,KAAK;EAC3D,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzBC,qBAAQ,CAACC,GAAG,CAAC;MAAE,CAACL,GAAG,GAAGC;IAAM,CAAC,CAAC;EAChC,CAAC,MAAM;IACL,IAAI,CAACK,0BAAa,CAACC,MAAM,EAAE;MACzB;IACF;IACAD,0BAAa,CAACC,MAAM,CAACC,OAAO,CAACR,GAAG,EAAEC,KAAK,CAAC;EAC1C;AACF,CAAC;AAACQ,OAAA,CAAAV,aAAA,GAAAA,aAAA;AAEK,MAAMW,aAAa,GAAIV,GAAW,IAAa;EACpD,IAAIE,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOC,qBAAQ,CAACO,GAAG,CAACX,GAAG,CAAC;EAC1B,CAAC,MAAM;IACL,IAAI,CAACM,0BAAa,CAACC,MAAM,EAAE;MACzB,OAAO,EAAE;IACX;IACA,OAAOD,0BAAa,CAACC,MAAM,CAACK,OAAO,CAACZ,GAAG,CAAC;EAC1C;AACF,CAAC;AAACS,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ const {
9
+ ReactNativeToolkit
10
+ } = _reactNative.NativeModules;
11
+ var _default = exports.default = ReactNativeToolkit;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","ReactNativeToolkit","NativeModules","_default","exports","default"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\n\ntype ReactNativeToolkitType = {\n multiply(a: number, b: number): Promise<number>;\n};\n\nconst { ReactNativeToolkit } = NativeModules;\n\nexport default ReactNativeToolkit as ReactNativeToolkitType;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,MAAM;EAAEC;AAAmB,CAAC,GAAGC,0BAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE9BJ,kBAAkB"}
@@ -0,0 +1,24 @@
1
+ import { NativeModules, Platform, Settings } from 'react-native';
2
+ export const setPrefString = (key, value) => {
3
+ if (Platform.OS === 'ios') {
4
+ Settings.set({
5
+ [key]: value
6
+ });
7
+ } else {
8
+ if (!NativeModules.NCYAPI) {
9
+ return;
10
+ }
11
+ NativeModules.NCYAPI.setData(key, value);
12
+ }
13
+ };
14
+ export const getPrefString = key => {
15
+ if (Platform.OS === 'ios') {
16
+ return Settings.get(key);
17
+ } else {
18
+ if (!NativeModules.NCYAPI) {
19
+ return '';
20
+ }
21
+ return NativeModules.NCYAPI.getData(key);
22
+ }
23
+ };
24
+ //# sourceMappingURL=SyncPrefData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","Settings","setPrefString","key","value","OS","set","NCYAPI","setData","getPrefString","get","getData"],"sources":["SyncPrefData.ts"],"sourcesContent":["import { NativeModules, Platform, Settings } from 'react-native';\n\nexport const setPrefString = (key: string, value: string) => {\n if (Platform.OS === 'ios') {\n Settings.set({ [key]: value });\n } else {\n if (!NativeModules.NCYAPI) {\n return;\n }\n NativeModules.NCYAPI.setData(key, value);\n }\n};\n\nexport const getPrefString = (key: string): string => {\n if (Platform.OS === 'ios') {\n return Settings.get(key);\n } else {\n if (!NativeModules.NCYAPI) {\n return '';\n }\n return NativeModules.NCYAPI.getData(key);\n }\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AAEhE,OAAO,MAAMC,aAAa,GAAGA,CAACC,GAAW,EAAEC,KAAa,KAAK;EAC3D,IAAIJ,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;IACzBJ,QAAQ,CAACK,GAAG,CAAC;MAAE,CAACH,GAAG,GAAGC;IAAM,CAAC,CAAC;EAChC,CAAC,MAAM;IACL,IAAI,CAACL,aAAa,CAACQ,MAAM,EAAE;MACzB;IACF;IACAR,aAAa,CAACQ,MAAM,CAACC,OAAO,CAACL,GAAG,EAAEC,KAAK,CAAC;EAC1C;AACF,CAAC;AAED,OAAO,MAAMK,aAAa,GAAIN,GAAW,IAAa;EACpD,IAAIH,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOJ,QAAQ,CAACS,GAAG,CAACP,GAAG,CAAC;EAC1B,CAAC,MAAM;IACL,IAAI,CAACJ,aAAa,CAACQ,MAAM,EAAE;MACzB,OAAO,EAAE;IACX;IACA,OAAOR,aAAa,CAACQ,MAAM,CAACI,OAAO,CAACR,GAAG,CAAC;EAC1C;AACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { NativeModules } from 'react-native';
2
+ const {
3
+ ReactNativeToolkit
4
+ } = NativeModules;
5
+ export default ReactNativeToolkit;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","ReactNativeToolkit"],"sources":["index.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\n\ntype ReactNativeToolkitType = {\n multiply(a: number, b: number): Promise<number>;\n};\n\nconst { ReactNativeToolkit } = NativeModules;\n\nexport default ReactNativeToolkit as ReactNativeToolkitType;\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,MAAM;EAAEC;AAAmB,CAAC,GAAGD,aAAa;AAE5C,eAAeC,kBAAkB"}
@@ -0,0 +1,2 @@
1
+ export declare const setPrefString: (key: string, value: string) => void;
2
+ export declare const getPrefString: (key: string) => string;
@@ -0,0 +1,5 @@
1
+ type ReactNativeToolkitType = {
2
+ multiply(a: number, b: number): Promise<number>;
3
+ };
4
+ declare const _default: ReactNativeToolkitType;
5
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,149 @@
1
+ {
2
+ "name": "@norcy/react-native-toolkit",
3
+ "version": "0.1.0",
4
+ "description": "My Toolkit",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "norcy-react-native-toolkit.podspec",
17
+ "!lib/typescript/example",
18
+ "!**/__tests__",
19
+ "!**/__fixtures__",
20
+ "!**/__mocks__"
21
+ ],
22
+ "scripts": {
23
+ "test": "jest",
24
+ "typescript": "tsc --noEmit",
25
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
26
+ "prepare": "bob build",
27
+ "release": "release-it",
28
+ "example": "yarn --cwd example",
29
+ "pods": "cd example && pod-install --quiet",
30
+ "bootstrap": "yarn example && yarn && yarn pods"
31
+ },
32
+ "keywords": [
33
+ "react-native",
34
+ "ios",
35
+ "android"
36
+ ],
37
+ "repository": "https://github.com/Norcy/react-native-toolkit",
38
+ "author": "Norcy <chenyg32@gmail.com> (https://github.com/Norcy)",
39
+ "license": "MIT",
40
+ "bugs": {
41
+ "url": "https://github.com/Norcy/react-native-toolkit/issues"
42
+ },
43
+ "homepage": "https://github.com/Norcy/react-native-toolkit#readme",
44
+ "devDependencies": {
45
+ "@commitlint/config-conventional": "^8.3.4",
46
+ "@react-native-community/bob": "^0.16.2",
47
+ "@react-native-community/eslint-config": "^3.0.0",
48
+ "@release-it/conventional-changelog": "^1.1.4",
49
+ "@types/jest": "^26.0.0",
50
+ "@types/react": "^16.9.19",
51
+ "@types/react-native": "0.62.13",
52
+ "commitlint": "^8.3.5",
53
+ "eslint": "^7.2.0",
54
+ "eslint-config-prettier": "^6.11.0",
55
+ "eslint-plugin-prettier": "^3.1.3",
56
+ "husky": "^4.2.5",
57
+ "jest": "^26.0.1",
58
+ "pod-install": "^0.1.0",
59
+ "prettier": "^2.0.5",
60
+ "react": "16.11.0",
61
+ "react-native": "0.62.2",
62
+ "release-it": "^13.5.8",
63
+ "typescript": "^5.0.2"
64
+ },
65
+ "peerDependencies": {
66
+ "react": "*",
67
+ "react-native": "*"
68
+ },
69
+ "jest": {
70
+ "preset": "react-native",
71
+ "modulePathIgnorePatterns": [
72
+ "<rootDir>/example/node_modules",
73
+ "<rootDir>/lib/"
74
+ ]
75
+ },
76
+ "husky": {
77
+ "hooks": {
78
+ "pre-commit": "yarn lint && yarn typescript"
79
+ }
80
+ },
81
+ "commitlint": {
82
+ "extends": [
83
+ "@commitlint/config-conventional"
84
+ ]
85
+ },
86
+ "release-it": {
87
+ "git": {
88
+ "commitMessage": "chore: release ${version}",
89
+ "tagName": "v${version}"
90
+ },
91
+ "npm": {
92
+ "publish": true
93
+ },
94
+ "github": {
95
+ "release": true
96
+ },
97
+ "plugins": {
98
+ "@release-it/conventional-changelog": {
99
+ "preset": "angular"
100
+ }
101
+ }
102
+ },
103
+ "eslintConfig": {
104
+ "extends": [
105
+ "@react-native-community",
106
+ "prettier"
107
+ ],
108
+ "rules": {
109
+ "prettier/prettier": [
110
+ "error",
111
+ {
112
+ "quoteProps": "consistent",
113
+ "singleQuote": true,
114
+ "tabWidth": 2,
115
+ "trailingComma": "es5",
116
+ "useTabs": false
117
+ }
118
+ ]
119
+ }
120
+ },
121
+ "eslintIgnore": [
122
+ "node_modules/",
123
+ "lib/"
124
+ ],
125
+ "prettier": {
126
+ "quoteProps": "consistent",
127
+ "singleQuote": true,
128
+ "tabWidth": 2,
129
+ "trailingComma": "es5",
130
+ "useTabs": false
131
+ },
132
+ "@react-native-community/bob": {
133
+ "source": "src",
134
+ "output": "lib",
135
+ "targets": [
136
+ "commonjs",
137
+ "module",
138
+ "typescript"
139
+ ]
140
+ },
141
+ "resolutions": {
142
+ "@react-native-community/cli": "~4.13.1",
143
+ "@react-native-community/cli-tools": "4.13.0",
144
+ "@types/react": "16.9.56"
145
+ },
146
+ "publishConfig": {
147
+ "access": "public"
148
+ }
149
+ }
@@ -0,0 +1,23 @@
1
+ import { NativeModules, Platform, Settings } from 'react-native';
2
+
3
+ export const setPrefString = (key: string, value: string) => {
4
+ if (Platform.OS === 'ios') {
5
+ Settings.set({ [key]: value });
6
+ } else {
7
+ if (!NativeModules.NCYAPI) {
8
+ return;
9
+ }
10
+ NativeModules.NCYAPI.setData(key, value);
11
+ }
12
+ };
13
+
14
+ export const getPrefString = (key: string): string => {
15
+ if (Platform.OS === 'ios') {
16
+ return Settings.get(key);
17
+ } else {
18
+ if (!NativeModules.NCYAPI) {
19
+ return '';
20
+ }
21
+ return NativeModules.NCYAPI.getData(key);
22
+ }
23
+ };
package/src/index.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import { NativeModules } from 'react-native';
2
+
3
+ type ReactNativeToolkitType = {
4
+ multiply(a: number, b: number): Promise<number>;
5
+ };
6
+
7
+ const { ReactNativeToolkit } = NativeModules;
8
+
9
+ export default ReactNativeToolkit as ReactNativeToolkitType;