@uploadista/react-native-core 0.0.20-beta.6 → 0.0.20-beta.8

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 CHANGED
@@ -1,10 +1,10 @@
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, FlowManager, FlowManagerCallbacks, FlowUploadOptions, FlowUploadState, FlowUploadStatus, HttpClient, IdGenerationService, InputExecutionState, 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, FlowUploadState as FlowUploadState$1, FlowUploadStatus, FlowUploadStatus as FlowUploadStatus$1, HttpClient, IdGenerationService, InputExecutionState, InputExecutionState as InputExecutionState$1, ServiceContainer, ServiceContainer as ServiceContainer$1, StorageService, UploadState, UploadStatus, UploadistaClientOptions, UploadistaEvent } from "@uploadista/client-core";
5
5
  import { TypedOutput } from "@uploadista/core/flow";
6
6
  import { UploadFile } from "@uploadista/core/types";
7
- import * as react_jsx_runtime3 from "react/jsx-runtime";
7
+ import * as react_jsx_runtime12 from "react/jsx-runtime";
8
8
  import * as _uploadista_core0 from "@uploadista/core";
9
9
 
10
10
  //#region src/types/types.d.ts
@@ -283,7 +283,7 @@ declare function CameraUploadButton({
283
283
  onError,
284
284
  onCancel,
285
285
  showProgress
286
- }: CameraUploadButtonProps): react_jsx_runtime3.JSX.Element;
286
+ }: CameraUploadButtonProps): react_jsx_runtime12.JSX.Element;
287
287
  //#endregion
288
288
  //#region src/components/FileUploadButton.d.ts
289
289
  interface FileUploadButtonProps {
@@ -314,7 +314,7 @@ declare function FileUploadButton({
314
314
  onError,
315
315
  onCancel,
316
316
  showProgress
317
- }: FileUploadButtonProps): react_jsx_runtime3.JSX.Element;
317
+ }: FileUploadButtonProps): react_jsx_runtime12.JSX.Element;
318
318
  //#endregion
319
319
  //#region src/components/GalleryUploadButton.d.ts
320
320
  interface GalleryUploadButtonProps {
@@ -345,7 +345,7 @@ declare function GalleryUploadButton({
345
345
  onError,
346
346
  onCancel,
347
347
  showProgress
348
- }: GalleryUploadButtonProps): react_jsx_runtime3.JSX.Element;
348
+ }: GalleryUploadButtonProps): react_jsx_runtime12.JSX.Element;
349
349
  //#endregion
350
350
  //#region src/components/UploadList.d.ts
351
351
  interface UploadListProps {
@@ -367,7 +367,7 @@ declare function UploadList({
367
367
  onRemove,
368
368
  onItemPress,
369
369
  showRemoveButton
370
- }: UploadListProps): react_jsx_runtime3.JSX.Element;
370
+ }: UploadListProps): react_jsx_runtime12.JSX.Element;
371
371
  //#endregion
372
372
  //#region src/components/UploadProgress.d.ts
373
373
  interface UploadProgressProps {
@@ -382,7 +382,745 @@ interface UploadProgressProps {
382
382
  declare function UploadProgress({
383
383
  state,
384
384
  label
385
- }: UploadProgressProps): react_jsx_runtime3.JSX.Element;
385
+ }: UploadProgressProps): react_jsx_runtime12.JSX.Element;
386
+ //#endregion
387
+ //#region src/hooks/use-flow.d.ts
388
+ /**
389
+ * Input metadata discovered from the flow
390
+ */
391
+ interface FlowInputMetadata {
392
+ /** Input node ID */
393
+ nodeId: string;
394
+ /** Human-readable node name */
395
+ nodeName: string;
396
+ /** Node description explaining what input is needed */
397
+ nodeDescription: string;
398
+ /** Input type ID from inputTypeRegistry - describes how clients interact with this node */
399
+ inputTypeId?: string;
400
+ /** Whether this input is required */
401
+ required: boolean;
402
+ }
403
+ /**
404
+ * Options for the useFlow hook
405
+ */
406
+ interface UseFlowOptions {
407
+ /** Flow ID to execute */
408
+ flowId: string;
409
+ /** Storage ID for the upload */
410
+ storageId: string;
411
+ /** Output node ID for the flow */
412
+ outputNodeId?: string;
413
+ /** Metadata to pass to flow */
414
+ metadata?: Record<string, unknown>;
415
+ /** Called when upload succeeds (receives typed outputs from all output nodes) */
416
+ onSuccess?: (outputs: TypedOutput[]) => void;
417
+ /** Called when the flow completes successfully (receives full flow outputs) */
418
+ onFlowComplete?: (outputs: TypedOutput[]) => void;
419
+ /** Called when upload fails */
420
+ onError?: (error: Error) => void;
421
+ /** Called when upload progress updates */
422
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
423
+ /** Called when a chunk completes */
424
+ onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
425
+ }
426
+ /**
427
+ * Return value from the useFlow hook with upload control methods and state.
428
+ *
429
+ * @property state - Complete flow upload state with progress and outputs
430
+ * @property inputMetadata - Metadata about discovered input nodes (null until discovered)
431
+ * @property inputStates - Per-input execution state for multi-input flows
432
+ * @property inputs - Current input values set via setInput()
433
+ * @property setInput - Set an input value for a specific node (for progressive provision)
434
+ * @property execute - Execute the flow with current inputs (auto-detects types)
435
+ * @property upload - Convenience method for single-file upload (same as execute with one file input)
436
+ * @property abort - Cancel the current upload and flow execution
437
+ * @property reset - Reset state to idle (clears all data)
438
+ * @property retry - Retry the last failed upload
439
+ * @property isActive - True when upload or processing is active
440
+ * @property isUploadingFile - True only during file upload phase
441
+ * @property isProcessing - True only during flow processing phase
442
+ * @property isDiscoveringInputs - True while discovering flow inputs
443
+ * @property canRetry - True if a retry is possible
444
+ */
445
+ interface UseFlowReturn {
446
+ /**
447
+ * Current upload state
448
+ */
449
+ state: FlowUploadState;
450
+ /**
451
+ * Discovered input nodes metadata (null until discovery completes)
452
+ */
453
+ inputMetadata: FlowInputMetadata[] | null;
454
+ /**
455
+ * Per-input execution state for multi-input flows
456
+ */
457
+ inputStates: ReadonlyMap<string, InputExecutionState>;
458
+ /**
459
+ * Current inputs set via setInput()
460
+ */
461
+ inputs: Record<string, unknown>;
462
+ /**
463
+ * Set an input value for a specific node.
464
+ * For progressive input provision before calling execute().
465
+ *
466
+ * @param nodeId - The input node ID
467
+ * @param value - The input value (FilePickResult, URL string, or structured data)
468
+ */
469
+ setInput: (nodeId: string, value: FilePickResult | string | unknown) => void;
470
+ /**
471
+ * Execute the flow with current inputs.
472
+ * Automatically detects input types and routes appropriately.
473
+ * For single input, uses standard upload path.
474
+ * For multiple inputs, requires multiInputUploadFn.
475
+ */
476
+ execute: () => Promise<void>;
477
+ /**
478
+ * Upload a single file through the flow (convenience method).
479
+ * Equivalent to setInput(firstNodeId, file) + execute().
480
+ *
481
+ * @param file - FilePickResult from a picker
482
+ */
483
+ upload: (file: FilePickResult) => Promise<void>;
484
+ /**
485
+ * Abort the current upload
486
+ */
487
+ abort: () => void;
488
+ /**
489
+ * Reset the upload state and clear all inputs
490
+ */
491
+ reset: () => void;
492
+ /**
493
+ * Retry the last failed upload
494
+ */
495
+ retry: () => void;
496
+ /**
497
+ * Whether an upload or flow execution is in progress (uploading OR processing)
498
+ */
499
+ isActive: boolean;
500
+ /**
501
+ * Whether the file is currently being uploaded (chunks being sent)
502
+ */
503
+ isUploadingFile: boolean;
504
+ /**
505
+ * Whether the flow is currently processing (after upload completes)
506
+ */
507
+ isProcessing: boolean;
508
+ /**
509
+ * Whether the hook is discovering flow inputs
510
+ */
511
+ isDiscoveringInputs: boolean;
512
+ /**
513
+ * Whether a retry is possible (after error or abort with stored inputs)
514
+ */
515
+ canRetry: boolean;
516
+ }
517
+ /**
518
+ * React Native hook for executing flows with single or multiple inputs.
519
+ * Automatically discovers input nodes and detects input types (File, URL, structured data).
520
+ * Supports progressive input provision via setInput() and execute().
521
+ *
522
+ * This is the unified flow hook that replaces useFlowUpload for advanced use cases.
523
+ * It provides:
524
+ * - Auto-discovery of flow input nodes
525
+ * - Automatic input type detection (FilePickResult -> upload, string -> URL, object -> data)
526
+ * - Progressive input provision via setInput()
527
+ * - Multi-input support with parallel coordination
528
+ * - Per-input state tracking
529
+ *
530
+ * Must be used within FlowManagerProvider (which must be within UploadistaProvider).
531
+ * Flow events are automatically routed by the provider to the appropriate manager.
532
+ *
533
+ * @param options - Flow upload configuration including flow ID and event handlers
534
+ * @returns Flow upload state and control methods
535
+ *
536
+ * @example
537
+ * ```tsx
538
+ * function MyComponent() {
539
+ * const flow = useFlow({
540
+ * flowId: 'image-processing-flow',
541
+ * storageId: 'my-storage',
542
+ * onSuccess: (outputs) => console.log('Flow complete:', outputs),
543
+ * onError: (error) => console.error('Flow failed:', error),
544
+ * });
545
+ *
546
+ * const handlePickFile = async () => {
547
+ * const file = await fileSystemProvider.pickDocument();
548
+ * if (file) {
549
+ * await flow.upload(file);
550
+ * }
551
+ * };
552
+ *
553
+ * return (
554
+ * <View>
555
+ * <Button title="Pick File" onPress={handlePickFile} />
556
+ * {flow.isActive && <Text>Progress: {flow.state.progress}%</Text>}
557
+ * {flow.inputMetadata && (
558
+ * <Text>Found {flow.inputMetadata.length} input nodes</Text>
559
+ * )}
560
+ * <Button title="Abort" onPress={flow.abort} disabled={!flow.isActive} />
561
+ * </View>
562
+ * );
563
+ * }
564
+ * ```
565
+ *
566
+ * @example
567
+ * ```tsx
568
+ * // Multi-input flow
569
+ * function MultiInputComponent() {
570
+ * const flow = useFlow({
571
+ * flowId: 'multi-source-flow',
572
+ * storageId: 'my-storage',
573
+ * });
574
+ *
575
+ * const handlePickPrimary = async () => {
576
+ * const file = await fileSystemProvider.pickDocument();
577
+ * if (file.status === 'success') {
578
+ * flow.setInput('primary-input', file);
579
+ * }
580
+ * };
581
+ *
582
+ * const handleSetUrl = (url: string) => {
583
+ * flow.setInput('url-input', url);
584
+ * };
585
+ *
586
+ * return (
587
+ * <View>
588
+ * <Button title="Pick Primary" onPress={handlePickPrimary} />
589
+ * <TextInput onChangeText={handleSetUrl} placeholder="Enter URL" />
590
+ * <Button title="Execute" onPress={flow.execute} />
591
+ * </View>
592
+ * );
593
+ * }
594
+ * ```
595
+ *
596
+ * @see {@link useFlowUpload} for a simpler file-only upload hook
597
+ */
598
+ declare function useFlow(options: UseFlowOptions): UseFlowReturn;
599
+ //#endregion
600
+ //#region src/components/flow-primitives.d.ts
601
+ /**
602
+ * Context value provided by the Flow component root.
603
+ * Contains all flow state and actions.
604
+ */
605
+ interface FlowContextValue {
606
+ /** Current upload state */
607
+ state: FlowUploadState$1;
608
+ /** Discovered input nodes metadata (null until discovery completes) */
609
+ inputMetadata: FlowInputMetadata[] | null;
610
+ /** Current input values set via setInput() */
611
+ inputs: Record<string, unknown>;
612
+ /** Per-input execution state for multi-input flows */
613
+ inputStates: ReadonlyMap<string, InputExecutionState$1>;
614
+ /** Set an input value for a specific node */
615
+ setInput: (nodeId: string, value: unknown) => void;
616
+ /** Execute the flow with current inputs */
617
+ execute: () => Promise<void>;
618
+ /** Upload a single file through the flow */
619
+ upload: (file: FilePickResult) => Promise<void>;
620
+ /** Abort the current upload */
621
+ abort: () => void;
622
+ /** Reset the upload state and clear all inputs */
623
+ reset: () => void;
624
+ /** Whether an upload or flow execution is in progress */
625
+ isActive: boolean;
626
+ /** Whether the file is currently being uploaded */
627
+ isUploadingFile: boolean;
628
+ /** Whether the flow is currently processing */
629
+ isProcessing: boolean;
630
+ /** Whether the hook is discovering flow inputs */
631
+ isDiscoveringInputs: boolean;
632
+ /** Pick a file and set it for a specific input node */
633
+ pickFileForInput: (nodeId: string) => Promise<void>;
634
+ /** Pick a file and start upload immediately (single-file flows) */
635
+ pickAndUpload: () => Promise<void>;
636
+ }
637
+ /**
638
+ * Hook to access flow context from within a Flow component.
639
+ * @throws Error if used outside of a Flow component
640
+ */
641
+ declare function useFlowContext(): FlowContextValue;
642
+ /**
643
+ * Context value for a specific input node within a Flow.
644
+ */
645
+ interface FlowInputContextValue {
646
+ /** Input node ID */
647
+ nodeId: string;
648
+ /** Input metadata from flow discovery */
649
+ metadata: FlowInputMetadata;
650
+ /** Current value for this input */
651
+ value: unknown;
652
+ /** Set the value for this input */
653
+ setValue: (value: unknown) => void;
654
+ /** Per-input execution state (if available) */
655
+ state: InputExecutionState$1 | undefined;
656
+ /** Pick a file for this input */
657
+ pickFile: () => Promise<void>;
658
+ }
659
+ /**
660
+ * Hook to access flow input context from within a Flow.Input component.
661
+ * @throws Error if used outside of a Flow.Input component
662
+ */
663
+ declare function useFlowInputContext(): FlowInputContextValue;
664
+ /**
665
+ * Render props for the Flow root component.
666
+ */
667
+ interface FlowRenderProps extends FlowContextValue {
668
+ /** Alias for execute() */
669
+ submit: () => Promise<void>;
670
+ /** Alias for abort() */
671
+ cancel: () => void;
672
+ }
673
+ /**
674
+ * Props for the Flow root component.
675
+ */
676
+ interface FlowProps {
677
+ /** Flow ID to execute */
678
+ flowId: string;
679
+ /** Storage ID for file uploads */
680
+ storageId: string;
681
+ /** Optional output node ID to wait for */
682
+ outputNodeId?: string;
683
+ /** Optional metadata to include with the flow execution */
684
+ metadata?: Record<string, string>;
685
+ /** Called when flow completes successfully */
686
+ onSuccess?: (outputs: TypedOutput[]) => void;
687
+ /** Called when flow fails */
688
+ onError?: (error: Error) => void;
689
+ /** Called on upload progress */
690
+ onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
691
+ /** Called when flow completes with all outputs */
692
+ onFlowComplete?: (outputs: TypedOutput[]) => void;
693
+ /** Children to render (can be render function or ReactNode) */
694
+ children: ReactNode | ((props: FlowRenderProps) => ReactNode);
695
+ }
696
+ /**
697
+ * Root component for flow-based uploads on React Native.
698
+ * Provides context for all Flow sub-components.
699
+ *
700
+ * @example
701
+ * ```tsx
702
+ * <Flow flowId="image-optimizer" storageId="s3" onSuccess={handleSuccess}>
703
+ * <Flow.Inputs>
704
+ * {({ inputs, isLoading }) => (
705
+ * inputs.map(input => (
706
+ * <Flow.Input key={input.nodeId} nodeId={input.nodeId}>
707
+ * {({ metadata, pickFile }) => (
708
+ * <Button onPress={pickFile} title={metadata.nodeName} />
709
+ * )}
710
+ * </Flow.Input>
711
+ * ))
712
+ * )}
713
+ * </Flow.Inputs>
714
+ * <Flow.Submit>
715
+ * <Text>Process</Text>
716
+ * </Flow.Submit>
717
+ * </Flow>
718
+ * ```
719
+ */
720
+ declare function FlowRoot({
721
+ flowId,
722
+ storageId,
723
+ outputNodeId,
724
+ metadata,
725
+ onSuccess,
726
+ onError,
727
+ onProgress,
728
+ onFlowComplete,
729
+ children
730
+ }: FlowProps): react_jsx_runtime12.JSX.Element;
731
+ /**
732
+ * Render props for Flow.Inputs component.
733
+ */
734
+ interface FlowInputsRenderProps {
735
+ /** Discovered input metadata */
736
+ inputs: FlowInputMetadata[];
737
+ /** Whether inputs are still being discovered */
738
+ isLoading: boolean;
739
+ }
740
+ /**
741
+ * Props for Flow.Inputs component.
742
+ */
743
+ interface FlowInputsProps {
744
+ /** Render function receiving discovered inputs */
745
+ children: (props: FlowInputsRenderProps) => ReactNode;
746
+ }
747
+ /**
748
+ * Auto-discovers flow input nodes and provides them via render props.
749
+ *
750
+ * @example
751
+ * ```tsx
752
+ * <Flow.Inputs>
753
+ * {({ inputs, isLoading }) => (
754
+ * isLoading ? <ActivityIndicator /> : (
755
+ * inputs.map(input => (
756
+ * <Flow.Input key={input.nodeId} nodeId={input.nodeId}>
757
+ * ...
758
+ * </Flow.Input>
759
+ * ))
760
+ * )
761
+ * )}
762
+ * </Flow.Inputs>
763
+ * ```
764
+ */
765
+ declare function FlowInputs({
766
+ children
767
+ }: FlowInputsProps): react_jsx_runtime12.JSX.Element;
768
+ /**
769
+ * Props for Flow.Input component.
770
+ */
771
+ interface FlowInputProps {
772
+ /** Input node ID */
773
+ nodeId: string;
774
+ /** Children (can be render function or regular children) */
775
+ children: ReactNode | ((props: FlowInputContextValue) => ReactNode);
776
+ }
777
+ /**
778
+ * Scoped input context provider for a specific input node.
779
+ * Children can access input-specific state via useFlowInputContext().
780
+ *
781
+ * @example
782
+ * ```tsx
783
+ * <Flow.Input nodeId="video-input">
784
+ * {({ metadata, value, pickFile }) => (
785
+ * <View>
786
+ * <Text>{metadata.nodeName}</Text>
787
+ * <Button onPress={pickFile} title="Select File" />
788
+ * {value && <Text>Selected: {value.data?.name}</Text>}
789
+ * </View>
790
+ * )}
791
+ * </Flow.Input>
792
+ * ```
793
+ */
794
+ declare function FlowInput({
795
+ nodeId,
796
+ children
797
+ }: FlowInputProps): react_jsx_runtime12.JSX.Element | null;
798
+ /**
799
+ * Render props for Flow.Input.FilePicker component.
800
+ */
801
+ interface FlowInputFilePickerRenderProps {
802
+ /** Current value for this input */
803
+ value: unknown;
804
+ /** Whether a file is selected */
805
+ hasFile: boolean;
806
+ /** File name (if value is FilePickResult) */
807
+ fileName: string | null;
808
+ /** File size in bytes (if value is FilePickResult) */
809
+ fileSize: number | null;
810
+ /** Per-input progress (if available) */
811
+ progress: number;
812
+ /** Per-input status (if available) */
813
+ status: string;
814
+ /** Open file picker */
815
+ pickFile: () => Promise<void>;
816
+ /** Clear the input value */
817
+ clear: () => void;
818
+ }
819
+ /**
820
+ * Props for Flow.Input.FilePicker component.
821
+ */
822
+ interface FlowInputFilePickerProps {
823
+ /** Render function receiving file picker state */
824
+ children: (props: FlowInputFilePickerRenderProps) => ReactNode;
825
+ }
826
+ /**
827
+ * File picker for a specific input within a Flow.Input.
828
+ * Sets the input value but does NOT trigger upload until Flow.Submit is pressed.
829
+ */
830
+ declare function FlowInputFilePicker({
831
+ children
832
+ }: FlowInputFilePickerProps): react_jsx_runtime12.JSX.Element;
833
+ /**
834
+ * Render props for Flow.Input.Preview component.
835
+ */
836
+ interface FlowInputPreviewRenderProps {
837
+ /** Current value */
838
+ value: unknown;
839
+ /** Whether a file is selected */
840
+ hasFile: boolean;
841
+ /** Whether value is a URL string */
842
+ isUrl: boolean;
843
+ /** File name (if value is FilePickResult) */
844
+ fileName: string | null;
845
+ /** File size in bytes (if value is FilePickResult) */
846
+ fileSize: number | null;
847
+ /** File URI (if value is FilePickResult) */
848
+ fileUri: string | null;
849
+ /** Clear the input value */
850
+ clear: () => void;
851
+ }
852
+ /**
853
+ * Props for Flow.Input.Preview component.
854
+ */
855
+ interface FlowInputPreviewProps {
856
+ /** Render function receiving preview state */
857
+ children: (props: FlowInputPreviewRenderProps) => ReactNode;
858
+ }
859
+ /**
860
+ * Preview component for showing the selected value within a Flow.Input.
861
+ */
862
+ declare function FlowInputPreview({
863
+ children
864
+ }: FlowInputPreviewProps): react_jsx_runtime12.JSX.Element;
865
+ /**
866
+ * Render props for Flow.Progress component.
867
+ */
868
+ interface FlowProgressRenderProps {
869
+ /** Progress percentage (0-100) */
870
+ progress: number;
871
+ /** Bytes uploaded so far */
872
+ bytesUploaded: number;
873
+ /** Total bytes to upload (null if unknown) */
874
+ totalBytes: number | null;
875
+ /** Current status */
876
+ status: FlowUploadStatus$1;
877
+ }
878
+ /**
879
+ * Props for Flow.Progress component.
880
+ */
881
+ interface FlowProgressProps {
882
+ /** Render function receiving progress state */
883
+ children: (props: FlowProgressRenderProps) => ReactNode;
884
+ }
885
+ /**
886
+ * Progress display component within a Flow.
887
+ */
888
+ declare function FlowProgress({
889
+ children
890
+ }: FlowProgressProps): react_jsx_runtime12.JSX.Element;
891
+ /**
892
+ * Render props for Flow.Status component.
893
+ */
894
+ interface FlowStatusRenderProps {
895
+ /** Current status */
896
+ status: FlowUploadStatus$1;
897
+ /** Current node being processed (if any) */
898
+ currentNodeName: string | null;
899
+ /** Current node type (if any) */
900
+ currentNodeType: string | null;
901
+ /** Error (if status is error) */
902
+ error: Error | null;
903
+ /** Job ID (if started) */
904
+ jobId: string | null;
905
+ /** Whether flow has started */
906
+ flowStarted: boolean;
907
+ /** Flow outputs (if completed) */
908
+ flowOutputs: TypedOutput[] | null;
909
+ }
910
+ /**
911
+ * Props for Flow.Status component.
912
+ */
913
+ interface FlowStatusProps {
914
+ /** Render function receiving status state */
915
+ children: (props: FlowStatusRenderProps) => ReactNode;
916
+ }
917
+ /**
918
+ * Status display component within a Flow.
919
+ */
920
+ declare function FlowStatus({
921
+ children
922
+ }: FlowStatusProps): react_jsx_runtime12.JSX.Element;
923
+ /**
924
+ * Render props for Flow.Error component.
925
+ */
926
+ interface FlowErrorRenderProps {
927
+ /** Error object (null if no error) */
928
+ error: Error | null;
929
+ /** Whether there is an error */
930
+ hasError: boolean;
931
+ /** Error message */
932
+ message: string | null;
933
+ /** Reset the flow */
934
+ reset: () => void;
935
+ }
936
+ /**
937
+ * Props for Flow.Error component.
938
+ */
939
+ interface FlowErrorProps {
940
+ /** Render function receiving error state */
941
+ children: (props: FlowErrorRenderProps) => ReactNode;
942
+ }
943
+ /**
944
+ * Error display component within a Flow.
945
+ */
946
+ declare function FlowError({
947
+ children
948
+ }: FlowErrorProps): react_jsx_runtime12.JSX.Element;
949
+ /**
950
+ * Render props for Flow.Submit component.
951
+ */
952
+ interface FlowSubmitRenderProps {
953
+ /** Execute the flow */
954
+ submit: () => Promise<void>;
955
+ /** Whether the button should be disabled */
956
+ isDisabled: boolean;
957
+ /** Whether currently submitting */
958
+ isSubmitting: boolean;
959
+ }
960
+ /**
961
+ * Props for Flow.Submit component.
962
+ */
963
+ interface FlowSubmitProps {
964
+ /** Render function receiving submit state */
965
+ children: ReactNode | ((props: FlowSubmitRenderProps) => ReactNode);
966
+ /** Additional disabled state */
967
+ disabled?: boolean;
968
+ }
969
+ /**
970
+ * Submit primitive that executes the flow with current inputs.
971
+ * Provides render props for building custom submit buttons.
972
+ * Automatically disabled when uploading.
973
+ */
974
+ declare function FlowSubmit({
975
+ children,
976
+ disabled
977
+ }: FlowSubmitProps): react_jsx_runtime12.JSX.Element;
978
+ /**
979
+ * Render props for Flow.Cancel component.
980
+ */
981
+ interface FlowCancelRenderProps {
982
+ /** Cancel the flow */
983
+ cancel: () => void;
984
+ /** Whether the button should be disabled */
985
+ isDisabled: boolean;
986
+ }
987
+ /**
988
+ * Props for Flow.Cancel component.
989
+ */
990
+ interface FlowCancelProps {
991
+ /** Render function receiving cancel state */
992
+ children: ReactNode | ((props: FlowCancelRenderProps) => ReactNode);
993
+ }
994
+ /**
995
+ * Cancel primitive that aborts the current upload.
996
+ */
997
+ declare function FlowCancel({
998
+ children
999
+ }: FlowCancelProps): react_jsx_runtime12.JSX.Element;
1000
+ /**
1001
+ * Render props for Flow.Reset component.
1002
+ */
1003
+ interface FlowResetRenderProps {
1004
+ /** Reset the flow */
1005
+ reset: () => void;
1006
+ /** Whether the button should be disabled */
1007
+ isDisabled: boolean;
1008
+ }
1009
+ /**
1010
+ * Props for Flow.Reset component.
1011
+ */
1012
+ interface FlowResetProps {
1013
+ /** Render function receiving reset state */
1014
+ children: ReactNode | ((props: FlowResetRenderProps) => ReactNode);
1015
+ }
1016
+ /**
1017
+ * Reset primitive that clears all inputs and resets to idle state.
1018
+ */
1019
+ declare function FlowReset({
1020
+ children
1021
+ }: FlowResetProps): react_jsx_runtime12.JSX.Element;
1022
+ /**
1023
+ * Render props for Flow.QuickUpload component.
1024
+ */
1025
+ interface FlowQuickUploadRenderProps {
1026
+ /** Whether currently uploading */
1027
+ isUploading: boolean;
1028
+ /** Progress percentage (0-100) */
1029
+ progress: number;
1030
+ /** Current status */
1031
+ status: FlowUploadStatus$1;
1032
+ /** Pick a file and start upload immediately */
1033
+ pickAndUpload: () => Promise<void>;
1034
+ /** Abort the current upload */
1035
+ abort: () => void;
1036
+ }
1037
+ /**
1038
+ * Props for Flow.QuickUpload component.
1039
+ */
1040
+ interface FlowQuickUploadProps {
1041
+ /** Render function receiving quick upload state */
1042
+ children: (props: FlowQuickUploadRenderProps) => ReactNode;
1043
+ }
1044
+ /**
1045
+ * Quick upload component for single-file flows.
1046
+ * Picks a file and starts upload immediately.
1047
+ *
1048
+ * @example
1049
+ * ```tsx
1050
+ * <Flow.QuickUpload>
1051
+ * {({ isUploading, progress, pickAndUpload, abort }) => (
1052
+ * <Button
1053
+ * onPress={isUploading ? abort : pickAndUpload}
1054
+ * title={isUploading ? `Uploading ${progress}%` : 'Upload File'}
1055
+ * />
1056
+ * )}
1057
+ * </Flow.QuickUpload>
1058
+ * ```
1059
+ */
1060
+ declare function FlowQuickUpload({
1061
+ children
1062
+ }: FlowQuickUploadProps): react_jsx_runtime12.JSX.Element;
1063
+ /**
1064
+ * Flow compound component for flow-based file uploads on React Native.
1065
+ *
1066
+ * Provides a composable, headless API for building flow upload interfaces.
1067
+ * All sub-components use render props for complete UI control.
1068
+ *
1069
+ * @example Quick Upload (Single File)
1070
+ * ```tsx
1071
+ * <Flow flowId="image-optimizer" storageId="s3" onSuccess={handleSuccess}>
1072
+ * <Flow.QuickUpload>
1073
+ * {({ isUploading, progress, pickAndUpload, abort }) => (
1074
+ * <View>
1075
+ * <Button
1076
+ * onPress={isUploading ? abort : pickAndUpload}
1077
+ * title={isUploading ? 'Cancel' : 'Upload Image'}
1078
+ * />
1079
+ * {isUploading && <Text>{progress}%</Text>}
1080
+ * </View>
1081
+ * )}
1082
+ * </Flow.QuickUpload>
1083
+ * </Flow>
1084
+ * ```
1085
+ *
1086
+ * @example Multi-Input Flow
1087
+ * ```tsx
1088
+ * <Flow flowId="video-processor" storageId="s3">
1089
+ * <Flow.Inputs>
1090
+ * {({ inputs, isLoading }) => (
1091
+ * isLoading ? <ActivityIndicator /> : inputs.map(input => (
1092
+ * <Flow.Input key={input.nodeId} nodeId={input.nodeId}>
1093
+ * {({ metadata, pickFile, value }) => (
1094
+ * <View>
1095
+ * <Text>{metadata.nodeName}</Text>
1096
+ * <Button onPress={pickFile} title="Select File" />
1097
+ * <Flow.Input.Preview>
1098
+ * {({ hasFile, fileName }) => hasFile && <Text>{fileName}</Text>}
1099
+ * </Flow.Input.Preview>
1100
+ * </View>
1101
+ * )}
1102
+ * </Flow.Input>
1103
+ * ))
1104
+ * )}
1105
+ * </Flow.Inputs>
1106
+ * <CustomSubmitButton />
1107
+ * </Flow>
1108
+ * ```
1109
+ */
1110
+ declare const Flow: typeof FlowRoot & {
1111
+ Inputs: typeof FlowInputs;
1112
+ Input: typeof FlowInput & {
1113
+ FilePicker: typeof FlowInputFilePicker;
1114
+ Preview: typeof FlowInputPreview;
1115
+ };
1116
+ Progress: typeof FlowProgress;
1117
+ Status: typeof FlowStatus;
1118
+ Error: typeof FlowError;
1119
+ Submit: typeof FlowSubmit;
1120
+ Cancel: typeof FlowCancel;
1121
+ Reset: typeof FlowReset;
1122
+ QuickUpload: typeof FlowQuickUpload;
1123
+ };
386
1124
  //#endregion
387
1125
  //#region src/contexts/flow-manager-context.d.ts
388
1126
  /**
@@ -432,7 +1170,7 @@ interface FlowManagerProviderProps {
432
1170
  */
433
1171
  declare function FlowManagerProvider({
434
1172
  children
435
- }: FlowManagerProviderProps): react_jsx_runtime3.JSX.Element;
1173
+ }: FlowManagerProviderProps): react_jsx_runtime12.JSX.Element;
436
1174
  /**
437
1175
  * Hook to access the FlowManager context.
438
1176
  * Must be used within a FlowManagerProvider.
@@ -697,219 +1435,6 @@ declare function useFileUpload(options?: UseFileUploadOptions): {
697
1435
  metrics: _uploadista_client_core3.UploadMetrics;
698
1436
  };
699
1437
  //#endregion
700
- //#region src/hooks/use-flow.d.ts
701
- /**
702
- * Input metadata discovered from the flow
703
- */
704
- interface FlowInputMetadata {
705
- /** Input node ID */
706
- nodeId: string;
707
- /** Human-readable node name */
708
- nodeName: string;
709
- /** Node description explaining what input is needed */
710
- nodeDescription: string;
711
- /** Input type ID from inputTypeRegistry - describes how clients interact with this node */
712
- inputTypeId?: string;
713
- /** Whether this input is required */
714
- required: boolean;
715
- }
716
- /**
717
- * Options for the useFlow hook
718
- */
719
- interface UseFlowOptions {
720
- /** Flow ID to execute */
721
- flowId: string;
722
- /** Storage ID for the upload */
723
- storageId: string;
724
- /** Output node ID for the flow */
725
- outputNodeId?: string;
726
- /** Metadata to pass to flow */
727
- metadata?: Record<string, unknown>;
728
- /** Called when upload succeeds (receives typed outputs from all output nodes) */
729
- onSuccess?: (outputs: TypedOutput[]) => void;
730
- /** Called when the flow completes successfully (receives full flow outputs) */
731
- onFlowComplete?: (outputs: TypedOutput[]) => void;
732
- /** Called when upload fails */
733
- onError?: (error: Error) => void;
734
- /** Called when upload progress updates */
735
- onProgress?: (progress: number, bytesUploaded: number, totalBytes: number | null) => void;
736
- /** Called when a chunk completes */
737
- onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
738
- }
739
- /**
740
- * Return value from the useFlow hook with upload control methods and state.
741
- *
742
- * @property state - Complete flow upload state with progress and outputs
743
- * @property inputMetadata - Metadata about discovered input nodes (null until discovered)
744
- * @property inputStates - Per-input execution state for multi-input flows
745
- * @property inputs - Current input values set via setInput()
746
- * @property setInput - Set an input value for a specific node (for progressive provision)
747
- * @property execute - Execute the flow with current inputs (auto-detects types)
748
- * @property upload - Convenience method for single-file upload (same as execute with one file input)
749
- * @property abort - Cancel the current upload and flow execution
750
- * @property reset - Reset state to idle (clears all data)
751
- * @property retry - Retry the last failed upload
752
- * @property isActive - True when upload or processing is active
753
- * @property isUploadingFile - True only during file upload phase
754
- * @property isProcessing - True only during flow processing phase
755
- * @property isDiscoveringInputs - True while discovering flow inputs
756
- * @property canRetry - True if a retry is possible
757
- */
758
- interface UseFlowReturn {
759
- /**
760
- * Current upload state
761
- */
762
- state: FlowUploadState;
763
- /**
764
- * Discovered input nodes metadata (null until discovery completes)
765
- */
766
- inputMetadata: FlowInputMetadata[] | null;
767
- /**
768
- * Per-input execution state for multi-input flows
769
- */
770
- inputStates: ReadonlyMap<string, InputExecutionState>;
771
- /**
772
- * Current inputs set via setInput()
773
- */
774
- inputs: Record<string, unknown>;
775
- /**
776
- * Set an input value for a specific node.
777
- * For progressive input provision before calling execute().
778
- *
779
- * @param nodeId - The input node ID
780
- * @param value - The input value (FilePickResult, URL string, or structured data)
781
- */
782
- setInput: (nodeId: string, value: FilePickResult | string | unknown) => void;
783
- /**
784
- * Execute the flow with current inputs.
785
- * Automatically detects input types and routes appropriately.
786
- * For single input, uses standard upload path.
787
- * For multiple inputs, requires multiInputUploadFn.
788
- */
789
- execute: () => Promise<void>;
790
- /**
791
- * Upload a single file through the flow (convenience method).
792
- * Equivalent to setInput(firstNodeId, file) + execute().
793
- *
794
- * @param file - FilePickResult from a picker
795
- */
796
- upload: (file: FilePickResult) => Promise<void>;
797
- /**
798
- * Abort the current upload
799
- */
800
- abort: () => void;
801
- /**
802
- * Reset the upload state and clear all inputs
803
- */
804
- reset: () => void;
805
- /**
806
- * Retry the last failed upload
807
- */
808
- retry: () => void;
809
- /**
810
- * Whether an upload or flow execution is in progress (uploading OR processing)
811
- */
812
- isActive: boolean;
813
- /**
814
- * Whether the file is currently being uploaded (chunks being sent)
815
- */
816
- isUploadingFile: boolean;
817
- /**
818
- * Whether the flow is currently processing (after upload completes)
819
- */
820
- isProcessing: boolean;
821
- /**
822
- * Whether the hook is discovering flow inputs
823
- */
824
- isDiscoveringInputs: boolean;
825
- /**
826
- * Whether a retry is possible (after error or abort with stored inputs)
827
- */
828
- canRetry: boolean;
829
- }
830
- /**
831
- * React Native hook for executing flows with single or multiple inputs.
832
- * Automatically discovers input nodes and detects input types (File, URL, structured data).
833
- * Supports progressive input provision via setInput() and execute().
834
- *
835
- * This is the unified flow hook that replaces useFlowUpload for advanced use cases.
836
- * It provides:
837
- * - Auto-discovery of flow input nodes
838
- * - Automatic input type detection (FilePickResult -> upload, string -> URL, object -> data)
839
- * - Progressive input provision via setInput()
840
- * - Multi-input support with parallel coordination
841
- * - Per-input state tracking
842
- *
843
- * Must be used within FlowManagerProvider (which must be within UploadistaProvider).
844
- * Flow events are automatically routed by the provider to the appropriate manager.
845
- *
846
- * @param options - Flow upload configuration including flow ID and event handlers
847
- * @returns Flow upload state and control methods
848
- *
849
- * @example
850
- * ```tsx
851
- * function MyComponent() {
852
- * const flow = useFlow({
853
- * flowId: 'image-processing-flow',
854
- * storageId: 'my-storage',
855
- * onSuccess: (outputs) => console.log('Flow complete:', outputs),
856
- * onError: (error) => console.error('Flow failed:', error),
857
- * });
858
- *
859
- * const handlePickFile = async () => {
860
- * const file = await fileSystemProvider.pickDocument();
861
- * if (file) {
862
- * await flow.upload(file);
863
- * }
864
- * };
865
- *
866
- * return (
867
- * <View>
868
- * <Button title="Pick File" onPress={handlePickFile} />
869
- * {flow.isActive && <Text>Progress: {flow.state.progress}%</Text>}
870
- * {flow.inputMetadata && (
871
- * <Text>Found {flow.inputMetadata.length} input nodes</Text>
872
- * )}
873
- * <Button title="Abort" onPress={flow.abort} disabled={!flow.isActive} />
874
- * </View>
875
- * );
876
- * }
877
- * ```
878
- *
879
- * @example
880
- * ```tsx
881
- * // Multi-input flow
882
- * function MultiInputComponent() {
883
- * const flow = useFlow({
884
- * flowId: 'multi-source-flow',
885
- * storageId: 'my-storage',
886
- * });
887
- *
888
- * const handlePickPrimary = async () => {
889
- * const file = await fileSystemProvider.pickDocument();
890
- * if (file.status === 'success') {
891
- * flow.setInput('primary-input', file);
892
- * }
893
- * };
894
- *
895
- * const handleSetUrl = (url: string) => {
896
- * flow.setInput('url-input', url);
897
- * };
898
- *
899
- * return (
900
- * <View>
901
- * <Button title="Pick Primary" onPress={handlePickPrimary} />
902
- * <TextInput onChangeText={handleSetUrl} placeholder="Enter URL" />
903
- * <Button title="Execute" onPress={flow.execute} />
904
- * </View>
905
- * );
906
- * }
907
- * ```
908
- *
909
- * @see {@link useFlowUpload} for a simpler file-only upload hook
910
- */
911
- declare function useFlow(options: UseFlowOptions): UseFlowReturn;
912
- //#endregion
913
1438
  //#region src/hooks/use-multi-upload.d.ts
914
1439
  interface UploadItemState {
915
1440
  id: string;
@@ -1202,5 +1727,5 @@ declare function normalizeUri(uri: string): string;
1202
1727
  */
1203
1728
  declare function getMimeTypeFromUri(uri: string): string;
1204
1729
  //#endregion
1205
- 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 FlowInputMetadata, FlowManagerProvider, type FlowUploadState, type FlowUploadStatus, GalleryUploadButton, type GalleryUploadButtonProps, type HttpClient, type IdGenerationService, type InputExecutionState, 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 UseFlowOptions, type UseFlowReturn, 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, useFlow, useFlowManagerContext, useGalleryUpload, useMultiUpload, useUploadMetrics, useUploadistaContext };
1730
+ 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, Flow, type FlowCancelProps, type FlowCancelRenderProps, type FlowContextValue, type FlowErrorProps, type FlowErrorRenderProps, type FlowInputContextValue, type FlowInputFilePickerProps, type FlowInputFilePickerRenderProps, type FlowInputMetadata, type FlowInputPreviewProps, type FlowInputPreviewRenderProps, type FlowInputProps, type FlowInputsProps, type FlowInputsRenderProps, FlowManagerProvider, type FlowProgressProps, type FlowProgressRenderProps, type FlowProps, type FlowQuickUploadProps, type FlowQuickUploadRenderProps, type FlowRenderProps, type FlowResetProps, type FlowResetRenderProps, type FlowStatusProps, type FlowStatusRenderProps, type FlowSubmitProps, type FlowSubmitRenderProps, type FlowUploadState, type FlowUploadStatus, GalleryUploadButton, type GalleryUploadButtonProps, type HttpClient, type IdGenerationService, type InputExecutionState, 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 UseFlowOptions, type UseFlowReturn, 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, useFlow, useFlowContext, useFlowInputContext, useFlowManagerContext, useGalleryUpload, useMultiUpload, useUploadMetrics, useUploadistaContext };
1206
1731
  //# sourceMappingURL=index.d.mts.map