nuxt-musicfyplayer 1.0.1 → 2.0.1

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
@@ -5,7 +5,6 @@
5
5
  [![npm version][npm-version-src]][npm-version-href]
6
6
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
7
  [![License][license-src]][license-href]
8
- [![Tests][tests-src]][tests-href]
9
8
  [![Nuxt][nuxt-src]][nuxt-href]
10
9
 
11
10
  Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and ColorThief.js
@@ -44,14 +43,25 @@ That's it! You can now use `nuxt-musicfyplayer` in your Nuxt app ✨
44
43
 
45
44
  In the project, use the component `<MusicfyPlayer :config="" />`, where `config` is the configuration options of the player.
46
45
 
46
+ ### Component properties
47
+
48
+ ## Size properties
49
+
50
+ | Property | Description | Default value |
51
+ |---------------------------------------|--------------------------|---------------|
52
+ | [`config`](#musicfyplayer-definition) | MusicfyPlayer definition | |
53
+ | `width` | Music player width | `100%` |
54
+ | `height` | Music player height | `450px` |
55
+
56
+ ## MusicfyPlayer Definition
57
+
47
58
  Define your configuration options with the `defineMusicfyPlayer` composable.
48
59
 
49
- | Property | Description |
50
- |----------------------------|---------------------------------------|
60
+ | Property | Description |
61
+ |-------------------------------------|---------------------------------------|
51
62
  | [`audio`](#audio-shared-properties) | The audio source properties |
52
- | [`image`](#image-properties) | The image source (preferably squared) |
53
- | [`size`](#size-properties) | The size of your player |
54
- | [`color`](#color-properties) | Color options |
63
+ | [`image`](#image-properties) | The image source (preferably squared) |
64
+ | [`color`](#color-properties) | Color options |
55
65
 
56
66
  ## Audio shared properties
57
67
 
@@ -65,7 +75,7 @@ Define your configuration options with the `defineMusicfyPlayer` composable.
65
75
 
66
76
  | Provider | Value |
67
77
  |--------------------------------------|----------|
68
- | [URL](#local-audio-properties) | `local` |
78
+ | [URL](#local-audio-properties) | `local` |
69
79
  | [Dropbox](#dropbox-audio-properties) | `dropbox`|
70
80
 
71
81
  ### Local audio properties
@@ -88,13 +98,6 @@ Define your configuration options with the `defineMusicfyPlayer` composable.
88
98
  | `src` | Image source link | Yes |
89
99
  | `alt` | Image alternative text | No |
90
100
 
91
- ## Size properties
92
-
93
- | Property | Description | Default value |
94
- |----------|------------------------|---------------|
95
- | `width` | Music player width | `100%` |
96
- | `height` | Music player height | `450px` |
97
-
98
101
  ## Color properties
99
102
 
100
103
  | Property | Description | Default value |
@@ -118,9 +121,6 @@ const config = defineMusicfyPlayer({
118
121
  src: "https://dimatis.yizack.com/images/reminiscences.jpg",
119
122
  alt: "Dimatis - Reminiscences"
120
123
  },
121
- size: {
122
- width: "100%"
123
- },
124
124
  color: {
125
125
  detect: true
126
126
  }
@@ -128,7 +128,7 @@ const config = defineMusicfyPlayer({
128
128
  </script>
129
129
 
130
130
  <template>
131
- <MusicfyPlayer :config="config" />
131
+ <MusicfyPlayer :config="config" width="100%" />
132
132
  </template>
133
133
  ```
134
134
 
@@ -175,17 +175,17 @@ npm run release
175
175
  ```
176
176
 
177
177
  <!-- Badges -->
178
- [npm-version-src]: https://img.shields.io/npm/v/nuxt-musicfyplayer/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
178
+ [npm-version-src]: https://img.shields.io/npm/v/nuxt-musicfyplayer/latest.svg?style=flat&colorA=020420&colorB=00DC82
179
179
  [npm-version-href]: https://npmjs.com/package/nuxt-musicfyplayer
180
180
 
181
- [npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-musicfyplayer.svg?style=flat&colorA=18181B&colorB=28CF8D
181
+ [npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-musicfyplayer.svg?style=flat&colorA=020420&colorB=00DC82
182
182
  [npm-downloads-href]: https://npmjs.com/package/nuxt-musicfyplayer
183
183
 
184
- [license-src]: https://img.shields.io/npm/l/nuxt-musicfyplayer.svg?style=flat&colorA=18181B&colorB=28CF8D
184
+ [license-src]: https://img.shields.io/npm/l/nuxt-musicfyplayer.svg?style=flat&colorA=020420&colorB=00DC82
185
185
  [license-href]: LICENSE
186
186
 
187
- [tests-src]: https://img.shields.io/github/actions/workflow/status/Yizack/nuxt-musicfyplayer/tests.yml?style=flat&colorA=18181B&colorB=28CF8D&label=tests
187
+ [tests-src]: https://img.shields.io/github/actions/workflow/status/Yizack/nuxt-musicfyplayer/tests.yml?style=flat&colorA=020420&colorB=00DC82&label=tests
188
188
  [tests-href]: https://github.com/Yizack/nuxt-musicfyplayer/actions/workflows/tests.yml
189
189
 
190
- [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
190
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
191
191
  [nuxt-href]: https://nuxt.com
package/dist/module.d.mts CHANGED
@@ -2,6 +2,6 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  }
5
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
5
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
6
 
7
7
  export { type ModuleOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -2,6 +2,6 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  }
5
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
5
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
6
 
7
7
  export { type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -2,7 +2,11 @@
2
2
  "name": "nuxt-musicfyplayer",
3
3
  "configKey": "nuxtMusicfyPlayer",
4
4
  "compatibility": {
5
- "nuxt": "^3.0.0"
5
+ "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "1.0.1"
7
+ "version": "2.0.1",
8
+ "builder": {
9
+ "@nuxt/module-builder": "0.8.3",
10
+ "unbuild": "2.0.0"
11
+ }
8
12
  }
package/dist/module.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { defineNuxtModule, createResolver, addComponent, addImportsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponent, addImportsDir, addTypeTemplate } from '@nuxt/kit';
2
2
 
3
3
  const module = defineNuxtModule({
4
4
  meta: {
5
5
  name: "nuxt-musicfyplayer",
6
6
  configKey: "nuxtMusicfyPlayer",
7
7
  compatibility: {
8
- nuxt: "^3.0.0"
8
+ nuxt: ">=3.0.0"
9
9
  }
10
10
  },
11
11
  setup() {
@@ -16,6 +16,10 @@ 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
+ });
19
23
  }
20
24
  });
21
25
 
@@ -1,21 +1,40 @@
1
1
  <script setup lang='ts'>
2
- import { onMounted, ref, type Ref } from '#imports'
3
- import type { MusicfyPlayerConfig } from './../types/musicfyplayer'
4
2
  import ColorThief from 'colorthief'
3
+ import type { MusicfyPlayerConfig } from './../types/musicfyplayer'
4
+ import { onMounted, ref, type Ref } from '#imports'
5
5
 
6
6
  const props = defineProps({
7
+ /**
8
+ * The configuration of the player
9
+ */
7
10
  config: {
8
11
  type: Object as () => MusicfyPlayerConfig,
9
- required: true
10
- }
12
+ required: true,
13
+ },
14
+ /**
15
+ * The width and height of the player
16
+ * @default '100%'
17
+ */
18
+ width: {
19
+ type: String,
20
+ default: '100%',
21
+ },
22
+ /**
23
+ * The height of the player
24
+ * @default '450px'
25
+ */
26
+ height: {
27
+ type: String,
28
+ default: '450px',
29
+ },
11
30
  })
12
31
 
13
32
  const audio = ref() as Ref<HTMLAudioElement>
14
- const size = ref({ width: props.config.sizeWidth, height: props.config.sizeHeight })
33
+ const size = ref({ width: props.width, height: props.height })
15
34
  const backgroundColor = ref<string | undefined>()
16
35
 
17
36
  const generateColor = async () => {
18
- if (process.client && props.config.colorDetect) {
37
+ if (import.meta.client && props.config.colorDetect) {
19
38
  const img = new Image()
20
39
  img.crossOrigin = 'Anonymous'
21
40
  img.src = props.config.imageSrc
@@ -40,7 +59,7 @@ onMounted(async () => {
40
59
  timeAndDurationSeparator: '<span></span>',
41
60
  iPadUseNativeControls: false,
42
61
  iPhoneUseNativeControls: false,
43
- AndroidUseNativeControls: false
62
+ AndroidUseNativeControls: false,
44
63
  })
45
64
  })
46
65
  </script>
@@ -1,2 +1,2 @@
1
- import type { MusicfyPlayerConfig, MusicfyPlayerDefinition } from './../types/musicfyplayer';
1
+ import type { MusicfyPlayerConfig, MusicfyPlayerDefinition } from './../types/musicfyplayer.js';
2
2
  export declare const defineMusicfyPlayer: (config: MusicfyPlayerDefinition) => MusicfyPlayerConfig;
@@ -6,10 +6,6 @@ const srcDropbox = (id, rlkey) => {
6
6
  export const defineMusicfyPlayer = (config) => {
7
7
  const audioSrc = ref();
8
8
  const provider = config.audio.provider || "local";
9
- const size = {
10
- width: config.size?.width || "100%",
11
- height: config.size?.height || "450px"
12
- };
13
9
  switch (provider) {
14
10
  default:
15
11
  case "local":
@@ -19,16 +15,12 @@ export const defineMusicfyPlayer = (config) => {
19
15
  audioSrc.value = srcDropbox(config.audio.id, config.audio.rlkey);
20
16
  break;
21
17
  }
22
- if (!audioSrc.value) {
23
- throw new Error("Invalid audio source");
24
- }
18
+ if (!audioSrc.value) throw new Error("Invalid audio source");
25
19
  return {
26
20
  imageSrc: config.image.src,
27
21
  imageAlt: config.image.alt || "Musicfy Player",
28
22
  audioType: config.audio.type || "audio/mpeg",
29
23
  audioSrc: audioSrc.value,
30
- sizeWidth: size.width,
31
- sizeHeight: size.height,
32
24
  colorClass: config.color?.class || "musicfyplayer-color",
33
25
  colorDetect: config.color?.detect || false
34
26
  };
@@ -1,7 +1,9 @@
1
- declare module 'colorthief' {
2
- type RGBColor = [number, number, number];
3
- export default class ColorThief {
4
- getColor: (img: HTMLImageElement | null, quality?: number) => RGBColor | null;
5
- getPalette: (img: HTMLImageElement | null, colorCount: number, quality?: number) => RGBColor[] | null;
6
- }
7
- }
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
+ }
@@ -1,13 +1,14 @@
1
- export interface MediaElementPlayer {
2
- new (node: HTMLAudioElement, options: MediaElementPlayerOptions): void;
3
- }
4
- export interface MediaElementPlayerOptions {
5
- iconSprite: string;
6
- audioHeight: number;
7
- features: ('playpause' | 'current' | 'progress' | 'duration' | 'tracks' | 'volume' | 'fullscreen')[];
8
- alwaysShowControls: boolean;
9
- timeAndDurationSeparator: string;
10
- iPadUseNativeControls: boolean;
11
- iPhoneUseNativeControls: boolean;
12
- AndroidUseNativeControls: boolean;
13
- }
1
+ export interface MediaElementPlayer {
2
+ new (node: HTMLAudioElement, options: MediaElementPlayerOptions): void
3
+ }
4
+
5
+ export interface MediaElementPlayerOptions {
6
+ iconSprite: string
7
+ audioHeight: number
8
+ features: ('playpause' | 'current' | 'progress' | 'duration' | 'tracks' | 'volume' | 'fullscreen')[]
9
+ alwaysShowControls: boolean
10
+ timeAndDurationSeparator: string
11
+ iPadUseNativeControls: boolean
12
+ iPhoneUseNativeControls: boolean
13
+ AndroidUseNativeControls: boolean
14
+ }
@@ -1,38 +1,67 @@
1
- export interface MusicfyPlayerDefinition {
2
- image: {
3
- src: string;
4
- alt: string;
5
- };
6
- audio: {
7
- provider: string;
8
- type: string;
9
- } & (LocalAudio | DropboxAudio);
10
- color?: {
11
- detect?: boolean;
12
- class?: string;
13
- };
14
- size?: {
15
- width?: string;
16
- height?: string;
17
- };
18
- }
19
- export interface LocalAudio {
20
- provider: 'local';
21
- src: string;
22
- }
23
- export interface DropboxAudio {
24
- provider: 'dropbox';
25
- id: string;
26
- rlkey?: string;
27
- }
28
- export type AudioConfig = LocalAudio | DropboxAudio;
29
- export interface MusicfyPlayerConfig {
30
- imageSrc: string;
31
- imageAlt: string;
32
- audioType: string;
33
- audioSrc: string;
34
- sizeWidth: string;
35
- sizeHeight: string;
36
- colorClass: string;
37
- colorDetect: boolean;
38
- }
1
+ export interface MusicfyPlayerDefinition {
2
+ /**
3
+ * Image configuration
4
+ */
5
+ image: {
6
+ src: string
7
+ /**
8
+ * Image alt text
9
+ * @default 'Musicfy Player'
10
+ */
11
+ alt?: string
12
+ }
13
+ audio: {
14
+ /**
15
+ * Audio provider
16
+ * @default 'local'
17
+ */
18
+ provider?: string
19
+ /**
20
+ * Audio type
21
+ * @default 'audio/mpeg'
22
+ */
23
+ type?: string
24
+ } & (LocalAudio | DropboxAudio)
25
+ /**
26
+ * Color configuration
27
+ */
28
+ color?: {
29
+ /**
30
+ * Set if the color should be detected from the image
31
+ * @default false
32
+ */
33
+ detect?: boolean
34
+ /**
35
+ * Custom class to apply to the player
36
+ * @default 'musicfyplayer-color'
37
+ */
38
+ class?: string
39
+ }
40
+ }
41
+
42
+ export interface LocalAudio {
43
+ provider?: 'local'
44
+ /**
45
+ * Path to the audio file
46
+ * @example '/path/to/audio.mp3'
47
+ * @example 'https://example.com/audio.mp3'
48
+ */
49
+ src: string
50
+ }
51
+
52
+ export interface DropboxAudio {
53
+ provider?: 'dropbox'
54
+ id: string
55
+ rlkey?: string
56
+ }
57
+
58
+ export type AudioConfig = LocalAudio | DropboxAudio
59
+
60
+ export interface MusicfyPlayerConfig {
61
+ imageSrc: string
62
+ imageAlt: string
63
+ audioType: string
64
+ audioSrc: string
65
+ colorClass: string
66
+ colorDetect: boolean
67
+ }
@@ -1,5 +1,5 @@
1
1
  import 'mediaelement/build/mediaelement-and-player.js';
2
- import type { MediaElementPlayer, MediaElementPlayerOptions } from '../types/mediaelement';
2
+ import type { MediaElementPlayer, MediaElementPlayerOptions } from '../types/mediaelement.js';
3
3
  declare global {
4
4
  interface Window {
5
5
  MediaElementPlayer: MediaElementPlayer | undefined;
@@ -0,0 +1,8 @@
1
+ import "mediaelement/build/mediaelement-and-player.js";
2
+ import { createError } from "h3";
3
+ export const mediaElementPlayer = (element, options) => {
4
+ const MediaElementPlayer = window.MediaElementPlayer;
5
+ if (!import.meta.client) throw createError({ status: 500, message: "MediaElementPlayer is not available on server side" });
6
+ if (!MediaElementPlayer) throw createError({ status: 500, message: "MediaElementPlayer is not available" });
7
+ return new MediaElementPlayer(element, options);
8
+ };
package/dist/types.d.mts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module.js'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['nuxtMusicfyPlayer']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['nuxtMusicfyPlayer']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['nuxtMusicfyPlayer']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['nuxtMusicfyPlayer']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module.js'
1
+ export { type ModuleOptions, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['nuxtMusicfyPlayer']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['nuxtMusicfyPlayer']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['nuxtMusicfyPlayer']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['nuxtMusicfyPlayer']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module'
1
+ export { type ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-musicfyplayer",
3
- "version": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and ColorThief.js",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -8,7 +8,10 @@
8
8
  "music-player",
9
9
  "music"
10
10
  ],
11
- "repository": "Yizack/nuxt-musicfyplayer",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/Yizack/nuxt-musicfyplayer.git"
14
+ },
12
15
  "homepage": "https://github.com/Yizack/nuxt-musicfyplayer",
13
16
  "author": {
14
17
  "name": "Yizack Rangel",
@@ -31,30 +34,32 @@
31
34
  ],
32
35
  "scripts": {
33
36
  "prepack": "nuxt-module-build build",
34
- "dev": "npm run dev:prepare && nuxi dev playground",
37
+ "dev": "nuxi dev playground",
35
38
  "dev:build": "nuxi build playground",
36
39
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
37
- "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
40
+ "release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
38
41
  "lint": "eslint .",
39
42
  "test": "echo \"Error: no test specified\"",
43
+ "test:types": "vue-tsc --noEmit",
40
44
  "test:watch": "vitest watch"
41
45
  },
42
46
  "dependencies": {
43
- "@nuxt/kit": "^3.10.1",
47
+ "@nuxt/kit": "^3.13.0",
44
48
  "colorthief": "^2.4.0",
45
- "mediaelement": "^7.0.3"
49
+ "mediaelement": "^7.0.5"
46
50
  },
47
51
  "devDependencies": {
48
- "@nuxt/devtools": "^1.0.8",
49
- "@nuxt/eslint-config": "^0.2.0",
50
- "@nuxt/module-builder": "^0.5.5",
51
- "@nuxt/schema": "^3.10.1",
52
- "@nuxt/test-utils": "^3.11.0",
53
- "@types/node": "^20.11.17",
52
+ "@nuxt/devtools": "^1.4.1",
53
+ "@nuxt/eslint-config": "^0.5.3",
54
+ "@nuxt/module-builder": "^0.8.3",
55
+ "@nuxt/schema": "^3.13.0",
56
+ "@nuxt/test-utils": "^3.14.1",
57
+ "@types/node": "^22.5.1",
54
58
  "changelogen": "^0.5.5",
55
- "eslint": "^8.56.0",
56
- "nuxt": "^3.10.1",
57
- "vitest": "^1.2.2"
59
+ "eslint": "^9.9.1",
60
+ "nuxt": "^3.13.0",
61
+ "vitest": "^2.0.5",
62
+ "vue-tsc": "^2.1.2"
58
63
  },
59
64
  "changelog": {
60
65
  "repo": {
@@ -62,5 +67,6 @@
62
67
  "provider": "github",
63
68
  "domain": "github.com"
64
69
  }
65
- }
66
- }
70
+ },
71
+ "packageManager": "pnpm@9.9.0"
72
+ }
File without changes
File without changes
File without changes
@@ -1,9 +0,0 @@
1
- import "mediaelement/build/mediaelement-and-player.js";
2
- export const mediaElementPlayer = (element, options) => {
3
- const MediaElementPlayer = window.MediaElementPlayer;
4
- if (!process.client)
5
- throw new Error("MediaElementPlayer is not available on server side");
6
- if (!MediaElementPlayer)
7
- throw new Error("MediaElementPlayer is not available");
8
- return new MediaElementPlayer(element, options);
9
- };