@ship-ui/core 0.13.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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/assets/fonts/InterTight-VariableFont_wght.woff2 +0 -0
- package/bin/ship-fg-node +40 -0
- package/bin/ship-fg.ts +40 -0
- package/bin/src/ship-fg-node.js +344 -0
- package/bin/src/ship-fg.ts +368 -0
- package/bin/src/utilities.js +53 -0
- package/bin/src/utilities.ts +98 -0
- package/bin/tsconfig.app.json +15 -0
- package/fesm2022/ship-ui-core.mjs +5373 -0
- package/fesm2022/ship-ui-core.mjs.map +1 -0
- package/index.d.ts +758 -0
- package/package.json +52 -0
- package/styles/components/ship-alert-container.component.scss +49 -0
- package/styles/components/ship-alert.component.scss +273 -0
- package/styles/components/ship-button-group.component.scss +63 -0
- package/styles/components/ship-button.component.scss +330 -0
- package/styles/components/ship-card.component.scss +54 -0
- package/styles/components/ship-checkbox.component.scss +245 -0
- package/styles/components/ship-chip.component.scss +290 -0
- package/styles/components/ship-color-picker.component.scss +78 -0
- package/styles/components/ship-datepicker.component.scss +274 -0
- package/styles/components/ship-dialog.component.scss +119 -0
- package/styles/components/ship-divider.component.scss +27 -0
- package/styles/components/ship-file-upload.component.scss +47 -0
- package/styles/components/ship-form-field.component.scss +334 -0
- package/styles/components/ship-icon.component.scss +54 -0
- package/styles/components/ship-list.component.scss +148 -0
- package/styles/components/ship-menu.component.scss +217 -0
- package/styles/components/ship-popover.component.scss +66 -0
- package/styles/components/ship-progress-bar.component.scss +173 -0
- package/styles/components/ship-radio.component.scss +182 -0
- package/styles/components/ship-range-slider.component.scss +412 -0
- package/styles/components/ship-select.component.scss +139 -0
- package/styles/components/ship-sidenav.component.scss +192 -0
- package/styles/components/ship-sortable.component.scss +54 -0
- package/styles/components/ship-spinner.component.scss +53 -0
- package/styles/components/ship-stepper.component.scss +138 -0
- package/styles/components/ship-table.component.scss +402 -0
- package/styles/components/ship-tabs.component.scss +86 -0
- package/styles/components/ship-toggle-card.component.scss +71 -0
- package/styles/components/ship-toggle.component.scss +238 -0
- package/styles/components/ship-tooltip.component.scss +175 -0
- package/styles/components/ship-virtual-scroll.component.scss +12 -0
- package/styles/components/sparkle-checkbox.component.scss +245 -0
- package/styles/components/sparkle-select.component.scss +139 -0
- package/styles/core/apexcharts/apexcharts.scss +58 -0
- package/styles/core/core/layout.scss +74 -0
- package/styles/core/core/loader.scss +63 -0
- package/styles/core/core/palette-variables.scss +352 -0
- package/styles/core/core/typography.scss +103 -0
- package/styles/core/core/variables.scss +188 -0
- package/styles/core/core.scss +4 -0
- package/styles/core/fonts/_inter-tight.scss +11 -0
- package/styles/core/helpers/fn/color-mix.scss +7 -0
- package/styles/core/helpers/fn/dp.scss +14 -0
- package/styles/core/helpers/fn/p2r.scss +23 -0
- package/styles/core/helpers/mixins/border-gradient.scss +61 -0
- package/styles/core/helpers/mixins/breakpoint.scss +217 -0
- package/styles/core/helpers/mixins/ellipsis.scss +7 -0
- package/styles/core/helpers/mixins/overflow-scrolling.scss +18 -0
- package/styles/core/helpers/mixins/wrapper.scss +16 -0
- package/styles/core/polyfill/light-dark.scss +3 -0
- package/styles/helpers.scss +13 -0
- package/styles/index.scss +146 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Simon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
Binary file
|
package/bin/ship-fg-node
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { parseArgs } from 'util';
|
|
4
|
+
import { main } from './src/ship-fg-node.js'; // Added .js extension for ESM imports
|
|
5
|
+
|
|
6
|
+
const { values } = parseArgs({
|
|
7
|
+
args: process.argv, // Changed from Bun.argv to process.argv
|
|
8
|
+
options: {
|
|
9
|
+
src: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
},
|
|
12
|
+
out: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
rootPath: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
default: '/',
|
|
18
|
+
},
|
|
19
|
+
watch: {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
watchLib: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
verbose: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
allowPositionals: true,
|
|
33
|
+
strict: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (values.src === undefined || values.out === undefined) {
|
|
37
|
+
throw new Error('src and out are both required arguments');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
main(values);
|
package/bin/ship-fg.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { parseArgs } from 'util';
|
|
4
|
+
import { main } from './src/sparkle-fg';
|
|
5
|
+
|
|
6
|
+
const { values } = parseArgs({
|
|
7
|
+
args: Bun.argv,
|
|
8
|
+
options: {
|
|
9
|
+
src: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
},
|
|
12
|
+
out: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
rootPath: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
default: '/',
|
|
18
|
+
},
|
|
19
|
+
watch: {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
watchLib: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
verbose: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
allowPositionals: true,
|
|
33
|
+
strict: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (values.src === undefined || values.out === undefined) {
|
|
37
|
+
throw new Error('src and out are both required arguments');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
main(values as any);
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { promises as fs, watch } from 'fs';
|
|
2
|
+
import { glob } from 'glob';
|
|
3
|
+
import path, { join, resolve } from 'path';
|
|
4
|
+
import { performance } from 'perf_hooks';
|
|
5
|
+
import zlib from 'zlib';
|
|
6
|
+
|
|
7
|
+
import subsetFont from 'subset-font';
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { formatFileSize, getUnicodeObject } from './utilities.js';
|
|
11
|
+
|
|
12
|
+
let writtenCssSize = 0;
|
|
13
|
+
let compressedCssSize = 0;
|
|
14
|
+
|
|
15
|
+
const run = async (PROJECT_SRC, LIB_ICONS, PROJECT_PUBLIC, GLYPH_MAP, TARGET_FONT_TYPE, values) => {
|
|
16
|
+
const startTime = performance.now();
|
|
17
|
+
|
|
18
|
+
const regex = /<sh-icon[^>]*>\s*((?!{{.*?}})[^<]*?)\s*<\/sh-icon>/g;
|
|
19
|
+
const regex2 = /sh:([^']+)/g;
|
|
20
|
+
const iconsFound = new Set(LIB_ICONS);
|
|
21
|
+
const missingIcons = new Set();
|
|
22
|
+
|
|
23
|
+
const htmlFiles = await glob('**/*.html', { cwd: PROJECT_SRC });
|
|
24
|
+
for (const file of htmlFiles) {
|
|
25
|
+
const fileText = await fs.readFile(join(PROJECT_SRC, file), 'utf8');
|
|
26
|
+
const matches = Array.from(fileText.matchAll(regex), (m) => m[1]);
|
|
27
|
+
|
|
28
|
+
if (matches?.length) {
|
|
29
|
+
for (const match of matches) {
|
|
30
|
+
if (match) iconsFound.add(match);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const tsFiles = await glob('**/*.ts', { cwd: PROJECT_SRC });
|
|
36
|
+
for (const file of tsFiles) {
|
|
37
|
+
const fileText = await fs.readFile(join(PROJECT_SRC, file), 'utf8');
|
|
38
|
+
const matches = Array.from(fileText.matchAll(regex2), (m) => m[1]);
|
|
39
|
+
|
|
40
|
+
if (matches?.length) {
|
|
41
|
+
for (const match of matches) {
|
|
42
|
+
if (match) iconsFound.add(match);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const groupedIcons = Array.from(iconsFound).reduce(
|
|
48
|
+
(acc, icon) => {
|
|
49
|
+
const bold = icon.endsWith('-bold');
|
|
50
|
+
const thin = icon.endsWith('-thin');
|
|
51
|
+
const light = icon.endsWith('-light');
|
|
52
|
+
const fill = icon.endsWith('-fill');
|
|
53
|
+
const regular = !bold && !thin && !light && !fill;
|
|
54
|
+
const glyph = GLYPH_MAP[icon];
|
|
55
|
+
|
|
56
|
+
if (!glyph) {
|
|
57
|
+
missingIcons.add(icon);
|
|
58
|
+
return acc;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (bold) {
|
|
62
|
+
acc['bold'].push([icon, '']);
|
|
63
|
+
acc['bold'].push(glyph);
|
|
64
|
+
}
|
|
65
|
+
if (thin) {
|
|
66
|
+
acc['thin'].push([icon, '']);
|
|
67
|
+
acc['thin'].push(glyph);
|
|
68
|
+
}
|
|
69
|
+
if (light) {
|
|
70
|
+
acc['light'].push([icon, '']);
|
|
71
|
+
acc['light'].push(glyph);
|
|
72
|
+
}
|
|
73
|
+
if (fill) {
|
|
74
|
+
acc['fill'].push([icon, '']);
|
|
75
|
+
acc['fill'].push(glyph);
|
|
76
|
+
}
|
|
77
|
+
if (regular) {
|
|
78
|
+
acc['regular'].push([icon, '']);
|
|
79
|
+
acc['regular'].push(glyph);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return acc;
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
bold: [],
|
|
86
|
+
thin: [],
|
|
87
|
+
light: [],
|
|
88
|
+
fill: [],
|
|
89
|
+
regular: [],
|
|
90
|
+
text: [],
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const missingIconsArray = Array.from(missingIcons);
|
|
95
|
+
|
|
96
|
+
if (missingIconsArray.length) {
|
|
97
|
+
console.log('Following icons does not exist in font: \n ', missingIconsArray);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await writeCssFile(PROJECT_PUBLIC, values, groupedIcons, TARGET_FONT_TYPE);
|
|
101
|
+
|
|
102
|
+
const fontTypes = ['bold', 'thin', 'light', 'fill', 'regular'].filter((x) => groupedIcons[x].length > 0);
|
|
103
|
+
const targetFormat = TARGET_FONT_TYPE === 'ttf' ? 'truetype' : TARGET_FONT_TYPE;
|
|
104
|
+
const fonts = fontTypes.map(async (fontType) => {
|
|
105
|
+
const glyphs = uniqueString(groupedIcons[fontType].map((icon) => icon[0]).join(''));
|
|
106
|
+
const fontFileName = `Phosphor${fontType === 'regular' ? '' : '-' + capitalize(fontType)}.${TARGET_FONT_TYPE}`;
|
|
107
|
+
const fullPath = path.resolve(
|
|
108
|
+
process.cwd(),
|
|
109
|
+
'node_modules',
|
|
110
|
+
'@phosphor-icons',
|
|
111
|
+
'web',
|
|
112
|
+
'src',
|
|
113
|
+
fontType,
|
|
114
|
+
fontFileName
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const arrayBuffer = await fs.readFile(fullPath);
|
|
118
|
+
const subsetBuffer = await subsetFont(arrayBuffer, glyphs, {
|
|
119
|
+
targetFormat,
|
|
120
|
+
noLayoutClosure: true,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return subsetBuffer;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const _fonts = await Promise.all(fonts);
|
|
127
|
+
let totalFontSize = 0;
|
|
128
|
+
let totalCompressedFontSize = 0;
|
|
129
|
+
|
|
130
|
+
for (let i = 0; i < _fonts.length; i++) {
|
|
131
|
+
const subsetBuffer = _fonts[i];
|
|
132
|
+
const fontType = fontTypes[i];
|
|
133
|
+
const outputPath = `${PROJECT_PUBLIC}/sh${fontType === 'regular' ? '' : '-' + fontType}.${TARGET_FONT_TYPE}`;
|
|
134
|
+
|
|
135
|
+
await fs.writeFile(outputPath, subsetBuffer);
|
|
136
|
+
const fontWrites = subsetBuffer.length;
|
|
137
|
+
|
|
138
|
+
const compressedFont = zlib.gzipSync(subsetBuffer);
|
|
139
|
+
const iconsOnGroup = groupedIcons[fontType].filter((icon) => icon[1] === '').map((icon) => icon[0]);
|
|
140
|
+
|
|
141
|
+
totalFontSize += fontWrites;
|
|
142
|
+
totalCompressedFontSize += compressedFont.length;
|
|
143
|
+
|
|
144
|
+
if (values.verbose) {
|
|
145
|
+
console.log('Group: ', fontType, '\n', iconsOnGroup);
|
|
146
|
+
console.log(
|
|
147
|
+
`Font & CSS (Generated/Compressed size): ${formatFileSize(fontWrites)}/${formatFileSize(compressedFont.length)}`
|
|
148
|
+
);
|
|
149
|
+
console.log(' ');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const endTime = performance.now();
|
|
154
|
+
const runtime = endTime - startTime;
|
|
155
|
+
console.log(
|
|
156
|
+
`Font & CSS (Generated/Compressed size): ${formatFileSize(totalFontSize + writtenCssSize)}/${formatFileSize(totalCompressedFontSize + compressedCssSize)}`
|
|
157
|
+
);
|
|
158
|
+
console.log('Time taken: ', runtime.toFixed(2) + 'ms');
|
|
159
|
+
console.log(' ');
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
function uniqueString(s) {
|
|
163
|
+
const seen = new Set();
|
|
164
|
+
let result = '';
|
|
165
|
+
|
|
166
|
+
for (const char of s) {
|
|
167
|
+
if (!seen.has(char)) {
|
|
168
|
+
seen.add(char);
|
|
169
|
+
result += char;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const writeCssFile = async (PROJECT_PUBLIC, values, groupedIcons, TARGET_FONT_TYPE = 'woff2') => {
|
|
176
|
+
const groupedIconsEntries = Object.entries(groupedIcons).map(([key, value], i) => {
|
|
177
|
+
if (key === 'text') return '';
|
|
178
|
+
|
|
179
|
+
const suffix = key === 'regular' ? '' : '-' + key;
|
|
180
|
+
const fontUrl = `url('${values.rootPath}sh${suffix}.${TARGET_FONT_TYPE}') format('${TARGET_FONT_TYPE === 'ttf' ? 'truetype' : TARGET_FONT_TYPE}')`;
|
|
181
|
+
|
|
182
|
+
return `
|
|
183
|
+
@font-face {
|
|
184
|
+
font-family: 'sh${suffix}';
|
|
185
|
+
src: ${fontUrl};
|
|
186
|
+
font-weight: normal;
|
|
187
|
+
font-style: normal;
|
|
188
|
+
font-display: block;
|
|
189
|
+
}`;
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const keys = Object.keys(groupedIcons).map((key) => {
|
|
193
|
+
if (['regular', 'text'].includes(key)) return '';
|
|
194
|
+
|
|
195
|
+
const suffix = key === 'regular' ? '' : '-' + key;
|
|
196
|
+
|
|
197
|
+
return `
|
|
198
|
+
sh-icon.${key} {
|
|
199
|
+
font-family: 'sh${suffix}' !important;
|
|
200
|
+
}`;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const cssFileContent = `
|
|
204
|
+
${groupedIconsEntries.join('\n')}
|
|
205
|
+
${keys.join('\n')}
|
|
206
|
+
sh-icon {
|
|
207
|
+
font-family: "sh" !important;
|
|
208
|
+
speak: never;
|
|
209
|
+
font-style: normal;
|
|
210
|
+
font-weight: normal;
|
|
211
|
+
font-variant: normal;
|
|
212
|
+
text-transform: none;
|
|
213
|
+
line-height: 1;
|
|
214
|
+
|
|
215
|
+
letter-spacing: 0;
|
|
216
|
+
-webkit-font-feature-settings: "liga";
|
|
217
|
+
-moz-font-feature-settings: "liga=1";
|
|
218
|
+
-moz-font-feature-settings: "liga";
|
|
219
|
+
-ms-font-feature-settings: "liga" 1;
|
|
220
|
+
font-feature-settings: "liga";
|
|
221
|
+
-webkit-font-variant-ligatures: discretionary-ligatures;
|
|
222
|
+
font-variant-ligatures: discretionary-ligatures;
|
|
223
|
+
|
|
224
|
+
-webkit-font-smoothing: antialiased;
|
|
225
|
+
-moz-osx-font-smoothing: grayscale;
|
|
226
|
+
}`;
|
|
227
|
+
|
|
228
|
+
const cssOutputPath = `${PROJECT_PUBLIC}/ship.css`;
|
|
229
|
+
await fs.writeFile(cssOutputPath, cssFileContent);
|
|
230
|
+
const cssWrites = Buffer.byteLength(cssFileContent, 'utf8');
|
|
231
|
+
|
|
232
|
+
const compressedCss = zlib.gzipSync(Buffer.from(cssFileContent, 'utf8'));
|
|
233
|
+
|
|
234
|
+
writtenCssSize = cssWrites;
|
|
235
|
+
compressedCssSize = compressedCss.length;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const textMateSnippet = async (GLYPH_MAP) => {
|
|
239
|
+
const iconsSnippetContent = `
|
|
240
|
+
{
|
|
241
|
+
"Phosphor icons": {
|
|
242
|
+
"prefix": ["pp:icon"],
|
|
243
|
+
"scope": "javascript,typescript,html",
|
|
244
|
+
"body": "\${1|${Object.keys(GLYPH_MAP).join(',')}|}",
|
|
245
|
+
"description": "Add a phosphor icon"
|
|
246
|
+
},
|
|
247
|
+
"Ship sh-icon": {
|
|
248
|
+
"prefix": ["sh-icon"],
|
|
249
|
+
"scope": "html",
|
|
250
|
+
"body": "<sh-icon>\${1|${Object.keys(GLYPH_MAP).join(',')}|}</sh-icon>",
|
|
251
|
+
"description": "Add a ship phosphor icon"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
const vscodeDir = './.vscode';
|
|
257
|
+
await fs.mkdir(vscodeDir, { recursive: true });
|
|
258
|
+
await fs.writeFile('./.vscode/html.code-snippets', iconsSnippetContent);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
function capitalize(str) {
|
|
262
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export const main = async (values) => {
|
|
266
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
267
|
+
const __dirname = path.dirname(__filename);
|
|
268
|
+
const TARGET_FONT_TYPE = 'woff2';
|
|
269
|
+
const packageJsonPath = resolve(__dirname, '../../package.json');
|
|
270
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
271
|
+
const PROJECT_SRC = values.src;
|
|
272
|
+
const PROJECT_PUBLIC = values.out;
|
|
273
|
+
const fontVariants = ['bold', 'thin', 'light', 'fill', 'regular'];
|
|
274
|
+
|
|
275
|
+
await fs.mkdir(PROJECT_PUBLIC, { recursive: true });
|
|
276
|
+
|
|
277
|
+
const GLYPH_MAPS = await Promise.all(
|
|
278
|
+
fontVariants.map(async (fontVariant) => {
|
|
279
|
+
const selectionJsonFullPath = path.resolve(
|
|
280
|
+
process.cwd(),
|
|
281
|
+
'node_modules',
|
|
282
|
+
'@phosphor-icons',
|
|
283
|
+
'web',
|
|
284
|
+
'src',
|
|
285
|
+
fontVariant,
|
|
286
|
+
'selection.json'
|
|
287
|
+
);
|
|
288
|
+
const selectionJson = JSON.parse(await fs.readFile(selectionJsonFullPath, 'utf8'));
|
|
289
|
+
|
|
290
|
+
return getUnicodeObject(selectionJson.icons);
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const GLYPH_MAP = GLYPH_MAPS.reduce((acc, curr) => {
|
|
295
|
+
return {
|
|
296
|
+
...acc,
|
|
297
|
+
...curr,
|
|
298
|
+
};
|
|
299
|
+
}, {});
|
|
300
|
+
|
|
301
|
+
const LIB_ICONS = packageJson.libraryIcons;
|
|
302
|
+
let watchers = [];
|
|
303
|
+
|
|
304
|
+
await textMateSnippet(GLYPH_MAP);
|
|
305
|
+
|
|
306
|
+
if (values.watch) {
|
|
307
|
+
const excludeFolders = ['node_modules', '.git', '.vscode', 'bin', 'assets'].concat([PROJECT_PUBLIC]);
|
|
308
|
+
const watcher = watch(PROJECT_SRC, { recursive: true }, (_, filename) => {
|
|
309
|
+
if (filename && !excludeFolders.some((folder) => resolve(join(PROJECT_SRC, filename)).includes(folder))) {
|
|
310
|
+
run(PROJECT_SRC, LIB_ICONS, PROJECT_PUBLIC, GLYPH_MAP, TARGET_FONT_TYPE, values);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
watchers.push(watcher);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (values.watchLib) {
|
|
318
|
+
const watcher = watch(packageJsonPath, {}, async (_, filename) => {
|
|
319
|
+
const updatedPackageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
320
|
+
const newLibIcons = updatedPackageJson.libraryIcons;
|
|
321
|
+
|
|
322
|
+
run(PROJECT_SRC, newLibIcons, PROJECT_PUBLIC, GLYPH_MAP, TARGET_FONT_TYPE, values);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
watchers.push(watcher);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
await run(PROJECT_SRC, LIB_ICONS, PROJECT_PUBLIC, GLYPH_MAP, TARGET_FONT_TYPE, values);
|
|
329
|
+
|
|
330
|
+
if (values.watch) {
|
|
331
|
+
process.on('SIGINT', killWatchers);
|
|
332
|
+
process.on('SIGTERM', killWatchers);
|
|
333
|
+
process.on('SIGBREAK', killWatchers);
|
|
334
|
+
}
|
|
335
|
+
function killWatchers() {
|
|
336
|
+
console.log(`✅ The icon font generation watch process has been stopped.`);
|
|
337
|
+
|
|
338
|
+
for (const watcher of watchers) {
|
|
339
|
+
watcher.close();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
process.exit(0);
|
|
343
|
+
}
|
|
344
|
+
};
|