UNPKG

@aigamo/nostalgic-diva

Version:

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

25 lines (24 loc) 880 B
import { L as o } from "./index-DzXJDFxB.js"; function c(e) { return new Promise((a, n) => { const t = document.createElement("script"); t.src = e, t.async = !0, t.onerror = n, t.onload = t.onreadystatechange = function() { const r = this.readyState; r && r !== "loaded" && r !== "complete" || (t.onload = t.onreadystatechange = null, a()); }, document.head.appendChild(t); }); } const s = []; async function i(e, a) { if (s.includes(e)) return a.log(o.Debug, e, "script is already loaded"), !1; try { return a.log(o.Debug, e, "Loading script..."), await c(e), s.includes(e) ? (a.log(o.Debug, e, "script is already loaded"), !1) : (s.push(e), a.log(o.Debug, e, "script loaded"), !0); } catch (n) { throw a.log(o.Error, e, "Failed to load script"), n; } } export { i as e }; //# sourceMappingURL=ensureScriptLoaded-C7IsEn-U.js.map