deno.land / x / react_icons@0.2.3 / regen.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
// deno run --allow-read --allow-write .\regen.ts// du --exclude .git --exclude node_modules --bytes .// Maximum allowed size is 20971520 bytes, 20480 Kbytesimport * as path from "https://deno.land/std@0.165.0/path/mod.ts";import * as fs from "https://deno.land/std@0.165.0/fs/mod.ts";const src = 'node_modules/react-icons';const nextTag = '0.2.3';
// lioke original IconManifestinterface Provider { name: string licence: [string, string], projectUrl: string since: string, source?: string, to?: string, contributors?: string[],}
const packages: { [key: string]: Provider } = { ai: { name: 'Ant Design Icons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/ant-design/ant-design-icons', since: '2018', to: 'present', }, bs: { name: 'Bootstrap Icons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/twbs/icons', since: '2019', to: '2021', }, bi: { name: 'BoxIcons', licence: ['CC BY 4.0 License', 'https://github.com/atisawd/boxicons/blob/master/LICENSE'], projectUrl: 'https://github.com/atisawd/boxicons', since: '2015', to: '2021', }, ci: { name: 'Circum Icons', licence: ['MPL-2.0 license', 'https://github.com/Klarr-Agency/Circum-Icons/blob/main/LICENSE'], projectUrl: 'https://circumicons.com/', since: '2022', to: 'present', }, di: { name: 'Devicons', licence: ['MIT', 'https://github.com/Klarr-Agency/Circum-Icons/blob/main/LICENSE'], projectUrl: 'https://vorillaz.github.io/devicons/', source: 'https://github.com/vorillaz/devicons', since: '2014', }, fi: { name: 'Feather', licence: ['MIT', 'https://github.com/feathericons/feather/blob/master/LICENSE'], projectUrl: 'https://feathericons.com/', source: 'https://github.com/feathericons/feather', since: '2017', }, fc: { name: 'Devicons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/icons8/flat-color-icons', since: '2015' }, fa: { name: 'Font Awesome', licence: ['CC BY 4.0 License', 'https://creativecommons.org/licenses/by/4.0/'], projectUrl: 'https://fontawesome.com/', source: 'https://github.com/FortAwesome/Font-Awesome', since: '2012' }, gi: { name: 'Game Icons', licence: ['CC BY 3.0', 'https://creativecommons.org/licenses/by/3.0/'], projectUrl: 'https://game-icons.net/', source: 'https://github.com/game-icons/icons', since: '2015' }, go: { name: 'Github Octicons icons', licence: ['MIT', 'https://github.com/primer/octicons/blob/master/LICENSE'], projectUrl: 'https://octicons.github.com/', source: 'https://github.com/primer/octicons', since: '2014', }, gr: { name: 'Grommet-Icons', licence: ['Apache License Version 2.0', 'http://www.apache.org/licenses/'], projectUrl: 'https://github.com/grommet/grommet-icons', since: '2017', }, hi: { name: 'Heroicons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/tailwindlabs/heroicons', since: '2020', }, hi2: { name: 'Heroicons 2', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/tailwindlabs/heroicons', since: '2022', }, im: { name: 'IcoMoon Free', licence: ['CC BY 4.0 License', 'https://github.com/Keyamoon/IcoMoon-Free/blob/master/License.txt'], projectUrl: 'https://github.com/Keyamoon/IcoMoon-Free', since: '2014', }, io: { name: 'Ionicons 4', licence: ['MIT', 'https://github.com/ionic-team/ionicons/blob/master/LICENSE'], projectUrl: 'https://ionicons.com/', source: 'https://github.com/ionic-team/ionicons', since: '2015', }, io5: { name: 'Ionicons 5', licence: ['MIT', 'https://github.com/ionic-team/ionicons/blob/master/LICENSE'], projectUrl: 'https://ionicons.com/', source: 'https://github.com/ionic-team/ionicons', since: "2020", }, md: { name: 'Material Design icons', licence: ['Apache License Version 2.0', 'https://github.com/google/material-design-icons/blob/master/LICENSE'], projectUrl: 'http://google.github.io/material-design-icons/', source: 'https://github.com/google/material-design-icons', since: "2016", }, ri: { name: 'Remix Icon', licence: ['Apache License Version 2.0', 'http://www.apache.org/licenses/'], projectUrl: 'https://github.com/Remix-Design/RemixIcon', since: "2019", }, rx: { name: 'Radix Icons', licence: ['MIT', 'https://github.com/radix-ui/icons/blob/master/LICENSE'], projectUrl: 'https://icons.radix-ui.com', since: "2022", }, si: { name: 'Simple Icons', licence: ['CC0 1.0 Universal', 'https://creativecommons.org/publicdomain/zero/1.0/'], projectUrl: 'https://simpleicons.org/', source: 'https://github.com/simple-icons/simple-icons', since: "2015", }, sl: { name: 'Simple Line Icons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://thesabbir.github.io/simple-line-icons/', source: 'https://github.com/thesabbir/simple-line-icons', contributors: ['Sabbir Ahmed', 'All Contributors'], since: '2016' }, tb: { name: 'Tabler Icons', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/tabler/tabler-icons', since: '2020', }, tfi: { name: 'Themify Icons', licence: ['MIT', 'https://github.com/thecreation/standard-icons/blob/master/modules/themify-icons/LICENSE'], projectUrl: 'https://github.com/lykmapipo/themify-icons', since: '2014', }, ti: { name: 'Typicons', licence: ['CC BY-SA 3.0', 'https://creativecommons.org/licenses/by-sa/3.0/'], projectUrl: 'http://s-ings.com/typicons/', source: 'https://github.com/stephenhutchings/typicons.font', since: '2019', }, vsc: { name: 'VS Code Icons', licence: ['CC BY 4.0', 'https://creativecommons.org/licenses/by/4.0/'], projectUrl: 'https://github.com/microsoft/vscode-codicons', since: '2019', }, wi: { name: 'Weather Icons', licence: ['SIL OFL 1.1', 'http://scripts.sil.org/OFL'], projectUrl: 'https://erikflowers.github.io/weather-icons/', source: 'https://github.com/erikflowers/weather-icons', since: '2013', }, cg: { name: 'css.gg', licence: ['MIT', 'https://opensource.org/licenses/MIT'], projectUrl: 'https://github.com/astrit/css.gg', since: '2019', },};
for await (const dirEntry of Deno.readDir(src)) { if (dirEntry.isFile) continue; const { name } = dirEntry; if (name === 'lib') continue; // lib is not a provider if (name === 'io5') continue; // collision io io5 is too large if (name === 'io') continue; if (name === 'hi') continue; // collision hi2 if (name === 'hi2') continue; // collision hi too large const pkg = packages[name]; if (!pkg) throw Error(`no Licence for lib ${name}`) const esm = path.join(src, name, 'index.esm.js') let content = ''; try { content = await Deno.readTextFile(esm); } catch (_) { continue } content = content.replace(`import { GenIcon } from '../lib';`, `import { GenIcon, IconBaseProps } from "../lib/mod.tsx";`) content = content.replaceAll(` (props) {`, `(props: IconBaseProps) {`) for (const att of ['tag', 'viewBox', 'attr', 'child', 'd', 'id', 'dataName', 'strokeLinecap', 'strokeLinejoin', 'strokeWidth', 'fill', 'ariaHidden', 'fillRule', 'version', 'x', 'y', 'style', 'baseProfile', 'enableBackground', 'stroke']) content = content.replaceAll(new RegExp(`\s?"${att}"\s?:\s?`, 'g'), `${att}:`) content = content.replaceAll(/};(\s+)export/mg, '}$1export') content = content.replaceAll(/};(\s+)$/mg, '}$1') const first = content.match(/export function ([\w]+)\(props/)![1]; // console.log(first); const dest = path.join(name, 'mod.ts') /** * DOC */ const libName = pkg.name.replace(/ Icons^/, ''); let readme = `# ${libName} icons for deno / Preact\n\n` readme += `**License** [${pkg.licence[0]}](${pkg.licence[1]})\n\n` readme += `**Project** [${pkg.projectUrl}](${pkg.projectUrl})\n\n` readme += `[See available icons here](https://react-icons.github.io/react-icons/icons?name=${name})\n\n` readme += `## import_map.json\n\n`; readme += `For a transparent usage:\n\n`; readme += '```json\n'; readme += `{ "imports": { "preact": "https://esm.sh/preact@10.11.3", "preact/": "https://esm.sh/preact@10.11.3/", "react-icons/${name}": "https://deno.land/x/react_icons@${nextTag}/${name}/mod.ts", }}`; readme += '\n```\n\n'; readme += `## Direct import sample\n\n`; readme += '`import { ' + first + ' } from "https://deno.land/x/react_icons@' + nextTag + '/' + name + '/mod.ts"`\n\n'; readme += `## import_map import sample\n\n`; readme += '`import { ' + first + ' } from "react-icons/' + name + '"`\n\n'; readme += '@module'; // convert README TO comment README readme = '/**\n' + readme.split(/\r?\n/g).map((line) => ` * ${line}`).join('\n') + '\n */\n\n';
/** * code reduction: */ let shorted = ''; const short = { 'attr': ['{viewBox:"0 0 24 24"}', '{viewBox:"0 0 24 24",fill:"none"}', '{viewBox:"0 0 1024 1024"}', '{fill:"currentColor",viewBox:"0 0 16 16"}', '{version:"1.1",viewBox:"0 0 32 32"}', '{version:"1",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48"}', '{version:"1.1",viewBox:"0 0 16 16"}', '{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}', // tb '{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}', // fi '{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"}', '{version:"1.1",id:"Layer_1",x:"0px",y:"0px",viewBox:"0 0 30 30",style:"enable-background:new 0 0 30 30;"}', '{viewBox:"0 0 16 16",fill:"currentColor"}', '{"role":"img",viewBox:"0 0 24 24"}', '{version:"1.1",viewBox:"0 0 17 17"}', '{viewBox:"0 0 512 512"}', '{viewBox:"0 0 20 20",fill:"currentColor"}', '{viewBox:"0 0 10 16"}', ], 'tag': ['"path"'], 'fill': ['"currentColor"', '"none"'], 'stroke': ['"none"'] }; if (name === 'gr') { // remove all stroke to fix dark mode usage content = content.replaceAll(/,stroke:"[^"]+"/g, ''); content = content.replaceAll(/{stroke:"[^"]+",/g, '{');
} for (const [commonKey, commonAtts] of Object.entries(short)) { for (const commonAtt of commonAtts) { if (content.includes(`${commonKey}:${commonAtt}`)) { content = content.replaceAll(`${commonKey}:${commonAtt}`, commonKey); content = `const ${commonKey}=${commonAtt}\n${content}`; shorted += commonAtt + " "; break; } } } console.log(`generating ${dest} shorted:${shorted}`); await fs.ensureDir(name) const licenceHeader = `// Copyright ${pkg.since}-2022 the ${pkg.name} authors. All rights reserved. ${pkg.licence[0]} (${pkg.licence[1]}).\n` await Deno.writeTextFile(dest, licenceHeader + readme + content) // TODO Regen the main mod.ts}
react_icons

Version Info

Tagged at
a year ago