sveltekit-ui 1.1.20 → 1.1.22

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.
@@ -297,6 +297,32 @@ export function create_audio_manager(config) {
297
297
  is_loading = false
298
298
  }
299
299
 
300
+ function mime_to_ext(mime) {
301
+ const v = String(mime || "").toLowerCase()
302
+ if (v.includes("mpeg")) return "mp3"
303
+ if (v.includes("mp4")) return "mp4"
304
+ if (v.includes("webm")) return "webm"
305
+ if (v.includes("ogg")) return "ogg"
306
+ if (v.includes("wav")) return "wav"
307
+ if (v.includes("flac")) return "flac"
308
+ if (v.includes("aac")) return "aac"
309
+ return "audio"
310
+ }
311
+
312
+ function safe_file_base(input) {
313
+ const s = String(input || "").trim()
314
+ if (!s) return "audio"
315
+ return (
316
+ s
317
+ .replace(/\.[a-z0-9]+$/i, "")
318
+ .replace(/[^a-z0-9_\- ]/gi, "")
319
+ .trim()
320
+ .replace(/\s+/g, "_")
321
+ .slice(0, 80)
322
+ .toLowerCase() || "audio"
323
+ )
324
+ }
325
+
300
326
  async function download_audio() {
301
327
  if (!browser) return
302
328
  download_error_message = null
@@ -306,7 +332,7 @@ export function create_audio_manager(config) {
306
332
  }
307
333
  try {
308
334
  download_is_loading = true
309
- const res = await fetch(src, { credentials: "include" })
335
+ const res = await fetch(src)
310
336
  if (!res.ok) {
311
337
  const t = await res.text().catch(() => null)
312
338
  download_error_message = t || `download failed (${res.status})`
@@ -316,11 +342,11 @@ export function create_audio_manager(config) {
316
342
  const blob = await res.blob()
317
343
  const ext = mime_to_ext(content_type || blob.type)
318
344
  const base = safe_file_base(title || album || artist || "recording")
319
- const filename = `${base}.${ext}`
345
+ const file_name = `${base}.${ext}`
320
346
  const object_url = URL.createObjectURL(blob)
321
347
  const a = document.createElement("a")
322
348
  a.href = object_url
323
- a.download = filename
349
+ a.download = file_name
324
350
  a.rel = "noopener"
325
351
  document.body.appendChild(a)
326
352
  a.click()
@@ -9,6 +9,9 @@ export const mime_type_extensions = {
9
9
  "image/tiff": "tiff",
10
10
  "image/heic": "heic",
11
11
  "image/svg+xml": "svg",
12
+ "audio/mp4": "m4a",
13
+ "audio/x-m4a": "m4a",
14
+ "audio/m4a": "m4a",
12
15
  "audio/mpeg": "mp3",
13
16
  "audio/wav": "wav",
14
17
  "audio/ogg": "ogg",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltekit-ui",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "A SvelteKit UI component library for building modern web applications",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
32
32
  "@vercel/analytics": "^1.6.1",
33
33
  "typescript": "^5.9.3",
34
- "vite": "^7.2.7"
34
+ "vite": "^7.3.0"
35
35
  },
36
36
  "homepage": "https://www.sveltekit-ui.com",
37
37
  "keywords": [
@@ -297,6 +297,32 @@ export function create_audio_manager(config) {
297
297
  is_loading = false
298
298
  }
299
299
 
300
+ function mime_to_ext(mime) {
301
+ const v = String(mime || "").toLowerCase()
302
+ if (v.includes("mpeg")) return "mp3"
303
+ if (v.includes("mp4")) return "mp4"
304
+ if (v.includes("webm")) return "webm"
305
+ if (v.includes("ogg")) return "ogg"
306
+ if (v.includes("wav")) return "wav"
307
+ if (v.includes("flac")) return "flac"
308
+ if (v.includes("aac")) return "aac"
309
+ return "audio"
310
+ }
311
+
312
+ function safe_file_base(input) {
313
+ const s = String(input || "").trim()
314
+ if (!s) return "audio"
315
+ return (
316
+ s
317
+ .replace(/\.[a-z0-9]+$/i, "")
318
+ .replace(/[^a-z0-9_\- ]/gi, "")
319
+ .trim()
320
+ .replace(/\s+/g, "_")
321
+ .slice(0, 80)
322
+ .toLowerCase() || "audio"
323
+ )
324
+ }
325
+
300
326
  async function download_audio() {
301
327
  if (!browser) return
302
328
  download_error_message = null
@@ -306,7 +332,7 @@ export function create_audio_manager(config) {
306
332
  }
307
333
  try {
308
334
  download_is_loading = true
309
- const res = await fetch(src, { credentials: "include" })
335
+ const res = await fetch(src)
310
336
  if (!res.ok) {
311
337
  const t = await res.text().catch(() => null)
312
338
  download_error_message = t || `download failed (${res.status})`
@@ -316,11 +342,11 @@ export function create_audio_manager(config) {
316
342
  const blob = await res.blob()
317
343
  const ext = mime_to_ext(content_type || blob.type)
318
344
  const base = safe_file_base(title || album || artist || "recording")
319
- const filename = `${base}.${ext}`
345
+ const file_name = `${base}.${ext}`
320
346
  const object_url = URL.createObjectURL(blob)
321
347
  const a = document.createElement("a")
322
348
  a.href = object_url
323
- a.download = filename
349
+ a.download = file_name
324
350
  a.rel = "noopener"
325
351
  document.body.appendChild(a)
326
352
  a.click()
@@ -9,6 +9,9 @@ export const mime_type_extensions = {
9
9
  "image/tiff": "tiff",
10
10
  "image/heic": "heic",
11
11
  "image/svg+xml": "svg",
12
+ "audio/mp4": "m4a",
13
+ "audio/x-m4a": "m4a",
14
+ "audio/m4a": "m4a",
12
15
  "audio/mpeg": "mp3",
13
16
  "audio/wav": "wav",
14
17
  "audio/ogg": "ogg",
@@ -24,6 +24,7 @@
24
24
  type: "audio/aac",
25
25
  image_src: "https://dummyimage.com/1000x400",
26
26
  image_type: "image/png",
27
+ is_show_download_button: true,
27
28
  })
28
29
 
29
30
  let audio_manager3 = create_audio_manager({