react-native-carrot-quest 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CarrotQuest.podspec +34 -0
  2. package/LICENSE +20 -0
  3. package/README.md +457 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +136 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  8. package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuest.kt +585 -0
  9. package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestPackage.kt +22 -0
  10. package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestSetup.kt +472 -0
  11. package/ios/CarrotQuest.swift +588 -0
  12. package/ios/CarrotQuestSetup.swift +333 -0
  13. package/lib/module/CarrotQuest.nitro.js +4 -0
  14. package/lib/module/CarrotQuest.nitro.js.map +1 -0
  15. package/lib/module/carrot-quest.js +136 -0
  16. package/lib/module/carrot-quest.js.map +1 -0
  17. package/lib/module/carrot-quest.native.js +155 -0
  18. package/lib/module/carrot-quest.native.js.map +1 -0
  19. package/lib/module/index.js +6 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/package.json +1 -0
  22. package/lib/module/subscriptions.js +76 -0
  23. package/lib/module/subscriptions.js.map +1 -0
  24. package/lib/typescript/package.json +1 -0
  25. package/lib/typescript/src/CarrotQuest.nitro.d.ts +394 -0
  26. package/lib/typescript/src/CarrotQuest.nitro.d.ts.map +1 -0
  27. package/lib/typescript/src/carrot-quest.d.ts +37 -0
  28. package/lib/typescript/src/carrot-quest.d.ts.map +1 -0
  29. package/lib/typescript/src/carrot-quest.native.d.ts +37 -0
  30. package/lib/typescript/src/carrot-quest.native.d.ts.map +1 -0
  31. package/lib/typescript/src/index.d.ts +6 -0
  32. package/lib/typescript/src/index.d.ts.map +1 -0
  33. package/lib/typescript/src/subscriptions.d.ts +32 -0
  34. package/lib/typescript/src/subscriptions.d.ts.map +1 -0
  35. package/nitro.json +23 -0
  36. package/nitrogen/generated/android/c++/JCarrotQuestEventValue.cpp +30 -0
  37. package/nitrogen/generated/android/c++/JCarrotQuestEventValue.hpp +83 -0
  38. package/nitrogen/generated/android/c++/JCarrotQuestLogCategory.hpp +76 -0
  39. package/nitrogen/generated/android/c++/JCarrotQuestLogEntry.hpp +100 -0
  40. package/nitrogen/generated/android/c++/JCarrotQuestLogLevel.hpp +70 -0
  41. package/nitrogen/generated/android/c++/JCarrotQuestProperty.hpp +74 -0
  42. package/nitrogen/generated/android/c++/JCarrotQuestPropertyKind.hpp +61 -0
  43. package/nitrogen/generated/android/c++/JCarrotQuestPropertyOperation.hpp +73 -0
  44. package/nitrogen/generated/android/c++/JCarrotQuestSetupOptions.hpp +94 -0
  45. package/nitrogen/generated/android/c++/JCarrotQuestTheme.hpp +64 -0
  46. package/nitrogen/generated/android/c++/JCarrotQuestUrlSource.hpp +64 -0
  47. package/nitrogen/generated/android/c++/JCarrotQuestUserProperties.hpp +84 -0
  48. package/nitrogen/generated/android/c++/JFunc_void_CarrotQuestLogEntry.hpp +84 -0
  49. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  50. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  51. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  52. package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.cpp +388 -0
  53. package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.hpp +96 -0
  54. package/nitrogen/generated/android/carrotquest+autolinking.cmake +82 -0
  55. package/nitrogen/generated/android/carrotquest+autolinking.gradle +27 -0
  56. package/nitrogen/generated/android/carrotquestOnLoad.cpp +62 -0
  57. package/nitrogen/generated/android/carrotquestOnLoad.hpp +34 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestEventValue.kt +75 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogCategory.kt +29 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogEntry.kt +81 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogLevel.kt +27 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestProperty.kt +66 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyKind.kt +24 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyOperation.kt +28 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestSetupOptions.kt +91 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestTheme.kt +25 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUrlSource.kt +25 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUserProperties.kt +66 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_CarrotQuestLogEntry.kt +80 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_bool.kt +80 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_double.kt +80 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_std__string.kt +80 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/HybridCarrotQuestSpec.kt +209 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/carrotquestOnLoad.kt +35 -0
  75. package/nitrogen/generated/ios/CarrotQuest+autolinking.rb +62 -0
  76. package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.cpp +97 -0
  77. package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.hpp +637 -0
  78. package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Umbrella.hpp +80 -0
  79. package/nitrogen/generated/ios/CarrotQuestAutolinking.mm +33 -0
  80. package/nitrogen/generated/ios/CarrotQuestAutolinking.swift +26 -0
  81. package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.cpp +11 -0
  82. package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.hpp +344 -0
  83. package/nitrogen/generated/ios/swift/CarrotQuestEventValue.swift +32 -0
  84. package/nitrogen/generated/ios/swift/CarrotQuestLogCategory.swift +64 -0
  85. package/nitrogen/generated/ios/swift/CarrotQuestLogEntry.swift +86 -0
  86. package/nitrogen/generated/ios/swift/CarrotQuestLogLevel.swift +56 -0
  87. package/nitrogen/generated/ios/swift/CarrotQuestProperty.swift +56 -0
  88. package/nitrogen/generated/ios/swift/CarrotQuestPropertyKind.swift +44 -0
  89. package/nitrogen/generated/ios/swift/CarrotQuestPropertyOperation.swift +60 -0
  90. package/nitrogen/generated/ios/swift/CarrotQuestSetupOptions.swift +172 -0
  91. package/nitrogen/generated/ios/swift/CarrotQuestTheme.swift +48 -0
  92. package/nitrogen/generated/ios/swift/CarrotQuestUrlSource.swift +48 -0
  93. package/nitrogen/generated/ios/swift/CarrotQuestUserProperties.swift +110 -0
  94. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  95. package/nitrogen/generated/ios/swift/Func_void_CarrotQuestLogEntry.swift +46 -0
  96. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  97. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  98. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  99. package/nitrogen/generated/ios/swift/Func_void_std__optional_double_.swift +53 -0
  100. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
  101. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  102. package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec.swift +88 -0
  103. package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec_cxx.swift +674 -0
  104. package/nitrogen/generated/shared/c++/CarrotQuestLogCategory.hpp +100 -0
  105. package/nitrogen/generated/shared/c++/CarrotQuestLogEntry.hpp +114 -0
  106. package/nitrogen/generated/shared/c++/CarrotQuestLogLevel.hpp +92 -0
  107. package/nitrogen/generated/shared/c++/CarrotQuestProperty.hpp +101 -0
  108. package/nitrogen/generated/shared/c++/CarrotQuestPropertyKind.hpp +80 -0
  109. package/nitrogen/generated/shared/c++/CarrotQuestPropertyOperation.hpp +96 -0
  110. package/nitrogen/generated/shared/c++/CarrotQuestSetupOptions.hpp +121 -0
  111. package/nitrogen/generated/shared/c++/CarrotQuestTheme.hpp +84 -0
  112. package/nitrogen/generated/shared/c++/CarrotQuestUrlSource.hpp +84 -0
  113. package/nitrogen/generated/shared/c++/CarrotQuestUserProperties.hpp +97 -0
  114. package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.cpp +55 -0
  115. package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.hpp +118 -0
  116. package/package.json +140 -0
  117. package/src/CarrotQuest.nitro.ts +493 -0
  118. package/src/carrot-quest.native.tsx +241 -0
  119. package/src/carrot-quest.tsx +207 -0
  120. package/src/index.tsx +57 -0
  121. package/src/subscriptions.ts +83 -0
package/package.json ADDED
@@ -0,0 +1,140 @@
1
+ {
2
+ "name": "react-native-carrot-quest",
3
+ "version": "0.1.0",
4
+ "description": "Unofficial React Native bindings for the Carrot quest SDK, built with Nitro Modules.",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "react-native-carrot-quest-source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "nitrogen",
22
+ "nitro.json",
23
+ "*.podspec",
24
+ "react-native.config.js",
25
+ "!ios/build",
26
+ "!android/build",
27
+ "!android/gradle",
28
+ "!android/gradlew",
29
+ "!android/gradlew.bat",
30
+ "!android/local.properties",
31
+ "!**/__tests__",
32
+ "!**/__fixtures__",
33
+ "!**/__mocks__",
34
+ "!**/.*"
35
+ ],
36
+ "scripts": {
37
+ "example": "yarn workspace react-native-carrot-quest-example",
38
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
39
+ "prepare": "bob build",
40
+ "nitrogen": "nitrogen",
41
+ "typecheck": "tsc",
42
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
43
+ "test": "jest",
44
+ "test:coverage": "jest --coverage",
45
+ "verify:native": "node scripts/verify-native-api.mjs"
46
+ },
47
+ "keywords": [
48
+ "react-native",
49
+ "ios",
50
+ "android"
51
+ ],
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/Ahmedhamed77/react-native-carrot-quest.git"
55
+ },
56
+ "author": "Ahmed Hamed <ahmedhamed7728@gmail.com> (https://github.com/Ahmedhamed77)",
57
+ "license": "MIT",
58
+ "bugs": {
59
+ "url": "https://github.com/Ahmedhamed77/react-native-carrot-quest/issues"
60
+ },
61
+ "homepage": "https://github.com/Ahmedhamed77/react-native-carrot-quest#readme",
62
+ "publishConfig": {
63
+ "access": "public",
64
+ "registry": "https://registry.npmjs.org/"
65
+ },
66
+ "devDependencies": {
67
+ "@eslint/compat": "^2.1.0",
68
+ "@eslint/eslintrc": "^3.3.5",
69
+ "@eslint/js": "^10.0.1",
70
+ "@react-native/babel-preset": "0.85.0",
71
+ "@react-native/eslint-config": "0.85.0",
72
+ "@types/jest": "^29",
73
+ "@types/node": "^26.1.2",
74
+ "@types/react": "^19.2.0",
75
+ "babel-jest": "^29",
76
+ "del-cli": "^7.0.0",
77
+ "eslint": "^9.39.4",
78
+ "eslint-config-prettier": "^10.1.8",
79
+ "eslint-plugin-ft-flow": "^3.0.11",
80
+ "eslint-plugin-prettier": "^5.5.6",
81
+ "jest": "^29",
82
+ "nitrogen": "^0.35.3",
83
+ "prettier": "^3.8.3",
84
+ "react": "19.2.3",
85
+ "react-native": "0.85.0",
86
+ "react-native-builder-bob": "^0.41.0",
87
+ "react-native-nitro-modules": "^0.35.3",
88
+ "turbo": "^2.9.16",
89
+ "typescript": "^6.0.3"
90
+ },
91
+ "peerDependencies": {
92
+ "react": "*",
93
+ "react-native": "*",
94
+ "react-native-nitro-modules": "^0.35.3"
95
+ },
96
+ "workspaces": [
97
+ "example"
98
+ ],
99
+ "packageManager": "yarn@4.11.0",
100
+ "react-native-builder-bob": {
101
+ "source": "src",
102
+ "output": "lib",
103
+ "targets": [
104
+ [
105
+ "custom",
106
+ {
107
+ "script": "nitrogen",
108
+ "clean": "nitrogen/"
109
+ }
110
+ ],
111
+ [
112
+ "module",
113
+ {
114
+ "esm": true
115
+ }
116
+ ],
117
+ [
118
+ "typescript",
119
+ {
120
+ "project": "tsconfig.build.json"
121
+ }
122
+ ]
123
+ ]
124
+ },
125
+ "prettier": {
126
+ "quoteProps": "consistent",
127
+ "singleQuote": true,
128
+ "tabWidth": 2,
129
+ "trailingComma": "es5",
130
+ "useTabs": false
131
+ },
132
+ "create-react-native-library": {
133
+ "type": "nitro-module",
134
+ "languages": "kotlin-swift",
135
+ "tools": [
136
+ "eslint"
137
+ ],
138
+ "version": "0.63.0"
139
+ }
140
+ }
@@ -0,0 +1,493 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ /**
4
+ * Chat colour theme.
5
+ *
6
+ * `fromDevice` follows the device's light/dark setting (`Theme.fromMobile` on
7
+ * iOS, `ThemeSdk.FROM_DEVICE` on Android). `fromWeb` uses whatever is
8
+ * configured in your Carrot quest web dashboard.
9
+ */
10
+ export type CarrotQuestTheme = 'light' | 'dark' | 'fromDevice' | 'fromWeb';
11
+
12
+ /**
13
+ * Android SDK log level, in increasing verbosity. Android only — the iOS SDK
14
+ * exposes no logging control.
15
+ *
16
+ * `debugging` maps to the SDK's `DEBUG` level. It is spelled out rather than
17
+ * abbreviated because Nitro derives a C++ enum member from each value, and
18
+ * `DEBUG` is a preprocessor macro in React Native's Debug configuration — the
19
+ * generated header would not compile in any app that includes it.
20
+ */
21
+ export type CarrotQuestLogLevel =
22
+ 'none' | 'error' | 'warn' | 'info' | 'debugging' | 'verbose';
23
+
24
+ /**
25
+ * Which subsystem produced a log entry. Mirrors Android's `SdkLogCategory`.
26
+ */
27
+ export type CarrotQuestLogCategory =
28
+ | 'general'
29
+ | 'network'
30
+ | 'connectivity'
31
+ | 'auth'
32
+ | 'realtime'
33
+ | 'lifecycle'
34
+ | 'database'
35
+ | 'push';
36
+
37
+ /**
38
+ * A single log line emitted by the native SDK. Android only.
39
+ */
40
+ export interface CarrotQuestLogEntry {
41
+ /** Milliseconds since the Unix epoch. */
42
+ timestampMs: number;
43
+ level: CarrotQuestLogLevel;
44
+ category: CarrotQuestLogCategory;
45
+ tag: string;
46
+ message: string;
47
+ /** Structured context, stringified. Empty when the entry carries none. */
48
+ fields: Record<string, string>;
49
+ /** Description of an attached throwable, when the entry has one. */
50
+ error?: string;
51
+ }
52
+
53
+ /**
54
+ * How a property value is merged with any existing value.
55
+ *
56
+ * Mirrors `UserProperty.Operations` (iOS) / `Operation` (Android).
57
+ */
58
+ export type CarrotQuestPropertyOperation =
59
+ | 'updateOrCreate'
60
+ | 'setOnce'
61
+ | 'add'
62
+ | 'delete'
63
+ | 'append'
64
+ | 'union'
65
+ | 'exclude';
66
+
67
+ /**
68
+ * Which of the SDK's typed property namespaces a key belongs to.
69
+ *
70
+ * - `custom` — a free-form property (default)
71
+ * - `system` — one of `name`, `phone`, `email`
72
+ * - `ecommerce` — one of the {@link CarrotQuestEcommerceProperty} keys
73
+ */
74
+ export type CarrotQuestPropertyKind = 'custom' | 'system' | 'ecommerce';
75
+
76
+ /**
77
+ * Which links the SDK should hand to your own handler instead of opening
78
+ * itself. Mirrors `CustomUrlOpener.UrlType` on iOS.
79
+ */
80
+ export type CarrotQuestUrlSource = 'push' | 'chat' | 'popup' | 'all';
81
+
82
+ /**
83
+ * A value an event parameter can carry.
84
+ *
85
+ * Android's `EventParams.Builder` accepts strings, booleans, ints, longs and
86
+ * doubles; iOS takes an untyped params dictionary. Values keep their JSON type
87
+ * on the wire rather than being stringified.
88
+ */
89
+ export type CarrotQuestEventValue = string | number | boolean;
90
+
91
+ /**
92
+ * Predefined e-commerce property keys, mapped to the SDK's
93
+ * `EcommerceUserProperty.Property` enum on both platforms.
94
+ */
95
+ export type CarrotQuestEcommerceProperty =
96
+ | 'cartAmount'
97
+ | 'viewedProducts'
98
+ | 'cartItems'
99
+ | 'lastOrderStatus'
100
+ | 'lastPayment'
101
+ | 'revenue'
102
+ | 'profit'
103
+ | 'group'
104
+ | 'discount'
105
+ | 'ordersCount'
106
+ | 'orderedItems'
107
+ | 'orderedCategories'
108
+ | 'viewedCategories';
109
+
110
+ /**
111
+ * A single user property with full control over its namespace and merge
112
+ * operation. Use {@link CarrotQuest.setProperties} to send a batch.
113
+ */
114
+ export interface CarrotQuestProperty {
115
+ /**
116
+ * For `kind: 'system'` one of `name` / `phone` / `email`; for
117
+ * `kind: 'ecommerce'` a {@link CarrotQuestEcommerceProperty}; otherwise any
118
+ * free-form key.
119
+ */
120
+ key: string;
121
+ value: string;
122
+ /** Defaults to `updateOrCreate`. */
123
+ operation?: CarrotQuestPropertyOperation;
124
+ /** Defaults to `custom`. */
125
+ kind?: CarrotQuestPropertyKind;
126
+ }
127
+
128
+ /**
129
+ * The ergonomic subset of user properties.
130
+ *
131
+ * `name`, `phone` and `email` map to the SDK's predefined system properties.
132
+ * Everything in `custom` is sent as a free-form property. Empty strings are
133
+ * dropped rather than written as blank values. For merge operations or
134
+ * e-commerce keys use {@link CarrotQuest.setProperties} instead.
135
+ */
136
+ export interface CarrotQuestUserProperties {
137
+ name?: string;
138
+ phone?: string;
139
+ email?: string;
140
+ custom?: Record<string, string>;
141
+ }
142
+
143
+ /**
144
+ * Options applied when the Carrot quest SDK is initialised.
145
+ */
146
+ export interface CarrotQuestSetupOptions {
147
+ /**
148
+ * Force a locale for the Carrot SDK UI, e.g. `'ru'`.
149
+ *
150
+ * The SDK has no public `setLanguage` API and resolves its language from the
151
+ * system locale, so this is applied by overriding the process locale before
152
+ * `setup` runs. On Android this calls `Locale.setDefault`, which is
153
+ * process-global and affects the whole app.
154
+ *
155
+ * Leave unset to follow the device language.
156
+ */
157
+ locale?: string;
158
+ /** Chat colour theme. Defaults to the SDK's own default when unset. */
159
+ theme?: CarrotQuestTheme;
160
+ /**
161
+ * Route traffic to Carrot's EU servers.
162
+ *
163
+ * On iOS this maps to the documented `useEuServer` setup parameter. On
164
+ * Android it selects the four-argument `setup(context, key, boolean,
165
+ * callback)` overload — the SDK is obfuscated and that flag is *inferred*
166
+ * from the neighbouring `isUseEuApi()` accessor rather than documented, so
167
+ * verify the routing before relying on it. When this option is unset the
168
+ * three-argument overload is used and behaviour is unchanged.
169
+ */
170
+ useEuServer?: boolean;
171
+ /**
172
+ * App Group identifier shared with your Notification Service Extension.
173
+ * Required for rich pushes and duplicate suppression. iOS only.
174
+ */
175
+ appGroup?: string;
176
+ /**
177
+ * Run the SDK in service mode (no UI), for use inside an extension process.
178
+ * iOS only.
179
+ */
180
+ isServiceMode?: boolean;
181
+ /**
182
+ * Fully-qualified activity class name the chat returns to when it closes,
183
+ * e.g. `'com.example.MainActivity'`. Android only.
184
+ */
185
+ parentActivityClassName?: string;
186
+ /**
187
+ * Drawable resource *name* (not id) used for the push notification icon,
188
+ * e.g. `'ic_notification'`. Resolved with `Resources.getIdentifier`.
189
+ * Android only.
190
+ */
191
+ notificationIconResourceName?: string;
192
+ /** SDK log level. Android only. */
193
+ logLevel?: CarrotQuestLogLevel;
194
+ /**
195
+ * Allow sensitive values (tokens, user ids) into SDK logs. Android only.
196
+ * Leave off in production.
197
+ */
198
+ logIncludeSensitive?: boolean;
199
+ }
200
+
201
+ export interface CarrotQuest extends HybridObject<{
202
+ ios: 'swift';
203
+ android: 'kotlin';
204
+ }> {
205
+ // MARK: - Lifecycle
206
+
207
+ /**
208
+ * Whether the SDK finished initialising successfully.
209
+ *
210
+ * This reflects the SDK's own state (`isInit()` on Android), not merely that
211
+ * {@link setup} was called.
212
+ */
213
+ readonly isConfigured: boolean;
214
+
215
+ /**
216
+ * Initialise the SDK with your Carrot quest API key.
217
+ *
218
+ * Call this once from `index.js` or the root app component. Operations called
219
+ * while setup is still in flight wait in the native setup queue, so consuming
220
+ * apps do not need their own readiness promise or repeated setup calls.
221
+ *
222
+ * Resolves only once the SDK reports success. Concurrent matching setup calls
223
+ * share a single initialisation and all resolve together.
224
+ *
225
+ * Rejects if the SDK reports a failure, e.g. an invalid API key or no
226
+ * network.
227
+ */
228
+ setup(apiKey: string, options?: CarrotQuestSetupOptions): Promise<void>;
229
+
230
+ /** The underlying native SDK version. */
231
+ getSdkVersion(): string;
232
+
233
+ // MARK: - Authentication
234
+
235
+ /**
236
+ * Authenticate with the User Auth Key — the **simple, less secure** flow.
237
+ *
238
+ * `userAuthKey` is the single key from your Carrot quest settings, stored in
239
+ * the app itself and identical for every user. It is intended for apps with
240
+ * no backend. Because the key ships inside the binary, anyone who extracts it
241
+ * can authenticate as any user id.
242
+ *
243
+ * If you have a backend, use {@link hashedAuth} instead.
244
+ *
245
+ * Resolves with the Carrot-side user id.
246
+ */
247
+ auth(userId: string, userAuthKey: string): Promise<string | undefined>;
248
+
249
+ /**
250
+ * Authenticate with a backend-generated hash — the **recommended secure**
251
+ * flow.
252
+ *
253
+ * `hash` is generated per user on your server from your Carrot secret key,
254
+ * which never leaves it. Prefer this over {@link auth} whenever you have a
255
+ * backend.
256
+ *
257
+ * Resolves with the Carrot-side user id.
258
+ */
259
+ hashedAuth(userId: string, hash: string): Promise<string | undefined>;
260
+
261
+ /** Sign the current user out and clear their local session. */
262
+ logout(): Promise<void>;
263
+
264
+ // MARK: - Chat UI
265
+
266
+ /**
267
+ * Present the chat UI. Rejects if the UI cannot be presented — on Android
268
+ * when there is no foreground activity, on iOS when there is no key window.
269
+ */
270
+ openChat(): Promise<void>;
271
+
272
+ /**
273
+ * Dismiss the chat UI.
274
+ *
275
+ * iOS only — the Android SDK exposes no programmatic close. Resolves without
276
+ * doing anything on Android.
277
+ */
278
+ closeChat(): Promise<void>;
279
+
280
+ /**
281
+ * Whether the chat UI is currently presented.
282
+ *
283
+ * iOS only; always `false` on Android, which exposes no equivalent.
284
+ */
285
+ readonly isChatOpen: boolean;
286
+
287
+ /**
288
+ * Observe chat visibility.
289
+ *
290
+ * On iOS this maps to `onVisibilityUIChanged` and fires for both open and
291
+ * close. On Android only `setCloseChatCallback` exists, so the listener
292
+ * fires with `false` on close and never with `true`.
293
+ */
294
+ onChatVisibilityChanged(listener: (visible: boolean) => void): void;
295
+
296
+ /** Apply a colour theme to the chat UI. */
297
+ setTheme(theme: CarrotQuestTheme): void;
298
+
299
+ // MARK: - Unread state
300
+
301
+ /**
302
+ * Number of conversations with unread messages.
303
+ *
304
+ * iOS reads `getUnreadConversationsCount`; Android counts
305
+ * `getUnreadConversations()`.
306
+ */
307
+ getUnreadConversationsCount(): Promise<number>;
308
+
309
+ /**
310
+ * Number of unread messages.
311
+ *
312
+ * iOS only — Android exposes conversations but not a message count.
313
+ * Resolves with `undefined` on Android.
314
+ */
315
+ getUnreadMessagesCount(): Promise<number | undefined>;
316
+
317
+ /**
318
+ * Observe the unread conversation count.
319
+ *
320
+ * Android only, via `setUnreadConversationsCallback`. Never fires on iOS —
321
+ * poll {@link getUnreadConversationsCount} there instead.
322
+ */
323
+ onUnreadConversationsChanged(listener: (count: number) => void): void;
324
+
325
+ // MARK: - User properties
326
+
327
+ /** Attach the common user properties. Fire-and-forget. */
328
+ setUserProperties(properties: CarrotQuestUserProperties): void;
329
+
330
+ /**
331
+ * Attach properties with explicit merge operations and namespaces.
332
+ * Fire-and-forget.
333
+ */
334
+ setProperties(properties: CarrotQuestProperty[]): void;
335
+
336
+ // MARK: - Tracking
337
+
338
+ /**
339
+ * Track a named event.
340
+ *
341
+ * Values keep their JSON type: Android dispatches to the matching
342
+ * `EventParams.Builder.put` overload and iOS passes them through the params
343
+ * dictionary. Non-integral numbers go through as doubles.
344
+ * Fire-and-forget.
345
+ */
346
+ trackEvent(
347
+ name: string,
348
+ params?: Record<string, CarrotQuestEventValue>
349
+ ): void;
350
+
351
+ /** Track a screen view. Fire-and-forget. */
352
+ trackScreen(name: string): void;
353
+
354
+ /**
355
+ * Record UTM attribution from a campaign URL. Fire-and-forget.
356
+ */
357
+ trackUtm(url: string): void;
358
+
359
+ // MARK: - Push notifications
360
+
361
+ /**
362
+ * Register the device push token.
363
+ *
364
+ * Pass the APNs token as a hex string on iOS, or the FCM token on Android.
365
+ */
366
+ setPushToken(token: string): void;
367
+
368
+ /**
369
+ * Clear the registered push token.
370
+ *
371
+ * iOS only — the Android SDK exposes no token deletion. No-op on Android.
372
+ */
373
+ deletePushToken(): void;
374
+
375
+ /** Unsubscribe the current user from push notifications. */
376
+ pushNotificationsUnsubscribe(): Promise<void>;
377
+
378
+ /** Unsubscribe the current user from push campaigns. */
379
+ pushCampaignsUnsubscribe(): Promise<void>;
380
+
381
+ /**
382
+ * Whether a notification payload originated from Carrot quest.
383
+ *
384
+ * `payloadJson` is the JSON-encoded remote message payload — `userInfo` on
385
+ * iOS, the FCM data map on Android.
386
+ */
387
+ isCarrotPush(payloadJson: string): boolean;
388
+
389
+ /**
390
+ * Whether a Carrot payload is an automated message rather than a reply.
391
+ *
392
+ * **Android is SDK-backed; iOS is best effort.** Android calls
393
+ * `Carrot.isAutoMessage`. The iOS SDK exposes no equivalent, so this reads a
394
+ * `type` discriminator out of the payload — a shape inferred from Carrot's
395
+ * messages, not a documented contract. Verify against your own payloads
396
+ * before branching on it, and treat `false` as "unknown" on iOS.
397
+ */
398
+ isAutoMessage(payloadJson: string): boolean;
399
+
400
+ /**
401
+ * Hand a Carrot push payload to the SDK so it can present the notification.
402
+ */
403
+ handlePushNotification(payloadJson: string): void;
404
+
405
+ /**
406
+ * Report that the user tapped a Carrot notification.
407
+ *
408
+ * iOS only — on Android tapping is routed through the notification's own
409
+ * pending intent. No-op on Android.
410
+ *
411
+ * @param openLink whether the SDK should follow the notification's link
412
+ * itself, or leave it to your {@link onUrlOpen} handler.
413
+ */
414
+ handlePushClick(payloadJson: string, openLink: boolean): void;
415
+
416
+ /**
417
+ * Extract the deep link from a Carrot push payload.
418
+ *
419
+ * **Best effort, iOS only.** The SDK's own accessor is
420
+ * `getLink(from: UNNotificationResponse)`, and a `UNNotificationResponse`
421
+ * cannot cross into JS — so this scans the payload for the link keys Carrot
422
+ * is observed to use. Android SDK 3.1.0 removed its push-link accessor
423
+ * entirely and always returns `undefined`.
424
+ *
425
+ * For a guaranteed link, call
426
+ * `CarrotNotificationService.shared.getLink(from:)` from your own
427
+ * `UNUserNotificationCenterDelegate` in native code, or let the SDK follow
428
+ * the link itself via {@link handlePushClick} with `openLink: true`.
429
+ */
430
+ getPushLink(payloadJson: string): string | undefined;
431
+
432
+ /**
433
+ * Whether this notification was already shown, using the App Group store.
434
+ *
435
+ * iOS only; always `false` on Android. Requires
436
+ * {@link CarrotQuestSetupOptions.appGroup}.
437
+ */
438
+ wasPushShownEarlier(payloadJson: string): Promise<boolean>;
439
+
440
+ // MARK: - Deep links
441
+
442
+ /**
443
+ * Intercept links the SDK would otherwise open itself.
444
+ *
445
+ * iOS only — the Android SDK routes links through
446
+ * {@link CarrotQuestSetupOptions.parentActivityClassName} and exposes no
447
+ * equivalent hook. Never fires on Android.
448
+ *
449
+ * @param source which links to intercept: `push`, `chat`, `popup` or `all`.
450
+ */
451
+ onUrlOpen(
452
+ source: CarrotQuestUrlSource,
453
+ listener: (url: string) => void
454
+ ): void;
455
+
456
+ /** Ask the SDK to open a URL in the in-app browser. iOS only. */
457
+ openBrowserLink(url: string): void;
458
+
459
+ /** Ask the SDK to open a URL as a universal link. iOS only. */
460
+ openUniversalLink(url: string): void;
461
+
462
+ // MARK: - Diagnostics
463
+
464
+ /**
465
+ * A formatted dump of the SDK's internal state and recent logs.
466
+ *
467
+ * Android only, via `getDiagnostics()`. Returns `undefined` on iOS.
468
+ */
469
+ getDiagnostics(): string | undefined;
470
+
471
+ /**
472
+ * Receive the SDK's log entries, e.g. to forward them to a crash reporter.
473
+ *
474
+ * Android only, via `setLogSink`. Never fires on iOS, whose SDK exposes no
475
+ * logging hook.
476
+ *
477
+ * Entries are filtered by {@link CarrotQuestSetupOptions.logLevel}, so leave
478
+ * that at `info` or lower in production — `verbose` crosses the bridge for
479
+ * every network call. Values are redacted unless
480
+ * {@link CarrotQuestSetupOptions.logIncludeSensitive} is on.
481
+ */
482
+ onLog(listener: (entry: CarrotQuestLogEntry) => void): void;
483
+
484
+ /**
485
+ * Detach the log listener installed by {@link onLog}.
486
+ *
487
+ * Called by the package's subscription registry when the last `onLog`
488
+ * subscriber is removed — without it the SDK would keep pushing every log
489
+ * line across the bridge to nobody. You should not need to call it directly;
490
+ * use the subscription returned by the package's `onLog` instead.
491
+ */
492
+ offLog(): void;
493
+ }