@sagepilot-ai/react-native-sdk 0.3.2 → 0.3.3

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.
@@ -8,13 +8,11 @@ import java.util.Collections;
8
8
  import java.util.List;
9
9
 
10
10
  public class SagepilotReactNativeSdkPackage implements ReactPackage {
11
- /** Registers SDK-owned native modules exposed to JavaScript. */
12
11
  @Override
13
12
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
14
13
  return Collections.emptyList();
15
14
  }
16
15
 
17
- /** Registers the existing SDK view managers without changing their surface. */
18
16
  @Override
19
17
  public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
20
18
  return Collections.singletonList(new SagepilotInsetsViewManager());
package/dist/index.js CHANGED
@@ -67,7 +67,7 @@ var SagepilotChatError = class extends Error {
67
67
 
68
68
  // src/core/config/constants.ts
69
69
  var SDK_NAME = "@sagepilot-ai/react-native-sdk";
70
- var SDK_VERSION = "0.3.2";
70
+ var SDK_VERSION = "0.3.3";
71
71
  var DEFAULT_HOST = "https://app.sagepilot.ai";
72
72
  var DEFAULT_WIDGET_HOST = "https://app.sagepilot.ai";
73
73
  var CUSTOMER_API_PREFIX = "/customer-api/v1";
@@ -1670,7 +1670,6 @@ function createSagepilotFilePicker(options) {
1670
1670
 
1671
1671
  // src/ui/SagepilotChatProvider.ts
1672
1672
  var import_react = require("react");
1673
- var import_lucide_react_native = require("lucide-react-native");
1674
1673
  var import_react_native3 = require("react-native");
1675
1674
  var import_react_native_webview = require("react-native-webview");
1676
1675
 
@@ -1849,8 +1848,10 @@ function readPresentationState() {
1849
1848
  };
1850
1849
  }
1851
1850
  function getBridgeCapabilities() {
1851
+ const filePicker = internalSagepilotChat.getConfig()?.filePicker;
1852
1852
  return {
1853
- nativeFilePicker: Boolean(internalSagepilotChat.getConfig()?.filePicker)
1853
+ nativeFilePicker: Boolean(filePicker),
1854
+ nativeFilePickerSources: filePicker?.sources ?? []
1854
1855
  };
1855
1856
  }
1856
1857
  function getInjectedWebViewScript() {
@@ -1866,21 +1867,13 @@ var FILE_PICKER_SOURCE_LABELS = {
1866
1867
  library: "Choose from gallery",
1867
1868
  documents: "Browse files"
1868
1869
  };
1869
- var FILE_PICKER_SOURCE_DESCRIPTIONS = {
1870
- camera: "Use the in-app camera",
1871
- library: "Photos and videos on this device",
1872
- documents: "PDFs, documents, and Drive files"
1873
- };
1874
- var FILE_PICKER_SOURCE_ICONS = {
1875
- camera: import_lucide_react_native.Camera,
1876
- library: import_lucide_react_native.Images,
1877
- documents: import_lucide_react_native.FileText
1878
- };
1879
- var FILE_PICKER_SOURCE_ICON_COLORS = {
1880
- camera: "#0284c7",
1881
- library: "#16a34a",
1882
- documents: "#7c3aed"
1883
- };
1870
+ var RN_FILE_PICKER_LOG_PREFIX = "[SagepilotRNFilePicker]";
1871
+ function logNativeFilePicker(event, details) {
1872
+ console.info(`${RN_FILE_PICKER_LOG_PREFIX} ${event}`, details ?? {});
1873
+ }
1874
+ function warnNativeFilePicker(event, details) {
1875
+ console.warn(`${RN_FILE_PICKER_LOG_PREFIX} ${event}`, details ?? {});
1876
+ }
1884
1877
  var DELIVERY_RETRY_MS = 1500;
1885
1878
  var DELIVERY_LEGACY_FALLBACK_ATTEMPTS = 2;
1886
1879
  var DELIVERY_MAX_ATTEMPTS = 8;
@@ -1904,29 +1897,6 @@ function totalBase64Bytes(files) {
1904
1897
  function storageKeyFor(batchId, index) {
1905
1898
  return `${batchId}_${index}.bin`;
1906
1899
  }
1907
- function renderFilePickerSourceIcon(source) {
1908
- const Icon = FILE_PICKER_SOURCE_ICONS[source];
1909
- return (0, import_react.createElement)(
1910
- import_react_native3.View,
1911
- { style: getFilePickerSourceIconStyle(source) },
1912
- (0, import_react.createElement)(Icon, {
1913
- color: FILE_PICKER_SOURCE_ICON_COLORS[source],
1914
- size: 23,
1915
- strokeWidth: 2.35
1916
- })
1917
- );
1918
- }
1919
- function getFilePickerSourceIconStyle(source) {
1920
- if (source === "camera") return [styles.sheetOptionIcon, styles.cameraOptionIcon];
1921
- if (source === "library") return [styles.sheetOptionIcon, styles.libraryOptionIcon];
1922
- return [styles.sheetOptionIcon, styles.documentsOptionIcon];
1923
- }
1924
- function getSheetOptionStyle(pressed) {
1925
- return [styles.sheetOption, pressed && styles.sheetOptionPressed];
1926
- }
1927
- function getSheetCancelStyle(pressed) {
1928
- return [styles.sheetCancelButton, pressed && styles.sheetCancelButtonPressed];
1929
- }
1930
1900
  function buildDispatchScript(messageLiteral) {
1931
1901
  return [
1932
1902
  "(function(){",
@@ -2177,35 +2147,70 @@ function SagepilotChatProvider({
2177
2147
  }, []);
2178
2148
  const runNativeFilePicker = (0, import_react.useCallback)((source, multiple) => {
2179
2149
  const filePicker = internalSagepilotChat.getConfig()?.filePicker;
2150
+ logNativeFilePicker("run_requested", {
2151
+ source,
2152
+ multiple,
2153
+ availableSources: filePicker?.sources ?? []
2154
+ });
2180
2155
  if (!filePicker) {
2156
+ warnNativeFilePicker("run_without_file_picker", { source });
2181
2157
  return;
2182
2158
  }
2183
2159
  if (pickerInFlightRef.current) {
2160
+ warnNativeFilePicker("run_ignored_picker_in_flight", { source });
2184
2161
  return;
2185
2162
  }
2186
- pauseLivenessAfterPicker(6e4);
2187
2163
  pickerInFlightRef.current = true;
2188
- filePicker.pickFiles({ source, multiple }).then((files) => {
2189
- if (files.length === 0) {
2190
- nativeWebViewRef.current?.injectJavaScript(buildFilePickerCancelledScript());
2191
- return;
2164
+ pauseLivenessAfterPicker(6e4);
2165
+ void (async () => {
2166
+ try {
2167
+ const files = await filePicker.pickFiles({ source, multiple });
2168
+ logNativeFilePicker("native_pick_resolved", { source, fileCount: files.length });
2169
+ if (files.length === 0) {
2170
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerCancelledScript());
2171
+ return;
2172
+ }
2173
+ queuePickedFiles(files);
2174
+ } catch (error) {
2175
+ const { message, code } = readFilePickerError(error);
2176
+ warnNativeFilePicker("native_pick_failed", { source, code, message });
2177
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(message, code));
2178
+ } finally {
2179
+ pickerInFlightRef.current = false;
2180
+ pauseLivenessAfterPicker(LIVENESS_PICKER_GRACE_MS);
2192
2181
  }
2193
- queuePickedFiles(files);
2194
- }).catch((error) => {
2195
- const { message, code } = readFilePickerError(error);
2196
- nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(message, code));
2197
- }).finally(() => {
2198
- pickerInFlightRef.current = false;
2199
- pauseLivenessAfterPicker(LIVENESS_PICKER_GRACE_MS);
2200
- });
2182
+ })();
2201
2183
  }, [pauseLivenessAfterPicker, queuePickedFiles]);
2202
- const openNativeFilePicker = (0, import_react.useCallback)((multiple) => {
2184
+ const openNativeFilePicker = (0, import_react.useCallback)((multiple, source) => {
2203
2185
  const filePicker = internalSagepilotChat.getConfig()?.filePicker;
2186
+ logNativeFilePicker("open_requested", {
2187
+ source: source ?? "source_chooser",
2188
+ multiple,
2189
+ hasFilePicker: Boolean(filePicker),
2190
+ availableSources: filePicker?.sources ?? []
2191
+ });
2204
2192
  if (!filePicker || filePicker.sources.length === 0) {
2193
+ warnNativeFilePicker("open_unavailable", { source: source ?? "source_chooser" });
2194
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(
2195
+ source === "camera" ? "CameraX is not available in this Expo runtime. Use a dev build with the CameraX addon linked." : "Native attachment picker is not available in this build.",
2196
+ "camera_unavailable"
2197
+ ));
2198
+ return;
2199
+ }
2200
+ if (source) {
2201
+ if (filePicker.sources.includes(source)) {
2202
+ runNativeFilePicker(source, multiple);
2203
+ } else {
2204
+ warnNativeFilePicker("source_not_available", { source, availableSources: filePicker.sources });
2205
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(
2206
+ source === "camera" ? "CameraX is not available in this build." : `Native ${source} picker is not available in this build.`,
2207
+ "camera_unavailable"
2208
+ ));
2209
+ }
2205
2210
  return;
2206
2211
  }
2207
2212
  const [onlySource] = filePicker.sources;
2208
- if (filePicker.sources.length === 1 && onlySource && onlySource !== "camera") {
2213
+ if (filePicker.sources.length === 1 && onlySource) {
2209
2214
  runNativeFilePicker(onlySource, multiple);
2210
2215
  return;
2211
2216
  }
@@ -2385,7 +2390,11 @@ function SagepilotChatProvider({
2385
2390
  const handleWebViewMessage = (event) => {
2386
2391
  const message = parseHostedBridgeMessage(event.nativeEvent?.data);
2387
2392
  if (message?.type === "sagepilot:open_file_picker") {
2388
- openNativeFilePicker(message.multiple ?? true);
2393
+ logNativeFilePicker("bridge_message_open_file_picker", {
2394
+ source: message.source ?? "source_chooser",
2395
+ multiple: message.multiple ?? true
2396
+ });
2397
+ openNativeFilePicker(message.multiple ?? true, message.source);
2389
2398
  return;
2390
2399
  }
2391
2400
  if (message?.type === "sagepilot:widget_listener_ready") {
@@ -2603,7 +2612,6 @@ function SagepilotChatProvider({
2603
2612
  (0, import_react.createElement)(
2604
2613
  import_react_native3.View,
2605
2614
  { style: styles.sheetCard },
2606
- (0, import_react.createElement)(import_react_native3.View, { style: styles.sheetHandle }),
2607
2615
  (0, import_react.createElement)(import_react_native3.Text, { style: styles.sheetTitle }, "Add attachment"),
2608
2616
  ...(internalSagepilotChat.getConfig()?.filePicker?.sources ?? []).map(
2609
2617
  (source) => (0, import_react.createElement)(
@@ -2611,29 +2619,19 @@ function SagepilotChatProvider({
2611
2619
  {
2612
2620
  key: source,
2613
2621
  accessibilityRole: "button",
2614
- android_ripple: { color: "rgba(15, 23, 42, 0.06)" },
2615
- hitSlop: 4,
2616
- style: ({ pressed }) => getSheetOptionStyle(pressed),
2622
+ style: styles.sheetButton,
2617
2623
  onPress: () => handleSourceChoice(source)
2618
2624
  },
2619
- renderFilePickerSourceIcon(source),
2620
- (0, import_react.createElement)(
2621
- import_react_native3.View,
2622
- { style: styles.sheetOptionText },
2623
- (0, import_react.createElement)(import_react_native3.Text, { style: styles.sheetButtonText }, FILE_PICKER_SOURCE_LABELS[source]),
2624
- (0, import_react.createElement)(import_react_native3.Text, { style: styles.sheetButtonDescription }, FILE_PICKER_SOURCE_DESCRIPTIONS[source])
2625
- )
2625
+ (0, import_react.createElement)(import_react_native3.Text, { style: styles.sheetButtonText }, FILE_PICKER_SOURCE_LABELS[source])
2626
2626
  )
2627
2627
  ),
2628
2628
  (0, import_react.createElement)(
2629
2629
  import_react_native3.Pressable,
2630
2630
  {
2631
2631
  accessibilityRole: "button",
2632
- android_ripple: { color: "rgba(15, 23, 42, 0.06)" },
2633
- style: ({ pressed }) => getSheetCancelStyle(pressed),
2632
+ style: [styles.sheetButton, styles.sheetCancelButton],
2634
2633
  onPress: () => setSourceChooser(null)
2635
2634
  },
2636
- (0, import_react.createElement)(import_lucide_react_native.X, { color: "#334155", size: 18, strokeWidth: 2.5, style: styles.sheetCancelIcon }),
2637
2635
  (0, import_react.createElement)(import_react_native3.Text, { style: styles.sheetCancelText }, "Cancel")
2638
2636
  )
2639
2637
  )
@@ -2739,109 +2737,43 @@ var styles = import_react_native3.StyleSheet.create({
2739
2737
  },
2740
2738
  sheetBackdrop: {
2741
2739
  flex: 1,
2742
- alignItems: "center",
2743
2740
  justifyContent: "flex-end",
2744
- backgroundColor: "rgba(15, 23, 42, 0.48)"
2741
+ backgroundColor: "rgba(17, 24, 39, 0.36)"
2745
2742
  },
2746
2743
  sheetCard: {
2747
- width: "100%",
2748
- maxWidth: 540,
2749
2744
  backgroundColor: "#ffffff",
2750
- borderTopLeftRadius: 26,
2751
- borderTopRightRadius: 26,
2752
- paddingTop: 10,
2753
- paddingBottom: 18,
2754
- paddingHorizontal: 14,
2755
- shadowColor: "#0f172a",
2756
- shadowOpacity: 0.22,
2757
- shadowRadius: 28,
2758
- shadowOffset: { width: 0, height: -10 },
2759
- elevation: 18
2760
- },
2761
- sheetHandle: {
2762
- alignSelf: "center",
2763
- width: 42,
2764
- height: 5,
2765
- borderRadius: 999,
2766
- backgroundColor: "#d1d5db",
2767
- marginBottom: 14
2745
+ borderTopLeftRadius: 16,
2746
+ borderTopRightRadius: 16,
2747
+ paddingTop: 8,
2748
+ paddingBottom: 24,
2749
+ paddingHorizontal: 8
2768
2750
  },
2769
2751
  sheetTitle: {
2770
- color: "#111827",
2771
- fontSize: 17,
2772
- fontWeight: "700",
2773
- paddingBottom: 12,
2774
- paddingHorizontal: 4
2775
- },
2776
- sheetOption: {
2777
- minHeight: 70,
2778
- flexDirection: "row",
2779
- alignItems: "center",
2780
- borderRadius: 18,
2781
- paddingHorizontal: 12,
2782
- marginBottom: 6,
2783
- backgroundColor: "#ffffff"
2784
- },
2785
- sheetOptionPressed: {
2786
- backgroundColor: "#f8fafc",
2787
- transform: [{ scale: 0.985 }]
2752
+ textAlign: "center",
2753
+ color: "#6b7280",
2754
+ fontSize: 13,
2755
+ fontWeight: "600",
2756
+ paddingVertical: 10
2788
2757
  },
2789
- sheetOptionIcon: {
2790
- width: 46,
2791
- height: 46,
2792
- borderRadius: 16,
2793
- marginRight: 14,
2758
+ sheetButton: {
2759
+ minHeight: 52,
2794
2760
  alignItems: "center",
2795
2761
  justifyContent: "center",
2796
- position: "relative",
2797
- overflow: "hidden"
2798
- },
2799
- sheetOptionText: {
2800
- flex: 1,
2801
- justifyContent: "center"
2762
+ borderRadius: 12
2802
2763
  },
2803
2764
  sheetButtonText: {
2804
- color: "#0f172a",
2765
+ color: "#111827",
2805
2766
  fontSize: 16,
2806
- fontWeight: "700"
2807
- },
2808
- sheetButtonDescription: {
2809
- color: "#64748b",
2810
- fontSize: 13,
2811
- fontWeight: "500",
2812
- marginTop: 3
2813
- },
2814
- cameraOptionIcon: {
2815
- backgroundColor: "#e0f2fe"
2816
- },
2817
- libraryOptionIcon: {
2818
- backgroundColor: "#ecfdf5"
2819
- },
2820
- documentsOptionIcon: {
2821
- backgroundColor: "#f5f3ff"
2767
+ fontWeight: "500"
2822
2768
  },
2823
2769
  sheetCancelButton: {
2824
- minHeight: 56,
2825
- flexDirection: "row",
2826
- alignItems: "center",
2827
- justifyContent: "center",
2828
- borderRadius: 18,
2829
- marginTop: 8,
2830
- backgroundColor: "#f1f5f9"
2831
- },
2832
- sheetCancelButtonPressed: {
2833
- backgroundColor: "#e2e8f0",
2834
- transform: [{ scale: 0.985 }]
2835
- },
2836
- sheetCancelIcon: {
2837
- width: 18,
2838
- height: 18,
2839
- marginRight: 8
2770
+ marginTop: 6,
2771
+ backgroundColor: "#f3f4f6"
2840
2772
  },
2841
2773
  sheetCancelText: {
2842
- color: "#0f172a",
2774
+ color: "#111827",
2843
2775
  fontSize: 16,
2844
- fontWeight: "700"
2776
+ fontWeight: "600"
2845
2777
  }
2846
2778
  });
2847
2779
 
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ var SagepilotChatError = class extends Error {
18
18
 
19
19
  // src/core/config/constants.ts
20
20
  var SDK_NAME = "@sagepilot-ai/react-native-sdk";
21
- var SDK_VERSION = "0.3.2";
21
+ var SDK_VERSION = "0.3.3";
22
22
  var DEFAULT_HOST = "https://app.sagepilot.ai";
23
23
  var DEFAULT_WIDGET_HOST = "https://app.sagepilot.ai";
24
24
  var CUSTOMER_API_PREFIX = "/customer-api/v1";
@@ -1621,7 +1621,6 @@ function createSagepilotFilePicker(options) {
1621
1621
 
1622
1622
  // src/ui/SagepilotChatProvider.ts
1623
1623
  import { createElement, useCallback, useEffect, useRef, useState } from "react";
1624
- import { Camera, FileText, Images, X } from "lucide-react-native";
1625
1624
  import {
1626
1625
  ActivityIndicator,
1627
1626
  AppState,
@@ -1812,8 +1811,10 @@ function readPresentationState() {
1812
1811
  };
1813
1812
  }
1814
1813
  function getBridgeCapabilities() {
1814
+ const filePicker = internalSagepilotChat.getConfig()?.filePicker;
1815
1815
  return {
1816
- nativeFilePicker: Boolean(internalSagepilotChat.getConfig()?.filePicker)
1816
+ nativeFilePicker: Boolean(filePicker),
1817
+ nativeFilePickerSources: filePicker?.sources ?? []
1817
1818
  };
1818
1819
  }
1819
1820
  function getInjectedWebViewScript() {
@@ -1829,21 +1830,13 @@ var FILE_PICKER_SOURCE_LABELS = {
1829
1830
  library: "Choose from gallery",
1830
1831
  documents: "Browse files"
1831
1832
  };
1832
- var FILE_PICKER_SOURCE_DESCRIPTIONS = {
1833
- camera: "Use the in-app camera",
1834
- library: "Photos and videos on this device",
1835
- documents: "PDFs, documents, and Drive files"
1836
- };
1837
- var FILE_PICKER_SOURCE_ICONS = {
1838
- camera: Camera,
1839
- library: Images,
1840
- documents: FileText
1841
- };
1842
- var FILE_PICKER_SOURCE_ICON_COLORS = {
1843
- camera: "#0284c7",
1844
- library: "#16a34a",
1845
- documents: "#7c3aed"
1846
- };
1833
+ var RN_FILE_PICKER_LOG_PREFIX = "[SagepilotRNFilePicker]";
1834
+ function logNativeFilePicker(event, details) {
1835
+ console.info(`${RN_FILE_PICKER_LOG_PREFIX} ${event}`, details ?? {});
1836
+ }
1837
+ function warnNativeFilePicker(event, details) {
1838
+ console.warn(`${RN_FILE_PICKER_LOG_PREFIX} ${event}`, details ?? {});
1839
+ }
1847
1840
  var DELIVERY_RETRY_MS = 1500;
1848
1841
  var DELIVERY_LEGACY_FALLBACK_ATTEMPTS = 2;
1849
1842
  var DELIVERY_MAX_ATTEMPTS = 8;
@@ -1867,29 +1860,6 @@ function totalBase64Bytes(files) {
1867
1860
  function storageKeyFor(batchId, index) {
1868
1861
  return `${batchId}_${index}.bin`;
1869
1862
  }
1870
- function renderFilePickerSourceIcon(source) {
1871
- const Icon = FILE_PICKER_SOURCE_ICONS[source];
1872
- return createElement(
1873
- View,
1874
- { style: getFilePickerSourceIconStyle(source) },
1875
- createElement(Icon, {
1876
- color: FILE_PICKER_SOURCE_ICON_COLORS[source],
1877
- size: 23,
1878
- strokeWidth: 2.35
1879
- })
1880
- );
1881
- }
1882
- function getFilePickerSourceIconStyle(source) {
1883
- if (source === "camera") return [styles.sheetOptionIcon, styles.cameraOptionIcon];
1884
- if (source === "library") return [styles.sheetOptionIcon, styles.libraryOptionIcon];
1885
- return [styles.sheetOptionIcon, styles.documentsOptionIcon];
1886
- }
1887
- function getSheetOptionStyle(pressed) {
1888
- return [styles.sheetOption, pressed && styles.sheetOptionPressed];
1889
- }
1890
- function getSheetCancelStyle(pressed) {
1891
- return [styles.sheetCancelButton, pressed && styles.sheetCancelButtonPressed];
1892
- }
1893
1863
  function buildDispatchScript(messageLiteral) {
1894
1864
  return [
1895
1865
  "(function(){",
@@ -2140,35 +2110,70 @@ function SagepilotChatProvider({
2140
2110
  }, []);
2141
2111
  const runNativeFilePicker = useCallback((source, multiple) => {
2142
2112
  const filePicker = internalSagepilotChat.getConfig()?.filePicker;
2113
+ logNativeFilePicker("run_requested", {
2114
+ source,
2115
+ multiple,
2116
+ availableSources: filePicker?.sources ?? []
2117
+ });
2143
2118
  if (!filePicker) {
2119
+ warnNativeFilePicker("run_without_file_picker", { source });
2144
2120
  return;
2145
2121
  }
2146
2122
  if (pickerInFlightRef.current) {
2123
+ warnNativeFilePicker("run_ignored_picker_in_flight", { source });
2147
2124
  return;
2148
2125
  }
2149
- pauseLivenessAfterPicker(6e4);
2150
2126
  pickerInFlightRef.current = true;
2151
- filePicker.pickFiles({ source, multiple }).then((files) => {
2152
- if (files.length === 0) {
2153
- nativeWebViewRef.current?.injectJavaScript(buildFilePickerCancelledScript());
2154
- return;
2127
+ pauseLivenessAfterPicker(6e4);
2128
+ void (async () => {
2129
+ try {
2130
+ const files = await filePicker.pickFiles({ source, multiple });
2131
+ logNativeFilePicker("native_pick_resolved", { source, fileCount: files.length });
2132
+ if (files.length === 0) {
2133
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerCancelledScript());
2134
+ return;
2135
+ }
2136
+ queuePickedFiles(files);
2137
+ } catch (error) {
2138
+ const { message, code } = readFilePickerError(error);
2139
+ warnNativeFilePicker("native_pick_failed", { source, code, message });
2140
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(message, code));
2141
+ } finally {
2142
+ pickerInFlightRef.current = false;
2143
+ pauseLivenessAfterPicker(LIVENESS_PICKER_GRACE_MS);
2155
2144
  }
2156
- queuePickedFiles(files);
2157
- }).catch((error) => {
2158
- const { message, code } = readFilePickerError(error);
2159
- nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(message, code));
2160
- }).finally(() => {
2161
- pickerInFlightRef.current = false;
2162
- pauseLivenessAfterPicker(LIVENESS_PICKER_GRACE_MS);
2163
- });
2145
+ })();
2164
2146
  }, [pauseLivenessAfterPicker, queuePickedFiles]);
2165
- const openNativeFilePicker = useCallback((multiple) => {
2147
+ const openNativeFilePicker = useCallback((multiple, source) => {
2166
2148
  const filePicker = internalSagepilotChat.getConfig()?.filePicker;
2149
+ logNativeFilePicker("open_requested", {
2150
+ source: source ?? "source_chooser",
2151
+ multiple,
2152
+ hasFilePicker: Boolean(filePicker),
2153
+ availableSources: filePicker?.sources ?? []
2154
+ });
2167
2155
  if (!filePicker || filePicker.sources.length === 0) {
2156
+ warnNativeFilePicker("open_unavailable", { source: source ?? "source_chooser" });
2157
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(
2158
+ source === "camera" ? "CameraX is not available in this Expo runtime. Use a dev build with the CameraX addon linked." : "Native attachment picker is not available in this build.",
2159
+ "camera_unavailable"
2160
+ ));
2161
+ return;
2162
+ }
2163
+ if (source) {
2164
+ if (filePicker.sources.includes(source)) {
2165
+ runNativeFilePicker(source, multiple);
2166
+ } else {
2167
+ warnNativeFilePicker("source_not_available", { source, availableSources: filePicker.sources });
2168
+ nativeWebViewRef.current?.injectJavaScript(buildFilePickerErrorScript(
2169
+ source === "camera" ? "CameraX is not available in this build." : `Native ${source} picker is not available in this build.`,
2170
+ "camera_unavailable"
2171
+ ));
2172
+ }
2168
2173
  return;
2169
2174
  }
2170
2175
  const [onlySource] = filePicker.sources;
2171
- if (filePicker.sources.length === 1 && onlySource && onlySource !== "camera") {
2176
+ if (filePicker.sources.length === 1 && onlySource) {
2172
2177
  runNativeFilePicker(onlySource, multiple);
2173
2178
  return;
2174
2179
  }
@@ -2348,7 +2353,11 @@ function SagepilotChatProvider({
2348
2353
  const handleWebViewMessage = (event) => {
2349
2354
  const message = parseHostedBridgeMessage(event.nativeEvent?.data);
2350
2355
  if (message?.type === "sagepilot:open_file_picker") {
2351
- openNativeFilePicker(message.multiple ?? true);
2356
+ logNativeFilePicker("bridge_message_open_file_picker", {
2357
+ source: message.source ?? "source_chooser",
2358
+ multiple: message.multiple ?? true
2359
+ });
2360
+ openNativeFilePicker(message.multiple ?? true, message.source);
2352
2361
  return;
2353
2362
  }
2354
2363
  if (message?.type === "sagepilot:widget_listener_ready") {
@@ -2566,7 +2575,6 @@ function SagepilotChatProvider({
2566
2575
  createElement(
2567
2576
  View,
2568
2577
  { style: styles.sheetCard },
2569
- createElement(View, { style: styles.sheetHandle }),
2570
2578
  createElement(Text, { style: styles.sheetTitle }, "Add attachment"),
2571
2579
  ...(internalSagepilotChat.getConfig()?.filePicker?.sources ?? []).map(
2572
2580
  (source) => createElement(
@@ -2574,29 +2582,19 @@ function SagepilotChatProvider({
2574
2582
  {
2575
2583
  key: source,
2576
2584
  accessibilityRole: "button",
2577
- android_ripple: { color: "rgba(15, 23, 42, 0.06)" },
2578
- hitSlop: 4,
2579
- style: ({ pressed }) => getSheetOptionStyle(pressed),
2585
+ style: styles.sheetButton,
2580
2586
  onPress: () => handleSourceChoice(source)
2581
2587
  },
2582
- renderFilePickerSourceIcon(source),
2583
- createElement(
2584
- View,
2585
- { style: styles.sheetOptionText },
2586
- createElement(Text, { style: styles.sheetButtonText }, FILE_PICKER_SOURCE_LABELS[source]),
2587
- createElement(Text, { style: styles.sheetButtonDescription }, FILE_PICKER_SOURCE_DESCRIPTIONS[source])
2588
- )
2588
+ createElement(Text, { style: styles.sheetButtonText }, FILE_PICKER_SOURCE_LABELS[source])
2589
2589
  )
2590
2590
  ),
2591
2591
  createElement(
2592
2592
  Pressable,
2593
2593
  {
2594
2594
  accessibilityRole: "button",
2595
- android_ripple: { color: "rgba(15, 23, 42, 0.06)" },
2596
- style: ({ pressed }) => getSheetCancelStyle(pressed),
2595
+ style: [styles.sheetButton, styles.sheetCancelButton],
2597
2596
  onPress: () => setSourceChooser(null)
2598
2597
  },
2599
- createElement(X, { color: "#334155", size: 18, strokeWidth: 2.5, style: styles.sheetCancelIcon }),
2600
2598
  createElement(Text, { style: styles.sheetCancelText }, "Cancel")
2601
2599
  )
2602
2600
  )
@@ -2702,109 +2700,43 @@ var styles = StyleSheet.create({
2702
2700
  },
2703
2701
  sheetBackdrop: {
2704
2702
  flex: 1,
2705
- alignItems: "center",
2706
2703
  justifyContent: "flex-end",
2707
- backgroundColor: "rgba(15, 23, 42, 0.48)"
2704
+ backgroundColor: "rgba(17, 24, 39, 0.36)"
2708
2705
  },
2709
2706
  sheetCard: {
2710
- width: "100%",
2711
- maxWidth: 540,
2712
2707
  backgroundColor: "#ffffff",
2713
- borderTopLeftRadius: 26,
2714
- borderTopRightRadius: 26,
2715
- paddingTop: 10,
2716
- paddingBottom: 18,
2717
- paddingHorizontal: 14,
2718
- shadowColor: "#0f172a",
2719
- shadowOpacity: 0.22,
2720
- shadowRadius: 28,
2721
- shadowOffset: { width: 0, height: -10 },
2722
- elevation: 18
2723
- },
2724
- sheetHandle: {
2725
- alignSelf: "center",
2726
- width: 42,
2727
- height: 5,
2728
- borderRadius: 999,
2729
- backgroundColor: "#d1d5db",
2730
- marginBottom: 14
2708
+ borderTopLeftRadius: 16,
2709
+ borderTopRightRadius: 16,
2710
+ paddingTop: 8,
2711
+ paddingBottom: 24,
2712
+ paddingHorizontal: 8
2731
2713
  },
2732
2714
  sheetTitle: {
2733
- color: "#111827",
2734
- fontSize: 17,
2735
- fontWeight: "700",
2736
- paddingBottom: 12,
2737
- paddingHorizontal: 4
2738
- },
2739
- sheetOption: {
2740
- minHeight: 70,
2741
- flexDirection: "row",
2742
- alignItems: "center",
2743
- borderRadius: 18,
2744
- paddingHorizontal: 12,
2745
- marginBottom: 6,
2746
- backgroundColor: "#ffffff"
2747
- },
2748
- sheetOptionPressed: {
2749
- backgroundColor: "#f8fafc",
2750
- transform: [{ scale: 0.985 }]
2715
+ textAlign: "center",
2716
+ color: "#6b7280",
2717
+ fontSize: 13,
2718
+ fontWeight: "600",
2719
+ paddingVertical: 10
2751
2720
  },
2752
- sheetOptionIcon: {
2753
- width: 46,
2754
- height: 46,
2755
- borderRadius: 16,
2756
- marginRight: 14,
2721
+ sheetButton: {
2722
+ minHeight: 52,
2757
2723
  alignItems: "center",
2758
2724
  justifyContent: "center",
2759
- position: "relative",
2760
- overflow: "hidden"
2761
- },
2762
- sheetOptionText: {
2763
- flex: 1,
2764
- justifyContent: "center"
2725
+ borderRadius: 12
2765
2726
  },
2766
2727
  sheetButtonText: {
2767
- color: "#0f172a",
2728
+ color: "#111827",
2768
2729
  fontSize: 16,
2769
- fontWeight: "700"
2770
- },
2771
- sheetButtonDescription: {
2772
- color: "#64748b",
2773
- fontSize: 13,
2774
- fontWeight: "500",
2775
- marginTop: 3
2776
- },
2777
- cameraOptionIcon: {
2778
- backgroundColor: "#e0f2fe"
2779
- },
2780
- libraryOptionIcon: {
2781
- backgroundColor: "#ecfdf5"
2782
- },
2783
- documentsOptionIcon: {
2784
- backgroundColor: "#f5f3ff"
2730
+ fontWeight: "500"
2785
2731
  },
2786
2732
  sheetCancelButton: {
2787
- minHeight: 56,
2788
- flexDirection: "row",
2789
- alignItems: "center",
2790
- justifyContent: "center",
2791
- borderRadius: 18,
2792
- marginTop: 8,
2793
- backgroundColor: "#f1f5f9"
2794
- },
2795
- sheetCancelButtonPressed: {
2796
- backgroundColor: "#e2e8f0",
2797
- transform: [{ scale: 0.985 }]
2798
- },
2799
- sheetCancelIcon: {
2800
- width: 18,
2801
- height: 18,
2802
- marginRight: 8
2733
+ marginTop: 6,
2734
+ backgroundColor: "#f3f4f6"
2803
2735
  },
2804
2736
  sheetCancelText: {
2805
- color: "#0f172a",
2737
+ color: "#111827",
2806
2738
  fontSize: 16,
2807
- fontWeight: "700"
2739
+ fontWeight: "600"
2808
2740
  }
2809
2741
  });
2810
2742
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagepilot-ai/react-native-sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Sagepilot AI React Native chat SDK",
5
5
  "keywords": [
6
6
  "sagepilot",
@@ -46,9 +46,6 @@
46
46
  "typecheck": "tsc --noEmit",
47
47
  "prepublishOnly": "npm run typecheck && npm run build"
48
48
  },
49
- "dependencies": {
50
- "lucide-react-native": "^1.21.0"
51
- },
52
49
  "peerDependencies": {
53
50
  "@react-native-async-storage/async-storage": ">=1.23",
54
51
  "@react-native-documents/picker": ">=10",