@mirai/core 0.4.78 → 0.4.79
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.
|
@@ -11,8 +11,7 @@ const loadScript = function () {
|
|
|
11
11
|
id,
|
|
12
12
|
inline,
|
|
13
13
|
src,
|
|
14
|
-
onLoad = () => {}
|
|
15
|
-
...others
|
|
14
|
+
onLoad = () => {}
|
|
16
15
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17
16
|
return new Promise((resolve, reject) => {
|
|
18
17
|
const scriptId = "".concat(domain, "-").concat(id);
|
|
@@ -21,7 +20,8 @@ const loadScript = function () {
|
|
|
21
20
|
const script = document.createElement('script');
|
|
22
21
|
script.id = scriptId;
|
|
23
22
|
script.async = async;
|
|
24
|
-
Object.keys(others || {}).forEach(key => script[key] = others[key]);
|
|
23
|
+
// Object.keys(others || {}).forEach((key) => (script[key] = others[key]));
|
|
24
|
+
|
|
25
25
|
if (src) script.src = src;else if (inline) script.textContent = inline;
|
|
26
26
|
script.onerror = error => reject(error);
|
|
27
27
|
script.onload = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.js","names":["loadScript","async","domain","id","inline","src","onLoad","
|
|
1
|
+
{"version":3,"file":"loadScript.js","names":["loadScript","async","domain","id","inline","src","onLoad","arguments","length","undefined","Promise","resolve","reject","scriptId","concat","exists","document","getElementById","script","createElement","textContent","onerror","error","onload","inlineScript","head","appendChild","console","log","el","parentNode","removeChild","exports"],"sources":["../../src/helpers/loadScript.js"],"sourcesContent":["export const loadScript = ({ async = true, domain = 'mirai', id, inline, src, onLoad = () => {} } = {}) =>\n new Promise((resolve, reject) => {\n const scriptId = `${domain}-${id}`;\n const exists = document.getElementById(scriptId);\n\n if ((!inline && !src) || exists) return resolve();\n\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = async;\n // Object.keys(others || {}).forEach((key) => (script[key] = others[key]));\n\n if (src) script.src = src;\n else if (inline) script.textContent = inline;\n\n script.onerror = (error) => reject(error);\n\n script.onload = () => {\n if (src && inline) {\n const inlineScript = document.createElement('script');\n inlineScript.textContent = inline;\n document.head.appendChild(inlineScript);\n }\n\n onLoad();\n // eslint-disable-next-line no-console\n if (src) console.log(`📜 <script ${scriptId} ${src ? `src=${src} ` : ''}/>`);\n\n resolve(() => {\n const el = document.getElementById(scriptId);\n if (el) el.parentNode.removeChild(el);\n });\n };\n\n document.head.appendChild(script);\n });\n"],"mappings":";;;;;;AAAO,MAAMA,UAAU,GAAG,SAAAA,CAAA;EAAA,IAAC;IAAEC,KAAK,GAAG,IAAI;IAAEC,MAAM,GAAG,OAAO;IAAEC,EAAE;IAAEC,MAAM;IAAEC,GAAG;IAAEC,MAAM,GAAGA,CAAA,KAAM,CAAC;EAAE,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAAA,OACpG,IAAIG,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC/B,MAAMC,QAAQ,MAAAC,MAAA,CAAMZ,MAAM,OAAAY,MAAA,CAAIX,EAAE,CAAE;IAClC,MAAMY,MAAM,GAAGC,QAAQ,CAACC,cAAc,CAACJ,QAAQ,CAAC;IAEhD,IAAK,CAACT,MAAM,IAAI,CAACC,GAAG,IAAKU,MAAM,EAAE,OAAOJ,OAAO,CAAC,CAAC;IAEjD,MAAMO,MAAM,GAAGF,QAAQ,CAACG,aAAa,CAAC,QAAQ,CAAC;IAC/CD,MAAM,CAACf,EAAE,GAAGU,QAAQ;IACpBK,MAAM,CAACjB,KAAK,GAAGA,KAAK;IACpB;;IAEA,IAAII,GAAG,EAAEa,MAAM,CAACb,GAAG,GAAGA,GAAG,CAAC,KACrB,IAAID,MAAM,EAAEc,MAAM,CAACE,WAAW,GAAGhB,MAAM;IAE5Cc,MAAM,CAACG,OAAO,GAAIC,KAAK,IAAKV,MAAM,CAACU,KAAK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