-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuploadWidget.ts
More file actions
1618 lines (1408 loc) · 47 KB
/
uploadWidget.ts
File metadata and controls
1618 lines (1408 loc) · 47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as vscode from "vscode";
import { CloudinaryTreeDataProvider } from "../tree/treeDataProvider";
import { v2 as cloudinary } from "cloudinary";
import { Readable } from "stream";
/**
* Represents an upload preset from Cloudinary with its configuration.
*/
interface UploadPreset {
name: string;
signed: boolean;
settings?: Record<string, any>;
}
/**
* Represents a folder option for the upload destination.
*/
interface FolderOption {
path: string;
label: string;
}
/**
* Singleton panel instance for the upload widget.
* Only one upload panel exists at a time.
*/
let uploadPanel: vscode.WebviewPanel | undefined;
/**
* Current folder path for uploads (managed by extension, updated via messages).
*/
let currentFolderPath = "";
/**
* Registers commands for the Cloudinary upload widget.
* - cloudinary.openUploadWidget: Opens the upload widget (root folder selected)
* - cloudinary.uploadToFolder: Opens the upload widget with a specific folder pre-selected
*/
function registerUpload(
context: vscode.ExtensionContext,
provider: CloudinaryTreeDataProvider
) {
// Register command to open upload widget (root)
context.subscriptions.push(
vscode.commands.registerCommand("cloudinary.openUploadWidget", async () => {
try {
// Fetch presets but don't require them - signed uploads work without presets
await provider.fetchUploadPresets();
openOrRevealUploadPanel("", provider, context);
} catch (err: any) {
vscode.window.showErrorMessage(`Failed to open upload widget: ${err.message}`);
}
})
);
// Register command to open upload widget in a specific folder
context.subscriptions.push(
vscode.commands.registerCommand(
"cloudinary.uploadToFolder",
async (folderItem: { label: string; data: { path?: string } }) => {
try {
// Fetch presets but don't require them - signed uploads work without presets
await provider.fetchUploadPresets();
const folderPath = folderItem.data.path || "";
openOrRevealUploadPanel(folderPath, provider, context);
} catch (err: any) {
vscode.window.showErrorMessage(`Failed to open upload widget: ${err.message}`);
}
}
)
);
}
/**
* Opens the upload panel or reveals it if already open.
* If a folder path is provided, updates the folder selection in the webview.
*/
function openOrRevealUploadPanel(
folderPath: string,
provider: CloudinaryTreeDataProvider,
context: vscode.ExtensionContext
) {
currentFolderPath = folderPath;
if (uploadPanel) {
// Panel exists - reveal it and update the folder selection
uploadPanel.reveal(vscode.ViewColumn.One);
uploadPanel.webview.postMessage({
command: "setFolder",
folderPath: folderPath,
});
return;
}
// Create new panel
uploadPanel = createUploadPanel(provider, context);
// Clear reference when panel is disposed
uploadPanel.onDidDispose(() => {
uploadPanel = undefined;
});
}
/**
* Size threshold (in bytes) above which to use chunked upload.
* Files over 100 MB require chunked upload to avoid 413 errors.
* We use a lower threshold (20 MB) for better reliability.
*/
const CHUNKED_UPLOAD_THRESHOLD = 20 * 1024 * 1024; // 20 MB
/**
* Chunk size for chunked uploads. 6 MB is a good balance between
* network resilience and upload speed.
*/
const UPLOAD_CHUNK_SIZE = 6 * 1024 * 1024; // 6 MB
/**
* Uploads a file to Cloudinary with progress tracking.
* Uses chunked upload for large files to avoid 413 errors.
*/
async function uploadWithProgress(
panel: vscode.WebviewPanel,
dataUri: string,
options: Record<string, any>,
fileId: string
): Promise<any> {
// Convert data URI to buffer
const base64Data = dataUri.split(",")[1];
const buffer = Buffer.from(base64Data, "base64");
// Use chunked upload for large files to avoid 413 errors
const useChunkedUpload = buffer.length > CHUNKED_UPLOAD_THRESHOLD;
return new Promise((resolve, reject) => {
let uploadStream;
if (useChunkedUpload) {
// Use chunked upload for large files
uploadStream = cloudinary.uploader.upload_chunked_stream(
{ ...options, chunk_size: UPLOAD_CHUNK_SIZE },
(error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
}
);
} else {
// Use standard upload stream for smaller files
uploadStream = cloudinary.uploader.upload_stream(
options,
(error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
}
);
}
// Create readable stream with progress tracking
let uploaded = 0;
const total = buffer.length;
const progressChunkSize = 64 * 1024; // 64KB chunks for progress reporting
const readable = new Readable({
read() {
const chunk = buffer.slice(uploaded, uploaded + progressChunkSize);
if (chunk.length > 0) {
uploaded += chunk.length;
const percent = Math.round((uploaded / total) * 100);
panel.webview.postMessage({
command: "uploadProgress",
fileId,
percent,
});
this.push(chunk);
} else {
this.push(null);
}
},
});
readable.pipe(uploadStream);
});
}
/**
* Collects all folder paths from the provider's cache.
*/
function collectFolderOptions(provider: CloudinaryTreeDataProvider): FolderOption[] {
const folders: FolderOption[] = [{ path: "", label: "/ (root)" }];
// Get folders from provider's cache
const cachedFolders = provider.getAvailableFolders();
for (const folder of cachedFolders) {
folders.push({
path: folder.path,
label: folder.path,
});
}
return folders;
}
/**
* Creates the webview panel with custom upload UI.
*/
function createUploadPanel(
provider: CloudinaryTreeDataProvider,
context: vscode.ExtensionContext
): vscode.WebviewPanel {
const panel = vscode.window.createWebviewPanel(
"cloudinaryUploadWidget",
"Upload to Cloudinary",
vscode.ViewColumn.One,
{ enableScripts: true, retainContextWhenHidden: true }
);
// Set the panel icon to the Cloudinary logo
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, "resources", "cloudinary_icon_blue.png");
const currentPreset = provider.getCurrentUploadPreset() || "";
const cloudName = provider.cloudName!;
const folders = collectFolderOptions(provider);
// Set up the webview HTML content
panel.webview.html = getWebviewContent(
currentPreset,
provider,
currentFolderPath,
cloudName,
folders
);
// Handle messages from the webview
panel.webview.onDidReceiveMessage(async (message: {
command: string;
fileId?: string;
fileName?: string;
dataUri?: string;
url?: string;
preset?: string;
text?: string;
folderPath?: string;
publicId?: string;
tags?: string;
asset?: any;
}) => {
// Update current folder when changed in webview
if (message.command === "folderChanged" && message.folderPath !== undefined) {
currentFolderPath = message.folderPath;
return;
}
// Get upload options based on current preset, folder, and optional overrides
// Upload preset is optional - signed uploads work without one
const getUploadOptions = (presetName: string | null | undefined, folder: string, publicId?: string, tags?: string, fileName?: string) => {
const options: Record<string, any> = {
resource_type: "auto",
};
// Only add upload_preset if one is selected (not null, undefined, or empty string)
if (presetName && presetName.trim()) {
options.upload_preset = presetName;
}
// Add folder configuration
if (folder) {
if (provider.dynamicFolders) {
options.asset_folder = folder;
} else {
options.folder = folder;
}
}
// Preserve original filename when uploading data URIs
// This prevents Cloudinary from defaulting to "file" for original_filename
if (fileName) {
options.filename_override = fileName;
// For dynamic folders, also set display_name from original filename
if (provider.dynamicFolders) {
// Remove file extension for display_name
const displayName = fileName.replace(/\.[^/.]+$/, "");
options.display_name = displayName;
}
}
// Add custom public_id if provided
if (publicId && publicId.trim()) {
options.public_id = publicId.trim();
}
// Add tags if provided (comma-separated string)
if (tags && tags.trim()) {
options.tags = tags.split(",").map((t: string) => t.trim()).filter((t: string) => t);
}
return options;
};
if (message.command === "uploadFile" && message.dataUri && message.fileId) {
// Use nullish coalescing - empty string "" means "no preset" (signed upload)
const presetName = message.preset !== undefined ? message.preset : currentPreset;
const folder = message.folderPath !== undefined ? message.folderPath : currentFolderPath;
const options = getUploadOptions(presetName, folder, message.publicId, message.tags, message.fileName);
try {
panel.webview.postMessage({
command: "uploadStarted",
fileId: message.fileId,
});
const result = await uploadWithProgress(
panel,
message.dataUri,
options,
message.fileId
);
// Include folder info and original filename in the result for display
result._uploadedToFolder = folder || "(root)";
result._originalFileName = message.fileName;
panel.webview.postMessage({
command: "uploadComplete",
fileId: message.fileId,
asset: result,
});
vscode.commands.executeCommand("cloudinary.refresh");
} catch (err: any) {
panel.webview.postMessage({
command: "uploadError",
fileId: message.fileId,
error: err.message || "Upload failed",
});
vscode.window.showErrorMessage(`Upload failed: ${err.message}`);
}
}
if (message.command === "uploadUrl" && message.url) {
// Use nullish coalescing - empty string "" means "no preset" (signed upload)
const presetName = message.preset !== undefined ? message.preset : currentPreset;
const folder = message.folderPath !== undefined ? message.folderPath : currentFolderPath;
// Try to extract filename from URL for display_name
let urlFileName: string | undefined;
try {
const urlPath = new URL(message.url).pathname;
const lastSegment = urlPath.split('/').pop();
if (lastSegment && lastSegment.includes('.')) {
urlFileName = lastSegment;
}
} catch {
// Invalid URL, skip filename extraction
}
const options = getUploadOptions(presetName, folder, message.publicId, message.tags, urlFileName);
const fileId = message.fileId || `url-${Date.now()}`;
try {
panel.webview.postMessage({
command: "uploadStarted",
fileId,
fileName: message.url,
});
// URL uploads don't support progress tracking, so we simulate it
panel.webview.postMessage({
command: "uploadProgress",
fileId,
percent: 50,
});
const result = await cloudinary.uploader.upload(message.url, options);
// Include folder info and original filename in the result for display
result._uploadedToFolder = folder || "(root)";
result._originalFileName = urlFileName;
panel.webview.postMessage({
command: "uploadComplete",
fileId,
asset: result,
});
vscode.commands.executeCommand("cloudinary.refresh");
} catch (err: any) {
panel.webview.postMessage({
command: "uploadError",
fileId,
error: err.message || "Upload failed",
});
vscode.window.showErrorMessage(`Upload failed: ${err.message}`);
}
}
if (message.command === "copyToClipboard" && message.text) {
await vscode.env.clipboard.writeText(message.text);
}
if (message.command === "refreshFolders") {
// Refresh folder list from provider
const updatedFolders = collectFolderOptions(provider);
panel.webview.postMessage({
command: "updateFolders",
folders: updatedFolders,
});
}
if (message.command === "openAsset" && message.asset) {
// Transform upload response to match expected AssetData format for preview
const asset = message.asset;
const assetType = asset.resource_type || 'raw';
// Generate optimized URL (same logic as cloudinaryItem.ts)
const optimizedUrl = assetType === 'raw'
? cloudinary.url(asset.public_id, {
resource_type: 'raw',
type: asset.type,
})
: cloudinary.url(asset.public_id, {
resource_type: assetType,
type: asset.type,
transformation: [
{ fetch_format: assetType === 'video' ? 'auto:video' : 'auto' },
{ quality: 'auto' }
],
});
// Determine the best filename to use
// Prefer our stored original filename, then Cloudinary's original_filename (if not "file"), then public_id
let filename = asset._originalFileName
|| (asset.original_filename && asset.original_filename !== 'file' ? asset.original_filename : null)
|| asset.public_id.split('/').pop()
|| asset.public_id;
// Enrich asset data with fields expected by preview
const enrichedAsset = {
...asset,
displayType: assetType,
optimized_url: optimizedUrl,
filename: filename,
};
// Open the asset in preview panel
vscode.commands.executeCommand("cloudinary.openAsset", enrichedAsset);
}
});
return panel;
}
/**
* Generates the HTML content for the custom upload webview.
*/
function getWebviewContent(
currentPreset: string,
provider: CloudinaryTreeDataProvider,
initialFolderPath: string,
cloudName: string,
folders: FolderOption[]
): string {
// Serialize presets for JavaScript
const presetsJson = JSON.stringify(provider.uploadPresets);
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Upload to Cloudinary</title>
<style>
/* Reset and base */
*, *::before, *::after {
box-sizing: border-box;
}
body {
font-family: var(--vscode-font-family);
background-color: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
margin: 0;
padding: 1rem;
display: flex;
justify-content: center;
align-items: flex-start;
}
/* Main container */
.upload-panel {
background-color: var(--vscode-editorWidget-background);
padding: 1.25rem;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
max-width: 750px;
width: 100%;
}
.upload-panel h2 {
margin: 0 0 1rem 0;
font-size: 1.15rem;
font-weight: 600;
color: var(--vscode-editor-foreground);
}
/* Settings row */
.settings-row {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.setting-group {
flex: 1;
min-width: 200px;
background-color: var(--vscode-editor-background);
border-radius: 6px;
padding: 0.65rem 0.85rem;
border: 1px solid var(--vscode-editorWidget-border);
}
.setting-group.full-width {
flex: 100%;
min-width: 100%;
}
.setting-label {
font-size: 0.75rem;
font-weight: 600;
margin: 0 0 0.4rem 0;
color: var(--vscode-descriptionForeground);
text-transform: uppercase;
letter-spacing: 0.5px;
display: flex;
align-items: center;
gap: 0.5rem;
}
.setting-group select,
.setting-group input[type="text"] {
width: 100%;
background-color: var(--vscode-dropdown-background);
color: var(--vscode-dropdown-foreground);
border: 1px solid var(--vscode-dropdown-border);
padding: 0.4rem 0.6rem;
border-radius: 4px;
font-size: 0.85rem;
}
.setting-group input[type="text"] {
background-color: var(--vscode-input-background);
color: var(--vscode-input-foreground);
border-color: var(--vscode-input-border);
}
.setting-group input[type="text"]:focus {
outline: none;
border-color: var(--vscode-focusBorder);
}
.setting-group input[type="text"]::placeholder {
color: var(--vscode-input-placeholderForeground);
}
.input-hint {
font-size: 0.7rem;
color: var(--vscode-descriptionForeground);
margin-top: 0.25rem;
font-weight: normal;
}
/* Preset details toggle */
.preset-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.preset-details-toggle {
background: none;
border: none;
color: var(--vscode-textLink-foreground);
cursor: pointer;
padding: 0;
font-size: 0.7rem;
display: flex;
align-items: center;
gap: 0.25rem;
}
.preset-details-toggle::before {
content: '▶';
font-size: 0.55rem;
transition: transform 0.2s;
}
.preset-details-toggle.expanded::before {
transform: rotate(90deg);
}
.preset-details {
margin-top: 0.5rem;
padding: 0.5rem;
background-color: var(--vscode-editor-background);
border-radius: 4px;
font-size: 0.7rem;
font-family: var(--vscode-editor-font-family, monospace);
white-space: pre-wrap;
max-height: 150px;
overflow-y: auto;
border: 1px solid var(--vscode-editorWidget-border);
display: none;
color: var(--vscode-descriptionForeground);
}
.preset-details.visible {
display: block;
}
/* Collapsible section */
.collapsible-section {
margin-bottom: 1rem;
}
.collapsible-header {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
padding: 0.5rem 0;
user-select: none;
}
.collapsible-header::before {
content: '▶';
font-size: 0.65rem;
transition: transform 0.2s;
color: var(--vscode-descriptionForeground);
}
.collapsible-header.expanded::before {
transform: rotate(90deg);
}
.collapsible-header span {
font-size: 0.8rem;
font-weight: 600;
color: var(--vscode-descriptionForeground);
}
.collapsible-content {
display: none;
padding-top: 0.5rem;
}
.collapsible-content.visible {
display: block;
}
/* Tabs */
.upload-tabs {
display: flex;
gap: 0;
margin-bottom: 1rem;
border-bottom: 1px solid var(--vscode-editorWidget-border);
}
.tab {
background: none;
border: none;
padding: 0.65rem 1.25rem;
font-size: 0.85rem;
cursor: pointer;
color: var(--vscode-descriptionForeground);
border-bottom: 2px solid transparent;
margin-bottom: -1px;
transition: color 0.2s, border-color 0.2s;
}
.tab:hover {
color: var(--vscode-editor-foreground);
}
.tab.active {
color: var(--vscode-textLink-foreground);
border-bottom-color: var(--vscode-textLink-foreground);
font-weight: 500;
}
/* Tab content */
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
/* Drop zone */
.drop-zone {
border: 2px dashed var(--vscode-editorWidget-border);
border-radius: 10px;
padding: 2.5rem 1.5rem;
text-align: center;
transition: border-color 0.2s, background-color 0.2s;
background-color: var(--vscode-editor-background);
}
.drop-zone:hover,
.drop-zone.drag-over {
border-color: var(--vscode-focusBorder);
background-color: rgba(0, 120, 212, 0.05);
}
.drop-zone-icon {
margin-bottom: 0.75rem;
color: var(--vscode-textLink-foreground);
opacity: 0.8;
}
.drop-zone p {
margin: 0.4rem 0;
color: var(--vscode-descriptionForeground);
font-size: 0.9rem;
}
.drop-zone .or-text {
margin: 0.75rem 0;
font-size: 0.8rem;
opacity: 0.6;
}
.browse-btn {
background-color: var(--vscode-button-background);
color: var(--vscode-button-foreground);
border: none;
padding: 0.6rem 1.5rem;
border-radius: 4px;
font-size: 0.85rem;
cursor: pointer;
margin-top: 0.5rem;
transition: background-color 0.2s;
}
.browse-btn:hover {
background-color: var(--vscode-button-hoverBackground);
}
/* URL input */
.url-input-group {
display: flex;
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.url-input {
flex: 1;
background-color: var(--vscode-input-background);
color: var(--vscode-input-foreground);
border: 1px solid var(--vscode-input-border);
padding: 0.6rem 0.85rem;
border-radius: 4px;
font-size: 0.85rem;
}
.url-input:focus {
outline: none;
border-color: var(--vscode-focusBorder);
}
.upload-url-btn {
background-color: var(--vscode-button-background);
color: var(--vscode-button-foreground);
border: none;
padding: 0.6rem 1.25rem;
border-radius: 4px;
font-size: 0.85rem;
cursor: pointer;
transition: background-color 0.2s;
white-space: nowrap;
}
.upload-url-btn:hover {
background-color: var(--vscode-button-hoverBackground);
}
.upload-url-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Upload queue */
#upload-queue {
margin-top: 1rem;
}
#upload-queue:empty {
display: none;
}
.queue-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.6rem 0.75rem;
background: var(--vscode-editor-background);
border-radius: 6px;
margin-bottom: 0.5rem;
border: 1px solid var(--vscode-editorWidget-border);
}
.queue-item .file-name {
flex: 1;
font-size: 0.8rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200px;
}
.queue-item .progress-bar {
flex: 2;
height: 6px;
background: var(--vscode-progressBar-background);
border-radius: 3px;
overflow: hidden;
}
.queue-item .progress {
height: 100%;
background: var(--vscode-progressBar-foreground, #0078d4);
transition: width 0.15s ease-out;
border-radius: 3px;
}
.queue-item .status {
font-size: 0.75rem;
color: var(--vscode-descriptionForeground);
min-width: 80px;
text-align: right;
}
.queue-item.complete .progress {
background: var(--vscode-testing-iconPassed, #4caf50);
}
.queue-item.complete .status {
color: var(--vscode-testing-iconPassed, #4caf50);
}
.queue-item.error .progress {
background: var(--vscode-testing-iconFailed, #f44336);
}
.queue-item.error .status {
color: var(--vscode-testing-iconFailed, #f44336);
}
/* Uploaded assets section */
#uploaded-assets {
margin-top: 1.5rem;
padding-top: 1.25rem;
border-top: 1px solid var(--vscode-editorWidget-border);
}
#uploaded-assets.hidden {
display: none;
}
.assets-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.assets-header h3 {
margin: 0;
font-size: 0.95rem;
font-weight: 600;
}
.clear-btn {
background-color: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
border: none;
padding: 0.35rem 0.75rem;
border-radius: 4px;
font-size: 0.75rem;
cursor: pointer;
transition: background-color 0.15s;
}
.clear-btn:hover {
background-color: var(--vscode-button-secondaryHoverBackground);
}
#asset-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 1rem;
}
.asset-card {
background: var(--vscode-editor-background);
border: 1px solid var(--vscode-editorWidget-border);
border-radius: 8px;
padding: 0.6rem;
text-align: center;
transition: border-color 0.2s, transform 0.15s;
}
.asset-card:hover {
border-color: var(--vscode-focusBorder);
transform: translateY(-2px);
}
.asset-card .thumbnail-wrapper {
cursor: pointer;
position: relative;
}
.asset-card .thumbnail-wrapper:hover::after {
content: '🔍';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.5rem;
background: rgba(0, 0, 0, 0.6);
border-radius: 50%;
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
}
.asset-card .thumbnail {
width: 130px;
height: 100px;
object-fit: cover;
border-radius: 6px;
background: var(--vscode-editorWidget-background);
}
.asset-card .file-icon {
width: 130px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
background: var(--vscode-editorWidget-background);
border-radius: 6px;
color: var(--vscode-descriptionForeground);
}
.asset-card .asset-folder {
font-size: 0.65rem;
color: var(--vscode-descriptionForeground);
margin: 0.35rem 0 0.2rem 0;
opacity: 0.8;
}
.asset-card .asset-folder code {
background: var(--vscode-badge-background);
color: var(--vscode-badge-foreground);
padding: 0.1rem 0.3rem;
border-radius: 3px;
font-size: 0.6rem;
}
.asset-card .public-id {
font-size: 0.7rem;
color: var(--vscode-descriptionForeground);
margin: 0.3rem 0;
word-break: break-all;
max-height: 2.4em;
overflow: hidden;
text-overflow: ellipsis;
}
.asset-card .actions {
display: flex;
gap: 0.35rem;
justify-content: center;
flex-wrap: wrap;
}
.asset-card .actions button {
font-size: 0.7rem;
padding: 0.3rem 0.55rem;
background-color: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
border: none;