@iconify/tools 1.3.17 → 2.0.0-dev.2

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.
Files changed (147) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/lib/colors/attribs.d.ts +16 -0
  4. package/lib/colors/attribs.js +26 -0
  5. package/lib/colors/attribs.mjs +28 -0
  6. package/lib/colors/parse.d.ts +37 -0
  7. package/lib/colors/parse.js +261 -0
  8. package/lib/colors/parse.mjs +212 -0
  9. package/lib/css/parse.d.ts +4 -0
  10. package/lib/css/parse.js +23 -0
  11. package/lib/css/parse.mjs +20 -0
  12. package/lib/css/parser/error.d.ts +11 -0
  13. package/lib/css/parser/error.js +27 -0
  14. package/lib/css/parser/error.mjs +23 -0
  15. package/lib/css/parser/export.d.ts +5 -0
  16. package/lib/css/parser/export.js +69 -0
  17. package/lib/css/parser/export.mjs +46 -0
  18. package/lib/css/parser/strings.d.ts +13 -0
  19. package/lib/css/parser/strings.js +93 -0
  20. package/lib/css/parser/strings.mjs +74 -0
  21. package/lib/css/parser/text.d.ts +17 -0
  22. package/lib/css/parser/text.js +174 -0
  23. package/lib/css/parser/text.mjs +133 -0
  24. package/lib/css/parser/tokens.d.ts +6 -0
  25. package/lib/css/parser/tokens.js +200 -0
  26. package/lib/css/parser/tokens.mjs +186 -0
  27. package/lib/css/parser/tree.d.ts +5 -0
  28. package/lib/css/parser/tree.js +44 -0
  29. package/lib/css/parser/tree.mjs +40 -0
  30. package/lib/css/parser/types.d.ts +51 -0
  31. package/lib/css/parser/types.js +2 -0
  32. package/lib/css/parser/types.mjs +0 -0
  33. package/lib/icon-set/index.d.ts +134 -0
  34. package/lib/icon-set/index.js +776 -0
  35. package/lib/icon-set/index.mjs +617 -0
  36. package/lib/icon-set/match.d.ts +6 -0
  37. package/lib/icon-set/match.js +66 -0
  38. package/lib/icon-set/match.mjs +55 -0
  39. package/lib/icon-set/merge.d.ts +5 -0
  40. package/lib/icon-set/merge.js +91 -0
  41. package/lib/icon-set/merge.mjs +75 -0
  42. package/lib/icon-set/props.d.ts +10 -0
  43. package/lib/icon-set/props.js +33 -0
  44. package/lib/icon-set/props.mjs +25 -0
  45. package/lib/icon-set/types.d.ts +68 -0
  46. package/lib/icon-set/types.js +2 -0
  47. package/lib/icon-set/types.mjs +0 -0
  48. package/lib/import/directory.d.ts +35 -0
  49. package/lib/import/directory.js +59 -0
  50. package/lib/import/directory.mjs +47 -0
  51. package/lib/misc/keyword.d.ts +4 -0
  52. package/lib/misc/keyword.js +31 -0
  53. package/lib/misc/keyword.mjs +17 -0
  54. package/lib/misc/scan.d.ts +24 -0
  55. package/lib/misc/scan.js +48 -0
  56. package/lib/misc/scan.mjs +43 -0
  57. package/lib/optimise/flags.d.ts +5 -0
  58. package/lib/optimise/flags.js +303 -0
  59. package/lib/optimise/flags.mjs +241 -0
  60. package/lib/optimise/scale.d.ts +5 -0
  61. package/lib/optimise/scale.js +42 -0
  62. package/lib/optimise/scale.mjs +22 -0
  63. package/lib/optimise/svgo.d.ts +27 -0
  64. package/lib/optimise/svgo.js +88 -0
  65. package/lib/optimise/svgo.mjs +75 -0
  66. package/lib/svg/cleanup/attribs.d.ts +5 -0
  67. package/lib/svg/cleanup/attribs.js +43 -0
  68. package/lib/svg/cleanup/attribs.mjs +36 -0
  69. package/lib/svg/cleanup/bad-tags.d.ts +5 -0
  70. package/lib/svg/cleanup/bad-tags.js +69 -0
  71. package/lib/svg/cleanup/bad-tags.mjs +68 -0
  72. package/lib/svg/cleanup/inline-style.d.ts +5 -0
  73. package/lib/svg/cleanup/inline-style.js +77 -0
  74. package/lib/svg/cleanup/inline-style.mjs +65 -0
  75. package/lib/svg/cleanup/root-svg.d.ts +5 -0
  76. package/lib/svg/cleanup/root-svg.js +106 -0
  77. package/lib/svg/cleanup/root-svg.mjs +88 -0
  78. package/lib/svg/cleanup/svgo-style.d.ts +5 -0
  79. package/lib/svg/cleanup/svgo-style.js +35 -0
  80. package/lib/svg/cleanup/svgo-style.mjs +29 -0
  81. package/lib/svg/cleanup.d.ts +5 -0
  82. package/lib/svg/cleanup.js +24 -0
  83. package/lib/svg/cleanup.mjs +16 -0
  84. package/lib/svg/data/attributes.d.ts +71 -0
  85. package/lib/svg/data/attributes.js +403 -0
  86. package/lib/svg/data/attributes.mjs +352 -0
  87. package/lib/svg/data/tags.d.ts +89 -0
  88. package/lib/svg/data/tags.js +185 -0
  89. package/lib/svg/data/tags.mjs +136 -0
  90. package/lib/svg/index.d.ts +33 -0
  91. package/lib/svg/index.js +122 -0
  92. package/lib/svg/index.mjs +85 -0
  93. package/lib/svg/parse-style.d.ts +40 -0
  94. package/lib/svg/parse-style.js +131 -0
  95. package/lib/svg/parse-style.mjs +109 -0
  96. package/lib/svg/parse.d.ts +30 -0
  97. package/lib/svg/parse.js +49 -0
  98. package/lib/svg/parse.mjs +40 -0
  99. package/package.json +167 -13
  100. package/README.md +0 -576
  101. package/license.txt +0 -21
  102. package/sample/parse.js +0 -74
  103. package/sample/source/icon-close.svg +0 -15
  104. package/sample/source/icon-confirm.svg +0 -14
  105. package/sample/source/icon-search.svg +0 -16
  106. package/src/collection.js +0 -641
  107. package/src/colors/change_palette.js +0 -227
  108. package/src/colors/get_palette.js +0 -143
  109. package/src/colors/opacify.js +0 -195
  110. package/src/export/component.js +0 -482
  111. package/src/export/dir.js +0 -109
  112. package/src/export/json.js +0 -329
  113. package/src/export/phantomjs.js +0 -76
  114. package/src/export/phantomjs_script.js +0 -125
  115. package/src/export/png.js +0 -193
  116. package/src/export/svg.js +0 -55
  117. package/src/export/templates/component.md +0 -79
  118. package/src/export/templates/info.md +0 -3
  119. package/src/export/templates/sample-react-1.md +0 -21
  120. package/src/export/templates/sample-react-2.md +0 -15
  121. package/src/export/templates/sample-react.md +0 -11
  122. package/src/export/templates/sample-svelte.md +0 -11
  123. package/src/export/templates/sample-svelte1.md +0 -22
  124. package/src/export/templates/sample-svelte2.md +0 -13
  125. package/src/export/templates/sample-vue-0.md +0 -30
  126. package/src/export/templates/sample-vue-1.md +0 -25
  127. package/src/export/templates/sample-vue-2.md +0 -27
  128. package/src/export/templates/sample-vue.md +0 -28
  129. package/src/helpers.js +0 -43
  130. package/src/import/dir.js +0 -234
  131. package/src/import/font.js +0 -402
  132. package/src/import/json.js +0 -200
  133. package/src/import/svg.js +0 -60
  134. package/src/import/web_icons.js +0 -248
  135. package/src/modules.js +0 -50
  136. package/src/optimize/crop.js +0 -554
  137. package/src/optimize/crop_script.js +0 -525
  138. package/src/optimize/flags.js +0 -430
  139. package/src/optimize/scale.js +0 -72
  140. package/src/optimize/svgo.js +0 -161
  141. package/src/optimize/tags.js +0 -522
  142. package/src/shapes/convert.js +0 -264
  143. package/src/shapes/index.js +0 -135
  144. package/src/shapes/length.js +0 -707
  145. package/src/shapes/length_script.js +0 -105
  146. package/src/shapes/options.js +0 -60
  147. package/src/svg.js +0 -162
@@ -1,105 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- /**
11
- * This script is for phantomjs, not nodejs
12
- */
13
- 'use strict';
14
-
15
- var system = require('system'),
16
- fs = require('fs'),
17
- webpage = require('webpage'),
18
- sourceData,
19
- html,
20
- page,
21
- results,
22
- resultData;
23
-
24
- if (system.args.length < 3) {
25
- console.log(
26
- 'Invalid arguments. Requires 2 arguments: source.json target.json'
27
- );
28
- phantom.exit();
29
- }
30
-
31
- var debug = system.args.length > 3 && system.args[3] === '--debug';
32
-
33
- try {
34
- sourceData = JSON.parse(fs.read(system.args[1]));
35
- } catch (err) {
36
- console.log('Error reading source file.');
37
- phantom.exit();
38
- }
39
-
40
- if (typeof sourceData !== 'object' || !(sourceData instanceof Array)) {
41
- console.log('Expected array');
42
- phantom.exit();
43
- }
44
-
45
- // Generate HTML
46
- html =
47
- '<!DOCTYPE html>' +
48
- '<html lang="en">' +
49
- ' <head><meta charset="UTF-8"></head>' +
50
- ' <body>' +
51
- ' <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">';
52
- sourceData.forEach(function(item, index) {
53
- html += '<path data-index="' + index + '" d="' + item + '" />';
54
- });
55
- html += ' </svg>' + ' </body>' + '</html>';
56
-
57
- // Create page
58
- page = webpage.create();
59
- page.setContent(html, 'http://localhost/');
60
-
61
- // Render image and parse all shapes
62
- results = page.evaluate(function() {
63
- var shapes = document.querySelectorAll('path'),
64
- results = [],
65
- i,
66
- node,
67
- length;
68
-
69
- for (i = 0; i < shapes.length; i++) {
70
- node = shapes[i];
71
- try {
72
- length = node.getTotalLength();
73
- } catch (err) {
74
- length = false;
75
- }
76
-
77
- // Save as object because node index might not match data-index
78
- results.push({
79
- length: length,
80
- index: parseInt(node.getAttribute('data-index')),
81
- });
82
- }
83
-
84
- return results;
85
- });
86
-
87
- // Convert results to array
88
- resultData = [];
89
- sourceData.forEach(function(item, index) {
90
- for (var i = 0; i < results.length; i++) {
91
- if (results[i].index === index) {
92
- resultData.push(results[i].length);
93
- return;
94
- }
95
- }
96
- resultData.push(false);
97
- });
98
-
99
- // Write results
100
- try {
101
- fs.write(system.args[2], JSON.stringify(resultData, null, '\t'), 'w');
102
- } catch (err) {
103
- console.log('Error writing to target file');
104
- }
105
- phantom.exit();
@@ -1,60 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- 'use strict';
11
-
12
- /**
13
- * Default options for shape functions
14
- *
15
- * @type {object}
16
- */
17
- const defaults = {
18
- // List of tags that should be ignored
19
- ignoreTags: ['style', 'mask', 'clipPath', 'defs'],
20
-
21
- // List of shape tags
22
- shapeTags: [
23
- 'path',
24
- 'circle',
25
- 'line',
26
- 'polygon',
27
- 'polyline',
28
- 'rect',
29
- 'ellipse',
30
- ],
31
-
32
- // Index for first shape
33
- shapeStartIndex: 0,
34
-
35
- // Attribute to add to tags
36
- shapeAttribute: 'data-shape-index',
37
-
38
- // Value of attribute. {index} is replaced by index number
39
- shapeAttributeValue: '{index}',
40
-
41
- // True if tags should be removed rather than added
42
- remove: false,
43
-
44
- // Callback for shape. function({$node, node, index, tag, svg})
45
- // If callback returns false, attribute will not be added/removed
46
- shapeCallback: null,
47
- };
48
-
49
- module.exports = (options, moduleDefaults) => {
50
- Object.keys(defaults).forEach(key => {
51
- if (options[key] === void 0) {
52
- options[key] = defaults[key];
53
- }
54
- });
55
- Object.keys(moduleDefaults).forEach(key => {
56
- if (options[key] === void 0) {
57
- options[key] = moduleDefaults[key];
58
- }
59
- });
60
- };
package/src/svg.js DELETED
@@ -1,162 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- 'use strict';
11
-
12
- const cheerio = require('cheerio');
13
-
14
- class SVG {
15
- /**
16
- * Constructor
17
- *
18
- * @param {string} content SVG content
19
- */
20
- constructor(content) {
21
- this.load(content);
22
- }
23
-
24
- /**
25
- * Get SVG as string
26
- *
27
- * @return {string}
28
- */
29
- toString() {
30
- let $root = this.$svg(':root');
31
-
32
- // Add missing viewBox attribute
33
- if ($root.attr('viewBox') === void 0) {
34
- $root.attr(
35
- 'viewBox',
36
- this.left + ' ' + this.top + ' ' + this.width + ' ' + this.height
37
- );
38
- }
39
-
40
- // Add missing width/height
41
- if ($root.attr('width') === void 0) {
42
- $root.attr('width', this.width);
43
- }
44
- if ($root.attr('height') === void 0) {
45
- $root.attr('height', this.height);
46
- }
47
-
48
- return this.$svg.html();
49
- }
50
-
51
- /**
52
- * Get SVG as string without whitespaces
53
- *
54
- * @return {string}
55
- */
56
- toMinifiedString() {
57
- return this.toString().replace(/\s*\n\s*/g, '');
58
- }
59
-
60
- /**
61
- * Get body
62
- *
63
- * @return {string}
64
- */
65
- getBody() {
66
- return this.$svg('svg').html();
67
- }
68
-
69
- /**
70
- * Get dimensions
71
- *
72
- * @return {object}
73
- */
74
- getDimensions() {
75
- return {
76
- width: this.width,
77
- height: this.height,
78
- };
79
- }
80
-
81
- /**
82
- * Load SVG
83
- *
84
- * @param {string} content
85
- */
86
- load(content) {
87
- // Remove junk
88
- function remove(str1, str2, append) {
89
- let start = 0,
90
- end;
91
-
92
- while ((start = content.indexOf(str1, start)) !== -1) {
93
- end = content.indexOf(str2, start + str1.length);
94
- if (end === -1) {
95
- return;
96
- }
97
- content =
98
- content.slice(0, start) + append + content.slice(end + str2.length);
99
- start = start + append.length;
100
- }
101
- }
102
-
103
- // Remove comments
104
- remove('<!--', '-->', '');
105
-
106
- // Remove doctype and XML declaration
107
- remove('<?xml', '?>', '');
108
- remove('<!DOCTYPE svg', '<svg', '<svg');
109
-
110
- // Remove Adobe Illustrator junk
111
- remove(
112
- 'xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;"',
113
- '',
114
- ''
115
- );
116
- remove('xml:space="preserve"', '', '');
117
- remove('<foreignObject', '</foreignObject>', '');
118
-
119
- remove('<i:pgf', '</i:pgf>', '');
120
-
121
- // Entypo stuff
122
- remove('enable-background="', '"', '');
123
-
124
- // Remove empty <g> elements
125
- content = content.replace(/<g>\s*<\/g>/g, '');
126
-
127
- // Create _svg element
128
- this.$svg = cheerio.load(content.trim(), {
129
- lowerCaseAttributeNames: false,
130
- xmlMode: true,
131
- });
132
-
133
- // Check root
134
- let $root = this.$svg(':root');
135
- if ($root.length > 1 || $root.get(0).tagName !== 'svg') {
136
- throw new Error('Invalid SVG file');
137
- }
138
-
139
- // Get dimensions and origin
140
- let viewBox = $root.attr('viewBox');
141
- if (viewBox !== void 0) {
142
- let list = viewBox.split(' ');
143
-
144
- this.left = parseFloat(list[0]);
145
- this.top = parseFloat(list[1]);
146
- this.width = parseFloat(list[2]);
147
- this.height = parseFloat(list[3]);
148
- } else {
149
- this.left = this.top = 0;
150
- this.width = parseFloat($root.attr('width'));
151
- this.height = parseFloat($root.attr('height'));
152
- }
153
-
154
- ['width', 'height', 'left', 'top'].forEach(attr => {
155
- if (isNaN(this[attr])) {
156
- this[attr] = 0;
157
- }
158
- });
159
- }
160
- }
161
-
162
- module.exports = SVG;