packages = new ArrayList();
33 | // packages.add(new TerraReactPackage());
34 | return packages;
35 | }
36 |
37 | @Override
38 | protected String getJSMainModuleName() {
39 | return "index";
40 | }
41 |
42 | };
43 |
44 | @Override
45 | public ReactNativeHost getReactNativeHost() {
46 | return mReactNativeHost;
47 | }
48 |
49 | @Override
50 | public void onCreate() {
51 | super.onCreate();
52 | SoLoader.init(this, /* native exopackage */ false);
53 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled
54 | }
55 |
56 | /**
57 | * Loads Flipper in React Native templates.
58 | *
59 | * @param context
60 | */
61 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
62 | if (BuildConfig.DEBUG) {
63 | try {
64 | /*
65 | We use reflection here to pick up the class that initializes Flipper,
66 | since Flipper library is not available in release mode
67 | */
68 | Class> aClass = Class.forName("com.example.terrareact.ReactNativeFlipper");
69 | aClass
70 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
71 | .invoke(null, context, reactInstanceManager);
72 | } catch (ClassNotFoundException e) {
73 | e.printStackTrace();
74 | } catch (NoSuchMethodException e) {
75 | e.printStackTrace();
76 | } catch (IllegalAccessException e) {
77 | e.printStackTrace();
78 | } catch (InvocationTargetException e) {
79 | e.printStackTrace();
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/src/enums/ActivityTypes.ts:
--------------------------------------------------------------------------------
1 | export enum ActivityType {
2 | IN_VEHICLE = 0,
3 | BIKING = 1,
4 | STILL = 3,
5 | UNKNOWN = 4,
6 | TILTING = 5,
7 | WALKING = 7,
8 | RUNNING = 8,
9 | AEROBICS = 9,
10 | BADMINTON = 10,
11 | BASEBALL = 11,
12 | BASKETBALL = 12,
13 | BIATHLON = 13,
14 | HANDBIKING = 14,
15 | MOUNTAIN_BIKING = 15,
16 | ROAD_BIKING = 16,
17 | SPINNING = 17,
18 | STATIONARY_BIKING = 18,
19 | UTILITY_BIKING = 19,
20 | BOXING = 20,
21 | CALISTHENICS = 21,
22 | CIRCUIT_TRAINING = 22,
23 | CRICKET = 23,
24 | DANCING = 24,
25 | ELLIPTICAL = 25,
26 | FENCING = 26,
27 | AMERICAN_FOOTBALL = 27,
28 | AUSTRALIAN_FOOTBALL = 28,
29 | ENGLISH_FOOTBALL = 29,
30 | FRISBEE = 30,
31 | GARDENING = 31,
32 | GOLF = 32,
33 | GYMNASTICS = 33,
34 | HANDBALL = 34,
35 | HIKING = 35,
36 | HOCKEY = 36,
37 | HORSEBACK_RIDING = 37,
38 | HOUSEWORK = 38,
39 | JUMPING_ROPE = 39,
40 | KAYAKING = 40,
41 | KETTLEBELL_TRAINING = 41,
42 | KICKBOXING = 42,
43 | KITESURFING = 43,
44 | MARTIAL_ARTS = 44,
45 | MEDITATION = 45,
46 | MIXED_MARTIAL_ARTS = 46,
47 | P90X_EXERCISES = 47,
48 | PARAGLIDING = 48,
49 | PILATES = 49,
50 | POLO = 50,
51 | RACQUETBALL = 51,
52 | ROCK_CLIMBING = 52,
53 | ROWING = 53,
54 | ROWING_MACHINE = 54,
55 | RUGBY = 55,
56 | JOGGING = 56,
57 | RUNNING_ON_SAND = 57,
58 | TREADMILL_RUNNING = 58,
59 | SAILING = 59,
60 | SCUBA_DIVING = 60,
61 | SKATEBOARDING = 61,
62 | SKATING = 62,
63 | CROSS_SKATING = 63,
64 | INDOOR_ROLLERBLADING = 64,
65 | SKIING = 65,
66 | BACK_COUNTRY_SKIING = 66,
67 | CROSS_COUNTRY_SKIING = 67,
68 | DOWNHILL_SKIING = 68,
69 | KITE_SKIING = 69,
70 | ROLLER_SKIING = 70,
71 | SLEDDING = 71,
72 | SNOWBOARDING = 73,
73 | SNOWMOBILE = 74,
74 | SNOWSHOEING = 75,
75 | SQUASH = 76,
76 | STAIR_CLIMBING = 77,
77 | STAIR_CLIMBING_MACHINE = 78,
78 | STAND_UP_PADDLEBOARDING = 79,
79 | STRENGTH_TRAINING = 80,
80 | SURFING = 81,
81 | SWIMMING = 82,
82 | SWIMMING_SWIMMING_POOL = 83,
83 | SWIMMING_OPEN_WATER = 84,
84 | TABLE_TENNIS = 85,
85 | TEAM_SPORTS = 86,
86 | TENNIS = 87,
87 | TREADMILL = 88,
88 | VOLLEYBALL = 89,
89 | VOLLEYBALL_BEACH = 90,
90 | VOLLEYBALL_INDOOR = 91,
91 | WAKEBOARDING = 92,
92 | WALKING_FITNESS = 93,
93 | NORDIC_WALKING = 94,
94 | WALKING_TREADMILL = 95,
95 | WATERPOLO = 96,
96 | WEIGHTLIFTING = 97,
97 | WHEELCHAIR = 98,
98 | WINDSURFING = 99,
99 | YOGA = 100,
100 | ZUMBA = 101,
101 | DIVING = 102,
102 | ERGOMETER = 103,
103 | ICE_SKATING = 104,
104 | INDOOR_SKATING = 105,
105 | CURLING = 106,
106 | OTHER = 108,
107 | CROSSFIT = 113,
108 | HIIT = 114,
109 | INTERVAL_TRAINING = 115,
110 | WALKING_STROLLER = 116,
111 | ELEVATOR = 117,
112 | ESCALATOR = 118,
113 | ARCHERY = 119,
114 | SOFTBALL = 120,
115 | GUIDED_BREATHING = 122,
116 | CARDIO_TRAINING = 123,
117 | LACROSSE = 124,
118 | STRETCHING = 125,
119 | TRIATHLON = 126,
120 | INLINE_SKATING = 127,
121 | SKY_DIVING = 128,
122 | PADDLING = 129,
123 | MOUNTAINEERING = 130,
124 | FISHING = 131,
125 | WATER_SKIING = 132,
126 | }
127 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/java/com/example/terrareact/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.example.terrareact;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32 | client.addPlugin(new ReactFlipperPlugin());
33 | client.addPlugin(new DatabasesFlipperPlugin(context));
34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35 | client.addPlugin(CrashReporterPlugin.getInstance());
36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37 | NetworkingModule.setCustomClientBuilder(
38 | new NetworkingModule.CustomClientBuilder() {
39 | @Override
40 | public void apply(OkHttpClient.Builder builder) {
41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42 | }
43 | });
44 | client.addPlugin(networkFlipperPlugin);
45 | client.start();
46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47 | // Hence we run if after all native modules have been initialized
48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49 | if (reactContext == null) {
50 | reactInstanceManager.addReactInstanceEventListener(
51 | new ReactInstanceManager.ReactInstanceEventListener() {
52 | @Override
53 | public void onReactContextInitialized(ReactContext reactContext) {
54 | reactInstanceManager.removeReactInstanceEventListener(this);
55 | reactContext.runOnNativeModulesQueueThread(
56 | new Runnable() {
57 | @Override
58 | public void run() {
59 | client.addPlugin(new FrescoFlipperPlugin());
60 | }
61 | });
62 | }
63 | });
64 | } else {
65 | client.addPlugin(new FrescoFlipperPlugin());
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/.github/workflows/release_package.yml:
--------------------------------------------------------------------------------
1 | # author: https://superface.ai/blog/npm-publish-gh-actions-changelog
2 |
3 | name: Release package
4 | on:
5 | workflow_dispatch:
6 | inputs:
7 | release-type:
8 | description: 'Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease'
9 | required: true
10 | jobs:
11 | release:
12 | runs-on: ubuntu-latest
13 | steps:
14 | # Checkout project repository
15 | - name: Checkout
16 | uses: actions/checkout@v2.3.4
17 |
18 | # Setup Node.js environment
19 | - name: Setup Node.js
20 | uses: actions/setup-node@v2
21 | with:
22 | registry-url: https://registry.npmjs.org/
23 | node-version: '14'
24 |
25 | # Configure Git
26 | - name: Git configuration
27 | run: |
28 | git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
29 | git config --global user.name "GitHub Actions"
30 |
31 | # Bump package version
32 | # Use tag latest
33 | - name: Bump release version
34 | if: startsWith(github.event.inputs.release-type, 'pre') != true
35 | run: |
36 | echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
37 | echo "RELEASE_TAG=latest" >> $GITHUB_ENV
38 | env:
39 | RELEASE_TYPE: ${{ github.event.inputs.release-type }}
40 |
41 | # Bump package pre-release version
42 | # Use tag beta for pre-release versions
43 | - name: Bump pre-release version
44 | if: startsWith(github.event.inputs.release-type, 'pre')
45 | run: |
46 | echo "NEW_VERSION=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE
47 | echo "RELEASE_TAG=beta" >> $GITHUB_ENV
48 | env:
49 | RELEASE_TYPE: ${{ github.event.inputs.release-type }}
50 |
51 | # Update changelog unreleased section with new version
52 | - name: Update changelog
53 | uses: superfaceai/release-changelog-action@v1
54 | with:
55 | path-to-changelog: CHANGELOG.md
56 | version: ${{ env.NEW_VERSION }}
57 | operation: release
58 |
59 | # Commit changes
60 | - name: Commit CHANGELOG.md and package.json changes and create tag
61 | run: |
62 | git add "package.json"
63 | git add "CHANGELOG.md"
64 | git commit -m "chore: release ${{ env.NEW_VERSION }}"
65 | git tag ${{ env.NEW_VERSION }}
66 |
67 | # Push repository changes
68 | - name: Push changes to repository
69 | env:
70 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 | run: |
72 | git push origin && git push --tags
73 |
74 | # Read version changelog
75 | - id: get-changelog
76 | name: Get version changelog
77 | uses: superfaceai/release-changelog-action@v1
78 | with:
79 | path-to-changelog: CHANGELOG.md
80 | version: ${{ env.NEW_VERSION }}
81 | operation: read
82 |
83 | # Update GitHub release with changelog
84 | - name: Update GitHub release documentation
85 | uses: softprops/action-gh-release@v1
86 | with:
87 | tag_name: ${{ env.NEW_VERSION }}
88 | body: ${{ steps.get-changelog.outputs.changelog }}
89 | prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }}
90 | env:
91 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92 |
93 | # Publish version to public repository
94 | - name: Publish
95 | run: npm publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
96 | env:
97 | NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
98 |
--------------------------------------------------------------------------------
/example/ios/TerraReactExample.xcodeproj/xcshareddata/xcschemes/TerraReactExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
51 |
52 |
53 |
54 |
64 |
66 |
72 |
73 |
74 |
75 |
81 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "terra-react",
3 | "version": "1.8.11",
4 | "description": "React Native SDK mapping for Terra API",
5 | "main": "lib/commonjs/index.js",
6 | "module": "lib/module/index.js",
7 | "types": "lib/typescript/src/index.d.ts",
8 | "react-native": "src/index",
9 | "source": "src/index",
10 | "exports": {
11 | ".": {
12 | "types": "./lib/typescript/src/index.d.ts",
13 | "import": "./lib/commonjs/index.js",
14 | "require": "./lib/commonjs/index.js",
15 | "default": "./lib/commonjs/index.js"
16 | },
17 | "./package.json": "./package.json",
18 | "./app.plugin.js" : "./app.plugin.js"
19 | },
20 | "files": [
21 | "src",
22 | "plugin/build",
23 | "lib",
24 | "android/src",
25 | "android/build.gradle",
26 | "android/gradlew*",
27 | "android/gradle/wrapper/**",
28 | "app.plugin.js",
29 | "ios",
30 | "cpp",
31 | "terra-react.podspec",
32 | "!lib/typescript/example",
33 | "!android/build",
34 | "!android/bin",
35 | "!ios/build",
36 | "!**/__tests__",
37 | "!**/__fixtures__",
38 | "!**/__mocks__"
39 | ],
40 | "scripts": {
41 | "test": "jest",
42 | "typescript": "tsc --noEmit",
43 | "lint": "eslint \"**/*.{js,ts}\"",
44 | "prepare": "bob build && npm run build:plugin",
45 | "release": "release-it",
46 | "example": "yarn --cwd example",
47 | "pods": "cd example && pod-install --quiet",
48 | "bootstrap": "yarn example && yarn && yarn pods",
49 | "build": "tsc",
50 | "format": "prettier --write \"**/*.{js,ts}\"",
51 | "prepublishOnly": "npm test && npm run lint",
52 | "preversion": "npm run lint",
53 | "version": "npm run format && git add -A src",
54 | "postversion": "git push && git push --tags",
55 | "build:plugin": "rimraf plugin/build && tsc --build plugin"
56 | },
57 | "keywords": [
58 | "react-native",
59 | "ios",
60 | "android"
61 | ],
62 | "repository": "https://github.com/tryterra/terra-react",
63 | "author": "TerraDev (https://tryterra.co)",
64 | "license": "MIT",
65 | "bugs": {
66 | "url": "https://github.com/tryterra/terra-react/issues"
67 | },
68 | "homepage": "https://github.com/tryterra/terra-react#readme",
69 | "publishConfig": {
70 | "registry": "https://registry.npmjs.org/"
71 | },
72 | "devDependencies": {
73 | "@commitlint/config-conventional": "^11.0.0",
74 | "@expo/config-plugins": "^10.0.2",
75 | "@react-native-community/eslint-config": "^2.0.0",
76 | "@release-it/conventional-changelog": "^2.0.0",
77 | "@types/jest": "^26.0.0",
78 | "@types/react": "^16.9.19",
79 | "@types/react-native": "0.62.13",
80 | "commitlint": "^11.0.0",
81 | "eslint": "^7.2.0",
82 | "eslint-config-prettier": "^7.0.0",
83 | "eslint-plugin-prettier": "^3.1.3",
84 | "husky": "^6.0.0",
85 | "jest": "^26.6.3",
86 | "pod-install": "^0.1.0",
87 | "prettier": "^2.7.1",
88 | "react": "18.0.0",
89 | "react-native": "0.69",
90 | "react-native-builder-bob": "^0.18.2",
91 | "release-it": "^14.2.2",
92 | "typescript": "^4.1.3"
93 | },
94 | "peerDependencies": {
95 | "react": "*",
96 | "react-native": "*"
97 | },
98 | "jest": {
99 | "preset": "react-native",
100 | "modulePathIgnorePatterns": [
101 | "/example/node_modules",
102 | "/lib/"
103 | ]
104 | },
105 | "commitlint": {
106 | "extends": [
107 | "@commitlint/config-conventional"
108 | ]
109 | },
110 | "release-it": {
111 | "git": {
112 | "commitMessage": "chore: release ${version}",
113 | "tagName": "v${version}"
114 | },
115 | "npm": {
116 | "publish": true
117 | },
118 | "github": {
119 | "release": true
120 | },
121 | "plugins": {
122 | "@release-it/conventional-changelog": {
123 | "preset": "angular"
124 | }
125 | }
126 | },
127 | "eslintConfig": {
128 | "root": true,
129 | "extends": [
130 | "@react-native-community",
131 | "prettier"
132 | ],
133 | "rules": {
134 | "prettier/prettier": [
135 | "error",
136 | {
137 | "quoteProps": "consistent",
138 | "singleQuote": true,
139 | "tabWidth": 2,
140 | "trailingComma": "es5",
141 | "useTabs": false
142 | }
143 | ]
144 | }
145 | },
146 | "eslintIgnore": [
147 | "node_modules/",
148 | "lib/"
149 | ],
150 | "prettier": {
151 | "quoteProps": "consistent",
152 | "singleQuote": true,
153 | "tabWidth": 2,
154 | "trailingComma": "es5",
155 | "useTabs": false
156 | },
157 | "react-native-builder-bob": {
158 | "source": "src",
159 | "output": "lib",
160 | "targets": [
161 | "commonjs",
162 | "module",
163 | [
164 | "typescript",
165 | {
166 | "project": "tsconfig.build.json"
167 | }
168 | ]
169 | ]
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/ios/TerraReact.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Jaafar Rammal on 06/06/2022.
3 | //
4 |
5 | #import
6 |
7 | @interface RCT_EXTERN_MODULE(TerraReact, NSObject)
8 |
9 | // init
10 | RCT_EXTERN_METHOD(
11 | initTerra: (NSString *)devID
12 | referenceId: (NSString *)referenceId
13 | resolve: (RCTPromiseResolveBlock)resolve
14 | rejecter: (RCTPromiseRejectBlock)reject
15 | )
16 |
17 | // initConnection
18 | RCT_EXTERN_METHOD(
19 | initConnection: (NSString *)connection
20 | token: (NSString *)token
21 | schedulerOn: (BOOL)schedulerOn
22 | customPermissions: (NSArray *)customPermissions
23 | startIntent: (NSString *)startIntent
24 | resolve: (RCTPromiseResolveBlock)resolve
25 | rejecter: (RCTPromiseRejectBlock)reject
26 | )
27 |
28 | // check connection
29 | RCT_EXTERN_METHOD(
30 | checkAuth: (NSString *)connection
31 | devID: (NSString *)devID
32 | resolve: (RCTPromiseResolveBlock)resolve
33 | rejecter: (RCTPromiseRejectBlock)reject
34 | )
35 |
36 | RCT_EXTERN_METHOD(
37 | getUserId: (NSString *)connection
38 | resolve: (RCTPromiseResolveBlock)resolve
39 | rejecter: (RCTPromiseRejectBlock)reject
40 | )
41 |
42 | // getters
43 | RCT_EXTERN_METHOD(
44 | getAthlete: (NSString *)connection
45 | toWebhook: (BOOL)toWebhook
46 | resolve: (RCTPromiseResolveBlock)resolve
47 | rejecter: (RCTPromiseRejectBlock)reject
48 | )
49 | RCT_EXTERN_METHOD(
50 | getBody: (NSString *)connection
51 | startDate: (NSDate *)startDate
52 | endDate: (NSDate *)endDate
53 | latestReading: (BOOL) latestReading
54 | toWebhook: (BOOL)toWebhook
55 | resolve: (RCTPromiseResolveBlock)resolve
56 | rejecter: (RCTPromiseRejectBlock)reject
57 | )
58 | RCT_EXTERN_METHOD(
59 | getDaily: (NSString *)connection
60 | startDate: (NSDate *)startDate
61 | endDate:(NSDate *)endDate
62 | toWebhook: (BOOL)toWebhook
63 | resolve: (RCTPromiseResolveBlock)resolve
64 | rejecter: (RCTPromiseRejectBlock)reject
65 | )
66 | RCT_EXTERN_METHOD(
67 | getSleep: (NSString *)connection
68 | startDate: (NSDate *)startDate
69 | endDate:(NSDate *)endDate
70 | toWebhook: (BOOL)toWebhook
71 | resolve: (RCTPromiseResolveBlock)resolve
72 | rejecter: (RCTPromiseRejectBlock)reject
73 | )
74 | RCT_EXTERN_METHOD(
75 | getActivity: (NSString *)connection
76 | startDate: (NSDate *)startDate
77 | endDate:(NSDate *)endDate
78 | toWebhook: (BOOL)toWebhook
79 | resolve: (RCTPromiseResolveBlock)resolve
80 | rejecter: (RCTPromiseRejectBlock)reject
81 | )
82 | RCT_EXTERN_METHOD(
83 | getMenstruation: (NSString *)connection
84 | startDate: (NSDate *)startDate
85 | endDate:(NSDate *)endDate
86 | toWebhook: (BOOL)toWebhook
87 | resolve: (RCTPromiseResolveBlock)resolve
88 | rejecter: (RCTPromiseRejectBlock)reject
89 | )
90 | RCT_EXTERN_METHOD(
91 | getNutrition: (NSString *)connection
92 | startDate: (NSDate *)startDate
93 | endDate:(NSDate *)endDate
94 | toWebhook: (BOOL)toWebhook
95 | resolve: (RCTPromiseResolveBlock)resolve
96 | rejecter: (RCTPromiseRejectBlock)reject
97 | )
98 |
99 | RCT_EXTERN_METHOD(
100 | postActivity: (NSString *)connection
101 | payload: (NSDictionary *)payload
102 | resolve: (RCTPromiseResolveBlock)resolve
103 | rejecter: (RCTPromiseRejectBlock)reject
104 | )
105 |
106 | // Freestyle glucose init
107 | RCT_EXTERN_METHOD(
108 | readGlucoseData:(RCTPromiseResolveBlock)resolve
109 | rejecter: (RCTPromiseRejectBlock)reject
110 | )
111 |
112 | RCT_EXTERN_METHOD(
113 | activateSensor:(RCTPromiseResolveBlock)resolve
114 | rejecter: (RCTPromiseRejectBlock)reject
115 | )
116 |
117 | RCT_EXTERN_METHOD(
118 | isHealthConnectAvailable:(RCTPromiseResolveBlock)resolve
119 | rejecter: (RCTPromiseRejectBlock)reject
120 | )
121 |
122 | RCT_EXTERN_METHOD(
123 | openHealthConnect:(RCTPromiseResolveBlock)resolve
124 | rejecter: (RCTPromiseRejectBlock)reject
125 | )
126 |
127 | RCT_EXTERN_METHOD(
128 | grantedPermissions:(RCTPromiseResolveBlock)resolve
129 | rejecter: (RCTPromiseRejectBlock)reject
130 | )
131 |
132 | RCT_EXTERN_METHOD(
133 | setIgnoredSources:(NSArray *)ignoredSources
134 | resolve: (RCTPromiseResolveBlock)resolve
135 | rejecter: (RCTPromiseRejectBlock)reject
136 | )
137 |
138 | RCT_EXTERN_METHOD(
139 | getPlannedWorkouts: (NSString *)connection
140 | resolve: (RCTPromiseResolveBlock)resolve
141 | rejecter: (RCTPromiseRejectBlock)reject
142 | )
143 |
144 | RCT_EXTERN_METHOD(
145 | deletePlannedWorkout: (NSString *)connection
146 | workoutId: (NSString *)workoutId
147 | resolve: (RCTPromiseResolveBlock)resolve
148 | rejecter: (RCTPromiseRejectBlock)reject
149 | )
150 |
151 | RCT_EXTERN_METHOD(
152 | completePlannedWorkout: (NSString *)connection
153 | workoutId: (NSString *)workoutId
154 | at: (NSString *)atIso
155 | resolve: (RCTPromiseResolveBlock)resolve
156 | rejecter: (RCTPromiseRejectBlock)reject
157 | )
158 |
159 | RCT_EXTERN_METHOD(
160 | postPlannedWorkout: (NSString *)connection
161 | payload: (NSString *)payload
162 | resolve: (RCTPromiseResolveBlock)resolve
163 | rejecter: (RCTPromiseRejectBlock)reject
164 | )
165 |
166 |
167 | @end
168 |
--------------------------------------------------------------------------------
/example/ios/TerraReactExample/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/example/src/App.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 |
3 | import { StyleSheet, View, Text } from 'react-native';
4 | import {
5 | Connections,
6 | getDaily,
7 | getUserId,
8 | getActivity,
9 | initTerra,
10 | initConnection,
11 | getMenstruation,
12 | getBody,
13 | getNutrition,
14 | getSleep,
15 | checkAuth,
16 | setIgnoredSources,
17 | postPlannedWorkout,
18 | getPlannedWorkouts,
19 | deletePlannedWorkout,
20 | } from 'terra-react';
21 | import { config } from './config';
22 | import { generateSamplePlannedWorkout } from './samplePlannedWorkout';
23 |
24 | export default function App() {
25 | // after showing the widget to the users
26 | // initialise accordingle which connection / reference_id
27 | // example if user wants connect Google using SDK
28 | // you can have multiple connections in the array
29 |
30 | const [results, setResults] = React.useState({});
31 |
32 | function initThings(devId: string, token: string, connection: Connections) {
33 | setIgnoredSources(['com.apple.Health']);
34 | initTerra(devId, 'reid').then((aa) => {
35 | setResults((r) => ({ ...r, initTerra: aa.success }));
36 | initConnection(connection, token, true).then((a) => {
37 | setResults((r) => ({ ...r, initConnection: a.success }));
38 | let startDate = new Date();
39 | startDate.setMonth(8);
40 | startDate.setDate(10);
41 | startDate.setHours(0);
42 | startDate.setMinutes(0);
43 | startDate.setSeconds(0);
44 | let endDate = new Date();
45 | getActivity(connection, startDate, new Date())
46 | .then((d: any) => console.log(d))
47 | .catch((e: any) => console.log(e));
48 | getBody(connection, startDate, new Date(), true, false)
49 | .then((d: any) => {
50 | setResults((r) => ({ ...r, getBody: d.success }));
51 | })
52 | .catch((e: any) => console.log(e));
53 | getDaily(connection, startDate, endDate, false)
54 | .then((d: any) => {
55 | setResults((r) => ({ ...r, getDaily: d.success }));
56 | console.log(JSON.stringify(d.data));
57 | })
58 | .catch((e: any) => console.log(e));
59 | getMenstruation(connection, startDate, new Date())
60 | .then((d: any) =>
61 | setResults((r) => ({ ...r, getMenstruation: d.success }))
62 | )
63 | .catch((e: any) => console.log(e));
64 | getNutrition(connection, startDate, new Date())
65 | .then((d: any) =>
66 | setResults((r) => ({ ...r, getNutrition: d.success }))
67 | )
68 | .catch((e: any) => console.log(e));
69 | getSleep(connection, startDate, new Date())
70 | .then((d: any) => setResults((r) => ({ ...r, getSleep: d.success })))
71 | .catch((e: any) => console.log(e));
72 | // readGlucoseData().then((d) => {console.log(d.data.blood_glucose_samples);});
73 | // postActivity(connection, {metadata: {start_time: "2024-11-01T04:00:00+01:00", end_time: "2024-11-01T05:00:00+01:00", type: 8, upload_type: 1}, device_data: {name: "Equinox"}, distance_data: {summary: {distance_meters: 1000}}, calories_data: {net_activity_calories: 200}}).then((d) => {
74 | // console.log(d)
75 | // })
76 | getUserId(connection)
77 | .then((de) => {
78 | console.log(de.userId);
79 | setResults((r) => ({ ...r, getUserId: de.userId }));
80 | })
81 | .catch((ee) => console.log(ee));
82 | checkAuth(connection, devId).then((d) => {
83 | console.log(d);
84 | });
85 | postPlannedWorkoutFlow()
86 | });
87 | });
88 | }
89 |
90 | async function postPlannedWorkoutFlow() {
91 | try {
92 | const workout = generateSamplePlannedWorkout();
93 | const resp = await postPlannedWorkout(Connections.APPLE_HEALTH, workout);
94 | console.log('post success:', resp?.success ?? false);
95 |
96 | const postedPlannedWorkouts = await getPlannedWorkouts(Connections.APPLE_HEALTH);
97 | console.log('getPlannedWorkouts data:', postedPlannedWorkouts?.data ?? 'No data');
98 |
99 | // 3. Optionally mark as complete
100 | // const markComplete = await completePlannedWorkout(
101 | // connection,
102 | // 'ceef601a-23e4-4393-8483-a9f6d37b0407',
103 | // new Date()
104 | // );
105 | // console.log('complete success:', markComplete?.success ?? false);
106 |
107 | // 4. Delete workout
108 | // const deleteWorkout = await deletePlannedWorkout(
109 | // Connections.APPLE_HEALTH,
110 | // 'ceef601a-23e4-4393-8483-a9f6d37b0407'
111 | // );
112 | // console.log('delete success:', deleteWorkout?.success ?? false);
113 | } catch (e) {
114 | console.error('error in planned workout flow', e);
115 | }
116 | }
117 |
118 | React.useEffect(() => {
119 | const devId = config.devId;
120 | const apiKey = config.apiKey;
121 | const connection = Connections.APPLE_HEALTH;
122 | fetch('https://api.tryterra.co/v2/auth/generateAuthToken', {
123 | method: 'POST',
124 | headers: {
125 | 'dev-id': devId,
126 | 'x-api-key': apiKey,
127 | },
128 | })
129 | .then((response) => response.json())
130 | .then((result) => initThings(devId, result.token, connection))
131 | .catch((error) => console.log('error', error));
132 | }, []);
133 |
134 | return (
135 |
136 | Hello from Terra
137 | {Object.entries(results).map(([k, v], i) => (
138 |
139 | {k}: {v !== undefined || v !== null ? v!.toString() : 'undefined'}
140 |
141 | ))}
142 |
143 | );
144 | }
145 |
146 | const styles = StyleSheet.create({
147 | container: {
148 | flex: 1,
149 | alignItems: 'center',
150 | justifyContent: 'center',
151 | },
152 | box: {
153 | width: 60,
154 | height: 60,
155 | marginVertical: 20,
156 | },
157 | });
158 |
--------------------------------------------------------------------------------
/src/models/Activity.ts:
--------------------------------------------------------------------------------
1 | import { ActivityType } from '../enums/ActivityTypes';
2 | import { UploadType } from '../enums/UploadType';
3 | import { Option } from '../helpers';
4 | import { ActivityLevelSample } from './samples/ActivityLevelSample';
5 | import { CadenceSample } from './samples/CadenceSample';
6 | import { DistanceSample } from './samples/DistanceSample';
7 | import { ElevationSample } from './samples/ElevationSample';
8 | import { FloorsClimbedSample } from './samples/FloorsClimbedSample';
9 | import { HeartRateDataSample } from './samples/HeartRateDataSample';
10 | import { HeartRateVariabilityDataSampleRMSSD } from './samples/HeartRateVariabilityDataSampleRMSSD';
11 | import { HeartRateVariabilityDataSampleSDNN } from './samples/HeartRateVariabilityDataSampleSDNN';
12 | import { HeartRateZoneData } from './samples/HeartRateZoneData';
13 | import { LapSample } from './samples/LapSample';
14 | import { METSample } from './samples/METSample';
15 | import { OtherDeviceData } from './samples/OtherDeviceData';
16 | import { OxygenSaturationSample } from './samples/OxygenSaturationSample';
17 | import { PositionSample } from './samples/PositionSample';
18 | import { PowerSample } from './samples/PowerSample';
19 | import { StepSample } from './samples/StepSample';
20 | import { SpeedSample } from './samples/SpeedSample';
21 | import { TSSSample } from './samples/TSSSample';
22 | import { Vo2MaxSample } from './samples/Vo2MaxSample';
23 |
24 | export interface Activity {
25 | movement_data?: {
26 | normalized_speed_meters_per_second?: Option;
27 | max_cadence_rpm?: Option;
28 | avg_speed_meters_per_second?: Option;
29 | avg_pace_minutes_per_kilometer?: Option;
30 | max_velocity_meters_per_second?: Option;
31 | max_pace_minutes_per_kilometer?: Option;
32 | max_torque_newton_meters?: Option;
33 | avg_cadence_rpm?: Option;
34 | avg_velocity_meters_per_second?: Option;
35 | avg_torque_newton_meters?: Option;
36 | cadence_samples?: Array;
37 | speed_samples?: Array;
38 | max_speed_meters_per_second?: Option;
39 | };
40 | power_data?: {
41 | max_watts?: Option;
42 | avg_watts?: Option;
43 | power_samples?: Array;
44 | };
45 | position_data?: {
46 | position_samples?: Array;
47 | center_pos_lat_lng_deg?: [number, number];
48 | start_pos_lat_lng_deg?: [number, number];
49 | end_pos_lat_lng_deg?: [number, number];
50 | };
51 | oxygen_data?: {
52 | saturation_samples?: Array;
53 | avg_saturation_percentage?: Option;
54 | vo2_samples?: Array;
55 | vo2max_ml_per_min_per_kg?: Option;
56 | };
57 | metadata: {
58 | name?: Option;
59 | summary_id?: Option;
60 | country?: Option;
61 | state?: Option;
62 | upload_type?: UploadType;
63 | end_time: string;
64 | city?: Option;
65 | type: Option;
66 | start_time: string;
67 | };
68 | TSS_data?: {
69 | TSS_samples?: Array;
70 | };
71 | device_data: {
72 | name?: Option;
73 | other_devices?: Array;
74 | hardware_version?: Option;
75 | manufacturer?: Option;
76 | software_version?: Option;
77 | activation_timestamp?: Option;
78 | serial_number?: Option;
79 | };
80 | distance_data?: {
81 | summary?: {
82 | swimming?: {
83 | num_strokes?: Option;
84 | num_laps?: Option;
85 | pool_length_meters?: Option;
86 | };
87 | floors_climbed?: number;
88 | elevation?: {
89 | loss_actual_meters?: Option;
90 | min_meters?: Option;
91 | avg_meters?: Option;
92 | gain_actual_meters?: Option;
93 | max_meters?: Option;
94 | gain_planned_meters?: Option;
95 | };
96 | steps?: Option;
97 | distance_meters?: Option;
98 | };
99 | detailed?: {
100 | step_samples?: Array;
101 | distance_samples?: Array;
102 | elevation_samples?: Array;
103 | floors_climbed_samples?: Array;
104 | };
105 | };
106 | calories_data?: {
107 | net_intake_calories?: Option;
108 | BMR_calories?: Option;
109 | total_burned_calories?: Option;
110 | net_activity_calories?: Option;
111 | };
112 | lap_data?: {
113 | laps?: Array;
114 | };
115 | MET_data?: {
116 | MET_samples?: Array;
117 | num_low_intensity_minutes?: Option;
118 | num_high_intensity_minutes?: Option;
119 | num_inactive_minutes?: Option;
120 | num_moderate_intensity_minutes?: Option;
121 | avg_level?: Option;
122 | };
123 | heart_rate_data?: {
124 | summary?: {
125 | max_hr_bpm?: Option;
126 | resting_hr_bpm?: Option;
127 | avg_hrv_rmssd?: Option;
128 | min_hr_bpm?: Option;
129 | user_max_hr_bpm?: Option;
130 | avg_hrv_sdnn?: Option;
131 | avg_hr_bpm?: Option;
132 | hr_zone_data?: Array;
133 | };
134 | detailed?: {
135 | hr_samples?: Array;
136 | hrv_samples_sdnn?: Array;
137 | hrv_samples_rmssd?: Array;
138 | };
139 | };
140 | active_durations_data?: {
141 | activity_seconds?: Option;
142 | rest_seconds?: Option;
143 | low_intensity_seconds?: Option;
144 | activity_levels_samples?: Array;
145 | vigorous_intensity_seconds?: Option;
146 | num_continuous_inactive_periods?: Option;
147 | inactivity_seconds?: Option;
148 | moderate_intensity_seconds?: Option;
149 | };
150 | polyline_map_data?: {
151 | summary_polyline?: Option;
152 | };
153 | strain_data?: {
154 | strain_level?: Option;
155 | };
156 | work_data?: {
157 | work_kilojoules?: Option;
158 | };
159 | energy_data?: {
160 | energy_kilojoules?: Option;
161 | energy_planned_kilojoules?: Option;
162 | };
163 | }
164 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MSYS* | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4 |
5 | ## Development workflow
6 |
7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
8 |
9 | ```sh
10 | yarn
11 | ```
12 |
13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
14 |
15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
16 |
17 | To start the packager:
18 |
19 | ```sh
20 | yarn example start
21 | ```
22 |
23 | To run the example app on Android:
24 |
25 | ```sh
26 | yarn example android
27 | ```
28 |
29 | To run the example app on iOS:
30 |
31 | ```sh
32 | yarn example ios
33 | ```
34 |
35 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
36 |
37 | ```sh
38 | yarn typescript
39 | yarn lint
40 | ```
41 |
42 | To fix formatting errors, run the following:
43 |
44 | ```sh
45 | yarn lint --fix
46 | ```
47 |
48 | Remember to add tests for your change if possible. Run the unit tests by:
49 |
50 | ```sh
51 | yarn test
52 | ```
53 |
54 | To edit the Objective-C files, open `example/ios/TerraReactExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > terra-react`.
55 |
56 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `terrareact` under `Android`.
57 |
58 | ### Commit message convention
59 |
60 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
61 |
62 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
63 | - `feat`: new features, e.g. add new method to the module.
64 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
65 | - `docs`: changes into documentation, e.g. add usage example for the module..
66 | - `test`: adding or updating tests, e.g. add integration tests using detox.
67 | - `chore`: tooling changes, e.g. change CI config.
68 |
69 | Our pre-commit hooks verify that your commit message matches this format when committing.
70 |
71 | ### Linting and tests
72 |
73 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
74 |
75 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
76 |
77 | Our pre-commit hooks verify that the linter and tests pass when committing.
78 |
79 | ### Publishing to npm
80 |
81 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
82 |
83 | To publish new versions, run the following:
84 |
85 | ```sh
86 | yarn release
87 | ```
88 |
89 | ### Scripts
90 |
91 | The `package.json` file contains various scripts for common tasks:
92 |
93 | - `yarn bootstrap`: setup project by installing all dependencies and pods.
94 | - `yarn typescript`: type-check files with TypeScript.
95 | - `yarn lint`: lint files with ESLint.
96 | - `yarn test`: run unit tests with Jest.
97 | - `yarn example start`: start the Metro server for the example app.
98 | - `yarn example android`: run the example app on Android.
99 | - `yarn example ios`: run the example app on iOS.
100 |
101 | ### Sending a pull request
102 |
103 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
104 |
105 | When you're sending a pull request:
106 |
107 | - Prefer small pull requests focused on one change.
108 | - Verify that linters and tests are passing.
109 | - Review the documentation to make sure it looks good.
110 | - Follow the pull request template when opening a pull request.
111 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
112 |
113 | ## Code of Conduct
114 |
115 | ### Our Pledge
116 |
117 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
118 |
119 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
120 |
121 | ### Our Standards
122 |
123 | Examples of behavior that contributes to a positive environment for our community include:
124 |
125 | - Demonstrating empathy and kindness toward other people
126 | - Being respectful of differing opinions, viewpoints, and experiences
127 | - Giving and gracefully accepting constructive feedback
128 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
129 | - Focusing on what is best not just for us as individuals, but for the overall community
130 |
131 | Examples of unacceptable behavior include:
132 |
133 | - The use of sexualized language or imagery, and sexual attention or
134 | advances of any kind
135 | - Trolling, insulting or derogatory comments, and personal or political attacks
136 | - Public or private harassment
137 | - Publishing others' private information, such as a physical or email
138 | address, without their explicit permission
139 | - Other conduct which could reasonably be considered inappropriate in a
140 | professional setting
141 |
142 | ### Enforcement Responsibilities
143 |
144 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
145 |
146 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
147 |
148 | ### Scope
149 |
150 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
151 |
152 | ### Enforcement
153 |
154 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.
155 |
156 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
157 |
158 | ### Enforcement Guidelines
159 |
160 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
161 |
162 | #### 1. Correction
163 |
164 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
165 |
166 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
167 |
168 | #### 2. Warning
169 |
170 | **Community Impact**: A violation through a single incident or series of actions.
171 |
172 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
173 |
174 | #### 3. Temporary Ban
175 |
176 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
177 |
178 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
179 |
180 | #### 4. Permanent Ban
181 |
182 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
183 |
184 | **Consequence**: A permanent ban from any sort of public interaction within the community.
185 |
186 | ### Attribution
187 |
188 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
189 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
190 |
191 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
192 |
193 | [homepage]: https://www.contributor-covenant.org
194 |
195 | For answers to common questions about this code of conduct, see the FAQ at
196 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
197 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 |
3 | import com.android.build.OutputFile
4 |
5 | /**
6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 | * and bundleReleaseJsAndAssets).
8 | * These basically call `react-native bundle` with the correct arguments during the Android build
9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 | * bundle directly from the development server. Below you can see all the possible configurations
11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 | * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 | *
14 | * project.ext.react = [
15 | * // the name of the generated asset file containing your JS bundle
16 | * bundleAssetName: "index.android.bundle",
17 | *
18 | * // the entry file for bundle generation
19 | * entryFile: "index.android.js",
20 | *
21 | * // https://reactnative.dev/docs/performance#enable-the-ram-format
22 | * bundleCommand: "ram-bundle",
23 | *
24 | * // whether to bundle JS and assets in debug mode
25 | * bundleInDebug: false,
26 | *
27 | * // whether to bundle JS and assets in release mode
28 | * bundleInRelease: true,
29 | *
30 | * // whether to bundle JS and assets in another build variant (if configured).
31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32 | * // The configuration property can be in the following formats
33 | * // 'bundleIn${productFlavor}${buildType}'
34 | * // 'bundleIn${buildType}'
35 | * // bundleInFreeDebug: true,
36 | * // bundleInPaidRelease: true,
37 | * // bundleInBeta: true,
38 | *
39 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
40 | * // for TerraReactExample: to disable dev mode in the staging build type (if configured)
41 | * devDisabledInStaging: true,
42 | * // The configuration property can be in the following formats
43 | * // 'devDisabledIn${productFlavor}${buildType}'
44 | * // 'devDisabledIn${buildType}'
45 | *
46 | * // the root of your project, i.e. where "package.json" lives
47 | * root: "../../",
48 | *
49 | * // where to put the JS bundle asset in debug mode
50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51 | *
52 | * // where to put the JS bundle asset in release mode
53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54 | *
55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
56 | * // require('./image.png')), in debug mode
57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58 | *
59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
60 | * // require('./image.png')), in release mode
61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62 | *
63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67 | * // for TerraReactExample, you might want to remove it from here.
68 | * inputExcludes: ["android/**", "ios/**"],
69 | *
70 | * // override which node gets called and with what additional arguments
71 | * nodeExecutableAndArgs: ["node"],
72 | *
73 | * // supply additional arguments to the packager
74 | * extraPackagerArgs: []
75 | * ]
76 | */
77 |
78 | project.ext.react = [
79 | enableHermes: false, // clean and rebuild if changing
80 | entryFile: "index.tsx",
81 | ]
82 |
83 | apply from: "../../node_modules/react-native/react.gradle"
84 |
85 | /**
86 | * Set this to true to create two separate APKs instead of one:
87 | * - An APK that only works on ARM devices
88 | * - An APK that only works on x86 devices
89 | * The advantage is the size of the APK is reduced by about 4MB.
90 | * Upload all the APKs to the Play Store and people will download
91 | * the correct one based on the CPU architecture of their device.
92 | */
93 | def enableSeparateBuildPerCPUArchitecture = false
94 |
95 | /**
96 | * Run Proguard to shrink the Java bytecode in release builds.
97 | */
98 | def enableProguardInReleaseBuilds = false
99 |
100 | /**
101 | * The preferred build flavor of JavaScriptCore.
102 | *
103 | * For TerraReactExample, to use the international variant, you can use:
104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105 | *
106 | * The international variant includes ICU i18n library and necessary data
107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108 | * give correct results when using with locales other than en-US. Note that
109 | * this variant is about 6MiB larger per architecture than default.
110 | */
111 | def jscFlavor = 'org.webkit:android-jsc:+'
112 |
113 | /**
114 | * Whether to enable the Hermes VM.
115 | *
116 | * This should be set on project.ext.react and mirrored here. If it is not set
117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118 | * and the benefits of using Hermes will therefore be sharply reduced.
119 | */
120 | def enableHermes = project.ext.react.get("enableHermes", false);
121 |
122 | android {
123 | compileSdkVersion rootProject.ext.compileSdkVersion
124 |
125 | compileOptions {
126 | sourceCompatibility JavaVersion.VERSION_1_8
127 | targetCompatibility JavaVersion.VERSION_1_8
128 | }
129 |
130 | defaultConfig {
131 | applicationId "com.example.terrareact"
132 | minSdkVersion rootProject.ext.minSdkVersion
133 | targetSdkVersion rootProject.ext.targetSdkVersion
134 | versionCode 1
135 | versionName "1.0"
136 | multiDexEnabled true
137 |
138 | }
139 |
140 | splits {
141 | abi {
142 | reset()
143 | enable enableSeparateBuildPerCPUArchitecture
144 | universalApk false // If true, also generate a universal APK
145 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
146 | }
147 | }
148 | signingConfigs {
149 | debug {
150 | storeFile file('debug.keystore')
151 | storePassword 'android'
152 | keyAlias 'androiddebugkey'
153 | keyPassword 'android'
154 | }
155 | }
156 | buildTypes {
157 | debug {
158 | signingConfig signingConfigs.debug
159 | }
160 | release {
161 | // Caution! In production, you need to generate your own keystore file.
162 | // see https://reactnative.dev/docs/signed-apk-android.
163 | signingConfig signingConfigs.debug
164 | minifyEnabled enableProguardInReleaseBuilds
165 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
166 | }
167 | }
168 | // applicationVariants are e.g. debug, release
169 | applicationVariants.all { variant ->
170 | variant.outputs.each { output ->
171 | // For each separate APK per architecture, set a unique version code as described here:
172 | // https://developer.android.com/studio/build/configure-apk-splits.html
173 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
174 | def abi = output.getFilter(OutputFile.ABI)
175 | if (abi != null) { // null for the universal-debug, universal-release variants
176 | output.versionCodeOverride =
177 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
178 | }
179 |
180 | }
181 | }
182 |
183 | packagingOptions {
184 | pickFirst 'lib/x86/libc++_shared.so'
185 | pickFirst 'lib/x86_64/libc++_shared.so'
186 | pickFirst 'lib/armeabi-v7a/libc++_shared.so'
187 | pickFirst 'lib/arm64-v8a/libc++_shared.so'
188 | pickFirst 'lib/arm64-v8a/libfbjni.so'
189 | pickFirst 'lib/armeabi-v7a/libfbjni.so'
190 | pickFirst 'lib/x86_64/libfbjni.so'
191 | pickFirst 'lib/x86/libfbjni.so'
192 | }
193 | rootProject.ext.ffmpegKitPackage = "video"
194 | namespace "com.example.terrareact"
195 |
196 | }
197 |
198 | dependencies {
199 | implementation fileTree(dir: "libs", include: ["*.jar"])
200 | //noinspection GradleDynamicVersion
201 | implementation "com.facebook.react:react-native:+" // From node_modules
202 | implementation 'androidx.core:core-ktx:1.8.0'
203 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
204 |
205 | implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
206 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
207 | exclude group:'com.facebook.fbjni'
208 | }
209 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
210 | exclude group:'com.facebook.flipper'
211 | exclude group:'com.squareup.okhttp3', module:'okhttp'
212 | }
213 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
214 | exclude group:'com.facebook.flipper'
215 | }
216 |
217 | if (enableHermes) {
218 | def hermesPath = "../../node_modules/hermes-engine/android/";
219 | debugImplementation files(hermesPath + "hermes-debug.aar")
220 | releaseImplementation files(hermesPath + "hermes-release.aar")
221 | } else {
222 | implementation jscFlavor
223 | }
224 |
225 | // implementation project(':terrareact')
226 | }
227 |
228 | // // Run this once to be able to run the application with BUCK
229 | // puts all compile dependencies into folder libs for BUCK to use
230 | task copyDownloadableDepsToLibs(type: Copy) {
231 | from configurations.implementation
232 | into 'libs'
233 | }
234 |
235 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
236 |
--------------------------------------------------------------------------------
/ios/TerraReact.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | F4FF95D7245B92E800C19C63 /* TerraReact.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* TerraReact.swift */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXCopyFilesBuildPhase section */
14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15 | isa = PBXCopyFilesBuildPhase;
16 | buildActionMask = 2147483647;
17 | dstPath = "include/$(PRODUCT_NAME)";
18 | dstSubfolderSpec = 16;
19 | files = (
20 | );
21 | runOnlyForDeploymentPostprocessing = 0;
22 | };
23 | /* End PBXCopyFilesBuildPhase section */
24 |
25 | /* Begin PBXFileReference section */
26 | 134814201AA4EA6300B7C361 /* libTerraReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTerraReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
27 | 9B4A77942CD523B5000941A0 /* TerraActivityData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraActivityData.swift; sourceTree = ""; };
28 | B3E7B5891CC2AC0600A0062D /* TerraReact.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TerraReact.m; sourceTree = ""; };
29 | F4FF95D5245B92E700C19C63 /* TerraReact-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TerraReact-Bridging-Header.h"; sourceTree = ""; };
30 | F4FF95D6245B92E800C19C63 /* TerraReact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerraReact.swift; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 134814211AA4EA7D00B7C361 /* Products */ = {
45 | isa = PBXGroup;
46 | children = (
47 | 134814201AA4EA6300B7C361 /* libTerraReact.a */,
48 | );
49 | name = Products;
50 | sourceTree = "";
51 | };
52 | 58B511D21A9E6C8500147676 = {
53 | isa = PBXGroup;
54 | children = (
55 | 9B4A77942CD523B5000941A0 /* TerraActivityData.swift */,
56 | F4FF95D6245B92E800C19C63 /* TerraReact.swift */,
57 | B3E7B5891CC2AC0600A0062D /* TerraReact.m */,
58 | F4FF95D5245B92E700C19C63 /* TerraReact-Bridging-Header.h */,
59 | 134814211AA4EA7D00B7C361 /* Products */,
60 | );
61 | sourceTree = "";
62 | };
63 | /* End PBXGroup section */
64 |
65 | /* Begin PBXNativeTarget section */
66 | 58B511DA1A9E6C8500147676 /* TerraReact */ = {
67 | isa = PBXNativeTarget;
68 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "TerraReact" */;
69 | buildPhases = (
70 | 58B511D71A9E6C8500147676 /* Sources */,
71 | 58B511D81A9E6C8500147676 /* Frameworks */,
72 | 58B511D91A9E6C8500147676 /* CopyFiles */,
73 | );
74 | buildRules = (
75 | );
76 | dependencies = (
77 | );
78 | name = TerraReact;
79 | productName = RCTDataManager;
80 | productReference = 134814201AA4EA6300B7C361 /* libTerraReact.a */;
81 | productType = "com.apple.product-type.library.static";
82 | };
83 | /* End PBXNativeTarget section */
84 |
85 | /* Begin PBXProject section */
86 | 58B511D31A9E6C8500147676 /* Project object */ = {
87 | isa = PBXProject;
88 | attributes = {
89 | LastUpgradeCheck = 0920;
90 | ORGANIZATIONNAME = Facebook;
91 | TargetAttributes = {
92 | 58B511DA1A9E6C8500147676 = {
93 | CreatedOnToolsVersion = 6.1.1;
94 | };
95 | };
96 | };
97 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "TerraReact" */;
98 | compatibilityVersion = "Xcode 3.2";
99 | developmentRegion = English;
100 | hasScannedForEncodings = 0;
101 | knownRegions = (
102 | English,
103 | en,
104 | );
105 | mainGroup = 58B511D21A9E6C8500147676;
106 | productRefGroup = 58B511D21A9E6C8500147676;
107 | projectDirPath = "";
108 | projectRoot = "";
109 | targets = (
110 | 58B511DA1A9E6C8500147676 /* TerraReact */,
111 | );
112 | };
113 | /* End PBXProject section */
114 |
115 | /* Begin PBXSourcesBuildPhase section */
116 | 58B511D71A9E6C8500147676 /* Sources */ = {
117 | isa = PBXSourcesBuildPhase;
118 | buildActionMask = 2147483647;
119 | files = (
120 | F4FF95D7245B92E800C19C63 /* TerraReact.swift in Sources */,
121 | );
122 | runOnlyForDeploymentPostprocessing = 0;
123 | };
124 | /* End PBXSourcesBuildPhase section */
125 |
126 | /* Begin XCBuildConfiguration section */
127 | 58B511ED1A9E6C8500147676 /* Debug */ = {
128 | isa = XCBuildConfiguration;
129 | buildSettings = {
130 | ALWAYS_SEARCH_USER_PATHS = NO;
131 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
132 | CLANG_CXX_LIBRARY = "libc++";
133 | CLANG_ENABLE_MODULES = YES;
134 | CLANG_ENABLE_OBJC_ARC = YES;
135 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
136 | CLANG_WARN_BOOL_CONVERSION = YES;
137 | CLANG_WARN_COMMA = YES;
138 | CLANG_WARN_CONSTANT_CONVERSION = YES;
139 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
140 | CLANG_WARN_EMPTY_BODY = YES;
141 | CLANG_WARN_ENUM_CONVERSION = YES;
142 | CLANG_WARN_INFINITE_RECURSION = YES;
143 | CLANG_WARN_INT_CONVERSION = YES;
144 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
145 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
146 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
147 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
148 | CLANG_WARN_STRICT_PROTOTYPES = YES;
149 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
150 | CLANG_WARN_UNREACHABLE_CODE = YES;
151 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
152 | COPY_PHASE_STRIP = NO;
153 | ENABLE_STRICT_OBJC_MSGSEND = YES;
154 | ENABLE_TESTABILITY = YES;
155 | GCC_C_LANGUAGE_STANDARD = gnu99;
156 | GCC_DYNAMIC_NO_PIC = NO;
157 | GCC_NO_COMMON_BLOCKS = YES;
158 | GCC_OPTIMIZATION_LEVEL = 0;
159 | GCC_PREPROCESSOR_DEFINITIONS = (
160 | "DEBUG=1",
161 | "$(inherited)",
162 | );
163 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
164 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
165 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
166 | GCC_WARN_UNDECLARED_SELECTOR = YES;
167 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
168 | GCC_WARN_UNUSED_FUNCTION = YES;
169 | GCC_WARN_UNUSED_VARIABLE = YES;
170 | IPHONEOS_DEPLOYMENT_TARGET = 13.0;
171 | MTL_ENABLE_DEBUG_INFO = YES;
172 | ONLY_ACTIVE_ARCH = YES;
173 | SDKROOT = iphoneos;
174 | };
175 | name = Debug;
176 | };
177 | 58B511EE1A9E6C8500147676 /* Release */ = {
178 | isa = XCBuildConfiguration;
179 | buildSettings = {
180 | ALWAYS_SEARCH_USER_PATHS = NO;
181 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
182 | CLANG_CXX_LIBRARY = "libc++";
183 | CLANG_ENABLE_MODULES = YES;
184 | CLANG_ENABLE_OBJC_ARC = YES;
185 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
186 | CLANG_WARN_BOOL_CONVERSION = YES;
187 | CLANG_WARN_COMMA = YES;
188 | CLANG_WARN_CONSTANT_CONVERSION = YES;
189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
190 | CLANG_WARN_EMPTY_BODY = YES;
191 | CLANG_WARN_ENUM_CONVERSION = YES;
192 | CLANG_WARN_INFINITE_RECURSION = YES;
193 | CLANG_WARN_INT_CONVERSION = YES;
194 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
195 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
196 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
197 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
198 | CLANG_WARN_STRICT_PROTOTYPES = YES;
199 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
200 | CLANG_WARN_UNREACHABLE_CODE = YES;
201 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
202 | COPY_PHASE_STRIP = YES;
203 | ENABLE_NS_ASSERTIONS = NO;
204 | ENABLE_STRICT_OBJC_MSGSEND = YES;
205 | GCC_C_LANGUAGE_STANDARD = gnu99;
206 | GCC_NO_COMMON_BLOCKS = YES;
207 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
208 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
209 | GCC_WARN_UNDECLARED_SELECTOR = YES;
210 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
211 | GCC_WARN_UNUSED_FUNCTION = YES;
212 | GCC_WARN_UNUSED_VARIABLE = YES;
213 | IPHONEOS_DEPLOYMENT_TARGET = 13.0;
214 | MTL_ENABLE_DEBUG_INFO = NO;
215 | SDKROOT = iphoneos;
216 | VALIDATE_PRODUCT = YES;
217 | };
218 | name = Release;
219 | };
220 | 58B511F01A9E6C8500147676 /* Debug */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | HEADER_SEARCH_PATHS = (
224 | "$(inherited)",
225 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
226 | "$(SRCROOT)/../../../React/**",
227 | "$(SRCROOT)/../../react-native/React/**",
228 | );
229 | LIBRARY_SEARCH_PATHS = "$(inherited)";
230 | OTHER_LDFLAGS = "-ObjC";
231 | PRODUCT_NAME = TerraReact;
232 | SKIP_INSTALL = YES;
233 | SWIFT_OBJC_BRIDGING_HEADER = "TerraReact-Bridging-Header.h";
234 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
235 | SWIFT_VERSION = 5.0;
236 | };
237 | name = Debug;
238 | };
239 | 58B511F11A9E6C8500147676 /* Release */ = {
240 | isa = XCBuildConfiguration;
241 | buildSettings = {
242 | HEADER_SEARCH_PATHS = (
243 | "$(inherited)",
244 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
245 | "$(SRCROOT)/../../../React/**",
246 | "$(SRCROOT)/../../react-native/React/**",
247 | );
248 | LIBRARY_SEARCH_PATHS = "$(inherited)";
249 | OTHER_LDFLAGS = "-ObjC";
250 | PRODUCT_NAME = TerraReact;
251 | SKIP_INSTALL = YES;
252 | SWIFT_OBJC_BRIDGING_HEADER = "TerraReact-Bridging-Header.h";
253 | SWIFT_VERSION = 5.0;
254 | };
255 | name = Release;
256 | };
257 | /* End XCBuildConfiguration section */
258 |
259 | /* Begin XCConfigurationList section */
260 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "TerraReact" */ = {
261 | isa = XCConfigurationList;
262 | buildConfigurations = (
263 | 58B511ED1A9E6C8500147676 /* Debug */,
264 | 58B511EE1A9E6C8500147676 /* Release */,
265 | );
266 | defaultConfigurationIsVisible = 0;
267 | defaultConfigurationName = Release;
268 | };
269 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "TerraReact" */ = {
270 | isa = XCConfigurationList;
271 | buildConfigurations = (
272 | 58B511F01A9E6C8500147676 /* Debug */,
273 | 58B511F11A9E6C8500147676 /* Release */,
274 | );
275 | defaultConfigurationIsVisible = 0;
276 | defaultConfigurationName = Release;
277 | };
278 | /* End XCConfigurationList section */
279 | };
280 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
281 | }
282 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## 1.8.11
9 | - Bump TerraiOS SDK to 1.6.31 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
10 |
11 | ## 1.8.10
12 | - Bump TerraAndroid SDK to 1.6.2 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
13 |
14 | ## 1.8.9
15 | - Bump Tag latest version
16 |
17 | ## 1.8.8
18 | - Bump TerraiOS SDK to 1.6.29 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
19 |
20 | ## 1.8.7
21 | - Update react native config package
22 |
23 | ## 1.8.6
24 | - Add Plannedworkouts for iOS
25 |
26 | ## 1.8.5
27 |
28 | ### Changed
29 | - Bump TerraAndroidSDK to 1.6.1
30 | - This improves memory management for the Health Connect based integration
31 |
32 |
33 | ## 1.8.4
34 |
35 | ### Changed
36 | - Remove Info.plist fields from iOS Config on expo
37 | - Remove intent filters from android manifest expo config
38 | Users may now directly add these under their expo app config
39 |
40 |
41 | ## 1.8.3
42 |
43 | ### Changed
44 | - Bump TerraAndroid SDK to 1.6.0 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
45 |
46 | ## 1.8.2
47 |
48 | ### Changed
49 | - Bump TerraiOS SDK to 1.6.28 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
50 | - Bump TerraAndroid SDK to 1.5.10 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
51 |
52 |
53 | ## 1.8.1
54 |
55 | ### Changed
56 | - Added Expo Plugin Support for Expo v53+
57 |
58 | ## 1.8.0
59 |
60 | ### Changed
61 | - Add Expo Plugin Support
62 |
63 | ## 1.7.8
64 |
65 | ### Changed
66 | - Bump TerraiOS SDK to 1.6.27 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
67 |
68 | ## 1.7.7
69 |
70 | ### Changed
71 | - Bump TerraAndroid SDK to 1.5.7 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
72 |
73 |
74 | ## 1.7.6
75 |
76 | ### Changed
77 | - Bump TerraiOS SDK to 1.6.26 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
78 |
79 |
80 | ## 1.7.5
81 |
82 | ### Changed
83 | - Bump TerraAndroid SDK to 1.5.6 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
84 |
85 | ## 1.7.4
86 |
87 | ### Changed
88 | - Bump TerraAndroid SDK to 1.5.5 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
89 | - Bump TerraiOS SDK to 1.6.25 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
90 |
91 | ## 1.7.3
92 |
93 | ### Changed
94 | - Bump TerraAndroid SDK to 1.5.3 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
95 |
96 | ## 1.7.2
97 |
98 | ### Changed
99 | - Bump TerraiOS SDK to 1.6.24 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
100 |
101 | ## 1.7.1
102 |
103 | ### Changed
104 | - Bump TerraiOS SDK to 1.6.23 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
105 |
106 | ## 1.7.0
107 |
108 | ### Changed
109 | - Bump TerraiOS SDK to 1.6.22 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
110 | - Bump TerraAndroid SDK to 1.5.2 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
111 |
112 | ## 1.6.21
113 |
114 | ### Changed
115 | - Bump TerraiOS SDK to 1.6.21 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
116 | - Added postActivity (only available on iOS 14.0 and above)
117 |
118 | ## 1.6.20
119 |
120 | ### Changed
121 | - Bump TerraiOS SDK to 1.6.19 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
122 |
123 | ## 1.6.19
124 |
125 | ### Changed
126 | - Bump TerraiOS SDK to 1.6.18 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
127 |
128 | ## 1.6.18
129 |
130 | ### Changed
131 | - Bump TerraiOS SDK to 1.6.17 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
132 |
133 | ## 1.6.17
134 |
135 | ### Changed
136 | - Bump TerraiOS SDK to 1.6.16 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
137 |
138 | ## 1.6.16
139 |
140 | ### Changed
141 | - Bump TerraiOS SDK to 1.6.14 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
142 | - Remove specific null checks to getter functions
143 | - Change typings to use primitive types when possible
144 |
145 | ## 1.6.15
146 |
147 | ### Changed
148 | - Bump TerraAndroid SDK to 1.4.24 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
149 |
150 | ## 1.6.14
151 |
152 | ### Changed
153 | - Bump TerraiOS SDK to 1.6.13 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
154 |
155 | ## 1.6.13
156 |
157 | ### Changed
158 | - Bump TerraiOS SDK to 1.6.12 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
159 |
160 | ## 1.6.12
161 |
162 | ### Changed
163 | - Bump TerraiOS SDK to 1.6.10 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
164 |
165 | ## 1.6.11
166 |
167 | ### Changed
168 | - Bump TerraiOS SDK to 1.6.9 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
169 |
170 | ## 1.6.10
171 |
172 | ### Changed
173 | - Fixing sytax error in `TerraReactModule.java`
174 |
175 | ## 1.6.9
176 |
177 | ### Changed
178 | - Bump TerraiOS SDK to 1.6.7 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
179 | - This allows you to set ignoredSources via Terra.setIgnoredSources
180 |
181 | ## 1.6.8
182 |
183 | ### Changed
184 | - Bump TerraiOS SDK to 1.6.6 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
185 |
186 | ## 1.6.7
187 |
188 | ### Changed
189 | - Bump TerraiOS SDK to 1.6.5 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
190 |
191 | ## 1.6.6
192 |
193 | ### Changed
194 | - Bump TerraiOS SDK to 1.6.4 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
195 |
196 | ## 1.6.5
197 |
198 | ### Changed
199 | - Bump TerraiOS SDK to 1.6.3 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
200 | - Fixed a bug where if INTERBEAT CustomPermissions is used in Samsung, it causes a crash
201 |
202 | ## 1.6.4
203 |
204 | ### Changed
205 | - Bump TerraiOS SDK to 1.6.2 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
206 | - Bump TerraAndroid SDK to 1.4.23 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
207 |
208 | ## 1.6.3-noperm
209 |
210 | ### Changed
211 | - Bump TerraiOS SDK to 1.5.3 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
212 |
213 | ## 1.6.3
214 |
215 | ### Changed
216 | - Bump TerraiOS SDK to 1.5.3 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
217 |
218 | ## 1.6.2
219 |
220 | ### Changed
221 | - Bump TerraAndroid SDK to 1.4.21 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
222 | - Allow Health Connect to work correctly for Android 14.
223 |
224 | ## 1.6.1
225 |
226 | ### Changed
227 | - Bump TerraiOS SDK to 1.5.2 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
228 | - Bump TerraAndroid SDK to 1.4.19 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
229 |
230 | ## 1.6.0
231 |
232 | ### Changed
233 | - Bumped TerraiOS SDK to 1.5.1 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
234 | - Update uses new iOS 17 features and requires an Xcode update!
235 |
236 | ## 1.5.2
237 |
238 | ### Changed
239 | - Bumped TerraiOS SDK to 1.4.9 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
240 |
241 | ## 1.5.1
242 |
243 | ### Changed
244 | - Bumped TerraiOS SDK to 1.4.8 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
245 | - Bump TerraAndroid SDK to 1.4.18 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
246 | - Needs compileSdk 34
247 | - Improve local normalisation
248 | - Propagate Libre sensor state on activation of sensor
249 |
250 | ## 1.5.0
251 |
252 | ### Changed
253 | - Bumped TerraiOS SDK to 1.4.5 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
254 | - Improved iOS background delivery
255 | - Updated Terra data models to latest
256 |
257 | ## 1.4.19
258 |
259 | ### Changed
260 | - Bump TerraiOS SDK to 1.3.23 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
261 |
262 | ## 1.4.18
263 |
264 | ### Changed
265 | - Bump TerraiOS SDK to 1.3.21 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
266 |
267 | ## 1.4.17
268 |
269 | ### Changed
270 | - Bump TerraiOS SDK to 1.3.20 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
271 |
272 | ## 1.4.16
273 |
274 | ### Changed
275 | - Bump TerraiOS SDK to 1.3.19 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
276 | - Bump TerraAndroid SDK to 1.4.14 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
277 |
278 | ## 1.4.15
279 |
280 | ### Changed
281 | - Bump TerraAndroid SDK to 1.4.13 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
282 |
283 | ### Bug Fixes
284 | - Fix bug where checkAuth function was not executing correctly for iOS
285 |
286 | ### Added
287 | - Added checkAuth functionality for Android
288 |
289 | ## 1.4.14
290 |
291 | ### Changed
292 | - Bump TerraiOS SDK to 1.3.16 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
293 |
294 | ## 1.4.13
295 |
296 | ### Changed
297 | - Bump TerraiOS SDK to 1.3.15 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
298 | - Bump TerraAndroid SDK to 1.4.12 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
299 |
300 |
301 | ## 1.4.12
302 |
303 | ### Changed
304 | - Bump TerraiOS SDK to 1.3.14 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
305 | - Bump TerraAndroid SDK to 1.4.11 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
306 |
307 | ## 1.4.11
308 |
309 | ### Changed
310 | - Bump TerraiOS SDK to 1.3.13 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
311 |
312 | ## 1.4.10
313 |
314 | ### Changed
315 | - Bump TerraiOS SDK to 1.3.12 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
316 | - Bump TerraAndroid SDK to 1.4.10 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
317 |
318 | ## 1.4.9
319 |
320 | ### Changed
321 | - Bump TerraiOS SDK to 1.3.11 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
322 | - Bump TerraAndroid SDK to 1.4.9 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
323 |
324 | ## 1.4.8
325 |
326 | ### Changed
327 | - Bump TerraiOS SDK to 1.3.10 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
328 | - Bump TerraAndroid SDK to 1.4.8 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
329 |
330 | ## 1.4.7
331 |
332 | ### Changed
333 | - Bump TerraiOS SDK to 1.3.8 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
334 | - Bump TerraAndroid SDK to 1.4.8 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
335 |
336 | ### Added
337 | - Null checks for Android
338 |
339 | ## 1.4.6
340 |
341 | ### Changed
342 | - Bump TerraiOS SDK to 1.3.7 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
343 |
344 | ### Fixed
345 | - Fixed a bug where initTerra callbacks with true even with incorrect developer ID.
346 |
347 | ## 1.4.5
348 |
349 | ### Changed
350 | - Bump TerraiOS SDK to 1.3.6 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
351 | - Bump TerraAndroid SDK to 1.4.6 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
352 |
353 | ## 1.4.4
354 |
355 | ### Changed
356 | - Added a default "toWebhook" parameter for getAthlete function
357 |
358 | ## 1.4.3
359 |
360 | ### Added
361 | - Bridged functions to check if Health Connect is available, get granted permissions from Health Connect and Open Health Connect
362 |
363 | ## 1.4.2
364 |
365 | ### Changed
366 | - Bump TerraiOS SDK to 1.3.5 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
367 | - Bump TerraAndroid SDK to 1.4.5 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
368 |
369 | ## 1.4.1
370 |
371 | ### Changed
372 | - Bump TerraiOS SDK to 1.3.3 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
373 | - Bump TerraAndroid SDK to 1.4.3 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
374 |
375 | ## 1.4.0
376 |
377 | ### Changed
378 | - Bump TerraiOS SDK to 1.3.2 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
379 | - Bump TerraAndroid SDK to 1.4.0 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
380 |
381 | ### Added
382 | - Includes Singleton update
383 | - Can now receive data within getter functions (getActivity, getDaily etc.)
384 |
385 | ## 1.3.2
386 |
387 | ### Changed
388 |
389 | - Bump TerraiOS SDK to 1.2.25 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
390 | - Bump TerraAndroid SDK to 1.3.8 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
391 |
392 | ## 1.3.1
393 |
394 | ### Changed
395 |
396 | - Bump TerraiOS SDK to 1.2.24 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
397 | - Bump TerraAndroid SDK to 1.3.8 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
398 |
399 | ## 1.3.0
400 |
401 | ### Changes
402 |
403 | - Bump TerraiOS SDK to 1.2.21 (https://github.com/tryterra/TerraiOS/wiki/Change-Log)
404 | - Bump TerraAndroid SDK to 1.3.5 (https://github.com/tryterra/TerraAndroid/wiki/Change-Log)
405 | - This version onwards uses Health Connect to connect to Android data
406 |
407 |
408 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { NativeModules, Platform } from 'react-native';
2 | import { CustomPermissions as CustomPermissions_ } from './enums/CustomPermissions';
3 | import { Connections as Connections_ } from './enums/Connections';
4 | import { Activity as TerraActivityPayload } from './models/Activity';
5 | import { TerraPlannedWorkout } from './models/PlannedWorkouts';
6 |
7 | const LINKING_ERROR =
8 | `The package 'terra-react' doesn't seem to be linked. Make sure: \n\n` +
9 | Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
10 | '- You rebuilt the app after installing the package\n' +
11 | '- You are not using Expo managed workflow\n';
12 |
13 | const TerraReact = NativeModules.TerraReact
14 | ? NativeModules.TerraReact
15 | : new Proxy(
16 | {},
17 | {
18 | get() {
19 | throw new Error(LINKING_ERROR);
20 | },
21 | }
22 | );
23 |
24 | export type GetUserId = {
25 | success: boolean;
26 | userId: string | null;
27 | };
28 |
29 | export type SuccessMessage = {
30 | success: boolean;
31 | error: string | null;
32 | };
33 |
34 | export type DataMessage = {
35 | success: boolean;
36 | data: Object;
37 | error: string | null;
38 | };
39 |
40 | export interface ListDataMessage {
41 | success?: boolean | null;
42 | data?: T[] | null;
43 | error?: string | null;
44 | }
45 |
46 | function ConnectionToString(connection: Connections_) {
47 | switch (connection) {
48 | case Connections_.APPLE_HEALTH:
49 | return 'APPLE_HEALTH';
50 | case Connections_.FREESTYLE_LIBRE:
51 | return 'FREESTYLE_LIBRE';
52 | case Connections_.GOOGLE:
53 | return 'GOOGLE';
54 | case Connections_.SAMSUNG:
55 | return 'SAMSUNG';
56 | case Connections_.HEALTH_CONNECT:
57 | return 'HEALTH_CONNECT';
58 | default:
59 | return undefined;
60 | }
61 | }
62 |
63 | function CustomPermissions_ToString(cPermission: CustomPermissions_) {
64 | switch (cPermission) {
65 | case CustomPermissions_.WORKOUT_TYPES:
66 | return 'WORKOUT_TYPES';
67 | case CustomPermissions_.ACTIVITY_SUMMARY:
68 | return 'ACTIVITY_SUMMARY';
69 | case CustomPermissions_.LOCATION:
70 | return 'LOCATION';
71 | case CustomPermissions_.CALORIES:
72 | return 'CALORIES';
73 | case CustomPermissions_.STEPS:
74 | return 'STEPS';
75 | case CustomPermissions_.HEART_RATE:
76 | return 'HEART_RATE';
77 | case CustomPermissions_.HEART_RATE_VARIABILITY:
78 | return 'HEART_RATE_VARIABILITY';
79 | case CustomPermissions_.VO2MAX:
80 | return 'VO2MAX';
81 | case CustomPermissions_.HEIGHT:
82 | return 'HEIGHT';
83 | case CustomPermissions_.ACTIVE_DURATIONS:
84 | return 'ACTIVE_DURATIONS';
85 | case CustomPermissions_.WEIGHT:
86 | return 'WEIGHT';
87 | case CustomPermissions_.FLIGHTS_CLIMBED:
88 | return 'FLIGHTS_CLIMBED';
89 | case CustomPermissions_.BMI:
90 | return 'BMI';
91 | case CustomPermissions_.BODY_FAT:
92 | return 'BODY_FAT';
93 | case CustomPermissions_.EXERCISE_DISTANCE:
94 | return 'EXERCISE_DISTANCE';
95 | case CustomPermissions_.GENDER:
96 | return 'GENDER';
97 | case CustomPermissions_.DATE_OF_BIRTH:
98 | return 'DATE_OF_BIRTH';
99 | case CustomPermissions_.BASAL_ENERGY_BURNED:
100 | return 'BASAL_ENERGY_BURNED';
101 | case CustomPermissions_.SWIMMING_SUMMARY:
102 | return 'SWIMMING_SUMMARY';
103 | case CustomPermissions_.RESTING_HEART_RATE:
104 | return 'RESTING_HEART_RATE';
105 | case CustomPermissions_.BLOOD_PRESSURE:
106 | return 'BLOOD_PRESSURE';
107 | case CustomPermissions_.BLOOD_GLUCOSE:
108 | return 'BLOOD_GLUCOSE';
109 | case CustomPermissions_.BODY_TEMPERATURE:
110 | return 'BODY_TEMPERATURE';
111 | case CustomPermissions_.MINDFULNESS:
112 | return 'MINDFULNESS';
113 | case CustomPermissions_.LEAN_BODY_MASS:
114 | return 'LEAN_BODY_MASS';
115 | case CustomPermissions_.OXYGEN_SATURATION:
116 | return 'OXYGEN_SATURATION';
117 | case CustomPermissions_.SLEEP_ANALYSIS:
118 | return 'SLEEP_ANALYSIS';
119 | case CustomPermissions_.RESPIRATORY_RATE:
120 | return 'RESPIRATORY_RATE';
121 | case CustomPermissions_.NUTRITION_SODIUM:
122 | return 'NUTRITION_SODIUM';
123 | case CustomPermissions_.NUTRITION_PROTEIN:
124 | return 'NUTRITION_PROTEIN';
125 | case CustomPermissions_.NUTRITION_CARBOHYDRATES:
126 | return 'NUTRITION_CARBOHYDRATES';
127 | case CustomPermissions_.NUTRITION_FIBRE:
128 | return 'NUTRITION_FIBRE';
129 | case CustomPermissions_.NUTRITION_FAT_TOTAL:
130 | return 'NUTRITION_FAT_TOTAL';
131 | case CustomPermissions_.NUTRITION_SUGAR:
132 | return 'NUTRITION_SUGAR';
133 | case CustomPermissions_.NUTRITION_VITAMIN_C:
134 | return 'NUTRITION_VITAMIN_C';
135 | case CustomPermissions_.NUTRITION_VITAMIN_A:
136 | return 'NUTRITION_VITAMIN_A';
137 | case CustomPermissions_.NUTRITION_CALORIES:
138 | return 'NUTRITION_CALORIES';
139 | case CustomPermissions_.NUTRITION_WATER:
140 | return 'NUTRITION_WATER';
141 | case CustomPermissions_.NUTRITION_CHOLESTEROL:
142 | return 'NUTRITION_CHOLESTEROL';
143 | case CustomPermissions_.MENSTRUATION:
144 | return 'MENSTRUATION';
145 | case CustomPermissions_.INTERBEAT:
146 | return 'INTERBEAT';
147 | case CustomPermissions_.SPEED:
148 | return 'SPEED';
149 | case CustomPermissions_.POWER:
150 | return 'POWER';
151 | }
152 | }
153 |
154 | export function initTerra(
155 | devID: string,
156 | referenceId: string | null
157 | ): Promise {
158 | return TerraReact.initTerra(devID, referenceId);
159 | }
160 |
161 | export function initConnection(
162 | connection: Connections_,
163 | token: string,
164 | schedulerOn: boolean,
165 | customPermissions_: CustomPermissions_[] = [],
166 | startIntent: string | null = null
167 | ): Promise {
168 | return TerraReact.initConnection(
169 | ConnectionToString(connection),
170 | token,
171 | schedulerOn,
172 | customPermissions_.map((p) => CustomPermissions_ToString(p)),
173 | startIntent
174 | );
175 | }
176 |
177 | export function checkAuth(
178 | connection: Connections_,
179 | devID: string
180 | ): Promise> {
181 | return TerraReact.checkAuth(ConnectionToString(connection), devID);
182 | }
183 |
184 | export function getUserId(connection: Connections_): Promise {
185 | return TerraReact.getUserId(ConnectionToString(connection));
186 | }
187 |
188 | export function getBody(
189 | connection: Connections_,
190 | startDate: Date,
191 | endDate: Date,
192 | latestReading: boolean = false,
193 | toWebhook: boolean = true
194 | ): Promise {
195 | return new Promise((resolve, reject) => {
196 | TerraReact.getBody(
197 | ConnectionToString(connection),
198 | startDate.toISOString(),
199 | endDate.toISOString(),
200 | latestReading,
201 | toWebhook
202 | )
203 | .then((d: any) => {
204 | const data: DataMessage = {
205 | success: d.success,
206 | data: d.data !== undefined ? JSON.parse(d.data) : null,
207 | error: d.error,
208 | };
209 | resolve(data);
210 | })
211 | .catch((e: Error) => {
212 | reject(e);
213 | });
214 | });
215 | }
216 |
217 | export function getActivity(
218 | connection: Connections_,
219 | startDate: Date,
220 | endDate: Date,
221 | toWebhook: boolean = true
222 | ): Promise {
223 | return new Promise((resolve, reject) => {
224 | TerraReact.getActivity(
225 | ConnectionToString(connection),
226 | startDate.toISOString(),
227 | endDate.toISOString(),
228 | toWebhook
229 | )
230 | .then((d: any) => {
231 | const data: DataMessage = {
232 | success: d.success,
233 | data: d.data !== undefined ? JSON.parse(d.data) : null,
234 | error: d.error,
235 | };
236 | resolve(data);
237 | })
238 | .catch((e: Error) => {
239 | reject(e);
240 | });
241 | });
242 | }
243 |
244 | export function getMenstruation(
245 | connection: Connections_,
246 | startDate: Date,
247 | endDate: Date,
248 | toWebhook: boolean = true
249 | ): Promise {
250 | return new Promise((resolve, reject) => {
251 | TerraReact.getMenstruation(
252 | ConnectionToString(connection),
253 | startDate.toISOString(),
254 | endDate.toISOString(),
255 | toWebhook
256 | )
257 | .then((d: any) => {
258 | const data: DataMessage = {
259 | success: d.success,
260 | data: d.data !== undefined ? JSON.parse(d.data) : null,
261 | error: d.error,
262 | };
263 | resolve(data);
264 | })
265 | .catch((e: Error) => {
266 | reject(e);
267 | });
268 | });
269 | }
270 |
271 | export function getDaily(
272 | connection: Connections_,
273 | startDate: Date,
274 | endDate: Date,
275 | toWebhook: boolean = true
276 | ): Promise {
277 | return new Promise((resolve, reject) => {
278 | TerraReact.getDaily(
279 | ConnectionToString(connection),
280 | startDate.toISOString(),
281 | endDate.toISOString(),
282 | toWebhook
283 | )
284 | .then((d: any) => {
285 | const data: DataMessage = {
286 | success: d.success,
287 | data: d.data !== undefined ? JSON.parse(d.data) : null,
288 | error: d.error,
289 | };
290 | resolve(data);
291 | })
292 | .catch((e: Error) => {
293 | reject(e);
294 | });
295 | });
296 | }
297 |
298 | export function getNutrition(
299 | connection: Connections_,
300 | startDate: Date,
301 | endDate: Date,
302 | toWebhook: boolean = true
303 | ): Promise {
304 | return new Promise((resolve, reject) => {
305 | TerraReact.getNutrition(
306 | ConnectionToString(connection),
307 | startDate.toISOString(),
308 | endDate.toISOString(),
309 | toWebhook
310 | )
311 | .then((d: any) => {
312 | const data: DataMessage = {
313 | success: d.success,
314 | data: d.data !== undefined ? JSON.parse(d.data) : null,
315 | error: d.error,
316 | };
317 | resolve(data);
318 | })
319 | .catch((e: Error) => {
320 | reject(e);
321 | });
322 | });
323 | }
324 |
325 | export function getSleep(
326 | connection: Connections_,
327 | startDate: Date,
328 | endDate: Date,
329 | toWebhook: boolean = true
330 | ): Promise {
331 | return new Promise((resolve, reject) => {
332 | TerraReact.getSleep(
333 | ConnectionToString(connection),
334 | startDate.toISOString(),
335 | endDate.toISOString(),
336 | toWebhook
337 | )
338 | .then((d: any) => {
339 | const data: DataMessage = {
340 | success: d.success,
341 | data: d.data !== undefined ? JSON.parse(d.data) : null,
342 | error: d.error,
343 | };
344 | resolve(data);
345 | })
346 | .catch((e: Error) => {
347 | reject(e);
348 | });
349 | });
350 | }
351 |
352 | export function getAthlete(
353 | connection: Connections_,
354 | toWebhook: boolean = true
355 | ) {
356 | return TerraReact.getAthlete(ConnectionToString(connection), toWebhook);
357 | }
358 |
359 | /*
360 | @Only availble on iOS
361 | */
362 | export function postActivity(
363 | connection: Connections_,
364 | payload: TerraActivityPayload
365 | ): Promise {
366 | return new Promise((resolve, reject) => {
367 | TerraReact.postActivity(ConnectionToString(connection), payload)
368 | .then((d: any) => {
369 | resolve({ success: d.success, error: d.error } as SuccessMessage);
370 | })
371 | .catch((e: Error) => {
372 | reject(e);
373 | });
374 | });
375 | }
376 | export function getPlannedWorkouts(
377 | connection: Connections_
378 | ): Promise> {
379 | return new Promise>((resolve, reject) => {
380 | TerraReact.getPlannedWorkouts(ConnectionToString(connection))
381 | .then((d: any) => {
382 | const data: ListDataMessage = {
383 | success: d.success,
384 | data: d.data !== undefined ? JSON.parse(d.data) : null,
385 | error: d.error,
386 | };
387 | resolve(data);
388 | })
389 | .catch((e: Error) => reject(e));
390 | });
391 | }
392 | export function deletePlannedWorkout(
393 | connection: Connections_,
394 | id: string
395 | ): Promise {
396 | return new Promise((resolve, reject) => {
397 | TerraReact.deletePlannedWorkout(ConnectionToString(connection), id)
398 | .then((d: any) => {
399 | const res: SuccessMessage = {
400 | success: d.success,
401 | error: d.error,
402 | };
403 | resolve(res);
404 | })
405 | .catch((e: Error) => reject(e));
406 | });
407 | }
408 |
409 | export function completePlannedWorkout(
410 | connection: Connections_,
411 | id: string,
412 | at?: Date
413 | ): Promise {
414 | return new Promise((resolve, reject) => {
415 | TerraReact.completePlannedWorkout(
416 | ConnectionToString(connection),
417 | id,
418 | (at ?? new Date()).toISOString()
419 | )
420 | .then((d: any) => {
421 | const res: SuccessMessage = {
422 | success: d.success,
423 | error: d.error,
424 | };
425 | resolve(res);
426 | })
427 | .catch((e: Error) => reject(e));
428 | });
429 | }
430 |
431 | export function postPlannedWorkout(
432 | connection: Connections_,
433 | payload: TerraPlannedWorkout
434 | ): Promise {
435 | return new Promise((resolve, reject) => {
436 | TerraReact.postPlannedWorkout(
437 | ConnectionToString(connection),
438 | JSON.stringify(payload.toJson())
439 | )
440 | .then((d: any) => {
441 | const res: SuccessMessage = {
442 | success: d.success,
443 | error: d.error,
444 | };
445 | resolve(res);
446 | })
447 | .catch((e: Error) => reject(e));
448 | });
449 | }
450 |
451 | export function readGlucoseData(): Promise