@widgetic/file-browser 0.5.35 → 0.5.36
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/README.md +1 -0
- package/dist/components/FolderTree.svelte +46 -97
- package/dist/components/FolderTree.svelte.d.ts +7 -7
- package/dist/components/core/Dropzone.svelte +127 -0
- package/dist/components/core/Dropzone.svelte.d.ts +15 -0
- package/dist/components/core/FileBrowser.css +11 -79
- package/dist/components/core/FileBrowser.svelte +277 -150
- package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
- package/dist/components/core/FileUploader.svelte +204 -418
- package/dist/components/core/FileUploader.svelte.d.ts +1 -0
- package/dist/components/core/Header.svelte +51 -68
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +135 -562
- package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
- package/dist/components/core/UploadPanel.svelte +169 -0
- package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
- package/dist/components/core/UploadRow.svelte +90 -0
- package/dist/components/core/UploadRow.svelte.d.ts +21 -0
- package/dist/components/core/UploadStatus.svelte +34 -128
- package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
- package/dist/components/core/UploadStatusList.svelte +61 -77
- package/dist/components/items/FileItem.svelte +190 -532
- package/dist/components/items/FileItem.svelte.d.ts +1 -1
- package/dist/components/items/FolderItem.svelte +46 -36
- package/dist/components/items/FolderItem.svelte.d.ts +1 -1
- package/dist/components/modals/MoveDialog.svelte +142 -281
- package/dist/components/modals/NewFolderButton.svelte +13 -14
- package/dist/components/modals/SearchModal.svelte +112 -264
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
- package/dist/components/modals/SelectedFilesModal.svelte +91 -167
- package/dist/components/previews/AudioPlayer.svelte +75 -58
- package/dist/components/previews/ErrorPreview.svelte +9 -6
- package/dist/components/previews/FilePreview.svelte +173 -53
- package/dist/components/previews/FontPreview.svelte +37 -54
- package/dist/components/previews/ImagePreview.svelte +9 -2
- package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
- package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
- package/dist/components/previews/TextPreview.svelte +32 -40
- package/dist/components/previews/VideoPlayer.svelte +124 -149
- package/dist/components/previews/WaveformVisualizer.svelte +42 -222
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
- package/dist/components/ui/ControlToolbar.svelte +113 -288
- package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
- package/dist/components/ui/DragSelect.svelte +41 -248
- package/dist/components/ui/DropdownMenu.svelte +56 -55
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
- package/dist/components/ui/FileIcon.svelte +168 -51
- package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
- package/dist/components/ui/FileMetadata.svelte +20 -9
- package/dist/components/ui/LoadingSkeleton.svelte +5 -20
- package/dist/components/ui/SearchResults.svelte +50 -26
- package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
- package/dist/components/ui/SelectedBadge.svelte +25 -0
- package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TileSkeleton.svelte +15 -0
- package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
- package/dist/components/ui/VirtualList.svelte +3 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/i18n/messages.d.ts +38 -25
- package/dist/i18n/messages.js +39 -26
- package/dist/stores/fileStore.d.ts +2 -2
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.d.ts +1 -1
- package/dist/utils/gridLayout.d.ts +2 -0
- package/dist/utils/gridLayout.js +10 -0
- package/package.json +3 -4
|
@@ -1,240 +1,60 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, onDestroy } from 'svelte';
|
|
3
3
|
|
|
4
|
+
/** Figma Audio Wave 277:1437 — 60 bars, 3px wide, progress by playback time. */
|
|
4
5
|
export let mediaElement: HTMLAudioElement;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const MIN_FREQUENCY = 20; // Hz
|
|
24
|
-
const MAX_FREQUENCY = 20000; // Hz
|
|
25
|
-
|
|
26
|
-
// Helper function to convert frequency to mel scale
|
|
27
|
-
function freqToMel(f: number): number {
|
|
28
|
-
return 2595 * Math.log10(1 + f / 700);
|
|
7
|
+
const BAR_COUNT = 60;
|
|
8
|
+
const barHeights = [
|
|
9
|
+
28, 35, 42, 38, 31, 45, 52, 48, 41, 36, 33, 39, 44, 50, 55, 61, 58, 52, 47, 40, 34, 30,
|
|
10
|
+
27, 32, 37, 43, 49, 54, 57, 53, 46, 39, 33, 29, 26, 31, 36, 42, 48, 51, 56, 50, 44, 38,
|
|
11
|
+
32, 28, 25, 30, 35, 41, 46, 52, 55, 49, 43, 37, 31, 27, 24, 29
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
let currentTime = 0;
|
|
15
|
+
let duration = 0;
|
|
16
|
+
let playedBars = 0;
|
|
17
|
+
|
|
18
|
+
function syncFromMedia() {
|
|
19
|
+
if (!mediaElement) return;
|
|
20
|
+
currentTime = mediaElement.currentTime;
|
|
21
|
+
duration = mediaElement.duration || 0;
|
|
22
|
+
const ratio = duration > 0 ? currentTime / duration : 0;
|
|
23
|
+
playedBars = Math.min(BAR_COUNT, Math.floor(ratio * BAR_COUNT));
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return 700 * (Math.pow(10, m / 2595) - 1);
|
|
26
|
+
function onTimeUpdate() {
|
|
27
|
+
syncFromMedia();
|
|
34
28
|
}
|
|
35
29
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
audioContext = new AudioContext();
|
|
41
|
-
analyser = audioContext.createAnalyser();
|
|
42
|
-
const source = audioContext.createMediaElementSource(mediaElement);
|
|
43
|
-
|
|
44
|
-
analyser.fftSize = FFT_SIZE;
|
|
45
|
-
analyser.smoothingTimeConstant = SMOOTHING;
|
|
46
|
-
|
|
47
|
-
source.connect(analyser);
|
|
48
|
-
analyser.connect(audioContext.destination);
|
|
49
|
-
|
|
50
|
-
isInitialized = true;
|
|
51
|
-
if(showLogs) console.log('Audio context initialized successfully');
|
|
52
|
-
} catch (error) {
|
|
53
|
-
if(showLogs) console.error('Failed to initialize audio context:', error);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function resizeCanvas() {
|
|
58
|
-
if (!canvas || !canvas.parentElement) return;
|
|
59
|
-
|
|
60
|
-
const rect = canvas.parentElement.getBoundingClientRect();
|
|
61
|
-
const width = Math.floor(rect.width);
|
|
62
|
-
const height = Math.floor(rect.height);
|
|
63
|
-
|
|
64
|
-
canvas.width = width;
|
|
65
|
-
canvas.height = height;
|
|
66
|
-
|
|
67
|
-
// Calculate integer bar width to fill the entire width
|
|
68
|
-
const totalWidth = width;
|
|
69
|
-
const rawBarWidth = (totalWidth - (NUM_BARS - 1) * BAR_SPACING) / NUM_BARS;
|
|
70
|
-
barWidth = Math.max(1, Math.floor(rawBarWidth)); // Ensure minimum width of 1px
|
|
71
|
-
|
|
72
|
-
// Recalculate actual number of bars to fit the space
|
|
73
|
-
actualNumBars = Math.floor((width + BAR_SPACING) / (barWidth + BAR_SPACING));
|
|
74
|
-
|
|
75
|
-
// Precalculate frequency bins for better distribution
|
|
76
|
-
const minMel = freqToMel(MIN_FREQUENCY);
|
|
77
|
-
const maxMel = freqToMel(MAX_FREQUENCY);
|
|
78
|
-
const melStep = (maxMel - minMel) / actualNumBars;
|
|
79
|
-
|
|
80
|
-
freqBins = new Array(actualNumBars).fill(0).map((_, i) => {
|
|
81
|
-
const mel = minMel + i * melStep;
|
|
82
|
-
const freq = melToFreq(mel);
|
|
83
|
-
return Math.floor((freq / MAX_FREQUENCY) * (FFT_SIZE / 2));
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let barWidth = 0;
|
|
88
|
-
let actualNumBars = NUM_BARS;
|
|
89
|
-
let freqBins: number[] = [];
|
|
90
|
-
|
|
91
|
-
function drawBars() {
|
|
92
|
-
if (!ctx || !analyser) return;
|
|
93
|
-
|
|
94
|
-
const bufferLength = analyser.frequencyBinCount;
|
|
95
|
-
const dataArray = new Uint8Array(bufferLength);
|
|
96
|
-
analyser.getByteFrequencyData(dataArray);
|
|
97
|
-
|
|
98
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
99
|
-
|
|
100
|
-
const centerY = canvas.height / 2;
|
|
101
|
-
const maxBarHeight = centerY * MAX_HEIGHT_PERCENTAGE;
|
|
102
|
-
|
|
103
|
-
// Use direct sage green color with fallback
|
|
104
|
-
let sageGreenColor = '#86B049'; // Fallback sage green color
|
|
105
|
-
|
|
106
|
-
// Try to get the color from CSS variables if available
|
|
107
|
-
if (canvas.parentElement) {
|
|
108
|
-
try {
|
|
109
|
-
const computedStyle = getComputedStyle(canvas.parentElement);
|
|
110
|
-
const sageGreenValue = computedStyle.getPropertyValue('--sage-green').trim();
|
|
111
|
-
if (sageGreenValue) {
|
|
112
|
-
sageGreenColor = `hsl(${sageGreenValue})`;
|
|
113
|
-
// if(showLogs) console.log('Using sage green from CSS:', sageGreenColor);
|
|
114
|
-
} else {
|
|
115
|
-
if(showLogs) console.log('Sage green CSS variable is empty, using fallback');
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.error('Error accessing CSS variables:', error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Sample the frequency data using our precalculated bins
|
|
123
|
-
for (let i = 0; i < actualNumBars; i++) {
|
|
124
|
-
// Get the frequency range for this bar
|
|
125
|
-
const binStart = freqBins[i];
|
|
126
|
-
const binEnd = freqBins[i + 1] || bufferLength - 1;
|
|
127
|
-
|
|
128
|
-
// Average the values in the frequency range
|
|
129
|
-
let sum = 0;
|
|
130
|
-
let count = 0;
|
|
131
|
-
for (let j = binStart; j <= binEnd; j++) {
|
|
132
|
-
sum += dataArray[j];
|
|
133
|
-
count++;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
let value = (sum / count) / 255.0; // Normalize to 0-1
|
|
137
|
-
|
|
138
|
-
// Apply minimum amplitude and smooth scaling
|
|
139
|
-
value = Math.max(value, MIN_AMPLITUDE);
|
|
140
|
-
value = Math.pow(value, 1.5); // Add some exponential scaling for better visual effect
|
|
141
|
-
|
|
142
|
-
// Calculate bar height with smooth scaling and max height limit
|
|
143
|
-
const barHeight = Math.max(
|
|
144
|
-
Math.min(value * maxBarHeight * 2, maxBarHeight),
|
|
145
|
-
MIN_BAR_HEIGHT
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
// Calculate x position for the bar (using integer values)
|
|
149
|
-
const x = Math.floor(i * (barWidth + BAR_SPACING));
|
|
150
|
-
|
|
151
|
-
// Draw upper bar
|
|
152
|
-
ctx.beginPath();
|
|
153
|
-
ctx.roundRect(
|
|
154
|
-
x,
|
|
155
|
-
centerY - barHeight,
|
|
156
|
-
barWidth,
|
|
157
|
-
barHeight + 1, // Add 1px overlap at center
|
|
158
|
-
[barWidth / 2, barWidth / 2, 0, 0] // Round only top corners
|
|
159
|
-
);
|
|
160
|
-
ctx.fillStyle = sageGreenColor;
|
|
161
|
-
ctx.fill();
|
|
162
|
-
|
|
163
|
-
// Draw lower bar (mirrored)
|
|
164
|
-
ctx.beginPath();
|
|
165
|
-
ctx.roundRect(
|
|
166
|
-
x,
|
|
167
|
-
centerY - 1, // Subtract 1px to ensure overlap
|
|
168
|
-
barWidth,
|
|
169
|
-
barHeight + 1, // Add 1px overlap at center
|
|
170
|
-
[0, 0, barWidth / 2, barWidth / 2] // Round only bottom corners
|
|
171
|
-
);
|
|
172
|
-
ctx.fillStyle = sageGreenColor;
|
|
173
|
-
ctx.fill();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
animationFrame = requestAnimationFrame(drawBars);
|
|
30
|
+
function onLoadedMetadata() {
|
|
31
|
+
syncFromMedia();
|
|
177
32
|
}
|
|
178
33
|
|
|
179
34
|
onMount(() => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
ctx = canvas.getContext('2d')!;
|
|
186
|
-
resizeCanvas();
|
|
187
|
-
|
|
188
|
-
mediaElement.addEventListener('play', () => {
|
|
189
|
-
if (!isInitialized) {
|
|
190
|
-
initializeAudioContext();
|
|
191
|
-
}
|
|
192
|
-
drawBars();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
mediaElement.addEventListener('pause', () => {
|
|
196
|
-
if (animationFrame) {
|
|
197
|
-
cancelAnimationFrame(animationFrame);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
202
|
-
resizeCanvas();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (canvas.parentElement) {
|
|
206
|
-
resizeObserver.observe(canvas.parentElement);
|
|
207
|
-
}
|
|
208
|
-
|
|
35
|
+
syncFromMedia();
|
|
36
|
+
mediaElement.addEventListener('timeupdate', onTimeUpdate);
|
|
37
|
+
mediaElement.addEventListener('loadedmetadata', onLoadedMetadata);
|
|
38
|
+
mediaElement.addEventListener('seeked', onTimeUpdate);
|
|
209
39
|
return () => {
|
|
210
|
-
|
|
40
|
+
mediaElement.removeEventListener('timeupdate', onTimeUpdate);
|
|
41
|
+
mediaElement.removeEventListener('loadedmetadata', onLoadedMetadata);
|
|
42
|
+
mediaElement.removeEventListener('seeked', onTimeUpdate);
|
|
211
43
|
};
|
|
212
44
|
});
|
|
213
45
|
|
|
214
|
-
onDestroy(() => {
|
|
215
|
-
if (animationFrame) {
|
|
216
|
-
cancelAnimationFrame(animationFrame);
|
|
217
|
-
}
|
|
218
|
-
if (audioContext) {
|
|
219
|
-
audioContext.close();
|
|
220
|
-
}
|
|
221
|
-
});
|
|
46
|
+
onDestroy(() => {});
|
|
222
47
|
</script>
|
|
223
48
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
<
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
--sage-green: 108 25.4% 52.9%;
|
|
237
|
-
--deep-forest-green: 115 24.1% 24.7%;
|
|
238
|
-
--grey7: 0 0% 12.9%;
|
|
239
|
-
}
|
|
240
|
-
</style>
|
|
49
|
+
<div
|
|
50
|
+
class="audio-wave flex h-[4.5rem] w-full max-w-[22.625rem] items-center justify-between"
|
|
51
|
+
role="img"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
>
|
|
54
|
+
{#each barHeights as height, index (index)}
|
|
55
|
+
<span
|
|
56
|
+
class="w-[3px] shrink-0 rounded-full {index < playedBars ? 'bg-primary' : 'bg-muted-foreground/30'}"
|
|
57
|
+
style="height: {height}px"
|
|
58
|
+
></span>
|
|
59
|
+
{/each}
|
|
60
|
+
</div>
|
|
@@ -12,7 +12,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
14
|
declare const WaveformVisualizer: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
mediaElement: HTMLAudioElement;
|
|
15
|
+
/** Figma Audio Wave 277:1437 — 60 bars, 3px wide, progress by playback time. */ mediaElement: HTMLAudioElement;
|
|
16
16
|
}, {
|
|
17
17
|
[evt: string]: CustomEvent<any>;
|
|
18
18
|
}, {}, {}, string>;
|