UNPKG

@aigamo/nostalgic-diva

Version:

React function components for imperatively controlling embedded players (audio, Niconico, SoundCloud and YouTube) using refs.

3 lines (2 loc) 802 B
"use strict";const n=require("./index-vLjOJb_8.cjs");function d(e){return new Promise((o,a)=>{const t=document.createElement("script");t.src=e,t.async=!0,t.onerror=a,t.onload=t.onreadystatechange=function(){const r=this.readyState;r&&r!=="loaded"&&r!=="complete"||(t.onload=t.onreadystatechange=null,o())},document.head.appendChild(t)})}const c=[];async function s(e,o){if(c.includes(e))return o.log(n.LogLevel.Debug,e,"script is already loaded"),!1;try{return o.log(n.LogLevel.Debug,e,"Loading script..."),await d(e),c.includes(e)?(o.log(n.LogLevel.Debug,e,"script is already loaded"),!1):(c.push(e),o.log(n.LogLevel.Debug,e,"script loaded"),!0)}catch(a){throw o.log(n.LogLevel.Error,e,"Failed to load script"),a}}exports.ensureScriptLoaded=s; //# sourceMappingURL=ensureScriptLoaded-CzpKHcV0.cjs.map