@uploadista/client-core 0.0.18-beta.2 → 0.0.18-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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/client-core",
3
3
  "type": "module",
4
- "version": "0.0.18-beta.2",
4
+ "version": "0.0.18-beta.3",
5
5
  "description": "Platform-agnostic core upload client logic for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "js-base64": "3.7.8",
36
- "@uploadista/core": "0.0.18-beta.2"
36
+ "@uploadista/core": "0.0.18-beta.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^4.0.0"
@@ -42,7 +42,7 @@
42
42
  "tsdown": "0.16.6",
43
43
  "vitest": "4.0.13",
44
44
  "zod": "4.1.13",
45
- "@uploadista/typescript-config": "0.0.18-beta.2"
45
+ "@uploadista/typescript-config": "0.0.18-beta.3"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsdown",
@@ -328,6 +328,8 @@ export class FlowManager<TInput = FlowUploadInput> {
328
328
  private state: FlowUploadState;
329
329
  private abortController: FlowUploadAbortController | null = null;
330
330
  private inputStates: Map<string, InputExecutionState> = new Map();
331
+ /** Tracks the nodeId when executing a single-input flow via executeFlow() */
332
+ private currentSingleInputNodeId: string | null = null;
331
333
 
332
334
  /**
333
335
  * Create a new FlowManager
@@ -542,6 +544,17 @@ export class FlowManager<TInput = FlowUploadInput> {
542
544
  progress,
543
545
  });
544
546
 
547
+ // Also update inputStates for single-input flows executed via executeFlow()
548
+ if (this.currentSingleInputNodeId) {
549
+ const inputState = this.inputStates.get(this.currentSingleInputNodeId);
550
+ if (inputState) {
551
+ inputState.status = "uploading";
552
+ inputState.progress = progress;
553
+ inputState.bytesUploaded = bytesUploaded;
554
+ inputState.totalBytes = totalBytes;
555
+ }
556
+ }
557
+
545
558
  this.callbacks.onProgress?.(uploadId, bytesUploaded, totalBytes);
546
559
  }
547
560
 
@@ -623,6 +636,17 @@ export class FlowManager<TInput = FlowUploadInput> {
623
636
  this.updateState({
624
637
  progress: 100,
625
638
  });
639
+ // Update inputStates for single-input flows executed via executeFlow()
640
+ if (this.currentSingleInputNodeId) {
641
+ const inputState = this.inputStates.get(
642
+ this.currentSingleInputNodeId,
643
+ );
644
+ if (inputState) {
645
+ inputState.status = "complete";
646
+ inputState.progress = 100;
647
+ }
648
+ this.currentSingleInputNodeId = null;
649
+ }
626
650
  // Don't call callbacks.onSuccess here - wait for FlowEnd event with TOutput
627
651
  },
628
652
  onError: (error: Error) => {
@@ -630,6 +654,17 @@ export class FlowManager<TInput = FlowUploadInput> {
630
654
  status: "error",
631
655
  error,
632
656
  });
657
+ // Update inputStates for single-input flows executed via executeFlow()
658
+ if (this.currentSingleInputNodeId) {
659
+ const inputState = this.inputStates.get(
660
+ this.currentSingleInputNodeId,
661
+ );
662
+ if (inputState) {
663
+ inputState.status = "error";
664
+ inputState.error = error;
665
+ }
666
+ this.currentSingleInputNodeId = null;
667
+ }
633
668
  this.callbacks.onError?.(error);
634
669
  this.options?.onError?.(error);
635
670
  this.abortController = null;
@@ -638,6 +673,17 @@ export class FlowManager<TInput = FlowUploadInput> {
638
673
  this.updateState({
639
674
  status: "aborted",
640
675
  });
676
+ // Update inputStates for single-input flows executed via executeFlow()
677
+ if (this.currentSingleInputNodeId) {
678
+ const inputState = this.inputStates.get(
679
+ this.currentSingleInputNodeId,
680
+ );
681
+ if (inputState) {
682
+ inputState.status = "error";
683
+ inputState.error = new Error("Upload aborted");
684
+ }
685
+ this.currentSingleInputNodeId = null;
686
+ }
641
687
  this.callbacks.onAbort?.();
642
688
  this.options?.onAbort?.();
643
689
  this.abortController = null;
@@ -660,6 +706,16 @@ export class FlowManager<TInput = FlowUploadInput> {
660
706
  error: uploadError,
661
707
  });
662
708
 
709
+ // Update inputStates for single-input flows executed via executeFlow()
710
+ if (this.currentSingleInputNodeId) {
711
+ const inputState = this.inputStates.get(this.currentSingleInputNodeId);
712
+ if (inputState) {
713
+ inputState.status = "error";
714
+ inputState.error = uploadError;
715
+ }
716
+ this.currentSingleInputNodeId = null;
717
+ }
718
+
663
719
  this.callbacks.onError?.(uploadError);
664
720
  this.options?.onError?.(uploadError);
665
721
  this.abortController = null;
@@ -701,6 +757,7 @@ export class FlowManager<TInput = FlowUploadInput> {
701
757
  }
702
758
  }
703
759
  this.inputStates.clear();
760
+ this.currentSingleInputNodeId = null;
704
761
 
705
762
  this.state = { ...initialState };
706
763
  this.callbacks.onStateChange(this.state);
@@ -796,7 +853,9 @@ export class FlowManager<TInput = FlowUploadInput> {
796
853
  if (!firstEntry) {
797
854
  throw new Error("No inputs provided to executeFlow");
798
855
  }
799
- const [, firstData] = firstEntry;
856
+ const [nodeId, firstData] = firstEntry;
857
+ // Track nodeId so upload() callbacks can update inputStates
858
+ this.currentSingleInputNodeId = nodeId;
800
859
  await this.upload(firstData as TInput);
801
860
  return;
802
861
  }
@@ -933,5 +992,6 @@ export class FlowManager<TInput = FlowUploadInput> {
933
992
  }
934
993
  }
935
994
  this.inputStates.clear();
995
+ this.currentSingleInputNodeId = null;
936
996
  }
937
997
  }