@fanvue/ui 3.27.0 → 3.28.0

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/index.d.ts CHANGED
@@ -2253,6 +2253,14 @@ export declare interface CyclingTextProps extends Omit<React_2.HTMLAttributes<HT
2253
2253
  /** How the wrapper should be sized to accommodate variable-length items. */
2254
2254
  export declare type CyclingTextSizing = "longest" | "current";
2255
2255
 
2256
+ /**
2257
+ * Waveform amplitudes (0–1) taken from the Figma reference, so a waveform with
2258
+ * no real peak data still renders 1:1 with the design. Used by
2259
+ * {@link VoiceNote} and available to consumers building their own waveform out
2260
+ * of {@link resamplePeaks} and {@link useFittedBarCount}.
2261
+ */
2262
+ export declare const DEFAULT_WAVEFORM_PEAKS: number[];
2263
+
2256
2264
  /**
2257
2265
  * One row of a breakdown: a leading glyph and label, its share at the far end,
2258
2266
  * and a bar underneath. Stack these to show how a total splits across
@@ -3277,6 +3285,13 @@ export declare const FolderIcon: React_2.ForwardRefExoticComponent<BaseIconProps
3277
3285
  /** Props for {@link FolderIcon}. See {@link BaseIconProps} for the shared shape. */
3278
3286
  export declare type FolderIconProps = BaseIconProps;
3279
3287
 
3288
+ /**
3289
+ * Formats a duration in seconds as `m:ss`, or `--:--` when unknown. Matches the
3290
+ * timestamp {@link VoiceNote} renders, so waveforms built elsewhere read the
3291
+ * same.
3292
+ */
3293
+ export declare function formatTime(seconds: number | undefined): string;
3294
+
3280
3295
  /**
3281
3296
  * Forward icon. Renders at sizes 16, 24, or 32 px with outlined and filled variants.
3282
3297
  *
@@ -4805,6 +4820,9 @@ export declare const ReplyIcon: React_2.ForwardRefExoticComponent<BaseIconProps
4805
4820
  /** Props for {@link ReplyIcon}. See {@link BaseIconProps} for the shared shape. */
4806
4821
  export declare type ReplyIconProps = BaseIconProps;
4807
4822
 
4823
+ /** Resamples a peaks array to `barCount` values (nearest-neighbour). */
4824
+ export declare function resamplePeaks(peaks: number[], barCount: number): number[];
4825
+
4808
4826
  /**
4809
4827
  * Reverse icon. Renders at sizes 16, 24, or 32 px.
4810
4828
  *
@@ -6582,6 +6600,24 @@ export declare interface UseAudioRecorderReturn {
6582
6600
  isSupported: boolean;
6583
6601
  }
6584
6602
 
6603
+ /**
6604
+ * Measures a waveform track and returns how many fixed-width bars fit across it,
6605
+ * updating on resize. Lets callers resample their peaks to the *visible* bar
6606
+ * count so overflow bars aren't rendered (and, crucially, aren't counted when
6607
+ * computing playback progress).
6608
+ */
6609
+ export declare function useFittedBarCount(trackRef: React_2.RefObject<HTMLElement | null>, { barWidthPx, gapPx, fallback }: UseFittedBarCountOptions): number;
6610
+
6611
+ /** Options for {@link useFittedBarCount}. */
6612
+ export declare interface UseFittedBarCountOptions {
6613
+ /** Rendered width of a single bar, in pixels. */
6614
+ barWidthPx: number;
6615
+ /** Gap between bars, in pixels. */
6616
+ gapPx: number;
6617
+ /** Bar count used before the track is measured (SSR, jsdom, or zero-width layout). */
6618
+ fallback: number;
6619
+ }
6620
+
6585
6621
  /**
6586
6622
  * User Add icon. Renders at sizes 16, 24, or 32 px with outlined and filled variants.
6587
6623
  *
package/dist/index.mjs CHANGED
@@ -266,8 +266,10 @@ import { UserHandle } from "./components/UserHandle/UserHandle.mjs";
266
266
  import { UserItem } from "./components/UserItem/UserItem.mjs";
267
267
  import { UserItemTrailing } from "./components/UserItem/UserItemTrailing.mjs";
268
268
  import { VoiceNote } from "./components/VoiceNote/VoiceNote.mjs";
269
+ import { DEFAULT_WAVEFORM_PEAKS, formatTime, resamplePeaks } from "./utils/audioWaveform.mjs";
269
270
  import { cn } from "./utils/cn.mjs";
270
271
  import { getInitials } from "./utils/getInitials.mjs";
272
+ import { useFittedBarCount } from "./utils/useFittedBarCount.mjs";
271
273
  import { useSuppressClickAfterDrag } from "./utils/useSuppressClickAfterDrag.mjs";
272
274
  export {
273
275
  AI2Icon,
@@ -362,6 +364,7 @@ export {
362
364
  CrossIcon,
363
365
  CrownIcon,
364
366
  CyclingText,
367
+ DEFAULT_WAVEFORM_PEAKS,
365
368
  Demographics,
366
369
  DenseGridViewIcon,
367
370
  Dialog,
@@ -609,8 +612,11 @@ export {
609
612
  WifiOnIcon,
610
613
  WrenchIcon,
611
614
  cn,
615
+ formatTime,
612
616
  getInitials,
617
+ resamplePeaks,
613
618
  useAudioRecorder,
619
+ useFittedBarCount,
614
620
  useSuppressClickAfterDrag
615
621
  };
616
622
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -118,12 +118,12 @@
118
118
  --color-buttons-chip-dotted-hover-stroke: var(--color-neutral-alphas-500);
119
119
  --color-buttons-navigation-base: var(--color-background-secondary);
120
120
  --color-buttons-navigation-highlight: var(--color-interaction-hover);
121
- --color-buttons-ai-background-gradient-default-start: var(--primitives-color-green-800);
122
- --color-buttons-ai-background-gradient-default-end: var(--primitives-color-green-950);
123
- --color-buttons-ai-background-gradient-hover-start: var(--primitives-color-green-700);
124
- --color-buttons-ai-background-gradient-hover-end: var(--primitives-color-green-900);
125
- --color-buttons-ai-stroke-start: var(--primitives-color-green-500);
126
- --color-buttons-ai-stroke-end: var(--primitives-color-gray-900);
121
+ --color-buttons-ai-background-gradient-default-start: #acf6b9b8;
122
+ --color-buttons-ai-background-gradient-default-end: #acf6b9b8;
123
+ --color-buttons-ai-background-gradient-hover-start: #80f593b8;
124
+ --color-buttons-ai-background-gradient-hover-end: #80f593b8;
125
+ --color-buttons-ai-stroke-start: var(--primitives-color-green-550);
126
+ --color-buttons-ai-stroke-end: var(--primitives-color-green-200);
127
127
  --color-buttons-overlay-default: var(--primitives-color-blackalpha-300);
128
128
  --color-buttons-overlay-hover: var(--primitives-color-blackalpha-400);
129
129
  --color-special-chart-teal: #28ba8eff;
@@ -513,12 +513,12 @@
513
513
  --color-buttons-chip-dotted-hover-stroke: var(--color-neutral-alphas-500);
514
514
  --color-buttons-navigation-base: var(--color-background-secondary);
515
515
  --color-buttons-navigation-highlight: var(--color-interaction-hover);
516
- --color-buttons-ai-background-gradient-default-start: var(--primitives-color-green-800);
517
- --color-buttons-ai-background-gradient-default-end: var(--primitives-color-green-950);
518
- --color-buttons-ai-background-gradient-hover-start: var(--primitives-color-green-700);
519
- --color-buttons-ai-background-gradient-hover-end: var(--primitives-color-green-900);
520
- --color-buttons-ai-stroke-start: var(--primitives-color-green-500);
521
- --color-buttons-ai-stroke-end: var(--primitives-color-gray-900);
516
+ --color-buttons-ai-background-gradient-default-start: #acf6b9b8;
517
+ --color-buttons-ai-background-gradient-default-end: #acf6b9b8;
518
+ --color-buttons-ai-background-gradient-hover-start: #80f593b8;
519
+ --color-buttons-ai-background-gradient-hover-end: #80f593b8;
520
+ --color-buttons-ai-stroke-start: var(--primitives-color-green-550);
521
+ --color-buttons-ai-stroke-end: var(--primitives-color-green-200);
522
522
  --color-buttons-overlay-default: var(--primitives-color-blackalpha-300);
523
523
  --color-buttons-overlay-hover: var(--primitives-color-blackalpha-400);
524
524
  --color-special-chart-teal: #28ba8eff;
@@ -731,12 +731,12 @@
731
731
  --color-buttons-chip-dotted-hover-stroke: var(--color-neutral-alphas-600);
732
732
  --color-buttons-navigation-base: var(--color-background-secondary);
733
733
  --color-buttons-navigation-highlight: var(--color-interaction-hover);
734
- --color-buttons-ai-background-gradient-default-start: var(--primitives-color-green-800);
735
- --color-buttons-ai-background-gradient-default-end: var(--primitives-color-green-950);
734
+ --color-buttons-ai-background-gradient-default-start: #033f15a3;
735
+ --color-buttons-ai-background-gradient-default-end: #033f15a3;
736
736
  --color-buttons-ai-background-gradient-hover-start: var(--primitives-color-green-700);
737
737
  --color-buttons-ai-background-gradient-hover-end: var(--primitives-color-green-900);
738
738
  --color-buttons-ai-stroke-start: var(--primitives-color-green-500);
739
- --color-buttons-ai-stroke-end: var(--primitives-color-gray-900);
739
+ --color-buttons-ai-stroke-end: var(--primitives-color-green-800);
740
740
  --color-buttons-overlay-default: var(--primitives-color-blackalpha-300);
741
741
  --color-buttons-overlay-hover: var(--primitives-color-blackalpha-400);
742
742
  --color-special-chart-teal: #28ba8eff;
@@ -1,5 +1,72 @@
1
1
  "use client";
2
2
  const RAW_PEAK_COUNT = 128;
3
+ const DEFAULT_WAVEFORM_PEAKS = [
4
+ 0.15,
5
+ 0.46,
6
+ 0.85,
7
+ 0.23,
8
+ 1,
9
+ 0.85,
10
+ 0.62,
11
+ 0.62,
12
+ 0.62,
13
+ 0.85,
14
+ 0.85,
15
+ 0.62,
16
+ 0.62,
17
+ 1,
18
+ 1,
19
+ 0.62,
20
+ 0.62,
21
+ 0.62,
22
+ 0.23,
23
+ 0.23,
24
+ 0.15,
25
+ 0.46,
26
+ 0.85,
27
+ 0.23,
28
+ 1,
29
+ 0.46,
30
+ 0.85,
31
+ 0.62,
32
+ 0.23,
33
+ 0.23,
34
+ 0.62,
35
+ 0.62,
36
+ 0.85,
37
+ 0.85,
38
+ 0.62,
39
+ 0.62,
40
+ 0.85,
41
+ 1,
42
+ 0.85,
43
+ 1,
44
+ 0.62,
45
+ 0.62,
46
+ 0.62,
47
+ 0.23,
48
+ 0.23,
49
+ 0.62,
50
+ 0.23,
51
+ 0.23,
52
+ 0.23,
53
+ 0.62,
54
+ 0.85,
55
+ 0.62,
56
+ 0.85,
57
+ 1,
58
+ 0.85,
59
+ 0.85,
60
+ 1,
61
+ 0.85,
62
+ 0.23,
63
+ 0.23,
64
+ 0.23,
65
+ 0.46,
66
+ 0.62,
67
+ 0.23,
68
+ 0.23
69
+ ];
3
70
  function formatTime(seconds) {
4
71
  if (seconds === void 0 || !Number.isFinite(seconds)) return "--:--";
5
72
  const totalSeconds = Math.max(0, Math.floor(seconds));
@@ -64,6 +131,7 @@ async function decodeAudioPeaks(src, signal) {
64
131
  }
65
132
  }
66
133
  export {
134
+ DEFAULT_WAVEFORM_PEAKS,
67
135
  RAW_PEAK_COUNT,
68
136
  computePeaksFromChannelData,
69
137
  createSeededRandom,
@@ -1 +1 @@
1
- {"version":3,"file":"audioWaveform.mjs","sources":["../../src/utils/audioWaveform.ts"],"sourcesContent":["/** Number of amplitude samples decoded/kept internally, resampled to the rendered bar count. */\nexport const RAW_PEAK_COUNT = 128;\n\n/** Formats a duration in seconds as `m:ss`, or `--:--` when unknown. */\nexport function formatTime(seconds: number | undefined): string {\n if (seconds === undefined || !Number.isFinite(seconds)) return \"--:--\";\n const totalSeconds = Math.max(0, Math.floor(seconds));\n const minutes = Math.floor(totalSeconds / 60);\n const remainingSeconds = totalSeconds % 60;\n return `${minutes}:${String(remainingSeconds).padStart(2, \"0\")}`;\n}\n\n/** Deterministic 32-bit string hash (FNV-1a), used to seed the fallback waveform. */\nexport function hashString(value: string): number {\n let hash = 2166136261;\n for (let i = 0; i < value.length; i++) {\n hash ^= value.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n return hash >>> 0;\n}\n\n/** Seeded PRNG (mulberry32) — deterministic across runs, unlike `Math.random`. */\nexport function createSeededRandom(seed: number): () => number {\n let state = seed;\n return () => {\n state = (state + 0x6d2b79f5) | 0;\n let t = Math.imul(state ^ (state >>> 15), 1 | state);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** Deterministic placeholder amplitudes used when audio can't be decoded (network/CORS/format failure). */\nexport function generateFallbackPeaks(src: string, count: number): number[] {\n const random = createSeededRandom(hashString(src));\n return Array.from({ length: count }, () => 0.2 + random() * 0.8);\n}\n\n/** Downsamples decoded PCM data to `count` peak (max-abs) amplitudes. */\nexport function computePeaksFromChannelData(channelData: Float32Array, count: number): number[] {\n const blockSize = Math.max(1, Math.floor(channelData.length / count));\n const peaks: number[] = [];\n for (let i = 0; i < count; i++) {\n const start = i * blockSize;\n let max = 0;\n for (let j = 0; j < blockSize && start + j < channelData.length; j++) {\n max = Math.max(max, Math.abs(channelData[start + j] ?? 0));\n }\n peaks.push(max);\n }\n return peaks;\n}\n\n/** Resamples a peaks array to `barCount` values (nearest-neighbour). */\nexport function resamplePeaks(peaks: number[], barCount: number): number[] {\n if (peaks.length === 0 || barCount <= 0) return [];\n const step = peaks.length / barCount;\n return Array.from(\n { length: barCount },\n (_, i) => peaks[Math.min(peaks.length - 1, Math.floor(i * step))] ?? 0,\n );\n}\n\n/** Decodes `src` via WebAudio and returns downsampled peak amplitudes. Throws on any failure. */\nexport async function decodeAudioPeaks(src: string, signal: AbortSignal): Promise<number[]> {\n const AudioContextCtor =\n window.AudioContext ??\n (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;\n if (!AudioContextCtor) throw new Error(\"WebAudio unsupported\");\n\n const response = await fetch(src, { signal });\n const arrayBuffer = await response.arrayBuffer();\n const audioContext = new AudioContextCtor();\n try {\n const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);\n return computePeaksFromChannelData(audioBuffer.getChannelData(0), RAW_PEAK_COUNT);\n } finally {\n if (audioContext.state !== \"closed\") audioContext.close().catch(() => {});\n }\n}\n"],"names":[],"mappings":";AACO,MAAM,iBAAiB;AAGvB,SAAS,WAAW,SAAqC;AAC9D,MAAI,YAAY,UAAa,CAAC,OAAO,SAAS,OAAO,EAAG,QAAO;AAC/D,QAAM,eAAe,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,CAAC;AACpD,QAAM,UAAU,KAAK,MAAM,eAAe,EAAE;AAC5C,QAAM,mBAAmB,eAAe;AACxC,SAAO,GAAG,OAAO,IAAI,OAAO,gBAAgB,EAAE,SAAS,GAAG,GAAG,CAAC;AAChE;AAGO,SAAS,WAAW,OAAuB;AAChD,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,YAAQ,MAAM,WAAW,CAAC;AAC1B,WAAO,KAAK,KAAK,MAAM,QAAQ;AAAA,EACjC;AACA,SAAO,SAAS;AAClB;AAGO,SAAS,mBAAmB,MAA4B;AAC7D,MAAI,QAAQ;AACZ,SAAO,MAAM;AACX,YAAS,QAAQ,aAAc;AAC/B,QAAI,IAAI,KAAK,KAAK,QAAS,UAAU,IAAK,IAAI,KAAK;AACnD,QAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,KAAK,CAAC,IAAK;AAC7C,aAAS,IAAK,MAAM,QAAS,KAAK;AAAA,EACpC;AACF;AAGO,SAAS,sBAAsB,KAAa,OAAyB;AAC1E,QAAM,SAAS,mBAAmB,WAAW,GAAG,CAAC;AACjD,SAAO,MAAM,KAAK,EAAE,QAAQ,MAAA,GAAS,MAAM,MAAM,OAAA,IAAW,GAAG;AACjE;AAGO,SAAS,4BAA4B,aAA2B,OAAyB;AAC9F,QAAM,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,YAAY,SAAS,KAAK,CAAC;AACpE,QAAM,QAAkB,CAAA;AACxB,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,UAAM,QAAQ,IAAI;AAClB,QAAI,MAAM;AACV,aAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,IAAI,YAAY,QAAQ,KAAK;AACpE,YAAM,KAAK,IAAI,KAAK,KAAK,IAAI,YAAY,QAAQ,CAAC,KAAK,CAAC,CAAC;AAAA,IAC3D;AACA,UAAM,KAAK,GAAG;AAAA,EAChB;AACA,SAAO;AACT;AAGO,SAAS,cAAc,OAAiB,UAA4B;AACzE,MAAI,MAAM,WAAW,KAAK,YAAY,UAAU,CAAA;AAChD,QAAM,OAAO,MAAM,SAAS;AAC5B,SAAO,MAAM;AAAA,IACX,EAAE,QAAQ,SAAA;AAAA,IACV,CAAC,GAAG,MAAM,MAAM,KAAK,IAAI,MAAM,SAAS,GAAG,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,KAAK;AAAA,EAAA;AAEzE;AAGA,eAAsB,iBAAiB,KAAa,QAAwC;AAC1F,QAAM,mBACJ,OAAO,gBACN,OAAmE;AACtE,MAAI,CAAC,iBAAkB,OAAM,IAAI,MAAM,sBAAsB;AAE7D,QAAM,WAAW,MAAM,MAAM,KAAK,EAAE,QAAQ;AAC5C,QAAM,cAAc,MAAM,SAAS,YAAA;AACnC,QAAM,eAAe,IAAI,iBAAA;AACzB,MAAI;AACF,UAAM,cAAc,MAAM,aAAa,gBAAgB,WAAW;AAClE,WAAO,4BAA4B,YAAY,eAAe,CAAC,GAAG,cAAc;AAAA,EAClF,UAAA;AACE,QAAI,aAAa,UAAU,uBAAuB,MAAA,EAAQ,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAC1E;AACF;"}
1
+ {"version":3,"file":"audioWaveform.mjs","sources":["../../src/utils/audioWaveform.ts"],"sourcesContent":["/** Number of amplitude samples decoded/kept internally, resampled to the rendered bar count. */\nexport const RAW_PEAK_COUNT = 128;\n\n/**\n * Waveform amplitudes (0–1) taken from the Figma reference, so a waveform with\n * no real peak data still renders 1:1 with the design. Used by\n * {@link VoiceNote} and available to consumers building their own waveform out\n * of {@link resamplePeaks} and {@link useFittedBarCount}.\n */\nexport const DEFAULT_WAVEFORM_PEAKS = [\n 0.15, 0.46, 0.85, 0.23, 1, 0.85, 0.62, 0.62, 0.62, 0.85, 0.85, 0.62, 0.62, 1, 1, 0.62, 0.62, 0.62,\n 0.23, 0.23, 0.15, 0.46, 0.85, 0.23, 1, 0.46, 0.85, 0.62, 0.23, 0.23, 0.62, 0.62, 0.85, 0.85, 0.62,\n 0.62, 0.85, 1, 0.85, 1, 0.62, 0.62, 0.62, 0.23, 0.23, 0.62, 0.23, 0.23, 0.23, 0.62, 0.85, 0.62,\n 0.85, 1, 0.85, 0.85, 1, 0.85, 0.23, 0.23, 0.23, 0.46, 0.62, 0.23, 0.23,\n];\n\n/**\n * Formats a duration in seconds as `m:ss`, or `--:--` when unknown. Matches the\n * timestamp {@link VoiceNote} renders, so waveforms built elsewhere read the\n * same.\n */\nexport function formatTime(seconds: number | undefined): string {\n if (seconds === undefined || !Number.isFinite(seconds)) return \"--:--\";\n const totalSeconds = Math.max(0, Math.floor(seconds));\n const minutes = Math.floor(totalSeconds / 60);\n const remainingSeconds = totalSeconds % 60;\n return `${minutes}:${String(remainingSeconds).padStart(2, \"0\")}`;\n}\n\n/** Deterministic 32-bit string hash (FNV-1a), used to seed the fallback waveform. */\nexport function hashString(value: string): number {\n let hash = 2166136261;\n for (let i = 0; i < value.length; i++) {\n hash ^= value.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n return hash >>> 0;\n}\n\n/** Seeded PRNG (mulberry32) — deterministic across runs, unlike `Math.random`. */\nexport function createSeededRandom(seed: number): () => number {\n let state = seed;\n return () => {\n state = (state + 0x6d2b79f5) | 0;\n let t = Math.imul(state ^ (state >>> 15), 1 | state);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** Deterministic placeholder amplitudes used when audio can't be decoded (network/CORS/format failure). */\nexport function generateFallbackPeaks(src: string, count: number): number[] {\n const random = createSeededRandom(hashString(src));\n return Array.from({ length: count }, () => 0.2 + random() * 0.8);\n}\n\n/** Downsamples decoded PCM data to `count` peak (max-abs) amplitudes. */\nexport function computePeaksFromChannelData(channelData: Float32Array, count: number): number[] {\n const blockSize = Math.max(1, Math.floor(channelData.length / count));\n const peaks: number[] = [];\n for (let i = 0; i < count; i++) {\n const start = i * blockSize;\n let max = 0;\n for (let j = 0; j < blockSize && start + j < channelData.length; j++) {\n max = Math.max(max, Math.abs(channelData[start + j] ?? 0));\n }\n peaks.push(max);\n }\n return peaks;\n}\n\n/** Resamples a peaks array to `barCount` values (nearest-neighbour). */\nexport function resamplePeaks(peaks: number[], barCount: number): number[] {\n if (peaks.length === 0 || barCount <= 0) return [];\n const step = peaks.length / barCount;\n return Array.from(\n { length: barCount },\n (_, i) => peaks[Math.min(peaks.length - 1, Math.floor(i * step))] ?? 0,\n );\n}\n\n/** Decodes `src` via WebAudio and returns downsampled peak amplitudes. Throws on any failure. */\nexport async function decodeAudioPeaks(src: string, signal: AbortSignal): Promise<number[]> {\n const AudioContextCtor =\n window.AudioContext ??\n (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;\n if (!AudioContextCtor) throw new Error(\"WebAudio unsupported\");\n\n const response = await fetch(src, { signal });\n const arrayBuffer = await response.arrayBuffer();\n const audioContext = new AudioContextCtor();\n try {\n const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);\n return computePeaksFromChannelData(audioBuffer.getChannelData(0), RAW_PEAK_COUNT);\n } finally {\n if (audioContext.state !== \"closed\") audioContext.close().catch(() => {});\n }\n}\n"],"names":[],"mappings":";AACO,MAAM,iBAAiB;AAQvB,MAAM,yBAAyB;AAAA,EACpC;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAG;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;A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,QAAQ;AAC5C,QAAM,cAAc,MAAM,SAAS,YAAA;AACnC,QAAM,eAAe,IAAI,iBAAA;AACzB,MAAI;AACF,UAAM,cAAc,MAAM,aAAa,gBAAgB,WAAW;AAClE,WAAO,4BAA4B,YAAY,eAAe,CAAC,GAAG,cAAc;AAAA,EAClF,UAAA;AACE,QAAI,aAAa,UAAU,uBAAuB,MAAA,EAAQ,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAC1E;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanvue/ui",
3
- "version": "3.27.0",
3
+ "version": "3.28.0",
4
4
  "description": "React component library built with Tailwind CSS for Fanvue ecosystem",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",