@symbo.ls/utils 2.11.410 → 2.11.417
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/cjs/codify.js +3 -3
- package/dist/cjs/index.js +21 -5
- package/dist/cjs/load.js +19 -3
- package/package.json +2 -2
- package/src/load.js +18 -2
package/dist/cjs/codify.js
CHANGED
|
@@ -133,13 +133,13 @@ var require_globals = __commonJS({
|
|
|
133
133
|
document: () => document2,
|
|
134
134
|
global: () => global,
|
|
135
135
|
self: () => self,
|
|
136
|
-
window: () =>
|
|
136
|
+
window: () => window2
|
|
137
137
|
});
|
|
138
138
|
module2.exports = __toCommonJS2(globals_exports);
|
|
139
139
|
var global = globalThis;
|
|
140
140
|
var self = globalThis;
|
|
141
|
-
var
|
|
142
|
-
var document2 =
|
|
141
|
+
var window2 = globalThis;
|
|
142
|
+
var document2 = window2.document;
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -133,13 +133,13 @@ var require_globals = __commonJS({
|
|
|
133
133
|
document: () => document2,
|
|
134
134
|
global: () => global,
|
|
135
135
|
self: () => self,
|
|
136
|
-
window: () =>
|
|
136
|
+
window: () => window2
|
|
137
137
|
});
|
|
138
138
|
module2.exports = __toCommonJS2(globals_exports);
|
|
139
139
|
var global = globalThis;
|
|
140
140
|
var self = globalThis;
|
|
141
|
-
var
|
|
142
|
-
var document2 =
|
|
141
|
+
var window2 = globalThis;
|
|
142
|
+
var document2 = window2.document;
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
|
|
@@ -1525,6 +1525,7 @@ __export(src_exports, {
|
|
|
1525
1525
|
loadCssFile: () => loadCssFile,
|
|
1526
1526
|
loadJavascript: () => loadJavascript,
|
|
1527
1527
|
loadJavascriptFile: () => loadJavascriptFile,
|
|
1528
|
+
loadJavascriptFileSync: () => loadJavascriptFileSync,
|
|
1528
1529
|
removeChars: () => removeChars,
|
|
1529
1530
|
toCamelCase: () => toCamelCase,
|
|
1530
1531
|
toDashCase: () => toDashCase,
|
|
@@ -1594,10 +1595,10 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
|
|
|
1594
1595
|
});
|
|
1595
1596
|
});
|
|
1596
1597
|
scriptEle.addEventListener("error", (ev) => {
|
|
1597
|
-
reject({
|
|
1598
|
+
reject(new Error({
|
|
1598
1599
|
status: false,
|
|
1599
1600
|
message: `Failed to load the script ${FILE_URL}`
|
|
1600
|
-
});
|
|
1601
|
+
}));
|
|
1601
1602
|
});
|
|
1602
1603
|
doc.body.appendChild(scriptEle);
|
|
1603
1604
|
} catch (error) {
|
|
@@ -1605,6 +1606,21 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
|
|
|
1605
1606
|
}
|
|
1606
1607
|
});
|
|
1607
1608
|
};
|
|
1609
|
+
var loadJavascriptFileSync = (FILE_URL, doc = document, fallback, type = "text/javascript") => {
|
|
1610
|
+
const xhr = new window.XMLHttpRequest();
|
|
1611
|
+
xhr.open("GET", FILE_URL, false);
|
|
1612
|
+
xhr.send();
|
|
1613
|
+
if (xhr.status === 200) {
|
|
1614
|
+
const scriptEle = doc.createElement("script");
|
|
1615
|
+
scriptEle.type = type;
|
|
1616
|
+
scriptEle.text = xhr.responseText;
|
|
1617
|
+
doc.body.appendChild(scriptEle);
|
|
1618
|
+
if (typeof fallback === "function")
|
|
1619
|
+
fallback();
|
|
1620
|
+
} else {
|
|
1621
|
+
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1608
1624
|
var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
|
|
1609
1625
|
return new Promise((resolve, reject) => {
|
|
1610
1626
|
try {
|
package/dist/cjs/load.js
CHANGED
|
@@ -22,7 +22,8 @@ var load_exports = {};
|
|
|
22
22
|
__export(load_exports, {
|
|
23
23
|
loadCssFile: () => loadCssFile,
|
|
24
24
|
loadJavascript: () => loadJavascript,
|
|
25
|
-
loadJavascriptFile: () => loadJavascriptFile
|
|
25
|
+
loadJavascriptFile: () => loadJavascriptFile,
|
|
26
|
+
loadJavascriptFileSync: () => loadJavascriptFileSync
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(load_exports);
|
|
28
29
|
var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
|
|
@@ -38,10 +39,10 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
|
|
|
38
39
|
});
|
|
39
40
|
});
|
|
40
41
|
scriptEle.addEventListener("error", (ev) => {
|
|
41
|
-
reject({
|
|
42
|
+
reject(new Error({
|
|
42
43
|
status: false,
|
|
43
44
|
message: `Failed to load the script ${FILE_URL}`
|
|
44
|
-
});
|
|
45
|
+
}));
|
|
45
46
|
});
|
|
46
47
|
doc.body.appendChild(scriptEle);
|
|
47
48
|
} catch (error) {
|
|
@@ -49,6 +50,21 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
|
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
};
|
|
53
|
+
var loadJavascriptFileSync = (FILE_URL, doc = document, fallback, type = "text/javascript") => {
|
|
54
|
+
const xhr = new window.XMLHttpRequest();
|
|
55
|
+
xhr.open("GET", FILE_URL, false);
|
|
56
|
+
xhr.send();
|
|
57
|
+
if (xhr.status === 200) {
|
|
58
|
+
const scriptEle = doc.createElement("script");
|
|
59
|
+
scriptEle.type = type;
|
|
60
|
+
scriptEle.text = xhr.responseText;
|
|
61
|
+
doc.body.appendChild(scriptEle);
|
|
62
|
+
if (typeof fallback === "function")
|
|
63
|
+
fallback();
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(`Failed to load the script ${FILE_URL}`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
52
68
|
var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
|
|
53
69
|
return new Promise((resolve, reject) => {
|
|
54
70
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/utils",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.417",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@domql/utils": "latest"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d3f5ad50e57320d72c7d50bc0309f3308e6b8ff2"
|
|
30
30
|
}
|
package/src/load.js
CHANGED
|
@@ -15,10 +15,10 @@ export const loadJavascriptFile = (FILE_URL, async = false, doc = document, type
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
scriptEle.addEventListener('error', (ev) => {
|
|
18
|
-
reject({
|
|
18
|
+
reject(new Error({
|
|
19
19
|
status: false,
|
|
20
20
|
message: `Failed to load the script ${FILE_URL}`
|
|
21
|
-
})
|
|
21
|
+
}))
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
doc.body.appendChild(scriptEle)
|
|
@@ -28,6 +28,22 @@ export const loadJavascriptFile = (FILE_URL, async = false, doc = document, type
|
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export const loadJavascriptFileSync = (FILE_URL, doc = document, fallback, type = 'text/javascript') => {
|
|
32
|
+
const xhr = new window.XMLHttpRequest()
|
|
33
|
+
xhr.open('GET', FILE_URL, false) // false makes the request synchronous
|
|
34
|
+
xhr.send()
|
|
35
|
+
|
|
36
|
+
if (xhr.status === 200) {
|
|
37
|
+
const scriptEle = doc.createElement('script')
|
|
38
|
+
scriptEle.type = type
|
|
39
|
+
scriptEle.text = xhr.responseText
|
|
40
|
+
doc.body.appendChild(scriptEle)
|
|
41
|
+
if (typeof fallback === 'function') fallback()
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error(`Failed to load the script ${FILE_URL}`)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
export const loadCssFile = (FILE_URL, async = false, doc = document, type = 'text/javascript') => {
|
|
32
48
|
return new Promise((resolve, reject) => {
|
|
33
49
|
try {
|