@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
@@ -0,0 +1,352 @@
1
+ // src/svg/data/attributes.ts
2
+ import { filterChildTags, shapeTags } from "./tags.mjs";
3
+ var badAttributes = new Set([
4
+ "cursor",
5
+ "pointer-events",
6
+ "shape-rendering",
7
+ "tabindex",
8
+ "requiredExtensions",
9
+ "requiredFeatures",
10
+ "systemLanguage",
11
+ "role",
12
+ "title"
13
+ ]);
14
+ var junkSVGAttributes = new Set([
15
+ "xmlns:xlink",
16
+ "baseProfile",
17
+ "contentScriptType",
18
+ "contentStyleType",
19
+ "version",
20
+ "x",
21
+ "y",
22
+ "zoomAndPan"
23
+ ]);
24
+ var badSoftwareAttributes = new Set([
25
+ "color-interpolation-filters",
26
+ "isolation",
27
+ "enable-background",
28
+ "overflow",
29
+ "marker",
30
+ "white-space",
31
+ "direction"
32
+ ]);
33
+ var badAttributePrefixes = new Set([
34
+ "image",
35
+ "mix",
36
+ "block",
37
+ "data",
38
+ "aria",
39
+ "text",
40
+ "font",
41
+ "letter",
42
+ "baseline",
43
+ "word",
44
+ "line",
45
+ "writing",
46
+ ""
47
+ ]);
48
+ var commonAttributes = new Set(["id"]);
49
+ var stylingAttributes = new Set(["class", "style"]);
50
+ var insideClipPathAttributes = new Set(["clip-rule"]);
51
+ var fillPresentationalAttributes = new Set([
52
+ "fill-opacity",
53
+ "fill-rule"
54
+ ]);
55
+ var strokePresentationalAttributes = new Set([
56
+ "stroke-dasharray",
57
+ "stroke-dashoffset",
58
+ "stroke-linecap",
59
+ "stroke-linejoin",
60
+ "stroke-miterlimit",
61
+ "stroke-opacity",
62
+ "stroke-width"
63
+ ]);
64
+ var urlPresentationalAttributes = new Set([
65
+ "clip-path",
66
+ "filter",
67
+ "mask"
68
+ ]);
69
+ var visibilityPresentationalAttributes = new Set([
70
+ "display",
71
+ "opacity",
72
+ "visibility"
73
+ ]);
74
+ var commonColorPresentationalAttributes = new Set([
75
+ "color",
76
+ "fill",
77
+ "stroke"
78
+ ]);
79
+ var otherPresentationalAttributes = new Set([
80
+ "color-interpolation",
81
+ "color-rendering",
82
+ "transform",
83
+ "vector-effect"
84
+ ]);
85
+ var presentationalAttributes = new Set([
86
+ ...fillPresentationalAttributes,
87
+ ...strokePresentationalAttributes,
88
+ ...urlPresentationalAttributes,
89
+ ...visibilityPresentationalAttributes,
90
+ ...commonColorPresentationalAttributes,
91
+ ...otherPresentationalAttributes
92
+ ]);
93
+ var markerAttributes = new Set([
94
+ "marker-start",
95
+ "marker-mid",
96
+ "marker-end"
97
+ ]);
98
+ var otherShapeAttributes = new Set(["pathLength"]);
99
+ var animationTimingAttributes = new Set([
100
+ "begin",
101
+ "dur",
102
+ "end",
103
+ "min",
104
+ "max",
105
+ "restart",
106
+ "repeatCount",
107
+ "repeatDur",
108
+ "fill"
109
+ ]);
110
+ var animationValueAttributes = new Set([
111
+ "calcMode",
112
+ "values",
113
+ "keyTimes",
114
+ "keySplines",
115
+ "from",
116
+ "to",
117
+ "by"
118
+ ]);
119
+ var otherAnimationAttributes = new Set([
120
+ "attributeName",
121
+ "additive",
122
+ "accumulate"
123
+ ]);
124
+ var commonGradientAttributes = new Set([
125
+ "gradientUnits",
126
+ "gradientTransform",
127
+ "href",
128
+ "spreadMethod"
129
+ ]);
130
+ var commonFeAttributes = new Set([
131
+ "x",
132
+ "y",
133
+ "width",
134
+ "height",
135
+ "color-interpolation-filters"
136
+ ]);
137
+ var feFuncAttributes = new Set([
138
+ "type",
139
+ "tableValues",
140
+ "slope",
141
+ "intercept",
142
+ "amplitude",
143
+ "exponent",
144
+ "offset",
145
+ ...commonFeAttributes
146
+ ]);
147
+ var tagSpecificAnimatedAttributes = {
148
+ circle: new Set(["cx", "cy", "r"]),
149
+ ellipse: new Set(["cx", "cy", "rx", "ry"]),
150
+ line: new Set(["x1", "x2", "y1", "y2"]),
151
+ path: new Set(["d"]),
152
+ polygon: new Set(["points"]),
153
+ polyline: new Set(["points"]),
154
+ rect: new Set(["x", "y", "width", "height", "rx", "ry"])
155
+ };
156
+ var tagSpecificPresentationalAttributes = {
157
+ svg: new Set(["width", "height", ...presentationalAttributes]),
158
+ clipPath: new Set([...presentationalAttributes]),
159
+ defs: new Set([...presentationalAttributes]),
160
+ g: new Set([...presentationalAttributes]),
161
+ mask: new Set(["x", "y", "width", "height", ...presentationalAttributes]),
162
+ symbol: new Set(["x", "y", "width", "height", ...presentationalAttributes]),
163
+ use: new Set([
164
+ "x",
165
+ "y",
166
+ "width",
167
+ "height",
168
+ "refX",
169
+ "refY",
170
+ ...presentationalAttributes
171
+ ]),
172
+ marker: new Set([...presentationalAttributes]),
173
+ linearGradient: new Set([
174
+ "x1",
175
+ "x2",
176
+ "y1",
177
+ "y2",
178
+ ...presentationalAttributes
179
+ ]),
180
+ radialGradient: new Set([
181
+ "cx",
182
+ "cy",
183
+ "fr",
184
+ "fx",
185
+ "fy",
186
+ "r",
187
+ ...presentationalAttributes
188
+ ]),
189
+ stop: new Set(["offset", "stop-color", "stop-opacity"]),
190
+ feFlood: new Set(["flood-color", "flood-opacity"]),
191
+ feDropShadow: new Set(["flood-color", "flood-opacity"])
192
+ };
193
+ shapeTags.forEach((tag) => {
194
+ tagSpecificPresentationalAttributes[tag] = new Set([
195
+ ...presentationalAttributes,
196
+ ...markerAttributes,
197
+ ...tagSpecificPresentationalAttributes[tag] || []
198
+ ]);
199
+ });
200
+ filterChildTags.forEach((tag) => {
201
+ tagSpecificPresentationalAttributes[tag] = new Set([
202
+ ...commonFeAttributes,
203
+ ...tagSpecificPresentationalAttributes[tag] || []
204
+ ]);
205
+ });
206
+ var tagSpecificNonPresentationalAttributes = {
207
+ svg: new Set(["xmlns", "viewBox", "preserveAspectRatio"]),
208
+ clipPath: new Set(["clipPathUnits"]),
209
+ mask: new Set(["maskContentUnits", "maskUnits"]),
210
+ symbol: new Set(["viewBox", "preserveAspectRatio"]),
211
+ circle: new Set([...otherShapeAttributes]),
212
+ ellipse: new Set([...otherShapeAttributes]),
213
+ line: new Set([...otherShapeAttributes]),
214
+ path: new Set([...otherShapeAttributes]),
215
+ polygon: new Set([...otherShapeAttributes]),
216
+ polyline: new Set([...otherShapeAttributes]),
217
+ rect: new Set([...otherShapeAttributes]),
218
+ use: new Set(["href"]),
219
+ marker: new Set([
220
+ "markerHeight",
221
+ "markerUnits",
222
+ "markerWidth",
223
+ "orient",
224
+ "preserveAspectRatio",
225
+ "refX",
226
+ "refY",
227
+ "viewBox"
228
+ ]),
229
+ animate: new Set([
230
+ ...animationTimingAttributes,
231
+ ...animationValueAttributes,
232
+ ...otherAnimationAttributes
233
+ ]),
234
+ animateMotion: new Set([
235
+ "keyPoints",
236
+ "path",
237
+ "rotate",
238
+ ...animationTimingAttributes,
239
+ ...animationValueAttributes,
240
+ ...otherAnimationAttributes
241
+ ]),
242
+ animateTransform: new Set([
243
+ "by",
244
+ "from",
245
+ "to",
246
+ "type",
247
+ ...animationTimingAttributes,
248
+ ...animationValueAttributes,
249
+ ...otherAnimationAttributes
250
+ ]),
251
+ discard: new Set(["begin", "href"]),
252
+ set: new Set([
253
+ "to",
254
+ ...animationTimingAttributes,
255
+ ...otherAnimationAttributes
256
+ ]),
257
+ mpath: new Set(["href"]),
258
+ linearGradient: new Set([...commonGradientAttributes]),
259
+ radialGradient: new Set([...commonGradientAttributes]),
260
+ feSpotLight: new Set([
261
+ "x",
262
+ "y",
263
+ "z",
264
+ "pointsAtX",
265
+ "pointsAtY",
266
+ "pointsAtZ",
267
+ "specularExponent",
268
+ "limitingConeAngle"
269
+ ]),
270
+ feBlend: new Set(["in", "in2", "mode"]),
271
+ feColorMatrix: new Set(["in", "type", "values"]),
272
+ feComponentTransfer: new Set(["in"]),
273
+ feComposite: new Set(["in", "in2", "operator", "k1", "k2", "k3", "k4"]),
274
+ feConvolveMatrix: new Set([
275
+ "in",
276
+ "order",
277
+ "kernelMatrix",
278
+ "divisor",
279
+ "bias",
280
+ "targetX",
281
+ "targetY",
282
+ "edgeMode",
283
+ "kernelUnitLength",
284
+ "preserveAlpha"
285
+ ]),
286
+ feDiffuseLighting: new Set([
287
+ "in",
288
+ "surfaceScale",
289
+ "diffuseConstant",
290
+ "kernelUnitLength"
291
+ ]),
292
+ feDisplacementMap: new Set([
293
+ "in",
294
+ "in2",
295
+ "scale",
296
+ "xChannelSelector",
297
+ "yChannelSelector"
298
+ ]),
299
+ feDistantLight: new Set(["azimuth", "elevation"]),
300
+ feDropShadow: new Set(["dx", "dy", "stdDeviation"]),
301
+ feGaussianBlur: new Set(["in", "stdDeviation", "edgeMode"]),
302
+ feFuncA: feFuncAttributes,
303
+ feFuncR: feFuncAttributes,
304
+ feFuncG: feFuncAttributes,
305
+ feFuncB: feFuncAttributes,
306
+ feMergeNode: new Set(["in"]),
307
+ feMorphology: new Set(["in", "operator", "radius"]),
308
+ feOffset: new Set(["in", "dx", "dy"]),
309
+ fePointLight: new Set(["x", "y", "z"]),
310
+ feSpecularLighting: new Set([
311
+ "in",
312
+ "surfaceScale",
313
+ "specularConstant",
314
+ "specularExponent",
315
+ "kernelUnitLength"
316
+ ]),
317
+ feTile: new Set(["in"]),
318
+ feTurbulence: new Set([
319
+ "baseFrequency",
320
+ "numOctaves",
321
+ "seed",
322
+ "stitchTiles",
323
+ "type"
324
+ ])
325
+ };
326
+ export {
327
+ animationTimingAttributes,
328
+ animationValueAttributes,
329
+ badAttributePrefixes,
330
+ badAttributes,
331
+ badSoftwareAttributes,
332
+ commonAttributes,
333
+ commonColorPresentationalAttributes,
334
+ commonFeAttributes,
335
+ commonGradientAttributes,
336
+ feFuncAttributes,
337
+ fillPresentationalAttributes,
338
+ insideClipPathAttributes,
339
+ junkSVGAttributes,
340
+ markerAttributes,
341
+ otherAnimationAttributes,
342
+ otherPresentationalAttributes,
343
+ otherShapeAttributes,
344
+ presentationalAttributes,
345
+ strokePresentationalAttributes,
346
+ stylingAttributes,
347
+ tagSpecificAnimatedAttributes,
348
+ tagSpecificNonPresentationalAttributes,
349
+ tagSpecificPresentationalAttributes,
350
+ urlPresentationalAttributes,
351
+ visibilityPresentationalAttributes
352
+ };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
3
+ * Icons cannot have anything that requires external resources, anything that renders inconsistently.
4
+ */
5
+ /**
6
+ * Bad tags
7
+ *
8
+ * Parser should throw error if one of these tags is found
9
+ *
10
+ * List includes text tags because:
11
+ * - it usuaully uses custom font, which makes things much more complex
12
+ * - it renders differently on different operating systems and browsers
13
+ *
14
+ * View tag is not allowed because it requires targeting view by id from external source, making it unusable in embedded icons.
15
+ */
16
+ export declare const badTags: Set<string>;
17
+ /**
18
+ * Deprecated or irrelevant tags
19
+ *
20
+ * Tags that are quietly removed
21
+ */
22
+ export declare const unsupportedTags: Set<string>;
23
+ /**
24
+ * Style
25
+ */
26
+ export declare const styleTag: Set<string>;
27
+ /**
28
+ * Definitions: reusable elements inside
29
+ */
30
+ export declare const defsTag: Set<string>;
31
+ /**
32
+ * Masks: colors are ignored, child elements must have id
33
+ */
34
+ export declare const maskAndSymbolTags: Set<string>;
35
+ /**
36
+ * SVG shapes
37
+ */
38
+ export declare const shapeTags: Set<string>;
39
+ /**
40
+ * Use
41
+ */
42
+ export declare const useTag: Set<string>;
43
+ /**
44
+ * Groups
45
+ */
46
+ export declare const groupTag: Set<string>;
47
+ /**
48
+ * Marker, must be inside <defs>
49
+ */
50
+ export declare const markerTag: Set<string>;
51
+ /**
52
+ * SVG animations
53
+ */
54
+ export declare const animateTags: Set<string>;
55
+ export declare const animateMotionChildTags: Set<string>;
56
+ /**
57
+ * Gradients, must be inside <defs>
58
+ */
59
+ export declare const gradientTags: Set<string>;
60
+ /**
61
+ * Gradient color, must be inside one of gradientTags
62
+ */
63
+ export declare const gradientChildTags: Set<string>;
64
+ /**
65
+ * Pattern, must be inside <defs>
66
+ */
67
+ export declare const patternTag: Set<string>;
68
+ /**
69
+ * Filters
70
+ */
71
+ export declare const filterTag: Set<string>;
72
+ export declare const feLightningTags: Set<string>;
73
+ export declare const filterChildTags: Set<string>;
74
+ export declare const feComponentTransferChildTag: Set<string>;
75
+ export declare const feLightningChildTags: Set<string>;
76
+ export declare const feMergeChildTags: Set<string>;
77
+ /***** Combination of tags *****/
78
+ /**
79
+ * Tags that can be used only inside <defs>
80
+ */
81
+ export declare const tagsInsideDefs: Set<string>;
82
+ /**
83
+ * Parent tags for animations
84
+ */
85
+ export declare const tagsBeforeAnimation: Set<string>;
86
+ /**
87
+ * All supported tags
88
+ */
89
+ export declare const allValidTags: Set<string>;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ /**
3
+ * This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
4
+ * Icons cannot have anything that requires external resources, anything that renders inconsistently.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.allValidTags = exports.tagsBeforeAnimation = exports.tagsInsideDefs = exports.feMergeChildTags = exports.feLightningChildTags = exports.feComponentTransferChildTag = exports.filterChildTags = exports.feLightningTags = exports.filterTag = exports.patternTag = exports.gradientChildTags = exports.gradientTags = exports.animateMotionChildTags = exports.animateTags = exports.markerTag = exports.groupTag = exports.useTag = exports.shapeTags = exports.maskAndSymbolTags = exports.defsTag = exports.styleTag = exports.unsupportedTags = exports.badTags = void 0;
8
+ /**
9
+ * Bad tags
10
+ *
11
+ * Parser should throw error if one of these tags is found
12
+ *
13
+ * List includes text tags because:
14
+ * - it usuaully uses custom font, which makes things much more complex
15
+ * - it renders differently on different operating systems and browsers
16
+ *
17
+ * View tag is not allowed because it requires targeting view by id from external source, making it unusable in embedded icons.
18
+ */
19
+ exports.badTags = new Set([
20
+ // Nasty stuff or external resource
21
+ 'foreignObject',
22
+ 'script',
23
+ 'image',
24
+ 'feImage',
25
+ // Deprecated
26
+ 'animateColor',
27
+ 'altGlyph',
28
+ // Text
29
+ 'text',
30
+ 'tspan',
31
+ 'switch',
32
+ 'textPath',
33
+ // Font
34
+ 'font',
35
+ 'font-face',
36
+ 'glyph',
37
+ 'missing-glyph',
38
+ 'hkern',
39
+ 'vhern',
40
+ // View
41
+ 'view',
42
+ // Link
43
+ 'a',
44
+ ]);
45
+ /**
46
+ * Deprecated or irrelevant tags
47
+ *
48
+ * Tags that are quietly removed
49
+ */
50
+ exports.unsupportedTags = new Set(['metadata', 'desc', 'title']);
51
+ /**
52
+ * Style
53
+ */
54
+ exports.styleTag = new Set(['style']);
55
+ /**
56
+ * Definitions: reusable elements inside
57
+ */
58
+ exports.defsTag = new Set(['defs']);
59
+ /**
60
+ * Masks: colors are ignored, child elements must have id
61
+ */
62
+ exports.maskAndSymbolTags = new Set(['clipPath', 'mask', 'symbol']);
63
+ /**
64
+ * SVG shapes
65
+ */
66
+ exports.shapeTags = new Set([
67
+ 'circle',
68
+ 'ellipse',
69
+ 'line',
70
+ 'path',
71
+ 'polygon',
72
+ 'polyline',
73
+ 'rect',
74
+ ]);
75
+ /**
76
+ * Use
77
+ */
78
+ exports.useTag = new Set(['use']);
79
+ /**
80
+ * Groups
81
+ */
82
+ exports.groupTag = new Set(['g']);
83
+ /**
84
+ * Marker, must be inside <defs>
85
+ */
86
+ exports.markerTag = new Set(['marker']);
87
+ /**
88
+ * SVG animations
89
+ */
90
+ exports.animateTags = new Set([
91
+ 'animate',
92
+ 'animateMotion',
93
+ 'animateTransform',
94
+ 'discard',
95
+ 'set',
96
+ ]);
97
+ exports.animateMotionChildTags = new Set(['mpath']);
98
+ /**
99
+ * Gradients, must be inside <defs>
100
+ */
101
+ exports.gradientTags = new Set(['linearGradient', 'radialGradient']);
102
+ /**
103
+ * Gradient color, must be inside one of gradientTags
104
+ */
105
+ exports.gradientChildTags = new Set(['stop']);
106
+ /**
107
+ * Pattern, must be inside <defs>
108
+ */
109
+ exports.patternTag = new Set(['pattern']);
110
+ /**
111
+ * Filters
112
+ */
113
+ exports.filterTag = new Set(['filter']);
114
+ exports.feLightningTags = new Set([
115
+ 'feDiffuseLighting',
116
+ 'feSpecularLighting',
117
+ ]);
118
+ exports.filterChildTags = new Set([
119
+ 'feBlend',
120
+ 'feColorMatrix',
121
+ 'feComponentTransfer',
122
+ 'feComposite',
123
+ 'feConvolveMatrix',
124
+ 'feDisplacementMap',
125
+ 'feDropShadow',
126
+ 'feFlood',
127
+ 'feGaussianBlur',
128
+ 'feMerge',
129
+ 'feMorphology',
130
+ 'feOffset',
131
+ 'feTile',
132
+ 'feTurbulence',
133
+ ...exports.feLightningTags,
134
+ ]);
135
+ exports.feComponentTransferChildTag = new Set([
136
+ 'feFuncR',
137
+ 'feFuncG',
138
+ 'feFuncB',
139
+ 'feFuncA',
140
+ ]);
141
+ exports.feLightningChildTags = new Set([
142
+ 'feSpotLight',
143
+ 'fePointLight',
144
+ 'feDistantLight',
145
+ ]);
146
+ exports.feMergeChildTags = new Set(['feMergeNode']);
147
+ /***** Combination of tags *****/
148
+ /**
149
+ * Tags that can be used only inside <defs>
150
+ */
151
+ exports.tagsInsideDefs = new Set([
152
+ ...exports.gradientTags,
153
+ ...exports.patternTag,
154
+ ...exports.markerTag,
155
+ ]);
156
+ /**
157
+ * Parent tags for animations
158
+ */
159
+ exports.tagsBeforeAnimation = new Set([
160
+ ...exports.shapeTags,
161
+ ...exports.filterChildTags,
162
+ ...exports.feComponentTransferChildTag,
163
+ ]);
164
+ /**
165
+ * All supported tags
166
+ */
167
+ exports.allValidTags = new Set([
168
+ ...exports.styleTag,
169
+ ...exports.defsTag,
170
+ ...exports.maskAndSymbolTags,
171
+ ...exports.shapeTags,
172
+ ...exports.useTag,
173
+ ...exports.groupTag,
174
+ ...exports.markerTag,
175
+ ...exports.animateTags,
176
+ ...exports.animateMotionChildTags,
177
+ ...exports.gradientTags,
178
+ ...exports.gradientChildTags,
179
+ ...exports.patternTag,
180
+ ...exports.filterTag,
181
+ ...exports.filterChildTags,
182
+ ...exports.feComponentTransferChildTag,
183
+ ...exports.feLightningChildTags,
184
+ ...exports.feMergeChildTags,
185
+ ]);