@visulima/storage-client 1.0.0-alpha.3 → 1.0.0-alpha.4

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +239 -1
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## @visulima/storage-client [1.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/storage-client@1.0.0-alpha.3...@visulima/storage-client@1.0.0-alpha.4) (2025-12-27)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **storage-client:** update @testing-library/svelte to version 5.3.1 and improve README for Svelte support ([43e8ea5](https://github.com/visulima/visulima/commit/43e8ea5b01399d5dd0f98882629bceedd411e710))
6
+ * **storage-client:** update package files ([ba9d079](https://github.com/visulima/visulima/commit/ba9d079a5b25169e88836fd23af13796250452b1))
7
+
8
+ ### Miscellaneous Chores
9
+
10
+ * **dependencies:** update file-type to version 21.2.0, hono to version 4.11.3, and improve README for storage-client with detailed usage examples ([90bebfa](https://github.com/visulima/visulima/commit/90bebfa9b732afd8d80c133ca0636192b8496801))
11
+ * fixed project.json names and schema path ([964722f](https://github.com/visulima/visulima/commit/964722f691db205c7edb9aa6db29e849a647500b))
12
+
1
13
  ## @visulima/storage-client [1.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/storage-client@1.0.0-alpha.2...@visulima/storage-client@1.0.0-alpha.3) (2025-12-11)
2
14
 
3
15
  ### Bug Fixes
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  </a>
8
8
 
9
- <h3 align="center">The upload client library. Simple and easy file uploads for React | Vue | Solid | .</h3>
9
+ <h3 align="center">The upload client library. Simple and easy file uploads for React | Vue | Solid | Svelte</h3>
10
10
 
11
11
  <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
12
12
 
@@ -48,10 +48,248 @@ yarn add @visulima/storage-client
48
48
  pnpm add @visulima/storage-client
49
49
  ```
50
50
 
51
+ ## Description
52
+
53
+ The Visulima Storage Client is a powerful, framework-agnostic library for handling file uploads in modern web applications. It provides a unified API across React, Vue, Nuxt, Solid, and Svelte with support for multiple upload methods, progress tracking, retry mechanisms, and batch operations.
54
+
55
+ ## Features
56
+
57
+ - **Framework Support** - First-class support for React, Vue/Nuxt, Solid, and Svelte
58
+ - **Multiple Upload Methods** - Multipart (form-based), TUS (resumable), and chunked REST uploads
59
+ - **Auto-detection** - Automatically selects the best upload method based on file size and available endpoints
60
+ - **Progress Tracking** - Real-time upload progress with percentage and byte-level tracking
61
+ - **Batch Operations** - Upload multiple files simultaneously with batch progress tracking
62
+ - **Retry Mechanism** - Built-in retry with exponential backoff for failed uploads
63
+ - **File Management** - Get, list, delete files with full metadata support
64
+ - **TypeScript Ready** - Full TypeScript support with comprehensive type definitions
65
+ - **TanStack Query Integration** - Built on TanStack Query for powerful caching and state management
66
+ - **Drag & Drop Support** - Built-in file input hooks with drag & drop functionality
67
+ - **Paste Upload** - Support for pasting images from clipboard
68
+ - **Transform Support** - Transform files and metadata on upload
69
+ - **Abort Control** - Cancel uploads at any time with abort functionality
70
+
71
+ ## Prerequisites
72
+
73
+ The storage client requires TanStack Query (formerly React Query) for state management. You'll need to install the appropriate version for your framework:
74
+
75
+ - **React**: `@tanstack/react-query` >= 5.90.10
76
+ - **Vue**: `@tanstack/vue-query` >= 5.91.2
77
+ - **Solid**: `@tanstack/solid-query` >= 5.90.13
78
+ - **Svelte**: `@tanstack/svelte-query` >= 6.0.8
79
+
51
80
  ## Usage
52
81
 
82
+ ### React
83
+
84
+ ```tsx
85
+ import { useUpload } from "@visulima/storage-client/react";
86
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
87
+
88
+ const queryClient = new QueryClient();
89
+
90
+ function App() {
91
+ return (
92
+ <QueryClientProvider client={queryClient}>
93
+ <UploadComponent />
94
+ </QueryClientProvider>
95
+ );
96
+ }
97
+
98
+ function UploadComponent() {
99
+ const { upload, progress, isUploading, error, result } = useUpload({
100
+ endpointMultipart: "/api/upload/multipart",
101
+ onSuccess: (result) => console.log("Upload successful:", result),
102
+ });
103
+
104
+ const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
105
+ const file = e.target.files?.[0];
106
+ if (file) {
107
+ await upload(file);
108
+ }
109
+ };
110
+
111
+ return (
112
+ <div>
113
+ <input type="file" onChange={handleFileChange} />
114
+ {isUploading && <div>Progress: {progress}%</div>}
115
+ {error && <div>Error: {error.message}</div>}
116
+ {result && <div>File ID: {result.id}</div>}
117
+ </div>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ### Vue / Nuxt
123
+
124
+ ```vue
125
+ <template>
126
+ <div>
127
+ <input type="file" @change="handleFileChange" />
128
+ <div v-if="isUploading">Progress: {{ progress }}%</div>
129
+ <div v-if="error">Error: {{ error.message }}</div>
130
+ <div v-if="result">File ID: {{ result.id }}</div>
131
+ </div>
132
+ </template>
133
+
134
+ <script setup lang="ts">
135
+ import { useUpload } from "@visulima/storage-client/vue";
136
+
137
+ const { upload, progress, isUploading, error, result } = useUpload({
138
+ endpointMultipart: "/api/upload/multipart",
139
+ });
140
+
141
+ const handleFileChange = async (e: Event) => {
142
+ const target = e.target as HTMLInputElement;
143
+ const file = target.files?.[0];
144
+ if (file) {
145
+ await upload(file);
146
+ }
147
+ };
148
+ </script>
149
+ ```
150
+
151
+ ### Solid
152
+
153
+ ```tsx
154
+ import { createUpload } from "@visulima/storage-client/solid";
155
+ import { QueryClient, QueryClientProvider } from "@tanstack/solid-query";
156
+
157
+ const queryClient = new QueryClient();
158
+
159
+ function App() {
160
+ return (
161
+ <QueryClientProvider client={queryClient}>
162
+ <UploadComponent />
163
+ </QueryClientProvider>
164
+ );
165
+ }
166
+
167
+ function UploadComponent() {
168
+ const { upload, progress, isUploading, error, result } = createUpload({
169
+ endpointMultipart: "/api/upload/multipart",
170
+ });
171
+
172
+ const handleFileChange = async (e: Event) => {
173
+ const target = e.target as HTMLInputElement;
174
+ const file = target.files?.[0];
175
+ if (file) {
176
+ await upload(file);
177
+ }
178
+ };
179
+
180
+ return (
181
+ <div>
182
+ <input type="file" onChange={handleFileChange} />
183
+ {isUploading() && <div>Progress: {progress()}%</div>}
184
+ {error() && <div>Error: {error()?.message}</div>}
185
+ {result() && <div>File ID: {result()?.id}</div>}
186
+ </div>
187
+ );
188
+ }
189
+ ```
190
+
191
+ ### Svelte
192
+
193
+ ```svelte
194
+ <script lang="ts">
195
+ import { createUpload } from "@visulima/storage-client/svelte";
196
+ import { QueryClient, QueryClientProvider } from "@tanstack/svelte-query";
197
+
198
+ const queryClient = new QueryClient();
199
+
200
+ const { upload, progress, isUploading, error, result } = createUpload({
201
+ endpointMultipart: "/api/upload/multipart",
202
+ });
203
+
204
+ async function handleFileChange(e: Event) {
205
+ const target = e.target as HTMLInputElement;
206
+ const file = target.files?.[0];
207
+ if (file) {
208
+ await upload(file);
209
+ }
210
+ }
211
+ </script>
212
+
213
+ <QueryClientProvider client={queryClient}>
214
+ <div>
215
+ <input type="file" on:change={handleFileChange} />
216
+ {#if $isUploading}
217
+ <div>Progress: {$progress}%</div>
218
+ {/if}
219
+ {#if $error}
220
+ <div>Error: {$error.message}</div>
221
+ {/if}
222
+ {#if $result}
223
+ <div>File ID: {$result.id}</div>
224
+ {/if}
225
+ </div>
226
+ </QueryClientProvider>
227
+ ```
228
+
229
+ ## Upload Methods
230
+
231
+ ### Multipart Upload
232
+
233
+ Traditional `multipart/form-data` uploads, perfect for small to medium files and web forms.
234
+
235
+ ```tsx
236
+ import { useMultipartUpload } from "@visulima/storage-client/react";
237
+
238
+ const { upload, progress, isUploading } = useMultipartUpload({
239
+ endpoint: "/api/upload/multipart",
240
+ });
241
+
242
+ await upload(file);
243
+ ```
244
+
245
+ ### TUS Upload
246
+
247
+ Resumable uploads using the TUS protocol, ideal for large files and unreliable networks.
248
+
249
+ ```tsx
250
+ import { useTusUpload } from "@visulima/storage-client/react";
251
+
252
+ const { upload, pause, resume, progress } = useTusUpload({
253
+ endpoint: "/api/upload/tus",
254
+ });
255
+
256
+ await upload(file);
257
+ // Can pause and resume later
258
+ pause();
259
+ resume();
260
+ ```
261
+
262
+ ### Chunked REST Upload
263
+
264
+ Client-side chunked uploads for large files without requiring TUS server support.
265
+
266
+ ```tsx
267
+ import { useChunkedRestUpload } from "@visulima/storage-client/react";
268
+
269
+ const { upload, progress } = useChunkedRestUpload({
270
+ endpoint: "/api/upload/chunked-rest",
271
+ chunkSize: 5 * 1024 * 1024, // 5MB chunks
272
+ });
273
+
274
+ await upload(file);
275
+ ```
276
+
277
+ ## Documentation
278
+
279
+ For complete documentation and examples, visit:
280
+
281
+ - [Installation Guide](https://visulima.com/docs/package/storage-client/installation)
282
+ - [React Guide](https://visulima.com/docs/package/storage-client/react)
283
+ - [Vue / Nuxt Guide](https://visulima.com/docs/package/storage-client/vue)
284
+ - [Solid Guide](https://visulima.com/docs/package/storage-client/solid)
285
+ - [Svelte Guide](https://visulima.com/docs/package/storage-client/svelte)
286
+ - [Next.js Guide](https://visulima.com/docs/package/storage-client/nextjs)
287
+ - [TanStack Start Guide](https://visulima.com/docs/package/storage-client/tanstack-start)
288
+
53
289
  ## Related
54
290
 
291
+ - [@visulima/storage-server](../storage-server) - Server-side storage implementation
292
+
55
293
  ## Supported Node.js Versions
56
294
 
57
295
  Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/storage-client",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "The upload client library. Simple and easy file uploads for React | Vue | Solid | .",
5
5
  "keywords": [
6
6
  "visulima",