@sagepilot-ai/react-native-camera-addon 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +75 -0
- package/android/build.gradle +45 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraActivity.java +1549 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraDebugEvents.java +63 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraImageProcessor.java +278 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraModule.java +1012 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraOverlay.java +1419 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotInAppCameraResultStore.java +135 -0
- package/android/src/main/java/ai/sagepilot/reactnativecameraaddon/SagepilotReactNativeCameraAddonPackage.java +22 -0
- package/android/src/main/res/drawable/sagepilot_ic_check.xml +12 -0
- package/android/src/main/res/drawable/sagepilot_ic_rotate_ccw.xml +18 -0
- package/android/src/main/res/drawable/sagepilot_ic_switch_camera.xml +36 -0
- package/android/src/main/res/drawable/sagepilot_ic_x.xml +18 -0
- package/android/src/main/res/values/styles.xml +7 -0
- package/dist/index.d.mts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +339 -0
- package/dist/index.mjs +320 -0
- package/package.json +48 -0
- package/react-native.config.js +12 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sagepilot AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# `@sagepilot-ai/react-native-camera-addon`
|
|
2
|
+
|
|
3
|
+
Optional Android CameraX attachment picker for `@sagepilot-ai/react-native-sdk`.
|
|
4
|
+
|
|
5
|
+
Install this package only when you want Sagepilot to provide an in-app Android CameraX picker. Apps that do not install it can keep the smaller base SDK install.
|
|
6
|
+
|
|
7
|
+
This is not a replacement SDK. Your app always installs and configures `@sagepilot-ai/react-native-sdk` first, then adds this package only when it wants the optional CameraX picker.
|
|
8
|
+
|
|
9
|
+
## Install Flow
|
|
10
|
+
|
|
11
|
+
Install the base SDK and WebView:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @sagepilot-ai/react-native-sdk react-native-webview
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then install the CameraX addon:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @sagepilot-ai/react-native-camera-addon
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If your app already has the base SDK installed, run only the addon install command.
|
|
24
|
+
|
|
25
|
+
After adding this package, run a clean native Android rebuild. A Metro reload is not enough because React Native autolinking registers the new native module only during the native build:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd android && ./gradlew clean
|
|
29
|
+
cd .. && npx react-native run-android
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Expo apps should run a fresh native build, for example:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx expo run:android
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
On device, verify the adapter log includes the native sources:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
[SagepilotSDK][CameraXAddon] adapter created ... sources:["camera","library","documents"]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If the app was only Metro-reloaded after installing the addon, `NativeModules.SagepilotInAppCamera` is not registered yet. In that state `createSagepilotCameraXFilePicker()` returns `undefined`, the base SDK receives no `filePicker`, and the widget falls back to the WebView file input.
|
|
45
|
+
|
|
46
|
+
## Configure
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { SagepilotChat } from "@sagepilot-ai/react-native-sdk";
|
|
50
|
+
import { createSagepilotCameraXFilePicker } from "@sagepilot-ai/react-native-camera-addon";
|
|
51
|
+
|
|
52
|
+
await SagepilotChat.configure({
|
|
53
|
+
key: "workspace_id:channel_id",
|
|
54
|
+
filePicker: createSagepilotCameraXFilePicker()
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Mount `SagepilotChatProvider` from the base SDK once near the top of your app. The addon only supplies the `filePicker` adapter used by `SagepilotChat.configure`.
|
|
59
|
+
|
|
60
|
+
`createSagepilotCameraXFilePicker()` returns `undefined` outside Android, so cross-platform apps can call it from shared configuration code. On Android it exposes the CameraX camera source plus the addon native module's photo-library and document sources when they are linked in the host app.
|
|
61
|
+
|
|
62
|
+
iOS does not use this Android addon. If you pass `createSagepilotCameraXFilePicker()` from shared setup code on iOS, it returns `undefined` and the hosted widget uses WKWebView's native file input sheet unless your app provides a separate iOS picker through the base SDK.
|
|
63
|
+
|
|
64
|
+
## Options
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
createSagepilotCameraXFilePicker({
|
|
68
|
+
imageMaxDimension: 1920,
|
|
69
|
+
imageQuality: 0.8,
|
|
70
|
+
imageMaxFileSizeBytes: 15 * 1024 * 1024,
|
|
71
|
+
documentMaxFileSizeBytes: 20 * 1024 * 1024,
|
|
72
|
+
includeLibrary: true,
|
|
73
|
+
includeDocuments: true
|
|
74
|
+
});
|
|
75
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath "com.android.tools.build:gradle:8.5.0"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
apply plugin: "com.android.library"
|
|
12
|
+
|
|
13
|
+
def safeExtGet(prop, fallback) {
|
|
14
|
+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def cameraXVersion = safeExtGet("sagepilotCameraXVersion", "1.5.3")
|
|
18
|
+
def exifInterfaceVersion = safeExtGet("sagepilotExifInterfaceVersion", "1.4.2")
|
|
19
|
+
def activityVersion = safeExtGet("sagepilotActivityVersion", "1.10.1")
|
|
20
|
+
|
|
21
|
+
android {
|
|
22
|
+
namespace "ai.sagepilot.reactnativecameraaddon"
|
|
23
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 35)
|
|
24
|
+
|
|
25
|
+
defaultConfig {
|
|
26
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
27
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 35)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
compileOptions {
|
|
31
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
32
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
dependencies {
|
|
37
|
+
implementation "com.facebook.react:react-android"
|
|
38
|
+
implementation "androidx.core:core:1.13.1"
|
|
39
|
+
implementation "androidx.activity:activity:${activityVersion}"
|
|
40
|
+
implementation "androidx.camera:camera-core:${cameraXVersion}"
|
|
41
|
+
implementation "androidx.camera:camera-camera2:${cameraXVersion}"
|
|
42
|
+
implementation "androidx.camera:camera-lifecycle:${cameraXVersion}"
|
|
43
|
+
implementation "androidx.camera:camera-view:${cameraXVersion}"
|
|
44
|
+
implementation "androidx.exifinterface:exifinterface:${exifInterfaceVersion}"
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
|
|
3
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
4
|
+
|
|
5
|
+
<application>
|
|
6
|
+
<activity
|
|
7
|
+
android:name="ai.sagepilot.reactnativecameraaddon.SagepilotInAppCameraActivity"
|
|
8
|
+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode"
|
|
9
|
+
android:exported="false"
|
|
10
|
+
android:theme="@style/SagepilotInAppCameraTheme" />
|
|
11
|
+
</application>
|
|
12
|
+
</manifest>
|