@madeinbruno/music-plug 0.4.0 → 0.5.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/dist/player.d.ts CHANGED
@@ -1,127 +1,76 @@
1
1
  import * as react from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import { S as SongSearchOptions, P as PlugPlayerOptions, a as Song, b as Service, c as ServiceId } from './index-CxM1NkLk.js';
4
+ export { u as usePlugPlayer, d as useSongSearch } from './index-CxM1NkLk.js';
2
5
 
3
6
  /**
4
- * 들을 수 있는 곳. 앱 Music plug(apps/music-plug/src/server/listen.ts)의 목록과 이름(id)이 같다.
5
- * 고른 곳은 쿠키 mp_service에 두고, madeinbruno.com 아래에서는 Music plug와 같이 쓴다.
6
- * - here: YouTube를 이 페이지에서 바로 (글 안에 유튜브 플레이어를 연다). 화면에는 그냥 'YouTube'로 보인다
7
- * - ytvideo: YouTube (앱·사이트)
8
- * - youtube: YouTube Music (Music plug의 이름을 따른다)
9
- */
10
- type ServiceId = 'here' | 'ytvideo' | 'melon' | 'genie' | 'bugs' | 'flo' | 'vibe' | 'spotify' | 'apple' | 'youtube';
11
- type Service = {
12
- id: ServiceId;
13
- name: string;
14
- color: string;
15
- initial: string;
16
- };
17
-
18
- /** 한 곡. 다른 음원 앱에서 찾을 때 "제목 가수"로 찾는다 */
19
- type Song = {
20
- title: string;
21
- artist: string;
22
- };
23
-
24
- /**
25
- * 곳마다 직접 정해 둔 곡 링크 (예: { melon: 'https://www.melon.com/song/detail.htm?songId=…', apple: '…' }).
26
- * 곡을 못 찾아 곡까지 가지 않는 곳이 있을 때, 쓰는 사람이 그곳의 곡 링크를 직접 정해 둔다. 정해 둔 곳은 찾지 않고 그 링크를 연다.
27
- */
28
- type SongLinks = Partial<Record<ServiceId, string>>;
29
-
30
- /**
31
- * 곡 고르기(SongField)로 고른 곡. 글에 그대로 저장한다.
32
- * - youtube: 고를 때 Music plug가 찾아 준 유튜브 영상 (있으면 글 안에서 무료로 바로 튼다)
33
- * - apple: Apple Music 곡 주소 (듣는 사람이 Apple Music을 고르면 찾지 않고 바로 연다)
34
- */
35
- type PickedSong = {
36
- title: string;
37
- artist: string;
38
- album?: string;
39
- artwork?: string;
40
- apple?: string;
41
- youtube?: {
42
- id: string;
43
- };
44
- };
45
-
46
- /**
47
- * 곡 고르기: 인스타그램처럼 곡을 검색해서 고른다 (쓰는 사람 화면).
7
+ * 곡 고르기 기본 화면: 인스타그램처럼 곡을 검색해서 고른다 (쓰는 사람 화면). 동작은 useSongSearch.
48
8
  *
49
- * ♪ [곡 이름이나 가수 ]
50
- * [앨범] 밤편지 ▶
51
- * 아이유 · Palette
9
+ * ┌ 🔍 곡 이름이나 가수 ─────────────┐ 고른 뒤: ┌ [앨범] 밤편지 🔍 × ┐
10
+ * └──────────────────────────────────┘ │ 아이유 · Palette │
11
+ * ┌ [앨범] 밤편지 (▶) ┐ └─────────────────────────────┘
12
+ * │ 아이유 · Palette │
13
+ * └ … ┘
52
14
  *
53
- * - 치면 Music plug(/api/search, Apple 목록)에서 찾아 앨범 그림과 함께 보여 준다. ▶로 30초 미리 듣기.
54
- * - 고르면 Music plug(/api/match)가 그 곡의 유튜브 영상을 찾아 같이 담는다 (글 안에서 무료로 바로 틀 수 있게).
55
- * - 고른 곡은 앨범 그림·제목·가수로 보이고, '바꾸기'로 다시 찾고 '빼기'로 비운다.
56
15
  * - form 안에 두면 숨은 입력(name)에 고른 곡이 JSON으로 들어간다 (비우면 빈 값). 저장할 때 readPickedSong으로 읽는다.
57
- * 스타일은 styles.css의 mp-pick. 둘러싼 글의 색을 따른다.
16
+ * 스타일은 styles.css (흰 라운드 카드 + 그림자, PlugPlayer와 같은 모양).
58
17
  */
59
- type SongFieldProps = {
18
+ type SongFieldProps = SongSearchOptions & {
60
19
  /** 숨은 입력의 이름 */
61
20
  name: string;
62
- defaultValue?: PickedSong | null;
63
- /** 고르거나 뺄 때마다 */
64
- onChange?: (song: PickedSong | null) => void;
65
21
  placeholder?: string;
66
- /** Music plug 주소 (기본 https://musicplug.madeinbruno.com) */
67
- base?: string;
22
+ /** 'light'(기본) · 'dark' · 'auto' */
23
+ theme?: 'light' | 'dark' | 'auto';
68
24
  className?: string;
25
+ style?: CSSProperties;
69
26
  };
70
- declare function SongField({ name, defaultValue, onChange, placeholder, base, className }: SongFieldProps): react.JSX.Element;
27
+ declare function SongField({ name, placeholder, theme, className, style, ...options }: SongFieldProps): react.JSX.Element;
71
28
 
72
29
  /**
73
- * 글 속 노래 한 곡의 '음악 듣기'.
74
- *
75
- * ♪ 밤편지 · 아이유
30
+ * @madeinbruno/music-plug/player: 기본 화면. 어느 사이트에 붙여도 같은 모양(흰 라운드 카드 + 그림자)으로 보인다.
31
+ * 스타일은 '@madeinbruno/music-plug/styles.css' (클래스는 모두 mp-). 동작만 쓰고 직접 그리려면 '@madeinbruno/music-plug/headless'.
76
32
  *
77
- * - 처음 누르면 Music plug 듣기 플러그(PlugSheet)가 떠서 어디서 들을지 고른다:
78
- * YouTube(기본) · 멜론 · 지니 · 벅스 · FLO · VIBE · Spotify · Apple Music · YouTube Music
79
- * YouTube는 유튜브 영상이 있으면 이 페이지에서 바로(글 안의 플레이어), 없으면 YouTube로 연다.
80
- * - 고르면 그곳에서 이 곡을 연다 (Music plug가 곡을 찾아 보낸다. 폰에서는 앱으로). YouTube면 글 안에서 유튜브 플레이어가 열린다.
81
- * - 고른 곳은 기억해서 다음부터는 누르면 바로 그곳에서 연다. 곡 옆에 옅게 '멜론 · 바꾸기'가 보이고, 바꾸기로 다시 고른다.
82
- * 기억은 쿠키 mp_service(madeinbruno.com 아래에서는 Music plug와 같이)와 이 브라우저(localStorage)에 둔다.
83
- * - 곡을 모르면(song이 null) 다른 곳에서 찾을 수 없어서 이 페이지에서 YouTube로만 튼다 (유튜브가 아닌 곡 링크면 그 링크를 연다).
84
- * - 테마 음악을 정한 곡 링크(source)가 있으면, 듣는 사람이 같은 곳을 골랐을 때 찾지 않고 그 링크를 바로 연다.
85
- * 곳마다 직접 정해 둔 곡 링크(links)가 있으면 그곳도 찾지 않고 그 링크를 연다 (곡을 못 찾는 곳을 위해).
86
- * - 유튜브로 듣는 중에 읽어 내려가 플레이어가 화면 밖으로 나가면 왼쪽 아래에 작은 음악 바(▶/❚❚ + 곡 제목)가 뜬다
87
- * (avoid로 준 요소가 보일 때는 숨긴다). 제목이 길면 왼쪽으로 흘러가며 뒷부분을 보여 준다.
33
+ * ┌──────────────────────────────────────┐
34
+ * │ [앨범] 밤편지 (▶) │
35
+ * │ 아이유 │
36
+ * │ ──────────────────────────────────── │
37
+ * │ [멜론] 멜론에서 들어요 바꾸기 │ ← 듣는 곳을 고른 뒤에만
38
+ * └──────────────────────────────────────┘
88
39
  *
89
- * 스타일은 '@madeinbruno/music-plug/styles.css' (클래스는 모두 mp-). 곡 줄은 둘러싼 글의 색을 따르고, 듣기 플러그는 Music plug 색이다.
40
+ * - 처음 누르면 듣기 플러그(PlugSheet)가 떠서 어디서 들을지 고른다. 고른 곳은 기억해서 다음부터 바로 그곳에서 연다.
41
+ * - YouTube를 고르면 카드 안에 유튜브 플레이어가 열리고 ▶가 ❚❚(멈추기)가 된다. 읽어 내려가 플레이어가 화면 밖으로 나가면
42
+ * 왼쪽 아래에 작은 음악 바(▶/❚❚ + 흐르는 곡 제목)가 뜬다 (avoid로 준 요소가 보일 때는 숨긴다).
90
43
  */
91
- type PlugPlayerProps = {
92
- /** 곡 제목·가수. 모르면 null */
93
- song: Song | null;
94
- /** 곡을 모를 때 보일 이름 (기본: '음악 듣기') */
95
- fallbackLabel?: string;
96
- /** 유튜브 영상. 있으면 YouTube를 고를 때 글 안에서 바로 틀고, 없으면 YouTube로 연다 */
97
- youtube?: {
98
- id: string;
99
- start?: number;
100
- };
101
- /** 이 곡을 정한 곡 링크 (songFromUrl이 준 service·url). 듣는 사람이 같은 곳을 고르면 그 링크를 바로 연다 */
102
- source?: {
103
- service: ServiceId;
104
- url: string;
105
- };
106
- /** 곳마다 직접 정해 둔 곡 링크. 듣는 사람이 그곳을 고르면 찾지 않고 이 링크를 연다 (source보다 먼저) */
107
- links?: SongLinks | null;
108
- /** 유튜브 플레이어가 화면 밖일 때 뜨는 음악 바를, 이 요소가 보이면 숨긴다 (예: '.mib-footer') */
109
- avoid?: string;
110
- /** Music plug 주소 (기본 https://musicplug.madeinbruno.com) */
111
- base?: string;
44
+ type PlugPlayerProps = PlugPlayerOptions & {
45
+ /** 앨범 그림 주소 (없으면 Music plug 심볼) */
46
+ artwork?: string;
47
+ /** 'light'(기본) · 'dark' · 'auto'(기기 설정을 따름) */
48
+ theme?: 'light' | 'dark' | 'auto';
112
49
  className?: string;
50
+ style?: CSSProperties;
113
51
  };
114
- declare function PlugPlayer({ song, fallbackLabel, youtube, source, links, avoid, base, className }: PlugPlayerProps): react.JSX.Element;
52
+ declare function PlugPlayer({ artwork, theme, className, style, ...options }: PlugPlayerProps): react.JSX.Element;
115
53
  /**
116
- * Music plug 듣기 플러그: 어디서 들을지 고르는 창. Music plug의 /listen 화면과 같은 모양.
117
- * 바깥을 누르거나 Esc로 닫는다.
54
+ * 듣기 플러그: 어디서 들을지 고르는 창. 폰에서는 아래에서 올라오고, 넓은 화면에서는 가운데 카드.
55
+ * 바깥을 누르거나 Esc로 닫는다. 테마는 둘러싼 mp-ui의 것을 따른다 (따로 쓰면 theme으로).
118
56
  */
119
- declare function PlugSheet({ song, services, current, onChoose, onClose, }: {
57
+ declare function PlugSheet({ song, services, current, onChoose, onClose, theme, }: {
120
58
  song: Song | null;
121
59
  services: Service[];
122
60
  current: ServiceId | null;
123
61
  onChoose: (s: Service) => void;
124
62
  onClose: () => void;
63
+ theme?: 'light' | 'dark' | 'auto';
64
+ }): react.JSX.Element;
65
+ /** 음원 서비스 표시: 공식 로고가 있으면 그것을, 없으면 그 색의 머리글자 동그라미 */
66
+ declare function ServiceMark({ service, size, className }: {
67
+ service: Service;
68
+ size?: number;
69
+ className?: string;
70
+ }): react.JSX.Element;
71
+ /** Music plug 심볼: 플러그 몸통, 꽂는 쇠 둘, 음파 막대 다섯 (어두운 타일 위에 그린다) */
72
+ declare function Symbol({ size }: {
73
+ size?: number;
125
74
  }): react.JSX.Element;
126
75
 
127
- export { PlugPlayer, type PlugPlayerProps, PlugSheet, SongField, type SongFieldProps };
76
+ export { PlugPlayer, type PlugPlayerProps, PlugSheet, ServiceMark, SongField, type SongFieldProps, Symbol };