@uploadista/react-native-core 0.0.15-beta.2 → 0.0.15-beta.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.
- package/dist/index.d.mts +76 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/contexts/flow-manager-context.tsx +230 -0
- package/src/hooks/use-flow-upload.ts +54 -111
- package/src/index.ts +5 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react0 from "react";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import * as _uploadista_client_core3 from "@uploadista/client-core";
|
|
4
|
-
import { Base64Service, ConnectionMetrics, ConnectionPoolConfig, ConnectionPoolConfig as ConnectionPoolConfig$1, DetailedConnectionMetrics, FileReaderService, FlowUploadState, FlowUploadStatus, HttpClient, IdGenerationService, ServiceContainer, ServiceContainer as ServiceContainer$1, StorageService, UploadState, UploadStatus, UploadistaClientOptions, UploadistaEvent } from "@uploadista/client-core";
|
|
4
|
+
import { Base64Service, ConnectionMetrics, ConnectionPoolConfig, ConnectionPoolConfig as ConnectionPoolConfig$1, DetailedConnectionMetrics, FileReaderService, FlowManager, FlowManagerCallbacks, FlowUploadOptions, FlowUploadState, FlowUploadStatus, HttpClient, IdGenerationService, ServiceContainer, ServiceContainer as ServiceContainer$1, StorageService, UploadState, UploadStatus, UploadistaClientOptions, UploadistaEvent } from "@uploadista/client-core";
|
|
5
5
|
import { UploadFile } from "@uploadista/core/types";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
7
7
|
import * as _uploadista_core0 from "@uploadista/core";
|
|
8
8
|
|
|
9
9
|
//#region src/types/types.d.ts
|
|
@@ -306,7 +306,7 @@ declare function CameraUploadButton({
|
|
|
306
306
|
onError,
|
|
307
307
|
onCancel,
|
|
308
308
|
showProgress
|
|
309
|
-
}: CameraUploadButtonProps):
|
|
309
|
+
}: CameraUploadButtonProps): react_jsx_runtime1.JSX.Element;
|
|
310
310
|
//#endregion
|
|
311
311
|
//#region src/components/FileUploadButton.d.ts
|
|
312
312
|
interface FileUploadButtonProps {
|
|
@@ -337,7 +337,7 @@ declare function FileUploadButton({
|
|
|
337
337
|
onError,
|
|
338
338
|
onCancel,
|
|
339
339
|
showProgress
|
|
340
|
-
}: FileUploadButtonProps):
|
|
340
|
+
}: FileUploadButtonProps): react_jsx_runtime1.JSX.Element;
|
|
341
341
|
//#endregion
|
|
342
342
|
//#region src/components/GalleryUploadButton.d.ts
|
|
343
343
|
interface GalleryUploadButtonProps {
|
|
@@ -368,7 +368,7 @@ declare function GalleryUploadButton({
|
|
|
368
368
|
onError,
|
|
369
369
|
onCancel,
|
|
370
370
|
showProgress
|
|
371
|
-
}: GalleryUploadButtonProps):
|
|
371
|
+
}: GalleryUploadButtonProps): react_jsx_runtime1.JSX.Element;
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region src/components/UploadList.d.ts
|
|
374
374
|
interface UploadListProps {
|
|
@@ -390,7 +390,7 @@ declare function UploadList({
|
|
|
390
390
|
onRemove,
|
|
391
391
|
onItemPress,
|
|
392
392
|
showRemoveButton
|
|
393
|
-
}: UploadListProps):
|
|
393
|
+
}: UploadListProps): react_jsx_runtime1.JSX.Element;
|
|
394
394
|
//#endregion
|
|
395
395
|
//#region src/components/UploadProgress.d.ts
|
|
396
396
|
interface UploadProgressProps {
|
|
@@ -405,7 +405,73 @@ interface UploadProgressProps {
|
|
|
405
405
|
declare function UploadProgress({
|
|
406
406
|
state,
|
|
407
407
|
label
|
|
408
|
-
}: UploadProgressProps):
|
|
408
|
+
}: UploadProgressProps): react_jsx_runtime1.JSX.Element;
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/contexts/flow-manager-context.d.ts
|
|
411
|
+
/**
|
|
412
|
+
* Context value providing access to flow managers
|
|
413
|
+
*/
|
|
414
|
+
interface FlowManagerContextValue {
|
|
415
|
+
/**
|
|
416
|
+
* Get or create a flow manager for the given flow ID.
|
|
417
|
+
* Increments ref count - must call releaseManager when done.
|
|
418
|
+
*
|
|
419
|
+
* @param flowId - Unique identifier for the flow
|
|
420
|
+
* @param callbacks - Callbacks for state changes and lifecycle events
|
|
421
|
+
* @param options - Flow configuration options
|
|
422
|
+
* @returns FlowManager instance
|
|
423
|
+
*/
|
|
424
|
+
getManager: <TOutput = unknown>(flowId: string, callbacks: FlowManagerCallbacks<TOutput>, options: FlowUploadOptions<TOutput>) => FlowManager<unknown, TOutput>;
|
|
425
|
+
/**
|
|
426
|
+
* Release a flow manager reference.
|
|
427
|
+
* Decrements ref count and cleans up when reaching zero.
|
|
428
|
+
*
|
|
429
|
+
* @param flowId - Unique identifier for the flow to release
|
|
430
|
+
*/
|
|
431
|
+
releaseManager: (flowId: string) => void;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Props for FlowManagerProvider
|
|
435
|
+
*/
|
|
436
|
+
interface FlowManagerProviderProps {
|
|
437
|
+
children: ReactNode;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Provider that manages FlowManager instances with ref counting and event routing.
|
|
441
|
+
* Ensures managers persist across component re-renders and are only cleaned up
|
|
442
|
+
* when all consuming components unmount.
|
|
443
|
+
*
|
|
444
|
+
* This provider should be nested inside UploadistaProvider to access the upload client
|
|
445
|
+
* and event subscription system.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```tsx
|
|
449
|
+
* <UploadistaProvider baseUrl="https://api.example.com" storageId="default">
|
|
450
|
+
* <FlowManagerProvider>
|
|
451
|
+
* <App />
|
|
452
|
+
* </FlowManagerProvider>
|
|
453
|
+
* </UploadistaProvider>
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
declare function FlowManagerProvider({
|
|
457
|
+
children
|
|
458
|
+
}: FlowManagerProviderProps): react_jsx_runtime1.JSX.Element;
|
|
459
|
+
/**
|
|
460
|
+
* Hook to access the FlowManager context.
|
|
461
|
+
* Must be used within a FlowManagerProvider.
|
|
462
|
+
*
|
|
463
|
+
* @returns FlowManager context value with getManager and releaseManager functions
|
|
464
|
+
* @throws Error if used outside of FlowManagerProvider
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```tsx
|
|
468
|
+
* function MyComponent() {
|
|
469
|
+
* const { getManager, releaseManager } = useFlowManagerContext();
|
|
470
|
+
* // Use to create managers...
|
|
471
|
+
* }
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
declare function useFlowManagerContext(): FlowManagerContextValue;
|
|
409
475
|
//#endregion
|
|
410
476
|
//#region src/client/create-uploadista-client.d.ts
|
|
411
477
|
interface UploadistaClientOptions$1 extends Omit<UploadistaClientOptions<ReactNativeUploadInput>, "webSocketFactory" | "abortControllerFactory" | "generateId" | "clientStorage" | "logger" | "httpClient" | "fileReader" | "base64"> {
|
|
@@ -626,7 +692,8 @@ declare function useFileUpload(options?: UseFileUploadOptions): {
|
|
|
626
692
|
* Hook for uploading files through a flow pipeline with full state management.
|
|
627
693
|
* Provides upload progress tracking, flow execution monitoring, error handling, and abort functionality.
|
|
628
694
|
*
|
|
629
|
-
* Must be used within
|
|
695
|
+
* Must be used within FlowManagerProvider (which must be within UploadistaProvider).
|
|
696
|
+
* Flow events are automatically routed by the provider to the appropriate manager.
|
|
630
697
|
*
|
|
631
698
|
* @param options - Flow upload configuration
|
|
632
699
|
* @returns Flow upload state and control methods
|
|
@@ -963,5 +1030,5 @@ declare function normalizeUri(uri: string): string;
|
|
|
963
1030
|
*/
|
|
964
1031
|
declare function getMimeTypeFromUri(uri: string): string;
|
|
965
1032
|
//#endregion
|
|
966
|
-
export { type Base64Service, type CameraOptions, CameraUploadButton, type CameraUploadButtonProps, type ConnectionMetrics, type ConnectionPoolConfig, type DetailedConnectionMetrics, type FileInfo, type FilePickResult, type FileReaderService, type FileSystemProvider, type FileSystemProviderConfig, FileUploadButton, type FileUploadButtonProps, type FlowUploadState, type FlowUploadStatus, GalleryUploadButton, type GalleryUploadButtonProps, type HttpClient, type IdGenerationService, type MultiUploadState, PermissionStatus, PermissionType, type PickerOptions, type ReactNativeUploadInput, type ServiceContainer, type StorageService, type UploadItemState, UploadList, type UploadListProps, type UploadMetrics, UploadProgress, type UploadProgressProps, type UploadState, type UploadStatus, UploadistaContext, type UploadistaContextType, type UseCameraUploadOptions, type UseFileUploadOptions, type UseFlowUploadOptions, type UseGalleryUploadOptions, type UseMultiUploadOptions, formatFileSize, getDirectoryFromUri, getFileExtension, getFileNameFromUri, getFileNameWithoutExtension, getMimeTypeFromFileName, getMimeTypeFromUri, getPermissionStatus, hasPermissions, isContentUri, isDocumentFile, isFileSizeValid, isFileTypeAllowed, isFileUri, isImageFile, isVideoFile, normalizeUri, openAppSettings, pathToUri, requestCameraPermission, requestPermissions, requestPhotoLibraryPermission, requestStorageReadPermission, requestStorageWritePermission, uriToPath, useCameraUpload, useFileUpload, useFlowUpload, useGalleryUpload, useMultiUpload, useUploadMetrics, useUploadistaContext };
|
|
1033
|
+
export { type Base64Service, type CameraOptions, CameraUploadButton, type CameraUploadButtonProps, type ConnectionMetrics, type ConnectionPoolConfig, type DetailedConnectionMetrics, type FileInfo, type FilePickResult, type FileReaderService, type FileSystemProvider, type FileSystemProviderConfig, FileUploadButton, type FileUploadButtonProps, FlowManagerProvider, type FlowUploadState, type FlowUploadStatus, GalleryUploadButton, type GalleryUploadButtonProps, type HttpClient, type IdGenerationService, type MultiUploadState, PermissionStatus, PermissionType, type PickerOptions, type ReactNativeUploadInput, type ServiceContainer, type StorageService, type UploadItemState, UploadList, type UploadListProps, type UploadMetrics, UploadProgress, type UploadProgressProps, type UploadState, type UploadStatus, UploadistaContext, type UploadistaContextType, type UseCameraUploadOptions, type UseFileUploadOptions, type UseFlowUploadOptions, type UseGalleryUploadOptions, type UseMultiUploadOptions, formatFileSize, getDirectoryFromUri, getFileExtension, getFileNameFromUri, getFileNameWithoutExtension, getMimeTypeFromFileName, getMimeTypeFromUri, getPermissionStatus, hasPermissions, isContentUri, isDocumentFile, isFileSizeValid, isFileTypeAllowed, isFileUri, isImageFile, isVideoFile, normalizeUri, openAppSettings, pathToUri, requestCameraPermission, requestPermissions, requestPhotoLibraryPermission, requestStorageReadPermission, requestStorageWritePermission, uriToPath, useCameraUpload, useFileUpload, useFlowManagerContext, useFlowUpload, useGalleryUpload, useMultiUpload, useUploadMetrics, useUploadistaContext };
|
|
967
1034
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/types.ts","../src/types/upload-input.ts","../src/components/CameraUploadButton.tsx","../src/components/FileUploadButton.tsx","../src/components/GalleryUploadButton.tsx","../src/components/UploadList.tsx","../src/components/UploadProgress.tsx","../src/client/create-uploadista-client.ts","../src/hooks/use-uploadista-client.ts","../src/hooks/uploadista-context.ts","../src/hooks/use-camera-upload.ts","../src/hooks/use-file-upload.ts","../src/hooks/use-flow-upload.ts","../src/hooks/use-multi-upload.ts","../src/hooks/use-gallery-upload.ts","../src/hooks/use-upload-metrics.ts","../src/hooks/use-uploadista-context.ts","../src/utils/fileHelpers.ts","../src/utils/permissions.ts","../src/utils/uriHelpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;UAOiB,aAAA;;;EAAA;EAYA,aAAA,CAAA,EAAa,OAAA;EAcb;EAgBL,OAAA,CAAA,EAAA,MAAA;AAQZ;AAiBA;;;AAMyC,UA7DxB,aAAA,CA6DwB;EAOnB;EAAwB,UAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAAR;EAOhB,OAAA,CAAA,EAAA,MAAA;EAAwB;EAAR,QAAA,CAAA,EAAA,MAAA;EAOf;EAAwB,SAAA,CAAA,EAAA,MAAA;;;;;AAqBX,UAzFnB,eAAA,CAyFmB;EAAR;EAAO,GAAA,EAAA,MAAA;EA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AiBiB,iBmBrCD,SAAA,CnBqCmB,QAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;AAaG,iBmBhCtB,SAAA,CnBgCsB,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;AAcC,iBmB5BvB,mBAAA,CnB4BuB,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;AAqBJ,iBmBjCnB,YAAA,CnBiCmB,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;AAMnC;AAUA;AAWA;AAgCA;AA8DA;AAciB,iBmB/JD,SAAA,CnB+JqB,GAAA,EAQxB,MAAA,CAAA,EAIO,OAAK;AAkBzB;;;;;AAsBiB,iBmB1MD,YAAA,CnB0MwB,GAAA,EAQ3B,MAAA,CAAA,EAIO,MAAK;AAYzB;AAsBA;;;;ACnWY,iBkBqHI,kBAAA,ClBrHqB,GAAA,EAAO,MAAI,CAAA,EAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/types.ts","../src/types/upload-input.ts","../src/components/CameraUploadButton.tsx","../src/components/FileUploadButton.tsx","../src/components/GalleryUploadButton.tsx","../src/components/UploadList.tsx","../src/components/UploadProgress.tsx","../src/contexts/flow-manager-context.tsx","../src/client/create-uploadista-client.ts","../src/hooks/use-uploadista-client.ts","../src/hooks/uploadista-context.ts","../src/hooks/use-camera-upload.ts","../src/hooks/use-file-upload.ts","../src/hooks/use-flow-upload.ts","../src/hooks/use-multi-upload.ts","../src/hooks/use-gallery-upload.ts","../src/hooks/use-upload-metrics.ts","../src/hooks/use-uploadista-context.ts","../src/utils/fileHelpers.ts","../src/utils/permissions.ts","../src/utils/uriHelpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;UAOiB,aAAA;;;EAAA;EAYA,aAAA,CAAA,EAAa,OAAA;EAcb;EAgBL,OAAA,CAAA,EAAA,MAAA;AAQZ;AAiBA;;;AAMyC,UA7DxB,aAAA,CA6DwB;EAOnB;EAAwB,UAA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t,useCallback as n,useContext as r,useEffect as i,useRef as a,useState as o}from"react";import{ActivityIndicator as s,FlatList as c,Pressable as l,StyleSheet as u,Text as d,View as f}from"react-native";import{FlowManager as p,UploadManager as m}from"@uploadista/client-core";import{EventType as h}from"@uploadista/core/flow";import{UploadEventType as g}from"@uploadista/core/types";import{jsx as _,jsxs as v}from"react/jsx-runtime";const y=t(void 0);function b(e,t){let n=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Blob([n],t)}function x(){let e=r(y);if(!e)throw Error(`useUploadistaClient must be used within an UploadistaProvider`);return e}const ee={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,error:null,result:null};function S(e={}){let{client:t,fileSystemProvider:r}=x(),[s,c]=o(ee),l=a(null),u=a(null);return i(()=>(l.current=new m(async(e,n)=>{let i=e;if(i.status===`success`){let e=b(await r.readFile(i.data.uri),{type:i.data.mimeType||`application/octet-stream`});return t.upload(e,n)}return Promise.resolve({abort:()=>{}})},{onStateChange:c,onProgress:e.onProgress,onChunkComplete:e.onChunkComplete,onSuccess:e.onSuccess,onError:e.onError,onAbort:e.onAbort},{metadata:e.metadata,uploadLengthDeferred:e.uploadLengthDeferred,uploadSize:e.uploadSize,onShouldRetry:e.onShouldRetry}),()=>{l.current?.cleanup()}),[t,r,e]),{state:s,upload:n(async e=>{u.current=e,await l.current?.upload(e)},[]),abort:n(()=>{l.current?.abort()},[]),reset:n(()=>{l.current?.reset(),u.current=null},[]),retry:n(()=>{u.current&&l.current?.canRetry()&&l.current.retry()},[]),isUploading:s.status===`uploading`,canRetry:l.current?.canRetry()??!1,metrics:{getInsights:()=>t.getChunkingInsights(),exportMetrics:()=>t.exportMetrics(),getNetworkMetrics:()=>t.getNetworkMetrics(),getNetworkCondition:()=>t.getNetworkCondition(),resetMetrics:()=>t.resetMetrics()}}}function C(e){let{fileSystemProvider:t}=x(),r=S({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickCamera(e?.cameraOptions);await r.upload(n)}catch(e){console.error(`Camera capture error:`,e)}},[t,e?.cameraOptions,r]);return{...r,captureAndUpload:i}}function w(e){let{fileSystemProvider:t}=x(),r=S({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickDocument({allowedTypes:e?.allowedTypes});await r.upload(n)}catch(e){throw console.error(`File selection error:`,e),e}},[t,e?.allowedTypes,r]);return{...r,pickAndUpload:i}}function te(e){let t=e;return t.eventType===h.FlowStart||t.eventType===h.FlowEnd||t.eventType===h.FlowError||t.eventType===h.NodeStart||t.eventType===h.NodeEnd||t.eventType===h.NodePause||t.eventType===h.NodeResume||t.eventType===h.NodeError}const ne={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,error:null,result:null,jobId:null,flowStarted:!1,currentNodeName:null,currentNodeType:null,flowOutputs:null};function re(e){let t=x(),{client:r,fileSystemProvider:s}=t,[c,l]=o(ne),u=a(null),d=a(null);i(()=>(u.current=new p(async(e,t,n)=>{let i=await r.uploadWithFlow(e,t,{onJobStart:n.onJobStart,onProgress:n.onProgress,onChunkComplete:n.onChunkComplete,onSuccess:n.onSuccess,onError:n.onError,onShouldRetry:n.onShouldRetry});return{abort:async()=>{await i.abort()},pause:async()=>{await i.pause()}}},{onStateChange:l,onProgress:e.onProgress?(t,n,r)=>{let i=r?Math.round(n/r*100):0;e.onProgress?.(i,n,r)}:void 0,onChunkComplete:e.onChunkComplete,onSuccess:e.onSuccess,onError:e.onError},{flowConfig:{flowId:e.flowId,storageId:e.storageId,outputNodeId:e.outputNodeId,metadata:e.metadata},onChunkComplete:e.onChunkComplete,onSuccess:e.onSuccess,onError:e.onError}),()=>{u.current?.cleanup()}),[r]),i(()=>t.subscribeToEvents(e=>{if(te(e)){u.current?.handleFlowEvent(e);return}let t=e;if(t.type===g.UPLOAD_PROGRESS&&t.flow?.jobId===u.current?.getJobId()&&t.data){let{progress:e,total:n}=t.data;u.current?.handleUploadProgress(t.data.id,e,n)}}),[t]);let f=n(async t=>{if(t.status!==`cancelled`){if(t.status===`error`){e.onError?.(t.error);return}d.current=t;try{let e=b(await s.readFile(t.data.uri),{type:t.data.mimeType||`application/octet-stream`});await u.current?.upload(e)}catch(t){e.onError?.(t)}}},[s,e]),m=n(()=>{u.current?.reset(),d.current=null},[]);return{state:c,upload:f,abort:n(()=>{u.current?.abort()},[]),reset:m,retry:n(()=>{d.current&&(c.status===`error`||c.status===`aborted`)&&f(d.current)},[f,c.status]),isActive:c.status===`uploading`||c.status===`processing`,canRetry:(c.status===`error`||c.status===`aborted`)&&d.current!==null}}const T={items:[],totalProgress:0,totalUploaded:0,totalBytes:0,activeCount:0,completedCount:0,failedCount:0};function E(e={}){let{client:t}=x(),[r,i]=o(T),s=a(new Map),c=a(0),l=a([]),u=n(()=>`upload-${Date.now()}-${c.current++}`,[]),d=n(e=>{let t=e.reduce((e,t)=>e+t.totalBytes,0),n=e.reduce((e,t)=>e+t.bytesUploaded,0),r=t>0?Math.round(n/t*100):0,a=e.filter(e=>e.status===`uploading`).length,o=e.filter(e=>e.status===`success`).length,s=e.filter(e=>e.status===`error`).length;l.current=e,i(i=>({...i,items:e,totalProgress:r,totalUploaded:n,totalBytes:t,activeCount:a,completedCount:o,failedCount:s}))},[]),f=n(e=>{let t=e.filter(e=>e.status===`success`).map(e=>({id:u(),file:e,status:`idle`,progress:0,bytesUploaded:0,totalBytes:e.data.size,error:null,result:null})),n=[...l.current,...t];return l.current=n,i(e=>{let t=n.reduce((e,t)=>e+t.totalBytes,0);return{...e,items:n,totalBytes:t}}),t.map(e=>e.id)},[u]),p=n(async n=>{try{console.log(`Uploading item:`,n.file.data.name),d(l.current.map(e=>e.id===n.id?{...e,status:`uploading`}:e));let r=await(await fetch(n.file.data.uri)).blob(),i=n.file.data.mimeType?new Blob([r],{type:n.file.data.mimeType}):r;console.log(`Uploading input:`,i);let a=await t.upload(i,{metadata:e.metadata,onProgress:(e,t,r)=>{let i=r?Math.round(t/r*100):0;d(l.current.map(e=>e.id===n.id?{...e,progress:i,bytesUploaded:t,totalBytes:r||e.totalBytes}:e))},onSuccess:t=>{d(l.current.map(e=>e.id===n.id?{...e,status:`success`,progress:100,result:t,bytesUploaded:t.size||e.totalBytes}:e)),e.onSuccess?.(t),s.current.delete(n.id)},onError:t=>{d(l.current.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e.onError?.(t),s.current.delete(n.id)}});s.current.set(n.id,a)}catch(t){console.error(`Error uploading item:`,t),d(l.current.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e.onError?.(t),s.current.delete(n.id)}},[t,e,d]),m=n(async t=>{let n=e.maxConcurrent||3,r=t?l.current.filter(e=>t.includes(e.id)&&e.status===`idle`):l.current.filter(e=>e.status===`idle`);console.log(`Items to upload:`,r.length,r);for(let e=0;e<r.length;e+=n){let t=r.slice(e,e+n);await Promise.all(t.map(e=>p(e)))}},[e.maxConcurrent,p]),h=n(e=>{let t=s.current.get(e);t&&(t.abort(),s.current.delete(e)),d(l.current.filter(t=>t.id!==e))},[d]),g=n(e=>{let t=s.current.get(e);t&&(t.abort(),s.current.delete(e)),d(l.current.map(t=>t.id===e?{...t,status:`aborted`}:t))},[d]),_=n(()=>{s.current.forEach(e=>{e.abort()}),s.current.clear(),l.current=[],i(T)},[]);return{state:r,addFiles:f,startUploads:m,removeItem:h,abortItem:g,retryItem:n(async e=>{let t=l.current.find(t=>t.id===e);if(t&&(t.status===`error`||t.status===`aborted`)){d(l.current.map(t=>t.id===e?{...t,status:`idle`,progress:0,bytesUploaded:0,error:null}:t));let t=l.current.find(t=>t.id===e);t&&await p(t)}},[p,d]),clear:_}}function D(e){let{fileSystemProvider:t}=x(),r=E({maxConcurrent:3,metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError}),i=n(async()=>{let n;if(n=e?.mediaType===`video`?await t.pickVideo({allowMultiple:e?.allowMultiple??!0}):(e?.mediaType,await t.pickImage({allowMultiple:e?.allowMultiple??!0})),n.status===`cancelled`)return[];if(n.status===`error`)return console.error(`Gallery selection error:`,n.error),e?.onError?.(n.error),[];let i=r.addFiles([n]);return await r.startUploads(i),i},[t,e?.allowMultiple,e?.mediaType,e?.onError,r]);return{...r,selectAndUpload:i}}function ie(){let e=a(null),t=a(0),r=a(0),[i,s]=o({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0});return{metrics:i,start:n(()=>{e.current=Date.now(),t.current=0,r.current=0},[]),update:n((t,n,i=0)=>{if(!e.current)return;let a=Date.now()-e.current,o=a>0?t/a*1e3:0;o>r.current&&(r.current=o),s({totalBytes:t,durationMs:a,avgSpeed:a>0?t/a*1e3:0,peakSpeed:r.current,retries:i})},[]),end:n(()=>{let t=i;return e.current=null,t},[i]),reset:n(()=>{e.current=null,t.current=0,r.current=0,s({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0})},[])}}function O(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*100)/100} ${n[r]}`}function k(e){return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".svg":`image/svg+xml`,".mp4":`video/mp4`,".avi":`video/x-msvideo`,".mov":`video/quicktime`,".wmv":`video/x-ms-wmv`,".flv":`video/x-flv`,".mkv":`video/x-matroska`,".webm":`video/webm`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".flac":`audio/flac`,".m4a":`audio/mp4`,".pdf":`application/pdf`,".doc":`application/msword`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xls":`application/vnd.ms-excel`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".ppt":`application/vnd.ms-powerpoint`,".pptx":`application/vnd.openxmlformats-officedocument.presentationml.presentation`,".txt":`text/plain`,".csv":`text/csv`,".json":`application/json`,".xml":`application/xml`,".zip":`application/zip`}[e.toLowerCase().slice(e.lastIndexOf(`.`))]||`application/octet-stream`}function A(e,t){if(!t||t.length===0)return!0;let n=k(e);return t.some(e=>{if(e.endsWith(`/*`)){let[t]=e.split(`/`);return n.startsWith(`${t}/`)}return e===n})}function j(e,t,n){return!(t!==void 0&&e>t||n!==void 0&&e<n)}function M(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function N(e){let t=e.lastIndexOf(`.`);return t===-1?e:e.slice(0,t)}function P(e){let t=[`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.webp`,`.svg`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function ae(e){let t=[`.mp4`,`.avi`,`.mov`,`.wmv`,`.flv`,`.mkv`,`.webm`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function oe(e){let t=[`.pdf`,`.doc`,`.docx`,`.xls`,`.xlsx`,`.ppt`,`.pptx`,`.txt`,`.csv`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}let F=function(e){return e.CAMERA=`CAMERA`,e.PHOTO_LIBRARY=`PHOTO_LIBRARY`,e.WRITE_STORAGE=`WRITE_STORAGE`,e.READ_STORAGE=`READ_STORAGE`,e}({}),I=function(e){return e.GRANTED=`granted`,e.DENIED=`denied`,e.NOT_DETERMINED=`not_determined`,e.RESTRICTED=`restricted`,e}({});async function L(){try{return console.log(`Camera permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request camera permission:`,e),!1}}async function R(){try{return console.log(`Photo library permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request photo library permission:`,e),!1}}async function z(){try{return console.log(`Storage read permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage read permission:`,e),!1}}async function B(){try{return console.log(`Storage write permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage write permission:`,e),!1}}async function V(e){try{return(await Promise.all(e.map(async e=>{switch(e){case F.CAMERA:return L();case F.PHOTO_LIBRARY:return R();case F.READ_STORAGE:return z();case F.WRITE_STORAGE:return B();default:return!1}}))).every(e=>e)}catch(e){return console.error(`Failed to request permissions:`,e),!1}}async function H(e){try{return!0}catch(e){return console.error(`Failed to check permissions:`,e),!1}}async function U(e){try{return I.GRANTED}catch(e){return console.error(`Failed to get permission status:`,e),I.DENIED}}function W(){try{console.log(`Opening app settings (requires react-native-app-settings or platform implementation)`)}catch(e){console.error(`Failed to open app settings:`,e)}}function G(e){try{if(e.startsWith(`file://`))return e.replace(`file://`,``).split(`/`).pop()||`file`;if(e.startsWith(`content://`)){let t=e.split(`/`);return t[t.length-1]||`file`}let t=e.split(`/`);return t[t.length-1]||`file`}catch{return`file`}}function K(e){return e.startsWith(`file://`)||e.startsWith(`content://`)?e:`file://${e}`}function q(e){return e.startsWith(`file://`)?e.replace(`file://`,``):(e.startsWith(`content://`),e)}function se(e){try{let t=q(e).split(`/`);return t.pop(),t.join(`/`)}catch{return``}}function ce(e){return e.startsWith(`content://`)}function le(e){return e.startsWith(`file://`)}function ue(e){return e.replace(/([^:]\/)\/+/g,`$1`)}function de(e){let t=G(e);return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".mp4":`video/mp4`,".mov":`video/quicktime`,".avi":`video/x-msvideo`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".pdf":`application/pdf`,".txt":`text/plain`,".json":`application/json`}[t.toLowerCase().slice(t.lastIndexOf(`.`))]||`application/octet-stream`}function J({state:e,label:t}){let n=()=>{switch(e.status){case`uploading`:return`#007AFF`;case`success`:return`#34C759`;case`error`:case`aborted`:return`#FF3B30`;default:return`#999999`}};return v(f,{style:[Y.wrapper,{borderLeftColor:n()}],children:[e.status===`uploading`&&_(s,{size:`small`,color:n(),style:Y.spinner}),(()=>{switch(e.status){case`idle`:return _(f,{style:Y.container,children:_(d,{style:Y.label,children:t||`Ready to upload`})});case`uploading`:return v(f,{style:Y.container,children:[v(f,{style:Y.headerRow,children:[_(d,{style:Y.label,children:t||`Uploading`}),v(d,{style:Y.percentage,children:[e.progress,`%`]})]}),_(f,{style:Y.progressBarContainer,children:_(f,{style:[Y.progressBar,{width:`${e.progress}%`,backgroundColor:n()}]})}),_(f,{style:Y.detailsRow,children:v(d,{style:Y.detail,children:[O(e.bytesUploaded),` /`,` `,O(e.totalBytes||0)]})})]});case`success`:return v(f,{style:Y.container,children:[v(f,{style:Y.headerRow,children:[_(d,{style:[Y.label,{color:n()}],children:t||`Upload complete`}),_(d,{style:[Y.percentage,{color:n()}],children:`✓`})]}),_(d,{style:[Y.detail,{color:n()}],children:O(e.totalBytes||0)})]});case`error`:return v(f,{style:Y.container,children:[v(f,{style:Y.headerRow,children:[_(d,{style:[Y.label,{color:n()}],children:t||`Upload failed`}),_(d,{style:[Y.percentage,{color:n()}],children:`✕`})]}),e.error&&_(d,{style:[Y.detail,{color:n()}],children:e.error.message})]});case`aborted`:return _(f,{style:Y.container,children:_(d,{style:[Y.label,{color:n()}],children:t||`Upload cancelled`})});default:return null}})()]})}const Y=u.create({wrapper:{flexDirection:`row`,alignItems:`flex-start`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},spinner:{marginTop:4},container:{flex:1,gap:4},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},label:{fontSize:14,fontWeight:`600`,color:`#333333`,flex:1},percentage:{fontSize:14,fontWeight:`600`,color:`#007AFF`,minWidth:36,textAlign:`right`},progressBarContainer:{height:4,backgroundColor:`#e0e0e0`,borderRadius:2,overflow:`hidden`},progressBar:{height:`100%`,borderRadius:2},detailsRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},detail:{fontSize:12,color:`#666666`}});function fe({options:e,label:t=`Take Photo`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,captureAndUpload:p}=C(e),m=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},h=u.status===`uploading`,g=h||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),v(f,{style:X.container,children:[v(l,{style:[X.button,g&&X.buttonDisabled],onPress:m,disabled:g,children:[h&&_(s,{size:`small`,color:`#FFFFFF`,style:X.spinner}),_(d,{style:X.buttonText,children:n||t})]}),c&&u.status!==`idle`&&_(f,{style:X.progressContainer,children:_(J,{state:u,label:`Camera upload`})})]})}const X=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#007AFF`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function pe({options:e,label:t=`Choose File`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,pickAndUpload:p}=w(e),m=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},h=u.status===`uploading`,g=h||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),v(f,{style:Z.container,children:[v(l,{style:[Z.button,g&&Z.buttonDisabled],onPress:m,disabled:g,children:[h&&_(s,{size:`small`,color:`#FFFFFF`,style:Z.spinner}),_(d,{style:Z.buttonText,children:n||t})]}),c&&u.status!==`idle`&&_(f,{style:Z.progressContainer,children:_(J,{state:u,label:`File upload`})})]})}const Z=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#FF9500`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function me({options:t,label:n=`Select from Gallery`,children:r,onSuccess:i,onError:a,onCancel:o,showProgress:u=!0}){let{state:p,selectAndUpload:m}=D(t),h=async()=>{try{await m()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},g=p.items.some(e=>e.status===`uploading`),y=p.items.length>0,b=y&&p.items.every(e=>e.status!==`uploading`&&e.status!==`idle`);return e.useEffect(()=>{if(b){let e=p.items.filter(e=>e.status===`success`).map(e=>e.result);e.length>0&&i?.(e)}},[b,p.items,i]),e.useEffect(()=>{let e=p.items.filter(e=>e.status===`error`)[0]?.error;e&&a?.(e)},[p.items,a]),v(f,{style:Q.container,children:[v(l,{style:[Q.button,g&&Q.buttonDisabled],onPress:h,disabled:g,children:[g&&_(s,{size:`small`,color:`#FFFFFF`,style:Q.spinner}),v(d,{style:Q.buttonText,children:[r||n,y&&` (${p.items.length})`]})]}),y&&v(f,{style:Q.statsContainer,children:[v(d,{style:Q.statsText,children:[`Progress: `,p.items.filter(e=>e.status===`success`).length,`/`,p.items.length,` uploaded`]}),v(d,{style:Q.statsText,children:[`Overall: `,p.totalProgress,`%`]})]}),u&&y&&_(c,{scrollEnabled:!1,data:p.items,renderItem:({item:e})=>_(f,{style:Q.itemContainer,children:_(J,{state:{status:e.status,progress:e.progress,bytesUploaded:e.bytesUploaded,totalBytes:e.totalBytes,error:e.error,result:e.result},label:e.file.data.name})},e.id),keyExtractor:e=>e.id,style:Q.listContainer,contentContainerStyle:Q.listContent,ItemSeparatorComponent:()=>_(f,{style:Q.separator})})]})}const Q=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#34C759`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},statsContainer:{paddingVertical:8,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,gap:4},statsText:{fontSize:12,color:`#666666`},listContainer:{maxHeight:400},listContent:{gap:8},itemContainer:{paddingHorizontal:0},separator:{height:4}});function he({items:e,onRemove:t,onItemPress:n,showRemoveButton:r=!0}){return e.length===0?_(f,{style:$.emptyContainer,children:_(d,{style:$.emptyText,children:`No uploads`})}):v(f,{style:$.container,children:[v(f,{style:$.headerRow,children:[v(d,{style:$.headerText,children:[`Uploads (`,e.length,`)`]}),v(d,{style:$.headerSubtext,children:[e.filter(e=>e.progress.state===`success`).length,` complete`]})]}),_(c,{scrollEnabled:!1,data:e,renderItem:({item:e})=>v(l,{style:[$.itemContainer,{borderLeftColor:ge(e.progress.state)}],onPress:()=>n?.(e),children:[v(f,{style:$.itemContent,children:[e.file.status===`success`&&v(f,{style:$.itemHeader,children:[_(d,{style:$.fileName,numberOfLines:1,children:e.file.data.name}),_(d,{style:$.fileSize,children:_e(e.file.data.size)})]}),e.file.status===`error`&&_(d,{style:$.errorText,children:e.progress.error?.message}),_(f,{style:$.progressWrapper,children:_(J,{state:{status:e.progress.state===`pending`?`idle`:e.progress.state===`cancelled`?`aborted`:e.progress.state,progress:e.progress.progress,bytesUploaded:e.progress.uploadedBytes,totalBytes:e.progress.totalBytes,error:e.progress.error||null,result:e.result??null}})})]}),r&&e.progress.state!==`uploading`&&e.progress.state!==`pending`&&_(l,{style:$.removeButton,onPress:()=>t?.(e.id),hitSlop:{top:8,right:8,bottom:8,left:8},children:_(d,{style:$.removeButtonText,children:`✕`})})]}),keyExtractor:e=>e.id,ItemSeparatorComponent:()=>_(f,{style:$.separator}),contentContainerStyle:$.listContent})]})}function ge(e){switch(e){case`success`:return`#34C759`;case`error`:case`cancelled`:return`#FF3B30`;case`uploading`:case`pending`:return`#007AFF`;default:return`#999999`}}function _e(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*10)/10} ${n[r]}`}const $=u.create({container:{gap:8},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,paddingHorizontal:12,paddingVertical:8,backgroundColor:`#f9f9f9`,borderRadius:4},headerText:{fontSize:16,fontWeight:`600`,color:`#333333`},errorText:{fontSize:14,color:`#FF3B30`},headerSubtext:{fontSize:14,color:`#666666`},listContent:{gap:8},itemContainer:{flexDirection:`row`,alignItems:`center`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},itemContent:{flex:1,gap:6},itemHeader:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},fileName:{fontSize:14,fontWeight:`500`,color:`#333333`,flex:1},fileSize:{fontSize:12,color:`#999999`,marginLeft:8},progressWrapper:{marginTop:2},removeButton:{width:32,height:32,justifyContent:`center`,alignItems:`center`,borderRadius:16,backgroundColor:`#FFE5E5`},removeButtonText:{fontSize:16,fontWeight:`600`,color:`#FF3B30`},separator:{height:4},emptyContainer:{paddingVertical:24,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,alignItems:`center`,justifyContent:`center`},emptyText:{fontSize:14,color:`#999999`,fontStyle:`italic`}});export{fe as CameraUploadButton,pe as FileUploadButton,me as GalleryUploadButton,I as PermissionStatus,F as PermissionType,he as UploadList,J as UploadProgress,y as UploadistaContext,O as formatFileSize,se as getDirectoryFromUri,M as getFileExtension,G as getFileNameFromUri,N as getFileNameWithoutExtension,k as getMimeTypeFromFileName,de as getMimeTypeFromUri,U as getPermissionStatus,H as hasPermissions,ce as isContentUri,oe as isDocumentFile,j as isFileSizeValid,A as isFileTypeAllowed,le as isFileUri,P as isImageFile,ae as isVideoFile,ue as normalizeUri,W as openAppSettings,K as pathToUri,L as requestCameraPermission,V as requestPermissions,R as requestPhotoLibraryPermission,z as requestStorageReadPermission,B as requestStorageWritePermission,q as uriToPath,C as useCameraUpload,w as useFileUpload,re as useFlowUpload,D as useGalleryUpload,E as useMultiUpload,ie as useUploadMetrics,x as useUploadistaContext};
|
|
1
|
+
import e,{createContext as t,useCallback as n,useContext as r,useEffect as i,useRef as a,useState as o}from"react";import{ActivityIndicator as s,FlatList as c,Pressable as l,StyleSheet as u,Text as d,View as f}from"react-native";import{FlowManager as p,UploadManager as m}from"@uploadista/client-core";import{EventType as h}from"@uploadista/core/flow";import{UploadEventType as g}from"@uploadista/core/types";import{jsx as _,jsxs as v}from"react/jsx-runtime";const y=t(void 0);function b(e,t){let n=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Blob([n],t)}function x(){let e=r(y);if(!e)throw Error(`useUploadistaClient must be used within an UploadistaProvider`);return e}const ee={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,error:null,result:null};function S(e={}){let{client:t,fileSystemProvider:r}=x(),[s,c]=o(ee),l=a(null),u=a(null);return i(()=>(l.current=new m(async(e,n)=>{let i=e;if(i.status===`success`){let e=b(await r.readFile(i.data.uri),{type:i.data.mimeType||`application/octet-stream`});return t.upload(e,n)}return Promise.resolve({abort:()=>{}})},{onStateChange:c,onProgress:e.onProgress,onChunkComplete:e.onChunkComplete,onSuccess:e.onSuccess,onError:e.onError,onAbort:e.onAbort},{metadata:e.metadata,uploadLengthDeferred:e.uploadLengthDeferred,uploadSize:e.uploadSize,onShouldRetry:e.onShouldRetry}),()=>{l.current?.cleanup()}),[t,r,e]),{state:s,upload:n(async e=>{u.current=e,await l.current?.upload(e)},[]),abort:n(()=>{l.current?.abort()},[]),reset:n(()=>{l.current?.reset(),u.current=null},[]),retry:n(()=>{u.current&&l.current?.canRetry()&&l.current.retry()},[]),isUploading:s.status===`uploading`,canRetry:l.current?.canRetry()??!1,metrics:{getInsights:()=>t.getChunkingInsights(),exportMetrics:()=>t.exportMetrics(),getNetworkMetrics:()=>t.getNetworkMetrics(),getNetworkCondition:()=>t.getNetworkCondition(),resetMetrics:()=>t.resetMetrics()}}}function C(e){let{fileSystemProvider:t}=x(),r=S({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickCamera(e?.cameraOptions);await r.upload(n)}catch(e){console.error(`Camera capture error:`,e)}},[t,e?.cameraOptions,r]);return{...r,captureAndUpload:i}}function w(e){let{fileSystemProvider:t}=x(),r=S({metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError,onProgress:e?.onProgress}),i=n(async()=>{try{let n=await t.pickDocument({allowedTypes:e?.allowedTypes});await r.upload(n)}catch(e){throw console.error(`File selection error:`,e),e}},[t,e?.allowedTypes,r]);return{...r,pickAndUpload:i}}function te(e){let t=e;return t.eventType===h.FlowStart||t.eventType===h.FlowEnd||t.eventType===h.FlowError||t.eventType===h.NodeStart||t.eventType===h.NodeEnd||t.eventType===h.NodePause||t.eventType===h.NodeResume||t.eventType===h.NodeError}const T=t(void 0);function E({children:e}){let{client:t,subscribeToEvents:r}=x(),o=a(new Map);i(()=>r(e=>{if(te(e)){for(let t of o.current.values())t.manager.handleFlowEvent(e);return}if(`type`in e&&e.type===g.UPLOAD_PROGRESS&&`data`in e){let t=e;for(let e of o.current.values())e.manager.handleUploadProgress(t.uploadId,t.data.progress,t.data.total)}}),[r]);let s=n((e,n,r)=>{let i=o.current.get(e);if(i)return i.refCount++,i.manager;let a=new p((e,n,r)=>t.uploadWithFlow(e,n,r),n,r);return o.current.set(e,{manager:a,refCount:1,flowId:e}),a},[t]),c=n(e=>{let t=o.current.get(e);t&&(t.refCount--,t.refCount<=0&&(t.manager.cleanup(),o.current.delete(e)))},[]);return _(T.Provider,{value:{getManager:s,releaseManager:c},children:e})}function D(){let e=r(T);if(e===void 0)throw Error(`useFlowManagerContext must be used within a FlowManagerProvider. Make sure to wrap your component tree with <FlowManagerProvider>.`);return e}const ne={status:`idle`,progress:0,bytesUploaded:0,totalBytes:null,error:null,result:null,jobId:null,flowStarted:!1,currentNodeName:null,currentNodeType:null,flowOutputs:null};function re(e){let{getManager:t,releaseManager:r}=D(),{fileSystemProvider:s}=x(),[c,l]=o(ne),u=a(null),d=a(null),f=a(e);i(()=>{f.current=e}),i(()=>{let n=e.flowId;return u.current=t(n,{onStateChange:l,onProgress:(e,t,n)=>{if(f.current.onProgress){let e=n?Math.round(t/n*100):0;f.current.onProgress(e,t,n)}},onChunkComplete:(e,t,n)=>{f.current.onChunkComplete?.(e,t,n)},onFlowComplete:e=>{f.current.onFlowComplete?.(e)},onSuccess:e=>{f.current.onSuccess?.(e)},onError:e=>{f.current.onError?.(e)},onAbort:()=>{f.current.onAbort?.()}},{flowConfig:{flowId:e.flowId,storageId:e.storageId,outputNodeId:e.outputNodeId,metadata:e.metadata},onChunkComplete:e.onChunkComplete,onSuccess:e.onSuccess,onError:e.onError}),()=>{r(n),u.current=null}},[e.flowId,e.storageId,e.outputNodeId,t,r]);let p=n(async t=>{if(t.status!==`cancelled`){if(t.status===`error`){e.onError?.(t.error);return}d.current=t;try{let e=b(await s.readFile(t.data.uri),{type:t.data.mimeType||`application/octet-stream`});await u.current?.upload(e)}catch(t){e.onError?.(t)}}},[s,e]),m=n(()=>{u.current?.reset(),d.current=null},[]);return{state:c,upload:p,abort:n(()=>{u.current?.abort()},[]),reset:m,retry:n(()=>{d.current&&(c.status===`error`||c.status===`aborted`)&&p(d.current)},[p,c.status]),isActive:c.status===`uploading`||c.status===`processing`,canRetry:(c.status===`error`||c.status===`aborted`)&&d.current!==null}}const O={items:[],totalProgress:0,totalUploaded:0,totalBytes:0,activeCount:0,completedCount:0,failedCount:0};function k(e={}){let{client:t}=x(),[r,i]=o(O),s=a(new Map),c=a(0),l=a([]),u=n(()=>`upload-${Date.now()}-${c.current++}`,[]),d=n(e=>{let t=e.reduce((e,t)=>e+t.totalBytes,0),n=e.reduce((e,t)=>e+t.bytesUploaded,0),r=t>0?Math.round(n/t*100):0,a=e.filter(e=>e.status===`uploading`).length,o=e.filter(e=>e.status===`success`).length,s=e.filter(e=>e.status===`error`).length;l.current=e,i(i=>({...i,items:e,totalProgress:r,totalUploaded:n,totalBytes:t,activeCount:a,completedCount:o,failedCount:s}))},[]),f=n(e=>{let t=e.filter(e=>e.status===`success`).map(e=>({id:u(),file:e,status:`idle`,progress:0,bytesUploaded:0,totalBytes:e.data.size,error:null,result:null})),n=[...l.current,...t];return l.current=n,i(e=>{let t=n.reduce((e,t)=>e+t.totalBytes,0);return{...e,items:n,totalBytes:t}}),t.map(e=>e.id)},[u]),p=n(async n=>{try{console.log(`Uploading item:`,n.file.data.name),d(l.current.map(e=>e.id===n.id?{...e,status:`uploading`}:e));let r=await(await fetch(n.file.data.uri)).blob(),i=n.file.data.mimeType?new Blob([r],{type:n.file.data.mimeType}):r;console.log(`Uploading input:`,i);let a=await t.upload(i,{metadata:e.metadata,onProgress:(e,t,r)=>{let i=r?Math.round(t/r*100):0;d(l.current.map(e=>e.id===n.id?{...e,progress:i,bytesUploaded:t,totalBytes:r||e.totalBytes}:e))},onSuccess:t=>{d(l.current.map(e=>e.id===n.id?{...e,status:`success`,progress:100,result:t,bytesUploaded:t.size||e.totalBytes}:e)),e.onSuccess?.(t),s.current.delete(n.id)},onError:t=>{d(l.current.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e.onError?.(t),s.current.delete(n.id)}});s.current.set(n.id,a)}catch(t){console.error(`Error uploading item:`,t),d(l.current.map(e=>e.id===n.id?{...e,status:`error`,error:t}:e)),e.onError?.(t),s.current.delete(n.id)}},[t,e,d]),m=n(async t=>{let n=e.maxConcurrent||3,r=t?l.current.filter(e=>t.includes(e.id)&&e.status===`idle`):l.current.filter(e=>e.status===`idle`);console.log(`Items to upload:`,r.length,r);for(let e=0;e<r.length;e+=n){let t=r.slice(e,e+n);await Promise.all(t.map(e=>p(e)))}},[e.maxConcurrent,p]),h=n(e=>{let t=s.current.get(e);t&&(t.abort(),s.current.delete(e)),d(l.current.filter(t=>t.id!==e))},[d]),g=n(e=>{let t=s.current.get(e);t&&(t.abort(),s.current.delete(e)),d(l.current.map(t=>t.id===e?{...t,status:`aborted`}:t))},[d]),_=n(()=>{s.current.forEach(e=>{e.abort()}),s.current.clear(),l.current=[],i(O)},[]);return{state:r,addFiles:f,startUploads:m,removeItem:h,abortItem:g,retryItem:n(async e=>{let t=l.current.find(t=>t.id===e);if(t&&(t.status===`error`||t.status===`aborted`)){d(l.current.map(t=>t.id===e?{...t,status:`idle`,progress:0,bytesUploaded:0,error:null}:t));let t=l.current.find(t=>t.id===e);t&&await p(t)}},[p,d]),clear:_}}function A(e){let{fileSystemProvider:t}=x(),r=k({maxConcurrent:3,metadata:e?.metadata,onSuccess:e?.onSuccess,onError:e?.onError}),i=n(async()=>{let n;if(n=e?.mediaType===`video`?await t.pickVideo({allowMultiple:e?.allowMultiple??!0}):(e?.mediaType,await t.pickImage({allowMultiple:e?.allowMultiple??!0})),n.status===`cancelled`)return[];if(n.status===`error`)return console.error(`Gallery selection error:`,n.error),e?.onError?.(n.error),[];let i=r.addFiles([n]);return await r.startUploads(i),i},[t,e?.allowMultiple,e?.mediaType,e?.onError,r]);return{...r,selectAndUpload:i}}function ie(){let e=a(null),t=a(0),r=a(0),[i,s]=o({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0});return{metrics:i,start:n(()=>{e.current=Date.now(),t.current=0,r.current=0},[]),update:n((t,n,i=0)=>{if(!e.current)return;let a=Date.now()-e.current,o=a>0?t/a*1e3:0;o>r.current&&(r.current=o),s({totalBytes:t,durationMs:a,avgSpeed:a>0?t/a*1e3:0,peakSpeed:r.current,retries:i})},[]),end:n(()=>{let t=i;return e.current=null,t},[i]),reset:n(()=>{e.current=null,t.current=0,r.current=0,s({totalBytes:0,durationMs:0,avgSpeed:0,peakSpeed:0,retries:0})},[])}}function j(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*100)/100} ${n[r]}`}function M(e){return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".svg":`image/svg+xml`,".mp4":`video/mp4`,".avi":`video/x-msvideo`,".mov":`video/quicktime`,".wmv":`video/x-ms-wmv`,".flv":`video/x-flv`,".mkv":`video/x-matroska`,".webm":`video/webm`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".flac":`audio/flac`,".m4a":`audio/mp4`,".pdf":`application/pdf`,".doc":`application/msword`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xls":`application/vnd.ms-excel`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".ppt":`application/vnd.ms-powerpoint`,".pptx":`application/vnd.openxmlformats-officedocument.presentationml.presentation`,".txt":`text/plain`,".csv":`text/csv`,".json":`application/json`,".xml":`application/xml`,".zip":`application/zip`}[e.toLowerCase().slice(e.lastIndexOf(`.`))]||`application/octet-stream`}function N(e,t){if(!t||t.length===0)return!0;let n=M(e);return t.some(e=>{if(e.endsWith(`/*`)){let[t]=e.split(`/`);return n.startsWith(`${t}/`)}return e===n})}function P(e,t,n){return!(t!==void 0&&e>t||n!==void 0&&e<n)}function F(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function ae(e){let t=e.lastIndexOf(`.`);return t===-1?e:e.slice(0,t)}function oe(e){let t=[`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.webp`,`.svg`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function se(e){let t=[`.mp4`,`.avi`,`.mov`,`.wmv`,`.flv`,`.mkv`,`.webm`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}function ce(e){let t=[`.pdf`,`.doc`,`.docx`,`.xls`,`.xlsx`,`.ppt`,`.pptx`,`.txt`,`.csv`],n=e.toLowerCase().slice(e.lastIndexOf(`.`));return t.includes(n)}let I=function(e){return e.CAMERA=`CAMERA`,e.PHOTO_LIBRARY=`PHOTO_LIBRARY`,e.WRITE_STORAGE=`WRITE_STORAGE`,e.READ_STORAGE=`READ_STORAGE`,e}({}),L=function(e){return e.GRANTED=`granted`,e.DENIED=`denied`,e.NOT_DETERMINED=`not_determined`,e.RESTRICTED=`restricted`,e}({});async function R(){try{return console.log(`Camera permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request camera permission:`,e),!1}}async function z(){try{return console.log(`Photo library permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request photo library permission:`,e),!1}}async function B(){try{return console.log(`Storage read permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage read permission:`,e),!1}}async function V(){try{return console.log(`Storage write permission requested (handled by file system provider)`),!0}catch(e){return console.error(`Failed to request storage write permission:`,e),!1}}async function H(e){try{return(await Promise.all(e.map(async e=>{switch(e){case I.CAMERA:return R();case I.PHOTO_LIBRARY:return z();case I.READ_STORAGE:return B();case I.WRITE_STORAGE:return V();default:return!1}}))).every(e=>e)}catch(e){return console.error(`Failed to request permissions:`,e),!1}}async function U(e){try{return!0}catch(e){return console.error(`Failed to check permissions:`,e),!1}}async function W(e){try{return L.GRANTED}catch(e){return console.error(`Failed to get permission status:`,e),L.DENIED}}function le(){try{console.log(`Opening app settings (requires react-native-app-settings or platform implementation)`)}catch(e){console.error(`Failed to open app settings:`,e)}}function G(e){try{if(e.startsWith(`file://`))return e.replace(`file://`,``).split(`/`).pop()||`file`;if(e.startsWith(`content://`)){let t=e.split(`/`);return t[t.length-1]||`file`}let t=e.split(`/`);return t[t.length-1]||`file`}catch{return`file`}}function ue(e){return e.startsWith(`file://`)||e.startsWith(`content://`)?e:`file://${e}`}function K(e){return e.startsWith(`file://`)?e.replace(`file://`,``):(e.startsWith(`content://`),e)}function de(e){try{let t=K(e).split(`/`);return t.pop(),t.join(`/`)}catch{return``}}function fe(e){return e.startsWith(`content://`)}function pe(e){return e.startsWith(`file://`)}function me(e){return e.replace(/([^:]\/)\/+/g,`$1`)}function he(e){let t=G(e);return{".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".bmp":`image/bmp`,".webp":`image/webp`,".mp4":`video/mp4`,".mov":`video/quicktime`,".avi":`video/x-msvideo`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".aac":`audio/aac`,".pdf":`application/pdf`,".txt":`text/plain`,".json":`application/json`}[t.toLowerCase().slice(t.lastIndexOf(`.`))]||`application/octet-stream`}function q({state:e,label:t}){let n=()=>{switch(e.status){case`uploading`:return`#007AFF`;case`success`:return`#34C759`;case`error`:case`aborted`:return`#FF3B30`;default:return`#999999`}};return v(f,{style:[J.wrapper,{borderLeftColor:n()}],children:[e.status===`uploading`&&_(s,{size:`small`,color:n(),style:J.spinner}),(()=>{switch(e.status){case`idle`:return _(f,{style:J.container,children:_(d,{style:J.label,children:t||`Ready to upload`})});case`uploading`:return v(f,{style:J.container,children:[v(f,{style:J.headerRow,children:[_(d,{style:J.label,children:t||`Uploading`}),v(d,{style:J.percentage,children:[e.progress,`%`]})]}),_(f,{style:J.progressBarContainer,children:_(f,{style:[J.progressBar,{width:`${e.progress}%`,backgroundColor:n()}]})}),_(f,{style:J.detailsRow,children:v(d,{style:J.detail,children:[j(e.bytesUploaded),` /`,` `,j(e.totalBytes||0)]})})]});case`success`:return v(f,{style:J.container,children:[v(f,{style:J.headerRow,children:[_(d,{style:[J.label,{color:n()}],children:t||`Upload complete`}),_(d,{style:[J.percentage,{color:n()}],children:`✓`})]}),_(d,{style:[J.detail,{color:n()}],children:j(e.totalBytes||0)})]});case`error`:return v(f,{style:J.container,children:[v(f,{style:J.headerRow,children:[_(d,{style:[J.label,{color:n()}],children:t||`Upload failed`}),_(d,{style:[J.percentage,{color:n()}],children:`✕`})]}),e.error&&_(d,{style:[J.detail,{color:n()}],children:e.error.message})]});case`aborted`:return _(f,{style:J.container,children:_(d,{style:[J.label,{color:n()}],children:t||`Upload cancelled`})});default:return null}})()]})}const J=u.create({wrapper:{flexDirection:`row`,alignItems:`flex-start`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},spinner:{marginTop:4},container:{flex:1,gap:4},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},label:{fontSize:14,fontWeight:`600`,color:`#333333`,flex:1},percentage:{fontSize:14,fontWeight:`600`,color:`#007AFF`,minWidth:36,textAlign:`right`},progressBarContainer:{height:4,backgroundColor:`#e0e0e0`,borderRadius:2,overflow:`hidden`},progressBar:{height:`100%`,borderRadius:2},detailsRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},detail:{fontSize:12,color:`#666666`}});function ge({options:e,label:t=`Take Photo`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,captureAndUpload:p}=C(e),m=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},h=u.status===`uploading`,g=h||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),v(f,{style:Y.container,children:[v(l,{style:[Y.button,g&&Y.buttonDisabled],onPress:m,disabled:g,children:[h&&_(s,{size:`small`,color:`#FFFFFF`,style:Y.spinner}),_(d,{style:Y.buttonText,children:n||t})]}),c&&u.status!==`idle`&&_(f,{style:Y.progressContainer,children:_(q,{state:u,label:`Camera upload`})})]})}const Y=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#007AFF`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function _e({options:e,label:t=`Choose File`,children:n,onSuccess:r,onError:a,onCancel:o,showProgress:c=!0}){let{state:u,pickAndUpload:p}=w(e),m=async()=>{try{await p()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},h=u.status===`uploading`,g=h||u.status===`aborted`;return i(()=>{u.status===`success`&&u.result&&r?.(u.result)},[u.status,u.result,r]),i(()=>{u.status===`error`&&u.error&&a?.(u.error)},[u.status,u.error,a]),v(f,{style:X.container,children:[v(l,{style:[X.button,g&&X.buttonDisabled],onPress:m,disabled:g,children:[h&&_(s,{size:`small`,color:`#FFFFFF`,style:X.spinner}),_(d,{style:X.buttonText,children:n||t})]}),c&&u.status!==`idle`&&_(f,{style:X.progressContainer,children:_(q,{state:u,label:`File upload`})})]})}const X=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#FF9500`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},progressContainer:{marginTop:4}});function Z({options:t,label:n=`Select from Gallery`,children:r,onSuccess:i,onError:a,onCancel:o,showProgress:u=!0}){let{state:p,selectAndUpload:m}=A(t),h=async()=>{try{await m()}catch(e){e instanceof Error&&(e.message.includes(`cancelled`)||e.message.includes(`aborted`)?o?.():a?.(e))}},g=p.items.some(e=>e.status===`uploading`),y=p.items.length>0,b=y&&p.items.every(e=>e.status!==`uploading`&&e.status!==`idle`);return e.useEffect(()=>{if(b){let e=p.items.filter(e=>e.status===`success`).map(e=>e.result);e.length>0&&i?.(e)}},[b,p.items,i]),e.useEffect(()=>{let e=p.items.filter(e=>e.status===`error`)[0]?.error;e&&a?.(e)},[p.items,a]),v(f,{style:Q.container,children:[v(l,{style:[Q.button,g&&Q.buttonDisabled],onPress:h,disabled:g,children:[g&&_(s,{size:`small`,color:`#FFFFFF`,style:Q.spinner}),v(d,{style:Q.buttonText,children:[r||n,y&&` (${p.items.length})`]})]}),y&&v(f,{style:Q.statsContainer,children:[v(d,{style:Q.statsText,children:[`Progress: `,p.items.filter(e=>e.status===`success`).length,`/`,p.items.length,` uploaded`]}),v(d,{style:Q.statsText,children:[`Overall: `,p.totalProgress,`%`]})]}),u&&y&&_(c,{scrollEnabled:!1,data:p.items,renderItem:({item:e})=>_(f,{style:Q.itemContainer,children:_(q,{state:{status:e.status,progress:e.progress,bytesUploaded:e.bytesUploaded,totalBytes:e.totalBytes,error:e.error,result:e.result},label:e.file.data.name})},e.id),keyExtractor:e=>e.id,style:Q.listContainer,contentContainerStyle:Q.listContent,ItemSeparatorComponent:()=>_(f,{style:Q.separator})})]})}const Q=u.create({container:{gap:8},button:{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,paddingVertical:12,paddingHorizontal:16,backgroundColor:`#34C759`,borderRadius:8,gap:8},buttonDisabled:{opacity:.6},buttonText:{fontSize:16,fontWeight:`600`,color:`#FFFFFF`},spinner:{marginRight:4},statsContainer:{paddingVertical:8,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,gap:4},statsText:{fontSize:12,color:`#666666`},listContainer:{maxHeight:400},listContent:{gap:8},itemContainer:{paddingHorizontal:0},separator:{height:4}});function ve({items:e,onRemove:t,onItemPress:n,showRemoveButton:r=!0}){return e.length===0?_(f,{style:$.emptyContainer,children:_(d,{style:$.emptyText,children:`No uploads`})}):v(f,{style:$.container,children:[v(f,{style:$.headerRow,children:[v(d,{style:$.headerText,children:[`Uploads (`,e.length,`)`]}),v(d,{style:$.headerSubtext,children:[e.filter(e=>e.progress.state===`success`).length,` complete`]})]}),_(c,{scrollEnabled:!1,data:e,renderItem:({item:e})=>v(l,{style:[$.itemContainer,{borderLeftColor:ye(e.progress.state)}],onPress:()=>n?.(e),children:[v(f,{style:$.itemContent,children:[e.file.status===`success`&&v(f,{style:$.itemHeader,children:[_(d,{style:$.fileName,numberOfLines:1,children:e.file.data.name}),_(d,{style:$.fileSize,children:be(e.file.data.size)})]}),e.file.status===`error`&&_(d,{style:$.errorText,children:e.progress.error?.message}),_(f,{style:$.progressWrapper,children:_(q,{state:{status:e.progress.state===`pending`?`idle`:e.progress.state===`cancelled`?`aborted`:e.progress.state,progress:e.progress.progress,bytesUploaded:e.progress.uploadedBytes,totalBytes:e.progress.totalBytes,error:e.progress.error||null,result:e.result??null}})})]}),r&&e.progress.state!==`uploading`&&e.progress.state!==`pending`&&_(l,{style:$.removeButton,onPress:()=>t?.(e.id),hitSlop:{top:8,right:8,bottom:8,left:8},children:_(d,{style:$.removeButtonText,children:`✕`})})]}),keyExtractor:e=>e.id,ItemSeparatorComponent:()=>_(f,{style:$.separator}),contentContainerStyle:$.listContent})]})}function ye(e){switch(e){case`success`:return`#34C759`;case`error`:case`cancelled`:return`#FF3B30`;case`uploading`:case`pending`:return`#007AFF`;default:return`#999999`}}function be(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Math.round(e/t**r*10)/10} ${n[r]}`}const $=u.create({container:{gap:8},headerRow:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,paddingHorizontal:12,paddingVertical:8,backgroundColor:`#f9f9f9`,borderRadius:4},headerText:{fontSize:16,fontWeight:`600`,color:`#333333`},errorText:{fontSize:14,color:`#FF3B30`},headerSubtext:{fontSize:14,color:`#666666`},listContent:{gap:8},itemContainer:{flexDirection:`row`,alignItems:`center`,paddingVertical:8,paddingHorizontal:12,borderLeftWidth:4,backgroundColor:`#f5f5f5`,borderRadius:4,gap:8},itemContent:{flex:1,gap:6},itemHeader:{flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`},fileName:{fontSize:14,fontWeight:`500`,color:`#333333`,flex:1},fileSize:{fontSize:12,color:`#999999`,marginLeft:8},progressWrapper:{marginTop:2},removeButton:{width:32,height:32,justifyContent:`center`,alignItems:`center`,borderRadius:16,backgroundColor:`#FFE5E5`},removeButtonText:{fontSize:16,fontWeight:`600`,color:`#FF3B30`},separator:{height:4},emptyContainer:{paddingVertical:24,paddingHorizontal:12,backgroundColor:`#f5f5f5`,borderRadius:4,alignItems:`center`,justifyContent:`center`},emptyText:{fontSize:14,color:`#999999`,fontStyle:`italic`}});export{ge as CameraUploadButton,_e as FileUploadButton,E as FlowManagerProvider,Z as GalleryUploadButton,L as PermissionStatus,I as PermissionType,ve as UploadList,q as UploadProgress,y as UploadistaContext,j as formatFileSize,de as getDirectoryFromUri,F as getFileExtension,G as getFileNameFromUri,ae as getFileNameWithoutExtension,M as getMimeTypeFromFileName,he as getMimeTypeFromUri,W as getPermissionStatus,U as hasPermissions,fe as isContentUri,ce as isDocumentFile,P as isFileSizeValid,N as isFileTypeAllowed,pe as isFileUri,oe as isImageFile,se as isVideoFile,me as normalizeUri,le as openAppSettings,ue as pathToUri,R as requestCameraPermission,H as requestPermissions,z as requestPhotoLibraryPermission,B as requestStorageReadPermission,V as requestStorageWritePermission,K as uriToPath,C as useCameraUpload,w as useFileUpload,D as useFlowManagerContext,re as useFlowUpload,A as useGalleryUpload,k as useMultiUpload,ie as useUploadMetrics,x as useUploadistaContext};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|