MCPcopy
hub / github.com/tldraw/tldraw / optimizeAndMergeDotcomIcons

Function optimizeAndMergeDotcomIcons

internal/scripts/refresh-assets.ts:196–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

194}
195
196async function optimizeAndMergeDotcomIcons() {
197 const sourceFolderPath = join(DOTCOM_FOLDER_PATH, 'client', 'assets', 'icons', 'icon')
198 const mergedIconName = '0_merged_tla.svg'
199
200 // this is how `svgo` starts each one of our optimized icon SVGs. if they don't all start with this,
201 // we can't merge them as it means they're of different size and are using different fill rules.
202 const mergedIconHeader =
203 '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="none">'
204
205 // Get a list of all icons
206 const icons = readdirSync(sourceFolderPath).filter((icon) => /icon-.*\.svg$/.test(icon))
207
208 const optimizedSvgs = optimizeAndMergeSvgs(
209 icons,
210 sourceFolderPath,
211 mergedIconName,
212 mergedIconHeader
213 )
214
215 const mergedIconPath = join(DOTCOM_FOLDER_PATH, 'client', 'src', 'assets')
216
217 for (const { fileName, data } of optimizedSvgs) {
218 if (fileName.includes(mergedIconName)) {
219 await writeStringFile(join(mergedIconPath, fileName), data)
220 } else {
221 await writeStringFile(join(sourceFolderPath, fileName), data)
222 }
223 }
224}
225
226// 2. EMBED-ICONS
227async function copyEmbedIcons() {

Callers 1

mainFunction · 0.85

Calls 5

writeStringFileFunction · 0.90
optimizeAndMergeSvgsFunction · 0.85
filterMethod · 0.80
testMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…