@uploadista/react-native-core 0.1.3-beta.7 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadista/react-native-core",
3
- "version": "0.1.3-beta.7",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Core React Native client for Uploadista",
6
6
  "license": "MIT",
@@ -15,8 +15,8 @@
15
15
  "dependencies": {
16
16
  "uuid": "^13.0.0",
17
17
  "js-base64": "^3.7.7",
18
- "@uploadista/client-core": "0.1.3-beta.7",
19
- "@uploadista/core": "0.1.3-beta.7"
18
+ "@uploadista/core": "0.1.3",
19
+ "@uploadista/client-core": "0.1.3"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": ">=16.8.0",
@@ -31,7 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@types/react": ">=18.0.0",
33
33
  "tsdown": "0.20.1",
34
- "@uploadista/typescript-config": "0.1.3-beta.7"
34
+ "@uploadista/typescript-config": "0.1.3"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc --noEmit && tsdown",
@@ -45,6 +45,8 @@ export interface FlowContextValue {
45
45
  upload: (file: FilePickResult) => Promise<void>;
46
46
  /** Abort the current upload */
47
47
  abort: () => void;
48
+ /** Pause the current upload */
49
+ pause: () => void;
48
50
  /** Reset the upload state and clear all inputs */
49
51
  reset: () => void;
50
52
 
@@ -56,6 +58,8 @@ export interface FlowContextValue {
56
58
  isProcessing: boolean;
57
59
  /** Whether the hook is discovering flow inputs */
58
60
  isDiscoveringInputs: boolean;
61
+ /** Whether the flow is currently paused */
62
+ isPaused: boolean;
59
63
 
60
64
  /** Pick a file and set it for a specific input node */
61
65
  pickFileForInput: (nodeId: string) => Promise<void>;
@@ -241,11 +245,13 @@ function FlowRoot({
241
245
  execute: flow.execute,
242
246
  upload: flow.upload,
243
247
  abort: flow.abort,
248
+ pause: flow.pause,
244
249
  reset: flow.reset,
245
250
  isActive: flow.isActive,
246
251
  isUploadingFile: flow.isUploadingFile,
247
252
  isProcessing: flow.isProcessing,
248
253
  isDiscoveringInputs: flow.isDiscoveringInputs,
254
+ isPaused: flow.isPaused,
249
255
  pickFileForInput,
250
256
  pickAndUpload,
251
257
  };
@@ -726,6 +732,43 @@ function FlowReset({ children }: FlowResetProps) {
726
732
  );
727
733
  }
728
734
 
735
+ /**
736
+ * Render props for Flow.Pause component.
737
+ */
738
+ export interface FlowPauseRenderProps {
739
+ /** Pause the flow */
740
+ pause: () => void;
741
+ /** Whether the button should be disabled */
742
+ isDisabled: boolean;
743
+ /** Whether currently paused */
744
+ isPaused: boolean;
745
+ }
746
+
747
+ /**
748
+ * Props for Flow.Pause component.
749
+ */
750
+ export interface FlowPauseProps {
751
+ /** Render function receiving pause state */
752
+ children: ReactNode | ((props: FlowPauseRenderProps) => ReactNode);
753
+ }
754
+
755
+ /**
756
+ * Pause primitive that pauses the current upload.
757
+ */
758
+ function FlowPause({ children }: FlowPauseProps) {
759
+ const flow = useFlowContext();
760
+
761
+ const renderProps: FlowPauseRenderProps = {
762
+ pause: flow.pause,
763
+ isDisabled: !flow.isActive || flow.isPaused,
764
+ isPaused: flow.isPaused,
765
+ };
766
+
767
+ return (
768
+ <>{typeof children === "function" ? children(renderProps) : children}</>
769
+ );
770
+ }
771
+
729
772
  // ============ QUICK UPLOAD PRIMITIVE ============
730
773
 
731
774
  /**
@@ -842,6 +885,7 @@ export const Flow = Object.assign(FlowRoot, {
842
885
  Error: FlowError,
843
886
  Submit: FlowSubmit,
844
887
  Cancel: FlowCancel,
888
+ Pause: FlowPause,
845
889
  Reset: FlowReset,
846
890
  QuickUpload: FlowQuickUpload,
847
891
  });
@@ -27,6 +27,8 @@ export {
27
27
  type FlowInputProps,
28
28
  type FlowInputsProps,
29
29
  type FlowInputsRenderProps,
30
+ type FlowPauseProps,
31
+ type FlowPauseRenderProps,
30
32
  type FlowProgressProps,
31
33
  type FlowProgressRenderProps,
32
34
  type FlowProps,
@@ -130,7 +130,7 @@ export interface UseFlowReturn {
130
130
  /**
131
131
  * Abort the current upload
132
132
  */
133
- abort: () => void;
133
+ abort: () => Promise<void>;
134
134
 
135
135
  /**
136
136
  * Reset the upload state and clear all inputs
@@ -166,6 +166,21 @@ export interface UseFlowReturn {
166
166
  * Whether a retry is possible (after error or abort with stored inputs)
167
167
  */
168
168
  canRetry: boolean;
169
+
170
+ /**
171
+ * Pause the current upload
172
+ */
173
+ pause: () => void;
174
+
175
+ /**
176
+ * Resume a paused upload
177
+ */
178
+ resume: () => void;
179
+
180
+ /**
181
+ * Whether the flow is currently paused
182
+ */
183
+ isPaused: boolean;
169
184
  }
170
185
 
171
186
  const initialState: FlowUploadState = {
@@ -179,6 +194,7 @@ const initialState: FlowUploadState = {
179
194
  currentNodeName: null,
180
195
  currentNodeType: null,
181
196
  flowOutputs: null,
197
+ pausedAtNodeId: null,
182
198
  };
183
199
 
184
200
  /**
@@ -525,8 +541,16 @@ export function useFlow(options: UseFlowOptions): UseFlowReturn {
525
541
  [inputMetadata, fileSystemProvider, options],
526
542
  );
527
543
 
528
- const abort = useCallback(() => {
529
- managerRef.current?.abort();
544
+ const abort = useCallback(async () => {
545
+ await managerRef.current?.abort();
546
+ }, []);
547
+
548
+ const pause = useCallback(async () => {
549
+ await managerRef.current?.pause();
550
+ }, []);
551
+
552
+ const resume = useCallback(async () => {
553
+ await managerRef.current?.resume();
530
554
  }, []);
531
555
 
532
556
  const reset = useCallback(() => {
@@ -552,6 +576,7 @@ export function useFlow(options: UseFlowOptions): UseFlowReturn {
552
576
  state.status === "uploading" || state.status === "processing";
553
577
  const isUploadingFile = state.status === "uploading";
554
578
  const isProcessing = state.status === "processing";
579
+ const isPaused = state.status === "paused";
555
580
  const canRetry =
556
581
  (state.status === "error" || state.status === "aborted") &&
557
582
  lastInputsRef.current !== null;
@@ -565,6 +590,8 @@ export function useFlow(options: UseFlowOptions): UseFlowReturn {
565
590
  execute,
566
591
  upload,
567
592
  abort,
593
+ pause,
594
+ resume,
568
595
  reset,
569
596
  retry,
570
597
  isActive,
@@ -572,5 +599,6 @@ export function useFlow(options: UseFlowOptions): UseFlowReturn {
572
599
  isProcessing,
573
600
  isDiscoveringInputs,
574
601
  canRetry,
602
+ isPaused,
575
603
  };
576
604
  }
package/src/index.ts CHANGED
@@ -48,6 +48,8 @@ export {
48
48
  type FlowInputProps,
49
49
  type FlowInputsProps,
50
50
  type FlowInputsRenderProps,
51
+ type FlowPauseProps,
52
+ type FlowPauseRenderProps,
51
53
  type FlowProgressProps,
52
54
  type FlowProgressRenderProps,
53
55
  type FlowProps,