Skip to content

Commit feaffea

Browse files
committed
update img2ico
1 parent c40dac1 commit feaffea

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

packages/origine2/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
"@types/parse-path": "^7.1.0",
3838
"@uiw/react-json-view": "^2.0.0-alpha.12",
3939
"axios": "^1.6.0",
40-
"buffer": "^6.0.3",
4140
"classnames": "^2.5.1",
4241
"cloudlogjs": "^1.0.11",
43-
"img2ico": "^1.1.5",
42+
"img2ico": "^1.3.0",
4443
"lodash": "^4.17.21",
4544
"material-icon-theme": "^4.27.0",
4645
"mitt": "^3.0.1",

packages/origine2/src/components/IconCreator/IconCreator.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import axios from 'axios';
88
import { ColorPickerPopup } from '../ColorPickerPopup/ColorPickerPopup';
99
import img2ico from 'img2ico';
1010
import Transformer from '../Transformer/Transformer';
11-
import { Buffer } from 'buffer';
12-
window.Buffer = Buffer;
1311

1412
type IIconShape = 'circle' | 'square' | 'rounded-rectangle';
1513
type IBackgroundStyle = 'color' | 'image';
@@ -306,7 +304,7 @@ const IconCreator = ({ gameDir, triggerButton }: { gameDir: string, triggerButto
306304
let timeoutId: ReturnType<typeof setTimeout> | null = null;
307305

308306
if (activeIndex === 1) {
309-
const ANIMATION_DURATION = 1000;
307+
const ANIMATION_DURATION = 750;
310308

311309
timeoutId = setTimeout(() => {
312310
generateAllIcons().then(() => {
@@ -483,16 +481,15 @@ const IconCreator = ({ gameDir, triggerButton }: { gameDir: string, triggerButto
483481

484482
const webIconBlob = await resizeCanvasToBlob(webIconCanvas, 256);
485483
const webIconArrayBuffer = await webIconBlob.arrayBuffer();
486-
const webIconBuffer = Buffer.from(webIconArrayBuffer);
487-
const icoBuffer = await img2ico(webIconBuffer);
488-
const icoBlob = new Blob([icoBuffer], { type: 'image/x-icon' });
489-
const icoUrl = URL.createObjectURL(icoBlob);
484+
const icoResult = await img2ico(webIconArrayBuffer);
485+
const icoDataUrl = icoResult.toDataUrl();
486+
const icoBlob = await fetch(icoDataUrl).then(res => res.blob());
490487

491488
const previewIcons: IIcons = {
492-
ico: { name: 'Ico', src: icoUrl },
489+
ico: { name: 'Ico', src: icoDataUrl },
493490
web: { name: 'Web', src: webIconCanvas.toDataURL() },
494491
webMaskable: { name: 'Web Maskable', src: maskableCanvas.toDataURL() },
495-
desktop: { name: 'Desktop', src: icoUrl },
492+
desktop: { name: 'Desktop', src: icoDataUrl },
496493
androidForeground: { name: 'Android Foreground', src: androidForegroundCanvas.toDataURL() },
497494
androidBackground: { name: 'Android Background', src: androidBackgroundCanvas.toDataURL() },
498495
androidFullBleed: { name: 'Android Full Bleed', src: compositeCanvas.toDataURL() },
@@ -634,6 +631,7 @@ const IconCreator = ({ gameDir, triggerButton }: { gameDir: string, triggerButto
634631
<Carousel
635632
groupSize={1}
636633
activeIndex={activeIndex}
634+
motion='fade'
637635
>
638636
<CarouselViewport draggable={false}>
639637
<CarouselSlider>

packages/origine2/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export default defineConfig({
2626
'@': resolve('src'),
2727
},
2828
},
29+
optimizeDeps: {
30+
include: ['buffer'],
31+
exclude: ['img2ico'],
32+
},
2933
server: {
3034
port: WEBGAL_PORT,
3135
proxy: {

yarn.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8148,11 +8148,12 @@ image-q@^4.0.0:
81488148
dependencies:
81498149
"@types/node" "16.9.1"
81508150

8151-
img2ico@^1.1.5:
8152-
version "1.1.5"
8153-
resolved "https://registry.yarnpkg.com/img2ico/-/img2ico-1.1.5.tgz#0927cd34f43c9666edd1621060e4f81428ac569e"
8154-
integrity sha512-Zz1hd2Z5XNih1qpDdAbKRNhgkh5gUFhWIXOmWabcjvrf9G429PELO3m9E7F2S7RdWWruJVZtd2gy8dKPi2Wu6Q==
8151+
img2ico@^1.3.0:
8152+
version "1.3.0"
8153+
resolved "https://registry.yarnpkg.com/img2ico/-/img2ico-1.3.0.tgz#b879ff6abb91fff5e6dada8fba892014e13c5ac6"
8154+
integrity sha512-lknA3SgeDrz7b2Erd6s0JyEQMSp8Ay2SSMggop32SkzlN9HgM0CddnB7+FkzBAxMoJTzYafHbkp6IIJ3wNJ2Og==
81558155
dependencies:
8156+
buffer "^6.0.3"
81568157
commander "^14.0.0"
81578158
jimp "^1.6.0"
81588159

0 commit comments

Comments
 (0)