From c993c1630b92a057b5b920640cf38304165730b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Ciccola?= Date: Tue, 13 Feb 2024 10:45:35 -0300 Subject: [PATCH 1/3] fix: sort icons so that variants are grouped together --- src/config-import.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/config-import.js b/src/config-import.js index 5d3ff2819..26e32e8e7 100644 --- a/src/config-import.js +++ b/src/config-import.js @@ -26,22 +26,15 @@ const MAX_ICON_SIZE = 10_000_000 export async function readConfig(configPath) { /** @type {Error[]} */ const warnings = [] - /** @type {yauzl.ZipFile} */ - let iconsZip - const presetsZip = await yauzl.open(configPath) - if (presetsZip.entryCount > MAX_ENTRIES) { + const zip = await yauzl.open(configPath) + if (zip.entryCount > MAX_ENTRIES) { // MAX_ENTRIES in MAC can be inacurrate throw new Error(`Zip file contains too many entries. Max is ${MAX_ENTRIES}`) } + const entries = await zip.readEntries(MAX_ENTRIES) /** @type {undefined | Entry} */ - let presetsEntry - for await (const entry of presetsZip) { - if (entry.filename === 'presets.json') { - presetsEntry = entry - break - } - } + let presetsEntry = entries.find((entry) => entry.filename === 'presets.json') if (!presetsEntry) { throw new Error('Zip file does not contain presets.json') } @@ -54,8 +47,7 @@ export async function readConfig(configPath) { }, async close() { - presetsZip.close() - iconsZip.close() + zip.close() }, /** @@ -65,10 +57,12 @@ export async function readConfig(configPath) { /** @type {IconData | undefined} */ let icon - iconsZip = await yauzl.open(configPath) - const entries = await iconsZip.readEntries(MAX_ENTRIES) - for (const entry of entries) { - if (!entry.filename.match(/^icons\/([^/]+)$/)) continue + // we sort the icons by filename so we can group variants together + const iconEntries = entries + .filter((entry) => entry.filename.match(/^icons\/([^/]+)$/)) + .sort((icon, nextIcon) => (icon.filename > nextIcon.filename ? 1 : -1)) + + for (const entry of iconEntries) { if (entry.uncompressedSize > MAX_ICON_SIZE) { warnings.push( new Error( @@ -81,14 +75,17 @@ export async function readConfig(configPath) { const iconFilename = entry.filename.replace(/^icons\//, '') try { const { name, variant } = parseIcon(iconFilename, buf) + // new icon (first pass) if (!icon) { icon = { name, variants: [variant], } + // icon already exists, push new variant } else if (icon.name === name) { icon.variants.push(variant) } else { + // icon has change yield icon icon = { name, From 4799c4b7a2a0df7f6bcf8790aebf8eabbba647f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Ciccola?= Date: Tue, 13 Feb 2024 11:36:26 -0300 Subject: [PATCH 2/3] modify icons tests adding different number of variants for different icons --- tests/config-import.js | 12 ++++++------ tests/fixtures/config/validIcons.zip | Bin 21574 -> 24690 bytes 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/config-import.js b/tests/config-import.js index 5f435c8ae..3e4f885f6 100644 --- a/tests/config-import.js +++ b/tests/config-import.js @@ -131,12 +131,12 @@ test('config import - icons', async (t) => { config = await readConfig('./tests/fixtures/config/validIcons.zip') for await (const icon of config.icons()) { - t.is(icon.name, 'plant', 'icon name is `plant`') - t.is( - icon.variants.length, - 9, - '9 variants of icons (dot product of density and size)' - ) + // t.is(icon.name, 'plant', 'icon name is `plant`') + if (icon.name === 'plant') { + t.is(icon.variants.length, 3, '3 variants of plant icons') + } else if (icon.name === 'tree') { + t.is(icon.variants.length, 9, '9 - all - variants of tree icons') + } for (let variant of icon.variants) { t.is(variant.mimeType, 'image/png', 'variant is a png') } diff --git a/tests/fixtures/config/validIcons.zip b/tests/fixtures/config/validIcons.zip index 2faecbda1c1a2ab1c9c0689dab209db15dd24d19..b178749b9d4bdc5637e1974336a6686b29bf3631 100644 GIT binary patch delta 12389 zcmeHtWmp{9)@}oh2X_e)2p-(sg1a^j!QCxLBf;HW5+pbT*Wm6>aCZxCfeUlaoSB?& zzMuEkz17d!Pj$&#yLRm*`(3N20OG6-0!cv{3WxxB*`l>%V~_}8qdfDAj2m$7Xwl))4sd;(}GAR`pK70iSwz1WZR{| z$1wd77ks}IqtX!QqZuvxi4}MablTe_NXQaEB`O&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aFA8!=r){H$7$K0)aL^lL3k9F>3Wec^ z%YsY2Ga$GoC4FwNu}T3wJ$hg_6;WCQ0i5b43`y&>w#(ix3Jybbi2Bm}ZSk&_cEEyA z)v-TXUT|(gArz)22^RyiBHumNR)m9Yrfikija)>lk{HwcPu)X@X9R}bX_>{*^6PhM zl^lX!$NIQ$MVU1eXUcyK?jXr&w6yi8xt|$Yej(OV#q9%1)cY>c5WwI|pFqs@D`BgY zRQv?|J9#4{@kjC|Nr@R;pD%HZ^gDz5S1bRYGr0d?UHzYt|9?jQ|1Tr|HwuZuDyK~l z0Dxcg&nWx{SM#Bc0D|*?be!K=M3K+Q$^ZZY!!MiviAHGBnpPhdW~d1RfT5eN1_2I? z2j$_ zls-%=5~1CbvenX&aR6hZrLaT5>JYtZWAhd3I)%e=#;|toBwfGA=LqLld;%Z<@QeOj9yA3& zl9I&V*7L6u`11!Rl|KdlPZ7`G<^JB5KTqvn$IqqyPi+2U8P<#`egluxl$>Nu;~~)G nX6bI};m%>_?(C$i^DxI>NK`c?!Nve!01h51jHEPw0p Date: Wed, 14 Feb 2024 13:28:30 -0300 Subject: [PATCH 3/3] replace comparing strings for sort with `.localCompare`, add t.plan to check if assertions have been called --- src/config-import.js | 4 +++- tests/config-import.js | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config-import.js b/src/config-import.js index 26e32e8e7..0b52db36e 100644 --- a/src/config-import.js +++ b/src/config-import.js @@ -60,7 +60,9 @@ export async function readConfig(configPath) { // we sort the icons by filename so we can group variants together const iconEntries = entries .filter((entry) => entry.filename.match(/^icons\/([^/]+)$/)) - .sort((icon, nextIcon) => (icon.filename > nextIcon.filename ? 1 : -1)) + .sort((icon, nextIcon) => + icon.filename.localeCompare(nextIcon.filename) + ) for (const entry of iconEntries) { if (entry.uncompressedSize > MAX_ICON_SIZE) { diff --git a/tests/config-import.js b/tests/config-import.js index 3e4f885f6..c414cd758 100644 --- a/tests/config-import.js +++ b/tests/config-import.js @@ -130,8 +130,8 @@ test('config import - icons', async (t) => { ) config = await readConfig('./tests/fixtures/config/validIcons.zip') + t.plan(15) // 2 icon assertions + (3+9) variant assertions + 1 no warnings for await (const icon of config.icons()) { - // t.is(icon.name, 'plant', 'icon name is `plant`') if (icon.name === 'plant') { t.is(icon.variants.length, 3, '3 variants of plant icons') } else if (icon.name === 'tree') { @@ -141,7 +141,6 @@ test('config import - icons', async (t) => { t.is(variant.mimeType, 'image/png', 'variant is a png') } } - t.is(config.warnings.length, 0, 'no warnings on the file') })