@iconify/tools 2.2.1 → 2.2.3
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/lib/export/json-package.cjs +3 -1
- package/lib/export/json-package.mjs +3 -1
- package/lib/import/figma/nodes.cjs +2 -1
- package/lib/import/figma/nodes.mjs +2 -1
- package/lib/import/figma/types/nodes.d.ts +1 -1
- package/lib/optimise/global-style.cjs +20 -21
- package/lib/optimise/global-style.mjs +20 -21
- package/package.json +2 -2
|
@@ -96,7 +96,9 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
96
96
|
if (data !== void 0) {
|
|
97
97
|
await misc_writeJson.writeJSONFile(`${dir}/${jsonFilename}`, data);
|
|
98
98
|
cjsImports.push(`const ${attr} = require('${relativeFile}');`);
|
|
99
|
-
mjsImports.push(
|
|
99
|
+
mjsImports.push(
|
|
100
|
+
`import ${attr} from '${relativeFile}' assert { type: 'json' };`
|
|
101
|
+
);
|
|
100
102
|
packageJSONIconSet[attr] = attr + ".json";
|
|
101
103
|
packageJSONExports[relativeFile] = relativeFile;
|
|
102
104
|
} else {
|
|
@@ -94,7 +94,9 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
94
94
|
if (data !== void 0) {
|
|
95
95
|
await writeJSONFile(`${dir}/${jsonFilename}`, data);
|
|
96
96
|
cjsImports.push(`const ${attr} = require('${relativeFile}');`);
|
|
97
|
-
mjsImports.push(
|
|
97
|
+
mjsImports.push(
|
|
98
|
+
`import ${attr} from '${relativeFile}' assert { type: 'json' };`
|
|
99
|
+
);
|
|
98
100
|
packageJSONIconSet[attr] = attr + ".json";
|
|
99
101
|
packageJSONExports[relativeFile] = relativeFile;
|
|
100
102
|
} else {
|
|
@@ -7,7 +7,7 @@ import '../../../icon-set/types.js';
|
|
|
7
7
|
import '../../../svg/index.js';
|
|
8
8
|
import '@iconify/utils/lib/icon-set/tree';
|
|
9
9
|
|
|
10
|
-
type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP';
|
|
10
|
+
type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP' | 'SECTION';
|
|
11
11
|
type FigmaImportIconNodeType = IconFigmaNode['type'];
|
|
12
12
|
/**
|
|
13
13
|
* Node information passed to callback
|
|
@@ -39,6 +39,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
+
const removeClasses = /* @__PURE__ */ new Set();
|
|
42
43
|
try {
|
|
43
44
|
await svg_parseStyle.parseSVGStyle(svg, async (styleItem) => {
|
|
44
45
|
const returnValue = styleItem.value;
|
|
@@ -123,28 +124,26 @@ async function cleanupGlobalStyle(svg) {
|
|
|
123
124
|
);
|
|
124
125
|
containsTempAttr = true;
|
|
125
126
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
127
|
+
matches.forEach((match) => {
|
|
128
|
+
if (match.type === "class") {
|
|
129
|
+
removeClasses.add(match.value);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
await svg_parse.parseSVG(svg, (svgItem) => {
|
|
134
|
+
const $element = svgItem.$element;
|
|
135
|
+
const classList = getClassList($element.attr("class"));
|
|
136
|
+
if (!classList) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const filtered = classList.filter(
|
|
140
|
+
(item) => !removeClasses.has(item)
|
|
141
|
+
);
|
|
142
|
+
if (!filtered.length) {
|
|
143
|
+
$element.removeAttr("class");
|
|
144
|
+
} else {
|
|
145
|
+
$element.attr("class", filtered.join(" "));
|
|
146
146
|
}
|
|
147
|
-
return;
|
|
148
147
|
});
|
|
149
148
|
if (containsTempAttr) {
|
|
150
149
|
await svg_parse.parseSVG(svg, (item) => {
|
|
@@ -37,6 +37,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
const removeClasses = /* @__PURE__ */ new Set();
|
|
40
41
|
try {
|
|
41
42
|
await parseSVGStyle(svg, async (styleItem) => {
|
|
42
43
|
const returnValue = styleItem.value;
|
|
@@ -121,28 +122,26 @@ async function cleanupGlobalStyle(svg) {
|
|
|
121
122
|
);
|
|
122
123
|
containsTempAttr = true;
|
|
123
124
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
125
|
+
matches.forEach((match) => {
|
|
126
|
+
if (match.type === "class") {
|
|
127
|
+
removeClasses.add(match.value);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
await parseSVG(svg, (svgItem) => {
|
|
132
|
+
const $element = svgItem.$element;
|
|
133
|
+
const classList = getClassList($element.attr("class"));
|
|
134
|
+
if (!classList) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const filtered = classList.filter(
|
|
138
|
+
(item) => !removeClasses.has(item)
|
|
139
|
+
);
|
|
140
|
+
if (!filtered.length) {
|
|
141
|
+
$element.removeAttr("class");
|
|
142
|
+
} else {
|
|
143
|
+
$element.attr("class", filtered.join(" "));
|
|
144
144
|
}
|
|
145
|
-
return;
|
|
146
145
|
});
|
|
147
146
|
if (containsTempAttr) {
|
|
148
147
|
await parseSVG(svg, (item) => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
5
5
|
"author": "Vjacheslav Trushkin",
|
|
6
|
-
"version": "2.2.
|
|
6
|
+
"version": "2.2.3",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"types": "./lib/index.d.ts",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@iconify/types": "^2.0.0",
|
|
19
|
-
"@iconify/utils": "^2.0
|
|
19
|
+
"@iconify/utils": "^2.1.0",
|
|
20
20
|
"@types/cheerio": "^0.22.31",
|
|
21
21
|
"@types/node-fetch": "^2.6.2",
|
|
22
22
|
"@types/tar": "^6.1.3",
|