iconly 1.1.1 → 1.2.0
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/index.js +17 -21
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +17 -21
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +22 -30
package/dist/index.js
CHANGED
|
@@ -13,42 +13,38 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 {
|
|
|
13
13
|
this.options = {
|
|
14
14
|
...options
|
|
15
15
|
};
|
|
16
|
-
this.isLocalStorage =
|
|
16
|
+
this.isLocalStorage = typeof window.localStorage !== "undefined";
|
|
17
17
|
this.body = document.body;
|
|
18
18
|
this.init().then();
|
|
19
19
|
}
|
|
20
20
|
async init() {
|
|
21
21
|
const { file: file } = this.options;
|
|
22
|
-
if (document.querySelector("#iconset")) return;
|
|
23
22
|
if (this.isLocalStorage) {
|
|
24
23
|
const storedSize = localStorage.getItem("inlineSVGsize");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error("There was a problem with the network fetch operation:", error);
|
|
24
|
+
const storedData = localStorage.getItem("inlineSVGdata");
|
|
25
|
+
const response = await fetch(file);
|
|
26
|
+
if (!response.ok) throw new Error("Network response was not ok");
|
|
27
|
+
const data = await response.text();
|
|
28
|
+
if (storedSize && storedSize === data.length.toString()) this.insert(storedData);
|
|
29
|
+
else {
|
|
30
|
+
this.insert(data);
|
|
31
|
+
localStorage.setItem("inlineSVGdata", data);
|
|
32
|
+
localStorage.setItem("inlineSVGsize", data.length.toString());
|
|
37
33
|
}
|
|
38
|
-
} else
|
|
34
|
+
} else {
|
|
39
35
|
const response = await fetch(file);
|
|
40
36
|
if (!response.ok) throw new Error("Network response was not ok");
|
|
41
37
|
const data = await response.text();
|
|
42
38
|
this.insert(data);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error("There was a problem with the network fetch operation:", error);
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
41
|
insert(data) {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
if (!document.getElementById("iconset")) {
|
|
43
|
+
if (this.body) this.body.insertAdjacentHTML("beforeend", data);
|
|
44
|
+
else document.addEventListener("DOMContentLoaded", ()=>{
|
|
45
|
+
this.body.insertAdjacentHTML("beforeend", data);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,OAAO,OAAO,iBAAiB;QACrD,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO;iBACN;gBACN,IAAI,CAAC,OAAO;gBAEZ,aAAa,QAAQ,iBAAiB;gBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;YACnD;QACD,OAAO;YACN,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb;IACD;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,CAAC,SAAS,eAAe;YAC5B,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;iBAE1C,SAAS,iBAAiB,oBAAoB;gBAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;YAC3C;;IAGH;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { ...options }\r\n\t\tthis.isLocalStorage = typeof window.localStorage !== 'undefined'\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\t\t\tconst storedData = localStorage.getItem('inlineSVGdata')\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\tthis.insert(storedData)\r\n\t\t\t} else {\r\n\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tthis.insert(data)\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (!document.getElementById('iconset')) {\r\n\t\t\tif (this.body) {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t} else {\r\n\t\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -3,42 +3,38 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 {
|
|
|
3
3
|
this.options = {
|
|
4
4
|
...options
|
|
5
5
|
};
|
|
6
|
-
this.isLocalStorage =
|
|
6
|
+
this.isLocalStorage = typeof window.localStorage !== "undefined";
|
|
7
7
|
this.body = document.body;
|
|
8
8
|
this.init().then();
|
|
9
9
|
}
|
|
10
10
|
async init() {
|
|
11
11
|
const { file: file } = this.options;
|
|
12
|
-
if (document.querySelector("#iconset")) return;
|
|
13
12
|
if (this.isLocalStorage) {
|
|
14
13
|
const storedSize = localStorage.getItem("inlineSVGsize");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error("There was a problem with the network fetch operation:", error);
|
|
14
|
+
const storedData = localStorage.getItem("inlineSVGdata");
|
|
15
|
+
const response = await fetch(file);
|
|
16
|
+
if (!response.ok) throw new Error("Network response was not ok");
|
|
17
|
+
const data = await response.text();
|
|
18
|
+
if (storedSize && storedSize === data.length.toString()) this.insert(storedData);
|
|
19
|
+
else {
|
|
20
|
+
this.insert(data);
|
|
21
|
+
localStorage.setItem("inlineSVGdata", data);
|
|
22
|
+
localStorage.setItem("inlineSVGsize", data.length.toString());
|
|
27
23
|
}
|
|
28
|
-
} else
|
|
24
|
+
} else {
|
|
29
25
|
const response = await fetch(file);
|
|
30
26
|
if (!response.ok) throw new Error("Network response was not ok");
|
|
31
27
|
const data = await response.text();
|
|
32
28
|
this.insert(data);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error("There was a problem with the network fetch operation:", error);
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
insert(data) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
if (!document.getElementById("iconset")) {
|
|
33
|
+
if (this.body) this.body.insertAdjacentHTML("beforeend", data);
|
|
34
|
+
else document.addEventListener("DOMContentLoaded", ()=>{
|
|
35
|
+
this.body.insertAdjacentHTML("beforeend", data);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,
|
|
1
|
+
{"mappings":"AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,OAAO,OAAO,iBAAiB;QACrD,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO;iBACN;gBACN,IAAI,CAAC,OAAO;gBAEZ,aAAa,QAAQ,iBAAiB;gBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;YACnD;QACD,OAAO;YACN,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb;IACD;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,CAAC,SAAS,eAAe;YAC5B,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;iBAE1C,SAAS,iBAAiB,oBAAoB;gBAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;YAC3C;;IAGH;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { ...options }\r\n\t\tthis.isLocalStorage = typeof window.localStorage !== 'undefined'\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\t\t\tconst storedData = localStorage.getItem('inlineSVGdata')\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\tthis.insert(storedData)\r\n\t\t\t} else {\r\n\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tthis.insert(data)\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (!document.getElementById('iconset')) {\r\n\t\t\tif (this.body) {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t} else {\r\n\t\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default class Iconly {
|
|
2
2
|
constructor(options) {
|
|
3
3
|
this.options = { ...options }
|
|
4
|
-
this.isLocalStorage =
|
|
4
|
+
this.isLocalStorage = typeof window.localStorage !== 'undefined'
|
|
5
5
|
this.body = document.body
|
|
6
6
|
|
|
7
7
|
this.init().then()
|
|
@@ -10,51 +10,43 @@ export default class Iconly {
|
|
|
10
10
|
async init() {
|
|
11
11
|
const { file } = this.options
|
|
12
12
|
|
|
13
|
-
if (document.querySelector('#iconset')) return
|
|
14
|
-
|
|
15
13
|
if (this.isLocalStorage) {
|
|
16
14
|
const storedSize = localStorage.getItem('inlineSVGsize')
|
|
15
|
+
const storedData = localStorage.getItem('inlineSVGdata')
|
|
16
|
+
const response = await fetch(file)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const response = await fetch(file)
|
|
20
|
-
|
|
21
|
-
if (!response.ok) throw new Error('Network response was not ok')
|
|
18
|
+
if (!response.ok) throw new Error('Network response was not ok')
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
const data = await response.text()
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
if (storedSize && storedSize === data.length.toString()) {
|
|
23
|
+
this.insert(storedData)
|
|
24
|
+
} else {
|
|
25
|
+
this.insert(data)
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('There was a problem with the network fetch operation:', error)
|
|
27
|
+
localStorage.setItem('inlineSVGdata', data)
|
|
28
|
+
localStorage.setItem('inlineSVGsize', data.length.toString())
|
|
35
29
|
}
|
|
36
30
|
} else {
|
|
37
|
-
|
|
38
|
-
const response = await fetch(file)
|
|
31
|
+
const response = await fetch(file)
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
if (!response.ok) throw new Error('Network response was not ok')
|
|
41
34
|
|
|
42
|
-
|
|
35
|
+
const data = await response.text()
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error('There was a problem with the network fetch operation:', error)
|
|
47
|
-
}
|
|
37
|
+
this.insert(data)
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
insert(data) {
|
|
52
|
-
if (
|
|
53
|
-
this.body
|
|
54
|
-
} else {
|
|
55
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
42
|
+
if (!document.getElementById('iconset')) {
|
|
43
|
+
if (this.body) {
|
|
56
44
|
this.body.insertAdjacentHTML('beforeend', data)
|
|
57
|
-
}
|
|
45
|
+
} else {
|
|
46
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
47
|
+
this.body.insertAdjacentHTML('beforeend', data)
|
|
48
|
+
})
|
|
49
|
+
}
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
}
|