nuxt-musicfyplayer 2.1.2 → 2.1.4

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  [![License][license-src]][license-href]
8
8
  [![Nuxt][nuxt-src]][nuxt-href]
9
9
 
10
- Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and ColorThief.js
10
+ Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and fast-average-color
11
11
 
12
12
  - [✨ Release Notes](https://github.com/Yizack/nuxt-musicfyplayer/blob/main/CHANGELOG.md)
13
13
  - [🏀 Online playground](https://stackblitz.com/github/yizack/nuxt-musicfyplayer?file=playground%2Fapp.vue)
@@ -49,7 +49,7 @@ In the project, use the component `<MusicfyPlayer :config="" />`, where `config`
49
49
 
50
50
  | Property | Description | Default value |
51
51
  |---------------------------------------|--------------------------|---------------|
52
- | [`config`](#musicfyplayer-composale) | MusicfyPlayer composable | |
52
+ | [`config`](#musicfyplayer-composable) | MusicfyPlayer composable | |
53
53
  | `width` | Music player width | `100%` |
54
54
  | `height` | Music player height | `450px` |
55
55
 
@@ -120,7 +120,7 @@ const config = useMusicfyPlayer({
120
120
  rlkey: "g7sqo9y5zl3f69oxftzo5auc5"
121
121
  },
122
122
  image: {
123
- src: "https://dimatis.yizack.com/images/reminiscences.jpg",
123
+ src: "https://dimatis.music/images/reminiscences.jpg",
124
124
  alt: "Dimatis - Reminiscences"
125
125
  },
126
126
  color: {
@@ -146,7 +146,7 @@ Check out the [🏀 Online playground](https://stackblitz.com/github/yizack/nuxt
146
146
 
147
147
  ## Credits
148
148
 
149
- - Detect dominant color with [ColorThief](https://lokeshdhakar.com/projects/color-thief/)
149
+ - Detect average color with [fast-average-color](https://github.com/fast-average-color/fast-average-color)
150
150
  - Music player controls by [MediaElement.js](https://www.mediaelementjs.com/)
151
151
  - [Nuxt](https://github.com/nuxt/nuxt), the JavaScript framework for creating SSR Vue applications and its [Module Author Guide](https://nuxt.com/docs/guide/going-further/modules)
152
152
 
package/dist/module.d.mts CHANGED
@@ -4,4 +4,5 @@ interface ModuleOptions {
4
4
  }
5
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
6
 
7
- export { type ModuleOptions, _default as default };
7
+ export { _default as default };
8
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nuxt-musicfyplayer",
3
- "configKey": "nuxtMusicfyPlayer",
3
+ "configKey": "musicfyplayer",
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "2.1.2",
7
+ "version": "2.1.4",
8
8
  "builder": {
9
- "@nuxt/module-builder": "0.8.4",
10
- "unbuild": "2.0.0"
9
+ "@nuxt/module-builder": "1.0.0",
10
+ "unbuild": "3.5.0"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { defineNuxtModule, createResolver, addComponent, addImportsDir, addTypeTemplate } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponent, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const module = defineNuxtModule({
4
4
  meta: {
5
5
  name: "nuxt-musicfyplayer",
6
- configKey: "nuxtMusicfyPlayer",
6
+ configKey: "musicfyplayer",
7
7
  compatibility: {
8
8
  nuxt: ">=3.0.0"
9
9
  }
@@ -16,10 +16,6 @@ const module = defineNuxtModule({
16
16
  filePath: resolve("./runtime/components/MusicfyPlayer.vue")
17
17
  });
18
18
  addImportsDir(resolve("./runtime/composables"));
19
- addTypeTemplate({
20
- filename: "types/colorthief.d.ts",
21
- src: resolve("./runtime/types/colorthief.d.ts")
22
- });
23
19
  }
24
20
  });
25
21
 
@@ -1,62 +1,52 @@
1
- <script setup lang='ts'>
2
- import ColorThief from 'colorthief'
3
- import type { MusicfyPlayerConfig } from './../types/musicfyplayer'
4
- import { onMounted, ref, useTemplateRef } from '#imports'
5
-
6
- const props = withDefaults(defineProps<{
7
- /**
8
- * The configuration of the player
9
- */
10
- config: MusicfyPlayerConfig
11
- /**
12
- * The width and height of the player
13
- * @default '100%'
14
- */
15
- width?: string
16
- /**
17
- * The height of the player
18
- * @default '450px'
19
- */
20
- height?: string
21
- }>(), {
22
- width: '100%',
23
- height: '450px',
24
- })
25
-
26
- const audio = useTemplateRef<HTMLAudioElement>('audio')
27
-
28
- const size = ref({ width: props.width, height: props.height })
29
- const backgroundColor = ref<string | undefined>()
30
-
31
- if (import.meta.client && props.config.colorDetect) {
32
- const img = new Image()
33
- img.crossOrigin = 'Anonymous'
34
- img.src = props.config.imageSrc
35
-
36
- img.onload = () => {
37
- const colorThief = new ColorThief()
38
- const color = colorThief.getColor(img)
39
- backgroundColor.value = color ? `rgb(${color[0]}, ${color[1]}, ${color[2]})` : undefined
40
- }
41
- }
42
-
43
- onMounted(async () => {
44
- if (!audio.value) return
45
- const { mediaElementPlayer } = await import('./../utils/mediaelement')
46
- mediaElementPlayer(audio.value, {
47
- iconSprite: '',
48
- audioHeight: 40,
49
- features: ['playpause', 'current', 'duration', 'progress', 'volume', 'tracks', 'fullscreen'],
50
- alwaysShowControls: true,
51
- timeAndDurationSeparator: '<span></span>',
52
- iPadUseNativeControls: false,
53
- iPhoneUseNativeControls: false,
54
- AndroidUseNativeControls: false,
55
- })
56
- })
57
- </script>
58
-
59
- <template>
1
+ <script setup>
2
+ import { FastAverageColor } from "fast-average-color";
3
+ import { onMounted, ref, useTemplateRef } from "#imports";
4
+ const props = defineProps({
5
+ config: {
6
+ type: Object,
7
+ required: true
8
+ },
9
+ width: {
10
+ type: String,
11
+ required: false,
12
+ default: "100%"
13
+ },
14
+ height: {
15
+ type: String,
16
+ required: false,
17
+ default: "450px"
18
+ }
19
+ });
20
+ const audio = useTemplateRef("audio");
21
+ const size = ref({ width: props.width, height: props.height });
22
+ const backgroundColor = ref();
23
+ if (import.meta.client && props.config.colorDetect) {
24
+ const img = new Image();
25
+ img.crossOrigin = "Anonymous";
26
+ img.src = props.config.imageSrc;
27
+ img.onload = () => {
28
+ const fac = new FastAverageColor();
29
+ const color = fac.getColor(img);
30
+ backgroundColor.value = color ? color.rgba : void 0;
31
+ };
32
+ }
33
+ onMounted(async () => {
34
+ if (!audio.value) return;
35
+ const { mediaElementPlayer } = await import("./../utils/mediaelement");
36
+ mediaElementPlayer(audio.value, {
37
+ iconSprite: "",
38
+ audioHeight: 40,
39
+ features: ["playpause", "current", "duration", "progress", "volume", "tracks", "fullscreen"],
40
+ alwaysShowControls: true,
41
+ timeAndDurationSeparator: "<span></span>",
42
+ iPadUseNativeControls: false,
43
+ iPhoneUseNativeControls: false,
44
+ AndroidUseNativeControls: false
45
+ });
46
+ });
47
+ </script>
48
+
49
+ <template>
60
50
  <div class="musicfyplayer" :class="{ [`${config.colorClass}`]: config.colorClass }" :style="{ ...size, backgroundColor }">
61
51
  <div class="mp__box">
62
52
  <div class="mp__controls">
@@ -75,8 +65,8 @@ onMounted(async () => {
75
65
  </div>
76
66
  </div>
77
67
  </div>
78
- </template>
79
-
68
+ </template>
69
+
80
70
  <style>
81
71
  @import "./../assets/css/musicfyplayer.css";
82
- </style>
72
+ </style>
@@ -0,0 +1,22 @@
1
+ import type { MusicfyPlayerConfig } from './../types/musicfyplayer.js';
2
+ type __VLS_Props = {
3
+ /**
4
+ * The configuration of the player
5
+ */
6
+ config: MusicfyPlayerConfig;
7
+ /**
8
+ * The width and height of the player
9
+ * @default '100%'
10
+ */
11
+ width?: string;
12
+ /**
13
+ * The height of the player
14
+ * @default '450px'
15
+ */
16
+ height?: string;
17
+ };
18
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ width: string;
20
+ height: string;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ export default _default;
@@ -5,5 +5,5 @@ import type { MusicfyPlayerConfig, MusicfyPlayerComposableConfig } from './../ty
5
5
  * @param config - Musicfy Player composable configuration
6
6
  * @returns Musicfy Player configuration
7
7
  */
8
- export declare const useMusicfyPlayer: <T extends keyof Providers>(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
9
- export declare const defineMusicfyPlayer: <T extends keyof Providers>(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
8
+ export declare const useMusicfyPlayer: <T extends keyof Providers = "local">(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
9
+ export declare const defineMusicfyPlayer: <T extends keyof Providers = "local">(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
@@ -12,3 +12,9 @@ export interface MediaElementPlayerOptions {
12
12
  iPhoneUseNativeControls: boolean
13
13
  AndroidUseNativeControls: boolean
14
14
  }
15
+
16
+ declare global {
17
+ interface Window {
18
+ MediaElementPlayer?: MediaElementPlayer
19
+ }
20
+ }
@@ -1,8 +1,3 @@
1
1
  import 'mediaelement/build/mediaelement-and-player.js';
2
- import type { MediaElementPlayer, MediaElementPlayerOptions } from '../types/mediaelement.js';
3
- declare global {
4
- interface Window {
5
- MediaElementPlayer: MediaElementPlayer | undefined;
6
- }
7
- }
2
+ import type { MediaElementPlayerOptions } from '../types/mediaelement.js';
8
3
  export declare const mediaElementPlayer: (element: HTMLAudioElement, options: MediaElementPlayerOptions) => void;
package/dist/types.d.mts CHANGED
@@ -1 +1,3 @@
1
- export { type ModuleOptions, default } from './module.js'
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-musicfyplayer",
3
- "version": "2.1.2",
4
- "description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and ColorThief.js",
3
+ "version": "2.1.4",
4
+ "description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and fast-average-color",
5
5
  "keywords": [
6
6
  "nuxt",
7
7
  "nuxt3",
@@ -16,19 +16,17 @@
16
16
  "author": {
17
17
  "name": "Yizack Rangel",
18
18
  "email": "yizackr@gmail.com",
19
- "url": "https://yizack.com/"
19
+ "url": "https://yizack.com"
20
20
  },
21
21
  "license": "MIT",
22
22
  "type": "module",
23
23
  "exports": {
24
24
  ".": {
25
- "types": "./dist/types.d.ts",
26
- "import": "./dist/module.mjs",
27
- "require": "./dist/module.cjs"
25
+ "types": "./dist/types.d.mts",
26
+ "import": "./dist/module.mjs"
28
27
  }
29
28
  },
30
- "main": "./dist/module.cjs",
31
- "types": "./dist/types.d.ts",
29
+ "main": "./dist/module.mjs",
32
30
  "files": [
33
31
  "dist"
34
32
  ],
@@ -45,29 +43,22 @@
45
43
  "test:watch": "vitest watch"
46
44
  },
47
45
  "dependencies": {
48
- "@nuxt/kit": "^3.15.4",
49
- "colorthief": "2.4.0",
46
+ "@nuxt/kit": "^3.16.2",
47
+ "fast-average-color": "^9.5.0",
50
48
  "mediaelement": "^7.0.7"
51
49
  },
52
50
  "devDependencies": {
53
- "@nuxt/devtools": "^2.0.0",
54
- "@nuxt/eslint-config": "^1.0.1",
55
- "@nuxt/module-builder": "^0.8.4",
56
- "@nuxt/schema": "^3.15.4",
57
- "@nuxt/test-utils": "^3.15.4",
58
- "@types/node": "^22.13.1",
59
- "changelogen": "^0.5.7",
60
- "eslint": "^9.20.0",
61
- "nuxt": "^3.15.4",
62
- "vitest": "^3.0.5",
63
- "vue-tsc": "^2.2.0"
51
+ "@nuxt/devtools": "^2.3.2",
52
+ "@nuxt/eslint-config": "^1.3.0",
53
+ "@nuxt/module-builder": "^1.0.0",
54
+ "@nuxt/schema": "^3.16.2",
55
+ "@nuxt/test-utils": "^3.17.2",
56
+ "@types/node": "^22.14.0",
57
+ "changelogen": "^0.6.1",
58
+ "eslint": "^9.24.0",
59
+ "nuxt": "^3.16.2",
60
+ "vitest": "^3.1.1",
61
+ "vue-tsc": "^2.2.8"
64
62
  },
65
- "changelog": {
66
- "repo": {
67
- "repo": "Yizack/nuxt-musicfyplayer",
68
- "provider": "github",
69
- "domain": "github.com"
70
- }
71
- },
72
- "packageManager": "pnpm@10.2.1"
73
- }
63
+ "packageManager": "pnpm@10.7.1"
64
+ }
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- }
5
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
-
7
- export { type ModuleOptions, _default as default };
@@ -1,9 +0,0 @@
1
- declare module 'colorthief' {
2
- type Palette = [red: number, green: number, blue: number]
3
- export default class ColorThief {
4
- getColor(sourceImage: HTMLImageElement, quality?: number): Palette
5
- static getColor(sourceImage: string, quality?: number): Promise<Palette>
6
- getPaletteFromURL(URL: string, colorCount?: number, quality?: number): Promise<Palette[]>
7
- getColorFromURL(imageURL: string, quality?: number): Promise<Palette>
8
- }
9
- }
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export { type ModuleOptions, default } from './module'