@madeinbruno/music-plug 0.2.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/README.md +90 -5
- package/dist/chunk-3HM3NTBS.js +296 -0
- package/dist/headless.d.ts +2 -0
- package/dist/headless.js +13 -0
- package/dist/index-CxM1NkLk.d.ts +160 -0
- package/dist/index.d.ts +49 -1
- package/dist/index.js +70 -0
- package/dist/player.d.ts +54 -53
- package/dist/player.js +227 -177
- package/package.json +5 -1
- package/styles.css +467 -78
package/dist/player.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
usePlugPlayer,
|
|
4
|
+
useSongSearch
|
|
5
|
+
} from "./chunk-3HM3NTBS.js";
|
|
2
6
|
|
|
3
7
|
// src/player.tsx
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { useEffect, useRef as useRef2, useState } from "react";
|
|
5
9
|
|
|
6
10
|
// src/logos.ts
|
|
7
11
|
var YT = "M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z";
|
|
@@ -13,145 +17,140 @@ var LOGO_PATHS = {
|
|
|
13
17
|
youtube: "M12 0C5.376 0 0 5.376 0 12s5.376 12 12 12 12-5.376 12-12S18.624 0 12 0zm0 19.104c-3.924 0-7.104-3.18-7.104-7.104S8.076 4.896 12 4.896s7.104 3.18 7.104 7.104-3.18 7.104-7.104 7.104zm0-13.332c-3.432 0-6.228 2.796-6.228 6.228S8.568 18.228 12 18.228s6.228-2.796 6.228-6.228S15.432 5.772 12 5.772zM9.684 15.54V8.46L15.816 12l-6.132 3.54z"
|
|
14
18
|
};
|
|
15
19
|
|
|
16
|
-
// src/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
// src/picker.tsx
|
|
21
|
+
import { useRef } from "react";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
function SongField({ name, placeholder = "\uACE1 \uC774\uB984\uC774\uB098 \uAC00\uC218", theme = "light", className, style, ...options }) {
|
|
24
|
+
const s = useSongSearch(options);
|
|
25
|
+
const input = useRef(null);
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: ["mp-ui mp-pick", className].filter(Boolean).join(" "), "data-mp-theme": theme, style, children: [
|
|
27
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name, value: s.value }),
|
|
28
|
+
s.song && !s.searching && /* @__PURE__ */ jsxs("div", { className: "mp-card mp-pick__chosen", children: [
|
|
29
|
+
s.song.artwork ? /* @__PURE__ */ jsx("img", { src: s.song.artwork, alt: "", className: "mp-art" }) : /* @__PURE__ */ jsx("span", { className: "mp-art mp-art--empty", "aria-hidden": "true" }),
|
|
30
|
+
/* @__PURE__ */ jsxs("span", { className: "mp-pick__text", children: [
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "mp-pick__title", children: s.song.title }),
|
|
32
|
+
/* @__PURE__ */ jsx("span", { className: "mp-pick__sub", children: [s.song.artist, s.song.album].filter(Boolean).join(" \xB7 ") })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
type: "button",
|
|
38
|
+
className: "mp-icon-button",
|
|
39
|
+
"aria-label": "\uB2E4\uB978 \uACE1 \uCC3E\uAE30",
|
|
40
|
+
title: "\uB2E4\uB978 \uACE1 \uCC3E\uAE30",
|
|
41
|
+
onClick: () => {
|
|
42
|
+
s.startSearch();
|
|
43
|
+
window.setTimeout(() => input.current?.focus(), 0);
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "mp-icon-button", "aria-label": "\uACE1 \uBE7C\uAE30", title: "\uACE1 \uBE7C\uAE30", onClick: s.clear, children: /* @__PURE__ */ jsx(CloseIcon, {}) })
|
|
49
|
+
] }),
|
|
50
|
+
s.searching && /* @__PURE__ */ jsxs("div", { className: "mp-pick__search", children: [
|
|
51
|
+
/* @__PURE__ */ jsxs("label", { className: "mp-card mp-pick__bar", children: [
|
|
52
|
+
/* @__PURE__ */ jsx(SearchIcon, {}),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
"input",
|
|
55
|
+
{
|
|
56
|
+
ref: input,
|
|
57
|
+
type: "search",
|
|
58
|
+
value: s.query,
|
|
59
|
+
onChange: (e) => s.setQuery(e.target.value),
|
|
60
|
+
onKeyDown: (e) => e.key === "Enter" && e.preventDefault(),
|
|
61
|
+
placeholder,
|
|
62
|
+
"aria-label": "\uACE1 \uCC3E\uAE30",
|
|
63
|
+
autoComplete: "off"
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
s.status === "loading" || s.status === "matching" ? /* @__PURE__ */ jsx("span", { className: "mp-spinner", "aria-label": s.status === "matching" ? "\uACE0\uB974\uB294 \uC911" : "\uCC3E\uB294 \uC911" }) : s.song && /* @__PURE__ */ jsx("button", { type: "button", className: "mp-icon-button", "aria-label": "\uADF8\uB9CC \uCC3E\uAE30", title: "\uADF8\uB9CC \uCC3E\uAE30", onClick: s.stopSearch, children: /* @__PURE__ */ jsx(CloseIcon, {}) })
|
|
67
|
+
] }),
|
|
68
|
+
s.status === "empty" && /* @__PURE__ */ jsx("p", { className: "mp-pick__note", children: "\uCC3E\uB294 \uACE1\uC774 \uC5C6\uC5B4\uC694" }),
|
|
69
|
+
s.status === "error" && /* @__PURE__ */ jsx("p", { className: "mp-pick__note", children: "\uC9C0\uAE08\uC740 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694. \uC7A0\uC2DC \uB4A4\uC5D0 \uB2E4\uC2DC \uD574 \uBCF4\uC138\uC694" }),
|
|
70
|
+
s.results.length > 0 && s.status !== "matching" && /* @__PURE__ */ jsx("ul", { className: "mp-card mp-pick__list", "aria-label": "\uCC3E\uC740 \uACE1", children: s.results.map((r, i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
71
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "mp-pick__row", onClick: () => void s.pick(r), children: [
|
|
72
|
+
r.artwork ? /* @__PURE__ */ jsx("img", { src: r.artwork, alt: "", className: "mp-art", loading: "lazy" }) : /* @__PURE__ */ jsx("span", { className: "mp-art mp-art--empty", "aria-hidden": "true" }),
|
|
73
|
+
/* @__PURE__ */ jsxs("span", { className: "mp-pick__text", children: [
|
|
74
|
+
/* @__PURE__ */ jsx("span", { className: "mp-pick__title", children: r.title }),
|
|
75
|
+
/* @__PURE__ */ jsx("span", { className: "mp-pick__sub", children: [r.artist, r.album].filter(Boolean).join(" \xB7 ") })
|
|
76
|
+
] })
|
|
77
|
+
] }),
|
|
78
|
+
r.preview && /* @__PURE__ */ jsx(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
className: "mp-play mp-play--small mp-play--soft",
|
|
83
|
+
"aria-label": s.previewing === r.preview ? "\uBBF8\uB9AC \uB4E3\uAE30 \uBA48\uCD94\uAE30" : "\uBBF8\uB9AC \uB4E3\uAE30",
|
|
84
|
+
"aria-pressed": s.previewing === r.preview,
|
|
85
|
+
onClick: () => s.togglePreview(r.preview),
|
|
86
|
+
children: /* @__PURE__ */ jsx("svg", { width: "11", height: "11", viewBox: "0 0 12 12", "aria-hidden": "true", children: s.previewing === r.preview ? /* @__PURE__ */ jsx("rect", { x: "2", y: "2", width: "8", height: "8", rx: "1.2", fill: "currentColor" }) : /* @__PURE__ */ jsx("path", { d: "M3.4 1.8v8.4a.7.7 0 0 0 1.06.6l6.8-4.2a.7.7 0 0 0 0-1.2l-6.8-4.2A.7.7 0 0 0 3.4 1.8z", fill: "currentColor" }) })
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }, `${r.title}|${r.artist}|${i}`)) })
|
|
90
|
+
] })
|
|
91
|
+
] });
|
|
31
92
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (youtube?.id) p.set("v", youtube.id);
|
|
38
|
-
if (youtube?.start) p.set("start", String(youtube.start));
|
|
39
|
-
return p.toString();
|
|
93
|
+
function SearchIcon() {
|
|
94
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", "aria-hidden": "true", className: "mp-pick__icon", children: [
|
|
95
|
+
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.6" }),
|
|
96
|
+
/* @__PURE__ */ jsx("path", { d: "M10.4 10.4L14 14" })
|
|
97
|
+
] });
|
|
40
98
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
99
|
+
function CloseIcon() {
|
|
100
|
+
return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 14 14", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 2l10 10M12 2L2 12", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) });
|
|
43
101
|
}
|
|
44
102
|
|
|
45
103
|
// src/player.tsx
|
|
46
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
localStorage.setItem(KEY, id);
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
const host = location.hostname;
|
|
64
|
-
const shared = host === SHARED_DOMAIN || host.endsWith(`.${SHARED_DOMAIN}`) ? `; domain=.${SHARED_DOMAIN}` : "";
|
|
65
|
-
document.cookie = `mp_service=${id}; path=/; max-age=31536000; samesite=lax${shared}`;
|
|
66
|
-
}
|
|
67
|
-
function PlugPlayer({ song, fallbackLabel = "\uC74C\uC545 \uB4E3\uAE30", youtube, source, avoid, base = MUSIC_PLUG_URL, className }) {
|
|
68
|
-
const [choice, setChoice] = useState(null);
|
|
69
|
-
const [sheet, setSheet] = useState(false);
|
|
70
|
-
const [open, setOpen] = useState(false);
|
|
71
|
-
const [playing, setPlaying] = useState(false);
|
|
72
|
-
const [chip, setChip] = useState(false);
|
|
73
|
-
const frame = useRef(null);
|
|
74
|
-
useEffect(() => setChoice(readChoice()), []);
|
|
75
|
-
const known = Boolean(song?.title);
|
|
76
|
-
const services = SERVICES.filter((s) => s.id === "here" ? Boolean(youtube) : s.id === "ytvideo" ? !youtube : known);
|
|
77
|
-
const isYoutube = (id) => id === "here" || id === "ytvideo";
|
|
78
|
-
const remembered = services.find((s) => s.id === choice || isYoutube(choice) && isYoutube(s.id)) ?? null;
|
|
79
|
-
function play(s) {
|
|
80
|
-
if (s.id === "here") {
|
|
81
|
-
setOpen(true);
|
|
82
|
-
setPlaying(true);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const direct = source && source.service === s.id && !youtube ? source.url : null;
|
|
86
|
-
window.open(direct ?? listenGoUrl(s.id, song, youtube, { base }), "_blank", "noopener");
|
|
87
|
-
}
|
|
88
|
-
function choose(s) {
|
|
89
|
-
saveChoice(s.id);
|
|
90
|
-
setChoice(s.id);
|
|
91
|
-
setSheet(false);
|
|
92
|
-
play(s);
|
|
93
|
-
}
|
|
94
|
-
function tap() {
|
|
95
|
-
if (!known && youtube) return play(SERVICES[0]);
|
|
96
|
-
if (!known && source) return void window.open(source.url, "_blank", "noopener");
|
|
97
|
-
if (remembered) play(remembered);
|
|
98
|
-
else setSheet(true);
|
|
99
|
-
}
|
|
100
|
-
const command = (func) => frame.current?.contentWindow?.postMessage(JSON.stringify({ event: "command", func, args: [] }), "https://www.youtube-nocookie.com");
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (!open) return;
|
|
103
|
-
const seen = /* @__PURE__ */ new Map();
|
|
104
|
-
const io = new IntersectionObserver((entries) => {
|
|
105
|
-
for (const e of entries) seen.set(e.target, e.isIntersecting);
|
|
106
|
-
setChip(![...seen.values()].some(Boolean));
|
|
107
|
-
});
|
|
108
|
-
const targets = [frame.current, avoid ? document.querySelector(avoid) : null].filter((el) => el !== null);
|
|
109
|
-
for (const el of targets) {
|
|
110
|
-
seen.set(el, false);
|
|
111
|
-
io.observe(el);
|
|
112
|
-
}
|
|
113
|
-
return () => io.disconnect();
|
|
114
|
-
}, [open, avoid]);
|
|
115
|
-
const label = song && [song.title, song.artist].filter(Boolean).join(" \xB7 ") || fallbackLabel;
|
|
116
|
-
return /* @__PURE__ */ jsxs("div", { className: ["mp-plug", className].filter(Boolean).join(" "), children: [
|
|
117
|
-
/* @__PURE__ */ jsxs("div", { className: "mp-plug__row", children: [
|
|
118
|
-
/* @__PURE__ */ jsxs("button", { type: "button", className: "mp-plug__song", onClick: tap, children: [
|
|
119
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u266A" }),
|
|
120
|
-
" ",
|
|
121
|
-
label
|
|
104
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
105
|
+
function PlugPlayer({ artwork, theme = "light", className, style, ...options }) {
|
|
106
|
+
const p = usePlugPlayer(options);
|
|
107
|
+
const { video } = p;
|
|
108
|
+
const playing = video.open && video.playing;
|
|
109
|
+
return /* @__PURE__ */ jsxs2("div", { className: cx("mp-ui mp-card mp-player", className), "data-mp-theme": theme, style, children: [
|
|
110
|
+
/* @__PURE__ */ jsxs2("div", { className: "mp-player__row", children: [
|
|
111
|
+
/* @__PURE__ */ jsxs2("button", { type: "button", className: "mp-player__main", onClick: p.listen, "aria-label": `${p.title}${p.artist ? ` \xB7 ${p.artist}` : ""} \uB4E3\uAE30`, children: [
|
|
112
|
+
/* @__PURE__ */ jsx2(Artwork, { src: artwork }),
|
|
113
|
+
/* @__PURE__ */ jsxs2("span", { className: "mp-player__text", children: [
|
|
114
|
+
/* @__PURE__ */ jsx2("span", { className: "mp-player__title", children: p.title }),
|
|
115
|
+
p.artist && /* @__PURE__ */ jsx2("span", { className: "mp-player__artist", children: p.artist })
|
|
116
|
+
] })
|
|
122
117
|
] }),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
/* @__PURE__ */ jsx2(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
type: "button",
|
|
122
|
+
className: "mp-play",
|
|
123
|
+
onClick: video.open ? video.toggle : p.listen,
|
|
124
|
+
"aria-label": playing ? "\uBA48\uCD94\uAE30" : "\uB4E3\uAE30",
|
|
125
|
+
"aria-pressed": video.open ? playing : void 0,
|
|
126
|
+
children: /* @__PURE__ */ jsx2(PlayIcon, { playing })
|
|
127
|
+
}
|
|
128
|
+
)
|
|
128
129
|
] }),
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
p.current && (p.known || options.links) && /* @__PURE__ */ jsxs2("div", { className: "mp-player__foot", children: [
|
|
131
|
+
/* @__PURE__ */ jsxs2("span", { className: "mp-player__via", children: [
|
|
132
|
+
/* @__PURE__ */ jsx2(ServiceMark, { service: p.current, size: 16 }),
|
|
133
|
+
p.current.name,
|
|
134
|
+
"\uC5D0\uC11C \uB4E4\uC5B4\uC694"
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "mp-link", onClick: p.picker.show, children: "\uBC14\uAFB8\uAE30" })
|
|
137
|
+
] }),
|
|
138
|
+
video.frameProps && /* @__PURE__ */ jsx2("div", { className: "mp-player__video", children: /* @__PURE__ */ jsx2("iframe", { ...video.frameProps }) }),
|
|
139
|
+
video.offscreen && /* @__PURE__ */ jsxs2("button", { type: "button", className: "mp-card mp-mini", onClick: video.toggle, "aria-label": `${p.title} ${video.playing ? "\uBA48\uCD94\uAE30" : "\uD2C0\uAE30"}`, children: [
|
|
140
|
+
/* @__PURE__ */ jsx2("span", { className: "mp-play mp-play--small", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(PlayIcon, { playing: video.playing }) }),
|
|
141
|
+
/* @__PURE__ */ jsx2(Marquee, { text: p.title })
|
|
142
|
+
] }),
|
|
143
|
+
p.picker.open && /* @__PURE__ */ jsx2(
|
|
144
|
+
PlugSheet,
|
|
141
145
|
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
children: [
|
|
149
|
-
"\u266A ",
|
|
150
|
-
playing ? "\uBA48\uCD94\uAE30" : "\uB2E4\uC2DC \uB4E3\uAE30"
|
|
151
|
-
]
|
|
146
|
+
song: { title: p.title, artist: p.artist },
|
|
147
|
+
services: p.services,
|
|
148
|
+
current: p.current?.id ?? null,
|
|
149
|
+
onChoose: p.listenOn,
|
|
150
|
+
onClose: p.picker.close,
|
|
151
|
+
theme
|
|
152
152
|
}
|
|
153
|
-
)
|
|
154
|
-
sheet && /* @__PURE__ */ jsx(PlugSheet, { song, services, current: remembered?.id ?? null, onChoose: choose, onClose: () => setSheet(false) })
|
|
153
|
+
)
|
|
155
154
|
] });
|
|
156
155
|
}
|
|
157
156
|
function PlugSheet({
|
|
@@ -159,7 +158,8 @@ function PlugSheet({
|
|
|
159
158
|
services,
|
|
160
159
|
current,
|
|
161
160
|
onChoose,
|
|
162
|
-
onClose
|
|
161
|
+
onClose,
|
|
162
|
+
theme
|
|
163
163
|
}) {
|
|
164
164
|
useEffect(() => {
|
|
165
165
|
const onKey = (e) => e.key === "Escape" && onClose();
|
|
@@ -171,57 +171,107 @@ function PlugSheet({
|
|
|
171
171
|
document.body.style.overflow = prev;
|
|
172
172
|
};
|
|
173
173
|
}, [onClose]);
|
|
174
|
-
return /* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
174
|
+
return /* @__PURE__ */ jsx2(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
className: "mp-ui mp-sheet",
|
|
178
|
+
"data-mp-theme": theme,
|
|
179
|
+
role: "dialog",
|
|
180
|
+
"aria-modal": "true",
|
|
181
|
+
"aria-label": "\uC5B4\uB514\uC11C \uB4E4\uC744\uAE4C\uC694",
|
|
182
|
+
onClick: (e) => e.target === e.currentTarget && onClose(),
|
|
183
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "mp-card mp-sheet__panel", children: [
|
|
184
|
+
/* @__PURE__ */ jsxs2("div", { className: "mp-sheet__head", children: [
|
|
185
|
+
/* @__PURE__ */ jsxs2("span", { className: "mp-sheet__brand", children: [
|
|
186
|
+
/* @__PURE__ */ jsx2(Symbol, { size: 22 }),
|
|
187
|
+
" Music plug"
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "mp-icon-button", onClick: onClose, "aria-label": "\uB2EB\uAE30", children: /* @__PURE__ */ jsx2("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("path", { d: "M2 2l10 10M12 2L2 12", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) })
|
|
190
|
+
] }),
|
|
191
|
+
song?.title && /* @__PURE__ */ jsxs2("div", { className: "mp-sheet__song", children: [
|
|
192
|
+
/* @__PURE__ */ jsx2("p", { className: "mp-sheet__song-title", children: song.title }),
|
|
193
|
+
song.artist && /* @__PURE__ */ jsx2("p", { className: "mp-sheet__sub", children: song.artist })
|
|
194
|
+
] }),
|
|
195
|
+
/* @__PURE__ */ jsx2("p", { className: "mp-sheet__ask", children: "\uC5B4\uB514\uC11C \uB4E4\uC744\uAE4C\uC694?" }),
|
|
196
|
+
/* @__PURE__ */ jsx2("ul", { className: "mp-sheet__grid", children: services.map((s) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2(
|
|
197
|
+
"button",
|
|
198
|
+
{
|
|
199
|
+
type: "button",
|
|
200
|
+
"aria-current": (current ? s.id === current : s.id === "here" || s.id === "ytvideo") ? "true" : void 0,
|
|
201
|
+
onClick: () => onChoose(s),
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ jsx2(ServiceMark, { service: s, size: 24 }),
|
|
204
|
+
/* @__PURE__ */ jsx2("span", { children: s.name }),
|
|
205
|
+
(s.id === "here" || s.id === "ytvideo") && /* @__PURE__ */ jsx2("span", { className: "mp-sheet__tag", children: "\uAE30\uBCF8" })
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
) }, s.id)) }),
|
|
209
|
+
/* @__PURE__ */ jsx2("p", { className: "mp-sheet__note", children: "\uACE0\uB978 \uACF3\uC740 \uAE30\uC5B5\uD574 \uB450\uACE0 \uB2E4\uC74C\uBD80\uD130 \uBC14\uB85C \uADF8\uACF3\uC5D0\uC11C \uC5F4\uC5B4\uC694. \uCE74\uB4DC\uC758 \u2018\uBC14\uAFB8\uAE30\u2019\uB85C \uB2E4\uC2DC \uACE0\uB97C \uC218 \uC788\uC5B4\uC694." })
|
|
210
|
+
] })
|
|
211
|
+
}
|
|
212
|
+
);
|
|
202
213
|
}
|
|
203
|
-
function
|
|
214
|
+
function ServiceMark({ service, size = 24, className }) {
|
|
204
215
|
const logo = LOGO_PATHS[service.id];
|
|
205
|
-
return /* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ jsx2("svg", { width: size, height: size, viewBox: "0 0 24 24", "aria-hidden": "true", className: cx("mp-mark", className), children: logo ? /* @__PURE__ */ jsx2("path", { d: logo, fill: service.color }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
217
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "12", fill: service.color }),
|
|
218
|
+
/* @__PURE__ */ jsx2("text", { x: "12", y: "16.8", textAnchor: "middle", fontSize: "13.5", fontWeight: "800", fill: "#0b0b0d", children: service.initial })
|
|
208
219
|
] }) });
|
|
209
220
|
}
|
|
210
|
-
function
|
|
211
|
-
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
function Artwork({ src }) {
|
|
222
|
+
if (src) {
|
|
223
|
+
return /* @__PURE__ */ jsx2("img", { src, alt: "", className: "mp-art", loading: "lazy" });
|
|
224
|
+
}
|
|
225
|
+
return /* @__PURE__ */ jsx2("span", { className: "mp-art mp-art--plug", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(Symbol, { size: 30 }) });
|
|
226
|
+
}
|
|
227
|
+
function PlayIcon({ playing }) {
|
|
228
|
+
return /* @__PURE__ */ jsx2("svg", { width: "14", height: "14", viewBox: "0 0 12 12", "aria-hidden": "true", children: playing ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
229
|
+
/* @__PURE__ */ jsx2("rect", { x: "2", y: "1.5", width: "2.6", height: "9", rx: "0.8", fill: "currentColor" }),
|
|
230
|
+
/* @__PURE__ */ jsx2("rect", { x: "7.4", y: "1.5", width: "2.6", height: "9", rx: "0.8", fill: "currentColor" })
|
|
231
|
+
] }) : /* @__PURE__ */ jsx2("path", { d: "M3.4 1.8v8.4a.7.7 0 0 0 1.06.6l6.8-4.2a.7.7 0 0 0 0-1.2l-6.8-4.2A.7.7 0 0 0 3.4 1.8z", fill: "currentColor" }) });
|
|
232
|
+
}
|
|
233
|
+
function Marquee({ text }) {
|
|
234
|
+
const box = useRef2(null);
|
|
235
|
+
const inner = useRef2(null);
|
|
236
|
+
const [shift, setShift] = useState(0);
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
const measure = () => {
|
|
239
|
+
if (box.current && inner.current) setShift(Math.max(0, inner.current.scrollWidth - box.current.clientWidth));
|
|
240
|
+
};
|
|
241
|
+
measure();
|
|
242
|
+
const ro = new ResizeObserver(measure);
|
|
243
|
+
if (box.current) ro.observe(box.current);
|
|
244
|
+
return () => ro.disconnect();
|
|
245
|
+
}, [text]);
|
|
246
|
+
const style = shift ? { "--mp-shift": `-${shift}px`, "--mp-dur": `${(shift / 30 + 3).toFixed(1)}s` } : void 0;
|
|
247
|
+
return /* @__PURE__ */ jsx2("span", { ref: box, className: shift ? "mp-marquee mp-marquee--move" : "mp-marquee", children: /* @__PURE__ */ jsx2("span", { ref: inner, className: "mp-marquee__text", style, children: text }) });
|
|
248
|
+
}
|
|
249
|
+
function Symbol({ size = 20 }) {
|
|
250
|
+
return /* @__PURE__ */ jsxs2("svg", { width: size, height: size, viewBox: "0 0 64 64", "aria-hidden": "true", className: "mp-symbol", children: [
|
|
251
|
+
/* @__PURE__ */ jsx2("rect", { width: "64", height: "64", rx: "14", fill: "#141417" }),
|
|
252
|
+
/* @__PURE__ */ jsxs2("g", { transform: "translate(0 3.5)", children: [
|
|
253
|
+
/* @__PURE__ */ jsx2("rect", { x: "21.5", y: "8.5", width: "5.5", height: "13", rx: "2.75", fill: "#f2f2ee" }),
|
|
254
|
+
/* @__PURE__ */ jsx2("rect", { x: "37", y: "8.5", width: "5.5", height: "13", rx: "2.75", fill: "#f2f2ee" }),
|
|
255
|
+
/* @__PURE__ */ jsx2("rect", { x: "12", y: "19", width: "40", height: "29", rx: "5", fill: "#f2f2ee" }),
|
|
256
|
+
/* @__PURE__ */ jsxs2("g", { fill: "#141417", children: [
|
|
257
|
+
/* @__PURE__ */ jsx2("rect", { x: "17.9", y: "30.25", width: "3.4", height: "6.5", rx: "1.7" }),
|
|
258
|
+
/* @__PURE__ */ jsx2("rect", { x: "24.1", y: "27.25", width: "3.4", height: "12.5", rx: "1.7" }),
|
|
259
|
+
/* @__PURE__ */ jsx2("rect", { x: "30.3", y: "24.5", width: "3.4", height: "18", rx: "1.7" }),
|
|
260
|
+
/* @__PURE__ */ jsx2("rect", { x: "36.5", y: "27.25", width: "3.4", height: "12.5", rx: "1.7" }),
|
|
261
|
+
/* @__PURE__ */ jsx2("rect", { x: "42.7", y: "30.25", width: "3.4", height: "6.5", rx: "1.7" })
|
|
262
|
+
] })
|
|
221
263
|
] })
|
|
222
|
-
] })
|
|
264
|
+
] });
|
|
265
|
+
}
|
|
266
|
+
function cx(...names) {
|
|
267
|
+
return names.filter(Boolean).join(" ");
|
|
223
268
|
}
|
|
224
269
|
export {
|
|
225
270
|
PlugPlayer,
|
|
226
|
-
PlugSheet
|
|
271
|
+
PlugSheet,
|
|
272
|
+
ServiceMark,
|
|
273
|
+
SongField,
|
|
274
|
+
Symbol,
|
|
275
|
+
usePlugPlayer,
|
|
276
|
+
useSongSearch
|
|
227
277
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madeinbruno/music-plug",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "글 속 노래를 듣는 사람이 쓰는 음원 앱(멜론·지니·벅스·FLO·VIBE·Spotify·Apple Music·YouTube Music)에서, 없으면 YouTube로 바로 듣게 하는 플러그",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "codingbotPark <pbk575@gmail.com>",
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"types": "./dist/player.d.ts",
|
|
26
26
|
"import": "./dist/player.js"
|
|
27
27
|
},
|
|
28
|
+
"./headless": {
|
|
29
|
+
"types": "./dist/headless.d.ts",
|
|
30
|
+
"import": "./dist/headless.js"
|
|
31
|
+
},
|
|
28
32
|
"./styles.css": "./styles.css"
|
|
29
33
|
},
|
|
30
34
|
"files": [
|