@molecule/app-feature-audio-waveform-vue 0.0.0-stage → 0.0.1-stage

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # @molecule/app-feature-audio-waveform-vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Stylized SVG audio waveform with click-to-seek + region overlays — renders pre-computed peaks for music-daw / podcast / streaming
4
+
5
+ ```
6
+ npm install @molecule/app-feature-audio-waveform-vue
7
+ ```
8
+
9
+ Part of the [Molecule](https://www.molecule.dev) package fleet. This page carries the manifest summary; the full generated documentation ships with the package's first committed version.
10
+
11
+ License: Apache-2.0
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Vue stylized SVG audio waveform with click-to-seek + region overlays.
3
+ *
4
+ * Vue counterpart of `@molecule/app-feature-audio-waveform-react`'s
5
+ * `AudioWaveform` — the same props (React names), the same ClassMap classes,
6
+ * inline styles, SVG geometry and callbacks, and therefore the same DOM for
7
+ * the same input.
8
+ *
9
+ * @module
10
+ */
11
+ import { type PropType, type VNode } from 'vue';
12
+ import type { WaveformRegion } from './types.js';
13
+ /**
14
+ * Clamp a value into the closed interval `[min, max]`. Returns `min`
15
+ * for `NaN` / non-finite inputs.
16
+ *
17
+ * @param value - Value to clamp.
18
+ * @param min - Minimum (inclusive).
19
+ * @param max - Maximum (inclusive).
20
+ * @returns The clamped value.
21
+ */
22
+ export declare function clamp(value: number, min: number, max: number): number;
23
+ /**
24
+ * Compute the seek time (in seconds) for a click at horizontal pixel
25
+ * `x` inside a waveform bounding box of `width` pixels covering an
26
+ * audio of `duration` seconds. Clamps the result into `[0, duration]`.
27
+ *
28
+ * @param x - Horizontal pixel offset of the click inside the bounding box.
29
+ * @param width - Width of the bounding box in pixels.
30
+ * @param duration - Total audio duration in seconds.
31
+ * @returns The seek target time, in seconds.
32
+ */
33
+ export declare function seekTimeFromClick(x: number, width: number, duration: number): number;
34
+ /**
35
+ * Stylized SVG audio waveform with click-to-seek + region overlays.
36
+ * Renders pre-computed peak amplitudes as vertical bars centered on a
37
+ * baseline. A progress overlay fills the played portion from the left;
38
+ * region markers render as colored rectangles spanning their time range.
39
+ *
40
+ * All styling routes through `getClassMap()` and all user-visible text
41
+ * routes through `t()` so the waveform translates via the companion
42
+ * `@molecule/app-locales-feature-audio-waveform` locale bond.
43
+ *
44
+ * @param props - Component props (see {@link AudioWaveformProps}).
45
+ * @returns The audio-waveform element.
46
+ */
47
+ export declare const AudioWaveform: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
48
+ peaks: {
49
+ type: PropType<number[]>;
50
+ required: true;
51
+ };
52
+ duration: {
53
+ type: NumberConstructor;
54
+ required: true;
55
+ };
56
+ currentTime: {
57
+ type: NumberConstructor;
58
+ default: number;
59
+ };
60
+ onSeek: {
61
+ type: PropType<(seekTime: number) => void>;
62
+ default: undefined;
63
+ };
64
+ regions: {
65
+ type: PropType<WaveformRegion[]>;
66
+ default: undefined;
67
+ };
68
+ height: {
69
+ type: NumberConstructor;
70
+ default: number;
71
+ };
72
+ progressColor: {
73
+ type: StringConstructor;
74
+ default: undefined;
75
+ };
76
+ waveColor: {
77
+ type: StringConstructor;
78
+ default: undefined;
79
+ };
80
+ className: {
81
+ type: StringConstructor;
82
+ default: undefined;
83
+ };
84
+ }>, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
85
+ peaks: {
86
+ type: PropType<number[]>;
87
+ required: true;
88
+ };
89
+ duration: {
90
+ type: NumberConstructor;
91
+ required: true;
92
+ };
93
+ currentTime: {
94
+ type: NumberConstructor;
95
+ default: number;
96
+ };
97
+ onSeek: {
98
+ type: PropType<(seekTime: number) => void>;
99
+ default: undefined;
100
+ };
101
+ regions: {
102
+ type: PropType<WaveformRegion[]>;
103
+ default: undefined;
104
+ };
105
+ height: {
106
+ type: NumberConstructor;
107
+ default: number;
108
+ };
109
+ progressColor: {
110
+ type: StringConstructor;
111
+ default: undefined;
112
+ };
113
+ waveColor: {
114
+ type: StringConstructor;
115
+ default: undefined;
116
+ };
117
+ className: {
118
+ type: StringConstructor;
119
+ default: undefined;
120
+ };
121
+ }>> & Readonly<{}>, {
122
+ currentTime: number;
123
+ onSeek: (seekTime: number) => void;
124
+ regions: WaveformRegion[];
125
+ height: number;
126
+ progressColor: string;
127
+ waveColor: string;
128
+ className: string;
129
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
130
+ //# sourceMappingURL=AudioWaveform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AudioWaveform.d.ts","sourceRoot":"","sources":["../src/AudioWaveform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,KAAK,CAAA;AAKZ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAoBhD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKpF;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa;;cAIL,QAAQ,CAAC,MAAM,EAAE,CAAC;;;;;;;;;;;;cAYf,QAAQ,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;;;;cAIvC,QAAQ,CAAC,cAAc,EAAE,CAAC;;;;;;;;;;;;;;;;;;;UA4DhC,KAAK;;cA5EC,QAAQ,CAAC,MAAM,EAAE,CAAC;;;;;;;;;;;;cAYf,QAAQ,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;;;;cAIvC,QAAQ,CAAC,cAAc,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;uBAJH,MAAM,KAAK,IAAI;;;;;;4EAmOzD,CAAA"}
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Vue stylized SVG audio waveform with click-to-seek + region overlays.
3
+ *
4
+ * Vue counterpart of `@molecule/app-feature-audio-waveform-react`'s
5
+ * `AudioWaveform` — the same props (React names), the same ClassMap classes,
6
+ * inline styles, SVG geometry and callbacks, and therefore the same DOM for
7
+ * the same input.
8
+ *
9
+ * @module
10
+ */
11
+ import { defineComponent, h, } from 'vue';
12
+ import { getClassMap } from '@molecule/app-ui';
13
+ import { useTranslation } from '@molecule/app-vue';
14
+ /**
15
+ * Next value of the module-wide clip-path id counter.
16
+ *
17
+ * React derives the clipPath id from `useId()`, which numbers ids from one
18
+ * process-wide counter (`_r_<base32>_`). The id appears in the `clip-path`
19
+ * attribute, which the conformance normalizer keeps verbatim, so the port
20
+ * generates ids from the same kind of counter — unique per instance, exactly
21
+ * React's format.
22
+ */
23
+ let nextClipId = 0;
24
+ /**
25
+ * A fresh clip-path id, in React `useId()`'s `_r_<base32>_` shape.
26
+ *
27
+ * @returns The id prefix for this instance's clipPath.
28
+ */
29
+ const clipId = () => `_r_${(nextClipId++).toString(32)}_`;
30
+ /**
31
+ * Clamp a value into the closed interval `[min, max]`. Returns `min`
32
+ * for `NaN` / non-finite inputs.
33
+ *
34
+ * @param value - Value to clamp.
35
+ * @param min - Minimum (inclusive).
36
+ * @param max - Maximum (inclusive).
37
+ * @returns The clamped value.
38
+ */
39
+ export function clamp(value, min, max) {
40
+ if (!Number.isFinite(value))
41
+ return min;
42
+ if (value < min)
43
+ return min;
44
+ if (value > max)
45
+ return max;
46
+ return value;
47
+ }
48
+ /**
49
+ * Compute the seek time (in seconds) for a click at horizontal pixel
50
+ * `x` inside a waveform bounding box of `width` pixels covering an
51
+ * audio of `duration` seconds. Clamps the result into `[0, duration]`.
52
+ *
53
+ * @param x - Horizontal pixel offset of the click inside the bounding box.
54
+ * @param width - Width of the bounding box in pixels.
55
+ * @param duration - Total audio duration in seconds.
56
+ * @returns The seek target time, in seconds.
57
+ */
58
+ export function seekTimeFromClick(x, width, duration) {
59
+ if (!Number.isFinite(width) || width <= 0)
60
+ return 0;
61
+ if (!Number.isFinite(duration) || duration <= 0)
62
+ return 0;
63
+ const ratio = clamp(x / width, 0, 1);
64
+ return ratio * duration;
65
+ }
66
+ /**
67
+ * Stylized SVG audio waveform with click-to-seek + region overlays.
68
+ * Renders pre-computed peak amplitudes as vertical bars centered on a
69
+ * baseline. A progress overlay fills the played portion from the left;
70
+ * region markers render as colored rectangles spanning their time range.
71
+ *
72
+ * All styling routes through `getClassMap()` and all user-visible text
73
+ * routes through `t()` so the waveform translates via the companion
74
+ * `@molecule/app-locales-feature-audio-waveform` locale bond.
75
+ *
76
+ * @param props - Component props (see {@link AudioWaveformProps}).
77
+ * @returns The audio-waveform element.
78
+ */
79
+ export const AudioWaveform = defineComponent({
80
+ name: 'AudioWaveform',
81
+ props: {
82
+ peaks: {
83
+ type: Array,
84
+ required: true,
85
+ },
86
+ duration: {
87
+ type: Number,
88
+ required: true,
89
+ },
90
+ currentTime: {
91
+ type: Number,
92
+ default: 0,
93
+ },
94
+ onSeek: {
95
+ type: Function,
96
+ default: undefined,
97
+ },
98
+ regions: {
99
+ type: Array,
100
+ default: undefined,
101
+ },
102
+ height: {
103
+ type: Number,
104
+ default: 64,
105
+ },
106
+ progressColor: {
107
+ type: String,
108
+ default: undefined,
109
+ },
110
+ waveColor: {
111
+ type: String,
112
+ default: undefined,
113
+ },
114
+ className: {
115
+ type: String,
116
+ default: undefined,
117
+ },
118
+ },
119
+ setup(props) {
120
+ const cm = getClassMap();
121
+ const { t } = useTranslation();
122
+ // React calls `useId()` before its empty-state return, so every rendered
123
+ // case consumes one id; take ours unconditionally to stay in step.
124
+ const id = clipId();
125
+ /** The mounted `<svg>`, whose bounding box maps a click to a seek time. */
126
+ let svgNode = null;
127
+ /**
128
+ * Records the mounted `<svg>` element.
129
+ *
130
+ * @param el - The element Vue passes to the ref callback.
131
+ */
132
+ const captureSvg = (el) => {
133
+ svgNode = el instanceof SVGSVGElement ? el : null;
134
+ };
135
+ /**
136
+ * Whether a click should seek (React's `typeof onSeek === 'function' && duration > 0`).
137
+ *
138
+ * @returns Whether the waveform is interactive.
139
+ */
140
+ const interactive = () => typeof props.onSeek === 'function' && props.duration > 0;
141
+ /**
142
+ * Maps a click inside the SVG onto a seek time and fires `onSeek`.
143
+ *
144
+ * @param event - The native click event.
145
+ */
146
+ const handleClick = (event) => {
147
+ if (!interactive())
148
+ return;
149
+ const node = svgNode;
150
+ if (!node)
151
+ return;
152
+ const rect = node.getBoundingClientRect();
153
+ const x = event.clientX - rect.left;
154
+ props.onSeek?.(seekTimeFromClick(x, rect.width, props.duration));
155
+ };
156
+ return () => {
157
+ const duration = props.duration;
158
+ const height = props.height;
159
+ const safeDuration = Number.isFinite(duration) && duration > 0 ? duration : 0;
160
+ const safeCurrent = clamp(props.currentTime, 0, safeDuration);
161
+ const playedRatio = safeDuration > 0 ? safeCurrent / safeDuration : 0;
162
+ // A 1000-unit virtual viewBox width so the SVG scales with its CSS width.
163
+ const viewWidth = 1000;
164
+ const barCount = props.peaks.length;
165
+ const totalGap = barCount > 1 ? Math.min(barCount - 1, Math.floor(viewWidth / 8)) : 0;
166
+ const barWidth = barCount > 0 ? Math.max((viewWidth - totalGap) / barCount, 0.5) : 0;
167
+ const stride = barCount > 0 ? viewWidth / barCount : 0;
168
+ const centerY = height / 2;
169
+ const minBarHeight = 1;
170
+ const ariaLabel = t('audioWaveform.aria.region', {}, { defaultValue: 'Audio waveform' });
171
+ const seekLabel = t('audioWaveform.aria.seek', {}, { defaultValue: 'Seek the audio by clicking the waveform' });
172
+ const emptyLabel = t('audioWaveform.empty', {}, { defaultValue: 'No waveform data available.' });
173
+ if (barCount === 0) {
174
+ return h('div', {
175
+ role: 'region',
176
+ 'aria-label': ariaLabel,
177
+ 'data-mol-id': 'audio-waveform',
178
+ 'data-state': 'empty',
179
+ class: cm.cn(cm.sp('p', 2), props.className),
180
+ }, [
181
+ h('p', { class: cm.textSize('xs'), 'data-mol-id': 'audio-waveform-empty' }, [
182
+ emptyLabel,
183
+ ]),
184
+ ]);
185
+ }
186
+ const resolvedWaveColor = props.waveColor ?? 'currentColor';
187
+ const resolvedProgressColor = props.progressColor ?? 'currentColor';
188
+ const isInteractive = interactive();
189
+ const containerStyle = 'width: 100%; color: currentColor';
190
+ const svgStyle = `display: block; width: 100%; height: ${height}px; cursor: ${isInteractive ? 'pointer' : 'default'}; opacity: 1`;
191
+ const bars = props.peaks.map((rawPeak, i) => {
192
+ const peak = clamp(rawPeak, 0, 1);
193
+ const barHeight = Math.max(peak * height, minBarHeight);
194
+ const x = i * stride + (stride - barWidth) / 2;
195
+ const y = centerY - barHeight / 2;
196
+ return { x, y, w: barWidth, h: barHeight, key: i };
197
+ });
198
+ const progressX = playedRatio * viewWidth;
199
+ const regionRects = (props.regions ?? []).flatMap((region) => {
200
+ if (!Number.isFinite(region.duration) || region.duration <= 0)
201
+ return [];
202
+ const startRatio = clamp(region.startTime / safeDuration, 0, 1);
203
+ const endRatio = clamp((region.startTime + region.duration) / safeDuration, 0, 1);
204
+ if (endRatio <= startRatio)
205
+ return [];
206
+ const x = startRatio * viewWidth;
207
+ const w = (endRatio - startRatio) * viewWidth;
208
+ return [
209
+ h('rect', {
210
+ key: region.id,
211
+ x,
212
+ y: 0,
213
+ width: w,
214
+ height,
215
+ fill: region.color ?? 'currentColor',
216
+ 'fill-opacity': region.color ? 1 : 0.15,
217
+ 'data-mol-id': 'audio-waveform-region',
218
+ 'data-region-id': region.id,
219
+ }),
220
+ ];
221
+ });
222
+ return h('div', {
223
+ role: 'region',
224
+ 'aria-label': ariaLabel,
225
+ 'data-mol-id': 'audio-waveform',
226
+ class: cm.cn(props.className),
227
+ style: containerStyle,
228
+ }, [
229
+ h('svg', {
230
+ ref: captureSvg,
231
+ viewBox: `0 0 ${viewWidth} ${height}`,
232
+ preserveAspectRatio: 'none',
233
+ width: '100%',
234
+ height,
235
+ onClick: handleClick,
236
+ role: isInteractive ? 'button' : 'img',
237
+ 'aria-label': isInteractive ? seekLabel : ariaLabel,
238
+ 'data-mol-id': 'audio-waveform-svg',
239
+ 'data-interactive': isInteractive ? 'true' : 'false',
240
+ style: svgStyle,
241
+ }, [
242
+ h('defs', [
243
+ h('clipPath', { id: `${id}-progress` }, [
244
+ h('rect', { x: 0, y: 0, width: progressX, height }),
245
+ ]),
246
+ ]),
247
+ h('g', {
248
+ 'data-mol-id': 'audio-waveform-bars-base',
249
+ fill: resolvedWaveColor,
250
+ opacity: 0.4,
251
+ }, bars.map((bar) => h('rect', {
252
+ key: bar.key,
253
+ x: bar.x,
254
+ y: bar.y,
255
+ width: bar.w,
256
+ height: bar.h,
257
+ 'data-mol-id': 'audio-waveform-bar',
258
+ }))),
259
+ h('g', {
260
+ 'data-mol-id': 'audio-waveform-bars-progress',
261
+ fill: resolvedProgressColor,
262
+ 'clip-path': `url(#${id}-progress)`,
263
+ }, bars.map((bar) => h('rect', {
264
+ key: bar.key,
265
+ x: bar.x,
266
+ y: bar.y,
267
+ width: bar.w,
268
+ height: bar.h,
269
+ 'data-mol-id': 'audio-waveform-bar-progress',
270
+ }))),
271
+ props.regions && safeDuration > 0
272
+ ? h('g', { 'data-mol-id': 'audio-waveform-regions' }, regionRects)
273
+ : null,
274
+ ]),
275
+ ]);
276
+ };
277
+ },
278
+ });
279
+ //# sourceMappingURL=AudioWaveform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AudioWaveform.js","sourceRoot":"","sources":["../src/AudioWaveform.ts"],"names":[],"mappings":"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AAC,CAAC;wBACb,aAAa,EAAE,6BAA6B;qBAC7C,CAAC,CACH,CACF;oBACD,KAAK,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC;wBAC/B,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,wBAAwB,EAAE,EAAE,WAAW,CAAC;wBAClE,CAAC,CAAC,IAAI;iBACT,CACF;aACF,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Audio waveform — stylized SVG renderer of pre-computed audio peaks
3
+ * with progress overlay, click-to-seek, and timed region markers.
4
+ *
5
+ * Vue counterpart of `@molecule/app-feature-audio-waveform-react`: the same
6
+ * props (React names), the same DOM for the same input.
7
+ *
8
+ * Used by music-daw, podcast, and music-streaming surfaces to display
9
+ * a waveform of the underlying audio source. Peak amplitudes must be
10
+ * computed by the caller (typically offline with `wavesurfer.js`,
11
+ * `peaks.js`, or an `AudioContext` analysis pass) — this package is
12
+ * intentionally just the renderer.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { defineComponent, h } from 'vue'
17
+ * import { AudioWaveform } from '@molecule/app-feature-audio-waveform-vue'
18
+ *
19
+ * const Player = defineComponent({
20
+ * props: { peaks: Array, duration: Number, currentTime: Number },
21
+ * setup(props) {
22
+ * return () =>
23
+ * h(AudioWaveform, {
24
+ * peaks: props.peaks,
25
+ * duration: props.duration,
26
+ * currentTime: props.currentTime,
27
+ * onSeek: (seconds: number) => {
28
+ * // move the audio element to `seconds`
29
+ * },
30
+ * regions: [{ id: 'loop', startTime: 12, duration: 3, color: '#a78bfa55' }],
31
+ * })
32
+ * },
33
+ * })
34
+ * ```
35
+ *
36
+ * @remarks
37
+ * - Requires a bonded ClassMap — rendering throws otherwise.
38
+ * - Text (aria labels + the empty state) routes through the binding's
39
+ * `useTranslation()`, so a locale switch re-renders it.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './AudioWaveform.js';
44
+ export * from './types.js';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Audio waveform — stylized SVG renderer of pre-computed audio peaks
3
+ * with progress overlay, click-to-seek, and timed region markers.
4
+ *
5
+ * Vue counterpart of `@molecule/app-feature-audio-waveform-react`: the same
6
+ * props (React names), the same DOM for the same input.
7
+ *
8
+ * Used by music-daw, podcast, and music-streaming surfaces to display
9
+ * a waveform of the underlying audio source. Peak amplitudes must be
10
+ * computed by the caller (typically offline with `wavesurfer.js`,
11
+ * `peaks.js`, or an `AudioContext` analysis pass) — this package is
12
+ * intentionally just the renderer.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { defineComponent, h } from 'vue'
17
+ * import { AudioWaveform } from '@molecule/app-feature-audio-waveform-vue'
18
+ *
19
+ * const Player = defineComponent({
20
+ * props: { peaks: Array, duration: Number, currentTime: Number },
21
+ * setup(props) {
22
+ * return () =>
23
+ * h(AudioWaveform, {
24
+ * peaks: props.peaks,
25
+ * duration: props.duration,
26
+ * currentTime: props.currentTime,
27
+ * onSeek: (seconds: number) => {
28
+ * // move the audio element to `seconds`
29
+ * },
30
+ * regions: [{ id: 'loop', startTime: 12, duration: 3, color: '#a78bfa55' }],
31
+ * })
32
+ * },
33
+ * })
34
+ * ```
35
+ *
36
+ * @remarks
37
+ * - Requires a bonded ClassMap — rendering throws otherwise.
38
+ * - Text (aria labels + the empty state) routes through the binding's
39
+ * `useTranslation()`, so a locale switch re-renders it.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './AudioWaveform.js';
44
+ export * from './types.js';
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Types for the Vue audio-waveform renderer.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * A timed colored band overlaid on top of the waveform — used to mark
8
+ * loop ranges, comments, edit selections, chapter spans, etc.
9
+ */
10
+ export interface WaveformRegion {
11
+ /** Stable identifier for the region (used as a render key). */
12
+ id: string;
13
+ /** Start of the region, in seconds. */
14
+ startTime: number;
15
+ /** Duration of the region, in seconds. Negative / zero hides the region. */
16
+ duration: number;
17
+ /**
18
+ * Optional CSS color applied to the region rectangle. Defaults to a
19
+ * semi-transparent accent ink. Use semi-transparent fills so the
20
+ * underlying waveform stays visible.
21
+ */
22
+ color?: string;
23
+ }
24
+ /** AudioWaveform component props (React's prop names). */
25
+ export interface AudioWaveformProps {
26
+ /**
27
+ * Pre-computed peak amplitudes in playback order. Each value should
28
+ * be normalized into the closed interval `[0, 1]` (the renderer clamps
29
+ * out-of-range values). One bar is drawn per peak.
30
+ */
31
+ peaks: number[];
32
+ /**
33
+ * Total duration of the underlying audio in seconds. Used to translate
34
+ * click positions into seek timestamps and to size region overlays.
35
+ * Must be `> 0` for `onSeek` and `regions` to render correctly.
36
+ */
37
+ duration: number;
38
+ /**
39
+ * Current playback time in seconds. Drives the progress overlay that
40
+ * fills the waveform from the left up to this point. Defaults to `0`.
41
+ */
42
+ currentTime?: number;
43
+ /**
44
+ * Optional click handler called with the seek target time (in
45
+ * seconds) when the user clicks anywhere on the waveform. When
46
+ * omitted, the waveform renders as a non-interactive display.
47
+ */
48
+ onSeek?: (seekTime: number) => void;
49
+ /** Optional region markers overlaid on top of the waveform. */
50
+ regions?: WaveformRegion[];
51
+ /** Pixel height of the waveform. Defaults to `64`. */
52
+ height?: number;
53
+ /**
54
+ * CSS color used for the progress overlay (the played portion of the
55
+ * waveform). Defaults to `currentColor`.
56
+ */
57
+ progressColor?: string;
58
+ /**
59
+ * CSS color used for the unplayed portion of the waveform. Defaults
60
+ * to `currentColor`.
61
+ */
62
+ waveColor?: string;
63
+ /** Extra classes merged onto the root element. */
64
+ className?: string;
65
+ }
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAA;IACV,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,cAAc,EAAE,CAAA;IAC1B,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Types for the Vue audio-waveform renderer.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@molecule/app-feature-audio-waveform-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-stage",
4
+ "description": "Stylized SVG audio waveform with click-to-seek + region overlays — renders pre-computed peaks for music-daw / podcast / streaming",
5
+ "homepage": "https://www.molecule.dev/packages/app-feature-audio-waveform-vue",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "vue-tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "audio-waveform",
28
+ "audio",
29
+ "waveform",
30
+ "music",
31
+ "podcast",
32
+ "vue"
33
+ ],
34
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/molecule-dev/molecule.git",
39
+ "directory": "packages/app/features/feature-audio-waveform-vue"
40
+ },
41
+ "engines": {
42
+ "node": ">=20"
43
+ },
44
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "peerDependencies": {
49
+ "@molecule/app-ui": "^1.0.1",
50
+ "@molecule/app-ui-vue": "^1.1.0",
51
+ "@molecule/app-vue": "^3.5.0",
52
+ "vue": "^3.4.0"
53
+ },
54
+ "devDependencies": {
55
+ "@molecule/app-framework-conformance": "0.0.0",
56
+ "@molecule/app-i18n": "1.2.2",
57
+ "@molecule/app-icons": "1.0.4",
58
+ "@molecule/app-ui": "1.4.0",
59
+ "@molecule/app-ui-vue": "1.1.5",
60
+ "@molecule/app-vue": "3.7.2",
61
+ "@types/node": "26.6.5",
62
+ "jsdom": "30.1.3",
63
+ "typescript": "6.0.3",
64
+ "vite": "8.3.5",
65
+ "vitest": "4.1.12",
66
+ "vue": "3.5.44",
67
+ "vue-tsc": "3.3.13"
68
+ }
69
+ }