snice 3.5.0 → 3.7.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/bin/snice.js +2 -1
- package/bin/templates/CLAUDE.md +24 -2
- package/bin/templates/pwa/README.md +173 -0
- package/bin/templates/pwa/global.d.ts +10 -0
- package/bin/templates/pwa/index.html +17 -0
- package/bin/templates/pwa/package.json +25 -0
- package/bin/templates/pwa/public/icons/.gitkeep +6 -0
- package/bin/templates/pwa/public/manifest.json +24 -0
- package/bin/templates/pwa/public/vite.svg +1 -0
- package/bin/templates/pwa/src/daemons/notifications.ts +148 -0
- package/bin/templates/pwa/src/guards/auth.ts +10 -0
- package/bin/templates/pwa/src/main.ts +42 -0
- package/bin/templates/pwa/src/middleware/auth.ts +15 -0
- package/bin/templates/pwa/src/middleware/error.ts +25 -0
- package/bin/templates/pwa/src/middleware/retry.ts +27 -0
- package/bin/templates/pwa/src/pages/dashboard.ts +142 -0
- package/bin/templates/pwa/src/pages/login.ts +161 -0
- package/bin/templates/pwa/src/pages/notifications.ts +156 -0
- package/bin/templates/pwa/src/pages/profile.ts +163 -0
- package/bin/templates/pwa/src/router.ts +16 -0
- package/bin/templates/pwa/src/services/auth.ts +48 -0
- package/bin/templates/pwa/src/services/jwt.ts +35 -0
- package/bin/templates/pwa/src/services/storage.ts +24 -0
- package/bin/templates/pwa/src/styles/global.css +55 -0
- package/bin/templates/pwa/src/types/auth.ts +21 -0
- package/bin/templates/pwa/src/types/notifications.ts +9 -0
- package/bin/templates/pwa/src/utils/fetch.ts +39 -0
- package/bin/templates/pwa/tsconfig.json +23 -0
- package/bin/templates/pwa/vite.config.ts +94 -0
- package/dist/components/audio-recorder/snice-audio-recorder.d.ts +14 -4
- package/dist/components/audio-recorder/snice-audio-recorder.js +248 -71
- package/dist/components/audio-recorder/snice-audio-recorder.js.map +1 -1
- package/dist/components/audio-recorder/snice-audio-recorder.types.d.ts +2 -0
- package/dist/components/music-player/snice-music-player.d.ts +72 -0
- package/dist/components/music-player/snice-music-player.js +730 -0
- package/dist/components/music-player/snice-music-player.js.map +1 -0
- package/dist/components/music-player/snice-music-player.types.d.ts +43 -0
- package/dist/components/timer/snice-timer.d.ts +27 -0
- package/dist/components/timer/snice-timer.js +197 -0
- package/dist/components/timer/snice-timer.js.map +1 -0
- package/dist/components/timer/snice-timer.types.d.ts +10 -0
- package/dist/fetcher.d.ts +65 -0
- package/dist/index.cjs +92 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +92 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +92 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/dist/types/context.d.ts +7 -1
- package/dist/types/router-options.d.ts +6 -0
- package/docs/ai/api.md +33 -1
- package/docs/ai/components/music-player.md +134 -0
- package/docs/ai/components/terminal.md +147 -0
- package/docs/ai/components/timer.md +43 -0
- package/docs/ai/patterns.md +47 -0
- package/docs/components/music-player.md +314 -0
- package/docs/components/terminal.md +451 -0
- package/docs/components/timer.md +143 -0
- package/docs/fetcher.md +447 -0
- package/docs/routing.md +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Music Player Component
|
|
2
|
+
|
|
3
|
+
A full-featured audio player with playlist support, shuffle, repeat modes, and volume control.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<snice-music-player id="player"></snice-music-player>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
const player = document.getElementById('player');
|
|
12
|
+
|
|
13
|
+
// Set tracks
|
|
14
|
+
player.tracks = [
|
|
15
|
+
{
|
|
16
|
+
id: 'track-1',
|
|
17
|
+
title: 'Song Title',
|
|
18
|
+
artist: 'Artist Name',
|
|
19
|
+
album: 'Album Name',
|
|
20
|
+
artwork: 'https://example.com/artwork.jpg',
|
|
21
|
+
src: 'https://example.com/audio.mp3',
|
|
22
|
+
duration: 180
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// Listen for events
|
|
27
|
+
player.addEventListener('@snice/player-play', (e) => {
|
|
28
|
+
console.log('Playing:', e.detail.track.title);
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Properties
|
|
34
|
+
|
|
35
|
+
| Property | Type | Default | Description |
|
|
36
|
+
|----------|------|---------|-------------|
|
|
37
|
+
| `tracks` | `Track[]` | `[]` | Array of tracks |
|
|
38
|
+
| `currentTrackIndex` | `number` | `0` | Current track index |
|
|
39
|
+
| `currentTrack` | `string` | `''` | Current track ID (reflected attribute) |
|
|
40
|
+
| `currentTime` | `number` | `0` | Current playback time (read-only, use seek() to set) |
|
|
41
|
+
| `duration` | `number` | `0` | Track duration (seconds) |
|
|
42
|
+
| `volume` | `number` | `1` | Volume (0-1) |
|
|
43
|
+
| `muted` | `boolean` | `false` | Mute state |
|
|
44
|
+
| `shuffle` | `boolean` | `false` | Shuffle mode |
|
|
45
|
+
| `repeat` | `RepeatMode` | `'off'` | Repeat mode |
|
|
46
|
+
| `state` | `PlayerState` | `'stopped'` | Playback state |
|
|
47
|
+
| `autoplay` | `boolean` | `false` | Auto-play on load |
|
|
48
|
+
| `showPlaylist` | `boolean` | `true` | Show playlist |
|
|
49
|
+
| `showControls` | `boolean` | `true` | Show control buttons |
|
|
50
|
+
| `showVolume` | `boolean` | `true` | Show volume control |
|
|
51
|
+
| `showArtwork` | `boolean` | `true` | Show artwork |
|
|
52
|
+
| `showTrackInfo` | `boolean` | `true` | Show track info |
|
|
53
|
+
| `compact` | `boolean` | `false` | Compact mode |
|
|
54
|
+
|
|
55
|
+
## Track Interface
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface Track {
|
|
59
|
+
id: string;
|
|
60
|
+
title: string;
|
|
61
|
+
artist?: string;
|
|
62
|
+
album?: string;
|
|
63
|
+
artwork?: string;
|
|
64
|
+
src: string;
|
|
65
|
+
duration?: number;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Repeat Modes
|
|
70
|
+
|
|
71
|
+
- `'off'` - No repeat
|
|
72
|
+
- `'all'` - Repeat all tracks
|
|
73
|
+
- `'one'` - Repeat current track
|
|
74
|
+
|
|
75
|
+
## Player States
|
|
76
|
+
|
|
77
|
+
- `'playing'` - Currently playing
|
|
78
|
+
- `'paused'` - Paused
|
|
79
|
+
- `'stopped'` - Stopped
|
|
80
|
+
- `'loading'` - Loading track
|
|
81
|
+
- `'error'` - Error occurred
|
|
82
|
+
|
|
83
|
+
## Methods
|
|
84
|
+
|
|
85
|
+
### `play(): Promise<void>`
|
|
86
|
+
Start or resume playback.
|
|
87
|
+
|
|
88
|
+
### `pause(): void`
|
|
89
|
+
Pause playback.
|
|
90
|
+
|
|
91
|
+
### `stop(): void`
|
|
92
|
+
Stop playback and reset position.
|
|
93
|
+
|
|
94
|
+
### `next(): void`
|
|
95
|
+
Skip to next track.
|
|
96
|
+
|
|
97
|
+
### `previous(): void`
|
|
98
|
+
Skip to previous track.
|
|
99
|
+
|
|
100
|
+
### `seek(time: number): void`
|
|
101
|
+
Seek to specific time (seconds).
|
|
102
|
+
|
|
103
|
+
### `setVolume(volume: number): void`
|
|
104
|
+
Set volume (0-1).
|
|
105
|
+
|
|
106
|
+
### `toggleShuffle(): void`
|
|
107
|
+
Toggle shuffle mode.
|
|
108
|
+
|
|
109
|
+
### `setRepeat(mode: RepeatMode): void`
|
|
110
|
+
Set repeat mode.
|
|
111
|
+
|
|
112
|
+
### `loadTrack(index: number): Promise<void>`
|
|
113
|
+
Load track by index.
|
|
114
|
+
|
|
115
|
+
### `getCurrentTrack(): Track | null`
|
|
116
|
+
Get current track.
|
|
117
|
+
|
|
118
|
+
## Events
|
|
119
|
+
|
|
120
|
+
- `@snice/player-play` - Playback started
|
|
121
|
+
- `@snice/player-pause` - Playback paused
|
|
122
|
+
- `@snice/player-stop` - Playback stopped
|
|
123
|
+
- `@snice/player-track-change` - Track changed
|
|
124
|
+
- `@snice/player-track-ended` - Track ended
|
|
125
|
+
- `@snice/player-shuffle-change` - Shuffle changed
|
|
126
|
+
- `@snice/player-repeat-change` - Repeat mode changed
|
|
127
|
+
- `@snice/player-volume-change` - Volume changed
|
|
128
|
+
- `@snice/player-time-update` - Playback time updated
|
|
129
|
+
- `@snice/player-error` - Error occurred
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
### Full Player with Playlist
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<snice-music-player id="player"></snice-music-player>
|
|
137
|
+
|
|
138
|
+
<script>
|
|
139
|
+
const player = document.getElementById('player');
|
|
140
|
+
|
|
141
|
+
player.tracks = [
|
|
142
|
+
{
|
|
143
|
+
id: '1',
|
|
144
|
+
title: 'Summer Breeze',
|
|
145
|
+
artist: 'The Acoustic Collective',
|
|
146
|
+
album: 'Peaceful Moments',
|
|
147
|
+
artwork: 'https://example.com/art1.jpg',
|
|
148
|
+
src: 'https://example.com/track1.mp3',
|
|
149
|
+
duration: 360
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: '2',
|
|
153
|
+
title: 'Midnight Jazz',
|
|
154
|
+
artist: 'Smooth Notes Ensemble',
|
|
155
|
+
album: 'Late Night Sessions',
|
|
156
|
+
artwork: 'https://example.com/art2.jpg',
|
|
157
|
+
src: 'https://example.com/track2.mp3',
|
|
158
|
+
duration: 420
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
</script>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Compact Player (No Playlist)
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<snice-music-player
|
|
168
|
+
show-playlist="false"
|
|
169
|
+
compact>
|
|
170
|
+
</snice-music-player>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Minimal Player
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<snice-music-player
|
|
177
|
+
show-playlist="false"
|
|
178
|
+
show-artwork="false"
|
|
179
|
+
show-track-info="false">
|
|
180
|
+
</snice-music-player>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Programmatic Control
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
const player = document.querySelector('snice-music-player');
|
|
187
|
+
|
|
188
|
+
// Play/Pause
|
|
189
|
+
await player.play();
|
|
190
|
+
player.pause();
|
|
191
|
+
player.stop();
|
|
192
|
+
|
|
193
|
+
// Navigation
|
|
194
|
+
player.next();
|
|
195
|
+
player.previous();
|
|
196
|
+
|
|
197
|
+
// Seek
|
|
198
|
+
player.seek(30); // Jump to 30 seconds
|
|
199
|
+
|
|
200
|
+
// Volume
|
|
201
|
+
player.setVolume(0.5); // 50% volume
|
|
202
|
+
|
|
203
|
+
// Shuffle
|
|
204
|
+
player.toggleShuffle();
|
|
205
|
+
|
|
206
|
+
// Repeat
|
|
207
|
+
player.setRepeat('all');
|
|
208
|
+
player.setRepeat('one');
|
|
209
|
+
player.setRepeat('off');
|
|
210
|
+
|
|
211
|
+
// Load track
|
|
212
|
+
await player.loadTrack(2); // Load third track
|
|
213
|
+
|
|
214
|
+
// Get current track
|
|
215
|
+
const track = player.getCurrentTrack();
|
|
216
|
+
console.log(track.title, track.artist);
|
|
217
|
+
|
|
218
|
+
// Get/set via currentTrack attribute
|
|
219
|
+
console.log(player.currentTrack); // Returns track ID
|
|
220
|
+
player.currentTrack = 'track-2'; // Loads track with this ID
|
|
221
|
+
|
|
222
|
+
// Change time via seek (currentTime is read-only)
|
|
223
|
+
player.seek(30); // Jump to 30 seconds
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Event Handling
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const player = document.querySelector('snice-music-player');
|
|
230
|
+
|
|
231
|
+
player.addEventListener('@snice/player-play', (e) => {
|
|
232
|
+
console.log('Playing:', e.detail.track);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
player.addEventListener('@snice/player-pause', (e) => {
|
|
236
|
+
console.log('Paused:', e.detail.track);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
player.addEventListener('@snice/player-track-change', (e) => {
|
|
240
|
+
console.log('Track changed:', e.detail.track);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
player.addEventListener('@snice/player-track-ended', (e) => {
|
|
244
|
+
console.log('Track ended:', e.detail.track);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
player.addEventListener('@snice/player-time-update', (e) => {
|
|
248
|
+
console.log('Time:', e.detail.currentTime, '/', e.detail.duration);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
player.addEventListener('@snice/player-error', (e) => {
|
|
252
|
+
console.error('Error:', e.detail.error);
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Auto-play
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<snice-music-player autoplay></snice-music-player>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Note:** Autoplay may be blocked by browser policies. User interaction is usually required.
|
|
263
|
+
|
|
264
|
+
### Dynamic Track Loading
|
|
265
|
+
|
|
266
|
+
```javascript
|
|
267
|
+
const player = document.querySelector('snice-music-player');
|
|
268
|
+
|
|
269
|
+
// Load tracks from API
|
|
270
|
+
const response = await fetch('/api/tracks');
|
|
271
|
+
const tracks = await response.json();
|
|
272
|
+
|
|
273
|
+
player.tracks = tracks;
|
|
274
|
+
await player.loadTrack(0);
|
|
275
|
+
await player.play();
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Playlist Click Handler
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
// Tracks in playlist are clickable by default
|
|
282
|
+
// Listen for track changes
|
|
283
|
+
player.addEventListener('@snice/player-track-change', (e) => {
|
|
284
|
+
console.log('User selected:', e.detail.track.title);
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Features
|
|
289
|
+
|
|
290
|
+
- Full-featured audio player with HTML5 Audio API
|
|
291
|
+
- Playlist support with clickable tracks
|
|
292
|
+
- Play, pause, stop, next, previous controls
|
|
293
|
+
- Shuffle mode with randomization
|
|
294
|
+
- Repeat modes: off, all, one
|
|
295
|
+
- Volume control with vertical slider
|
|
296
|
+
- Progress bar with seek support
|
|
297
|
+
- Real-time progress updates
|
|
298
|
+
- Track artwork and metadata display
|
|
299
|
+
- Compact mode for smaller layouts
|
|
300
|
+
- Fully customizable with show/hide options
|
|
301
|
+
- Event-driven architecture
|
|
302
|
+
- TypeScript support
|
|
303
|
+
|
|
304
|
+
## Browser Support
|
|
305
|
+
|
|
306
|
+
- Modern browsers with HTML5 Audio support
|
|
307
|
+
- Requires JavaScript enabled
|
|
308
|
+
|
|
309
|
+
## Accessibility
|
|
310
|
+
|
|
311
|
+
- Keyboard navigation support
|
|
312
|
+
- ARIA labels on controls
|
|
313
|
+
- Semantic HTML structure
|
|
314
|
+
- Focus indicators
|