@aigamo/nostalgic-diva 0.0.1-alpha.66 → 0.0.1-alpha.68
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/AudioPlayer-7plDTn5w.js +31 -0
- package/dist/AudioPlayer-7plDTn5w.js.map +1 -0
- package/dist/AudioPlayer-dEmhfyI_.cjs +2 -0
- package/dist/AudioPlayer-dEmhfyI_.cjs.map +1 -0
- package/dist/DailymotionPlayer-4LQmDDSf.js +61 -0
- package/dist/DailymotionPlayer-4LQmDDSf.js.map +1 -0
- package/dist/DailymotionPlayer-B3UVkJiv.cjs +2 -0
- package/dist/DailymotionPlayer-B3UVkJiv.cjs.map +1 -0
- package/dist/NiconicoPlayer-DiTU-06L.cjs +2 -0
- package/dist/NiconicoPlayer-DiTU-06L.cjs.map +1 -0
- package/dist/NiconicoPlayer-GFCXF5V7.js +35 -0
- package/dist/NiconicoPlayer-GFCXF5V7.js.map +1 -0
- package/dist/PlayerContainer-COjwHOhq.cjs +2 -0
- package/dist/PlayerContainer-COjwHOhq.cjs.map +1 -0
- package/dist/PlayerContainer-VQ3YPGU_.js +226 -0
- package/dist/PlayerContainer-VQ3YPGU_.js.map +1 -0
- package/dist/SoundCloudPlayer-Cqo5VU57.js +33 -0
- package/dist/SoundCloudPlayer-Cqo5VU57.js.map +1 -0
- package/dist/SoundCloudPlayer-tHiueAss.cjs +2 -0
- package/dist/SoundCloudPlayer-tHiueAss.cjs.map +1 -0
- package/dist/TwitchPlayer-BeQUOIE3.js +34 -0
- package/dist/TwitchPlayer-BeQUOIE3.js.map +1 -0
- package/dist/TwitchPlayer-Doh6zF0n.cjs +2 -0
- package/dist/TwitchPlayer-Doh6zF0n.cjs.map +1 -0
- package/dist/VimeoPlayer-7MjNmmgs.cjs +2 -0
- package/dist/VimeoPlayer-7MjNmmgs.cjs.map +1 -0
- package/dist/VimeoPlayer-CgWujBXW.js +33 -0
- package/dist/VimeoPlayer-CgWujBXW.js.map +1 -0
- package/dist/YouTubePlayer-CkaOKK_g.js +36 -0
- package/dist/YouTubePlayer-CkaOKK_g.js.map +1 -0
- package/dist/YouTubePlayer-Clpmqsmv.cjs +2 -0
- package/dist/YouTubePlayer-Clpmqsmv.cjs.map +1 -0
- package/dist/ensureScriptLoaded-BoubPl5C.cjs +2 -0
- package/dist/ensureScriptLoaded-BoubPl5C.cjs.map +1 -0
- package/dist/ensureScriptLoaded-CwERrTru.js +26 -0
- package/dist/ensureScriptLoaded-CwERrTru.js.map +1 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +769 -1232
- package/dist/index.es.js.map +1 -1
- package/package.json +15 -15
- package/dist/AudioPlayer-BMxdg9dp.js +0 -35
- package/dist/AudioPlayer-BMxdg9dp.js.map +0 -1
- package/dist/AudioPlayer-CgUxIJwa.cjs +0 -2
- package/dist/AudioPlayer-CgUxIJwa.cjs.map +0 -1
- package/dist/DailymotionPlayer-B4M9j0Lx.js +0 -65
- package/dist/DailymotionPlayer-B4M9j0Lx.js.map +0 -1
- package/dist/DailymotionPlayer-BdI4qcvJ.cjs +0 -2
- package/dist/DailymotionPlayer-BdI4qcvJ.cjs.map +0 -1
- package/dist/NiconicoPlayer-C1bgzaCT.cjs +0 -2
- package/dist/NiconicoPlayer-C1bgzaCT.cjs.map +0 -1
- package/dist/NiconicoPlayer-Cx3hGYsw.js +0 -36
- package/dist/NiconicoPlayer-Cx3hGYsw.js.map +0 -1
- package/dist/SoundCloudPlayer-BiFTnxn9.cjs +0 -2
- package/dist/SoundCloudPlayer-BiFTnxn9.cjs.map +0 -1
- package/dist/SoundCloudPlayer-C8QVPCXH.js +0 -43
- package/dist/SoundCloudPlayer-C8QVPCXH.js.map +0 -1
- package/dist/TwitchPlayer-C9D_eEaj.js +0 -40
- package/dist/TwitchPlayer-C9D_eEaj.js.map +0 -1
- package/dist/TwitchPlayer-DdhZD1Bh.cjs +0 -2
- package/dist/TwitchPlayer-DdhZD1Bh.cjs.map +0 -1
- package/dist/VimeoPlayer-DfBZwtd9.cjs +0 -2
- package/dist/VimeoPlayer-DfBZwtd9.cjs.map +0 -1
- package/dist/VimeoPlayer-UnKk2VAq.js +0 -43
- package/dist/VimeoPlayer-UnKk2VAq.js.map +0 -1
- package/dist/YouTubePlayer-CeTkdcOO.cjs +0 -2
- package/dist/YouTubePlayer-CeTkdcOO.cjs.map +0 -1
- package/dist/YouTubePlayer-bNmEJD02.js +0 -39
- package/dist/YouTubePlayer-bNmEJD02.js.map +0 -1
- package/dist/ensureScriptLoaded-CkK_-Amf.cjs +0 -2
- package/dist/ensureScriptLoaded-CkK_-Amf.cjs.map +0 -1
- package/dist/ensureScriptLoaded-HHnKf-aZ.js +0 -24
- package/dist/ensureScriptLoaded-HHnKf-aZ.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { a as e, t } from "./PlayerContainer-VQ3YPGU_.js";
|
|
2
|
+
import { AudioPlayerController as n } from "./index.es.js";
|
|
3
|
+
import { memo as r, useCallback as i } from "react";
|
|
4
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/AudioPlayer.tsx
|
|
6
|
+
var o = r(({ ...r }) => {
|
|
7
|
+
let { logger: o } = r;
|
|
8
|
+
o.log(e.Debug, "AudioPlayer");
|
|
9
|
+
let s = i((e) => Promise.resolve(e), []);
|
|
10
|
+
return /* @__PURE__ */ a(t, {
|
|
11
|
+
...r,
|
|
12
|
+
loadScript: void 0,
|
|
13
|
+
playerFactory: s,
|
|
14
|
+
controllerFactory: n,
|
|
15
|
+
children: (e, t) => /* @__PURE__ */ a("audio", {
|
|
16
|
+
ref: e,
|
|
17
|
+
src: t,
|
|
18
|
+
style: {
|
|
19
|
+
width: "100%",
|
|
20
|
+
height: "100%"
|
|
21
|
+
},
|
|
22
|
+
preload: "auto",
|
|
23
|
+
autoPlay: !0,
|
|
24
|
+
controls: !0
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { o as default };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=AudioPlayer-7plDTn5w.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayer-7plDTn5w.js","names":[],"sources":["../src/components/AudioPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { AudioPlayerController } from '@/controllers/AudioPlayerController';\nimport { LogLevel } from '@/controllers/Logger';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst AudioPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'AudioPlayer');\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLAudioElement): Promise<HTMLAudioElement> => {\n\t\t\treturn Promise.resolve(element);\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={undefined}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={AudioPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t<audio\n\t\t\t\t\tref={elementRef}\n\t\t\t\t\tsrc={videoId}\n\t\t\t\t\tstyle={{ width: '100%', height: '100%' }}\n\t\t\t\t\tpreload=\"auto\"\n\t\t\t\t\tautoPlay\n\t\t\t\t\tcontrols\n\t\t\t\t/>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default AudioPlayer;\n"],"mappings":";;;;;AAQA,IAAM,IAAc,GAAM,EAAE,GAAG,QAAuC;CACrE,IAAM,EAAE,cAAW;CAEnB,EAAO,IAAI,EAAS,OAAO,aAAa;CAExC,IAAM,IAAgB,GACpB,MACO,QAAQ,QAAQ,CAAO,GAE/B,CAAC,CACF;CAEA,OACC,kBAAC,GAAD;EACC,GAAI;EACJ,YAAY,KAAA;EACG;EACf,mBAAmB;aAEjB,GAAY,MACb,kBAAC,SAAD;GACC,KAAK;GACL,KAAK;GACL,OAAO;IAAE,OAAO;IAAQ,QAAQ;GAAO;GACvC,SAAQ;GACR,UAAA;GACA,UAAA;EACA,CAAA;CAEc,CAAA;AAEnB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./PlayerContainer-COjwHOhq.cjs`),t=require(`./index.cjs.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.memo)(({...i})=>{let{logger:a}=i;a.log(e.a.Debug,`AudioPlayer`);let o=(0,n.useCallback)(e=>Promise.resolve(e),[]);return(0,r.jsx)(e.t,{...i,loadScript:void 0,playerFactory:o,controllerFactory:t.AudioPlayerController,children:(e,t)=>(0,r.jsx)(`audio`,{ref:e,src:t,style:{width:`100%`,height:`100%`},preload:`auto`,autoPlay:!0,controls:!0})})});exports.default=i;
|
|
2
|
+
//# sourceMappingURL=AudioPlayer-dEmhfyI_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayer-dEmhfyI_.cjs","names":[],"sources":["../src/components/AudioPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { AudioPlayerController } from '@/controllers/AudioPlayerController';\nimport { LogLevel } from '@/controllers/Logger';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst AudioPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'AudioPlayer');\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLAudioElement): Promise<HTMLAudioElement> => {\n\t\t\treturn Promise.resolve(element);\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={undefined}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={AudioPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t<audio\n\t\t\t\t\tref={elementRef}\n\t\t\t\t\tsrc={videoId}\n\t\t\t\t\tstyle={{ width: '100%', height: '100%' }}\n\t\t\t\t\tpreload=\"auto\"\n\t\t\t\t\tautoPlay\n\t\t\t\t\tcontrols\n\t\t\t\t/>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default AudioPlayer;\n"],"mappings":"oIAQA,IAAM,GAAA,EAAA,EAAA,OAAoB,CAAE,GAAG,KAAuC,CACrE,GAAM,CAAE,UAAW,EAEnB,EAAO,IAAI,EAAA,EAAS,MAAO,aAAa,EAExC,IAAM,GAAA,EAAA,EAAA,aACJ,GACO,QAAQ,QAAQ,CAAO,EAE/B,CAAC,CACF,EAEA,OACC,EAAA,EAAA,KAAC,EAAA,EAAD,CACC,GAAI,EACJ,WAAY,IAAA,GACG,gBACf,kBAAmB,EAAA,gCAEjB,EAAY,KACb,EAAA,EAAA,KAAC,QAAD,CACC,IAAK,EACL,IAAK,EACL,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,EACvC,QAAQ,OACR,SAAA,GACA,SAAA,EACA,CAAA,CAEc,CAAA,CAEnB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { a as e, t } from "./PlayerContainer-VQ3YPGU_.js";
|
|
2
|
+
import { DailymotionPlayerController as n } from "./index.es.js";
|
|
3
|
+
import { t as r } from "./ensureScriptLoaded-CwERrTru.js";
|
|
4
|
+
import { memo as i, useCallback as a } from "react";
|
|
5
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/DailymotionPlayer.tsx
|
|
7
|
+
var s = i(({ options: i, ...s }) => {
|
|
8
|
+
let { logger: c } = s;
|
|
9
|
+
c.log(e.Debug, "DailymotionPlayer");
|
|
10
|
+
let l = a(async () => {
|
|
11
|
+
await r("https://api.dmcdn.net/all.js", c);
|
|
12
|
+
}, [c]), u = a((e, t) => Promise.resolve(new DM.player(e, {
|
|
13
|
+
video: t,
|
|
14
|
+
width: "100%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
events: {
|
|
17
|
+
apiready: () => {
|
|
18
|
+
i?.onLoaded?.({ id: t });
|
|
19
|
+
},
|
|
20
|
+
seeked: () => {
|
|
21
|
+
i?.onTimeUpdate?.({
|
|
22
|
+
duration: 0,
|
|
23
|
+
percent: 0,
|
|
24
|
+
seconds: 0
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
video_end: () => {
|
|
28
|
+
i?.onEnded?.();
|
|
29
|
+
},
|
|
30
|
+
durationchange: () => {},
|
|
31
|
+
pause: () => {
|
|
32
|
+
i?.onPause?.();
|
|
33
|
+
},
|
|
34
|
+
playing: () => {
|
|
35
|
+
i?.onPlay?.();
|
|
36
|
+
},
|
|
37
|
+
waiting: () => {},
|
|
38
|
+
error: (e) => {
|
|
39
|
+
i?.onError?.(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})), [i]);
|
|
43
|
+
return /* @__PURE__ */ o(t, {
|
|
44
|
+
...s,
|
|
45
|
+
options: i,
|
|
46
|
+
loadScript: l,
|
|
47
|
+
playerFactory: u,
|
|
48
|
+
controllerFactory: n,
|
|
49
|
+
children: (e) => /* @__PURE__ */ o("div", {
|
|
50
|
+
style: {
|
|
51
|
+
width: "100%",
|
|
52
|
+
height: "100%"
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ o("div", { ref: e })
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
export { s as default };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=DailymotionPlayer-4LQmDDSf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DailymotionPlayer-4LQmDDSf.js","names":[],"sources":["../src/components/DailymotionPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { DailymotionPlayerController } from '@/controllers/DailymotionPlayerController';\nimport { LogLevel } from '@/controllers/Logger';\nimport { ensureScriptLoaded } from '@/controllers/ensureScriptLoaded';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst DailymotionPlayer = memo(\n\t({ options, ...props }: PlayerProps): ReactElement => {\n\t\tconst { logger } = props;\n\n\t\tlogger.log(LogLevel.Debug, 'DailymotionPlayer');\n\n\t\tconst loadScript = useCallback(async () => {\n\t\t\tawait ensureScriptLoaded('https://api.dmcdn.net/all.js', logger);\n\t\t}, [logger]);\n\n\t\tconst playerFactory = useCallback(\n\t\t\t(element: HTMLDivElement, videoId: string): Promise<DM.player> => {\n\t\t\t\treturn Promise.resolve(\n\t\t\t\t\tnew DM.player(element, {\n\t\t\t\t\t\tvideo: videoId,\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\tevents: {\n\t\t\t\t\t\t\tapiready: (): void => {\n\t\t\t\t\t\t\t\toptions?.onLoaded?.({ id: videoId });\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tseeked: (): void => {\n\t\t\t\t\t\t\t\toptions?.onTimeUpdate?.({\n\t\t\t\t\t\t\t\t\tduration: 0,\n\t\t\t\t\t\t\t\t\tpercent: 0,\n\t\t\t\t\t\t\t\t\tseconds: 0,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tvideo_end: (): void => {\n\t\t\t\t\t\t\t\toptions?.onEnded?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdurationchange: (): void => {},\n\t\t\t\t\t\t\tpause: (): void => {\n\t\t\t\t\t\t\t\toptions?.onPause?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tplaying: (): void => {\n\t\t\t\t\t\t\t\toptions?.onPlay?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\twaiting: (): void => {},\n\t\t\t\t\t\t\terror: (error): void => {\n\t\t\t\t\t\t\t\toptions?.onError?.(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t[options],\n\t\t);\n\n\t\treturn (\n\t\t\t<PlayerContainer\n\t\t\t\t{...props}\n\t\t\t\toptions={options}\n\t\t\t\tloadScript={loadScript}\n\t\t\t\tplayerFactory={playerFactory}\n\t\t\t\tcontrollerFactory={DailymotionPlayerController}\n\t\t\t>\n\t\t\t\t{(elementRef): ReactElement => (\n\t\t\t\t\t<div style={{ width: '100%', height: '100%' }}>\n\t\t\t\t\t\t<div ref={elementRef} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</PlayerContainer>\n\t\t);\n\t},\n);\n\nexport default DailymotionPlayer;\n"],"mappings":";;;;;;AASA,IAAM,IAAoB,GACxB,EAAE,YAAS,GAAG,QAAuC;CACrD,IAAM,EAAE,cAAW;CAEnB,EAAO,IAAI,EAAS,OAAO,mBAAmB;CAE9C,IAAM,IAAa,EAAY,YAAY;EAC1C,MAAM,EAAmB,gCAAgC,CAAM;CAChE,GAAG,CAAC,CAAM,CAAC,GAEL,IAAgB,GACpB,GAAyB,MAClB,QAAQ,QACd,IAAI,GAAG,OAAO,GAAS;EACtB,OAAO;EACP,OAAO;EACP,QAAQ;EACR,QAAQ;GACP,gBAAsB;IACrB,GAAS,WAAW,EAAE,IAAI,EAAQ,CAAC;GACpC;GACA,cAAoB;IACnB,GAAS,eAAe;KACvB,UAAU;KACV,SAAS;KACT,SAAS;IACV,CAAC;GACF;GACA,iBAAuB;IACtB,GAAS,UAAU;GACpB;GACA,sBAA4B,CAAC;GAC7B,aAAmB;IAClB,GAAS,UAAU;GACpB;GACA,eAAqB;IACpB,GAAS,SAAS;GACnB;GACA,eAAqB,CAAC;GACtB,QAAQ,MAAgB;IACvB,GAAS,UAAU,CAAK;GACzB;EACD;CACD,CAAC,CACF,GAED,CAAC,CAAO,CACT;CAEA,OACC,kBAAC,GAAD;EACC,GAAI;EACK;EACG;EACG;EACf,mBAAmB;aAEjB,MACD,kBAAC,OAAD;GAAK,OAAO;IAAE,OAAO;IAAQ,QAAQ;GAAO;aAC3C,kBAAC,OAAD,EAAK,KAAK,EAAa,CAAA;EACnB,CAAA;CAEU,CAAA;AAEnB,CACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./PlayerContainer-COjwHOhq.cjs`),t=require(`./index.cjs.js`),n=require(`./ensureScriptLoaded-BoubPl5C.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);var a=(0,r.memo)(({options:a,...o})=>{let{logger:s}=o;s.log(e.a.Debug,`DailymotionPlayer`);let c=(0,r.useCallback)(async()=>{await n.t(`https://api.dmcdn.net/all.js`,s)},[s]),l=(0,r.useCallback)((e,t)=>Promise.resolve(new DM.player(e,{video:t,width:`100%`,height:`100%`,events:{apiready:()=>{a?.onLoaded?.({id:t})},seeked:()=>{a?.onTimeUpdate?.({duration:0,percent:0,seconds:0})},video_end:()=>{a?.onEnded?.()},durationchange:()=>{},pause:()=>{a?.onPause?.()},playing:()=>{a?.onPlay?.()},waiting:()=>{},error:e=>{a?.onError?.(e)}}})),[a]);return(0,i.jsx)(e.t,{...o,options:a,loadScript:c,playerFactory:l,controllerFactory:t.DailymotionPlayerController,children:e=>(0,i.jsx)(`div`,{style:{width:`100%`,height:`100%`},children:(0,i.jsx)(`div`,{ref:e})})})});exports.default=a;
|
|
2
|
+
//# sourceMappingURL=DailymotionPlayer-B3UVkJiv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DailymotionPlayer-B3UVkJiv.cjs","names":[],"sources":["../src/components/DailymotionPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { DailymotionPlayerController } from '@/controllers/DailymotionPlayerController';\nimport { LogLevel } from '@/controllers/Logger';\nimport { ensureScriptLoaded } from '@/controllers/ensureScriptLoaded';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst DailymotionPlayer = memo(\n\t({ options, ...props }: PlayerProps): ReactElement => {\n\t\tconst { logger } = props;\n\n\t\tlogger.log(LogLevel.Debug, 'DailymotionPlayer');\n\n\t\tconst loadScript = useCallback(async () => {\n\t\t\tawait ensureScriptLoaded('https://api.dmcdn.net/all.js', logger);\n\t\t}, [logger]);\n\n\t\tconst playerFactory = useCallback(\n\t\t\t(element: HTMLDivElement, videoId: string): Promise<DM.player> => {\n\t\t\t\treturn Promise.resolve(\n\t\t\t\t\tnew DM.player(element, {\n\t\t\t\t\t\tvideo: videoId,\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\tevents: {\n\t\t\t\t\t\t\tapiready: (): void => {\n\t\t\t\t\t\t\t\toptions?.onLoaded?.({ id: videoId });\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tseeked: (): void => {\n\t\t\t\t\t\t\t\toptions?.onTimeUpdate?.({\n\t\t\t\t\t\t\t\t\tduration: 0,\n\t\t\t\t\t\t\t\t\tpercent: 0,\n\t\t\t\t\t\t\t\t\tseconds: 0,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tvideo_end: (): void => {\n\t\t\t\t\t\t\t\toptions?.onEnded?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdurationchange: (): void => {},\n\t\t\t\t\t\t\tpause: (): void => {\n\t\t\t\t\t\t\t\toptions?.onPause?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tplaying: (): void => {\n\t\t\t\t\t\t\t\toptions?.onPlay?.();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\twaiting: (): void => {},\n\t\t\t\t\t\t\terror: (error): void => {\n\t\t\t\t\t\t\t\toptions?.onError?.(error);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\t[options],\n\t\t);\n\n\t\treturn (\n\t\t\t<PlayerContainer\n\t\t\t\t{...props}\n\t\t\t\toptions={options}\n\t\t\t\tloadScript={loadScript}\n\t\t\t\tplayerFactory={playerFactory}\n\t\t\t\tcontrollerFactory={DailymotionPlayerController}\n\t\t\t>\n\t\t\t\t{(elementRef): ReactElement => (\n\t\t\t\t\t<div style={{ width: '100%', height: '100%' }}>\n\t\t\t\t\t\t<div ref={elementRef} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</PlayerContainer>\n\t\t);\n\t},\n);\n\nexport default DailymotionPlayer;\n"],"mappings":"mLASA,IAAM,GAAA,EAAA,EAAA,OACJ,CAAE,UAAS,GAAG,KAAuC,CACrD,GAAM,CAAE,UAAW,EAEnB,EAAO,IAAI,EAAA,EAAS,MAAO,mBAAmB,EAE9C,IAAM,GAAA,EAAA,EAAA,aAAyB,SAAY,CAC1C,MAAM,EAAA,EAAmB,+BAAgC,CAAM,CAChE,EAAG,CAAC,CAAM,CAAC,EAEL,GAAA,EAAA,EAAA,cACJ,EAAyB,IAClB,QAAQ,QACd,IAAI,GAAG,OAAO,EAAS,CACtB,MAAO,EACP,MAAO,OACP,OAAQ,OACR,OAAQ,CACP,aAAsB,CACrB,GAAS,WAAW,CAAE,GAAI,CAAQ,CAAC,CACpC,EACA,WAAoB,CACnB,GAAS,eAAe,CACvB,SAAU,EACV,QAAS,EACT,QAAS,CACV,CAAC,CACF,EACA,cAAuB,CACtB,GAAS,UAAU,CACpB,EACA,mBAA4B,CAAC,EAC7B,UAAmB,CAClB,GAAS,UAAU,CACpB,EACA,YAAqB,CACpB,GAAS,SAAS,CACnB,EACA,YAAqB,CAAC,EACtB,MAAQ,GAAgB,CACvB,GAAS,UAAU,CAAK,CACzB,CACD,CACD,CAAC,CACF,EAED,CAAC,CAAO,CACT,EAEA,OACC,EAAA,EAAA,KAAC,EAAA,EAAD,CACC,GAAI,EACK,UACG,aACG,gBACf,kBAAmB,EAAA,qCAEjB,IACD,EAAA,EAAA,KAAC,MAAD,CAAK,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,YAC3C,EAAA,EAAA,KAAC,MAAD,CAAK,IAAK,CAAa,CAAA,CACnB,CAAA,CAEU,CAAA,CAEnB,CACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./PlayerContainer-COjwHOhq.cjs`),t=require(`./index.cjs.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.memo)(({...i})=>{let{logger:a}=i;a.log(e.a.Debug,`NiconicoPlayer`);let o=(0,n.useCallback)(e=>Promise.resolve(e),[]);return(0,r.jsx)(e.t,{...i,loadScript:void 0,playerFactory:o,controllerFactory:t.NiconicoPlayerController,children:(e,t)=>(0,r.jsx)(`div`,{style:{width:`100%`,height:`100%`},children:(0,r.jsx)(`iframe`,{ref:e,src:`https://embed.nicovideo.jp/watch/${t}?jsapi=1&playerId=1`,width:`100%`,height:`100%`,allowFullScreen:!0,style:{border:`none`},allow:`autoplay; fullscreen`})})})});exports.default=i;
|
|
2
|
+
//# sourceMappingURL=NiconicoPlayer-DiTU-06L.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NiconicoPlayer-DiTU-06L.cjs","names":[],"sources":["../src/components/NiconicoPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { LogLevel } from '@/controllers/Logger';\nimport { NiconicoPlayerController } from '@/controllers/NiconicoPlayerController';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst NiconicoPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'NiconicoPlayer');\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLIFrameElement): Promise<HTMLIFrameElement> => {\n\t\t\treturn Promise.resolve(element);\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={undefined}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={NiconicoPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t<div style={{ width: '100%', height: '100%' }}>\n\t\t\t\t\t{/* eslint-disable-next-line jsx-a11y/iframe-has-title */}\n\t\t\t\t\t<iframe\n\t\t\t\t\t\tref={elementRef}\n\t\t\t\t\t\tsrc={`https://embed.nicovideo.jp/watch/${videoId}?jsapi=1&playerId=1`}\n\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t\tallowFullScreen\n\t\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\t\t// The player has to have the allow=\"autoplay\" attribute.\n\t\t\t\t\t\t// Otherwise it throws a NotAllowedError: \"play() failed because the user didn't interact with the document first\".\n\t\t\t\t\t\t// See also: https://github.com/vimeo/player.js/issues/389.\n\t\t\t\t\t\t// NOTE: An iframe element created by `PVPlayerNiconico.playerFactory.create` doesn't have the allow=\"autoplay\" attribute,\n\t\t\t\t\t\t// which causes the above issue when trying to autoplay a video.\n\t\t\t\t\t\tallow=\"autoplay; fullscreen\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default NiconicoPlayer;\n"],"mappings":"oIAQA,IAAM,GAAA,EAAA,EAAA,OAAuB,CAAE,GAAG,KAAuC,CACxE,GAAM,CAAE,UAAW,EAEnB,EAAO,IAAI,EAAA,EAAS,MAAO,gBAAgB,EAE3C,IAAM,GAAA,EAAA,EAAA,aACJ,GACO,QAAQ,QAAQ,CAAO,EAE/B,CAAC,CACF,EAEA,OACC,EAAA,EAAA,KAAC,EAAA,EAAD,CACC,GAAI,EACJ,WAAY,IAAA,GACG,gBACf,kBAAmB,EAAA,mCAEjB,EAAY,KACb,EAAA,EAAA,KAAC,MAAD,CAAK,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,YAE3C,EAAA,EAAA,KAAC,SAAD,CACC,IAAK,EACL,IAAK,oCAAoC,EAAQ,qBACjD,MAAM,OACN,OAAO,OACP,gBAAA,GACA,MAAO,CAAE,OAAQ,MAAO,EAMxB,MAAM,sBACN,CAAA,CACG,CAAA,CAEU,CAAA,CAEnB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as e, t } from "./PlayerContainer-VQ3YPGU_.js";
|
|
2
|
+
import { NiconicoPlayerController as n } from "./index.es.js";
|
|
3
|
+
import { memo as r, useCallback as i } from "react";
|
|
4
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/NiconicoPlayer.tsx
|
|
6
|
+
var o = r(({ ...r }) => {
|
|
7
|
+
let { logger: o } = r;
|
|
8
|
+
o.log(e.Debug, "NiconicoPlayer");
|
|
9
|
+
let s = i((e) => Promise.resolve(e), []);
|
|
10
|
+
return /* @__PURE__ */ a(t, {
|
|
11
|
+
...r,
|
|
12
|
+
loadScript: void 0,
|
|
13
|
+
playerFactory: s,
|
|
14
|
+
controllerFactory: n,
|
|
15
|
+
children: (e, t) => /* @__PURE__ */ a("div", {
|
|
16
|
+
style: {
|
|
17
|
+
width: "100%",
|
|
18
|
+
height: "100%"
|
|
19
|
+
},
|
|
20
|
+
children: /* @__PURE__ */ a("iframe", {
|
|
21
|
+
ref: e,
|
|
22
|
+
src: `https://embed.nicovideo.jp/watch/${t}?jsapi=1&playerId=1`,
|
|
23
|
+
width: "100%",
|
|
24
|
+
height: "100%",
|
|
25
|
+
allowFullScreen: !0,
|
|
26
|
+
style: { border: "none" },
|
|
27
|
+
allow: "autoplay; fullscreen"
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { o as default };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=NiconicoPlayer-GFCXF5V7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NiconicoPlayer-GFCXF5V7.js","names":[],"sources":["../src/components/NiconicoPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { LogLevel } from '@/controllers/Logger';\nimport { NiconicoPlayerController } from '@/controllers/NiconicoPlayerController';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst NiconicoPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'NiconicoPlayer');\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLIFrameElement): Promise<HTMLIFrameElement> => {\n\t\t\treturn Promise.resolve(element);\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={undefined}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={NiconicoPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t<div style={{ width: '100%', height: '100%' }}>\n\t\t\t\t\t{/* eslint-disable-next-line jsx-a11y/iframe-has-title */}\n\t\t\t\t\t<iframe\n\t\t\t\t\t\tref={elementRef}\n\t\t\t\t\t\tsrc={`https://embed.nicovideo.jp/watch/${videoId}?jsapi=1&playerId=1`}\n\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t\tallowFullScreen\n\t\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\t\t// The player has to have the allow=\"autoplay\" attribute.\n\t\t\t\t\t\t// Otherwise it throws a NotAllowedError: \"play() failed because the user didn't interact with the document first\".\n\t\t\t\t\t\t// See also: https://github.com/vimeo/player.js/issues/389.\n\t\t\t\t\t\t// NOTE: An iframe element created by `PVPlayerNiconico.playerFactory.create` doesn't have the allow=\"autoplay\" attribute,\n\t\t\t\t\t\t// which causes the above issue when trying to autoplay a video.\n\t\t\t\t\t\tallow=\"autoplay; fullscreen\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default NiconicoPlayer;\n"],"mappings":";;;;;AAQA,IAAM,IAAiB,GAAM,EAAE,GAAG,QAAuC;CACxE,IAAM,EAAE,cAAW;CAEnB,EAAO,IAAI,EAAS,OAAO,gBAAgB;CAE3C,IAAM,IAAgB,GACpB,MACO,QAAQ,QAAQ,CAAO,GAE/B,CAAC,CACF;CAEA,OACC,kBAAC,GAAD;EACC,GAAI;EACJ,YAAY,KAAA;EACG;EACf,mBAAmB;aAEjB,GAAY,MACb,kBAAC,OAAD;GAAK,OAAO;IAAE,OAAO;IAAQ,QAAQ;GAAO;aAE3C,kBAAC,UAAD;IACC,KAAK;IACL,KAAK,oCAAoC,EAAQ;IACjD,OAAM;IACN,QAAO;IACP,iBAAA;IACA,OAAO,EAAE,QAAQ,OAAO;IAMxB,OAAM;GACN,CAAA;EACG,CAAA;CAEU,CAAA;AAEnB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`./index.cjs.js`);let e=require(`react`),t=require(`react/jsx-runtime`);var n=function(e){return e[e.Trace=0]=`Trace`,e[e.Debug=1]=`Debug`,e[e.Information=2]=`Information`,e[e.Warning=3]=`Warning`,e[e.Error=4]=`Error`,e[e.Critical=5]=`Critical`,e[e.None=6]=`None`,e}({}),r=new class{title=`nostalgic-diva`;createMessage(e){return`[${this.title}] ${e}`}debug(e,...t){console.debug(this.createMessage(e),...t)}error(e,...t){console.error(this.createMessage(e),...t)}warn(e,...t){console.warn(this.createMessage(e),...t)}isEnabled(){return!0}log(e,t,...n){switch(e){case 1:this.debug(t,...n);break;case 3:this.warn(t,...n);break;case 4:this.error(t,...n);break}}},i=new class{async attach(){}async detach(){}async loadVideo(e){}async play(){}async pause(){}async setCurrentTime(e){}async setVolume(e){}async setMuted(e){}async setPlaybackRate(e){}async getDuration(){return 0}async getCurrentTime(){return 0}async getVolume(){return 0}async getMuted(){return!1}async getPlaybackRate(){return 0}supports(e){return!1}};function a(){let t=(0,e.useRef)(!0);return t.current?(t.current=!1,!0):t.current}var o=(e,t)=>e===t;function s(t,n=o){let r=(0,e.useRef)(),i=(0,e.useRef)(t);return!a()&&!n(i.current,t)&&(r.current=i.current,i.current=t),r.current}var c=class{logger;player;options;constructor(e,t,r){this.logger=e,this.player=t,this.options=r,this.logger.log(n.Debug,`ctor`)}supports(e){return this[e]!==void 0}},l=class e{logger;type;player;options;controllerFactory;static nextId=1;id;impl;constructor(t,n,r,i,a){this.logger=t,this.type=n,this.player=r,this.options=i,this.controllerFactory=a,this.id=e.nextId++}createMessage(e){return`${this.type}#${this.id} ${e}`}debug(e,...t){this.logger.log(n.Debug,this.createMessage(e),...t)}error(e,...t){this.logger.log(n.Error,this.createMessage(e),...t)}async attach(e){if(this.debug(`attach`,e),this.impl){this.debug(`player is already attached`);return}this.debug(`Attaching player...`),this.impl=new this.controllerFactory(this.logger,this.player,this.options),await this.impl.attach(e),this.debug(`player attached`)}createPlayerNotAttachedError(){return this.error(`player is not attached`),Error(`player is not attached`)}createCommandNotSupportedError(e){return Error(`${e} is not supported`)}async detach(){if(this.debug(`detach`),this.impl===void 0)throw this.createPlayerNotAttachedError();await this.impl.detach(),this.impl=void 0}async loadVideo(e){if(this.debug(`loadVideo`,e),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.loadVideo===void 0)throw this.createCommandNotSupportedError(`loadVideo`);this.debug(`Loading video...`),await this.impl.loadVideo(e),this.debug(`video loaded`,e)}play(){if(this.debug(`play`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.play===void 0)throw this.createCommandNotSupportedError(`play`);return this.impl.play()}pause(){if(this.debug(`pause`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.pause===void 0)throw this.createCommandNotSupportedError(`pause`);return this.impl.pause()}setCurrentTime(e){if(this.debug(`setCurrentTime`,e),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.setCurrentTime===void 0)throw this.createCommandNotSupportedError(`setCurrentTime`);return this.impl.setCurrentTime(e)}setVolume(e){if(this.debug(`setVolume`,e),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.setVolume===void 0)throw this.createCommandNotSupportedError(`setVolume`);return this.impl.setVolume(e)}setMuted(e){if(this.debug(`setMuted`,e),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.setMuted===void 0)throw this.createCommandNotSupportedError(`setMuted`);return this.impl.setMuted(e)}setPlaybackRate(e){if(this.debug(`setPlaybackRate`,e),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.setPlaybackRate===void 0)throw this.createCommandNotSupportedError(`setPlaybackRate`);return this.impl.setPlaybackRate(e)}getDuration(){if(this.debug(`getDuration`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.getDuration===void 0)throw this.createCommandNotSupportedError(`getDuration`);return this.impl.getDuration()}getCurrentTime(){if(this.debug(`getCurrentTime`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.getCurrentTime===void 0)throw this.createCommandNotSupportedError(`getCurrentTime`);return this.impl.getCurrentTime()}getVolume(){if(this.debug(`getVolume`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.getVolume===void 0)throw this.createCommandNotSupportedError(`getVolume`);return this.impl.getVolume()}getMuted(){if(this.debug(`getMuted`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.getMuted===void 0)throw this.createCommandNotSupportedError(`getMuted`);return this.impl.getMuted()}getPlaybackRate(){if(this.debug(`getPlaybackRate`),this.impl===void 0)throw this.createPlayerNotAttachedError();if(this.impl.getPlaybackRate===void 0)throw this.createCommandNotSupportedError(`getPlaybackRate`);return this.impl.getPlaybackRate()}supports(e){if(this.impl===void 0)throw this.createPlayerNotAttachedError();return this.impl.supports(e)}},u=({logger:r,type:a,loadScript:o,playerFactory:c,onControllerChange:u,videoId:d,options:f,controllerFactory:p,children:m})=>{r.log(n.Debug,`PlayerContainer`);let h=(0,e.useRef)(d),g=(0,e.useRef)(void 0),[_,v]=(0,e.useState)(),[y,b]=(0,e.useState)(i),x=(0,e.useCallback)(e=>{b(e),u?.(e)},[u]);(0,e.useEffect)(()=>{(o?.()??Promise.resolve()).then(()=>c(g.current,h.current)).then(e=>v(e))},[o,c]),(0,e.useEffect)(()=>{if(_===void 0)return;let e=new l(r,a,_,f,p);return e.attach(h.current).then(()=>x(e)),()=>{e.detach().finally(()=>x(i))}},[r,a,o,_,f,p,x]);let S=s(d);return(0,e.useEffect)(()=>{S!==void 0&&y.loadVideo(d)},[S,d,y]),(0,t.jsx)(t.Fragment,{children:m(g,h.current)})};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
2
|
+
//# sourceMappingURL=PlayerContainer-COjwHOhq.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerContainer-COjwHOhq.cjs","names":[],"sources":["../src/controllers/Logger.ts","../src/controllers/NullPlayerController.ts","../src/components/useFirstMountState.ts","../src/components/usePreviousDistinct.ts","../src/controllers/PlayerControllerImpl.ts","../src/controllers/PlayerController.ts","../src/components/PlayerContainer.tsx"],"sourcesContent":["// https://source.dot.net/#Microsoft.Extensions.Logging.Abstractions/LogLevel.cs,d07793e8b722b77e,references\nexport enum LogLevel {\n\t/**\n\t * Logs that contain the most detailed messages. These messages may contain sensitive application data.\n\t * These messages are disabled by default and should never be enabled in a production environment.\n\t */\n\tTrace = 0,\n\t/**\n\t * Logs that are used for interactive investigation during development. These logs should primarily contain\n\t * information useful for debugging and have no long-term value.\n\t */\n\tDebug = 1,\n\t/**\n\t * Logs that track the general flow of the application. These logs should have long-term value.\n\t */\n\tInformation = 2,\n\t/**\n\t * Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the\n\t * application execution to stop.\n\t */\n\tWarning = 3,\n\t/**\n\t * Logs that highlight when the current flow of execution is stopped due to a failure. These should indicate a\n\t * failure in the current activity, not an application-wide failure.\n\t */\n\tError = 4,\n\t/**\n\t * Logs that describe an unrecoverable application or system crash, or a catastrophic failure that requires\n\t * immediate attention.\n\t */\n\tCritical = 5,\n\t/**\n\t * Not used for writing log messages. Specifies that a logging category should not write any messages.\n\t */\n\tNone = 6,\n}\n\n// https://source.dot.net/#Microsoft.Extensions.Logging.Abstractions/ILogger.cs,0976525f5d1b9e54,references\nexport interface ILogger {\n\tisEnabled(logLevel: LogLevel): boolean;\n\tlog(logLevel: LogLevel, message?: any, ...optionalParams: any[]): void;\n}\n\nclass Logger implements ILogger {\n\tprivate readonly title = 'nostalgic-diva';\n\n\tprivate createMessage(message: any): string {\n\t\treturn `[${this.title}] ${message}`;\n\t}\n\n\tprivate debug(message?: any, ...optionalParams: any): void {\n\t\tconsole.debug(this.createMessage(message), ...optionalParams);\n\t}\n\n\tprivate error(message?: any, ...optionalParams: any): void {\n\t\tconsole.error(this.createMessage(message), ...optionalParams);\n\t}\n\n\tprivate warn(message?: any, ...optionalParams: any): void {\n\t\tconsole.warn(this.createMessage(message), ...optionalParams);\n\t}\n\n\tisEnabled(): boolean {\n\t\treturn true;\n\t}\n\n\tlog(logLevel: LogLevel, message?: any, ...optionalParams: any[]): void {\n\t\tswitch (logLevel) {\n\t\t\tcase LogLevel.Debug:\n\t\t\t\tthis.debug(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t\tcase LogLevel.Warning:\n\t\t\t\tthis.warn(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t\tcase LogLevel.Error:\n\t\t\t\tthis.error(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport const defaultLogger = new Logger();\n","import type {\n\tIPlayerCommands,\n\tIPlayerController,\n} from '@/controllers/PlayerController';\n\nclass NullPlayerController implements IPlayerController {\n\tasync attach(): Promise<void> {}\n\n\tasync detach(): Promise<void> {}\n\n\tasync loadVideo(_id: string): Promise<void> {}\n\n\tasync play(): Promise<void> {}\n\n\tasync pause(): Promise<void> {}\n\n\tasync setCurrentTime(_seconds: number): Promise<void> {}\n\n\tasync setVolume(_volume: number): Promise<void> {}\n\n\tasync setMuted(_muted: boolean): Promise<void> {}\n\n\tasync setPlaybackRate(_playbackRate: number): Promise<void> {}\n\n\tasync getDuration(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getCurrentTime(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getVolume(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getMuted(): Promise<boolean> {\n\t\treturn false;\n\t}\n\n\tasync getPlaybackRate(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tsupports(_command: keyof IPlayerCommands): boolean {\n\t\treturn false;\n\t}\n}\n\nexport const nullPlayerController = new NullPlayerController();\n","// https://github.com/streamich/react-use/blob/8ceb4c0f0c5625124f487b435a2fd0d3b3bc2a4f/src/useFirstMountState.ts\nimport { useRef } from 'react';\n\nexport function useFirstMountState(): boolean {\n\tconst isFirst = useRef(true);\n\n\tif (isFirst.current) {\n\t\tisFirst.current = false;\n\n\t\treturn true;\n\t}\n\n\treturn isFirst.current;\n}\n","// https://github.com/streamich/react-use/blob/8ceb4c0f0c5625124f487b435a2fd0d3b3bc2a4f/src/usePreviousDistinct.ts.\nimport { useFirstMountState } from '@/components/useFirstMountState';\nimport { useRef } from 'react';\n\nexport type Predicate<T> = (prev: T | undefined, next: T) => boolean;\n\nconst strictEquals = <T>(prev: T | undefined, next: T): boolean =>\n\tprev === next;\n\nexport default function usePreviousDistinct<T>(\n\tvalue: T,\n\tcompare: Predicate<T> = strictEquals,\n): T | undefined {\n\tconst prevRef = useRef<T>();\n\tconst curRef = useRef<T>(value);\n\tconst isFirstMount = useFirstMountState();\n\n\tif (!isFirstMount && !compare(curRef.current, value)) {\n\t\tprevRef.current = curRef.current;\n\t\tcurRef.current = value;\n\t}\n\n\treturn prevRef.current;\n}\n","import { type ILogger, LogLevel } from '@/controllers/Logger';\nimport type {\n\tIPlayerCommands,\n\tPlayerOptions,\n} from '@/controllers/PlayerController';\n\nexport abstract class PlayerControllerImpl<\n\tTPlayer,\n> implements Partial<IPlayerCommands> {\n\tconstructor(\n\t\tprotected readonly logger: ILogger,\n\t\tprotected readonly player: TPlayer,\n\t\tprotected readonly options: PlayerOptions | undefined,\n\t) {\n\t\tthis.logger.log(LogLevel.Debug, 'ctor');\n\t}\n\n\tabstract attach(id: string): Promise<void>;\n\tabstract detach(): Promise<void>;\n\tabstract loadVideo?(id: string): Promise<void>;\n\tabstract play?(): Promise<void>;\n\tabstract pause?(): Promise<void>;\n\tabstract setCurrentTime?(seconds: number): Promise<void>;\n\tabstract setVolume?(volume: number): Promise<void>;\n\tabstract setMuted?(muted: boolean): Promise<void>;\n\tabstract setPlaybackRate?(playbackRate: number): Promise<void>;\n\tabstract getDuration?(): Promise<number>;\n\tabstract getCurrentTime?(): Promise<number>;\n\tabstract getVolume?(): Promise<number>;\n\tabstract getMuted?(): Promise<boolean>;\n\tabstract getPlaybackRate?(): Promise<number>;\n\n\tsupports(command: keyof IPlayerCommands): boolean {\n\t\treturn this[command] !== undefined;\n\t}\n}\n","import { type ILogger, LogLevel } from '@/controllers/Logger';\nimport { PlayerControllerImpl } from '@/controllers/PlayerControllerImpl';\n\nexport type PlayerType =\n\t| 'Audio'\n\t| 'Dailymotion'\n\t| 'Niconico'\n\t| 'SoundCloud'\n\t| 'Twitch'\n\t| 'Vimeo'\n\t| 'YouTube'\n\t| (string & {});\n\nexport interface LoadedEvent {\n\tid: string;\n}\n\nexport interface TimeEvent {\n\tduration: number;\n\tpercent: number;\n\tseconds: number;\n}\n\nexport interface PlayerOptions {\n\tonError?(event: any): void;\n\tonLoaded?(event: LoadedEvent): void;\n\tonPlay?(): void;\n\tonPause?(): void;\n\tonEnded?(): void;\n\tonTimeUpdate?(event: TimeEvent): void;\n}\n\nexport interface IPlayerCommands {\n\tloadVideo(id: string): Promise<void>;\n\tplay(): Promise<void>;\n\tpause(): Promise<void>;\n\tsetCurrentTime(seconds: number): Promise<void>;\n\tsetVolume(volume: number): Promise<void>;\n\tsetMuted(muted: boolean): Promise<void>;\n\tsetPlaybackRate(playbackRate: number): Promise<void>;\n\tgetDuration(): Promise<number>;\n\tgetCurrentTime(): Promise<number>;\n\tgetVolume(): Promise<number>;\n\tgetMuted(): Promise<boolean>;\n\tgetPlaybackRate(): Promise<number>;\n}\n\nexport interface IPlayerController extends IPlayerCommands {\n\tsupports(command: keyof IPlayerCommands): boolean;\n}\n\nexport class PlayerController<\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n> implements IPlayerController {\n\tprivate static nextId = 1;\n\n\tprivate readonly id: number;\n\tprivate impl?: TController;\n\n\tconstructor(\n\t\tprivate readonly logger: ILogger,\n\t\tprivate readonly type: PlayerType,\n\t\tprivate readonly player: TPlayer,\n\t\tprivate readonly options: PlayerOptions | undefined,\n\t\tprivate readonly controllerFactory: new (\n\t\t\tlogger: ILogger,\n\t\t\tplayer: TPlayer,\n\t\t\toptions: PlayerOptions | undefined,\n\t\t) => TController,\n\t) {\n\t\tthis.id = PlayerController.nextId++;\n\t}\n\n\tprivate createMessage(message: any): string {\n\t\treturn `${this.type}#${this.id} ${message}`;\n\t}\n\n\tpublic debug(message?: any, ...optionalParams: any): void {\n\t\tthis.logger.log(\n\t\t\tLogLevel.Debug,\n\t\t\tthis.createMessage(message),\n\t\t\t...optionalParams,\n\t\t);\n\t}\n\n\tpublic error(message?: any, ...optionalParams: any): void {\n\t\tthis.logger.log(\n\t\t\tLogLevel.Error,\n\t\t\tthis.createMessage(message),\n\t\t\t...optionalParams,\n\t\t);\n\t}\n\n\tasync attach(id: string): Promise<void> {\n\t\tthis.debug('attach', id);\n\n\t\tif (this.impl) {\n\t\t\tthis.debug('player is already attached');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.debug('Attaching player...');\n\n\t\tthis.impl = new this.controllerFactory(\n\t\t\tthis.logger,\n\t\t\tthis.player,\n\t\t\tthis.options,\n\t\t);\n\n\t\tawait this.impl.attach(id);\n\n\t\tthis.debug('player attached');\n\t}\n\n\tprivate createPlayerNotAttachedError(): Error {\n\t\tthis.error('player is not attached');\n\n\t\treturn new Error('player is not attached');\n\t}\n\n\tprivate createCommandNotSupportedError(\n\t\tcommand: keyof IPlayerCommands,\n\t): Error {\n\t\treturn new Error(`${command} is not supported`);\n\t}\n\n\tasync detach(): Promise<void> {\n\t\tthis.debug('detach');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tawait this.impl.detach();\n\n\t\tthis.impl = undefined;\n\t}\n\n\tasync loadVideo(id: string): Promise<void> {\n\t\tthis.debug('loadVideo', id);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.loadVideo === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('loadVideo');\n\t\t}\n\n\t\tthis.debug('Loading video...');\n\n\t\tawait this.impl.loadVideo(id);\n\n\t\tthis.debug('video loaded', id);\n\t}\n\n\tplay(): Promise<void> {\n\t\tthis.debug('play');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.play === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('play');\n\t\t}\n\n\t\treturn this.impl.play();\n\t}\n\n\tpause(): Promise<void> {\n\t\tthis.debug('pause');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.pause === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('pause');\n\t\t}\n\n\t\treturn this.impl.pause();\n\t}\n\n\tsetCurrentTime(seconds: number): Promise<void> {\n\t\tthis.debug('setCurrentTime', seconds);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setCurrentTime === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setCurrentTime');\n\t\t}\n\n\t\treturn this.impl.setCurrentTime(seconds);\n\t}\n\n\tsetVolume(volume: number): Promise<void> {\n\t\tthis.debug('setVolume', volume);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setVolume === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setVolume');\n\t\t}\n\n\t\treturn this.impl.setVolume(volume);\n\t}\n\n\tsetMuted(muted: boolean): Promise<void> {\n\t\tthis.debug('setMuted', muted);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setMuted === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setMuted');\n\t\t}\n\n\t\treturn this.impl.setMuted(muted);\n\t}\n\n\tsetPlaybackRate(playbackRate: number): Promise<void> {\n\t\tthis.debug('setPlaybackRate', playbackRate);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setPlaybackRate === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setPlaybackRate');\n\t\t}\n\n\t\treturn this.impl.setPlaybackRate(playbackRate);\n\t}\n\n\tgetDuration(): Promise<number> {\n\t\tthis.debug('getDuration');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getDuration === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getDuration');\n\t\t}\n\n\t\treturn this.impl.getDuration();\n\t}\n\n\tgetCurrentTime(): Promise<number> {\n\t\tthis.debug('getCurrentTime');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getCurrentTime === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getCurrentTime');\n\t\t}\n\n\t\treturn this.impl.getCurrentTime();\n\t}\n\n\tgetVolume(): Promise<number> {\n\t\tthis.debug('getVolume');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getVolume === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getVolume');\n\t\t}\n\n\t\treturn this.impl.getVolume();\n\t}\n\n\tgetMuted(): Promise<boolean> {\n\t\tthis.debug('getMuted');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getMuted === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getMuted');\n\t\t}\n\n\t\treturn this.impl.getMuted();\n\t}\n\n\tgetPlaybackRate(): Promise<number> {\n\t\tthis.debug('getPlaybackRate');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getPlaybackRate === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getPlaybackRate');\n\t\t}\n\n\t\treturn this.impl.getPlaybackRate();\n\t}\n\n\tsupports(command: keyof IPlayerCommands): boolean {\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\treturn this.impl.supports(command);\n\t}\n}\n","import usePreviousDistinct from '@/components/usePreviousDistinct';\nimport { type ILogger, LogLevel } from '@/controllers/Logger';\nimport { nullPlayerController } from '@/controllers/NullPlayerController';\nimport {\n\ttype IPlayerController,\n\tPlayerController,\n\ttype PlayerOptions,\n\ttype PlayerType,\n} from '@/controllers/PlayerController';\nimport { PlayerControllerImpl } from '@/controllers/PlayerControllerImpl';\nimport {\n\ttype MutableRefObject,\n\ttype ReactElement,\n\ttype ReactNode,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nexport interface PlayerProps {\n\tlogger: ILogger;\n\ttype: PlayerType;\n\tonControllerChange: ((value: IPlayerController) => void) | undefined;\n\tvideoId: string;\n\toptions: PlayerOptions | undefined;\n}\n\ninterface PlayerContainerProps<\n\tTElement extends HTMLElement,\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n> extends PlayerProps {\n\tloadScript: (() => Promise<void>) | undefined;\n\tplayerFactory: (element: TElement, videoId: string) => Promise<TPlayer>;\n\tcontrollerFactory: new (\n\t\tlogger: ILogger,\n\t\tplayer: TPlayer,\n\t\toptions: PlayerOptions | undefined,\n\t) => TController;\n\tchildren: (\n\t\telementRef: MutableRefObject<TElement>,\n\t\tvideoId: string,\n\t) => ReactNode;\n}\n\nexport const PlayerContainer = <\n\tTElement extends HTMLElement,\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n>({\n\tlogger,\n\ttype,\n\tloadScript,\n\tplayerFactory,\n\tonControllerChange,\n\tvideoId,\n\toptions,\n\tcontrollerFactory,\n\tchildren,\n}: PlayerContainerProps<TElement, TPlayer, TController>): ReactElement<\n\tPlayerContainerProps<TElement, TPlayer, TController>\n> => {\n\tlogger.log(LogLevel.Debug, 'PlayerContainer');\n\n\tconst videoIdRef = useRef(videoId);\n\n\tconst elementRef = useRef<TElement>(undefined!);\n\n\tconst [player, setPlayer] = useState<TPlayer>();\n\n\tconst [controller, _setController] =\n\t\tuseState<IPlayerController>(nullPlayerController);\n\n\tconst setController = useCallback(\n\t\t(value: IPlayerController): void => {\n\t\t\t_setController(value);\n\n\t\t\tonControllerChange?.(value);\n\t\t},\n\t\t[onControllerChange],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid (loadScript?.() ?? Promise.resolve())\n\t\t\t.then(() => playerFactory(elementRef.current, videoIdRef.current))\n\t\t\t.then((player) => setPlayer(player));\n\t}, [loadScript, playerFactory]);\n\n\t// Make sure that `options` do not change between re-rendering.\n\tuseEffect(() => {\n\t\tif (player === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = new PlayerController(\n\t\t\tlogger,\n\t\t\ttype,\n\t\t\tplayer,\n\t\t\toptions,\n\t\t\tcontrollerFactory,\n\t\t);\n\n\t\tvoid controller\n\t\t\t.attach(videoIdRef.current)\n\t\t\t.then(() => setController(controller));\n\n\t\treturn (): void => {\n\t\t\tvoid controller\n\t\t\t\t.detach()\n\t\t\t\t.finally(() => setController(nullPlayerController));\n\t\t};\n\t}, [\n\t\tlogger,\n\t\ttype,\n\t\tloadScript,\n\t\tplayer,\n\t\toptions,\n\t\tcontrollerFactory,\n\t\tsetController,\n\t]);\n\n\tconst previousVideoId = usePreviousDistinct(videoId);\n\tuseEffect(() => {\n\t\t// If `previousVideoId` is undefined, then it means that the video has already been loaded by either\n\t\t// 1. `<audio>`s `src` attribute (e.g. `AudioPlayer`),\n\t\t// 2. `<iframe>`'s `src` attribute (e.g. `NiconicoPlayer`, `SoundCloudPlayer` and `VimeoPlayer`), or\n\t\t// 3. the `attach` method of the player API (e.g. `YouTubePlayer`).\n\t\tif (previousVideoId === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tvoid controller.loadVideo(videoId);\n\t}, [previousVideoId, videoId, controller]);\n\n\t// Make sure that `videoId` does not change between re-rendering.\n\treturn <>{children(elementRef, videoIdRef.current)}</>;\n};\n"],"mappings":"gFACA,IAAY,EAAL,SAAA,EAAA,OAKN,GAAA,EAAA,MAAA,GAAA,QAKA,EAAA,EAAA,MAAA,GAAA,QAIA,EAAA,EAAA,YAAA,GAAA,cAKA,EAAA,EAAA,QAAA,GAAA,UAKA,EAAA,EAAA,MAAA,GAAA,QAKA,EAAA,EAAA,SAAA,GAAA,WAIA,EAAA,EAAA,KAAA,GAAA,QACD,EAAA,CAAA,CAAA,EA8Ca,EAAgB,IAAI,KAtCD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W,QAAS,EAAW,OAAO,CAAC,EAChE,KAAM,GAAW,EAAU,CAAM,CAAC,CACrC,EAAG,CAAC,EAAY,CAAa,CAAC,GAG9B,EAAA,EAAA,eAAgB,CACf,GAAI,IAAW,IAAA,GACd,OAGD,IAAM,EAAa,IAAI,EACtB,EACA,EACA,EACA,EACA,CACD,EAMA,OAJA,EACE,OAAO,EAAW,OAAO,EACzB,SAAW,EAAc,CAAU,CAAC,MAEnB,CAClB,EACE,OAAO,EACP,YAAc,EAAc,CAAoB,CAAC,CACpD,CACD,EAAG,CACF,EACA,EACA,EACA,EACA,EACA,EACA,CACD,CAAC,EAED,IAAM,EAAkB,EAAoB,CAAO,EAcnD,OAbA,EAAA,EAAA,eAAgB,CAKX,IAAoB,IAAA,IAIxB,EAAgB,UAAU,CAAO,CAClC,EAAG,CAAC,EAAiB,EAAS,CAAU,CAAC,GAGlC,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAG,EAAS,EAAY,EAAW,OAAO,CAAI,CAAA,CACtD"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
import { Fragment as i, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
//#region src/controllers/Logger.ts
|
|
4
|
+
var o = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e[e.Trace = 0] = "Trace", e[e.Debug = 1] = "Debug", e[e.Information = 2] = "Information", e[e.Warning = 3] = "Warning", e[e.Error = 4] = "Error", e[e.Critical = 5] = "Critical", e[e.None = 6] = "None", e;
|
|
6
|
+
}({}), s = new class {
|
|
7
|
+
title = "nostalgic-diva";
|
|
8
|
+
createMessage(e) {
|
|
9
|
+
return `[${this.title}] ${e}`;
|
|
10
|
+
}
|
|
11
|
+
debug(e, ...t) {
|
|
12
|
+
console.debug(this.createMessage(e), ...t);
|
|
13
|
+
}
|
|
14
|
+
error(e, ...t) {
|
|
15
|
+
console.error(this.createMessage(e), ...t);
|
|
16
|
+
}
|
|
17
|
+
warn(e, ...t) {
|
|
18
|
+
console.warn(this.createMessage(e), ...t);
|
|
19
|
+
}
|
|
20
|
+
isEnabled() {
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
log(e, t, ...n) {
|
|
24
|
+
switch (e) {
|
|
25
|
+
case 1:
|
|
26
|
+
this.debug(t, ...n);
|
|
27
|
+
break;
|
|
28
|
+
case 3:
|
|
29
|
+
this.warn(t, ...n);
|
|
30
|
+
break;
|
|
31
|
+
case 4:
|
|
32
|
+
this.error(t, ...n);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}(), c = new class {
|
|
37
|
+
async attach() {}
|
|
38
|
+
async detach() {}
|
|
39
|
+
async loadVideo(e) {}
|
|
40
|
+
async play() {}
|
|
41
|
+
async pause() {}
|
|
42
|
+
async setCurrentTime(e) {}
|
|
43
|
+
async setVolume(e) {}
|
|
44
|
+
async setMuted(e) {}
|
|
45
|
+
async setPlaybackRate(e) {}
|
|
46
|
+
async getDuration() {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
async getCurrentTime() {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
async getVolume() {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
async getMuted() {
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
async getPlaybackRate() {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
supports(e) {
|
|
62
|
+
return !1;
|
|
63
|
+
}
|
|
64
|
+
}();
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/components/useFirstMountState.ts
|
|
67
|
+
function l() {
|
|
68
|
+
let e = n(!0);
|
|
69
|
+
return e.current ? (e.current = !1, !0) : e.current;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/components/usePreviousDistinct.ts
|
|
73
|
+
var u = (e, t) => e === t;
|
|
74
|
+
function d(e, t = u) {
|
|
75
|
+
let r = n(), i = n(e);
|
|
76
|
+
return !l() && !t(i.current, e) && (r.current = i.current, i.current = e), r.current;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/controllers/PlayerControllerImpl.ts
|
|
80
|
+
var f = class {
|
|
81
|
+
logger;
|
|
82
|
+
player;
|
|
83
|
+
options;
|
|
84
|
+
constructor(e, t, n) {
|
|
85
|
+
this.logger = e, this.player = t, this.options = n, this.logger.log(o.Debug, "ctor");
|
|
86
|
+
}
|
|
87
|
+
supports(e) {
|
|
88
|
+
return this[e] !== void 0;
|
|
89
|
+
}
|
|
90
|
+
}, p = class e {
|
|
91
|
+
logger;
|
|
92
|
+
type;
|
|
93
|
+
player;
|
|
94
|
+
options;
|
|
95
|
+
controllerFactory;
|
|
96
|
+
static nextId = 1;
|
|
97
|
+
id;
|
|
98
|
+
impl;
|
|
99
|
+
constructor(t, n, r, i, a) {
|
|
100
|
+
this.logger = t, this.type = n, this.player = r, this.options = i, this.controllerFactory = a, this.id = e.nextId++;
|
|
101
|
+
}
|
|
102
|
+
createMessage(e) {
|
|
103
|
+
return `${this.type}#${this.id} ${e}`;
|
|
104
|
+
}
|
|
105
|
+
debug(e, ...t) {
|
|
106
|
+
this.logger.log(o.Debug, this.createMessage(e), ...t);
|
|
107
|
+
}
|
|
108
|
+
error(e, ...t) {
|
|
109
|
+
this.logger.log(o.Error, this.createMessage(e), ...t);
|
|
110
|
+
}
|
|
111
|
+
async attach(e) {
|
|
112
|
+
if (this.debug("attach", e), this.impl) {
|
|
113
|
+
this.debug("player is already attached");
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.debug("Attaching player..."), this.impl = new this.controllerFactory(this.logger, this.player, this.options), await this.impl.attach(e), this.debug("player attached");
|
|
117
|
+
}
|
|
118
|
+
createPlayerNotAttachedError() {
|
|
119
|
+
return this.error("player is not attached"), /* @__PURE__ */ Error("player is not attached");
|
|
120
|
+
}
|
|
121
|
+
createCommandNotSupportedError(e) {
|
|
122
|
+
return /* @__PURE__ */ Error(`${e} is not supported`);
|
|
123
|
+
}
|
|
124
|
+
async detach() {
|
|
125
|
+
if (this.debug("detach"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
126
|
+
await this.impl.detach(), this.impl = void 0;
|
|
127
|
+
}
|
|
128
|
+
async loadVideo(e) {
|
|
129
|
+
if (this.debug("loadVideo", e), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
130
|
+
if (this.impl.loadVideo === void 0) throw this.createCommandNotSupportedError("loadVideo");
|
|
131
|
+
this.debug("Loading video..."), await this.impl.loadVideo(e), this.debug("video loaded", e);
|
|
132
|
+
}
|
|
133
|
+
play() {
|
|
134
|
+
if (this.debug("play"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
135
|
+
if (this.impl.play === void 0) throw this.createCommandNotSupportedError("play");
|
|
136
|
+
return this.impl.play();
|
|
137
|
+
}
|
|
138
|
+
pause() {
|
|
139
|
+
if (this.debug("pause"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
140
|
+
if (this.impl.pause === void 0) throw this.createCommandNotSupportedError("pause");
|
|
141
|
+
return this.impl.pause();
|
|
142
|
+
}
|
|
143
|
+
setCurrentTime(e) {
|
|
144
|
+
if (this.debug("setCurrentTime", e), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
145
|
+
if (this.impl.setCurrentTime === void 0) throw this.createCommandNotSupportedError("setCurrentTime");
|
|
146
|
+
return this.impl.setCurrentTime(e);
|
|
147
|
+
}
|
|
148
|
+
setVolume(e) {
|
|
149
|
+
if (this.debug("setVolume", e), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
150
|
+
if (this.impl.setVolume === void 0) throw this.createCommandNotSupportedError("setVolume");
|
|
151
|
+
return this.impl.setVolume(e);
|
|
152
|
+
}
|
|
153
|
+
setMuted(e) {
|
|
154
|
+
if (this.debug("setMuted", e), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
155
|
+
if (this.impl.setMuted === void 0) throw this.createCommandNotSupportedError("setMuted");
|
|
156
|
+
return this.impl.setMuted(e);
|
|
157
|
+
}
|
|
158
|
+
setPlaybackRate(e) {
|
|
159
|
+
if (this.debug("setPlaybackRate", e), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
160
|
+
if (this.impl.setPlaybackRate === void 0) throw this.createCommandNotSupportedError("setPlaybackRate");
|
|
161
|
+
return this.impl.setPlaybackRate(e);
|
|
162
|
+
}
|
|
163
|
+
getDuration() {
|
|
164
|
+
if (this.debug("getDuration"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
165
|
+
if (this.impl.getDuration === void 0) throw this.createCommandNotSupportedError("getDuration");
|
|
166
|
+
return this.impl.getDuration();
|
|
167
|
+
}
|
|
168
|
+
getCurrentTime() {
|
|
169
|
+
if (this.debug("getCurrentTime"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
170
|
+
if (this.impl.getCurrentTime === void 0) throw this.createCommandNotSupportedError("getCurrentTime");
|
|
171
|
+
return this.impl.getCurrentTime();
|
|
172
|
+
}
|
|
173
|
+
getVolume() {
|
|
174
|
+
if (this.debug("getVolume"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
175
|
+
if (this.impl.getVolume === void 0) throw this.createCommandNotSupportedError("getVolume");
|
|
176
|
+
return this.impl.getVolume();
|
|
177
|
+
}
|
|
178
|
+
getMuted() {
|
|
179
|
+
if (this.debug("getMuted"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
180
|
+
if (this.impl.getMuted === void 0) throw this.createCommandNotSupportedError("getMuted");
|
|
181
|
+
return this.impl.getMuted();
|
|
182
|
+
}
|
|
183
|
+
getPlaybackRate() {
|
|
184
|
+
if (this.debug("getPlaybackRate"), this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
185
|
+
if (this.impl.getPlaybackRate === void 0) throw this.createCommandNotSupportedError("getPlaybackRate");
|
|
186
|
+
return this.impl.getPlaybackRate();
|
|
187
|
+
}
|
|
188
|
+
supports(e) {
|
|
189
|
+
if (this.impl === void 0) throw this.createPlayerNotAttachedError();
|
|
190
|
+
return this.impl.supports(e);
|
|
191
|
+
}
|
|
192
|
+
}, m = ({ logger: s, type: l, loadScript: u, playerFactory: f, onControllerChange: m, videoId: h, options: g, controllerFactory: _, children: v }) => {
|
|
193
|
+
s.log(o.Debug, "PlayerContainer");
|
|
194
|
+
let y = n(h), b = n(void 0), [x, S] = r(), [C, w] = r(c), T = e((e) => {
|
|
195
|
+
w(e), m?.(e);
|
|
196
|
+
}, [m]);
|
|
197
|
+
t(() => {
|
|
198
|
+
(u?.() ?? Promise.resolve()).then(() => f(b.current, y.current)).then((e) => S(e));
|
|
199
|
+
}, [u, f]), t(() => {
|
|
200
|
+
if (x === void 0) return;
|
|
201
|
+
let e = new p(s, l, x, g, _);
|
|
202
|
+
return e.attach(y.current).then(() => T(e)), () => {
|
|
203
|
+
e.detach().finally(() => T(c));
|
|
204
|
+
};
|
|
205
|
+
}, [
|
|
206
|
+
s,
|
|
207
|
+
l,
|
|
208
|
+
u,
|
|
209
|
+
x,
|
|
210
|
+
g,
|
|
211
|
+
_,
|
|
212
|
+
T
|
|
213
|
+
]);
|
|
214
|
+
let E = d(h);
|
|
215
|
+
return t(() => {
|
|
216
|
+
E !== void 0 && C.loadVideo(h);
|
|
217
|
+
}, [
|
|
218
|
+
E,
|
|
219
|
+
h,
|
|
220
|
+
C
|
|
221
|
+
]), /* @__PURE__ */ a(i, { children: v(b, y.current) });
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
export { o as a, c as i, p as n, s as o, f as r, m as t };
|
|
225
|
+
|
|
226
|
+
//# sourceMappingURL=PlayerContainer-VQ3YPGU_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerContainer-VQ3YPGU_.js","names":[],"sources":["../src/controllers/Logger.ts","../src/controllers/NullPlayerController.ts","../src/components/useFirstMountState.ts","../src/components/usePreviousDistinct.ts","../src/controllers/PlayerControllerImpl.ts","../src/controllers/PlayerController.ts","../src/components/PlayerContainer.tsx"],"sourcesContent":["// https://source.dot.net/#Microsoft.Extensions.Logging.Abstractions/LogLevel.cs,d07793e8b722b77e,references\nexport enum LogLevel {\n\t/**\n\t * Logs that contain the most detailed messages. These messages may contain sensitive application data.\n\t * These messages are disabled by default and should never be enabled in a production environment.\n\t */\n\tTrace = 0,\n\t/**\n\t * Logs that are used for interactive investigation during development. These logs should primarily contain\n\t * information useful for debugging and have no long-term value.\n\t */\n\tDebug = 1,\n\t/**\n\t * Logs that track the general flow of the application. These logs should have long-term value.\n\t */\n\tInformation = 2,\n\t/**\n\t * Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the\n\t * application execution to stop.\n\t */\n\tWarning = 3,\n\t/**\n\t * Logs that highlight when the current flow of execution is stopped due to a failure. These should indicate a\n\t * failure in the current activity, not an application-wide failure.\n\t */\n\tError = 4,\n\t/**\n\t * Logs that describe an unrecoverable application or system crash, or a catastrophic failure that requires\n\t * immediate attention.\n\t */\n\tCritical = 5,\n\t/**\n\t * Not used for writing log messages. Specifies that a logging category should not write any messages.\n\t */\n\tNone = 6,\n}\n\n// https://source.dot.net/#Microsoft.Extensions.Logging.Abstractions/ILogger.cs,0976525f5d1b9e54,references\nexport interface ILogger {\n\tisEnabled(logLevel: LogLevel): boolean;\n\tlog(logLevel: LogLevel, message?: any, ...optionalParams: any[]): void;\n}\n\nclass Logger implements ILogger {\n\tprivate readonly title = 'nostalgic-diva';\n\n\tprivate createMessage(message: any): string {\n\t\treturn `[${this.title}] ${message}`;\n\t}\n\n\tprivate debug(message?: any, ...optionalParams: any): void {\n\t\tconsole.debug(this.createMessage(message), ...optionalParams);\n\t}\n\n\tprivate error(message?: any, ...optionalParams: any): void {\n\t\tconsole.error(this.createMessage(message), ...optionalParams);\n\t}\n\n\tprivate warn(message?: any, ...optionalParams: any): void {\n\t\tconsole.warn(this.createMessage(message), ...optionalParams);\n\t}\n\n\tisEnabled(): boolean {\n\t\treturn true;\n\t}\n\n\tlog(logLevel: LogLevel, message?: any, ...optionalParams: any[]): void {\n\t\tswitch (logLevel) {\n\t\t\tcase LogLevel.Debug:\n\t\t\t\tthis.debug(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t\tcase LogLevel.Warning:\n\t\t\t\tthis.warn(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t\tcase LogLevel.Error:\n\t\t\t\tthis.error(message, ...optionalParams);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport const defaultLogger = new Logger();\n","import type {\n\tIPlayerCommands,\n\tIPlayerController,\n} from '@/controllers/PlayerController';\n\nclass NullPlayerController implements IPlayerController {\n\tasync attach(): Promise<void> {}\n\n\tasync detach(): Promise<void> {}\n\n\tasync loadVideo(_id: string): Promise<void> {}\n\n\tasync play(): Promise<void> {}\n\n\tasync pause(): Promise<void> {}\n\n\tasync setCurrentTime(_seconds: number): Promise<void> {}\n\n\tasync setVolume(_volume: number): Promise<void> {}\n\n\tasync setMuted(_muted: boolean): Promise<void> {}\n\n\tasync setPlaybackRate(_playbackRate: number): Promise<void> {}\n\n\tasync getDuration(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getCurrentTime(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getVolume(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tasync getMuted(): Promise<boolean> {\n\t\treturn false;\n\t}\n\n\tasync getPlaybackRate(): Promise<number> {\n\t\treturn 0;\n\t}\n\n\tsupports(_command: keyof IPlayerCommands): boolean {\n\t\treturn false;\n\t}\n}\n\nexport const nullPlayerController = new NullPlayerController();\n","// https://github.com/streamich/react-use/blob/8ceb4c0f0c5625124f487b435a2fd0d3b3bc2a4f/src/useFirstMountState.ts\nimport { useRef } from 'react';\n\nexport function useFirstMountState(): boolean {\n\tconst isFirst = useRef(true);\n\n\tif (isFirst.current) {\n\t\tisFirst.current = false;\n\n\t\treturn true;\n\t}\n\n\treturn isFirst.current;\n}\n","// https://github.com/streamich/react-use/blob/8ceb4c0f0c5625124f487b435a2fd0d3b3bc2a4f/src/usePreviousDistinct.ts.\nimport { useFirstMountState } from '@/components/useFirstMountState';\nimport { useRef } from 'react';\n\nexport type Predicate<T> = (prev: T | undefined, next: T) => boolean;\n\nconst strictEquals = <T>(prev: T | undefined, next: T): boolean =>\n\tprev === next;\n\nexport default function usePreviousDistinct<T>(\n\tvalue: T,\n\tcompare: Predicate<T> = strictEquals,\n): T | undefined {\n\tconst prevRef = useRef<T>();\n\tconst curRef = useRef<T>(value);\n\tconst isFirstMount = useFirstMountState();\n\n\tif (!isFirstMount && !compare(curRef.current, value)) {\n\t\tprevRef.current = curRef.current;\n\t\tcurRef.current = value;\n\t}\n\n\treturn prevRef.current;\n}\n","import { type ILogger, LogLevel } from '@/controllers/Logger';\nimport type {\n\tIPlayerCommands,\n\tPlayerOptions,\n} from '@/controllers/PlayerController';\n\nexport abstract class PlayerControllerImpl<\n\tTPlayer,\n> implements Partial<IPlayerCommands> {\n\tconstructor(\n\t\tprotected readonly logger: ILogger,\n\t\tprotected readonly player: TPlayer,\n\t\tprotected readonly options: PlayerOptions | undefined,\n\t) {\n\t\tthis.logger.log(LogLevel.Debug, 'ctor');\n\t}\n\n\tabstract attach(id: string): Promise<void>;\n\tabstract detach(): Promise<void>;\n\tabstract loadVideo?(id: string): Promise<void>;\n\tabstract play?(): Promise<void>;\n\tabstract pause?(): Promise<void>;\n\tabstract setCurrentTime?(seconds: number): Promise<void>;\n\tabstract setVolume?(volume: number): Promise<void>;\n\tabstract setMuted?(muted: boolean): Promise<void>;\n\tabstract setPlaybackRate?(playbackRate: number): Promise<void>;\n\tabstract getDuration?(): Promise<number>;\n\tabstract getCurrentTime?(): Promise<number>;\n\tabstract getVolume?(): Promise<number>;\n\tabstract getMuted?(): Promise<boolean>;\n\tabstract getPlaybackRate?(): Promise<number>;\n\n\tsupports(command: keyof IPlayerCommands): boolean {\n\t\treturn this[command] !== undefined;\n\t}\n}\n","import { type ILogger, LogLevel } from '@/controllers/Logger';\nimport { PlayerControllerImpl } from '@/controllers/PlayerControllerImpl';\n\nexport type PlayerType =\n\t| 'Audio'\n\t| 'Dailymotion'\n\t| 'Niconico'\n\t| 'SoundCloud'\n\t| 'Twitch'\n\t| 'Vimeo'\n\t| 'YouTube'\n\t| (string & {});\n\nexport interface LoadedEvent {\n\tid: string;\n}\n\nexport interface TimeEvent {\n\tduration: number;\n\tpercent: number;\n\tseconds: number;\n}\n\nexport interface PlayerOptions {\n\tonError?(event: any): void;\n\tonLoaded?(event: LoadedEvent): void;\n\tonPlay?(): void;\n\tonPause?(): void;\n\tonEnded?(): void;\n\tonTimeUpdate?(event: TimeEvent): void;\n}\n\nexport interface IPlayerCommands {\n\tloadVideo(id: string): Promise<void>;\n\tplay(): Promise<void>;\n\tpause(): Promise<void>;\n\tsetCurrentTime(seconds: number): Promise<void>;\n\tsetVolume(volume: number): Promise<void>;\n\tsetMuted(muted: boolean): Promise<void>;\n\tsetPlaybackRate(playbackRate: number): Promise<void>;\n\tgetDuration(): Promise<number>;\n\tgetCurrentTime(): Promise<number>;\n\tgetVolume(): Promise<number>;\n\tgetMuted(): Promise<boolean>;\n\tgetPlaybackRate(): Promise<number>;\n}\n\nexport interface IPlayerController extends IPlayerCommands {\n\tsupports(command: keyof IPlayerCommands): boolean;\n}\n\nexport class PlayerController<\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n> implements IPlayerController {\n\tprivate static nextId = 1;\n\n\tprivate readonly id: number;\n\tprivate impl?: TController;\n\n\tconstructor(\n\t\tprivate readonly logger: ILogger,\n\t\tprivate readonly type: PlayerType,\n\t\tprivate readonly player: TPlayer,\n\t\tprivate readonly options: PlayerOptions | undefined,\n\t\tprivate readonly controllerFactory: new (\n\t\t\tlogger: ILogger,\n\t\t\tplayer: TPlayer,\n\t\t\toptions: PlayerOptions | undefined,\n\t\t) => TController,\n\t) {\n\t\tthis.id = PlayerController.nextId++;\n\t}\n\n\tprivate createMessage(message: any): string {\n\t\treturn `${this.type}#${this.id} ${message}`;\n\t}\n\n\tpublic debug(message?: any, ...optionalParams: any): void {\n\t\tthis.logger.log(\n\t\t\tLogLevel.Debug,\n\t\t\tthis.createMessage(message),\n\t\t\t...optionalParams,\n\t\t);\n\t}\n\n\tpublic error(message?: any, ...optionalParams: any): void {\n\t\tthis.logger.log(\n\t\t\tLogLevel.Error,\n\t\t\tthis.createMessage(message),\n\t\t\t...optionalParams,\n\t\t);\n\t}\n\n\tasync attach(id: string): Promise<void> {\n\t\tthis.debug('attach', id);\n\n\t\tif (this.impl) {\n\t\t\tthis.debug('player is already attached');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.debug('Attaching player...');\n\n\t\tthis.impl = new this.controllerFactory(\n\t\t\tthis.logger,\n\t\t\tthis.player,\n\t\t\tthis.options,\n\t\t);\n\n\t\tawait this.impl.attach(id);\n\n\t\tthis.debug('player attached');\n\t}\n\n\tprivate createPlayerNotAttachedError(): Error {\n\t\tthis.error('player is not attached');\n\n\t\treturn new Error('player is not attached');\n\t}\n\n\tprivate createCommandNotSupportedError(\n\t\tcommand: keyof IPlayerCommands,\n\t): Error {\n\t\treturn new Error(`${command} is not supported`);\n\t}\n\n\tasync detach(): Promise<void> {\n\t\tthis.debug('detach');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tawait this.impl.detach();\n\n\t\tthis.impl = undefined;\n\t}\n\n\tasync loadVideo(id: string): Promise<void> {\n\t\tthis.debug('loadVideo', id);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.loadVideo === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('loadVideo');\n\t\t}\n\n\t\tthis.debug('Loading video...');\n\n\t\tawait this.impl.loadVideo(id);\n\n\t\tthis.debug('video loaded', id);\n\t}\n\n\tplay(): Promise<void> {\n\t\tthis.debug('play');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.play === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('play');\n\t\t}\n\n\t\treturn this.impl.play();\n\t}\n\n\tpause(): Promise<void> {\n\t\tthis.debug('pause');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.pause === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('pause');\n\t\t}\n\n\t\treturn this.impl.pause();\n\t}\n\n\tsetCurrentTime(seconds: number): Promise<void> {\n\t\tthis.debug('setCurrentTime', seconds);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setCurrentTime === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setCurrentTime');\n\t\t}\n\n\t\treturn this.impl.setCurrentTime(seconds);\n\t}\n\n\tsetVolume(volume: number): Promise<void> {\n\t\tthis.debug('setVolume', volume);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setVolume === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setVolume');\n\t\t}\n\n\t\treturn this.impl.setVolume(volume);\n\t}\n\n\tsetMuted(muted: boolean): Promise<void> {\n\t\tthis.debug('setMuted', muted);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setMuted === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setMuted');\n\t\t}\n\n\t\treturn this.impl.setMuted(muted);\n\t}\n\n\tsetPlaybackRate(playbackRate: number): Promise<void> {\n\t\tthis.debug('setPlaybackRate', playbackRate);\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.setPlaybackRate === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('setPlaybackRate');\n\t\t}\n\n\t\treturn this.impl.setPlaybackRate(playbackRate);\n\t}\n\n\tgetDuration(): Promise<number> {\n\t\tthis.debug('getDuration');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getDuration === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getDuration');\n\t\t}\n\n\t\treturn this.impl.getDuration();\n\t}\n\n\tgetCurrentTime(): Promise<number> {\n\t\tthis.debug('getCurrentTime');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getCurrentTime === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getCurrentTime');\n\t\t}\n\n\t\treturn this.impl.getCurrentTime();\n\t}\n\n\tgetVolume(): Promise<number> {\n\t\tthis.debug('getVolume');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getVolume === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getVolume');\n\t\t}\n\n\t\treturn this.impl.getVolume();\n\t}\n\n\tgetMuted(): Promise<boolean> {\n\t\tthis.debug('getMuted');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getMuted === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getMuted');\n\t\t}\n\n\t\treturn this.impl.getMuted();\n\t}\n\n\tgetPlaybackRate(): Promise<number> {\n\t\tthis.debug('getPlaybackRate');\n\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\tif (this.impl.getPlaybackRate === undefined) {\n\t\t\tthrow this.createCommandNotSupportedError('getPlaybackRate');\n\t\t}\n\n\t\treturn this.impl.getPlaybackRate();\n\t}\n\n\tsupports(command: keyof IPlayerCommands): boolean {\n\t\tif (this.impl === undefined) {\n\t\t\tthrow this.createPlayerNotAttachedError();\n\t\t}\n\n\t\treturn this.impl.supports(command);\n\t}\n}\n","import usePreviousDistinct from '@/components/usePreviousDistinct';\nimport { type ILogger, LogLevel } from '@/controllers/Logger';\nimport { nullPlayerController } from '@/controllers/NullPlayerController';\nimport {\n\ttype IPlayerController,\n\tPlayerController,\n\ttype PlayerOptions,\n\ttype PlayerType,\n} from '@/controllers/PlayerController';\nimport { PlayerControllerImpl } from '@/controllers/PlayerControllerImpl';\nimport {\n\ttype MutableRefObject,\n\ttype ReactElement,\n\ttype ReactNode,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nexport interface PlayerProps {\n\tlogger: ILogger;\n\ttype: PlayerType;\n\tonControllerChange: ((value: IPlayerController) => void) | undefined;\n\tvideoId: string;\n\toptions: PlayerOptions | undefined;\n}\n\ninterface PlayerContainerProps<\n\tTElement extends HTMLElement,\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n> extends PlayerProps {\n\tloadScript: (() => Promise<void>) | undefined;\n\tplayerFactory: (element: TElement, videoId: string) => Promise<TPlayer>;\n\tcontrollerFactory: new (\n\t\tlogger: ILogger,\n\t\tplayer: TPlayer,\n\t\toptions: PlayerOptions | undefined,\n\t) => TController;\n\tchildren: (\n\t\telementRef: MutableRefObject<TElement>,\n\t\tvideoId: string,\n\t) => ReactNode;\n}\n\nexport const PlayerContainer = <\n\tTElement extends HTMLElement,\n\tTPlayer extends object,\n\tTController extends PlayerControllerImpl<TPlayer>,\n>({\n\tlogger,\n\ttype,\n\tloadScript,\n\tplayerFactory,\n\tonControllerChange,\n\tvideoId,\n\toptions,\n\tcontrollerFactory,\n\tchildren,\n}: PlayerContainerProps<TElement, TPlayer, TController>): ReactElement<\n\tPlayerContainerProps<TElement, TPlayer, TController>\n> => {\n\tlogger.log(LogLevel.Debug, 'PlayerContainer');\n\n\tconst videoIdRef = useRef(videoId);\n\n\tconst elementRef = useRef<TElement>(undefined!);\n\n\tconst [player, setPlayer] = useState<TPlayer>();\n\n\tconst [controller, _setController] =\n\t\tuseState<IPlayerController>(nullPlayerController);\n\n\tconst setController = useCallback(\n\t\t(value: IPlayerController): void => {\n\t\t\t_setController(value);\n\n\t\t\tonControllerChange?.(value);\n\t\t},\n\t\t[onControllerChange],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid (loadScript?.() ?? Promise.resolve())\n\t\t\t.then(() => playerFactory(elementRef.current, videoIdRef.current))\n\t\t\t.then((player) => setPlayer(player));\n\t}, [loadScript, playerFactory]);\n\n\t// Make sure that `options` do not change between re-rendering.\n\tuseEffect(() => {\n\t\tif (player === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = new PlayerController(\n\t\t\tlogger,\n\t\t\ttype,\n\t\t\tplayer,\n\t\t\toptions,\n\t\t\tcontrollerFactory,\n\t\t);\n\n\t\tvoid controller\n\t\t\t.attach(videoIdRef.current)\n\t\t\t.then(() => setController(controller));\n\n\t\treturn (): void => {\n\t\t\tvoid controller\n\t\t\t\t.detach()\n\t\t\t\t.finally(() => setController(nullPlayerController));\n\t\t};\n\t}, [\n\t\tlogger,\n\t\ttype,\n\t\tloadScript,\n\t\tplayer,\n\t\toptions,\n\t\tcontrollerFactory,\n\t\tsetController,\n\t]);\n\n\tconst previousVideoId = usePreviousDistinct(videoId);\n\tuseEffect(() => {\n\t\t// If `previousVideoId` is undefined, then it means that the video has already been loaded by either\n\t\t// 1. `<audio>`s `src` attribute (e.g. `AudioPlayer`),\n\t\t// 2. `<iframe>`'s `src` attribute (e.g. `NiconicoPlayer`, `SoundCloudPlayer` and `VimeoPlayer`), or\n\t\t// 3. the `attach` method of the player API (e.g. `YouTubePlayer`).\n\t\tif (previousVideoId === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tvoid controller.loadVideo(videoId);\n\t}, [previousVideoId, videoId, controller]);\n\n\t// Make sure that `videoId` does not change between re-rendering.\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;CAE5C,IAAM,IAAa,EAAO,CAAO,GAE3B,IAAa,EAAiB,KAAA,CAAU,GAExC,CAAC,GAAQ,KAAa,EAAkB,GAExC,CAAC,GAAY,KAClB,EAA4B,CAAoB,GAE3C,IAAgB,GACpB,MAAmC;EAGnC,AAFA,EAAe,CAAK,GAEpB,IAAqB,CAAK;CAC3B,GACA,CAAC,CAAkB,CACpB;CASA,AAPA,QAAgB;EACf,CAAM,IAAa,KAAK,QAAQ,QAAQ,GACtC,WAAW,EAAc,EAAW,SAAS,EAAW,OAAO,CAAC,EAChE,MAAM,MAAW,EAAU,CAAM,CAAC;CACrC,GAAG,CAAC,GAAY,CAAa,CAAC,GAG9B,QAAgB;EACf,IAAI,MAAW,KAAA,GACd;EAGD,IAAM,IAAa,IAAI,EACtB,GACA,GACA,GACA,GACA,CACD;EAMA,OAJA,EACE,OAAO,EAAW,OAAO,EACzB,WAAW,EAAc,CAAU,CAAC,SAEnB;GAClB,EACE,OAAO,EACP,cAAc,EAAc,CAAoB,CAAC;EACpD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CAED,IAAM,IAAkB,EAAoB,CAAO;CAcnD,OAbA,QAAgB;EAKX,MAAoB,KAAA,KAIxB,EAAgB,UAAU,CAAO;CAClC,GAAG;EAAC;EAAiB;EAAS;CAAU,CAAC,GAGlC,kBAAA,GAAA,EAAA,UAAG,EAAS,GAAY,EAAW,OAAO,EAAI,CAAA;AACtD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as e, t } from "./PlayerContainer-VQ3YPGU_.js";
|
|
2
|
+
import { SoundCloudPlayerController as n } from "./index.es.js";
|
|
3
|
+
import { t as r } from "./ensureScriptLoaded-CwERrTru.js";
|
|
4
|
+
import { memo as i, useCallback as a } from "react";
|
|
5
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/SoundCloudPlayer.tsx
|
|
7
|
+
var s = i(({ ...i }) => {
|
|
8
|
+
let { logger: s } = i;
|
|
9
|
+
s.log(e.Debug, "SoundCloudPlayer");
|
|
10
|
+
let c = a(async () => {
|
|
11
|
+
await r("https://w.soundcloud.com/player/api.js", s);
|
|
12
|
+
}, [s]), l = a((e) => Promise.resolve(SC.Widget(e)), []);
|
|
13
|
+
return /* @__PURE__ */ o(t, {
|
|
14
|
+
...i,
|
|
15
|
+
loadScript: c,
|
|
16
|
+
playerFactory: l,
|
|
17
|
+
controllerFactory: n,
|
|
18
|
+
children: (e, t) => /* @__PURE__ */ o("iframe", {
|
|
19
|
+
ref: e,
|
|
20
|
+
src: `https://w.soundcloud.com/player/?url=${t}`,
|
|
21
|
+
frameBorder: 0,
|
|
22
|
+
allow: "autoplay",
|
|
23
|
+
style: {
|
|
24
|
+
width: "100%",
|
|
25
|
+
height: "100%"
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { s as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=SoundCloudPlayer-Cqo5VU57.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SoundCloudPlayer-Cqo5VU57.js","names":[],"sources":["../src/components/SoundCloudPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { LogLevel } from '@/controllers/Logger';\nimport { SoundCloudPlayerController } from '@/controllers/SoundCloudPlayerController';\nimport { ensureScriptLoaded } from '@/controllers/ensureScriptLoaded';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst SoundCloudPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'SoundCloudPlayer');\n\n\tconst loadScript = useCallback(async () => {\n\t\tawait ensureScriptLoaded(\n\t\t\t'https://w.soundcloud.com/player/api.js',\n\t\t\tlogger,\n\t\t);\n\t}, [logger]);\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLIFrameElement): Promise<SC.SoundCloudWidget> => {\n\t\t\treturn Promise.resolve(SC.Widget(element));\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={loadScript}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={SoundCloudPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/iframe-has-title\n\t\t\t\t<iframe\n\t\t\t\t\tref={elementRef}\n\t\t\t\t\tsrc={`https://w.soundcloud.com/player/?url=${videoId}`}\n\t\t\t\t\tframeBorder={0}\n\t\t\t\t\tallow=\"autoplay\"\n\t\t\t\t\tstyle={{ width: '100%', height: '100%' }}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default SoundCloudPlayer;\n"],"mappings":";;;;;;AASA,IAAM,IAAmB,GAAM,EAAE,GAAG,QAAuC;CAC1E,IAAM,EAAE,cAAW;CAEnB,EAAO,IAAI,EAAS,OAAO,kBAAkB;CAE7C,IAAM,IAAa,EAAY,YAAY;EAC1C,MAAM,EACL,0CACA,CACD;CACD,GAAG,CAAC,CAAM,CAAC,GAEL,IAAgB,GACpB,MACO,QAAQ,QAAQ,GAAG,OAAO,CAAO,CAAC,GAE1C,CAAC,CACF;CAEA,OACC,kBAAC,GAAD;EACC,GAAI;EACQ;EACG;EACf,mBAAmB;aAEjB,GAAY,MAEb,kBAAC,UAAD;GACC,KAAK;GACL,KAAK,wCAAwC;GAC7C,aAAa;GACb,OAAM;GACN,OAAO;IAAE,OAAO;IAAQ,QAAQ;GAAO;EACvC,CAAA;CAEc,CAAA;AAEnB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./PlayerContainer-COjwHOhq.cjs`),t=require(`./index.cjs.js`),n=require(`./ensureScriptLoaded-BoubPl5C.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);var a=(0,r.memo)(({...a})=>{let{logger:o}=a;o.log(e.a.Debug,`SoundCloudPlayer`);let s=(0,r.useCallback)(async()=>{await n.t(`https://w.soundcloud.com/player/api.js`,o)},[o]),c=(0,r.useCallback)(e=>Promise.resolve(SC.Widget(e)),[]);return(0,i.jsx)(e.t,{...a,loadScript:s,playerFactory:c,controllerFactory:t.SoundCloudPlayerController,children:(e,t)=>(0,i.jsx)(`iframe`,{ref:e,src:`https://w.soundcloud.com/player/?url=${t}`,frameBorder:0,allow:`autoplay`,style:{width:`100%`,height:`100%`}})})});exports.default=a;
|
|
2
|
+
//# sourceMappingURL=SoundCloudPlayer-tHiueAss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SoundCloudPlayer-tHiueAss.cjs","names":[],"sources":["../src/components/SoundCloudPlayer.tsx"],"sourcesContent":["import {\n\tPlayerContainer,\n\ttype PlayerProps,\n} from '@/components/PlayerContainer';\nimport { LogLevel } from '@/controllers/Logger';\nimport { SoundCloudPlayerController } from '@/controllers/SoundCloudPlayerController';\nimport { ensureScriptLoaded } from '@/controllers/ensureScriptLoaded';\nimport { type ReactElement, memo, useCallback } from 'react';\n\nconst SoundCloudPlayer = memo(({ ...props }: PlayerProps): ReactElement => {\n\tconst { logger } = props;\n\n\tlogger.log(LogLevel.Debug, 'SoundCloudPlayer');\n\n\tconst loadScript = useCallback(async () => {\n\t\tawait ensureScriptLoaded(\n\t\t\t'https://w.soundcloud.com/player/api.js',\n\t\t\tlogger,\n\t\t);\n\t}, [logger]);\n\n\tconst playerFactory = useCallback(\n\t\t(element: HTMLIFrameElement): Promise<SC.SoundCloudWidget> => {\n\t\t\treturn Promise.resolve(SC.Widget(element));\n\t\t},\n\t\t[],\n\t);\n\n\treturn (\n\t\t<PlayerContainer\n\t\t\t{...props}\n\t\t\tloadScript={loadScript}\n\t\t\tplayerFactory={playerFactory}\n\t\t\tcontrollerFactory={SoundCloudPlayerController}\n\t\t>\n\t\t\t{(elementRef, videoId): ReactElement => (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/iframe-has-title\n\t\t\t\t<iframe\n\t\t\t\t\tref={elementRef}\n\t\t\t\t\tsrc={`https://w.soundcloud.com/player/?url=${videoId}`}\n\t\t\t\t\tframeBorder={0}\n\t\t\t\t\tallow=\"autoplay\"\n\t\t\t\t\tstyle={{ width: '100%', height: '100%' }}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</PlayerContainer>\n\t);\n});\n\nexport default SoundCloudPlayer;\n"],"mappings":"mLASA,IAAM,GAAA,EAAA,EAAA,OAAyB,CAAE,GAAG,KAAuC,CAC1E,GAAM,CAAE,UAAW,EAEnB,EAAO,IAAI,EAAA,EAAS,MAAO,kBAAkB,EAE7C,IAAM,GAAA,EAAA,EAAA,aAAyB,SAAY,CAC1C,MAAM,EAAA,EACL,yCACA,CACD,CACD,EAAG,CAAC,CAAM,CAAC,EAEL,GAAA,EAAA,EAAA,aACJ,GACO,QAAQ,QAAQ,GAAG,OAAO,CAAO,CAAC,EAE1C,CAAC,CACF,EAEA,OACC,EAAA,EAAA,KAAC,EAAA,EAAD,CACC,GAAI,EACQ,aACG,gBACf,kBAAmB,EAAA,qCAEjB,EAAY,KAEb,EAAA,EAAA,KAAC,SAAD,CACC,IAAK,EACL,IAAK,wCAAwC,IAC7C,YAAa,EACb,MAAM,WACN,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,CACvC,CAAA,CAEc,CAAA,CAEnB,CAAC"}
|