@uploadista/vue 0.0.15-beta.1 → 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/components/index.d.mts +2 -2
- package/dist/components/index.mjs +1 -1
- package/dist/components-Cxh84bZE.mjs +2 -0
- package/dist/{components-DiNTrRSj.mjs.map → components-Cxh84bZE.mjs.map} +1 -1
- package/dist/composables/index.d.mts +1 -1
- package/dist/composables/index.mjs +1 -1
- package/dist/composables-F-8_X15y.mjs +2 -0
- package/dist/composables-F-8_X15y.mjs.map +1 -0
- package/dist/{index-DRICNOZ-.d.mts → index-D2ZeCepe.d.mts} +2 -2
- package/dist/{index-DRICNOZ-.d.mts.map → index-D2ZeCepe.d.mts.map} +1 -1
- package/dist/{index-DE2wzsj7.d.mts → index-DMZeyb2G.d.mts} +21 -21
- package/dist/index-DMZeyb2G.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
- package/src/composables/useFlowManagerContext.ts +46 -0
- package/src/composables/useFlowUpload.ts +54 -118
- package/src/providers/FlowManagerProvider.vue +159 -0
- package/dist/components-DiNTrRSj.mjs +0 -2
- package/dist/composables-8ehXYRvI.mjs +0 -2
- package/dist/composables-8ehXYRvI.mjs.map +0 -1
- package/dist/index-DE2wzsj7.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue1 from "vue";
|
|
2
2
|
import { App, InjectionKey, Ref } from "vue";
|
|
3
3
|
import * as _uploadista_client_browser0 from "@uploadista/client-browser";
|
|
4
4
|
import { BrowserUploadInput, ChunkMetrics, ChunkMetrics as ChunkMetrics$1, FlowUploadOptions, MultiFlowUploadOptions, PerformanceInsights, PerformanceInsights as PerformanceInsights$1, UploadOptions, UploadSessionMetrics, UploadSessionMetrics as UploadSessionMetrics$1, UploadistaClientOptions, UploadistaEvent, createUploadistaClient } from "@uploadista/client-browser";
|
|
@@ -173,7 +173,7 @@ interface DragDropState {
|
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
declare function useDragDrop(options?: DragDropOptions): {
|
|
176
|
-
state: Readonly<
|
|
176
|
+
state: Readonly<vue1.Ref<{
|
|
177
177
|
readonly isDragging: boolean;
|
|
178
178
|
readonly isOver: boolean;
|
|
179
179
|
readonly isValid: boolean;
|
|
@@ -189,7 +189,7 @@ declare function useDragDrop(options?: DragDropOptions): {
|
|
|
189
189
|
onDragLeave: (event: DragEvent) => void;
|
|
190
190
|
onDrop: (event: DragEvent) => void;
|
|
191
191
|
onInputChange: (event: Event) => void;
|
|
192
|
-
inputProps:
|
|
192
|
+
inputProps: vue1.ComputedRef<{
|
|
193
193
|
type: "file";
|
|
194
194
|
multiple: boolean;
|
|
195
195
|
accept: string | undefined;
|
|
@@ -244,8 +244,8 @@ interface UseFlowUploadOptions<TOutput = UploadFile> {
|
|
|
244
244
|
* The flow handles the upload process and can perform post-processing like
|
|
245
245
|
* saving to storage, optimizing images, etc.
|
|
246
246
|
*
|
|
247
|
-
* Must be used within
|
|
248
|
-
*
|
|
247
|
+
* Must be used within FlowManagerProvider (which must be within UploadistaProvider).
|
|
248
|
+
* Flow events are automatically routed by the provider to the appropriate manager.
|
|
249
249
|
*
|
|
250
250
|
* @example
|
|
251
251
|
* ```vue
|
|
@@ -274,13 +274,13 @@ interface UseFlowUploadOptions<TOutput = UploadFile> {
|
|
|
274
274
|
* ```
|
|
275
275
|
*/
|
|
276
276
|
declare function useFlowUpload<TOutput = UploadFile>(options: UseFlowUploadOptions<TOutput>): {
|
|
277
|
-
state: Readonly<
|
|
277
|
+
state: Readonly<vue1.Ref<{
|
|
278
278
|
readonly status: FlowUploadStatus;
|
|
279
279
|
readonly progress: number;
|
|
280
280
|
readonly bytesUploaded: number;
|
|
281
281
|
readonly totalBytes: number | null;
|
|
282
282
|
readonly error: Error | null;
|
|
283
|
-
readonly result:
|
|
283
|
+
readonly result: vue1.DeepReadonly<vue1.UnwrapRef<TOutput>> | null;
|
|
284
284
|
readonly jobId: string | null;
|
|
285
285
|
readonly flowStarted: boolean;
|
|
286
286
|
readonly currentNodeName: string | null;
|
|
@@ -365,7 +365,7 @@ declare function useFlowUpload<TOutput = UploadFile>(options: UseFlowUploadOptio
|
|
|
365
365
|
readonly bytesUploaded: number;
|
|
366
366
|
readonly totalBytes: number | null;
|
|
367
367
|
readonly error: Error | null;
|
|
368
|
-
readonly result:
|
|
368
|
+
readonly result: vue1.DeepReadonly<vue1.UnwrapRef<TOutput>> | null;
|
|
369
369
|
readonly jobId: string | null;
|
|
370
370
|
readonly flowStarted: boolean;
|
|
371
371
|
readonly currentNodeName: string | null;
|
|
@@ -449,9 +449,9 @@ declare function useFlowUpload<TOutput = UploadFile>(options: UseFlowUploadOptio
|
|
|
449
449
|
abort: () => void;
|
|
450
450
|
pause: () => void;
|
|
451
451
|
reset: () => void;
|
|
452
|
-
isUploading:
|
|
453
|
-
isUploadingFile:
|
|
454
|
-
isProcessing:
|
|
452
|
+
isUploading: vue1.ComputedRef<boolean>;
|
|
453
|
+
isUploadingFile: vue1.ComputedRef<boolean>;
|
|
454
|
+
isProcessing: vue1.ComputedRef<boolean>;
|
|
455
455
|
};
|
|
456
456
|
//#endregion
|
|
457
457
|
//#region src/composables/useMultiFlowUpload.d.ts
|
|
@@ -505,7 +505,7 @@ declare function useFlowUpload<TOutput = UploadFile>(options: UseFlowUploadOptio
|
|
|
505
505
|
* ```
|
|
506
506
|
*/
|
|
507
507
|
declare function useMultiFlowUpload(options: MultiFlowUploadOptions<BrowserUploadInput>): {
|
|
508
|
-
state: Readonly<
|
|
508
|
+
state: Readonly<vue1.Ref<{
|
|
509
509
|
readonly items: readonly {
|
|
510
510
|
readonly id: string;
|
|
511
511
|
readonly file: {
|
|
@@ -641,7 +641,7 @@ declare function useMultiFlowUpload(options: MultiFlowUploadOptions<BrowserUploa
|
|
|
641
641
|
abortAll: () => void;
|
|
642
642
|
clear: () => void;
|
|
643
643
|
retryUpload: (id: string) => void;
|
|
644
|
-
isUploading:
|
|
644
|
+
isUploading: vue1.ComputedRef<boolean>;
|
|
645
645
|
};
|
|
646
646
|
//#endregion
|
|
647
647
|
//#region src/composables/useUpload.d.ts
|
|
@@ -684,7 +684,7 @@ type UploadInput = File | Blob;
|
|
|
684
684
|
* ```
|
|
685
685
|
*/
|
|
686
686
|
declare function useUpload(options?: UploadOptions$1): {
|
|
687
|
-
state:
|
|
687
|
+
state: vue1.Ref<{
|
|
688
688
|
status: UploadStatus;
|
|
689
689
|
progress: number;
|
|
690
690
|
bytesUploaded: number;
|
|
@@ -757,8 +757,8 @@ declare function useUpload(options?: UploadOptions$1): {
|
|
|
757
757
|
abort: () => void;
|
|
758
758
|
reset: () => void;
|
|
759
759
|
retry: () => void;
|
|
760
|
-
isUploading:
|
|
761
|
-
canRetry:
|
|
760
|
+
isUploading: vue1.ComputedRef<boolean>;
|
|
761
|
+
canRetry: vue1.ComputedRef<boolean>;
|
|
762
762
|
metrics: UploadMetrics;
|
|
763
763
|
};
|
|
764
764
|
//#endregion
|
|
@@ -901,7 +901,7 @@ interface MultiUploadState {
|
|
|
901
901
|
* ```
|
|
902
902
|
*/
|
|
903
903
|
declare function useMultiUpload(options?: MultiUploadOptions): {
|
|
904
|
-
state: Readonly<
|
|
904
|
+
state: Readonly<vue1.Ref<{
|
|
905
905
|
readonly total: number;
|
|
906
906
|
readonly completed: number;
|
|
907
907
|
readonly successful: number;
|
|
@@ -924,7 +924,7 @@ declare function useMultiUpload(options?: MultiUploadOptions): {
|
|
|
924
924
|
readonly isUploading: boolean;
|
|
925
925
|
readonly isComplete: boolean;
|
|
926
926
|
}>>;
|
|
927
|
-
items: Readonly<
|
|
927
|
+
items: Readonly<vue1.Ref<readonly {
|
|
928
928
|
readonly id: string;
|
|
929
929
|
readonly file: {
|
|
930
930
|
readonly lastModified: number;
|
|
@@ -1424,7 +1424,7 @@ interface UseUploadMetricsOptions {
|
|
|
1424
1424
|
* ```
|
|
1425
1425
|
*/
|
|
1426
1426
|
declare function useUploadMetrics(options?: UseUploadMetricsOptions): {
|
|
1427
|
-
metrics: Readonly<
|
|
1427
|
+
metrics: Readonly<vue1.Ref<{
|
|
1428
1428
|
readonly totalBytesUploaded: number;
|
|
1429
1429
|
readonly totalBytes: number;
|
|
1430
1430
|
readonly averageSpeed: number;
|
|
@@ -1525,7 +1525,7 @@ declare function useUploadMetrics(options?: UseUploadMetricsOptions): {
|
|
|
1525
1525
|
readonly chunkingStrategy?: string | undefined;
|
|
1526
1526
|
}[];
|
|
1527
1527
|
}>>;
|
|
1528
|
-
fileMetrics: Readonly<
|
|
1528
|
+
fileMetrics: Readonly<vue1.Ref<readonly {
|
|
1529
1529
|
readonly id: string;
|
|
1530
1530
|
readonly filename: string;
|
|
1531
1531
|
readonly size: number;
|
|
@@ -1634,4 +1634,4 @@ declare function useUploadMetrics(options?: UseUploadMetricsOptions): {
|
|
|
1634
1634
|
};
|
|
1635
1635
|
//#endregion
|
|
1636
1636
|
export { useDragDrop as C, createUploadistaPlugin as D, UploadistaPluginOptions as E, DragDropState as S, UPLOADISTA_EVENT_SUBSCRIBERS_KEY as T, useMultiFlowUpload as _, useUploadistaClient as a, useFlowUpload as b, UploadItem as c, PerformanceInsights$1 as d, UploadInput as f, useUpload as g, UploadStatus as h, UseUploadistaClientReturn as i, useMultiUpload as l, UploadState as m, UseUploadMetricsOptions as n, MultiUploadOptions as o, UploadSessionMetrics$1 as p, useUploadMetrics as r, MultiUploadState as s, FileUploadMetrics as t, ChunkMetrics$1 as u, FlowUploadState as v, UPLOADISTA_CLIENT_KEY as w, DragDropOptions as x, FlowUploadStatus as y };
|
|
1637
|
-
//# sourceMappingURL=index-
|
|
1637
|
+
//# sourceMappingURL=index-DMZeyb2G.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DMZeyb2G.d.mts","names":[],"sources":["../src/composables/plugin.ts","../src/composables/useDragDrop.ts","../src/composables/useFlowUpload.ts","../src/composables/useMultiFlowUpload.ts","../src/composables/useUpload.ts","../src/composables/useMultiUpload.ts","../src/composables/useUploadistaClient.ts","../src/composables/useUploadMetrics.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAQiB,uBAAA,SAAgC;;;;YAIrC;;cAGC,uBAAuB,aAClC,kBAAkB;cAGP,kCAAkC,aAC7C,IAAI,YAAY;AAZlB;AAOA;;;;;AAIA;;;;;;AAiCA;;;;AClDA;AA0CA;AAmGA;;;;;;;;;;;AA4EmC,iBDvKnB,sBAAA,CCuKmB,OAAA,EDvKa,uBCuKb,CAAA,EAAA;eDrKlB;;;;UCpDA,eAAA;;;;;;;;;;ADMjB;AAOA;EACoB,WAAA,CAAA,EAAA,MAAA;EAAlB;;;EAGW,QAAA,CAAA,EAAA,OAAA;EACK;;;EAD6B,SAAA,CAAA,EAAA,CAAA,KAAA,ECOzB,IDPyB,EAAA,EAAA,GAAA,MAAA,EAAA,GAAA,IAAA;EAAY;AAiC3D;;4BCrB4B;;AA7B5B;AA0CA;EAmGgB,iBAAW,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,EAAA,GAAA,IAAA;EAAU;;;EAoHP,iBAAA,CAAA,EAAA,CAAA,UAAA,EAAA,OAAA,EAAA,GAAA,IAAA;;AAsBA,UA7Ob,aAAA,CA6Oa;EAYL;;;EA1EM,UAAA,EAAA,OAAA;EAAI;;;;EC7MlB;;;EAIH,OAAA,EAAA,OAAA;EAyBe;;;EAsBH,MAAA,EAAA,MAAA,EAAA;;AAqD1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC3DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBFoFgB,WAAA,WAAqB;kBAAoB,IAAA,CAAA;;;;IEgE9B,SAAA,MAAA,EAAA,SAAA,MAAA,EAAA;EAAS,CAAA,EAAA;IAAQ,SAAA,UAAA,EAAA,OAAA;;;;;EC3LhC,WAAA,EAAA,CAAW,KAAA,EH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C as useDragDrop, D as createUploadistaPlugin, E as UploadistaPluginOptions, S as DragDropState, T as UPLOADISTA_EVENT_SUBSCRIBERS_KEY, _ as useMultiFlowUpload, a as useUploadistaClient, b as useFlowUpload, c as UploadItem, d as PerformanceInsights, f as UploadInput, g as useUpload, h as UploadStatus, i as UseUploadistaClientReturn, l as useMultiUpload, m as UploadState, n as UseUploadMetricsOptions, o as MultiUploadOptions, p as UploadSessionMetrics, r as useUploadMetrics, s as MultiUploadState, t as FileUploadMetrics, u as ChunkMetrics, v as FlowUploadState, w as UPLOADISTA_CLIENT_KEY, x as DragDropOptions, y as FlowUploadStatus } from "./index-
|
|
1
|
+
import { i as _default, n as _default$2, r as _default$1, t as _default$3 } from "./index-D2ZeCepe.mjs";
|
|
2
|
+
import { C as useDragDrop, D as createUploadistaPlugin, E as UploadistaPluginOptions, S as DragDropState, T as UPLOADISTA_EVENT_SUBSCRIBERS_KEY, _ as useMultiFlowUpload, a as useUploadistaClient, b as useFlowUpload, c as UploadItem, d as PerformanceInsights, f as UploadInput, g as useUpload, h as UploadStatus, i as UseUploadistaClientReturn, l as useMultiUpload, m as UploadState, n as UseUploadMetricsOptions, o as MultiUploadOptions, p as UploadSessionMetrics, r as useUploadMetrics, s as MultiUploadState, t as FileUploadMetrics, u as ChunkMetrics, v as FlowUploadState, w as UPLOADISTA_CLIENT_KEY, x as DragDropOptions, y as FlowUploadStatus } from "./index-DMZeyb2G.mjs";
|
|
3
3
|
import { t as _default$4 } from "./index-9iS--7zH.mjs";
|
|
4
4
|
import { a as formatSpeed, c as isAudioFile, d as isVideoFile, f as revokeFilePreview, i as formatFileSize, l as isDocumentFile, m as isBrowserFile, n as createFilePreview, o as generateUploadId, p as validateFileType, r as formatDuration, s as getFileExtension, t as calculateProgress, u as isImageFile } from "./index-BLNNvTVx.mjs";
|
|
5
5
|
export { ChunkMetrics, DragDropOptions, DragDropState, FileUploadMetrics, _default as FlowUploadList, FlowUploadState, FlowUploadStatus, _default$1 as FlowUploadZone, MultiUploadOptions, MultiUploadState, PerformanceInsights, UPLOADISTA_CLIENT_KEY, UPLOADISTA_EVENT_SUBSCRIBERS_KEY, UploadInput, UploadItem, _default$2 as UploadList, UploadSessionMetrics, UploadState, UploadStatus, _default$3 as UploadZone, UploadistaPluginOptions, _default$4 as UploadistaProvider, UseUploadMetricsOptions, UseUploadistaClientReturn, calculateProgress, createFilePreview, createUploadistaPlugin, formatDuration, formatFileSize, formatSpeed, generateUploadId, getFileExtension, isAudioFile, isBrowserFile, isDocumentFile, isImageFile, isVideoFile, revokeFilePreview, useDragDrop, useFlowUpload, useMultiFlowUpload, useMultiUpload, useUpload, useUploadMetrics, useUploadistaClient, validateFileType };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./utils-CG6LdEtY.mjs";import{i as m,n as h,r as g,t as _}from"./components-
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./utils-CG6LdEtY.mjs";import{i as m,n as h,r as g,t as _}from"./components-Cxh84bZE.mjs";import{n as v,r as y,t as b}from"./plugin-LRx3Bv83.mjs";import{a as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./composables-F-8_X15y.mjs";import{t as O}from"./providers-CLkkhv12.mjs";export{m as FlowUploadList,g as FlowUploadZone,b as UPLOADISTA_CLIENT_KEY,v as UPLOADISTA_EVENT_SUBSCRIBERS_KEY,h as UploadList,_ as UploadZone,O as UploadistaProvider,f as calculateProgress,s as createFilePreview,y as createUploadistaPlugin,u as formatDuration,i as formatFileSize,e as formatSpeed,c as generateUploadId,d as getFileExtension,t as isAudioFile,o as isBrowserFile,a as isDocumentFile,p as isImageFile,n as isVideoFile,r as revokeFilePreview,E as useDragDrop,w as useFlowUpload,S as useMultiFlowUpload,T as useMultiUpload,C as useUpload,D as useUploadMetrics,x as useUploadistaClient,l as validateFileType};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.15-beta.
|
|
4
|
+
"version": "0.0.15-beta.3",
|
|
5
5
|
"description": "Vue client for Uploadista",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"vue": "^3.3.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@uploadista/client-core": "0.0.15-beta.
|
|
35
|
-
"@uploadista/core": "0.0.15-beta.
|
|
36
|
-
"@uploadista/client-browser": "0.0.15-beta.
|
|
34
|
+
"@uploadista/client-core": "0.0.15-beta.3",
|
|
35
|
+
"@uploadista/core": "0.0.15-beta.3",
|
|
36
|
+
"@uploadista/client-browser": "0.0.15-beta.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@vue/test-utils": "^2.4.6",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vitest": "4.0.8",
|
|
43
43
|
"vue": "^3.5.0",
|
|
44
44
|
"vue-tsc": "3.1.3",
|
|
45
|
-
"@uploadista/typescript-config": "0.0.15-beta.
|
|
45
|
+
"@uploadista/typescript-config": "0.0.15-beta.3"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsdown",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FlowManager,
|
|
3
|
+
type FlowManagerCallbacks,
|
|
4
|
+
type FlowUploadOptions,
|
|
5
|
+
} from "@uploadista/client-core";
|
|
6
|
+
import { inject } from "vue";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Context value providing access to flow managers
|
|
10
|
+
*/
|
|
11
|
+
interface FlowManagerContextValue {
|
|
12
|
+
getManager: <TOutput = unknown>(
|
|
13
|
+
flowId: string,
|
|
14
|
+
callbacks: FlowManagerCallbacks<TOutput>,
|
|
15
|
+
options: FlowUploadOptions<TOutput>,
|
|
16
|
+
) => FlowManager<unknown, TOutput>;
|
|
17
|
+
releaseManager: (flowId: string) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Composable to access the FlowManager context.
|
|
22
|
+
* Must be used within a FlowManagerProvider.
|
|
23
|
+
*
|
|
24
|
+
* @returns FlowManager context value with getManager and releaseManager functions
|
|
25
|
+
* @throws Error if used outside of FlowManagerProvider
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* function setup() {
|
|
30
|
+
* const { getManager, releaseManager } = useFlowManagerContext();
|
|
31
|
+
* // Use to create managers...
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function useFlowManagerContext(): FlowManagerContextValue {
|
|
36
|
+
const context = inject<FlowManagerContextValue>("flowManagerContext");
|
|
37
|
+
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"useFlowManagerContext must be used within a FlowManagerProvider. " +
|
|
41
|
+
"Make sure to wrap your component tree with <FlowManagerProvider>.",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return context;
|
|
46
|
+
}
|
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FlowUploadOptions,
|
|
3
|
-
UploadistaEvent,
|
|
4
|
-
} from "@uploadista/client-browser";
|
|
1
|
+
import type { FlowUploadOptions } from "@uploadista/client-browser";
|
|
5
2
|
import {
|
|
6
|
-
FlowManager,
|
|
3
|
+
type FlowManager,
|
|
7
4
|
type FlowUploadState,
|
|
8
5
|
type FlowUploadStatus,
|
|
9
|
-
type InternalFlowUploadOptions,
|
|
10
6
|
} from "@uploadista/client-core";
|
|
11
|
-
import {
|
|
7
|
+
import type { TypedOutput } from "@uploadista/core/flow";
|
|
12
8
|
import type { UploadFile } from "@uploadista/core/types";
|
|
13
|
-
import { UploadEventType } from "@uploadista/core/types";
|
|
14
9
|
import { computed, onMounted, onUnmounted, readonly, ref } from "vue";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Type guard to check if an event is a flow event
|
|
19
|
-
*/
|
|
20
|
-
function isFlowEvent(event: UploadistaEvent): event is FlowEvent {
|
|
21
|
-
const flowEvent = event as FlowEvent;
|
|
22
|
-
return (
|
|
23
|
-
flowEvent.eventType === EventType.FlowStart ||
|
|
24
|
-
flowEvent.eventType === EventType.FlowEnd ||
|
|
25
|
-
flowEvent.eventType === EventType.FlowError ||
|
|
26
|
-
flowEvent.eventType === EventType.NodeStart ||
|
|
27
|
-
flowEvent.eventType === EventType.NodeEnd ||
|
|
28
|
-
flowEvent.eventType === EventType.NodePause ||
|
|
29
|
-
flowEvent.eventType === EventType.NodeResume ||
|
|
30
|
-
flowEvent.eventType === EventType.NodeError
|
|
31
|
-
);
|
|
32
|
-
}
|
|
10
|
+
import { useFlowManagerContext } from "./useFlowManagerContext";
|
|
33
11
|
|
|
34
12
|
// Re-export types from core for convenience
|
|
35
13
|
export type { FlowUploadState, FlowUploadStatus };
|
|
@@ -109,8 +87,8 @@ const initialState: FlowUploadState = {
|
|
|
109
87
|
* The flow handles the upload process and can perform post-processing like
|
|
110
88
|
* saving to storage, optimizing images, etc.
|
|
111
89
|
*
|
|
112
|
-
* Must be used within
|
|
113
|
-
*
|
|
90
|
+
* Must be used within FlowManagerProvider (which must be within UploadistaProvider).
|
|
91
|
+
* Flow events are automatically routed by the provider to the appropriate manager.
|
|
114
92
|
*
|
|
115
93
|
* @example
|
|
116
94
|
* ```vue
|
|
@@ -141,109 +119,67 @@ const initialState: FlowUploadState = {
|
|
|
141
119
|
export function useFlowUpload<TOutput = UploadFile>(
|
|
142
120
|
options: UseFlowUploadOptions<TOutput>,
|
|
143
121
|
) {
|
|
144
|
-
|
|
145
|
-
const client = useUploadistaClient();
|
|
122
|
+
const { getManager, releaseManager } = useFlowManagerContext();
|
|
146
123
|
const state = ref<FlowUploadState<TOutput>>(
|
|
147
124
|
initialState as FlowUploadState<TOutput>,
|
|
148
125
|
);
|
|
149
|
-
let manager: FlowManager<
|
|
150
|
-
|
|
126
|
+
let manager: FlowManager<unknown, TOutput> | null = null;
|
|
127
|
+
|
|
128
|
+
// Store latest options in a ref to access in callbacks
|
|
129
|
+
const optionsRef = ref(options);
|
|
151
130
|
|
|
152
|
-
//
|
|
131
|
+
// Get or create manager from context when component mounts
|
|
153
132
|
onMounted(() => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
outputNodeId?: string;
|
|
161
|
-
metadata?: Record<string, string>;
|
|
162
|
-
},
|
|
163
|
-
internalOptions: InternalFlowUploadOptions,
|
|
164
|
-
) => {
|
|
165
|
-
const result = await client.client.uploadWithFlow(file, flowConfig, {
|
|
166
|
-
onJobStart: internalOptions.onJobStart,
|
|
167
|
-
onProgress: internalOptions.onProgress,
|
|
168
|
-
onChunkComplete: internalOptions.onChunkComplete,
|
|
169
|
-
onSuccess: internalOptions.onSuccess,
|
|
170
|
-
onError: internalOptions.onError,
|
|
171
|
-
onShouldRetry: internalOptions.onShouldRetry,
|
|
172
|
-
});
|
|
173
|
-
// Return only abort and pause (ignore jobId and return value)
|
|
174
|
-
return {
|
|
175
|
-
abort: async () => {
|
|
176
|
-
await result.abort();
|
|
177
|
-
},
|
|
178
|
-
pause: async () => {
|
|
179
|
-
await result.pause();
|
|
180
|
-
// Ignore the FlowJob return value
|
|
181
|
-
},
|
|
182
|
-
};
|
|
133
|
+
const flowId = options.flowConfig.flowId;
|
|
134
|
+
|
|
135
|
+
// Create stable callback wrappers
|
|
136
|
+
const stableCallbacks = {
|
|
137
|
+
onStateChange: (newState: FlowUploadState<TOutput>) => {
|
|
138
|
+
state.value = newState;
|
|
183
139
|
},
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
? Math.round((bytesUploaded / totalBytes) * 100)
|
|
192
|
-
: 0;
|
|
193
|
-
options.onProgress?.(progress, bytesUploaded, totalBytes);
|
|
194
|
-
}
|
|
195
|
-
: undefined,
|
|
196
|
-
onChunkComplete: options.onChunkComplete,
|
|
197
|
-
onFlowComplete: options.onFlowComplete,
|
|
198
|
-
onSuccess: options.onSuccess,
|
|
199
|
-
onError: options.onError,
|
|
200
|
-
onAbort: options.onAbort,
|
|
140
|
+
onProgress: (_uploadId: string, bytesUploaded: number, totalBytes: number | null) => {
|
|
141
|
+
if (optionsRef.value.onProgress) {
|
|
142
|
+
const progress = totalBytes
|
|
143
|
+
? Math.round((bytesUploaded / totalBytes) * 100)
|
|
144
|
+
: 0;
|
|
145
|
+
optionsRef.value.onProgress(progress, bytesUploaded, totalBytes);
|
|
146
|
+
}
|
|
201
147
|
},
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
onChunkComplete: options.onChunkComplete,
|
|
205
|
-
onFlowComplete: options.onFlowComplete,
|
|
206
|
-
onSuccess: options.onSuccess,
|
|
207
|
-
onError: options.onError,
|
|
208
|
-
onAbort: options.onAbort,
|
|
209
|
-
onShouldRetry: options.onShouldRetry,
|
|
148
|
+
onChunkComplete: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => {
|
|
149
|
+
optionsRef.value.onChunkComplete?.(chunkSize, bytesAccepted, bytesTotal);
|
|
210
150
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
manager?.handleUploadProgress(
|
|
235
|
-
uploadEvent.data.id,
|
|
236
|
-
bytesUploaded,
|
|
237
|
-
totalBytes,
|
|
238
|
-
);
|
|
239
|
-
}
|
|
151
|
+
onFlowComplete: (outputs: TypedOutput[]) => {
|
|
152
|
+
optionsRef.value.onFlowComplete?.(outputs as unknown as Record<string, unknown>);
|
|
153
|
+
},
|
|
154
|
+
onSuccess: (result: TOutput) => {
|
|
155
|
+
optionsRef.value.onSuccess?.(result);
|
|
156
|
+
},
|
|
157
|
+
onError: (error: Error) => {
|
|
158
|
+
optionsRef.value.onError?.(error);
|
|
159
|
+
},
|
|
160
|
+
onAbort: () => {
|
|
161
|
+
optionsRef.value.onAbort?.();
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Get manager from context
|
|
166
|
+
manager = getManager(flowId, stableCallbacks, {
|
|
167
|
+
flowConfig: options.flowConfig,
|
|
168
|
+
onChunkComplete: options.onChunkComplete,
|
|
169
|
+
onFlowComplete: options.onFlowComplete as ((outputs: TypedOutput[]) => void) | undefined,
|
|
170
|
+
onSuccess: options.onSuccess,
|
|
171
|
+
onError: options.onError,
|
|
172
|
+
onAbort: options.onAbort,
|
|
173
|
+
onShouldRetry: options.onShouldRetry,
|
|
240
174
|
});
|
|
241
175
|
});
|
|
242
176
|
|
|
243
177
|
// Cleanup on unmount
|
|
244
178
|
onUnmounted(() => {
|
|
245
|
-
|
|
246
|
-
|
|
179
|
+
if (manager) {
|
|
180
|
+
releaseManager(options.flowConfig.flowId);
|
|
181
|
+
manager = null;
|
|
182
|
+
}
|
|
247
183
|
});
|
|
248
184
|
|
|
249
185
|
const upload = async (file: File | Blob) => {
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import type { UploadistaEvent } from "@uploadista/client-browser";
|
|
7
|
+
import {
|
|
8
|
+
FlowManager,
|
|
9
|
+
type FlowManagerCallbacks,
|
|
10
|
+
type FlowUploadOptions,
|
|
11
|
+
} from "@uploadista/client-core";
|
|
12
|
+
import { EventType, type FlowEvent } from "@uploadista/core/flow";
|
|
13
|
+
import { UploadEventType } from "@uploadista/core/types";
|
|
14
|
+
import { onMounted, onBeforeUnmount, provide } from "vue";
|
|
15
|
+
import { useUploadistaContext } from "../composables/useUploadistaContext";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if an event is a flow event
|
|
19
|
+
*/
|
|
20
|
+
function isFlowEvent(event: UploadistaEvent): event is FlowEvent {
|
|
21
|
+
const flowEvent = event as FlowEvent;
|
|
22
|
+
return (
|
|
23
|
+
flowEvent.eventType === EventType.FlowStart ||
|
|
24
|
+
flowEvent.eventType === EventType.FlowEnd ||
|
|
25
|
+
flowEvent.eventType === EventType.FlowError ||
|
|
26
|
+
flowEvent.eventType === EventType.NodeStart ||
|
|
27
|
+
flowEvent.eventType === EventType.NodeEnd ||
|
|
28
|
+
flowEvent.eventType === EventType.NodePause ||
|
|
29
|
+
flowEvent.eventType === EventType.NodeResume ||
|
|
30
|
+
flowEvent.eventType === EventType.NodeError
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Internal manager registry entry with ref counting
|
|
36
|
+
*/
|
|
37
|
+
interface ManagerEntry<TOutput> {
|
|
38
|
+
manager: FlowManager<unknown, TOutput>;
|
|
39
|
+
refCount: number;
|
|
40
|
+
flowId: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Context value providing access to flow managers
|
|
45
|
+
*/
|
|
46
|
+
interface FlowManagerContextValue {
|
|
47
|
+
getManager: <TOutput = unknown>(
|
|
48
|
+
flowId: string,
|
|
49
|
+
callbacks: FlowManagerCallbacks<TOutput>,
|
|
50
|
+
options: FlowUploadOptions<TOutput>,
|
|
51
|
+
) => FlowManager<unknown, TOutput>;
|
|
52
|
+
releaseManager: (flowId: string) => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const { client, subscribeToEvents } = useUploadistaContext();
|
|
56
|
+
const managers = new Map<string, ManagerEntry<unknown>>();
|
|
57
|
+
let unsubscribe: (() => void) | null = null;
|
|
58
|
+
|
|
59
|
+
// Subscribe to events and route to managers
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
unsubscribe = subscribeToEvents((event: UploadistaEvent) => {
|
|
62
|
+
// Route flow events to all managers (they filter by jobId internally)
|
|
63
|
+
if (isFlowEvent(event)) {
|
|
64
|
+
for (const entry of managers.values()) {
|
|
65
|
+
entry.manager.handleFlowEvent(event);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Route upload progress events to all managers
|
|
71
|
+
if (
|
|
72
|
+
"type" in event &&
|
|
73
|
+
event.type === UploadEventType.UPLOAD_PROGRESS &&
|
|
74
|
+
"data" in event
|
|
75
|
+
) {
|
|
76
|
+
const uploadEvent = event as {
|
|
77
|
+
type: UploadEventType;
|
|
78
|
+
uploadId: string;
|
|
79
|
+
data: { progress: number; total: number | null };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
for (const entry of managers.values()) {
|
|
83
|
+
entry.manager.handleUploadProgress(
|
|
84
|
+
uploadEvent.uploadId,
|
|
85
|
+
uploadEvent.data.progress,
|
|
86
|
+
uploadEvent.data.total,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Cleanup on unmount
|
|
94
|
+
onBeforeUnmount(() => {
|
|
95
|
+
unsubscribe?.();
|
|
96
|
+
for (const entry of managers.values()) {
|
|
97
|
+
entry.manager.cleanup();
|
|
98
|
+
}
|
|
99
|
+
managers.clear();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const getManager = <TOutput,>(
|
|
103
|
+
flowId: string,
|
|
104
|
+
callbacks: FlowManagerCallbacks<TOutput>,
|
|
105
|
+
options: FlowUploadOptions<TOutput>,
|
|
106
|
+
): FlowManager<unknown, TOutput> => {
|
|
107
|
+
const existing = managers.get(flowId);
|
|
108
|
+
|
|
109
|
+
if (existing) {
|
|
110
|
+
// Increment ref count for existing manager
|
|
111
|
+
existing.refCount++;
|
|
112
|
+
return existing.manager as FlowManager<unknown, TOutput>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Create new manager
|
|
116
|
+
const flowUploadFn = (
|
|
117
|
+
input: unknown,
|
|
118
|
+
flowConfig: FlowUploadOptions<TOutput>["flowConfig"],
|
|
119
|
+
internalOptions: unknown,
|
|
120
|
+
) => {
|
|
121
|
+
return client.value.uploadWithFlow(input, flowConfig, internalOptions);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const manager = new FlowManager<unknown, TOutput>(
|
|
125
|
+
flowUploadFn,
|
|
126
|
+
callbacks,
|
|
127
|
+
options,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
managers.set(flowId, {
|
|
131
|
+
manager: manager as FlowManager<unknown, unknown>,
|
|
132
|
+
refCount: 1,
|
|
133
|
+
flowId,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return manager;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const releaseManager = (flowId: string) => {
|
|
140
|
+
const existing = managers.get(flowId);
|
|
141
|
+
if (!existing) return;
|
|
142
|
+
|
|
143
|
+
existing.refCount--;
|
|
144
|
+
|
|
145
|
+
// Clean up when no more refs
|
|
146
|
+
if (existing.refCount <= 0) {
|
|
147
|
+
existing.manager.cleanup();
|
|
148
|
+
managers.delete(flowId);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Provide the context
|
|
153
|
+
const flowManagerContext: FlowManagerContextValue = {
|
|
154
|
+
getManager,
|
|
155
|
+
releaseManager,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
provide("flowManagerContext", flowManagerContext);
|
|
159
|
+
</script>
|