react-native-carrot-quest 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,8 +29,9 @@ import java.util.Locale
29
29
  * that *disagree* fail with [CarrotQuestConfigurationConflictException] rather
30
30
  * than silently keeping the first configuration.
31
31
  *
32
- * `Carrot.setup` performs I/O, so call this off the main thread; this object
33
- * does not spawn its own thread, leaving the scheduler choice to the caller.
32
+ * `Carrot.setup` performs I/O, so this object runs it on its own background
33
+ * thread. The call returns as soon as the Initializing state is published, so
34
+ * it is safe to call from the main thread or the JS thread.
34
35
  */
35
36
  object CarrotQuestSetup {
36
37
  private const val TAG = "CarrotQuest"
@@ -211,17 +212,21 @@ object CarrotQuestSetup {
211
212
 
212
213
  val applicationContext = context.applicationContext
213
214
 
214
- try {
215
- start(applicationContext, options) { error ->
216
- if (error == null) {
217
- settleSuccess(applicationContext, identity, options)
218
- } else {
219
- settleFailure(error)
215
+ // The Initializing state above is already published, so calls that arrive
216
+ // before this thread runs queue as readiness waiters instead of failing.
217
+ Thread({
218
+ try {
219
+ start(applicationContext, options) { error ->
220
+ if (error == null) {
221
+ settleSuccess(applicationContext, identity, options)
222
+ } else {
223
+ settleFailure(error)
224
+ }
220
225
  }
226
+ } catch (error: Throwable) {
227
+ settleFailure(error)
221
228
  }
222
- } catch (error: Throwable) {
223
- settleFailure(error)
224
- }
229
+ }, "carrot-sdk-init").start()
225
230
  }
226
231
 
227
232
  /**
@@ -10,7 +10,6 @@ package com.margelo.nitro.carrotquest
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import dalvik.annotation.optimization.FastNative
14
13
 
15
14
 
16
15
  /**
@@ -59,7 +58,6 @@ class Func_void_CarrotQuestLogEntry_cxx: Func_void_CarrotQuestLogEntry {
59
58
  override fun invoke(entry: CarrotQuestLogEntry): Unit
60
59
  = invoke_cxx(entry)
61
60
 
62
- @FastNative
63
61
  private external fun invoke_cxx(entry: CarrotQuestLogEntry): Unit
64
62
  }
65
63
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.carrotquest
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import dalvik.annotation.optimization.FastNative
14
13
 
15
14
 
16
15
  /**
@@ -59,7 +58,6 @@ class Func_void_bool_cxx: Func_void_bool {
59
58
  override fun invoke(visible: Boolean): Unit
60
59
  = invoke_cxx(visible)
61
60
 
62
- @FastNative
63
61
  private external fun invoke_cxx(visible: Boolean): Unit
64
62
  }
65
63
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.carrotquest
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import dalvik.annotation.optimization.FastNative
14
13
 
15
14
 
16
15
  /**
@@ -59,7 +58,6 @@ class Func_void_double_cxx: Func_void_double {
59
58
  override fun invoke(count: Double): Unit
60
59
  = invoke_cxx(count)
61
60
 
62
- @FastNative
63
61
  private external fun invoke_cxx(count: Double): Unit
64
62
  }
65
63
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.carrotquest
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import dalvik.annotation.optimization.FastNative
14
13
 
15
14
 
16
15
  /**
@@ -59,7 +58,6 @@ class Func_void_std__string_cxx: Func_void_std__string {
59
58
  override fun invoke(url: String): Unit
60
59
  = invoke_cxx(url)
61
60
 
62
- @FastNative
63
61
  private external fun invoke_cxx(url: String): Unit
64
62
  }
65
63
 
@@ -10,6 +10,7 @@ package com.margelo.nitro.carrotquest
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
13
14
  import com.margelo.nitro.core.Promise
14
15
  import com.margelo.nitro.core.HybridObject
15
16
 
@@ -197,6 +198,7 @@ abstract class HybridCarrotQuestSpec: HybridObject() {
197
198
  @Keep
198
199
  protected open class CxxPart(javaPart: HybridCarrotQuestSpec): HybridObject.CxxPart(javaPart) {
199
200
  // C++ JHybridCarrotQuestSpec::CxxPart::initHybrid(...)
201
+ @FastNative
200
202
  external override fun initHybrid(): HybridData
201
203
  }
202
204
  override fun createCxxPart(): CxxPart {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-carrot-quest",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Unofficial React Native bindings for the Carrot quest SDK, built with Nitro Modules.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -84,12 +84,12 @@
84
84
  "eslint-plugin-prettier": "^5.5.6",
85
85
  "jest": "^29",
86
86
  "lefthook": "^2.1.10",
87
- "nitrogen": "^0.35.3",
87
+ "nitrogen": "^0.37.1",
88
88
  "prettier": "^3.8.3",
89
89
  "react": "19.2.3",
90
90
  "react-native": "0.85.0",
91
91
  "react-native-builder-bob": "^0.41.0",
92
- "react-native-nitro-modules": "^0.35.3",
92
+ "react-native-nitro-modules": "^0.37.1",
93
93
  "release-it": "^21.0.1",
94
94
  "turbo": "^2.9.16",
95
95
  "typescript": "^6.0.3"
@@ -97,7 +97,7 @@
97
97
  "peerDependencies": {
98
98
  "react": "*",
99
99
  "react-native": "*",
100
- "react-native-nitro-modules": "^0.35.3"
100
+ "react-native-nitro-modules": "^0.37.1"
101
101
  },
102
102
  "workspaces": [
103
103
  "example"