From 79b4cb42d29a08ad50940264ad422593cc69a76d Mon Sep 17 00:00:00 2001 From: Kwangsoo Yeo Date: Fri, 17 Nov 2023 16:17:43 -0800 Subject: [PATCH] v2.0 rn basic changes --- .github/workflows/react-native-demos.yml | 18 ++++++++++++++++++ .github/workflows/react-native-tests.yml | 2 +- .github/workflows/react-native.yml | 2 +- .../reactnative/cheetah/CheetahModule.java | 2 ++ binding/react-native/ios/Cheetah.swift | 7 ++++++- binding/react-native/package.json | 2 +- .../test-app/CheetahTestApp/ios/Podfile | 1 + 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/react-native-demos.yml b/.github/workflows/react-native-demos.yml index b2ca3fe8..c91b5a68 100644 --- a/.github/workflows/react-native-demos.yml +++ b/.github/workflows/react-native-demos.yml @@ -38,6 +38,15 @@ jobs: - name: Pre-build dependencies run: npm install yarn + # ************ REMOVE AFTER RELEASE ***************** + - name: Build and package binding + working-directory: binding/react-native + run: yarn && yarn pkg + + - name: Add to demo + run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz + # *************************************************** + - name: Install dependencies run: yarn android-install @@ -66,6 +75,15 @@ jobs: - name: Pre-build dependencies run: npm install yarn + # ************ REMOVE AFTER RELEASE ***************** + - name: Build and package binding + working-directory: binding/react-native + run: yarn && yarn pkg + + - name: Add to demo + run: yarn add ../../binding/react-native/pkg/picovoice-cheetah-react-native-2.0.0.tgz + # *************************************************** + - name: Install dependencies run: yarn ios-install diff --git a/.github/workflows/react-native-tests.yml b/.github/workflows/react-native-tests.yml index b60f2f01..65e2612d 100644 --- a/.github/workflows/react-native-tests.yml +++ b/.github/workflows/react-native-tests.yml @@ -59,7 +59,7 @@ jobs: ./copy_test_resources.sh - name: Cocoapods install working-directory: binding/react-native/test-app/CheetahTestApp/ios - run: pod install + run: pod install --repo-update - name: Inject AppID run: sed -i '.bak' 's:{TESTING_ACCESS_KEY_HERE}:${{secrets.PV_VALID_ACCESS_KEY}}:' Tests.ts diff --git a/.github/workflows/react-native.yml b/.github/workflows/react-native.yml index 20603461..49847267 100644 --- a/.github/workflows/react-native.yml +++ b/.github/workflows/react-native.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x, 20.x] + node-version: [16.x, 18.x, 20.x] steps: - uses: actions/checkout@v3 diff --git a/binding/react-native/android/src/main/java/ai/picovoice/reactnative/cheetah/CheetahModule.java b/binding/react-native/android/src/main/java/ai/picovoice/reactnative/cheetah/CheetahModule.java index a1ab9c1e..e66a2267 100644 --- a/binding/react-native/android/src/main/java/ai/picovoice/reactnative/cheetah/CheetahModule.java +++ b/binding/react-native/android/src/main/java/ai/picovoice/reactnative/cheetah/CheetahModule.java @@ -42,6 +42,8 @@ public class CheetahModule extends ReactContextBaseJavaModule { public CheetahModule(ReactApplicationContext reactContext) { super(reactContext); this.reactContext = reactContext; + + Cheetah.setSdk("react-native"); } @NonNull diff --git a/binding/react-native/ios/Cheetah.swift b/binding/react-native/ios/Cheetah.swift index 72cb24ef..5e61cacf 100644 --- a/binding/react-native/ios/Cheetah.swift +++ b/binding/react-native/ios/Cheetah.swift @@ -1,5 +1,5 @@ // -// Copyright 2022 Picovoice Inc. +// Copyright 2022-2023 Picovoice Inc. // // You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" // file accompanying this source. @@ -15,6 +15,11 @@ import Cheetah class PvCheetah: NSObject { private var cheetahPool: [String: Cheetah] = [:] + override init() { + super.init() + Cheetah.setSdk(sdk: "react-native") + } + @objc(create:modelPath:endpointDuration:enableAutomaticPunctuation:resolver:rejecter:) func create( accessKey: String, diff --git a/binding/react-native/package.json b/binding/react-native/package.json index 299d6f06..0b5603f8 100644 --- a/binding/react-native/package.json +++ b/binding/react-native/package.json @@ -1,6 +1,6 @@ { "name": "@picovoice/cheetah-react-native", - "version": "1.1.1", + "version": "2.0.0", "description": "Picovoice Cheetah React Native binding", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/binding/react-native/test-app/CheetahTestApp/ios/Podfile b/binding/react-native/test-app/CheetahTestApp/ios/Podfile index 5d6d4863..e3028bf8 100644 --- a/binding/react-native/test-app/CheetahTestApp/ios/Podfile +++ b/binding/react-native/test-app/CheetahTestApp/ios/Podfile @@ -14,6 +14,7 @@ end target 'CheetahTestApp' do config = use_native_modules! + pod 'Cheetah-iOS', :podspec => 'https://raw.githubusercontent.com/Picovoice/cheetah/v2.0/binding/ios/Cheetah-iOS.podspec' # Flags change depending on the env values. flags = get_default_flags()