@taiga-ui/icons 2.28.0 → 2.32.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.
@@ -3,43 +3,50 @@ import { rollup } from 'rollup';
3
3
  import typescript from 'rollup-plugin-typescript2';
4
4
  import { createFilter } from '@rollup/pluginutils';
5
5
  import { optimize } from 'svgo';
6
- import { unlinkSync, readFileSync, writeFileSync, readdirSync } from 'fs';
6
+ import fs, { unlinkSync, readFileSync, writeFileSync, readdirSync } from 'fs';
7
7
  import prettier from 'prettier';
8
+ import { parse } from 'path';
8
9
 
9
10
  function rollupSvgo(_a) {
10
11
  var _b = _a === void 0 ? {} : _a, _c = _b.include, include = _c === void 0 ? '**/*.svg' : _c, exclude = _b.exclude, options = _b.options;
11
12
  var filter = createFilter(include, exclude);
12
13
  return {
13
14
  name: 'rollupSvgo',
14
- transform: function (svgString, id) {
15
+ transform: function (svgString, path) {
16
+ var _a;
15
17
  return __awaiter(this, void 0, void 0, function () {
16
- var skip, optimizedSvg, err_1;
17
- return __generator(this, function (_a) {
18
- switch (_a.label) {
18
+ var skip, data, error, result, err_1;
19
+ return __generator(this, function (_b) {
20
+ switch (_b.label) {
19
21
  case 0:
20
- skip = !filter(id);
22
+ skip = !filter(path);
21
23
  if (skip) {
22
- console.info('\x1b[33m%s\x1b[0m', '[skip]', id);
24
+ console.info('\x1b[33m%s\x1b[0m', '[skip]', path);
23
25
  return [2 /*return*/];
24
26
  }
25
- optimizedSvg = null;
26
- _a.label = 1;
27
+ _b.label = 1;
27
28
  case 1:
28
- _a.trys.push([1, 3, , 4]);
29
- return [4 /*yield*/, optimize(svgString, __assign({ path: id }, options))];
29
+ _b.trys.push([1, 3, , 4]);
30
+ return [4 /*yield*/, optimize(svgString, __assign({ path: path }, options))];
30
31
  case 2:
31
- optimizedSvg = _a.sent();
32
- console.info('\x1b[32m%s\x1b[0m', '[success]', id);
32
+ result = _b.sent();
33
+ data = ((_a = result) === null || _a === void 0 ? void 0 : _a.data) || {};
34
+ error = result.error;
33
35
  return [3 /*break*/, 4];
34
36
  case 3:
35
- err_1 = _a.sent();
36
- console.error('\x1b[31m%s\x1b[0m', '[error]', id, "\n" + svgString, "\n" + err_1);
37
- process.exit(1);
37
+ err_1 = _b.sent();
38
+ error = err_1.message;
38
39
  return [3 /*break*/, 4];
39
- case 4: return [2 /*return*/, {
40
- code: "export default " + JSON.stringify(optimizedSvg === null || optimizedSvg === void 0 ? void 0 : optimizedSvg.data),
41
- map: { mappings: '' },
42
- }];
40
+ case 4:
41
+ if (error) {
42
+ console.error('\x1b[31m%s\x1b[0m', '[error]', path, "\n" + svgString, "\n" + error);
43
+ process.exit(1);
44
+ }
45
+ console.info('\x1b[32m%s\x1b[0m', '[success]', path);
46
+ return [2 /*return*/, {
47
+ code: "export default " + JSON.stringify(data),
48
+ map: { mappings: '' },
49
+ }];
43
50
  }
44
51
  });
45
52
  });
@@ -126,7 +133,7 @@ function postPrettierFormat(filePath, prettierConfig) {
126
133
  writeFileSync(filePath, formatted);
127
134
  }
128
135
 
129
- function prepareAllToCompileFile(iconsSrc, allToCompilePath) {
136
+ function prepareAllToCompileFile(iconsSrc, entryPointTs) {
130
137
  var e_1, _a;
131
138
  var icons = readdirSync(iconsSrc).filter(function (file) { return file.split('.').pop() === 'svg'; });
132
139
  var importDeclarations = '';
@@ -146,12 +153,74 @@ function prepareAllToCompileFile(iconsSrc, allToCompilePath) {
146
153
  }
147
154
  finally { if (e_1) throw e_1.error; }
148
155
  }
149
- writeFileSync(allToCompilePath, importDeclarations + " \n export { " + exportDeclarations + " }");
156
+ writeFileSync(entryPointTs, importDeclarations + " \n export { " + exportDeclarations + " }");
157
+ }
158
+
159
+ var START = '<svg';
160
+ var WIDTH_SEARCH = 'width="';
161
+ var HEIGHT_SEARCH = 'height="';
162
+ function processIcons(files, interceptor) {
163
+ var e_1, _a;
164
+ try {
165
+ for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
166
+ var file = files_1_1.value;
167
+ var baseContent = String(fs.readFileSync(file));
168
+ var src = interceptor ? interceptor(baseContent) : baseContent;
169
+ var name_1 = parse(file).base.replace('.svg', '');
170
+ if (src.includes("id=\"" + name_1 + "\"")) {
171
+ console.info('\x1b[33m%s\x1b[0m', "[skip]:", file);
172
+ continue;
173
+ }
174
+ var wrapped = wrapIcon(src, name_1);
175
+ var final = typeof wrapped === 'string'
176
+ ? wrapped.replace(START, "<svg xmlns=\"http://www.w3.org/2000/svg\"><g id=\"" + name_1 + "\" xmlns=\"http://www.w3.org/2000/svg\"><svg") + '</g></svg>'
177
+ : "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + wrapped.width + "\" height=\"" + wrapped.height + "\">" + wrapped.src + "</svg>";
178
+ fs.writeFileSync(file, final);
179
+ console.info('\x1b[32m%s\x1b[0m', "[preprocessed]:", file);
180
+ }
181
+ }
182
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
183
+ finally {
184
+ try {
185
+ if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
186
+ }
187
+ finally { if (e_1) throw e_1.error; }
188
+ }
189
+ }
190
+ function wrapIcon(source, name) {
191
+ var src = source.substring(source.indexOf(START));
192
+ var attributes = src.substring(0, src.indexOf('>'));
193
+ if (!attributes ||
194
+ !attributes.includes(WIDTH_SEARCH) ||
195
+ !attributes.includes(HEIGHT_SEARCH)) {
196
+ return src;
197
+ }
198
+ var indexOfWidth = attributes.indexOf(WIDTH_SEARCH);
199
+ var indexOfHeight = attributes.indexOf(HEIGHT_SEARCH);
200
+ var widthOffset = indexOfWidth + WIDTH_SEARCH.length;
201
+ var heightOffset = indexOfHeight + HEIGHT_SEARCH.length;
202
+ var widthString = attributes.substring(widthOffset, attributes.indexOf('"', widthOffset));
203
+ var heightString = attributes.substring(heightOffset, attributes.indexOf('"', heightOffset));
204
+ if (!heightString ||
205
+ !widthString ||
206
+ widthString.includes('%') ||
207
+ heightString.includes('%')) {
208
+ return src.replace(START, "<svg id=\"" + name + "\"");
209
+ }
210
+ var width = parseInt(widthString, 10);
211
+ var height = parseInt(heightString, 10);
212
+ var emWidth = width / 16;
213
+ var emHeight = height / 16;
214
+ return {
215
+ width: emWidth + "em",
216
+ height: emHeight + "em",
217
+ src: ("\n <g id=\"" + name + "\" xmlns=\"http://www.w3.org/2000/svg\">\n <svg x=\"50%\" y=\"50%\" width=\"" + emWidth + "em\" height=\"" + emHeight + "em\" overflow=\"visible\" viewBox=\"0 0 " + width + " " + height + "\">\n <svg x=\"" + -width / 2 + "\" y=\"" + -height / 2 + "\">" + src + "</svg>\n </svg>\n </g>").trim(),
218
+ };
150
219
  }
151
220
 
152
221
  /**
153
222
  * Generated bundle index. Do not edit.
154
223
  */
155
224
 
156
- export { convertAllCompileFileToAllFile, deleteAllToCompileFile, postPrettierFormat, prepareAllToCompileFile, rollupSvgo };
225
+ export { convertAllCompileFileToAllFile, deleteAllToCompileFile, postPrettierFormat, prepareAllToCompileFile, processIcons, rollupSvgo };
157
226
  //# sourceMappingURL=taiga-ui-icons-scripts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"taiga-ui-icons-scripts.js","sources":["ng://@taiga-ui/icons/scripts/rollup-svgo.ts","ng://@taiga-ui/icons/scripts/convert-all-compile-file-to-all-file.ts","ng://@taiga-ui/icons/scripts/delete-all-to-compile-file.ts","ng://@taiga-ui/icons/scripts/post-prettier-format.ts","ng://@taiga-ui/icons/scripts/prepare-all-to-compile-file.ts","ng://@taiga-ui/icons/scripts/taiga-ui-icons-scripts.ts"],"sourcesContent":["import {createFilter} from '@rollup/pluginutils';\nimport {Plugin, TransformResult} from 'rollup';\nimport {optimize, OptimizedSvg, OptimizeOptions} from 'svgo';\n\nexport interface RollupSvgoConfig {\n readonly include?: string;\n\n readonly exclude?: string;\n\n readonly options?: OptimizeOptions;\n}\n\nexport function rollupSvgo({\n include = '**/*.svg',\n exclude,\n options,\n}: RollupSvgoConfig = {}): Plugin {\n const filter = createFilter(include, exclude);\n\n return {\n name: 'rollupSvgo',\n async transform(svgString: string, id: string): Promise<TransformResult> {\n const skip: boolean = !filter(id);\n\n if (skip) {\n console.info('\\x1b[33m%s\\x1b[0m', '[skip]', id);\n\n return;\n }\n\n let optimizedSvg: OptimizedSvg | null = null;\n\n try {\n optimizedSvg = await optimize(svgString, {path: id, ...options});\n\n console.info('\\x1b[32m%s\\x1b[0m', '[success]', id);\n } catch (err) {\n console.error(\n '\\x1b[31m%s\\x1b[0m',\n '[error]',\n id,\n `\\n${svgString}`,\n `\\n${err}`,\n );\n\n process.exit(1);\n }\n\n return {\n code: `export default ${JSON.stringify(optimizedSvg?.data)}`,\n map: {mappings: ''},\n };\n },\n };\n}\n","import {rollup, RollupOptions} from 'rollup';\nimport typescript, {RPT2Options} from 'rollup-plugin-typescript2';\n\nimport {rollupSvgo} from './rollup-svgo';\n\nconst banner = `\n/**\n * @description:\n * DO NOT CHANGE THIS FILE. AUTOGENERATED\n */\n`;\n\ninterface Options {\n prt2Options?: RPT2Options;\n from: string;\n to: string;\n}\n\nexport async function convertAllCompileFileToAllFile(config: Options): Promise<void> {\n const {from, to, prt2Options} = config;\n\n const inputOptions: RollupOptions = {\n input: from,\n output: {preferConst: true},\n plugins: [\n typescript(prt2Options ?? {cacheRoot: 'node_modules/.cache/.rpt2_cache'}),\n rollupSvgo({\n include: '**/*.svg',\n options: {\n plugins: [\n {\n name: 'preset-default',\n params: {\n overrides: {\n removeViewBox: false,\n collapseGroups: false,\n cleanupIDs: false,\n removeUnknownsAndDefaults: false,\n },\n },\n },\n ],\n },\n }),\n ],\n };\n\n const bundle = await rollup(inputOptions);\n\n await bundle.write({\n banner,\n file: to,\n format: 'es',\n preferConst: true,\n });\n\n /**\n * @note:\n * The rollup bundle must be closed once `write` is finished to let plugins clean up their external\n * processes or services via the `closeBundle` hook, otherwise it can lead to memory leaks.\n */\n await bundle.close();\n}\n","import {unlinkSync} from 'fs';\n\nexport function deleteAllToCompileFile(allToCompilePath: string | string[]): void {\n if (Array.isArray(allToCompilePath)) {\n allToCompilePath.forEach(file => unlinkSync(file));\n } else {\n unlinkSync(allToCompilePath);\n }\n}\n","import {readFileSync, writeFileSync} from 'fs';\nimport prettier from 'prettier';\n\nexport function postPrettierFormat(filePath: string, prettierConfig?: string): void {\n const bundledBody = readFileSync(filePath, 'utf8');\n const options = prettier.resolveConfig.sync(prettierConfig ?? 'prettier.config.js');\n const formatted = prettier.format(bundledBody, {...options, parser: 'typescript'});\n\n writeFileSync(filePath, formatted);\n}\n","import {readdirSync, writeFileSync} from 'fs';\n\nexport function prepareAllToCompileFile(\n iconsSrc: string,\n allToCompilePath: string,\n): void {\n const icons: string[] = readdirSync(iconsSrc).filter(\n file => file.split('.').pop() === 'svg',\n );\n\n let importDeclarations = '';\n let exportDeclarations = '';\n\n for (const iconPath of icons) {\n const fileName = iconPath.split('.').shift();\n\n importDeclarations += `import ${fileName} from './src/${fileName}.svg';\\n`;\n exportDeclarations += `${fileName}, `;\n }\n\n writeFileSync(\n allToCompilePath,\n `${importDeclarations} \\n export { ${exportDeclarations} }`,\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;SAYgB,UAAU,CAAC,EAIH;QAJG,4BAIH,EAHpB,eAAoB,EAApB,yCAAoB,EACpB,oBAAO,EACP,oBAAO;IAEP,IAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE9C,OAAO;QACH,IAAI,EAAE,YAAY;QACZ,SAAS,EAAf,UAAgB,SAAiB,EAAE,EAAU;;;;;;4BACnC,IAAI,GAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;4BAElC,IAAI,IAAI,EAAE;gCACN,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;gCAEhD,sBAAO;6BACV;4BAEG,YAAY,GAAwB,IAAI,CAAC;;;;4BAG1B,qBAAM,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AAG,EAAE,CAAC;IAC5B,IAAI,kBAAkB,GAAG,EAAE,CAAC;;QAE5B,KAAuB,IAAA,UAAA,SAAA,KAAK,CAAA,4BAAA,+CAAE;YAAzB,IAAM,QAAQ,kBAAA;YACf,IAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAE7C,kBAAkB,IAAI,YAAU,QAAQ,qBAAgB,QAAQ,aAAU,CAAC;YAC3E,kBAAkB,IAAO,QAAQ,OAAI,CAAC;SACzC;;;;;;;;;IAED,aAAa,CACT,gBAAgB,EACb,kBAAkB,qBAAgB,kBAAkB,OAAI,CAC9D,CAAC;AACN;;ACxBA;;;;;;"}
1
+ {"version":3,"file":"taiga-ui-icons-scripts.js","sources":["ng://@taiga-ui/icons/scripts/rollup-svgo.ts","ng://@taiga-ui/icons/scripts/convert-all-compile-file-to-all-file.ts","ng://@taiga-ui/icons/scripts/delete-all-to-compile-file.ts","ng://@taiga-ui/icons/scripts/post-prettier-format.ts","ng://@taiga-ui/icons/scripts/prepare-all-to-compile-file.ts","ng://@taiga-ui/icons/scripts/process-icons.ts","ng://@taiga-ui/icons/scripts/taiga-ui-icons-scripts.ts"],"sourcesContent":["import {createFilter} from '@rollup/pluginutils';\nimport {Plugin, TransformResult} from 'rollup';\nimport {optimize, OptimizedError, OptimizedSvg, OptimizeOptions} from 'svgo';\n\ntype SvgoResult = OptimizedSvg | OptimizedError;\n\nexport interface RollupSvgoConfig {\n readonly include?: string;\n\n readonly exclude?: string;\n\n readonly options?: OptimizeOptions;\n}\n\nexport function rollupSvgo({\n include = '**/*.svg',\n exclude,\n options,\n}: RollupSvgoConfig = {}): Plugin {\n const filter = createFilter(include, exclude);\n\n return {\n name: 'rollupSvgo',\n async transform(svgString: string, path: string): Promise<TransformResult> {\n const skip = !filter(path);\n\n if (skip) {\n console.info('\\x1b[33m%s\\x1b[0m', '[skip]', path);\n\n return;\n }\n\n let data: unknown;\n let error: unknown;\n\n try {\n const result: SvgoResult = await optimize(svgString, {path, ...options});\n\n data = (result as OptimizedSvg)?.data || {};\n error = result.error;\n } catch (err) {\n error = err.message;\n }\n\n if (error) {\n console.error(\n '\\x1b[31m%s\\x1b[0m',\n '[error]',\n path,\n `\\n${svgString}`,\n `\\n${error}`,\n );\n process.exit(1);\n }\n\n console.info('\\x1b[32m%s\\x1b[0m', '[success]', path);\n\n return {\n code: `export default ${JSON.stringify(data)}`,\n map: {mappings: ''},\n };\n },\n };\n}\n","import {rollup, RollupOptions} from 'rollup';\nimport typescript, {RPT2Options} from 'rollup-plugin-typescript2';\n\nimport {rollupSvgo} from './rollup-svgo';\n\nconst banner = `\n/**\n * @description:\n * DO NOT CHANGE THIS FILE. AUTOGENERATED\n */\n`;\n\ninterface Options {\n prt2Options?: RPT2Options;\n from: string;\n to: string;\n}\n\nexport async function convertAllCompileFileToAllFile(config: Options): Promise<void> {\n const {from, to, prt2Options} = config;\n\n const inputOptions: RollupOptions = {\n input: from,\n output: {preferConst: true},\n plugins: [\n typescript(prt2Options ?? {cacheRoot: 'node_modules/.cache/.rpt2_cache'}),\n rollupSvgo({\n include: '**/*.svg',\n options: {\n plugins: [\n {\n name: 'preset-default',\n params: {\n overrides: {\n removeViewBox: false,\n collapseGroups: false,\n cleanupIDs: false,\n removeUnknownsAndDefaults: false,\n },\n },\n },\n ],\n },\n }),\n ],\n };\n\n const bundle = await rollup(inputOptions);\n\n await bundle.write({\n banner,\n file: to,\n format: 'es',\n preferConst: true,\n });\n\n /**\n * @note:\n * The rollup bundle must be closed once `write` is finished to let plugins clean up their external\n * processes or services via the `closeBundle` hook, otherwise it can lead to memory leaks.\n */\n await bundle.close();\n}\n","import {unlinkSync} from 'fs';\n\nexport function deleteAllToCompileFile(allToCompilePath: string | string[]): void {\n if (Array.isArray(allToCompilePath)) {\n allToCompilePath.forEach(file => unlinkSync(file));\n } else {\n unlinkSync(allToCompilePath);\n }\n}\n","import {readFileSync, writeFileSync} from 'fs';\nimport prettier from 'prettier';\n\nexport function postPrettierFormat(filePath: string, prettierConfig?: string): void {\n const bundledBody = readFileSync(filePath, 'utf8');\n const options = prettier.resolveConfig.sync(prettierConfig ?? 'prettier.config.js');\n const formatted = prettier.format(bundledBody, {...options, parser: 'typescript'});\n\n writeFileSync(filePath, formatted);\n}\n","import {readdirSync, writeFileSync} from 'fs';\n\nexport function prepareAllToCompileFile(iconsSrc: string, entryPointTs: string): void {\n const icons: string[] = readdirSync(iconsSrc).filter(\n file => file.split('.').pop() === 'svg',\n );\n\n let importDeclarations = '';\n let exportDeclarations = '';\n\n for (const iconPath of icons) {\n const fileName = iconPath.split('.').shift();\n\n importDeclarations += `import ${fileName} from './src/${fileName}.svg';\\n`;\n exportDeclarations += `${fileName}, `;\n }\n\n writeFileSync(\n entryPointTs,\n `${importDeclarations} \\n export { ${exportDeclarations} }`,\n );\n}\n","import fs from 'fs';\nimport {parse} from 'path';\n\nconst START = '<svg';\nconst WIDTH_SEARCH = 'width=\"';\nconst HEIGHT_SEARCH = 'height=\"';\n\ninterface WrappedContent {\n height: string;\n width: string;\n src: string;\n}\n\ntype ContentInterceptor = (src: string) => string;\n\nexport function processIcons(files: string[], interceptor?: ContentInterceptor): void {\n for (const file of files) {\n const baseContent = String(fs.readFileSync(file));\n const src = interceptor ? interceptor(baseContent) : baseContent;\n\n const name = parse(file).base.replace('.svg', '');\n\n if (src.includes(`id=\"${name}\"`)) {\n console.info('\\x1b[33m%s\\x1b[0m', `[skip]:`, file);\n continue;\n }\n\n const wrapped = wrapIcon(src, name);\n\n const final =\n typeof wrapped === 'string'\n ? wrapped.replace(\n START,\n `<svg xmlns=\"http://www.w3.org/2000/svg\"><g id=\"${name}\" xmlns=\"http://www.w3.org/2000/svg\"><svg`,\n ) + '</g></svg>'\n : `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${wrapped.width}\" height=\"${wrapped.height}\">${wrapped.src}</svg>`;\n\n fs.writeFileSync(file, final);\n\n console.info('\\x1b[32m%s\\x1b[0m', `[preprocessed]:`, file);\n }\n}\n\nfunction wrapIcon(source: string, name: string): string | WrappedContent {\n const src = source.substring(source.indexOf(START));\n const attributes = src.substring(0, src.indexOf('>'));\n\n if (\n !attributes ||\n !attributes.includes(WIDTH_SEARCH) ||\n !attributes.includes(HEIGHT_SEARCH)\n ) {\n return src;\n }\n\n const indexOfWidth = attributes.indexOf(WIDTH_SEARCH);\n const indexOfHeight = attributes.indexOf(HEIGHT_SEARCH);\n const widthOffset = indexOfWidth + WIDTH_SEARCH.length;\n const heightOffset = indexOfHeight + HEIGHT_SEARCH.length;\n const widthString = attributes.substring(\n widthOffset,\n attributes.indexOf('\"', widthOffset),\n );\n const heightString = attributes.substring(\n heightOffset,\n attributes.indexOf('\"', heightOffset),\n );\n\n if (\n !heightString ||\n !widthString ||\n widthString.includes('%') ||\n heightString.includes('%')\n ) {\n return src.replace(START, `<svg id=\"${name}\"`);\n }\n\n const width = parseInt(widthString, 10);\n const height = parseInt(heightString, 10);\n const emWidth = width / 16;\n const emHeight = height / 16;\n\n return {\n width: `${emWidth}em`,\n height: `${emHeight}em`,\n src: `\n <g id=\"${name}\" xmlns=\"http://www.w3.org/2000/svg\">\n <svg x=\"50%\" y=\"50%\" width=\"${emWidth}em\" height=\"${emHeight}em\" overflow=\"visible\" viewBox=\"0 0 ${width} ${height}\">\n <svg x=\"${-width / 2}\" y=\"${-height / 2}\">${src}</svg>\n </svg>\n </g>`.trim(),\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;SAcgB,UAAU,CAAC,EAIH;QAJG,4BAIH,EAHpB,eAAoB,EAApB,yCAAoB,EACpB,oBAAO,EACP,oBAAO;IAEP,IAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE9C,OAAO;QACH,IAAI,EAAE,YAAY;QACZ,SAAS,EAAf,UAAgB,SAAiB,EAAE,IAAY;;;;;;;4BACrC,IAAI,G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vD,IAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC;IAC1D,IAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CACpC,WAAW,EACX,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CACvC,CAAC;IACF,IAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CACrC,YAAY,EACZ,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CACxC,CAAC;IAEF,IACI,CAAC,YAAY;QACb,CAAC,WAAW;QACZ,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;QACzB,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAC5B;QACE,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,eAAY,IAAI,OAAG,CAAC,CAAC;KAClD;IAED,IAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACxC,IAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAM,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC;IAC3B,IAAM,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC;IAE7B,OAAO;QACH,KAAK,EAAK,OAAO,OAAI;QACrB,MAAM,EAAK,QAAQ,OAAI;QACvB,GAAG,EAAE,CAAA,uBACI,IAAI,+FACqB,OAAO,sBAAe,QAAQ,gDAAuC,KAAK,SAAI,MAAM,sCACpG,CAAC,KAAK,GAAG,CAAC,eAAQ,CAAC,MAAM,GAAG,CAAC,WAAK,GAAG,6CAElD,EAAC,IAAI,EAAE;KACf,CAAC;AACN;;AC5FA;;;;;;"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@taiga-ui/icons",
3
- "version": "2.28.0",
3
+ "version": "2.32.0",
4
4
  "description": "Taiga UI icons pack",
5
5
  "keywords": [
6
6
  "angular",
7
7
  "icon"
8
8
  ],
9
9
  "license": "Apache-2.0",
10
- "repository": "https://github.com/TinkoffCreditSystems/taiga-ui",
11
- "homepage": "https://github.com/TinkoffCreditSystems/taiga-ui",
10
+ "repository": "https://github.com/tinkoff/taiga-ui",
11
+ "homepage": "https://github.com/tinkoff/taiga-ui",
12
12
  "main": "bundles/taiga-ui-icons.umd.js",
13
13
  "module": "fesm5/taiga-ui-icons.js",
14
14
  "es2015": "fesm2015/taiga-ui-icons.js",
@@ -2,4 +2,5 @@ export * from './convert-all-compile-file-to-all-file';
2
2
  export * from './delete-all-to-compile-file';
3
3
  export * from './post-prettier-format';
4
4
  export * from './prepare-all-to-compile-file';
5
+ export * from './process-icons';
5
6
  export * from './rollup-svgo';
@@ -1 +1 @@
1
- export declare function prepareAllToCompileFile(iconsSrc: string, allToCompilePath: string): void;
1
+ export declare function prepareAllToCompileFile(iconsSrc: string, entryPointTs: string): void;
@@ -0,0 +1,3 @@
1
+ declare type ContentInterceptor = (src: string) => string;
2
+ export declare function processIcons(files: string[], interceptor?: ContentInterceptor): void;
3
+ export {};
@@ -1 +1 @@
1
- {"__symbolic":"module","version":4,"metadata":{"convertAllCompileFileToAllFile":{"__symbolic":"function"},"deleteAllToCompileFile":{"__symbolic":"function"},"postPrettierFormat":{"__symbolic":"function"},"prepareAllToCompileFile":{"__symbolic":"function"},"RollupSvgoConfig":{"__symbolic":"interface"},"rollupSvgo":{"__symbolic":"function"}},"origins":{"convertAllCompileFileToAllFile":"./convert-all-compile-file-to-all-file","deleteAllToCompileFile":"./delete-all-to-compile-file","postPrettierFormat":"./post-prettier-format","prepareAllToCompileFile":"./prepare-all-to-compile-file","RollupSvgoConfig":"./rollup-svgo","rollupSvgo":"./rollup-svgo"},"importAs":"@taiga-ui/icons/scripts"}
1
+ {"__symbolic":"module","version":4,"metadata":{"convertAllCompileFileToAllFile":{"__symbolic":"function"},"deleteAllToCompileFile":{"__symbolic":"function"},"postPrettierFormat":{"__symbolic":"function"},"prepareAllToCompileFile":{"__symbolic":"function"},"processIcons":{"__symbolic":"function"},"RollupSvgoConfig":{"__symbolic":"interface"},"rollupSvgo":{"__symbolic":"function"}},"origins":{"convertAllCompileFileToAllFile":"./convert-all-compile-file-to-all-file","deleteAllToCompileFile":"./delete-all-to-compile-file","postPrettierFormat":"./post-prettier-format","prepareAllToCompileFile":"./prepare-all-to-compile-file","processIcons":"./process-icons","RollupSvgoConfig":"./rollup-svgo","rollupSvgo":"./rollup-svgo"},"importAs":"@taiga-ui/icons/scripts"}
package/src/BQ.png ADDED
Binary file
package/src/CW.png ADDED
Binary file
File without changes
package/src/SX.png ADDED
Binary file
package/svg.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @caretaker note:
3
+ * needed to compile files, where source code has:
4
+ * `import tuiIconAddRowLarge from './src/tuiIconAddRowLarge.svg';`
5
+ */
6
+ declare module '*.svg' {
7
+ const content: any;
8
+ export default content;
9
+ }