Skip to content

Commit 290fb78

Browse files
nits
1 parent f9ec892 commit 290fb78

File tree

14 files changed

+49
-45
lines changed

14 files changed

+49
-45
lines changed

examples/profile-picture/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@auth/drizzle-adapter": "^1.2.0",
1717
"@libsql/client": "^0.14.0",
1818
"@uploadthing/react": "7.3.0",
19-
"class-variance-authority": "^0.7.0",
19+
"class-variance-authority": "^0.7.1",
2020
"client-only": "^0.0.1",
2121
"drizzle-orm": "^0.38.3",
2222
"lucide-react": "^0.469.0",

examples/with-novel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@tailwindcss/typography": "^0.5.15",
1313
"@uploadthing/react": "7.3.0",
14-
"class-variance-authority": "^0.7.0",
14+
"class-variance-authority": "^0.7.1",
1515
"cmdk": "^1.1.1",
1616
"lucide-react": "^0.469.0",
1717
"next": "15.3.1",

packages/uploadthing/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@
146146
},
147147
"scripts": {
148148
"lint": "eslint src test --max-warnings 0",
149-
"build": "NODE_OPTIONS='--max_old_space_size=8192' bunchee --tsconfig tsconfig.build.json && cp src/tw/v4.css tw/v4.css",
149+
"build": "NODE_OPTIONS='--max_old_space_size=16384' bunchee --tsconfig tsconfig.build.json && cp src/tw/v4.css tw/v4.css",
150150
"clean": "git clean -xdf client express fastify h3 internal next next-legacy server tw node_modules",
151-
"dev": "NODE_OPTIONS='--max_old_space_size=8192' bunchee --tsconfig tsconfig.build.json --no-clean && cp src/tw/v4.css tw/v4.css",
151+
"dev": "NODE_OPTIONS='--max_old_space_size=16384' bunchee --tsconfig tsconfig.build.json --no-clean && cp src/tw/v4.css tw/v4.css",
152152
"prepack": "bun ../../.github/replace-workspace-protocol.ts",
153153
"test": "vitest run",
154154
"typecheck": "tsc --noEmit"

packages/uploadthing/src/client-future.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const future_genUploader = <TRouter extends FileRouter>(
162162
const files = Arr.ensure(file ?? options.files);
163163
for (const file of files) {
164164
const upload = uploads.get(file);
165-
if (!upload) return;
165+
if (!upload) throw "No upload found";
166166

167167
if (upload.deferred.ac.signal.aborted === false) {
168168
// Ensure the upload is paused

packages/uploadthing/src/client.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
} from "@uploadthing/shared";
1515

1616
import * as pkgJson from "../package.json";
17-
import * as Future from "./_internal/client-future";
1817
import type { Deferred } from "./_internal/deferred";
1918
import { createDeferred } from "./_internal/deferred";
2019
import { uploadFile, uploadFilesInternal } from "./_internal/upload-browser";
@@ -51,8 +50,6 @@ export {
5150
UploadPausedError,
5251
} from "@uploadthing/shared";
5352

54-
export { Future };
55-
5653
/**
5754
* Validate that a file is of a valid type given a route config
5855
* @public

packages/uploadthing/turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"build": {
66
"outputs": [
77
"client/**",
8+
"client-future/**",
89
"dist/**",
910
"effect-platform/**",
1011
"express/**",

playground/app/api/uploadthing/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getSession } from "../../../lib/data";
1414
const fileRoute = createUploadthing();
1515

1616
export const uploadRouter = {
17-
anything: fileRoute({
17+
anyPrivate: fileRoute({
1818
blob: { maxFileSize: "256MB", maxFileCount: 10, acl: "private" },
1919
})
2020
.input(z.object({}))

playground/app/future/page.tsx

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
"use client";
22

3-
import { useState } from "react";
3+
import { useState, useTransition } from "react";
44

5-
import { Future } from "uploadthing/client";
5+
import { AnyFile } from "uploadthing/client-future";
66

77
import { future_createUpload, future_uploadFiles } from "../../lib/uploadthing";
88
import { UploadRouter } from "../api/uploadthing/route";
99

1010
function AsyncUploader() {
11-
const [files, setFiles] = useState<
12-
Future.AnyFile<UploadRouter["anything"]>[]
13-
>([]);
11+
const [files, setFiles] = useState<AnyFile<UploadRouter["anyPrivate"]>[]>([]);
1412

1513
return (
1614
<div className="mx-auto max-w-2xl p-8">
@@ -20,7 +18,7 @@ function AsyncUploader() {
2018
const files = formData.getAll("files") as File[];
2119
console.log("SUBMITTED", files);
2220

23-
const result = await future_uploadFiles("anything", {
21+
const result = await future_uploadFiles("anyPrivate", {
2422
files,
2523
onEvent: (event) => {
2624
console.log("EVENT", event);
@@ -54,49 +52,52 @@ function AsyncUploader() {
5452
}
5553

5654
function ControlledUploader() {
57-
const [files, setFiles] = useState<
58-
Future.AnyFile<UploadRouter["anything"]>[]
59-
>([]);
55+
const [files, setFiles] = useState<AnyFile<UploadRouter["anyPrivate"]>[]>([]);
6056
const [selectedFiles, setSelectedFiles] = useState<File[]>([]);
6157
const [uploadControls, setUploadControls] = useState<Awaited<
6258
ReturnType<typeof future_createUpload>
6359
> | null>(null);
6460
const [isUploading, setIsUploading] = useState(false);
61+
const [isPending, startTransition] = useTransition();
6562

6663
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
6764
if (e.target.files && e.target.files.length > 0) {
6865
setSelectedFiles(Array.from(e.target.files));
6966
}
7067
};
7168

72-
const handleSubmit = async (e: React.FormEvent) => {
69+
const handleSubmit = (e: React.FormEvent) => {
7370
e.preventDefault();
7471
if (selectedFiles.length === 0) return;
7572

76-
setIsUploading(true);
73+
startTransition(async () => {
74+
setIsUploading(true);
7775

78-
// Create uploads for each file
79-
const controls = await future_createUpload("anything", {
80-
files: selectedFiles,
81-
onEvent: (event) => {
82-
console.log("EVENT", event);
83-
setFiles([...event.files]);
84-
},
85-
input: {},
86-
});
76+
// Create uploads for each file
77+
const controls = await future_createUpload("anyPrivate", {
78+
files: selectedFiles,
79+
onEvent: (event) => {
80+
console.log("EVENT", event);
81+
setFiles([...event.files]);
82+
},
83+
input: {},
84+
});
8785

88-
setUploadControls(controls);
86+
setUploadControls(controls);
87+
});
8988
};
9089

91-
const handleComplete = async () => {
90+
const handleComplete = () => {
9291
if (uploadControls?.done) {
93-
const result = await uploadControls.done();
94-
console.log("COMPLETE", result);
95-
setIsUploading(false);
96-
setSelectedFiles([]);
97-
setFiles([]);
98-
setUploadControls(null);
99-
alert("Upload complete!");
92+
startTransition(async () => {
93+
const result = await uploadControls.done();
94+
console.log("COMPLETE", result);
95+
setIsUploading(false);
96+
setSelectedFiles([]);
97+
setFiles([]);
98+
setUploadControls(null);
99+
alert("Upload complete!");
100+
});
100101
}
101102
};
102103

@@ -121,8 +122,9 @@ function ControlledUploader() {
121122
{isUploading && uploadControls && (
122123
<button
123124
type="button"
124-
className="inline-flex rounded bg-green-500 px-4 py-2 text-black transition-colors hover:bg-green-600"
125+
className="inline-flex rounded bg-green-500 px-4 py-2 text-black transition-colors hover:bg-green-600 disabled:opacity-50"
125126
onClick={handleComplete}
127+
disabled={isPending}
126128
>
127129
Complete Upload
128130
</button>

playground/components/fieldset.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import cx from "clsx";
2+
import { cx } from "class-variance-authority";
33

44
export function Input({
55
className,

playground/components/file-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useTransition } from "react";
4-
import cx from "clsx";
4+
import { cx } from "class-variance-authority";
55

66
import { deleteFile, getFileUrl } from "../lib/actions";
77
import { ListedFileInfo } from "../lib/data";

0 commit comments

Comments
 (0)