vite-plugin-svg-sprite 0.4.0 → 0.5.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/cjs/runtime.d.ts +2 -1
- package/cjs/runtime.js +25 -20
- package/esm/runtime.d.ts +2 -1
- package/esm/runtime.js +25 -19
- package/package.json +1 -1
- package/src/runtime.ts +26 -18
package/cjs/runtime.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: (symbol: string, id: string) => void;
|
|
2
|
+
export default _default;
|
package/cjs/runtime.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
function createAddSymbol() {
|
|
4
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
5
|
+
return () => { };
|
|
6
|
+
}
|
|
7
|
+
const idSet = window._SVG_SPRITE_IDS_ = window._SVG_SPRITE_IDS_ || [];
|
|
8
|
+
const root = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
9
|
+
root.style.position = 'absolute';
|
|
10
|
+
root.style.width = '0';
|
|
11
|
+
root.style.height = '0';
|
|
12
|
+
function insertRoot() {
|
|
13
|
+
document.body.insertBefore(root, document.body.firstChild);
|
|
14
|
+
}
|
|
15
|
+
if (document.readyState === 'loading') {
|
|
16
|
+
document.addEventListener('DOMContentLoaded', insertRoot);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
insertRoot();
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return function addSymbol(symbol, id) {
|
|
22
|
+
if (idSet.indexOf(id) > -1 || document.getElementById(id)) {
|
|
23
|
+
console.warn(`Icon #${id} was duplicately registered. It must be globally unique.`);
|
|
24
|
+
}
|
|
25
|
+
idSet.push(id);
|
|
26
|
+
root.insertAdjacentHTML('beforeend', symbol);
|
|
27
|
+
};
|
|
23
28
|
}
|
|
24
|
-
exports.default =
|
|
29
|
+
exports.default = createAddSymbol();
|
package/esm/runtime.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: (symbol: string, id: string) => void;
|
|
2
|
+
export default _default;
|
package/esm/runtime.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
function createAddSymbol() {
|
|
2
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
3
|
+
return () => { };
|
|
4
|
+
}
|
|
5
|
+
const idSet = window._SVG_SPRITE_IDS_ = window._SVG_SPRITE_IDS_ || [];
|
|
6
|
+
const root = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
7
|
+
root.style.position = 'absolute';
|
|
8
|
+
root.style.width = '0';
|
|
9
|
+
root.style.height = '0';
|
|
10
|
+
function insertRoot() {
|
|
11
|
+
document.body.insertBefore(root, document.body.firstChild);
|
|
12
|
+
}
|
|
13
|
+
if (document.readyState === 'loading') {
|
|
14
|
+
document.addEventListener('DOMContentLoaded', insertRoot);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
insertRoot();
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return function addSymbol(symbol, id) {
|
|
20
|
+
if (idSet.indexOf(id) > -1 || document.getElementById(id)) {
|
|
21
|
+
console.warn(`Icon #${id} was duplicately registered. It must be globally unique.`);
|
|
22
|
+
}
|
|
23
|
+
idSet.push(id);
|
|
24
|
+
root.insertAdjacentHTML('beforeend', symbol);
|
|
25
|
+
};
|
|
21
26
|
}
|
|
27
|
+
export default createAddSymbol();
|
package/package.json
CHANGED
package/src/runtime.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
function createAddSymbol() {
|
|
2
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
3
|
+
return () => {};
|
|
4
|
+
}
|
|
2
5
|
|
|
3
|
-
const
|
|
4
|
-
root.style.position = 'absolute';
|
|
5
|
-
root.style.width = '0';
|
|
6
|
-
root.style.height = '0';
|
|
6
|
+
const idSet = (window as any)._SVG_SPRITE_IDS_ = (window as any)._SVG_SPRITE_IDS_ || [];
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const root = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as SVGSVGElement;
|
|
9
|
+
root.style.position = 'absolute';
|
|
10
|
+
root.style.width = '0';
|
|
11
|
+
root.style.height = '0';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
insertRoot();
|
|
16
|
-
}
|
|
13
|
+
function insertRoot() {
|
|
14
|
+
document.body.insertBefore(root, document.body.firstChild);
|
|
15
|
+
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (document.readyState === 'loading') {
|
|
18
|
+
document.addEventListener('DOMContentLoaded', insertRoot);
|
|
19
|
+
} else {
|
|
20
|
+
insertRoot();
|
|
21
21
|
}
|
|
22
|
-
idSet.push(id);
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
return function addSymbol(symbol: string, id: string) {
|
|
24
|
+
if (idSet.indexOf(id) > -1 || document.getElementById(id)) {
|
|
25
|
+
console.warn(`Icon #${id} was duplicately registered. It must be globally unique.`);
|
|
26
|
+
}
|
|
27
|
+
idSet.push(id);
|
|
28
|
+
|
|
29
|
+
root.insertAdjacentHTML('beforeend', symbol);
|
|
30
|
+
};
|
|
25
31
|
}
|
|
32
|
+
|
|
33
|
+
export default createAddSymbol();
|